summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
commit3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch)
tree73dc228333948738bbe02976cacca8cd382bc978 /Source/WebKit/chromium/tests
parentb32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff)
downloadqtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
Diffstat (limited to 'Source/WebKit/chromium/tests')
-rw-r--r--Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp2
-rw-r--r--Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/CCDelayBasedTimeSourceTest.cpp114
-rw-r--r--Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp33
-rw-r--r--Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp3
-rw-r--r--Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/CCLayerImplTest.cpp26
-rw-r--r--Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp6
-rw-r--r--Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp488
-rw-r--r--Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp647
-rw-r--r--Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp105
-rw-r--r--Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp338
-rw-r--r--Source/WebKit/chromium/tests/CCQuadCullerTest.cpp4
-rw-r--r--Source/WebKit/chromium/tests/CCRenderSurfaceFiltersTest.cpp158
-rw-r--r--Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp9
-rw-r--r--Source/WebKit/chromium/tests/CCResourceProviderTest.cpp3
-rw-r--r--Source/WebKit/chromium/tests/CCSchedulerTestCommon.h13
-rw-r--r--Source/WebKit/chromium/tests/CCScrollbarAnimationControllerLinearFadeTest.cpp138
-rw-r--r--Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp6
-rw-r--r--Source/WebKit/chromium/tests/CCTextureUpdateControllerTest.cpp (renamed from Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp)168
-rw-r--r--Source/WebKit/chromium/tests/CCThreadedTest.cpp25
-rw-r--r--Source/WebKit/chromium/tests/CCThreadedTest.h14
-rw-r--r--Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp4
-rw-r--r--Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h8
-rw-r--r--Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp25
-rw-r--r--Source/WebKit/chromium/tests/CompositorFakeWebGraphicsContext3D.h1
-rw-r--r--Source/WebKit/chromium/tests/FakeCCGraphicsContext.h4
-rwxr-xr-xSource/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h9
-rw-r--r--Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp3
-rw-r--r--Source/WebKit/chromium/tests/FakeWebCompositorOutputSurface.h78
-rw-r--r--Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h2
-rw-r--r--Source/WebKit/chromium/tests/FakeWebScrollbarThemeGeometry.h69
-rw-r--r--Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp11
-rw-r--r--Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/IDBFakeBackingStore.h5
-rw-r--r--Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp40
-rw-r--r--Source/WebKit/chromium/tests/IDBRequestTest.cpp64
-rw-r--r--Source/WebKit/chromium/tests/LayerChromiumTest.cpp5
-rw-r--r--Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp25
-rw-r--r--Source/WebKit/chromium/tests/LocaleMacTest.cpp46
-rw-r--r--Source/WebKit/chromium/tests/LocaleWinTest.cpp69
-rw-r--r--Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp228
-rw-r--r--Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp1
-rw-r--r--Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp73
-rw-r--r--Source/WebKit/chromium/tests/TextureCopierTest.cpp4
-rw-r--r--Source/WebKit/chromium/tests/TextureLayerChromiumTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/ThrottledTextureUploaderTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp209
-rw-r--r--Source/WebKit/chromium/tests/WebAnimationTest.cpp4
-rw-r--r--Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp6
-rw-r--r--Source/WebKit/chromium/tests/WebFrameTest.cpp50
-rw-r--r--Source/WebKit/chromium/tests/WebLayerTest.cpp24
-rw-r--r--Source/WebKit/chromium/tests/WebLayerTreeViewTest.cpp20
-rw-r--r--Source/WebKit/chromium/tests/data/hello_world.html3
55 files changed, 2190 insertions, 1212 deletions
diff --git a/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp b/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp
index 854595380..f210c1bb7 100644
--- a/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp
+++ b/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp
@@ -26,9 +26,7 @@
#include "CCAnimationTestCommon.h"
-#include "GraphicsLayer.h"
#include "LayerChromium.h"
-#include "TranslateTransformOperation.h"
#include "cc/CCKeyframedAnimationCurve.h"
#include "cc/CCLayerAnimationController.h"
#include "cc/CCLayerImpl.h"
diff --git a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
index 8294ca622..8f813b9ba 100644
--- a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
@@ -55,7 +55,7 @@ void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* root, Vector<CCLay
ASSERT_FALSE(renderSurfaceLayerList.size());
CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, &layerSorter, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, root->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
}
void clearDamageForAllSurfaces(CCLayerImpl* layer)
diff --git a/Source/WebKit/chromium/tests/CCDelayBasedTimeSourceTest.cpp b/Source/WebKit/chromium/tests/CCDelayBasedTimeSourceTest.cpp
index 93e84a4af..08b5d8202 100644
--- a/Source/WebKit/chromium/tests/CCDelayBasedTimeSourceTest.cpp
+++ b/Source/WebKit/chromium/tests/CCDelayBasedTimeSourceTest.cpp
@@ -199,6 +199,120 @@ TEST(CCDelayBasedTimeSource, NextDelaySaneWhenHalfAfterRequestedTime)
EXPECT_EQ(8, thread.pendingDelayMs());
}
+// If the timebase and interval are updated with a jittery source, we want to
+// make sure we do not double tick.
+TEST(CCDelayBasedTimeSource, SaneHandlingOfJitteryTimebase)
+{
+ FakeCCThread thread;
+ FakeCCTimeSourceClient client;
+ double interval = 1.0 / 60.0;
+ RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(interval, &thread);
+ timer->setClient(&client);
+ timer->setActive(true);
+ // Run the first task, as that activates the timer and picks up a timebase.
+ thread.runPendingTask();
+
+ EXPECT_EQ(16, thread.pendingDelayMs());
+
+ // Jitter timebase ~1ms late
+ timer->setTimebaseAndInterval(interval + 0.001, interval);
+ timer->setMonotonicallyIncreasingTime(interval);
+ thread.runPendingTask();
+
+ // Without double tick prevention, pendingDelayMs would be 1.
+ EXPECT_EQ(17, thread.pendingDelayMs());
+
+ // Jitter timebase ~1ms early
+ timer->setTimebaseAndInterval(interval * 2 - 0.001, interval);
+ timer->setMonotonicallyIncreasingTime(interval * 2);
+ thread.runPendingTask();
+
+ EXPECT_EQ(15, thread.pendingDelayMs());
+}
+
+TEST(CCDelayBasedTimeSource, HanldlesSignificantTimebaseChangesImmediately)
+{
+ FakeCCThread thread;
+ FakeCCTimeSourceClient client;
+ double interval = 1.0 / 60.0;
+ RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(interval, &thread);
+ timer->setClient(&client);
+ timer->setActive(true);
+ // Run the first task, as that activates the timer and picks up a timebase.
+ thread.runPendingTask();
+
+ EXPECT_EQ(16, thread.pendingDelayMs());
+
+ // Tick, then shift timebase by +7ms.
+ timer->setMonotonicallyIncreasingTime(interval);
+ thread.runPendingTask();
+
+ EXPECT_EQ(16, thread.pendingDelayMs());
+
+ client.reset();
+ thread.runPendingTaskOnOverwrite(true);
+ timer->setTimebaseAndInterval(interval + 0.0070001, interval);
+ thread.runPendingTaskOnOverwrite(false);
+
+ EXPECT_FALSE(client.tickCalled()); // Make sure pending tasks were canceled.
+ EXPECT_EQ(7, thread.pendingDelayMs());
+
+ // Tick, then shift timebase by -7ms.
+ timer->setMonotonicallyIncreasingTime(interval + 0.0070001);
+ thread.runPendingTask();
+
+ EXPECT_EQ(16, thread.pendingDelayMs());
+
+ client.reset();
+ thread.runPendingTaskOnOverwrite(true);
+ timer->setTimebaseAndInterval(interval, interval);
+ thread.runPendingTaskOnOverwrite(false);
+
+ EXPECT_FALSE(client.tickCalled()); // Make sure pending tasks were canceled.
+ EXPECT_EQ(16-7, thread.pendingDelayMs());
+}
+
+TEST(CCDelayBasedTimeSource, HanldlesSignificantIntervalChangesImmediately)
+{
+ FakeCCThread thread;
+ FakeCCTimeSourceClient client;
+ double interval = 1.0 / 60.0;
+ RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(interval, &thread);
+ timer->setClient(&client);
+ timer->setActive(true);
+ // Run the first task, as that activates the timer and picks up a timebase.
+ thread.runPendingTask();
+
+ EXPECT_EQ(16, thread.pendingDelayMs());
+
+ // Tick, then double the interval.
+ timer->setMonotonicallyIncreasingTime(interval);
+ thread.runPendingTask();
+
+ EXPECT_EQ(16, thread.pendingDelayMs());
+
+ client.reset();
+ thread.runPendingTaskOnOverwrite(true);
+ timer->setTimebaseAndInterval(interval, interval * 2);
+ thread.runPendingTaskOnOverwrite(false);
+
+ EXPECT_FALSE(client.tickCalled()); // Make sure pending tasks were canceled.
+ EXPECT_EQ(33, thread.pendingDelayMs());
+
+ // Tick, then halve the interval.
+ timer->setMonotonicallyIncreasingTime(interval * 3);
+ thread.runPendingTask();
+
+ EXPECT_EQ(33, thread.pendingDelayMs());
+
+ client.reset();
+ thread.runPendingTaskOnOverwrite(true);
+ timer->setTimebaseAndInterval(interval * 3, interval);
+ thread.runPendingTaskOnOverwrite(false);
+
+ EXPECT_FALSE(client.tickCalled()); // Make sure pending tasks were canceled.
+ EXPECT_EQ(16, thread.pendingDelayMs());
+}
TEST(CCDelayBasedTimeSourceTest, AchievesTargetRateWithNoNoise)
{
diff --git a/Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp b/Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp
index c9a60cfaa..20f2374a3 100644
--- a/Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp
@@ -139,4 +139,37 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
EXPECT_TRUE(client.vsyncTicked());
}
+TEST(CCFrameRateControllerTest, TestFrameThrottling_Unthrottled)
+{
+ FakeCCThread thread;
+ FakeCCFrameRateControllerClient client;
+ CCFrameRateController controller(&thread);
+
+ controller.setClient(&client);
+ controller.setMaxFramesPending(2);
+
+ // setActive triggers 1st frame, make sure the vsync callback is called
+ controller.setActive(true);
+ thread.runPendingTask();
+ EXPECT_TRUE(client.vsyncTicked());
+ client.reset();
+
+ // didBeginFrame triggers 2nd frame, make sure the vsync callback is called
+ controller.didBeginFrame();
+ thread.runPendingTask();
+ EXPECT_TRUE(client.vsyncTicked());
+ client.reset();
+
+ // didBeginFrame triggers 3rd frame (> maxFramesPending), make sure the vsync callback is NOT called
+ controller.didBeginFrame();
+ thread.runPendingTask();
+ EXPECT_FALSE(client.vsyncTicked());
+ client.reset();
+
+ // didFinishFrame triggers a frame, make sure the vsync callback is called
+ controller.didFinishFrame();
+ thread.runPendingTask();
+ EXPECT_TRUE(client.vsyncTicked());
+}
+
}
diff --git a/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp b/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp
index eb6bb0363..4d2c4ddaf 100644
--- a/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp
+++ b/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp
@@ -26,9 +26,6 @@
#include "cc/CCKeyframedAnimationCurve.h"
-#include "Length.h"
-#include "TranslateTransformOperation.h"
-
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <public/WebTransformOperations.h>
diff --git a/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp b/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
index 72361092a..2ce33a561 100644
--- a/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
@@ -27,8 +27,6 @@
#include "cc/CCLayerAnimationController.h"
#include "CCAnimationTestCommon.h"
-#include "GraphicsLayer.h"
-#include "Length.h"
#include "cc/CCActiveAnimation.h"
#include "cc/CCAnimationCurve.h"
diff --git a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp
index 47edeec9d..27c4a918a 100644
--- a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp
@@ -103,6 +103,17 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly)
WebFilterOperations arbitraryFilters;
arbitraryFilters.append(WebFilterOperation::createOpacityFilter(0.5));
+ // These properties are internal, and should not be considered "change" when they are used.
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUseLCDText(true));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawOpacity(arbitraryNumber));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setRenderTarget(0));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawTransform(arbitraryTransform));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScreenSpaceTransform(arbitraryTransform));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawableContentRect(arbitraryIntRect));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUpdateRect(arbitraryFloatRect));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setVisibleContentRect(arbitraryIntRect));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaxScrollPosition(arbitraryIntSize));
+
// Changing these properties affects the entire subtree of layers.
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryFloatPoint));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPointZ(arbitraryNumber));
@@ -115,7 +126,7 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPreserves3D(true));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setDoubleSided(false)); // constructor initializes it to "true".
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->scrollBy(arbitraryIntSize));
- EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollDelta(arbitraryIntSize));
+ EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollDelta(IntSize()));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollPosition(arbitraryIntPoint));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPageScaleDelta(arbitraryNumber));
@@ -153,7 +164,7 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPreserves3D(true));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setTransform(arbitraryTransform));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDoubleSided(false)); // constructor initializes it to "true".
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollDelta(arbitraryIntSize));
+ EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollDelta(IntSize()));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollPosition(arbitraryIntPoint));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPageScaleDelta(arbitraryNumber));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentBounds(arbitraryIntSize));
@@ -164,17 +175,6 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawsContent(true));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setSublayerTransform(arbitraryTransform));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setBounds(arbitraryIntSize));
-
- // These properties are internal, and should not be considered "change" when they are used.
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setIsNonCompositedContent(true));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawOpacity(arbitraryNumber));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setRenderTarget(0));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawTransform(arbitraryTransform));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScreenSpaceTransform(arbitraryTransform));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawableContentRect(arbitraryIntRect));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUpdateRect(arbitraryFloatRect));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setVisibleContentRect(arbitraryIntRect));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaxScrollPosition(arbitraryIntSize));
}
} // namespace
diff --git a/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp b/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp
index 73fda4cb4..b5e226916 100644
--- a/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp
@@ -148,7 +148,7 @@ TEST(CCLayerIteratorTest, simpleTree)
Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer.get(), rootLayer->bounds(), 1, 256, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootLayer->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
iterateBackToFront(&renderSurfaceLayerList);
EXPECT_COUNT(rootLayer, 0, -1, 1);
@@ -191,7 +191,7 @@ TEST(CCLayerIteratorTest, complexTree)
Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer.get(), rootLayer->bounds(), 1, 256, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootLayer->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
iterateBackToFront(&renderSurfaceLayerList);
EXPECT_COUNT(rootLayer, 0, -1, 1);
@@ -247,7 +247,7 @@ TEST(CCLayerIteratorTest, complexTreeMultiSurface)
Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer.get(), rootLayer->bounds(), 1, 256, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootLayer->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
iterateBackToFront(&renderSurfaceLayerList);
EXPECT_COUNT(rootLayer, 0, -1, 1);
diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
index 9e249f2d7..9fd226858 100644
--- a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
@@ -30,7 +30,6 @@
#include "CCLayerTreeTestCommon.h"
#include "ContentLayerChromium.h"
#include "LayerChromium.h"
-#include "TranslateTransformOperation.h"
#include "cc/CCLayerAnimationController.h"
#include "cc/CCLayerImpl.h"
#include "cc/CCLayerSorter.h"
@@ -80,7 +79,7 @@ void executeCalculateDrawTransformsAndVisibility(LayerChromium* rootLayer)
// We are probably not testing what is intended if the rootLayer bounds are empty.
ASSERT(!rootLayer->bounds().isEmpty());
CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, rootLayer->bounds(), 1, dummyMaxTextureSize, dummyRenderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(dummyRenderSurfaceLayerList, rootLayer->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(dummyRenderSurfaceLayerList);
}
void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* rootLayer)
@@ -94,7 +93,7 @@ void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* rootLayer)
// We are probably not testing what is intended if the rootLayer bounds are empty.
ASSERT(!rootLayer->bounds().isEmpty());
CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, rootLayer->bounds(), 1, 0, dummyMaxTextureSize, dummyRenderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(dummyRenderSurfaceLayerList, rootLayer->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(dummyRenderSurfaceLayerList);
}
WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix& mat)
@@ -359,344 +358,6 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface)
EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarget()->renderSurface()->screenSpaceTransform());
}
-TEST(CCLayerTreeHostCommonTest, scissorRectWithClip)
-{
- DebugScopedSetImplThread thisScopeIsOnImplThread;
-
- /*
- Layers are created as follows:
-
- +--------------------+
- | 1 |
- | +-----------+ |
- | | 2 | |
- | | +-------------------+
- | | | 3 |
- | | +-------------------+
- | | | |
- | +-----------+ |
- | |
- | |
- +--------------------+
-
- Layers 1, 2 have render surfaces
- */
- OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
- OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2);
- OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3);
-
- IntRect rootRect(0, 0, 100, 100);
- IntRect childRect(10, 10, 50, 50);
- IntRect grandChildRect(5, 5, 150, 150);
-
- root->setAnchorPoint(FloatPoint(0, 0));
- root->setPosition(FloatPoint(rootRect.x(), rootRect.y()));
- root->setBounds(IntSize(rootRect.width(), rootRect.height()));
- root->setContentBounds(root->bounds());
- root->setDrawsContent(true);
-
- child->setAnchorPoint(FloatPoint(0, 0));
- child->setPosition(FloatPoint(childRect.x(), childRect.y()));
- child->setOpacity(0.5);
- child->setBounds(IntSize(childRect.width(), childRect.height()));
- child->setContentBounds(child->bounds());
- child->setDrawsContent(true);
-
- grandChild->setAnchorPoint(FloatPoint(0, 0));
- grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y()));
- grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height()));
- grandChild->setContentBounds(grandChild->bounds());
- grandChild->setDrawsContent(true);
-
- CCLayerImpl* childPtr = child.get();
- CCLayerImpl* grandChildPtr = grandChild.get();
-
- child->addChild(grandChild.release());
- root->addChild(child.release());
-
- root->setMasksToBounds(true);
-
- Vector<CCLayerImpl*> renderSurfaceLayerList;
- {
- int dummyMaxTextureSize = 512;
- CCLayerSorter layerSorter;
- CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, &layerSorter, dummyMaxTextureSize, renderSurfaceLayerList);
-
- FloatRect dummyDamageRect;
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, dummyDamageRect);
- }
-
- ASSERT_TRUE(childPtr->renderSurface());
- ASSERT_TRUE(root->renderSurface());
- ASSERT_FALSE(grandChildPtr->renderSurface());
-
- EXPECT_EQ(renderSurfaceLayerList.size(), 2U);
-
- ASSERT_EQ(root->renderSurface()->clipRect(), rootRect);
- // Child surface's clipping rect is now set to root's
- ASSERT_EQ(childPtr->renderSurface()->clipRect(), rootRect);
-
- // Damage the entire screen
- IntRect rootDamage(rootRect);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
- // Child's renderSurface would have expanded to include the 150x150 grandChild located at (5, 5), and then have been clipped by the parent.
- IntRect expectedChildRenderSurfaceScissor = intersection(rootRect, IntRect(10, 10, 155, 155));
- EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), expectedChildRenderSurfaceScissor);
-
- EXPECT_EQ(root->scissorRect(), IntRect(rootRect));
-
- // The child layer is not clipped by anything (that clip is already represented by the rootSurface clipping the child's surface)
- // So here, the expected scissor is just the child layer's rect expressed in targetSurface (child surface) space.
- EXPECT_EQ(childPtr->scissorRect(), IntRect(0, 0, childRect.width(), childRect.height()));
-
- // Grand child is (indirectly) clipped by the root surface. But the scissor is expressed in the targetSurface (child surface) space.
- EXPECT_INT_RECT_EQ(grandChildPtr->scissorRect(), IntRect(5, 5, 85, 85));
-
- // Empty damage
- rootDamage = IntRect(0, 0, 0, 0);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- // Empty damage == empty scissor
- EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
- EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
-
- EXPECT_EQ(root->scissorRect(), IntRect(0, 0, 0, 0));
- EXPECT_EQ(childPtr->scissorRect(), IntRect(0, 0, 0, 0));
- EXPECT_EQ(grandChildPtr->scissorRect(), IntRect(0, 0, 0, 0));
-
- // Partial damage within child
- rootDamage = IntRect(10, 10, 20, 20);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- // Scissors are not computed for root
- EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
-
- // Entire damage rect is within the root surface
- EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage);
-
- // Entire damage rect is within the layer
- EXPECT_EQ(root->scissorRect(), rootDamage);
-
- // Entire damage rect is within the layer, but with different offset
- EXPECT_EQ(childPtr->scissorRect(), IntRect(rootDamage.x() - childRect.x(), rootDamage.y() - childRect.y(), rootDamage.width(), rootDamage.height()));
-
- // Grand child scissor is the damage intersected with the clipped grandChild layer rect (expressed in targetSurface space).
- EXPECT_EQ(grandChildPtr->scissorRect(), IntRect(5, 5, 15, 15));
-
- // Partial damage beyond child
- rootDamage = IntRect(10, 10, 80, 80);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- // Scissors are not computed for root
- EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
-
- // Entire damage rect is within the root surface
- EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage);
-
- // Entire damage rect is within the layer
- EXPECT_EQ(root->scissorRect(), rootDamage);
-
- // Child layer overlaps a portion of the damage rect.
- EXPECT_INT_RECT_EQ(childPtr->scissorRect(), IntRect(rootDamage.x() - childRect.x(), rootDamage.y() - childRect.y(), childRect.width(), childRect.height()));
-
- // Grand child scissor is the intersection of damage and grandChild rect, expressed in child surface.
- // The damage fits entirely within the grandChild.
- EXPECT_INT_RECT_EQ(grandChildPtr->scissorRect(), IntRect(5, 5, 75, 75));
-
- // Partial damage beyond root
- rootDamage = IntRect(10, 10, 110, 110);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- // Scissors are not computed for root
- EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
-
- // Root damage rect is clipped at root layer boundary.
- EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y()));
- EXPECT_EQ(root->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y()));
-
- // Now the scissor rects are clipped by surfaces contentRect
- EXPECT_INT_RECT_EQ(childPtr->scissorRect(), IntRect(rootDamage.x() - childRect.x(), rootDamage.y() - childRect.y(), childRect.width(), childRect.height()));
- EXPECT_INT_RECT_EQ(grandChildPtr->scissorRect(), IntRect(5, 5, 105, 105));
-}
-
-TEST(CCLayerTreeHostCommonTest, scissorRectWithClipAndSpaceTransform)
-{
- DebugScopedSetImplThread thisScopeIsOnImplThread;
-
- /*
- Layers are created as follows:
-
- +--------------------+
- | 1 |
- | +-----------+ |
- | | 2 | |
- | | +-------------------+
- | | | 3,4 |
- | | +-------------------+
- | | | |
- | +-----------+ |
- | |
- | |
- +--------------------+
-
- Layers 1, 2 and 3 have render surfaces
- */
- OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
- OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2);
- OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3);
- OwnPtr<CCLayerImpl> grandChild2 = CCLayerImpl::create(4);
-
- IntRect rootRect(0, 0, 100, 100);
- IntRect childRect(10, 10, 50, 50);
- IntRect grandChildRect(5, 5, 150, 150);
-
- root->setAnchorPoint(FloatPoint(0, 0));
- root->setPosition(FloatPoint(rootRect.x(), rootRect.y()));
- root->setBounds(IntSize(rootRect.width(), rootRect.height()));
- root->setContentBounds(root->bounds());
- root->setDrawsContent(true);
-
- child->setAnchorPoint(FloatPoint(0, 0));
- child->setPosition(FloatPoint(childRect.x(), childRect.y()));
- child->setOpacity(0.5);
- child->setBounds(IntSize(childRect.width(), childRect.height()));
- child->setContentBounds(child->bounds());
- child->setDrawsContent(true);
-
- grandChild->setAnchorPoint(FloatPoint(0, 0));
- grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y()));
- grandChild->setOpacity(0.5);
- grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height()));
- grandChild->setContentBounds(grandChild->bounds());
- grandChild->setDrawsContent(true);
-
- grandChild2->setAnchorPoint(FloatPoint(0, 0));
- grandChild2->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y()));
- grandChild2->setOpacity(0.5);
- grandChild2->setBounds(IntSize(grandChildRect.width(), grandChildRect.height()));
- grandChild2->setContentBounds(grandChild2->bounds());
- grandChild2->setDrawsContent(true);
-
- CCLayerImpl* childPtr = child.get();
- CCLayerImpl* grandChildPtr = grandChild.get();
-
- grandChild->addChild(grandChild2.release());
- child->addChild(grandChild.release());
- root->addChild(child.release());
-
- root->setMasksToBounds(true);
-
- Vector<CCLayerImpl*> renderSurfaceLayerList;
- {
- int dummyMaxTextureSize = 512;
- CCLayerSorter layerSorter;
- CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, &layerSorter, dummyMaxTextureSize, renderSurfaceLayerList);
-
- FloatRect dummyDamageRect;
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, dummyDamageRect);
- }
-
- ASSERT_TRUE(childPtr->renderSurface());
- ASSERT_TRUE(root->renderSurface());
- ASSERT_TRUE(grandChildPtr->renderSurface());
-
- EXPECT_EQ(renderSurfaceLayerList.size(), 3U);
-
- EXPECT_INT_RECT_EQ(root->renderSurface()->clipRect(), rootRect);
- // Child surface's clipping rect is now set to root's
- EXPECT_INT_RECT_EQ(childPtr->renderSurface()->clipRect(), rootRect);
-
- // Damage the entire screen
- IntRect rootDamage(rootRect);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- ASSERT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
- // Child's renderSurface would have expanded to include the grandChild1 and grandChild2, and then have been clipped by the parent.
- IntRect expectedChildRenderSurfaceScissor = intersection(rootRect, IntRect(10, 10, 160, 160));
- ASSERT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), expectedChildRenderSurfaceScissor);
-
- EXPECT_EQ(root->scissorRect(), IntRect(rootRect));
-
- // The child layer is not clipped by anything (that clip is already represented by the rootSurface clipping the child's surface)
- // So here, the expected scissor is just the child layer's rect expressed in targetSurface (child surface) space.
- EXPECT_EQ(childPtr->scissorRect(), IntRect(0, 0, childRect.width(), childRect.height()));
-
- // Grand child now draws to its own render surface, so the scissorRect is in that surface's space.
- EXPECT_EQ(grandChildPtr->scissorRect(), IntRect(0, 0, rootRect.width() - childRect.x() - grandChildRect.x(), rootRect.height() - childRect.y() - grandChildRect.y()));
-
- // Empty damage
- rootDamage = IntRect(0, 0, 0, 0);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- // Empty damage == empty scissor
- EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
- EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
-
- EXPECT_EQ(root->scissorRect(), IntRect(0, 0, 0, 0));
- EXPECT_EQ(childPtr->scissorRect(), IntRect(0, 0, 0, 0));
- EXPECT_EQ(grandChildPtr->scissorRect(), IntRect(0, 0, 0, 0));
-
- // Partial damage within child
- rootDamage = IntRect(10, 10, 20, 20);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- // Scissors are not computed for root
- EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
-
- // Entire damage rect is within the root surface
- EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage);
-
- // Entire damage rect is within the layer
- EXPECT_EQ(root->scissorRect(), rootDamage);
-
- // Entire damage rect is within the layer, but with different offset
- EXPECT_EQ(childPtr->scissorRect(), IntRect(rootDamage.x() - childRect.x(), rootDamage.y() - childRect.y(), rootDamage.width(), rootDamage.height()));
-
- // Grand child now gets scissored by its target surface as well as root
- EXPECT_EQ(grandChildPtr->scissorRect(), IntRect(rootDamage.x() - childRect.x(), rootDamage.y() - childRect.y(), rootDamage.width() - grandChildRect.x(), rootDamage.height() - grandChildRect.y()));
-
- // Partial damage beyond child
- rootDamage = IntRect(10, 10, 80, 80);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- // Scissors are not computed for root
- EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
-
- // Entire damage rect is within the root surface
- EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage);
-
- // Entire damage rect is within the layer
- EXPECT_EQ(root->scissorRect(), rootDamage);
-
- // Entire damage rect is within the layer, but it is still clipped with respect to the root.
- EXPECT_INT_RECT_EQ(childPtr->scissorRect(), IntRect(rootDamage.x() - childRect.x(), rootDamage.y() - childRect.y(), childRect.width(), childRect.height()));
-
- // Grand child now gets scissored by its target surface as well as root
- EXPECT_EQ(grandChildPtr->scissorRect(), IntRect(rootDamage.x() - childRect.x(), rootDamage.y() - childRect.y(), rootDamage.width() - grandChildRect.x(), rootDamage.height() - grandChildRect.y()));
-
- // Partial damage beyond root
- rootDamage = IntRect(10, 10, 110, 110);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage);
-
- // Scissors are not computed for root
- EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0));
-
- // Root surface does not have a clipRect, so its contentRect will be used to intersect with damage.
- // Result is that root damage rect is clipped at root layer boundary
- EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y()));
-
- // Root does not use layer clipping, so its content rect will be used to intersect with damage
- // Result is that root damage rect is clipped at root layer boundary
- EXPECT_EQ(root->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y()));
-
- EXPECT_INT_RECT_EQ(childPtr->scissorRect(), IntRect(rootDamage.x() - childRect.x(), rootDamage.y() - childRect.y(), childRect.width(), childRect.height()));
-
- // Grandchild's scissor rect is clipped by its target surface
- EXPECT_EQ(grandChildPtr->scissorRect(), IntRect(rootDamage.x() - childRect.x(), rootDamage.y() - childRect.y(), rootDamage.width() - grandChildRect.x(), rootDamage.height() - grandChildRect.y()));
-}
-
TEST(CCLayerTreeHostCommonTest, verifyTransformsForReplica)
{
RefPtr<LayerChromium> parent = LayerChromium::create();
@@ -903,6 +564,51 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy)
EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42());
}
+TEST(CCLayerTreeHostCommonTest, verifyTransformsForFlatteningLayer)
+{
+ // For layers that flatten their subtree, there should be an orthographic projection
+ // (for x and y values) in the middle of the transform sequence. Note that the way the
+ // code is currently implemented, it is not expected to use a canonical orthographic
+ // projection.
+
+ RefPtr<LayerChromium> root = LayerChromium::create();
+ RefPtr<LayerChromium> child = LayerChromium::create();
+ RefPtr<LayerChromiumWithForcedDrawsContent> grandChild = adoptRef(new LayerChromiumWithForcedDrawsContent());
+
+ WebTransformationMatrix rotationAboutYAxis;
+ rotationAboutYAxis.rotate3d(0, 30, 0);
+
+ const WebTransformationMatrix identityMatrix;
+ setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(100, 100), false);
+ setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false);
+ setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityMatrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false);
+
+ root->addChild(child);
+ child->addChild(grandChild);
+ child->setForceRenderSurface(true);
+
+ // No layers in this test should preserve 3d.
+ ASSERT_FALSE(root->preserves3D());
+ ASSERT_FALSE(child->preserves3D());
+ ASSERT_FALSE(grandChild->preserves3D());
+
+ WebTransformationMatrix expectedChildDrawTransform = rotationAboutYAxis;
+ WebTransformationMatrix expectedChildScreenSpaceTransform = rotationAboutYAxis;
+ WebTransformationMatrix expectedGrandChildDrawTransform = rotationAboutYAxis; // draws onto child's renderSurface
+ WebTransformationMatrix expectedGrandChildScreenSpaceTransform = rotationAboutYAxis.to2dTransform() * rotationAboutYAxis;
+
+ executeCalculateDrawTransformsAndVisibility(root.get());
+
+ // The child's drawTransform should have been taken by its surface.
+ ASSERT_TRUE(child->renderSurface());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSurface()->drawTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->renderSurface()->screenSpaceTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->screenSpaceTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild->drawTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, grandChild->screenSpaceTransform());
+}
+
TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClippedLayer)
{
RefPtr<LayerChromium> parent = LayerChromium::create();
@@ -921,7 +627,7 @@ TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipp
Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, parent->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// The child layer's content is entirely outside the parent's clip rect, so the intermediate
// render surface should not be listed here, even if it was forced to be created. Render surfaces without children or visible
@@ -949,7 +655,7 @@ TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild)
Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, parent->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Since the layer is transparent, renderSurface1->renderSurface() should not have gotten added anywhere.
// Also, the drawable content rect should not have been extended by the children.
@@ -1605,7 +1311,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces)
Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, parent->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
ASSERT_EQ(2U, renderSurfaceLayerList.size());
@@ -1718,9 +1424,7 @@ TEST(CCLayerTreeHostCommonTest, verifyDrawableContentRectForLayers)
Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, dummyMaxTextureSize, renderSurfaceLayerList);
-
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, parent->renderSurface()->contentRect());
-
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
EXPECT_INT_RECT_EQ(IntRect(IntPoint(5, 5), IntSize(10, 10)), grandChild1->drawableContentRect());
EXPECT_INT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawableContentRect());
@@ -1786,8 +1490,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces)
Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, dummyMaxTextureSize, renderSurfaceLayerList);
-
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, parent->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
ASSERT_TRUE(grandChild1->renderSurface());
ASSERT_TRUE(grandChild2->renderSurface());
@@ -2438,8 +2141,7 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms)
Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, dummyMaxTextureSize, renderSurfaceLayerList);
-
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, parent->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
EXPECT_FALSE(child->renderSurface());
EXPECT_TRUE(animatingSurface->renderSurface());
@@ -2560,7 +2262,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleLayer)
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2610,7 +2312,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2665,7 +2367,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer)
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2713,7 +2415,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer)
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2770,7 +2472,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer)
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2835,7 +2537,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
// The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25.
@@ -2900,7 +2602,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer)
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2991,7 +2693,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer)
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
// The grandChild is expected to create a renderSurface because it masksToBounds and is not axis aligned.
@@ -3039,6 +2741,70 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer)
EXPECT_EQ(2468, resultLayer->id());
}
+TEST(CCLayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer)
+{
+ // This test checks that hit testing code does not accidentally clip to layer
+ // bounds for a layer that actually does not clip.
+ DebugScopedSetImplThread thisScopeIsOnImplThread;
+
+ WebTransformationMatrix identityMatrix;
+ FloatPoint anchor(0, 0);
+
+ OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
+ setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anchor, FloatPoint(0, 0), IntSize(100, 100), false);
+
+ {
+ OwnPtr<CCLayerImpl> intermediateLayer = CCLayerImpl::create(123);
+ FloatPoint position(10, 10); // this layer is positioned, and hit testing should correctly know where the layer is located.
+ IntSize bounds(50, 50);
+ setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, identityMatrix, anchor, position, bounds, false);
+ // Sanity check the intermediate layer should not clip.
+ ASSERT_FALSE(intermediateLayer->masksToBounds());
+ ASSERT_FALSE(intermediateLayer->maskLayer());
+
+ // The child of the intermediateLayer is translated so that it does not overlap intermediateLayer at all.
+ // If child is incorrectly clipped, we would not be able to hit it successfully.
+ OwnPtr<CCLayerImpl> child = CCLayerImpl::create(456);
+ position = FloatPoint(60, 60); // 70, 70 in screen space
+ bounds = IntSize(20, 20);
+ setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, anchor, position, bounds, false);
+ child->setDrawsContent(true);
+ intermediateLayer->addChild(child.release());
+ root->addChild(intermediateLayer.release());
+ }
+
+ Vector<CCLayerImpl*> renderSurfaceLayerList;
+ int dummyMaxTextureSize = 512;
+ CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
+
+ // Sanity check the scenario we just created.
+ ASSERT_EQ(1u, renderSurfaceLayerList.size());
+ ASSERT_EQ(1u, root->renderSurface()->layerList().size());
+ ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id());
+
+ // Hit testing for a point outside the layer should return a null pointer.
+ IntPoint testPoint(69, 69);
+ CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+ EXPECT_FALSE(resultLayer);
+
+ testPoint = IntPoint(91, 91);
+ resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+ EXPECT_FALSE(resultLayer);
+
+ // Hit testing for a point inside should return the child layer.
+ testPoint = IntPoint(71, 71);
+ resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+ ASSERT_TRUE(resultLayer);
+ EXPECT_EQ(456, resultLayer->id());
+
+ testPoint = IntPoint(89, 89);
+ resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList);
+ ASSERT_TRUE(resultLayer);
+ EXPECT_EQ(456, resultLayer->id());
+}
+
+
TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayers)
{
DebugScopedSetImplThread thisScopeIsOnImplThread;
@@ -3091,7 +2857,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayers)
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_TRUE(child1);
@@ -3200,7 +2966,7 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists)
Vector<CCLayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, FloatRect()); // empty scissorRect will help ensure we're hit testing the correct rect.
+ CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_TRUE(child1);
diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
index 53c312cf5..2c14a1cc3 100644
--- a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
@@ -30,8 +30,11 @@
#include "CCLayerTestCommon.h"
#include "CCLayerTreeTestCommon.h"
#include "CCTestCommon.h"
+#include "FakeWebCompositorOutputSurface.h"
#include "FakeWebGraphicsContext3D.h"
+#include "FakeWebScrollbarThemeGeometry.h"
#include "LayerRendererChromium.h"
+#include "cc/CCHeadsUpDisplayLayerImpl.h"
#include "cc/CCIOSurfaceLayerImpl.h"
#include "cc/CCLayerImpl.h"
#include "cc/CCLayerTilingData.h"
@@ -74,11 +77,12 @@ public:
m_hostImpl = CCLayerTreeHostImpl::create(settings, this);
m_hostImpl->initializeLayerRenderer(createContext(), UnthrottledUploader);
- m_hostImpl->setViewportSize(IntSize(10, 10));
+ m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10));
}
virtual void didLoseContextOnImplThread() OVERRIDE { }
virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
+ virtual void onVSyncParametersChanged(double, double) OVERRIDE { }
virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = true; }
virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = true; }
virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE { }
@@ -93,7 +97,7 @@ public:
OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
myHostImpl->initializeLayerRenderer(graphicsContext, UnthrottledUploader);
- myHostImpl->setViewportSize(IntSize(10, 10));
+ myHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10));
OwnPtr<CCLayerImpl> root = rootPtr;
@@ -174,7 +178,7 @@ public:
protected:
PassOwnPtr<CCGraphicsContext> createContext()
{
- return CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3D));
+ return FakeWebCompositorOutputSurface::create(adoptPtr(new FakeWebGraphicsContext3D));
}
DebugScopedSetImplThread m_alwaysImplThread;
@@ -256,7 +260,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
{
setupScrollAndContentsLayers(IntSize(100, 100));
- m_hostImpl->setViewportSize(IntSize(50, 50));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeLayerRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
@@ -277,7 +281,7 @@ TEST_F(CCLayerTreeHostImplTest, replaceTreeWhileScrolling)
const int scrollLayerId = 1;
setupScrollAndContentsLayers(IntSize(100, 100));
- m_hostImpl->setViewportSize(IntSize(50, 50));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeLayerRendererAndDrawFrame();
// We should not crash if the tree is replaced while we are scrolling.
@@ -297,7 +301,7 @@ TEST_F(CCLayerTreeHostImplTest, replaceTreeWhileScrolling)
TEST_F(CCLayerTreeHostImplTest, clearRootRenderSurfaceAndScroll)
{
setupScrollAndContentsLayers(IntSize(100, 100));
- m_hostImpl->setViewportSize(IntSize(50, 50));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeLayerRendererAndDrawFrame();
// We should be able to scroll even if the root layer loses its render surface after the most
@@ -309,7 +313,7 @@ TEST_F(CCLayerTreeHostImplTest, clearRootRenderSurfaceAndScroll)
TEST_F(CCLayerTreeHostImplTest, wheelEventHandlers)
{
setupScrollAndContentsLayers(IntSize(100, 100));
- m_hostImpl->setViewportSize(IntSize(50, 50));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeLayerRendererAndDrawFrame();
CCLayerImpl* root = m_hostImpl->rootLayer();
@@ -325,7 +329,7 @@ TEST_F(CCLayerTreeHostImplTest, wheelEventHandlers)
TEST_F(CCLayerTreeHostImplTest, shouldScrollOnMainThread)
{
setupScrollAndContentsLayers(IntSize(100, 100));
- m_hostImpl->setViewportSize(IntSize(50, 50));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeLayerRendererAndDrawFrame();
CCLayerImpl* root = m_hostImpl->rootLayer();
@@ -338,7 +342,7 @@ TEST_F(CCLayerTreeHostImplTest, shouldScrollOnMainThread)
TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionBasic)
{
setupScrollAndContentsLayers(IntSize(200, 200));
- m_hostImpl->setViewportSize(IntSize(100, 100));
+ m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100));
initializeLayerRendererAndDrawFrame();
CCLayerImpl* root = m_hostImpl->rootLayer();
@@ -360,7 +364,7 @@ TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionBasic)
TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset)
{
setupScrollAndContentsLayers(IntSize(200, 200));
- m_hostImpl->setViewportSize(IntSize(100, 100));
+ m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100));
CCLayerImpl* root = m_hostImpl->rootLayer();
root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50));
@@ -379,7 +383,7 @@ TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset)
TEST_F(CCLayerTreeHostImplTest, pinchGesture)
{
setupScrollAndContentsLayers(IntSize(100, 100));
- m_hostImpl->setViewportSize(IntSize(50, 50));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeLayerRendererAndDrawFrame();
CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
@@ -460,7 +464,7 @@ TEST_F(CCLayerTreeHostImplTest, pinchGesture)
TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation)
{
setupScrollAndContentsLayers(IntSize(100, 100));
- m_hostImpl->setViewportSize(IntSize(50, 50));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeLayerRendererAndDrawFrame();
CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
@@ -510,7 +514,7 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation)
TEST_F(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
{
setupScrollAndContentsLayers(IntSize(100, 100));
- m_hostImpl->setViewportSize(IntSize(50, 50));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeLayerRendererAndDrawFrame();
CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
@@ -564,7 +568,7 @@ TEST_F(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZoomin
TEST_F(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPageScale)
{
setupScrollAndContentsLayers(IntSize(100, 100));
- m_hostImpl->setViewportSize(IntSize(50, 50));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeLayerRendererAndDrawFrame();
CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
@@ -696,7 +700,7 @@ TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer)
TEST_F(CCLayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer)
{
IntSize bigSize(1000, 1000);
- m_hostImpl->setViewportSize(bigSize);
+ m_hostImpl->setViewportSize(bigSize, bigSize);
m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
@@ -841,7 +845,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollNonCompositedRoot)
IntSize surfaceSize(10, 10);
OwnPtr<CCLayerImpl> contentLayer = CCLayerImpl::create(1);
- contentLayer->setIsNonCompositedContent(true);
+ contentLayer->setUseLCDText(true);
contentLayer->setDrawsContent(true);
contentLayer->setPosition(FloatPoint(0, 0));
contentLayer->setAnchorPoint(FloatPoint(0, 0));
@@ -858,7 +862,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollNonCompositedRoot)
scrollLayer->addChild(contentLayer.release());
m_hostImpl->setRootLayer(scrollLayer.release());
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeLayerRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
@@ -876,7 +880,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
root->setContentBounds(surfaceSize);
root->addChild(createScrollableLayer(2, FloatPoint(0, 0), surfaceSize));
m_hostImpl->setRootLayer(root.release());
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeLayerRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
@@ -892,7 +896,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollMissesChild)
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
root->addChild(createScrollableLayer(2, FloatPoint(0, 0), surfaceSize));
m_hostImpl->setRootLayer(root.release());
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeLayerRendererAndDrawFrame();
// Scroll event is ignored because the input coordinate is outside the layer boundaries.
@@ -906,7 +910,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild)
IntSize surfaceSize(10, 10);
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(0, 0), surfaceSize);
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
WebTransformationMatrix matrix;
matrix.rotate3d(180, 0, 0);
@@ -935,7 +939,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollBlockedByContentLayer)
scrollLayer->addChild(contentLayer.release());
m_hostImpl->setRootLayer(scrollLayer.release());
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeLayerRendererAndDrawFrame();
// Scrolling fails because the content layer is asking to be scrolled on the main thread.
@@ -948,7 +952,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
float pageScale = 2;
OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(0, 0), surfaceSize);
m_hostImpl->setRootLayer(root.release());
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeLayerRendererAndDrawFrame();
IntSize scrollDelta(0, 10);
@@ -979,7 +983,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
float pageScale = 2;
OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(0, 0), surfaceSize);
m_hostImpl->setRootLayer(root.release());
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
initializeLayerRendererAndDrawFrame();
@@ -1057,7 +1061,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
int scrollLayerId = 2;
root->addChild(createScrollableLayer(scrollLayerId, FloatPoint(0, 0), surfaceSize));
m_hostImpl->setRootLayer(root.release());
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeLayerRendererAndDrawFrame();
CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0].get();
@@ -1101,7 +1105,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit)
root->addChild(child.release());
m_hostImpl->setRootLayer(root.release());
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeLayerRendererAndDrawFrame();
{
IntSize scrollDelta(-3, -7);
@@ -1133,7 +1137,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling)
root->addChild(child.release());
m_hostImpl->setRootLayer(root.release());
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeLayerRendererAndDrawFrame();
{
IntSize scrollDelta(0, 4);
@@ -1153,7 +1157,7 @@ TEST_F(CCLayerTreeHostImplTest, scrollBeforeRedraw)
{
IntSize surfaceSize(10, 10);
m_hostImpl->setRootLayer(createScrollableLayer(1, FloatPoint(0, 0), surfaceSize));
- m_hostImpl->setViewportSize(surfaceSize);
+ m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
// Draw one frame and then immediately rebuild the layer tree to mimic a tree synchronization.
initializeLayerRendererAndDrawFrame();
@@ -1471,7 +1475,7 @@ TEST_F(CCLayerTreeHostImplTest, viewportCovered)
m_hostImpl->setBackgroundColor(SK_ColorGRAY);
IntSize viewportSize(1000, 1000);
- m_hostImpl->setViewportSize(viewportSize);
+ m_hostImpl->setViewportSize(viewportSize, viewportSize);
m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1, m_hostImpl->resourceProvider()));
BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl->rootLayer());
@@ -1576,7 +1580,7 @@ public:
// viewport size is never set.
TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw)
{
- OwnPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(adoptPtr(new ReshapeTrackerContext));
+ OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create(adoptPtr(new ReshapeTrackerContext));
ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(ccContext->context3D());
m_hostImpl->initializeLayerRenderer(ccContext.release(), UnthrottledUploader);
@@ -1619,7 +1623,7 @@ private:
// where it should request to swap only the subBuffer that is damaged.
TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect)
{
- OwnPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(adoptPtr(new PartialSwapTrackerContext));
+ OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapTrackerContext));
PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(ccContext->context3D());
// This test creates its own CCLayerTreeHostImpl, so
@@ -1628,7 +1632,7 @@ TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect)
CCSettings::setPartialSwapEnabled(true);
OwnPtr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::create(settings, this);
layerTreeHostImpl->initializeLayerRenderer(ccContext.release(), UnthrottledUploader);
- layerTreeHostImpl->setViewportSize(IntSize(500, 500));
+ layerTreeHostImpl->setViewportSize(IntSize(500, 500), IntSize(500, 500));
CCLayerImpl* root = new FakeDrawableCCLayerImpl(1);
CCLayerImpl* child = new FakeDrawableCCLayerImpl(2);
@@ -1677,7 +1681,7 @@ TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect)
// Make sure that partial swap is constrained to the viewport dimensions
// expected damage rect: IntRect(IntPoint::zero(), IntSize(500, 500));
// expected swap rect: flipped damage rect, but also clamped to viewport
- layerTreeHostImpl->setViewportSize(IntSize(10, 10));
+ layerTreeHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10));
root->setOpacity(0.7f); // this will damage everything
EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame));
layerTreeHostImpl->drawLayers(frame);
@@ -1748,6 +1752,7 @@ public:
MOCK_METHOD1(getString, WebString(WGC3Denum name));
MOCK_METHOD0(getRequestableExtensionsCHROMIUM, WebString());
MOCK_METHOD1(enable, void(WGC3Denum cap));
+ MOCK_METHOD1(disable, void(WGC3Denum cap));
MOCK_METHOD4(scissor, void(WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height));
};
@@ -1786,6 +1791,10 @@ public:
// Any un-sanctioned calls to enable() are OK
EXPECT_CALL(*m_context, enable(_))
.WillRepeatedly(Return());
+
+ // Any un-sanctioned calls to disable() are OK
+ EXPECT_CALL(*m_context, disable(_))
+ .WillRepeatedly(Return());
}
void mustDrawSolidQuad()
@@ -1811,16 +1820,27 @@ public:
.WillRepeatedly(Return());
}
+ void mustSetNoScissor()
+ {
+ EXPECT_CALL(*m_context, disable(GraphicsContext3D::SCISSOR_TEST))
+ .WillRepeatedly(Return());
+
+ EXPECT_CALL(*m_context, enable(GraphicsContext3D::SCISSOR_TEST))
+ .Times(0);
+
+ EXPECT_CALL(*m_context, scissor(_, _, _, _))
+ .Times(0);
+ }
};
TEST_F(CCLayerTreeHostImplTest, noPartialSwap)
{
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new MockContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new MockContext));
MockContext* mockContext = static_cast<MockContext*>(context->context3D());
MockContextHarness harness(mockContext);
harness.mustDrawSolidQuad();
- harness.mustSetScissor(0, 0, 10, 10);
+ harness.mustSetNoScissor();
// Run test case
OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context.release(), FakeLayerWithQuads::create(1));
@@ -1834,50 +1854,35 @@ TEST_F(CCLayerTreeHostImplTest, noPartialSwap)
TEST_F(CCLayerTreeHostImplTest, partialSwap)
{
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new MockContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new MockContext));
MockContext* mockContext = static_cast<MockContext*>(context->context3D());
MockContextHarness harness(mockContext);
- harness.mustDrawSolidQuad();
- harness.mustSetScissor(0, 0, 10, 10);
-
OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context.release(), FakeLayerWithQuads::create(1));
- CCLayerTreeHostImpl::FrameData frame;
- EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
- myHostImpl->drawLayers(frame);
- myHostImpl->didDrawAllLayers(frame);
+ // The first frame is not a partially-swapped one.
+ harness.mustSetNoScissor();
+ harness.mustDrawSolidQuad();
+ {
+ CCLayerTreeHostImpl::FrameData frame;
+ EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
+ myHostImpl->drawLayers(frame);
+ myHostImpl->didDrawAllLayers(frame);
+ }
Mock::VerifyAndClearExpectations(&mockContext);
-}
-TEST_F(CCLayerTreeHostImplTest, partialSwapNoUpdate)
-{
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new MockContext));
- MockContext* mockContext = static_cast<MockContext*>(context->context3D());
- MockContextHarness harness(mockContext);
+ // Damage a portion of the frame.
+ myHostImpl->rootLayer()->setUpdateRect(IntRect(0, 0, 2, 3));
+ // The second frame will be partially-swapped (the y coordinates are flipped).
+ harness.mustSetScissor(0, 7, 2, 3);
harness.mustDrawSolidQuad();
- harness.mustSetScissor(0, 8, 2, 2);
- harness.mustDrawSolidQuad();
- harness.mustSetScissor(0, 0, 10, 10);
-
- OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context.release(), FakeLayerWithQuads::create(1));
-
- // Draw once to make sure layer is not new
- CCLayerTreeHostImpl::FrameData frame;
- EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
- myHostImpl->drawLayers(frame);
- myHostImpl->didDrawAllLayers(frame);
-
- // Generate update in layer
- CCLayerImpl* root = myHostImpl->rootLayer();
- root->setUpdateRect(FloatRect(0, 0, 2, 2));
-
- // This draw should generate no new udpates
- EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
- myHostImpl->drawLayers(frame);
- myHostImpl->didDrawAllLayers(frame);
-
+ {
+ CCLayerTreeHostImpl::FrameData frame;
+ EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
+ myHostImpl->drawLayers(frame);
+ myHostImpl->didDrawAllLayers(frame);
+ }
Mock::VerifyAndClearExpectations(&mockContext);
}
@@ -1907,12 +1912,12 @@ static PassOwnPtr<CCLayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, C
{
CCSettings::setPartialSwapEnabled(partialSwap);
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapContext));
CCLayerTreeSettings settings;
OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, client);
myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
- myHostImpl->setViewportSize(IntSize(100, 100));
+ myHostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100));
/*
Layers are created as follows:
@@ -2013,59 +2018,6 @@ TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap)
}
}
-TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnScissoredLayer)
-{
- CCLayerTreeSettings settings;
- CCSettings::setPartialSwapEnabled(true);
-
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
- OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
- myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
- myHostImpl->setViewportSize(IntSize(10, 10));
-
- myHostImpl->setRootLayer(DidDrawCheckLayer::create(1));
- DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(myHostImpl->rootLayer());
- root->setMasksToBounds(true);
-
- root->addChild(DidDrawCheckLayer::create(2));
- DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[0].get());
-
- CCLayerTreeHostImpl::FrameData frame;
-
- EXPECT_FALSE(root->willDrawCalled());
- EXPECT_FALSE(root->didDrawCalled());
- EXPECT_FALSE(layer->willDrawCalled());
- EXPECT_FALSE(layer->didDrawCalled());
-
- // We should draw everything the first frame.
- EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
- myHostImpl->drawLayers(frame);
- myHostImpl->didDrawAllLayers(frame);
-
- EXPECT_TRUE(root->willDrawCalled());
- EXPECT_TRUE(root->didDrawCalled());
- EXPECT_TRUE(layer->willDrawCalled());
- EXPECT_TRUE(layer->didDrawCalled());
-
- root->clearDidDrawCheck();
- layer->clearDidDrawCheck();
-
- EXPECT_FALSE(root->willDrawCalled());
- EXPECT_FALSE(root->didDrawCalled());
- EXPECT_FALSE(layer->willDrawCalled());
- EXPECT_FALSE(layer->didDrawCalled());
-
- // Drawing again, we should scissor out everything since there is no damage.
- EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
- myHostImpl->drawLayers(frame);
- myHostImpl->didDrawAllLayers(frame);
-
- EXPECT_FALSE(root->willDrawCalled());
- EXPECT_FALSE(root->didDrawCalled());
- EXPECT_FALSE(layer->willDrawCalled());
- EXPECT_FALSE(layer->didDrawCalled());
-}
-
// Make sure that context lost notifications are propagated through the tree.
class ContextLostNotificationCheckLayer : public CCLayerImpl {
public:
@@ -2118,20 +2070,10 @@ public:
TEST_F(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost)
{
// The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects.
- m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails)), UnthrottledUploader);
+ m_hostImpl->initializeLayerRenderer(FakeWebCompositorOutputSurface::create(adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails)), UnthrottledUploader);
m_hostImpl->finishAllRendering();
}
-class ScrollbarLayerFakePaint : public CCScrollbarLayerImpl {
-public:
- static PassOwnPtr<ScrollbarLayerFakePaint> create(int id) { return adoptPtr(new ScrollbarLayerFakePaint(id)); }
-
- virtual void paint(GraphicsContext*) { }
-
-private:
- ScrollbarLayerFakePaint(int id) : CCScrollbarLayerImpl(id) { }
-};
-
// Fake WebGraphicsContext3D that will cause a failure if trying to use a
// resource that wasn't created by it (resources created by
// FakeWebGraphicsContext3D have an id of 1).
@@ -2235,25 +2177,28 @@ private:
// Fake video frame that represents a 4x4 YUV video frame.
class FakeVideoFrame: public WebVideoFrame {
public:
- FakeVideoFrame() { memset(m_data, 0x80, sizeof(m_data)); }
+ FakeVideoFrame() : m_textureId(0) { memset(m_data, 0x80, sizeof(m_data)); }
virtual ~FakeVideoFrame() { }
- virtual Format format() const { return FormatYV12; }
+ virtual Format format() const { return m_textureId ? FormatNativeTexture : FormatYV12; }
virtual unsigned width() const { return 4; }
virtual unsigned height() const { return 4; }
virtual unsigned planes() const { return 3; }
virtual int stride(unsigned plane) const { return 4; }
virtual const void* data(unsigned plane) const { return m_data; }
- virtual unsigned textureId() const { return 0; }
- virtual unsigned textureTarget() const { return 0; }
+ virtual unsigned textureId() const { return m_textureId; }
+ virtual unsigned textureTarget() const { return m_textureId ? GraphicsContext3D::TEXTURE_2D : 0; }
+
+ void setTextureId(unsigned id) { m_textureId = id; }
private:
char m_data[16];
+ unsigned m_textureId;
};
// Fake video frame provider that always provides the same FakeVideoFrame.
class FakeVideoFrameProvider: public WebVideoFrameProvider {
public:
- FakeVideoFrameProvider() : m_client(0) { }
+ FakeVideoFrameProvider() : m_frame(0), m_client(0) { }
virtual ~FakeVideoFrameProvider()
{
if (m_client)
@@ -2261,11 +2206,13 @@ public:
}
virtual void setVideoFrameProviderClient(Client* client) { m_client = client; }
- virtual WebVideoFrame* getCurrentFrame() { return &m_frame; }
+ virtual WebVideoFrame* getCurrentFrame() { return m_frame; }
virtual void putCurrentFrame(WebVideoFrame*) { }
+ void setFrame(WebVideoFrame* frame) { m_frame = frame; }
+
private:
- FakeVideoFrame m_frame;
+ WebVideoFrame* m_frame;
Client* m_client;
};
@@ -2291,6 +2238,45 @@ public:
}
};
+class FakeWebScrollbarThemeGeometryNonEmpty : public FakeWebScrollbarThemeGeometry {
+ virtual WebRect trackRect(WebScrollbar*) OVERRIDE { return WebRect(0, 0, 10, 10); }
+ virtual WebRect thumbRect(WebScrollbar*) OVERRIDE { return WebRect(0, 5, 5, 2); }
+ virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startTrack, WebRect& thumb, WebRect& endTrack) OVERRIDE
+ {
+ thumb = WebRect(0, 5, 5, 2);
+ startTrack = WebRect(0, 5, 0, 5);
+ endTrack = WebRect(0, 0, 0, 5);
+ }
+};
+
+class FakeScrollbarLayerImpl : public CCScrollbarLayerImpl {
+public:
+ static PassOwnPtr<FakeScrollbarLayerImpl> create(int id)
+ {
+ return adoptPtr(new FakeScrollbarLayerImpl(id));
+ }
+
+ void createResources(CCResourceProvider* provider)
+ {
+ ASSERT(provider);
+ int pool = 0;
+ IntSize size(10, 10);
+ GC3Denum format = GraphicsContext3D::RGBA;
+ CCResourceProvider::TextureUsageHint hint = CCResourceProvider::TextureUsageAny;
+ setScrollbarGeometry(FakeWebScrollbarThemeGeometryNonEmpty::create());
+
+ setBackTrackResourceId(provider->createResource(pool, size, format, hint));
+ setForeTrackResourceId(provider->createResource(pool, size, format, hint));
+ setThumbResourceId(provider->createResource(pool, size, format, hint));
+ }
+
+protected:
+ explicit FakeScrollbarLayerImpl(int id)
+ : CCScrollbarLayerImpl(id)
+ {
+ }
+};
+
TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
{
OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1));
@@ -2317,7 +2303,9 @@ TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
textureLayer->setTextureId(1);
rootLayer->addChild(textureLayer.release());
+ FakeVideoFrame videoFrame;
FakeVideoFrameProvider provider;
+ provider.setFrame(&videoFrame);
OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(4, &provider);
videoLayer->setBounds(IntSize(10, 10));
videoLayer->setAnchorPoint(FloatPoint(0, 0));
@@ -2326,7 +2314,18 @@ TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
videoLayer->setLayerTreeHostImpl(m_hostImpl.get());
rootLayer->addChild(videoLayer.release());
- OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(5);
+ FakeVideoFrame hwVideoFrame;
+ FakeVideoFrameProvider hwProvider;
+ hwProvider.setFrame(&hwVideoFrame);
+ OwnPtr<CCVideoLayerImpl> hwVideoLayer = CCVideoLayerImpl::create(5, &hwProvider);
+ hwVideoLayer->setBounds(IntSize(10, 10));
+ hwVideoLayer->setAnchorPoint(FloatPoint(0, 0));
+ hwVideoLayer->setContentBounds(IntSize(10, 10));
+ hwVideoLayer->setDrawsContent(true);
+ hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get());
+ rootLayer->addChild(hwVideoLayer.release());
+
+ OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(6);
ioSurfaceLayer->setBounds(IntSize(10, 10));
ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0));
ioSurfaceLayer->setContentBounds(IntSize(10, 10));
@@ -2335,8 +2334,27 @@ TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
rootLayer->addChild(ioSurfaceLayer.release());
+ OwnPtr<CCHeadsUpDisplayLayerImpl> hudLayer = CCHeadsUpDisplayLayerImpl::create(7);
+ hudLayer->setBounds(IntSize(10, 10));
+ hudLayer->setAnchorPoint(FloatPoint(0, 0));
+ hudLayer->setContentBounds(IntSize(10, 10));
+ hudLayer->setDrawsContent(true);
+ hudLayer->setLayerTreeHostImpl(m_hostImpl.get());
+ rootLayer->addChild(hudLayer.release());
+
+ OwnPtr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::create(8));
+ scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get());
+ scrollbarLayer->setBounds(IntSize(10, 10));
+ scrollbarLayer->setContentBounds(IntSize(10, 10));
+ scrollbarLayer->setDrawsContent(true);
+ scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get());
+ scrollbarLayer->createResources(m_hostImpl->resourceProvider());
+ rootLayer->addChild(scrollbarLayer.release());
+
// Use a context that supports IOSurfaces
- m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
+ m_hostImpl->initializeLayerRenderer(FakeWebCompositorOutputSurface::create(adoptPtr(new FakeWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
+
+ hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture());
m_hostImpl->setRootLayer(rootLayer.release());
@@ -2346,9 +2364,29 @@ TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
m_hostImpl->didDrawAllLayers(frame);
m_hostImpl->swapBuffers();
+ unsigned numResources = m_hostImpl->resourceProvider()->numResources();
+
// Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSurface,
// that will warn if any resource from the previous context gets used.
- m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new StrictWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
+ m_hostImpl->initializeLayerRenderer(FakeWebCompositorOutputSurface::create(adoptPtr(new StrictWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
+
+ // Create dummy resources so that looking up an old resource will get an
+ // invalid texture id mapping.
+ for (unsigned i = 0; i < numResources; ++i)
+ m_hostImpl->resourceProvider()->createResourceFromExternalTexture(1);
+
+ // The WebVideoFrameProvider is expected to recreate its textures after a
+ // lost context (or not serve a frame).
+ hwProvider.setFrame(0);
+
+ EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
+ m_hostImpl->drawLayers(frame);
+ m_hostImpl->didDrawAllLayers(frame);
+ m_hostImpl->swapBuffers();
+
+ hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture());
+ hwProvider.setFrame(&hwVideoFrame);
+
EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
m_hostImpl->drawLayers(frame);
m_hostImpl->didDrawAllLayers(frame);
@@ -2441,7 +2479,7 @@ TEST_F(CCLayerTreeHostImplTest, layersFreeTextures)
rootLayer->addChild(ioSurfaceLayer.release());
// Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the CCLayerTreeHostImpl takes ownership of).
- OwnPtr<CCGraphicsContext> ccContext(CCGraphicsContext::create3D(adoptPtr(new TrackingWebGraphicsContext3D)));
+ OwnPtr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::create(adoptPtr(new TrackingWebGraphicsContext3D)));
TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<TrackingWebGraphicsContext3D*>(ccContext->context3D());
m_hostImpl->initializeLayerRenderer(ccContext.release(), UnthrottledUploader);
@@ -2469,7 +2507,7 @@ public:
TEST_F(CCLayerTreeHostImplTest, hasTransparentBackground)
{
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new MockDrawQuadsToFillScreenContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new MockDrawQuadsToFillScreenContext));
MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(context->context3D());
// Run test case
@@ -2513,10 +2551,10 @@ static void addDrawingLayerTo(CCLayerImpl* parent, int id, const IntRect& layerR
static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl, CCLayerImpl*& rootPtr, CCLayerImpl*& intermediateLayerPtr, CCLayerImpl*& surfaceLayerPtr, CCLayerImpl*& childPtr, const IntSize& rootSize)
{
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapContext));
layerTreeHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
- layerTreeHostImpl->setViewportSize(rootSize);
+ layerTreeHostImpl->setViewportSize(rootSize, rootSize);
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
rootPtr = root.get();
@@ -2538,7 +2576,7 @@ static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl,
surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface
// Child of the surface layer will produce some quads
- addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(5, 5, rootSize.width(), rootSize.height()), &childPtr);
+ addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(5, 5, rootSize.width() - 25, rootSize.height() - 25), &childPtr);
}
class LayerRendererChromiumWithReleaseTextures : public LayerRendererChromium {
@@ -2551,17 +2589,18 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithClipping)
CCSettings::setPartialSwapEnabled(true);
CCLayerTreeSettings settings;
+ settings.minimumOcclusionTrackingSize = IntSize();
OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
CCLayerImpl* rootPtr;
CCLayerImpl* surfaceLayerPtr;
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapContext));
IntSize rootSize(100, 100);
myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
- myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()));
+ myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), IntSize(rootSize.width(), rootSize.height()));
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
rootPtr = root.get();
@@ -2601,12 +2640,15 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithClipping)
EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size());
ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size());
- // Verify that the child layers have been drawn entirely.
+ // Verify that the child layers are being clipped.
IntRect quadVisibleRect = frame.renderPasses[0]->quadList()[0]->quadVisibleRect();
- EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 3), quadVisibleRect);
+ EXPECT_LT(quadVisibleRect.width(), 100);
quadVisibleRect = frame.renderPasses[0]->quadList()[1]->quadVisibleRect();
- EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 3), quadVisibleRect);
+ EXPECT_LT(quadVisibleRect.width(), 100);
+
+ // Verify that the render surface texture is *not* clipped.
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), frame.renderPasses[0]->outputRect());
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
@@ -2623,15 +2665,16 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithClipping)
surfaceLayerPtr->setTransform(transform);
// The surface is now aligned again, and the clipped parts are exposed.
- // That should be OK, as we've already verified that the quads are drawn in full.
- // Verify that the render pass is removed.
+ // Since the layers were clipped, even though the render surface size
+ // was not changed, the texture should not be saved.
{
CCLayerTreeHostImpl::FrameData frame;
EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
- // Must receive a single render pass using a cached texture.
- ASSERT_EQ(1U, frame.renderPasses.size());
- EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size());
+ // Must receive two render passes, each with one quad
+ ASSERT_EQ(2U, frame.renderPasses.size());
+ EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size());
+ ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -2643,6 +2686,7 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusion)
CCSettings::setPartialSwapEnabled(false);
CCLayerTreeSettings settings;
+ settings.minimumOcclusionTrackingSize = IntSize();
OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
// Layers are structure as follows:
@@ -2663,12 +2707,12 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusion)
CCLayerImpl* layerS1Ptr;
CCLayerImpl* layerS2Ptr;
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapContext));
IntSize rootSize(1000, 1000);
myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
- myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()));
+ myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), IntSize(rootSize.width(), rootSize.height()));
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
rootPtr = root.get();
@@ -2698,11 +2742,11 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusion)
EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
// Must receive 3 render passes.
- // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad.
+ // For Root, there are 2 quads; for S1, there are 2 quads (1 is occluded); for S2, there is 2 quads.
ASSERT_EQ(3U, frame.renderPasses.size());
EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size());
- EXPECT_EQ(3U, frame.renderPasses[1]->quadList().size());
+ EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size());
EXPECT_EQ(2U, frame.renderPasses[2]->quadList().size());
myHostImpl->drawLayers(frame);
@@ -2758,6 +2802,7 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
CCSettings::setPartialSwapEnabled(false);
CCLayerTreeSettings settings;
+ settings.minimumOcclusionTrackingSize = IntSize();
OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
// Layers are structure as follows:
@@ -2775,12 +2820,12 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
CCLayerImpl* layerS1Ptr;
CCLayerImpl* layerS2Ptr;
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapContext));
IntSize rootSize(1000, 1000);
myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
- myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()));
+ myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), IntSize(rootSize.width(), rootSize.height()));
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
rootPtr = root.get();
@@ -2873,6 +2918,7 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
CCSettings::setPartialSwapEnabled(false);
CCLayerTreeSettings settings;
+ settings.minimumOcclusionTrackingSize = IntSize();
OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
// Layers are structured as follows:
@@ -2888,12 +2934,12 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
CCLayerImpl* layerS1Ptr;
CCLayerImpl* layerS2Ptr;
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapContext));
IntSize rootSize(1000, 1000);
myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
- myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()));
+ myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), IntSize(rootSize.width(), rootSize.height()));
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
rootPtr = root.get();
@@ -2971,12 +3017,12 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
CCLayerImpl* rootPtr;
CCLayerImpl* layerS1Ptr;
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapContext));
IntSize rootSize(1000, 1000);
myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
- myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()));
+ myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), IntSize(rootSize.width(), rootSize.height()));
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
rootPtr = root.get();
@@ -3035,6 +3081,7 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
CCSettings::setPartialSwapEnabled(true);
CCLayerTreeSettings settings;
+ settings.minimumOcclusionTrackingSize = IntSize();
OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
// Layers are structure as follows:
@@ -3055,12 +3102,12 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
CCLayerImpl* layerS1Ptr;
CCLayerImpl* layerS2Ptr;
- OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapContext));
IntSize rootSize(1000, 1000);
myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
- myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()));
+ myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), IntSize(rootSize.width(), rootSize.height()));
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
rootPtr = root.get();
@@ -3090,11 +3137,11 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
// Must receive 3 render passes.
- // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad.
+ // For Root, there are 2 quads; for S1, there are 2 quads (one is occluded); for S2, there is 2 quads.
ASSERT_EQ(3U, frame.renderPasses.size());
EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size());
- EXPECT_EQ(3U, frame.renderPasses[1]->quadList().size());
+ EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size());
EXPECT_EQ(2U, frame.renderPasses[2]->quadList().size());
myHostImpl->drawLayers(frame);
@@ -3112,12 +3159,12 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
// Must receive 2 render passes.
- // For Root, there are 2 quads
- // For S1, the number of quads depends on what got unoccluded, so not asserted beyond being positive.
+ // For Root, there are 2 quads.
+ // For S1, there are 2 quads.
// For S2, there is no render pass
ASSERT_EQ(2U, frame.renderPasses.size());
- EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U);
+ EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size());
EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size());
myHostImpl->drawLayers(frame);
@@ -3127,9 +3174,6 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
// "Re-occlude" surface S1 and repeat draw.
// Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed.
- // FIXME: Due to partial swap, the scissor rect will cause OcclusionTracker
- // to think there is an external occlusion in the previous step. Therefore,
- // S1's render pass will not be removed.
transform = layerS2Ptr->transform();
transform.translate(-15, -15);
layerS2Ptr->setTransform(transform);
@@ -3137,19 +3181,118 @@ TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
CCLayerTreeHostImpl::FrameData frame;
EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
- // 2 Render passes - Root and S1.
- ASSERT_EQ(2U, frame.renderPasses.size());
+ // Root render pass only.
+ ASSERT_EQ(1U, frame.renderPasses.size());
- // Render pass for S1 contains no quads as the scissor rect is now occluded.
- EXPECT_EQ(0U, frame.renderPasses[0]->quadList().size());
+ myHostImpl->drawLayers(frame);
+ myHostImpl->didDrawAllLayers(frame);
+ }
+}
- // Root contains S2 only, as S1 doesn't have any damage.
- EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size());
+TEST_F(CCLayerTreeHostImplTest, textureCachingWithScissor)
+{
+ CCSettings::setPartialSwapEnabled(false);
+ CCLayerTreeSettings settings;
+ settings.minimumOcclusionTrackingSize = IntSize();
+ OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
+
+ /*
+ Layers are created as follows:
+
+ +--------------------+
+ | 1 |
+ | +-----------+ |
+ | | 2 | |
+ | | +-------------------+
+ | | | 3 |
+ | | +-------------------+
+ | | | |
+ | +-----------+ |
+ | |
+ | |
+ +--------------------+
+
+ Layers 1, 2 have render surfaces
+ */
+ OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
+ OwnPtr<CCTiledLayerImpl> child = CCTiledLayerImpl::create(2);
+ OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3);
+
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect childRect(10, 10, 50, 50);
+ IntRect grandChildRect(5, 5, 150, 150);
+
+ OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapContext));
+ myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
+
+ root->setAnchorPoint(FloatPoint(0, 0));
+ root->setPosition(FloatPoint(rootRect.x(), rootRect.y()));
+ root->setBounds(IntSize(rootRect.width(), rootRect.height()));
+ root->setContentBounds(root->bounds());
+ root->setDrawsContent(true);
+ root->setMasksToBounds(true);
+
+ child->setAnchorPoint(FloatPoint(0, 0));
+ child->setPosition(FloatPoint(childRect.x(), childRect.y()));
+ child->setOpacity(0.5);
+ child->setBounds(IntSize(childRect.width(), childRect.height()));
+ child->setContentBounds(child->bounds());
+ child->setDrawsContent(true);
+ child->setSkipsDraw(false);
+
+ // child layer has 10x10 tiles.
+ OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(10, 10), CCLayerTilingData::HasBorderTexels);
+ tiler->setBounds(child->contentBounds());
+ child->setTilingData(*tiler.get());
+
+ grandChild->setAnchorPoint(FloatPoint(0, 0));
+ grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y()));
+ grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height()));
+ grandChild->setContentBounds(grandChild->bounds());
+ grandChild->setDrawsContent(true);
+
+ CCTiledLayerImpl* childPtr = child.get();
+
+ child->addChild(grandChild.release());
+ root->addChild(child.release());
+ myHostImpl->setRootLayer(root.release());
+ myHostImpl->setViewportSize(rootRect.size(), rootRect.size());
+
+ EXPECT_FALSE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(childPtr->id()));
+
+ {
+ CCLayerTreeHostImpl::FrameData frame;
+ EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
}
+ // We should have cached textures for surface 2.
+ EXPECT_TRUE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(childPtr->id()));
+
+ {
+ CCLayerTreeHostImpl::FrameData frame;
+ EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
+ myHostImpl->drawLayers(frame);
+ myHostImpl->didDrawAllLayers(frame);
+ }
+
+ // We should still have cached textures for surface 2 after drawing with no damage.
+ EXPECT_TRUE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(childPtr->id()));
+
+ // Damage a single tile of surface 2.
+ childPtr->setUpdateRect(IntRect(10, 10, 10, 10));
+
+ {
+ CCLayerTreeHostImpl::FrameData frame;
+ EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
+ myHostImpl->drawLayers(frame);
+ myHostImpl->didDrawAllLayers(frame);
+ }
+
+ // We should have a cached texture for surface 2 again even though it was damaged.
+ EXPECT_TRUE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(childPtr->id()));
}
TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
@@ -3157,6 +3300,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
CCSettings::setPartialSwapEnabled(true);
CCLayerTreeSettings settings;
+ settings.minimumOcclusionTrackingSize = IntSize();
OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
CCLayerImpl* rootPtr;
@@ -3178,7 +3322,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_TRUE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_FALSE(targetPass->damageRect().isEmpty());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3189,10 +3333,14 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
CCLayerTreeHostImpl::FrameData frame;
EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
- // Must receive two EMPTY render passes
- ASSERT_EQ(2U, frame.renderPasses.size());
- EXPECT_EQ(0U, frame.renderPasses[0]->quadList().size());
- EXPECT_EQ(0U, frame.renderPasses[1]->quadList().size());
+ // Must receive one render pass, as the other one should be culled
+ ASSERT_EQ(1U, frame.renderPasses.size());
+
+ EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size());
+ EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->material());
+ CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[0]->quadList()[0].get());
+ CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
+ EXPECT_TRUE(targetPass->damageRect().isEmpty());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3211,7 +3359,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[0]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_FALSE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_TRUE(targetPass->damageRect().isEmpty());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3232,7 +3380,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_TRUE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_FALSE(targetPass->damageRect().isEmpty());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3259,7 +3407,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_FALSE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_TRUE(targetPass->damageRect().isEmpty());
// Was our surface evicted?
EXPECT_FALSE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(targetPass->id()));
@@ -3273,10 +3421,14 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
CCLayerTreeHostImpl::FrameData frame;
EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
- // Must receive two EMPTY render passes
- ASSERT_EQ(2U, frame.renderPasses.size());
- EXPECT_EQ(0U, frame.renderPasses[0]->quadList().size());
- EXPECT_EQ(0U, frame.renderPasses[1]->quadList().size());
+ // Must receive one render pass, as the other one should be culled
+ ASSERT_EQ(1U, frame.renderPasses.size());
+
+ EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size());
+ EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->material());
+ CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[0]->quadList()[0].get());
+ CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
+ EXPECT_TRUE(targetPass->damageRect().isEmpty());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3297,7 +3449,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[0]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_FALSE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_TRUE(targetPass->damageRect().isEmpty());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3309,6 +3461,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
CCSettings::setPartialSwapEnabled(false);
CCLayerTreeSettings settings;
+ settings.minimumOcclusionTrackingSize = IntSize();
OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
CCLayerImpl* rootPtr;
@@ -3330,7 +3483,13 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_TRUE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_FALSE(targetPass->damageRect().isEmpty());
+
+ EXPECT_FALSE(frame.renderPasses[0]->damageRect().isEmpty());
+ EXPECT_FALSE(frame.renderPasses[1]->damageRect().isEmpty());
+
+ EXPECT_FALSE(frame.renderPasses[0]->hasOcclusionFromOutsideTargetSurface());
+ EXPECT_FALSE(frame.renderPasses[1]->hasOcclusionFromOutsideTargetSurface());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3347,6 +3506,8 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
ASSERT_EQ(1U, frame.renderPasses.size());
EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size());
+ EXPECT_TRUE(frame.renderPasses[0]->damageRect().isEmpty());
+
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
}
@@ -3364,7 +3525,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[0]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_FALSE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_TRUE(targetPass->damageRect().isEmpty());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3385,7 +3546,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_TRUE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_FALSE(targetPass->damageRect().isEmpty());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3412,7 +3573,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_FALSE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_TRUE(targetPass->damageRect().isEmpty());
// Was our surface evicted?
EXPECT_FALSE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(targetPass->id()));
@@ -3451,83 +3612,7 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->material());
CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[0]->quadList()[0].get());
CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_FALSE(targetPass->targetSurface()->contentsChanged());
-
- myHostImpl->drawLayers(frame);
- myHostImpl->didDrawAllLayers(frame);
- }
-}
-
-// FIXME: This test is temporary until memory management in render surfaces gets refactored.
-// It depends on implementation of TextureManager and needs to get removed as
-// it will become meaningless with a different implementation.
-TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingMemoryLimit)
-{
- CCSettings::setPartialSwapEnabled(true);
-
- CCLayerTreeSettings settings;
- OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
-
- CCLayerImpl* rootPtr;
- CCLayerImpl* intermediateLayerPtr;
- CCLayerImpl* surfaceLayerPtr;
- CCLayerImpl* childPtr;
-
- // FIXME: The number 4200 is the "magic" number which will cause render surface size
- // to go above 64M. This will bring it above reclaimLimitBytes().
- // We could compute this number from return value of reclaimLimitBytes(), however
- // it takes a viewport, so it's no better as it still contains same kind of assumption
- // (namely that reclaimLimitBytes() ignores viewport size).
- IntSize largeSurfaceSize(4200, 4200);
- setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr, surfaceLayerPtr, childPtr, largeSurfaceSize);
-
- {
- CCLayerTreeHostImpl::FrameData frame;
- EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
-
- // Must receive two render passes, each with one quad
- ASSERT_EQ(2U, frame.renderPasses.size());
- EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size());
- EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size());
-
- EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->material());
- CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
- CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_TRUE(targetPass->targetSurface()->contentsChanged());
-
- myHostImpl->drawLayers(frame);
- myHostImpl->didDrawAllLayers(frame);
- }
-
- // Draw without any change
- {
- CCLayerTreeHostImpl::FrameData frame;
- EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
-
- // Must receive two EMPTY render passes
- ASSERT_EQ(2U, frame.renderPasses.size());
- EXPECT_EQ(0U, frame.renderPasses[0]->quadList().size());
- EXPECT_EQ(0U, frame.renderPasses[1]->quadList().size());
-
- myHostImpl->drawLayers(frame);
- myHostImpl->didDrawAllLayers(frame);
- }
-
- // Change opacity and draw.
- // If all goes well, the texture must still be available, even though it's really big.
- surfaceLayerPtr->setOpacity(0.6f);
- {
- CCLayerTreeHostImpl::FrameData frame;
- EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
-
- // Must receive one render pass, as the other one should be culled
- ASSERT_EQ(1U, frame.renderPasses.size());
-
- EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size());
- EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->material());
- CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[0]->quadList()[0].get());
- CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId());
- EXPECT_FALSE(targetPass->targetSurface()->contentsChanged());
+ EXPECT_TRUE(targetPass->damageRect().isEmpty());
myHostImpl->drawLayers(frame);
myHostImpl->didDrawAllLayers(frame);
@@ -3698,7 +3783,7 @@ static void configureRenderPassTestData(const char* testScript, RenderPassRemova
IntRect quadRect = IntRect(0, 0, 1, 1);
IntRect contentsChangedRect = contentsChanged ? quadRect : IntRect();
- OwnPtr<CCRenderPassDrawQuad> quad = CCRenderPassDrawQuad::create(testData.sharedQuadState.get(), quadRect, newRenderPassId, isReplica, 1, contentsChangedRect);
+ OwnPtr<CCRenderPassDrawQuad> quad = CCRenderPassDrawQuad::create(testData.sharedQuadState.get(), quadRect, newRenderPassId, isReplica, 1, contentsChangedRect, 1, 1, 0, 0);
static_cast<CCTestRenderPass*>(renderPass.get())->appendQuad(quad.release());
}
}
diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
index ea7678b02..137e6249a 100644
--- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
@@ -26,20 +26,18 @@
#include "cc/CCLayerTreeHost.h"
-#include "AnimationIdVendor.h"
#include "CCOcclusionTrackerTestCommon.h"
#include "CCThreadedTest.h"
#include "ContentLayerChromium.h"
-#include "GraphicsContext3DPrivate.h"
#include "cc/CCGraphicsContext.h"
#include "cc/CCLayerTreeHostImpl.h"
#include "cc/CCSettings.h"
-#include "cc/CCTextureUpdater.h"
+#include "cc/CCTextureUpdateQueue.h"
#include "cc/CCTimingFunction.h"
-#include "platform/WebThread.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <public/Platform.h>
+#include <public/WebThread.h>
#include <wtf/MainThread.h>
#include <wtf/OwnArrayPtr.h>
@@ -339,7 +337,7 @@ public:
m_numCommits++;
if (m_numCommits == 1) {
// Make the viewport empty so the host says it can't draw.
- m_layerTreeHost->setViewportSize(IntSize(0, 0));
+ m_layerTreeHost->setViewportSize(IntSize(0, 0), IntSize(0, 0));
OwnArrayPtr<char> pixels(adoptArrayPtr(new char[4]));
m_layerTreeHost->compositeAndReadback(static_cast<void*>(pixels.get()), IntRect(0, 0, 1, 1));
@@ -747,7 +745,7 @@ public:
virtual void beginTest()
{
m_layerTreeHost->rootLayer()->setDrawOpacity(1);
- m_layerTreeHost->setViewportSize(IntSize(10, 10));
+ m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
m_layerTreeHost->rootLayer()->setOpacity(0);
postAddAnimationToMainThread();
}
@@ -1006,8 +1004,8 @@ public:
virtual void beginTest()
{
- m_layerTreeHost->setViewportSize(IntSize(20, 20));
- m_layerTreeHost->setBackgroundColor(Color::gray);
+ m_layerTreeHost->setViewportSize(IntSize(20, 20), IntSize(20, 20));
+ m_layerTreeHost->setBackgroundColor(SK_ColorGRAY);
m_layerTreeHost->setPageScaleFactorAndLimits(5, 5, 5);
postSetNeedsCommitToMainThread();
@@ -1015,8 +1013,8 @@ public:
virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl)
{
- EXPECT_EQ(IntSize(20, 20), impl->viewportSize());
- EXPECT_EQ(Color::gray, impl->backgroundColor());
+ EXPECT_EQ(IntSize(20, 20), impl->layoutViewportSize());
+ EXPECT_EQ(SK_ColorGRAY, impl->backgroundColor());
EXPECT_EQ(5, impl->pageScale());
endTest();
@@ -1160,9 +1158,9 @@ public:
int paintContentsCount() { return m_paintContentsCount; }
void resetPaintContentsCount() { m_paintContentsCount = 0; }
- virtual void update(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion, CCRenderingStats& stats) OVERRIDE
+ virtual void update(CCTextureUpdateQueue& queue, const CCOcclusionTracker* occlusion, CCRenderingStats& stats) OVERRIDE
{
- ContentLayerChromium::update(updater, occlusion, stats);
+ ContentLayerChromium::update(queue, occlusion, stats);
m_paintContentsCount++;
}
@@ -1191,7 +1189,7 @@ public:
virtual void beginTest()
{
m_layerTreeHost->setRootLayer(m_updateCheckLayer);
- m_layerTreeHost->setViewportSize(IntSize(10, 10));
+ m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
postSetNeedsCommitToMainThread();
}
@@ -1239,10 +1237,9 @@ public:
virtual void beginTest()
{
- // The device viewport should be scaled by the device scale factor.
- m_layerTreeHost->setViewportSize(IntSize(40, 40));
+ m_layerTreeHost->setViewportSize(IntSize(40, 40), IntSize(60, 60));
m_layerTreeHost->setDeviceScaleFactor(1.5);
- EXPECT_EQ(IntSize(40, 40), m_layerTreeHost->viewportSize());
+ EXPECT_EQ(IntSize(40, 40), m_layerTreeHost->layoutViewportSize());
EXPECT_EQ(IntSize(60, 60), m_layerTreeHost->deviceViewportSize());
m_rootLayer->addChild(m_childLayer);
@@ -1273,7 +1270,7 @@ public:
ASSERT_EQ(1u, impl->rootLayer()->children().size());
// Device viewport is scaled.
- EXPECT_EQ(IntSize(40, 40), impl->viewportSize());
+ EXPECT_EQ(IntSize(40, 40), impl->layoutViewportSize());
EXPECT_EQ(IntSize(60, 60), impl->deviceViewportSize());
CCLayerImpl* root = impl->rootLayer();
@@ -1347,7 +1344,7 @@ public:
virtual void beginTest()
{
m_layerTreeHost->setRootLayer(m_layer);
- m_layerTreeHost->setViewportSize(IntSize(10, 10));
+ m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
postSetNeedsCommitToMainThread();
postSetNeedsRedrawToMainThread();
@@ -1447,7 +1444,7 @@ public:
virtual void beginTest()
{
m_layerTreeHost->setRootLayer(m_parent);
- m_layerTreeHost->setViewportSize(IntSize(10, 20));
+ m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20));
WebTransformationMatrix identityMatrix;
setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 20), true);
@@ -1543,10 +1540,10 @@ public:
break;
case 3:
m_child->setNeedsDisplay();
- m_layerTreeHost->setViewportSize(IntSize(10, 10));
+ m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
break;
case 4:
- m_layerTreeHost->setViewportSize(IntSize(10, 20));
+ m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20));
break;
default:
ASSERT_NOT_REACHED();
@@ -1574,7 +1571,7 @@ class TestLayerChromium : public LayerChromium {
public:
static PassRefPtr<TestLayerChromium> create() { return adoptRef(new TestLayerChromium()); }
- virtual void update(CCTextureUpdater&, const CCOcclusionTracker* occlusion, CCRenderingStats&) OVERRIDE
+ virtual void update(CCTextureUpdateQueue&, const CCOcclusionTracker* occlusion, CCRenderingStats&) OVERRIDE
{
// Gain access to internals of the CCOcclusionTracker.
const TestCCOcclusionTracker* testOcclusion = static_cast<const TestCCOcclusionTracker*>(occlusion);
@@ -1627,10 +1624,10 @@ public:
setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
ASSERT_TRUE(m_layerTreeHost->initializeLayerRendererIfNeeded());
- CCTextureUpdater updater;
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ CCTextureUpdateQueue queue;
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());
@@ -1646,8 +1643,8 @@ public:
setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());
@@ -1664,8 +1661,8 @@ public:
setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());
@@ -1684,8 +1681,8 @@ public:
setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());
@@ -1706,8 +1703,8 @@ public:
child->setMaskLayer(mask.get());
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());
@@ -1728,8 +1725,8 @@ public:
child->setMaskLayer(mask.get());
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds());
@@ -1751,8 +1748,8 @@ public:
child->setOpacity(0.5);
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());
@@ -1774,8 +1771,8 @@ public:
child->setOpacity(0.5);
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds());
@@ -1835,10 +1832,10 @@ public:
}
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
ASSERT_TRUE(m_layerTreeHost->initializeLayerRendererIfNeeded());
- CCTextureUpdater updater;
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ CCTextureUpdateQueue queue;
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds());
@@ -1864,8 +1861,8 @@ public:
}
m_layerTreeHost->setRootLayer(rootLayer);
- m_layerTreeHost->setViewportSize(rootLayer->bounds());
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds());
@@ -1924,10 +1921,10 @@ public:
}
m_layerTreeHost->setRootLayer(layers[0].get());
- m_layerTreeHost->setViewportSize(layers[0]->bounds());
+ m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds());
ASSERT_TRUE(m_layerTreeHost->initializeLayerRendererIfNeeded());
- CCTextureUpdater updater;
- m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
+ CCTextureUpdateQueue queue;
+ m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
for (int i = 0; i < numSurfaces-1; ++i) {
@@ -1951,7 +1948,7 @@ public:
SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestManySurfaces)
-// A loseContext(1) should lead to a didRecreateContext(true)
+// A loseContext(1) should lead to a didRecreateOutputSurface(true)
class CCLayerTreeHostTestSetSingleLostContext : public CCLayerTreeHostTest {
public:
CCLayerTreeHostTestSetSingleLostContext()
@@ -1968,7 +1965,7 @@ public:
m_layerTreeHost->loseContext(1);
}
- virtual void didRecreateContext(bool succeeded)
+ virtual void didRecreateOutputSurface(bool succeeded)
{
EXPECT_TRUE(succeeded);
endTest();
@@ -1984,7 +1981,7 @@ TEST_F(CCLayerTreeHostTestSetSingleLostContext, runMultiThread)
runTest(true);
}
-// A loseContext(10) should lead to a didRecreateContext(false), and
+// A loseContext(10) should lead to a didRecreateOutputSurface(false), and
// a finishAllRendering() should not hang.
class CCLayerTreeHostTestSetRepeatedLostContext : public CCLayerTreeHostTest {
public:
@@ -2002,7 +1999,7 @@ public:
m_layerTreeHost->loseContext(10);
}
- virtual void didRecreateContext(bool succeeded)
+ virtual void didRecreateOutputSurface(bool succeeded)
{
EXPECT_FALSE(succeeded);
m_layerTreeHost->finishAllRendering();
@@ -2141,7 +2138,7 @@ public:
// Any valid CCAnimationCurve will do here.
OwnPtr<CCAnimationCurve> curve(CCEaseTimingFunction::create());
- OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(), AnimationIdVendor::getNextAnimationId(), AnimationIdVendor::getNextGroupId(), CCActiveAnimation::Opacity));
+ OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(), 1, 1, CCActiveAnimation::Opacity));
layer->layerAnimationController()->addAnimation(animation.release());
// We add the animation *before* attaching the layer to the tree.
@@ -2173,7 +2170,7 @@ public:
virtual void beginTest() OVERRIDE
{
- m_layerTreeHost->setViewportSize(IntSize(10, 10));
+ m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10));
m_rootScrollLayer = ContentLayerChromium::create(&m_mockDelegate);
@@ -2283,7 +2280,7 @@ public:
virtual void beginTest()
{
- m_layerTreeHost->setViewportSize(IntSize(100, 100));
+ m_layerTreeHost->setViewportSize(IntSize(100, 100), IntSize(100, 100));
m_rootLayer->setBounds(IntSize(100, 100));
m_surfaceLayer1->setBounds(IntSize(100, 100));
diff --git a/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp
index 596b0692c..9d51c9970 100644
--- a/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp
@@ -31,7 +31,6 @@
#include "CCOcclusionTrackerTestCommon.h"
#include "LayerChromium.h"
#include "Region.h"
-#include "TranslateTransformOperation.h"
#include "cc/CCLayerAnimationController.h"
#include "cc/CCLayerImpl.h"
#include "cc/CCLayerTreeHostCommon.h"
@@ -103,23 +102,23 @@ private:
};
template<typename LayerType, typename RenderSurfaceType>
-class TestCCOcclusionTrackerWithScissor : public TestCCOcclusionTrackerBase<LayerType, RenderSurfaceType> {
+class TestCCOcclusionTrackerWithClip : public TestCCOcclusionTrackerBase<LayerType, RenderSurfaceType> {
public:
- TestCCOcclusionTrackerWithScissor(IntRect screenScissorRect, bool recordMetricsForFrame = false)
- : TestCCOcclusionTrackerBase<LayerType, RenderSurfaceType>(screenScissorRect, recordMetricsForFrame)
- , m_overrideLayerScissorRect(false)
+ TestCCOcclusionTrackerWithClip(IntRect viewportRect, bool recordMetricsForFrame = false)
+ : TestCCOcclusionTrackerBase<LayerType, RenderSurfaceType>(viewportRect, recordMetricsForFrame)
+ , m_overrideLayerClipRect(false)
{
}
- void setLayerScissorRect(const IntRect& rect) { m_overrideLayerScissorRect = true; m_layerScissorRect = rect;}
- void useDefaultLayerScissorRect() { m_overrideLayerScissorRect = false; }
+ void setLayerClipRect(const IntRect& rect) { m_overrideLayerClipRect = true; m_layerClipRect = rect;}
+ void useDefaultLayerClipRect() { m_overrideLayerClipRect = false; }
protected:
- virtual IntRect layerScissorRectInTargetSurface(const LayerType* layer) const { return m_overrideLayerScissorRect ? m_layerScissorRect : CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::layerScissorRectInTargetSurface(layer); }
+ virtual IntRect layerClipRectInTarget(const LayerType* layer) const { return m_overrideLayerClipRect ? m_layerClipRect : CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::layerClipRectInTarget(layer); }
private:
- bool m_overrideLayerScissorRect;
- IntRect m_layerScissorRect;
+ bool m_overrideLayerClipRect;
+ IntRect m_layerClipRect;
};
struct CCOcclusionTrackerTestMainThreadTypes {
@@ -262,8 +261,7 @@ protected:
ASSERT(!root->renderSurface());
CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, &layerSorter, dummyMaxTextureSize, m_renderSurfaceLayerListImpl);
-
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(m_renderSurfaceLayerListImpl, root->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(m_renderSurfaceLayerListImpl);
m_layerIterator = m_layerIteratorBegin = Types::LayerIterator::begin(&m_renderSurfaceLayerListImpl);
}
@@ -276,8 +274,7 @@ protected:
ASSERT(!root->renderSurface());
CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, dummyMaxTextureSize, m_renderSurfaceLayerListChromium);
-
- CCLayerTreeHostCommon::calculateVisibleAndScissorRects(m_renderSurfaceLayerListChromium, root->renderSurface()->contentRect());
+ CCLayerTreeHostCommon::calculateVisibleRects(m_renderSurfaceLayerListChromium);
m_layerIterator = m_layerIteratorBegin = Types::LayerIterator::begin(&m_renderSurfaceLayerListChromium);
}
@@ -443,8 +440,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(30, 30), IntSize(500, 500), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
@@ -460,13 +457,13 @@ protected:
EXPECT_FALSE(occlusion.occluded(parent, IntRect(31, 30, 70, 70)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 31, 70, 70)));
- occlusion.useDefaultLayerScissorRect();
+ occlusion.useDefaultLayerClipRect();
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 70, 70)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 30, 70, 70)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 29, 70, 70)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(31, 30, 70, 70)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 31, 70, 70)));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 30, 70, 70)).isEmpty());
EXPECT_INT_RECT_EQ(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 70, 70)));
@@ -496,8 +493,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, layerTransform, FloatPoint(30, 30), IntSize(500, 500), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
@@ -513,13 +510,13 @@ protected:
EXPECT_FALSE(occlusion.occluded(parent, IntRect(31, 30, 70, 70)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 31, 70, 70)));
- occlusion.useDefaultLayerScissorRect();
+ occlusion.useDefaultLayerClipRect();
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 70, 70)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 30, 70, 70)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 29, 70, 70)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(31, 30, 70, 70)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 31, 70, 70)));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 30, 70, 70)).isEmpty());
EXPECT_INT_RECT_EQ(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 70, 70)));
@@ -547,8 +544,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, layerTransform, FloatPoint(30, 30), IntSize(500, 500), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
@@ -564,13 +561,13 @@ protected:
EXPECT_FALSE(occlusion.occluded(parent, IntRect(51, 50, 50, 50)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(50, 51, 50, 50)));
- occlusion.useDefaultLayerScissorRect();
+ occlusion.useDefaultLayerClipRect();
EXPECT_TRUE(occlusion.occluded(parent, IntRect(50, 50, 50, 50)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(49, 50, 50, 50)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(50, 49, 50, 50)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(51, 50, 50, 50)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(50, 51, 50, 50)));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(50, 50, 50, 50)).isEmpty());
EXPECT_INT_RECT_EQ(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 50, 50, 50)));
@@ -582,7 +579,7 @@ protected:
EXPECT_INT_RECT_EQ(IntRect(50, 100, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 51, 50, 50)));
EXPECT_INT_RECT_EQ(IntRect(49, 51, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 51, 50, 50)));
- occlusion.useDefaultLayerScissorRect();
+ occlusion.useDefaultLayerClipRect();
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(50, 50, 50, 50)).isEmpty());
EXPECT_INT_RECT_EQ(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 50, 50, 50)));
EXPECT_INT_RECT_EQ(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 49, 50, 50)));
@@ -592,7 +589,7 @@ protected:
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(51, 51, 50, 50)).isEmpty());
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(50, 51, 50, 50)).isEmpty());
EXPECT_INT_RECT_EQ(IntRect(49, 51, 1, 49), occlusion.unoccludedContentRect(parent, IntRect(49, 51, 50, 50)));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
}
};
@@ -614,8 +611,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingLayer(child, this->identityMatrix, FloatPoint(10, 10), IntSize(500, 500), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(layer, occlusion);
this->enterContributingSurface(child, occlusion);
@@ -625,20 +622,6 @@ protected:
EXPECT_INT_RECT_EQ(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
- EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 430, 60, 70)));
- EXPECT_FALSE(occlusion.occluded(child, IntRect(9, 430, 60, 70)));
- EXPECT_FALSE(occlusion.occluded(child, IntRect(10, 429, 60, 70)));
- EXPECT_FALSE(occlusion.occluded(child, IntRect(10, 430, 61, 70)));
- EXPECT_FALSE(occlusion.occluded(child, IntRect(10, 430, 60, 71)));
-
- occlusion.useDefaultLayerScissorRect();
- EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 430, 60, 70)));
- EXPECT_TRUE(occlusion.occluded(child, IntRect(9, 430, 60, 70)));
- EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 429, 60, 70)));
- EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 430, 61, 70)));
- EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 430, 60, 71)));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
-
this->leaveContributingSurface(child, occlusion);
this->enterLayer(parent, occlusion);
@@ -653,13 +636,13 @@ protected:
EXPECT_FALSE(occlusion.occluded(parent, IntRect(31, 40, 70, 60)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 41, 70, 60)));
- occlusion.useDefaultLayerScissorRect();
+ occlusion.useDefaultLayerClipRect();
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 40, 70, 60)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 40, 70, 60)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 39, 70, 60)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(31, 40, 70, 60)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 41, 70, 60)));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
/* Justification for the above occlusion from |layer|:
@@ -710,8 +693,8 @@ protected:
typename Types::ContentLayerType* child2 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(30, 30), IntSize(60, 20), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(-10, -10, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(-10, -10, 1000, 1000));
this->visitLayer(child2, occlusion);
@@ -729,45 +712,10 @@ protected:
this->enterContributingSurface(child, occlusion);
- EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 430, 60, 70)));
- EXPECT_FALSE(occlusion.occluded(child, IntRect(9, 430, 60, 70)));
- EXPECT_FALSE(occlusion.occluded(child, IntRect(10, 429, 60, 70)));
- EXPECT_FALSE(occlusion.occluded(child, IntRect(11, 430, 60, 70)));
- EXPECT_FALSE(occlusion.occluded(child, IntRect(10, 431, 60, 70)));
-
- occlusion.useDefaultLayerScissorRect();
- EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 430, 60, 70)));
- EXPECT_TRUE(occlusion.occluded(child, IntRect(9, 430, 60, 70)));
- EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 429, 60, 70)));
- EXPECT_TRUE(occlusion.occluded(child, IntRect(11, 430, 60, 70)));
- EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 431, 60, 70)));
- occlusion.setLayerScissorRect(IntRect(-10, -10, 1000, 1000));
-
- EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(10, 430, 60, 70)).isEmpty());
- // This is the little piece not occluded by child2
- EXPECT_INT_RECT_EQ(IntRect(9, 430, 1, 10), occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 70)));
- // This extends past both sides of child2, so it will be the original rect.
- EXPECT_INT_RECT_EQ(IntRect(9, 430, 60, 80), occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 80)));
- // This extends past two adjacent sides of child2, and should included the unoccluded parts of each side.
- // This also demonstrates that the rect can be arbitrary and does not get clipped to the layer's visibleContentRect().
- EXPECT_INT_RECT_EQ(IntRect(-10, 430, 20, 70), occlusion.unoccludedContentRect(child, IntRect(-10, 430, 60, 70)));
- // This extends past three adjacent sides of child2, so it should contain the unoccluded parts of each side. The left
- // and bottom edges are completely unoccluded for some row/column so we get back the original query rect.
- EXPECT_INT_RECT_EQ(IntRect(-10, 430, 60, 80), occlusion.unoccludedContentRect(child, IntRect(-10, 430, 60, 80)));
- EXPECT_INT_RECT_EQ(IntRect(10, 429, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 429, 60, 70)));
- EXPECT_INT_RECT_EQ(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child, IntRect(11, 430, 60, 70)));
- EXPECT_INT_RECT_EQ(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 431, 60, 70)));
-
- occlusion.useDefaultLayerScissorRect();
- EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(10, 430, 60, 70)).isEmpty());
- EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 70)).isEmpty());
- EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 80)).isEmpty());
- EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(-10, 430, 60, 70)).isEmpty());
- EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(-10, 430, 60, 80)).isEmpty());
- EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(10, 429, 60, 70)).isEmpty());
- EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(11, 430, 60, 70)).isEmpty());
- EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(10, 431, 60, 70)).isEmpty());
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
+ EXPECT_INT_RECT_EQ(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
// Occlusion in |child2| should get merged with the |child| surface we are leaving now.
this->leaveContributingSurface(child, occlusion);
@@ -856,8 +804,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingLayer(child, layerTransform, FloatPoint(0, 0), IntSize(500, 500), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
IntRect clippedLayerInChild = CCMathUtil::mapClippedRect(layerTransform, layer->visibleContentRect());
@@ -920,8 +868,8 @@ protected:
typename Types::ContentLayerType* layer2 = this->createDrawingLayer(child, this->identityMatrix, FloatPoint(10, 450), IntSize(500, 60), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(layer2, occlusion);
this->visitLayer(layer1, occlusion);
@@ -1008,8 +956,8 @@ protected:
typename Types::ContentLayerType* layer2 = this->createDrawingLayer(child2, this->identityMatrix, FloatPoint(-10, -10), IntSize(510, 510), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(-20, -20, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(-20, -20, 1000, 1000));
this->visitLayer(layer2, occlusion);
this->enterContributingSurface(child2, occlusion);
@@ -1025,13 +973,13 @@ protected:
EXPECT_FALSE(occlusion.occluded(child2, IntRect(-10, 420, 71, 80)));
EXPECT_FALSE(occlusion.occluded(child2, IntRect(-10, 420, 70, 81)));
- occlusion.useDefaultLayerScissorRect();
+ occlusion.useDefaultLayerClipRect();
EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 70, 80)));
EXPECT_TRUE(occlusion.occluded(child2, IntRect(-11, 420, 70, 80)));
EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 419, 70, 80)));
EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 71, 80)));
EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 70, 81)));
- occlusion.setLayerScissorRect(IntRect(-20, -20, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(-20, -20, 1000, 1000));
// There is nothing above child2's surface in the z-order.
EXPECT_INT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2, false, IntRect(-10, 420, 70, 80)));
@@ -1122,8 +1070,8 @@ protected:
typename Types::ContentLayerType* layer2 = this->createDrawingLayer(child2, this->identityMatrix, FloatPoint(-10, -10), IntSize(510, 510), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(-30, -30, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(-30, -30, 1000, 1000));
this->visitLayer(layer2, occlusion);
this->enterLayer(child2, occlusion);
@@ -1236,8 +1184,8 @@ protected:
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
// Opacity layer won't contribute to occlusion.
this->visitLayer(opacityLayer, occlusion);
@@ -1300,8 +1248,8 @@ protected:
this->createReplicaLayer(surface, this->identityMatrix, FloatPoint(50, 50), IntSize());
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(surface, occlusion);
@@ -1331,8 +1279,8 @@ protected:
this->createReplicaLayer(surface, this->identityMatrix, FloatPoint(50, 50), IntSize());
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(surface, occlusion);
@@ -1363,8 +1311,8 @@ protected:
this->createMaskLayer(replica, IntSize(10, 10));
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(surface, occlusion);
@@ -1385,7 +1333,7 @@ protected:
ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestReplicaWithMask);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestLayerScissorRectOutsideChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestLayerClipRectOutsideChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
@@ -1393,8 +1341,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(200, 100, 100, 100));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(200, 100, 100, 100));
this->enterLayer(layer, occlusion);
@@ -1404,9 +1352,9 @@ protected:
EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 100, 100, 100)));
EXPECT_FALSE(occlusion.occluded(layer, IntRect(200, 100, 100, 100)));
- occlusion.useDefaultLayerScissorRect();
+ occlusion.useDefaultLayerClipRect();
EXPECT_TRUE(occlusion.occluded(layer, IntRect(200, 100, 100, 100)));
- occlusion.setLayerScissorRect(IntRect(200, 100, 100, 100));
+ occlusion.setLayerClipRect(IntRect(200, 100, 100, 100));
this->leaveLayer(layer, occlusion);
this->visitContributingSurface(layer, occlusion);
@@ -1426,10 +1374,10 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerScissorRectOutsideChild);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerClipRectOutsideChild);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestScreenScissorRectOutsideChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestViewportRectOutsideChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
@@ -1437,8 +1385,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(200, 100, 100, 100));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(200, 100, 100, 100));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
@@ -1448,9 +1396,9 @@ protected:
EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 100, 100, 100)));
EXPECT_FALSE(occlusion.occluded(layer, IntRect(200, 100, 100, 100)));
- occlusion.useDefaultLayerScissorRect();
+ occlusion.useDefaultLayerClipRect();
EXPECT_TRUE(occlusion.occluded(layer, IntRect(200, 100, 100, 100)));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->leaveLayer(layer, occlusion);
this->visitContributingSurface(layer, occlusion);
@@ -1470,10 +1418,10 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestScreenScissorRectOutsideChild);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestViewportRectOutsideChild);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestLayerScissorRectOverChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestLayerClipRectOverChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
@@ -1481,8 +1429,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(100, 100, 100, 100));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(100, 100, 100, 100));
this->enterLayer(layer, occlusion);
@@ -1509,10 +1457,10 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerScissorRectOverChild);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerClipRectOverChild);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestScreenScissorRectOverChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestViewportRectOverChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
@@ -1520,8 +1468,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(100, 100, 100, 100));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(100, 100, 100, 100));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
@@ -1548,10 +1496,10 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestScreenScissorRectOverChild);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestViewportRectOverChild);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestLayerScissorRectPartlyOverChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestLayerClipRectPartlyOverChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
@@ -1559,8 +1507,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(50, 50, 200, 200));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(50, 50, 200, 200));
this->enterLayer(layer, occlusion);
@@ -1591,10 +1539,10 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerScissorRectPartlyOverChild);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerClipRectPartlyOverChild);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestScreenScissorRectPartlyOverChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestViewportRectPartlyOverChild : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
@@ -1602,8 +1550,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(50, 50, 200, 200));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(50, 50, 200, 200));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
@@ -1634,10 +1582,10 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestScreenScissorRectPartlyOverChild);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestViewportRectPartlyOverChild);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestLayerScissorRectOverNothing : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestLayerClipRectOverNothing : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
@@ -1645,8 +1593,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(500, 500, 100, 100));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(500, 500, 100, 100));
this->enterLayer(layer, occlusion);
@@ -1677,10 +1625,10 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerScissorRectOverNothing);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerClipRectOverNothing);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestScreenScissorRectOverNothing : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestViewportRectOverNothing : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
@@ -1688,8 +1636,8 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(500, 500, 100, 100));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(500, 500, 100, 100));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
@@ -1720,10 +1668,10 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestScreenScissorRectOverNothing);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestViewportRectOverNothing);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestLayerScissorRectForLayerOffOrigin : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestLayerClipRectForLayerOffOrigin : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
@@ -1731,12 +1679,12 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
- // This layer is translated when drawn into its target. So if the scissor rect given from the target surface
+ // This layer is translated when drawn into its target. So if the clip rect given from the target surface
// is not in that target space, then after translating these query rects into the target, they will fall outside
- // the scissor and be considered occluded.
+ // the clip and be considered occluded.
EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 0, 100, 100)));
EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 100, 100, 100)));
EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 0, 100, 100)));
@@ -1744,7 +1692,7 @@ protected:
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerScissorRectForLayerOffOrigin);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestLayerClipRectForLayerOffOrigin);
template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestOpaqueContentsRegionEmpty : public CCOcclusionTrackerTest<Types, opaqueLayers> {
@@ -1755,7 +1703,7 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), false);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 0, 100, 100)));
@@ -1766,10 +1714,10 @@ protected:
// Occluded since its outside the surface bounds.
EXPECT_TRUE(occlusion.occluded(layer, IntRect(200, 100, 100, 100)));
- // Test without any scissors.
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ // Test without any clip rect.
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
EXPECT_FALSE(occlusion.occluded(layer, IntRect(200, 100, 100, 100)));
- occlusion.useDefaultLayerScissorRect();
+ occlusion.useDefaultLayerClipRect();
this->leaveLayer(layer, occlusion);
this->visitContributingSurface(layer, occlusion);
@@ -1792,7 +1740,7 @@ protected:
this->calcDrawEtc(parent);
{
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
layer->setOpaqueContentsRect(IntRect(0, 0, 100, 100));
this->resetLayerIterator();
@@ -1808,7 +1756,7 @@ protected:
}
{
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
layer->setOpaqueContentsRect(IntRect(20, 20, 180, 180));
this->resetLayerIterator();
@@ -1824,7 +1772,7 @@ protected:
}
{
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
layer->setOpaqueContentsRect(IntRect(150, 150, 100, 100));
this->resetLayerIterator();
@@ -1856,7 +1804,7 @@ protected:
typename Types::ContentLayerType* layer = this->createDrawingLayer(container, transform, FloatPoint(100, 100), IntSize(200, 200), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
// The layer is rotated in 3d but without preserving 3d, so it only gets resized.
@@ -1890,7 +1838,7 @@ protected:
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->visitLayer(child2, occlusion);
EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty());
EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty());
@@ -1922,7 +1870,7 @@ protected:
layer->setPreserves3D(true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
EXPECT_INT_RECT_EQ(IntRect(0, 0, 200, 200), occlusion.unoccludedContentRect(layer, IntRect(0, 0, 200, 200)));
@@ -1953,7 +1901,7 @@ protected:
layer->setPreserves3D(true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
// The bottom 11 pixel rows of this layer remain visible inside the container, after translation to the target surface. When translated back,
@@ -1982,7 +1930,7 @@ protected:
layer->setPreserves3D(true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
// The |layer| is entirely behind the camera and should not occlude.
this->visitLayer(layer, occlusion);
@@ -2012,7 +1960,7 @@ protected:
layer->setPreserves3D(true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
// This is very close to the camera, so pixels in its visibleContentRect will actually go outside of the layer's clipRect.
// Ensure that those pixels don't occlude things outside the clipRect.
@@ -2049,7 +1997,7 @@ protected:
EXPECT_FALSE(surface->drawOpacityIsAnimating());
EXPECT_TRUE(surface->renderSurface()->drawOpacityIsAnimating());
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->visitLayer(topmost, occlusion);
this->enterLayer(parent2, occlusion);
@@ -2101,7 +2049,7 @@ protected:
EXPECT_FALSE(surface->drawOpacityIsAnimating());
EXPECT_TRUE(surface->renderSurface()->drawOpacityIsAnimating());
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->visitLayer(topmost, occlusion);
this->enterLayer(parent2, occlusion);
@@ -2159,7 +2107,7 @@ protected:
EXPECT_TRUE(surfaceChild->drawTransformIsAnimating());
EXPECT_TRUE(surfaceChild->screenSpaceTransformIsAnimating());
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->visitLayer(surface2, occlusion);
this->enterContributingSurface(surface2, occlusion);
@@ -2241,7 +2189,7 @@ protected:
surface2->setOpaqueContentsRect(IntRect(0, 0, 200, 200));
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->visitLayer(surface2, occlusion);
this->visitContributingSurface(surface2, occlusion);
@@ -2277,7 +2225,7 @@ protected:
surface->setOpaqueContentsRect(IntRect(0, 0, 400, 200));
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->visitLayer(surface, occlusion);
this->visitContributingSurface(surface, occlusion);
@@ -2302,8 +2250,8 @@ protected:
typename Types::LayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(100, 100), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
// |topmost| occludes the replica, but not the surface itself.
this->visitLayer(topmost, occlusion);
@@ -2340,8 +2288,8 @@ protected:
typename Types::LayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 110), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
// |topmost| occludes the surface, but not the entire surface's replica.
this->visitLayer(topmost, occlusion);
@@ -2380,8 +2328,8 @@ protected:
typename Types::LayerType* overReplica = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(50, 100), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
// These occlude the surface and replica differently, so we can test each one.
this->visitLayer(overReplica, occlusion);
@@ -2422,7 +2370,7 @@ protected:
typename Types::LayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 50), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(-100, -100, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(-100, -100, 1000, 1000));
// |topmost| occludes everything partially so we know occlusion is happening at all.
this->visitLayer(topmost, occlusion);
@@ -2468,19 +2416,19 @@ protected:
ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestSurfaceChildOfSurface);
template<class Types, bool opaqueLayers>
-class CCOcclusionTrackerTestTopmostSurfaceIsClippedToScissor : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+class CCOcclusionTrackerTestTopmostSurfaceIsClippedToViewport : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
{
- // This test verifies that the top-most surface is considered occluded outside of its scissor rect and outside the screen's scissor rect.
+ // This test verifies that the top-most surface is considered occluded outside of its target's clipRect and outside the viewport rect.
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200));
typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true);
this->calcDrawEtc(parent);
{
- // Make a screen scissor rect that is larger than the root layer's.
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ // Make a viewport rect that is larger than the root layer.
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->visitLayer(surface, occlusion);
@@ -2491,20 +2439,20 @@ protected:
}
this->resetLayerIterator();
{
- // Make a screen scissor rect that is smaller than the root layer's.
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 100, 100));
+ // Make a viewport rect that is smaller than the root layer.
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 100, 100));
this->visitLayer(surface, occlusion);
// The root layer always has a clipRect. So the parent of |surface| has a clipRect giving the surface itself a clipRect.
this->enterContributingSurface(surface, occlusion);
- // Make sure the screen scissor rect clips the unoccluded region of the child surface.
+ // Make sure the viewport rect clips the unoccluded region of the child surface.
EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 300)));
}
}
};
-ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestTopmostSurfaceIsClippedToScissor);
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestTopmostSurfaceIsClippedToViewport);
template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestSurfaceChildOfClippingSurface : public CCOcclusionTrackerTest<Types, opaqueLayers> {
@@ -2519,8 +2467,8 @@ protected:
typename Types::LayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 50), true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
// |topmost| occludes everything partially so we know occlusion is happening at all.
this->visitLayer(topmost, occlusion);
@@ -2587,8 +2535,8 @@ protected:
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
// These layers occlude pixels directly beside the filteredSurface. Because filtered surface blends pixels in a radius, it will
// need to see some of the pixels (up to radius far) underneath the occludingLayers.
@@ -2709,8 +2657,8 @@ protected:
this->calcDrawEtc(root);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(occludingLayerAbove, occlusion);
EXPECT_INT_RECT_EQ(IntRect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.occlusionInScreenSpace().bounds());
@@ -2773,8 +2721,8 @@ protected:
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
// These layers occlude pixels directly beside the filteredSurface. Because filtered surface blends pixels in a radius, it will
// need to see some of the pixels (up to radius far) underneath the occludingLayers.
@@ -2892,8 +2840,8 @@ protected:
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
// The surface has a background blur, so it blurs non-opaque pixels below it.
this->visitLayer(filteredSurface, occlusion);
@@ -2941,8 +2889,8 @@ protected:
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(aboveReplicaLayer, occlusion);
this->visitLayer(aboveSurfaceLayer, occlusion);
@@ -2995,8 +2943,8 @@ protected:
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(besideReplicaLayer, occlusion);
this->visitLayer(besideSurfaceLayer, occlusion);
@@ -3050,8 +2998,8 @@ protected:
typename Types::LayerType* small = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), belowTrackingSize, true);
this->calcDrawEtc(parent);
- TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
- occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
+ TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+ occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
occlusion.setMinimumTrackingSize(trackingSize);
// The small layer is not tracked because it is too small.
diff --git a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp
index 9eff157bc..8279a3a6b 100644
--- a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp
@@ -27,6 +27,7 @@
#include "cc/CCQuadCuller.h"
#include "cc/CCLayerTilingData.h"
+#include "cc/CCMathUtil.h"
#include "cc/CCOcclusionTracker.h"
#include "cc/CCOverdrawMetrics.h"
#include "cc/CCSingleThreadProxy.h"
@@ -80,6 +81,7 @@ static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const We
layer->pushTileProperties(i, j, resourceId++, tileOpaqueRect);
}
+ IntRect rectInTarget = CCMathUtil::mapClippedRect(layer->drawTransform(), layer->visibleContentRect());
if (!parent) {
layer->createRenderSurface();
surfaceLayerList.append(layer.get());
@@ -87,7 +89,9 @@ static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const We
} else {
layer->setRenderTarget(parent->renderTarget());
parent->renderSurface()->layerList().append(layer.get());
+ rectInTarget.unite(CCMathUtil::mapClippedRect(parent->drawTransform(), parent->visibleContentRect()));
}
+ layer->setDrawableContentRect(rectInTarget);
return layer.release();
}
diff --git a/Source/WebKit/chromium/tests/CCRenderSurfaceFiltersTest.cpp b/Source/WebKit/chromium/tests/CCRenderSurfaceFiltersTest.cpp
new file mode 100644
index 000000000..b56a7fb42
--- /dev/null
+++ b/Source/WebKit/chromium/tests/CCRenderSurfaceFiltersTest.cpp
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "cc/CCRenderSurfaceFilters.h"
+
+#include "CompositorFakeWebGraphicsContext3D.h"
+#include <gtest/gtest.h>
+#include <public/WebFilterOperation.h>
+#include <public/WebFilterOperations.h>
+#include <wtf/RefPtr.h>
+
+using namespace WebCore;
+using namespace WebKit;
+
+namespace {
+
+// Checks whether op can be combined with a following color matrix.
+bool isCombined(const WebFilterOperation& op)
+{
+ WebFilterOperations filters;
+ filters.append(op);
+ filters.append(WebFilterOperation::createBrightnessFilter(0)); // brightness(0) is identity.
+ WebFilterOperations optimized = CCRenderSurfaceFilters::optimize(filters);
+ return optimized.size() == 1;
+}
+
+TEST(CCRenderSurfaceFiltersTest, testColorMatrixFiltersCombined)
+{
+ // Several filters should always combine for any amount between 0 and 1:
+ // grayscale, saturate, invert, contrast, opacity.
+ EXPECT_TRUE(isCombined(WebFilterOperation::createGrayscaleFilter(0)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createGrayscaleFilter(0.3)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createGrayscaleFilter(0.5)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createGrayscaleFilter(1)));
+
+ EXPECT_TRUE(isCombined(WebFilterOperation::createSaturateFilter(0)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createSaturateFilter(0.3)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createSaturateFilter(0.5)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createSaturateFilter(1)));
+
+ EXPECT_TRUE(isCombined(WebFilterOperation::createInvertFilter(0)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createInvertFilter(0.3)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createInvertFilter(0.5)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createInvertFilter(1)));
+
+ EXPECT_TRUE(isCombined(WebFilterOperation::createContrastFilter(0)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createContrastFilter(0.3)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createContrastFilter(0.5)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createContrastFilter(1)));
+
+ EXPECT_TRUE(isCombined(WebFilterOperation::createOpacityFilter(0)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createOpacityFilter(0.3)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createOpacityFilter(0.5)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createOpacityFilter(1)));
+
+ // Several filters should never combine: brightness(amount > 0), blur, drop-shadow.
+ EXPECT_FALSE(isCombined(WebFilterOperation::createBrightnessFilter(0.5)));
+ EXPECT_FALSE(isCombined(WebFilterOperation::createBrightnessFilter(1)));
+ EXPECT_FALSE(isCombined(WebFilterOperation::createBlurFilter(3)));
+ EXPECT_FALSE(isCombined(WebFilterOperation::createDropShadowFilter(WebPoint(2, 2), 3, 0xffffffff)));
+
+ // sepia and hue may or may not combine depending on the value.
+ EXPECT_TRUE(isCombined(WebFilterOperation::createSepiaFilter(0)));
+ EXPECT_FALSE(isCombined(WebFilterOperation::createSepiaFilter(1)));
+ EXPECT_TRUE(isCombined(WebFilterOperation::createHueRotateFilter(0)));
+ EXPECT_FALSE(isCombined(WebFilterOperation::createHueRotateFilter(180)));
+
+ float matrix1[20] = {
+ 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 1, 0,
+ };
+ EXPECT_TRUE(isCombined(WebFilterOperation::createColorMatrixFilter(matrix1)));
+
+ float matrix2[20] = {
+ 1, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 1, 0,
+ };
+ EXPECT_FALSE(isCombined(WebFilterOperation::createColorMatrixFilter(matrix2)));
+
+ float matrix3[20] = {
+ 0.25, 0, 0, 0, 255*0.75,
+ 0, 1, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 1, 0,
+ };
+ EXPECT_TRUE(isCombined(WebFilterOperation::createColorMatrixFilter(matrix3)));
+
+ float matrix4[20] = {
+ -0.25, 0.75, 0, 0, 255*0.25,
+ 0, 1, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 1, 0,
+ };
+ EXPECT_TRUE(isCombined(WebFilterOperation::createColorMatrixFilter(matrix4)));
+}
+
+TEST(CCRenderSurfaceFiltersTest, testOptimize)
+{
+ WebFilterOperation combines(WebFilterOperation::createBrightnessFilter(0));
+ WebFilterOperation doesntCombine(WebFilterOperation::createBrightnessFilter(1));
+
+ WebFilterOperations filters;
+ WebFilterOperations optimized = CCRenderSurfaceFilters::optimize(filters);
+ EXPECT_EQ(0u, optimized.size());
+
+ filters.append(combines);
+ optimized = CCRenderSurfaceFilters::optimize(filters);
+ EXPECT_EQ(1u, optimized.size());
+
+ filters.append(combines);
+ optimized = CCRenderSurfaceFilters::optimize(filters);
+ EXPECT_EQ(1u, optimized.size());
+
+ filters.append(doesntCombine);
+ optimized = CCRenderSurfaceFilters::optimize(filters);
+ EXPECT_EQ(1u, optimized.size());
+
+ filters.append(combines);
+ optimized = CCRenderSurfaceFilters::optimize(filters);
+ EXPECT_EQ(2u, optimized.size());
+
+ filters.append(doesntCombine);
+ optimized = CCRenderSurfaceFilters::optimize(filters);
+ EXPECT_EQ(2u, optimized.size());
+
+ filters.append(doesntCombine);
+ optimized = CCRenderSurfaceFilters::optimize(filters);
+ EXPECT_EQ(3u, optimized.size());
+}
+
+} // namespace
diff --git a/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp b/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp
index c95d71e84..ad8df2595 100644
--- a/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp
+++ b/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp
@@ -94,11 +94,16 @@ TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
// This will fake that we are on the correct thread for testing purposes.
DebugScopedSetImplThread setImplThread;
- OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(1);
+ OwnPtr<CCLayerImpl> rootLayer = CCLayerImpl::create(1);
+
+ OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(2);
owningLayer->createRenderSurface();
ASSERT_TRUE(owningLayer->renderSurface());
+ owningLayer->setRenderTarget(owningLayer.get());
CCRenderSurface* renderSurface = owningLayer->renderSurface();
+ rootLayer->addChild(owningLayer.release());
+
IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50));
IntRect clipRect = IntRect(IntPoint(5, 5), IntSize(40, 40));
WebTransformationMatrix origin;
@@ -108,7 +113,6 @@ TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
renderSurface->setDrawTransform(origin);
renderSurface->setContentRect(contentRect);
renderSurface->setClipRect(clipRect);
- renderSurface->setScissorRect(clipRect);
renderSurface->setDrawOpacity(1);
OwnPtr<CCSharedQuadState> sharedQuadState = renderSurface->createSharedQuadState(0);
@@ -116,7 +120,6 @@ TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
EXPECT_EQ(30, sharedQuadState->quadTransform.m41());
EXPECT_EQ(40, sharedQuadState->quadTransform.m42());
EXPECT_EQ(contentRect, IntRect(sharedQuadState->visibleContentRect));
- EXPECT_EQ(clipRect, IntRect(sharedQuadState->scissorRect));
EXPECT_EQ(1, sharedQuadState->opacity);
EXPECT_FALSE(sharedQuadState->opaque);
}
diff --git a/Source/WebKit/chromium/tests/CCResourceProviderTest.cpp b/Source/WebKit/chromium/tests/CCResourceProviderTest.cpp
index b2c41e525..42277459a 100644
--- a/Source/WebKit/chromium/tests/CCResourceProviderTest.cpp
+++ b/Source/WebKit/chromium/tests/CCResourceProviderTest.cpp
@@ -28,6 +28,7 @@
#include "CompositorFakeWebGraphicsContext3D.h"
#include "Extensions3DChromium.h"
+#include "FakeWebCompositorOutputSurface.h"
#include "cc/CCGraphicsContext.h"
#include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread
#include <gtest/gtest.h>
@@ -188,7 +189,7 @@ private:
class CCResourceProviderTest : public testing::Test {
public:
CCResourceProviderTest()
- : m_context(CCGraphicsContext::create3D(ResourceProviderContext::create()))
+ : m_context(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create()))
, m_resourceProvider(CCResourceProvider::create(m_context.get()))
{
}
diff --git a/Source/WebKit/chromium/tests/CCSchedulerTestCommon.h b/Source/WebKit/chromium/tests/CCSchedulerTestCommon.h
index 6257ec888..beb16554d 100644
--- a/Source/WebKit/chromium/tests/CCSchedulerTestCommon.h
+++ b/Source/WebKit/chromium/tests/CCSchedulerTestCommon.h
@@ -52,6 +52,12 @@ public:
{
m_pendingTaskDelay = 0;
m_pendingTask.clear();
+ m_runPendingTaskOnOverwrite = false;
+ }
+
+ void runPendingTaskOnOverwrite(bool enable)
+ {
+ m_runPendingTaskOnOverwrite = enable;
}
bool hasPendingTask() const { return m_pendingTask; }
@@ -71,6 +77,9 @@ public:
virtual void postTask(PassOwnPtr<Task>) { ASSERT_NOT_REACHED(); }
virtual void postDelayedTask(PassOwnPtr<Task> task, long long delay)
{
+ if (m_runPendingTaskOnOverwrite && hasPendingTask())
+ runPendingTask();
+
EXPECT_TRUE(!hasPendingTask());
m_pendingTask = task;
m_pendingTaskDelay = delay;
@@ -80,6 +89,7 @@ public:
protected:
OwnPtr<Task> m_pendingTask;
long long m_pendingTaskDelay;
+ bool m_runPendingTaskOnOverwrite;
};
class FakeCCTimeSource : public WebCore::CCTimeSource {
@@ -93,6 +103,9 @@ public:
virtual void setClient(WebCore::CCTimeSourceClient* client) OVERRIDE { m_client = client; }
virtual void setActive(bool b) OVERRIDE { m_active = b; }
virtual bool active() const OVERRIDE { return m_active; }
+ virtual void setTimebaseAndInterval(double timebase, double interval) OVERRIDE { }
+ virtual double lastTickTime() OVERRIDE { return 0; }
+ virtual double nextTickTime() OVERRIDE { return 0; }
void tick()
{
diff --git a/Source/WebKit/chromium/tests/CCScrollbarAnimationControllerLinearFadeTest.cpp b/Source/WebKit/chromium/tests/CCScrollbarAnimationControllerLinearFadeTest.cpp
new file mode 100644
index 000000000..e6cdc24c1
--- /dev/null
+++ b/Source/WebKit/chromium/tests/CCScrollbarAnimationControllerLinearFadeTest.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "cc/CCScrollbarAnimationControllerLinearFade.h"
+
+#include "cc/CCScrollbarLayerImpl.h"
+#include "cc/CCSingleThreadProxy.h"
+#include <gtest/gtest.h>
+#include <wtf/OwnPtr.h>
+
+using namespace WebCore;
+
+namespace {
+
+class CCScrollbarAnimationControllerLinearFadeTest : public testing::Test {
+protected:
+ virtual void SetUp()
+ {
+ m_scrollLayer = CCLayerImpl::create(1);
+ m_scrollLayer->addChild(CCLayerImpl::create(2));
+ m_contentLayer = m_scrollLayer->children()[0].get();
+ m_scrollbarLayer = CCScrollbarLayerImpl::create(3);
+
+ m_scrollLayer->setMaxScrollPosition(IntSize(50, 50));
+ m_contentLayer->setBounds(IntSize(50, 50));
+
+ m_scrollbarController = CCScrollbarAnimationControllerLinearFade::create(m_scrollLayer.get(), 2, 3);
+ m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get());
+ }
+
+ DebugScopedSetImplThread implThread;
+
+ OwnPtr<CCScrollbarAnimationControllerLinearFade> m_scrollbarController;
+ OwnPtr<CCLayerImpl> m_scrollLayer;
+ CCLayerImpl* m_contentLayer;
+ OwnPtr<CCScrollbarLayerImpl> m_scrollbarLayer;
+
+};
+
+TEST_F(CCScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin)
+{
+ m_scrollbarController->animate(0);
+ EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
+ m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0);
+ m_scrollbarController->animate(0);
+ EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
+}
+
+TEST_F(CCScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll)
+{
+ m_scrollLayer->setScrollDelta(IntSize(1, 1));
+ m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0);
+ m_scrollbarController->animate(0);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(1);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollLayer->setScrollDelta(IntSize(2, 2));
+ m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1);
+ m_scrollbarController->animate(2);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(3);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(4);
+ EXPECT_FLOAT_EQ(2 / 3.0, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(5);
+ EXPECT_FLOAT_EQ(1 / 3.0, m_scrollbarLayer->opacity());
+ m_scrollLayer->setScrollDelta(IntSize(3, 3));
+ m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 5);
+ m_scrollbarController->animate(6);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(7);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(8);
+ EXPECT_FLOAT_EQ(2 / 3.0, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(9);
+ EXPECT_FLOAT_EQ(1 / 3.0, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(10);
+ EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
+}
+
+TEST_F(CCScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch)
+{
+ m_scrollbarController->didPinchGestureBeginAtTime(0);
+ m_scrollbarController->didPinchGestureUpdateAtTime(0);
+ m_scrollbarController->animate(0);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(1);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollLayer->setScrollDelta(IntSize(1, 1));
+ m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1);
+ m_scrollbarController->animate(2);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(3);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(4);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(5);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(6);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->didPinchGestureEndAtTime(6);
+ m_scrollbarController->animate(7);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(8);
+ EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(9);
+ EXPECT_FLOAT_EQ(2 / 3.0, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(10);
+ EXPECT_FLOAT_EQ(1 / 3.0, m_scrollbarLayer->opacity());
+ m_scrollbarController->animate(11);
+ EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
+
+}
+
+}
diff --git a/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp
index 1754a5b12..141a96328 100644
--- a/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp
+++ b/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp
@@ -51,6 +51,8 @@ TEST(CCSolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap)
layer->setVisibleContentRect(visibleContentRect);
layer->setBounds(layerSize);
layer->setContentBounds(layerSize);
+ layer->createRenderSurface();
+ layer->setRenderTarget(layer.get());
OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0);
bool hadMissingTiles = false;
@@ -74,6 +76,8 @@ TEST(CCSolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad)
layer->setBounds(layerSize);
layer->setContentBounds(layerSize);
layer->setBackgroundColor(testColor);
+ layer->createRenderSurface();
+ layer->setRenderTarget(layer.get());
OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0);
bool hadMissingTiles = false;
@@ -98,6 +102,8 @@ TEST(CCSolidColorLayerImplTest, verifyCorrectOpacityInQuad)
layer->setBounds(layerSize);
layer->setContentBounds(layerSize);
layer->setDrawOpacity(opacity);
+ layer->createRenderSurface();
+ layer->setRenderTarget(layer.get());
OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(0);
bool hadMissingTiles = false;
diff --git a/Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp b/Source/WebKit/chromium/tests/CCTextureUpdateControllerTest.cpp
index bfb35c048..a0dc2ec1f 100644
--- a/Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp
+++ b/Source/WebKit/chromium/tests/CCTextureUpdateControllerTest.cpp
@@ -24,14 +24,15 @@
#include "config.h"
-#include "cc/CCTextureUpdater.h"
+#include "cc/CCTextureUpdateController.h"
+#include "CCSchedulerTestCommon.h"
#include "CCTiledLayerTestCommon.h"
+#include "FakeWebCompositorOutputSurface.h"
#include "FakeWebGraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
-#include "WebCompositor.h"
#include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread
-#include "platform/WebThread.h"
+#include <public/WebCompositor.h>
+#include <public/WebThread.h>
#include <gtest/gtest.h>
#include <wtf/RefPtr.h>
@@ -47,11 +48,11 @@ namespace {
const int kFlushPeriodFull = 4;
const int kFlushPeriodPartial = kFlushPeriodFull;
-class CCTextureUpdaterTest;
+class CCTextureUpdateControllerTest;
class WebGraphicsContext3DForUploadTest : public FakeWebGraphicsContext3D {
public:
- WebGraphicsContext3DForUploadTest(CCTextureUpdaterTest *test)
+ WebGraphicsContext3DForUploadTest(CCTextureUpdateControllerTest *test)
: m_test(test)
, m_supportShallowFlush(true)
{ }
@@ -68,27 +69,23 @@ public:
}
private:
- CCTextureUpdaterTest* m_test;
+ CCTextureUpdateControllerTest* m_test;
bool m_supportShallowFlush;
};
class TextureUploaderForUploadTest : public FakeTextureUploader {
public:
- TextureUploaderForUploadTest(CCTextureUpdaterTest *test) : m_test(test) { }
+ TextureUploaderForUploadTest(CCTextureUpdateControllerTest *test) : m_test(test) { }
virtual void beginUploads() OVERRIDE;
virtual void endUploads() OVERRIDE;
- virtual void uploadTexture(WebCore::LayerTextureUpdater::Texture*,
- WebCore::CCResourceProvider*,
- const WebCore::IntRect sourceRect,
- const WebCore::IntRect destRect) OVERRIDE;
+ virtual void uploadTexture(WebCore::CCResourceProvider*, Parameters) OVERRIDE;
private:
- CCTextureUpdaterTest* m_test;
+ CCTextureUpdateControllerTest* m_test;
};
-
class TextureForUploadTest : public LayerTextureUpdater::Texture {
public:
TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritizedTexture>(0)) { }
@@ -96,10 +93,11 @@ public:
};
-class CCTextureUpdaterTest : public Test {
+class CCTextureUpdateControllerTest : public Test {
public:
- CCTextureUpdaterTest()
- : m_uploader(this)
+ CCTextureUpdateControllerTest()
+ : m_queue(adoptPtr(new CCTextureUpdateQueue))
+ , m_uploader(this)
, m_fullUploadCountExpected(0)
, m_partialCountExpected(0)
, m_totalUploadCountExpected(0)
@@ -176,8 +174,7 @@ protected:
OwnPtr<WebThread> thread;
WebCompositor::initialize(thread.get());
- m_context = CCGraphicsContext::create3D(
- adoptPtr(new WebGraphicsContext3DForUploadTest(this)));
+ m_context = FakeWebCompositorOutputSurface::create(adoptPtr(new WebGraphicsContext3DForUploadTest(this)));
DebugScopedSetImplThread implThread;
m_resourceProvider = CCResourceProvider::create(m_context.get());
}
@@ -187,24 +184,26 @@ protected:
WebCompositor::shutdown();
}
- void appendFullUploadsToUpdater(int count)
+ void appendFullUploadsToUpdateQueue(int count)
{
m_fullUploadCountExpected += count;
m_totalUploadCountExpected += count;
const IntRect rect(0, 0, 300, 150);
+ const TextureUploader::Parameters upload = { &m_texture, rect, rect };
for (int i = 0; i < count; i++)
- m_updater.appendFullUpdate(&m_texture, rect, rect);
+ m_queue->appendFullUpload(upload);
}
- void appendPartialUploadsToUpdater(int count)
+ void appendPartialUploadsToUpdateQueue(int count)
{
m_partialCountExpected += count;
m_totalUploadCountExpected += count;
const IntRect rect(0, 0, 100, 100);
+ const TextureUploader::Parameters upload = { &m_texture, rect, rect };
for (int i = 0; i < count; i++)
- m_updater.appendPartialUpdate(&m_texture, rect, rect);
+ m_queue->appendPartialUpload(upload);
}
void setMaxUploadCountPerUpdate(int count)
@@ -213,10 +212,10 @@ protected:
}
protected:
- // Classes required to interact and test the CCTextureUpdater
+ // Classes required to interact and test the CCTextureUpdateController
OwnPtr<CCGraphicsContext> m_context;
OwnPtr<CCResourceProvider> m_resourceProvider;
- CCTextureUpdater m_updater;
+ OwnPtr<CCTextureUpdateQueue> m_queue;
TextureForUploadTest m_texture;
FakeTextureCopier m_copier;
TextureUploaderForUploadTest m_uploader;
@@ -238,7 +237,6 @@ protected:
int m_numPreviousFlushes;
};
-
void WebGraphicsContext3DForUploadTest::flush(void)
{
m_test->onFlush();
@@ -259,21 +257,18 @@ void TextureUploaderForUploadTest::endUploads()
m_test->onEndUploads();
}
-void TextureUploaderForUploadTest::uploadTexture(WebCore::LayerTextureUpdater::Texture* texture,
- WebCore::CCResourceProvider*,
- const WebCore::IntRect sourceRect,
- const WebCore::IntRect destRect)
+void TextureUploaderForUploadTest::uploadTexture(WebCore::CCResourceProvider*, Parameters)
{
m_test->onUpload();
}
// ZERO UPLOADS TESTS
-TEST_F(CCTextureUpdaterTest, ZeroUploads)
+TEST_F(CCTextureUpdateControllerTest, ZeroUploads)
{
- appendFullUploadsToUpdater(0);
- appendPartialUploadsToUpdater(0);
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ appendFullUploadsToUpdateQueue(0);
+ appendPartialUploadsToUpdateQueue(0);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(0, m_numBeginUploads);
EXPECT_EQ(0, m_numEndUploads);
@@ -283,12 +278,12 @@ TEST_F(CCTextureUpdaterTest, ZeroUploads)
// ONE UPLOAD TESTS
-TEST_F(CCTextureUpdaterTest, OneFullUpload)
+TEST_F(CCTextureUpdateControllerTest, OneFullUpload)
{
- appendFullUploadsToUpdater(1);
- appendPartialUploadsToUpdater(0);
+ appendFullUploadsToUpdateQueue(1);
+ appendPartialUploadsToUpdateQueue(0);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -296,12 +291,12 @@ TEST_F(CCTextureUpdaterTest, OneFullUpload)
EXPECT_EQ(1, m_numPreviousUploads);
}
-TEST_F(CCTextureUpdaterTest, OnePartialUpload)
+TEST_F(CCTextureUpdateControllerTest, OnePartialUpload)
{
- appendFullUploadsToUpdater(0);
- appendPartialUploadsToUpdater(1);
+ appendFullUploadsToUpdateQueue(0);
+ appendPartialUploadsToUpdateQueue(1);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -309,12 +304,12 @@ TEST_F(CCTextureUpdaterTest, OnePartialUpload)
EXPECT_EQ(1, m_numPreviousUploads);
}
-TEST_F(CCTextureUpdaterTest, OneFullOnePartialUpload)
+TEST_F(CCTextureUpdateControllerTest, OneFullOnePartialUpload)
{
- appendFullUploadsToUpdater(1);
- appendPartialUploadsToUpdater(1);
+ appendFullUploadsToUpdateQueue(1);
+ appendPartialUploadsToUpdateQueue(1);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
// We expect the full uploads to be followed by a flush
// before the partial uploads begin.
@@ -333,12 +328,12 @@ const int fullNoRemainderCount = fullUploadFlushMultipler * kFlushPeriodFull;
const int partialUploadFlushMultipler = 11;
const int partialNoRemainderCount = partialUploadFlushMultipler * kFlushPeriodPartial;
-TEST_F(CCTextureUpdaterTest, ManyFullUploadsNoRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullUploadsNoRemainder)
{
- appendFullUploadsToUpdater(fullNoRemainderCount);
- appendPartialUploadsToUpdater(0);
+ appendFullUploadsToUpdateQueue(fullNoRemainderCount);
+ appendPartialUploadsToUpdateQueue(0);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -346,12 +341,12 @@ TEST_F(CCTextureUpdaterTest, ManyFullUploadsNoRemainder)
EXPECT_EQ(fullNoRemainderCount, m_numPreviousUploads);
}
-TEST_F(CCTextureUpdaterTest, ManyPartialUploadsNoRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyPartialUploadsNoRemainder)
{
- appendFullUploadsToUpdater(0);
- appendPartialUploadsToUpdater(partialNoRemainderCount);
+ appendFullUploadsToUpdateQueue(0);
+ appendPartialUploadsToUpdateQueue(partialNoRemainderCount);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -359,12 +354,12 @@ TEST_F(CCTextureUpdaterTest, ManyPartialUploadsNoRemainder)
EXPECT_EQ(partialNoRemainderCount, m_numPreviousUploads);
}
-TEST_F(CCTextureUpdaterTest, ManyFullManyPartialUploadsNoRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullManyPartialUploadsNoRemainder)
{
- appendFullUploadsToUpdater(fullNoRemainderCount);
- appendPartialUploadsToUpdater(partialNoRemainderCount);
+ appendFullUploadsToUpdateQueue(fullNoRemainderCount);
+ appendPartialUploadsToUpdateQueue(partialNoRemainderCount);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -382,12 +377,12 @@ const int fullMaxRemainderCount = fullNoRemainderCount - 1;
const int partialMinRemainderCount = partialNoRemainderCount + 1;
const int partialMaxRemainderCount = partialNoRemainderCount - 1;
-TEST_F(CCTextureUpdaterTest, ManyFullAndPartialMinRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullAndPartialMinRemainder)
{
- appendFullUploadsToUpdater(fullMinRemainderCount);
- appendPartialUploadsToUpdater(partialMinRemainderCount);
+ appendFullUploadsToUpdateQueue(fullMinRemainderCount);
+ appendPartialUploadsToUpdateQueue(partialMinRemainderCount);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -395,12 +390,12 @@ TEST_F(CCTextureUpdaterTest, ManyFullAndPartialMinRemainder)
EXPECT_EQ(fullMinRemainderCount + partialMinRemainderCount, m_numPreviousUploads);
}
-TEST_F(CCTextureUpdaterTest, ManyFullAndPartialUploadsMaxRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullAndPartialUploadsMaxRemainder)
{
- appendFullUploadsToUpdater(fullMaxRemainderCount);
- appendPartialUploadsToUpdater(partialMaxRemainderCount);
+ appendFullUploadsToUpdateQueue(fullMaxRemainderCount);
+ appendPartialUploadsToUpdateQueue(partialMaxRemainderCount);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -408,12 +403,12 @@ TEST_F(CCTextureUpdaterTest, ManyFullAndPartialUploadsMaxRemainder)
EXPECT_EQ(fullMaxRemainderCount + partialMaxRemainderCount, m_numPreviousUploads);
}
-TEST_F(CCTextureUpdaterTest, ManyFullMinRemainderManyPartialMaxRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullMinRemainderManyPartialMaxRemainder)
{
- appendFullUploadsToUpdater(fullMinRemainderCount);
- appendPartialUploadsToUpdater(partialMaxRemainderCount);
+ appendFullUploadsToUpdateQueue(fullMinRemainderCount);
+ appendPartialUploadsToUpdateQueue(partialMaxRemainderCount);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -421,12 +416,12 @@ TEST_F(CCTextureUpdaterTest, ManyFullMinRemainderManyPartialMaxRemainder)
EXPECT_EQ(fullMinRemainderCount + partialMaxRemainderCount, m_numPreviousUploads);
}
-TEST_F(CCTextureUpdaterTest, ManyFullMaxRemainderManyPartialMinRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullMaxRemainderManyPartialMinRemainder)
{
- appendFullUploadsToUpdater(fullMaxRemainderCount);
- appendPartialUploadsToUpdater(partialMinRemainderCount);
+ appendFullUploadsToUpdateQueue(fullMaxRemainderCount);
+ appendPartialUploadsToUpdateQueue(partialMinRemainderCount);
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), m_totalUploadCountExpected);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -444,7 +439,7 @@ int expectedFlushes(int uploads, int flushPeriod)
return (uploads + flushPeriod - 1) / flushPeriod;
}
-TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
+TEST_F(CCTextureUpdateControllerTest, TripleUpdateFinalUpdateFullAndPartial)
{
const int kMaxUploadsPerUpdate = 40;
const int kFullUploads = 100;
@@ -454,12 +449,12 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
int expectedPreviousUploads = 0;
setMaxUploadCountPerUpdate(kMaxUploadsPerUpdate);
- appendFullUploadsToUpdater(kFullUploads);
- appendPartialUploadsToUpdater(kPartialUploads);
+ appendFullUploadsToUpdateQueue(kFullUploads);
+ appendPartialUploadsToUpdateQueue(kPartialUploads);
// First update (40 full)
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), kMaxUploadsPerUpdate);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -471,7 +466,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
EXPECT_EQ(expectedPreviousUploads, m_numPreviousUploads);
// Second update (40 full)
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), kMaxUploadsPerUpdate);
EXPECT_EQ(2, m_numBeginUploads);
EXPECT_EQ(2, m_numEndUploads);
@@ -483,7 +478,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
EXPECT_EQ(expectedPreviousUploads, m_numPreviousUploads);
// Third update (20 full, 20 partial)
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), kMaxUploadsPerUpdate);
EXPECT_EQ(3, m_numBeginUploads);
EXPECT_EQ(3, m_numEndUploads);
@@ -499,7 +494,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
EXPECT_EQ(kFullUploads + kPartialUploads, m_numTotalUploads);
}
-TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
+TEST_F(CCTextureUpdateControllerTest, TripleUpdateFinalUpdateAllPartial)
{
const int kMaxUploadsPerUpdate = 40;
const int kFullUploads = 70;
@@ -509,12 +504,12 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
int expectedPreviousUploads = 0;
setMaxUploadCountPerUpdate(kMaxUploadsPerUpdate);
- appendFullUploadsToUpdater(kFullUploads);
- appendPartialUploadsToUpdater(kPartialUploads);
+ appendFullUploadsToUpdateQueue(kFullUploads);
+ appendPartialUploadsToUpdateQueue(kPartialUploads);
// First update (40 full)
DebugScopedSetImplThread implThread;
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), kMaxUploadsPerUpdate);
EXPECT_EQ(1, m_numBeginUploads);
EXPECT_EQ(1, m_numEndUploads);
@@ -526,7 +521,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
EXPECT_EQ(expectedPreviousUploads, m_numPreviousUploads);
// Second update (30 full, optionally 10 partial)
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), kMaxUploadsPerUpdate);
EXPECT_EQ(2, m_numBeginUploads);
EXPECT_EQ(2, m_numEndUploads);
@@ -536,7 +531,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
// onFlush(), onUpload(), and onEndUpload() will do basic flush checks for us anyway.
// Third update (30 partial OR 20 partial if 10 partial uploaded in second update)
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_queue.get(), kMaxUploadsPerUpdate);
EXPECT_EQ(3, m_numBeginUploads);
EXPECT_EQ(3, m_numEndUploads);
@@ -547,5 +542,4 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
EXPECT_EQ(kFullUploads + kPartialUploads, m_numTotalUploads);
}
-
} // namespace
diff --git a/Source/WebKit/chromium/tests/CCThreadedTest.cpp b/Source/WebKit/chromium/tests/CCThreadedTest.cpp
index 2e2c1a06f..89ff9cba3 100644
--- a/Source/WebKit/chromium/tests/CCThreadedTest.cpp
+++ b/Source/WebKit/chromium/tests/CCThreadedTest.cpp
@@ -26,31 +26,28 @@
#include "CCThreadedTest.h"
-#include "AnimationIdVendor.h"
#include "CCAnimationTestCommon.h"
#include "CCOcclusionTrackerTestCommon.h"
#include "CCTiledLayerTestCommon.h"
#include "ContentLayerChromium.h"
+#include "FakeWebCompositorOutputSurface.h"
#include "FakeWebGraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
#include "LayerChromium.h"
-#include "WebCompositor.h"
-#include "WebKit.h"
#include "cc/CCActiveAnimation.h"
#include "cc/CCLayerAnimationController.h"
-#include "cc/CCLayerAnimationDelegate.h"
#include "cc/CCLayerImpl.h"
#include "cc/CCLayerTreeHostImpl.h"
#include "cc/CCScopedThreadProxy.h"
#include "cc/CCSingleThreadProxy.h"
-#include "cc/CCTextureUpdater.h"
+#include "cc/CCTextureUpdateQueue.h"
#include "cc/CCThreadTask.h"
#include "cc/CCTimingFunction.h"
-#include "platform/WebThread.h"
#include <gmock/gmock.h>
#include <public/Platform.h>
+#include <public/WebCompositor.h>
#include <public/WebFilterOperation.h>
#include <public/WebFilterOperations.h>
+#include <public/WebThread.h>
#include <wtf/Locker.h>
#include <wtf/MainThread.h>
#include <wtf/PassRefPtr.h>
@@ -102,9 +99,9 @@ CompositorFakeWebGraphicsContext3DWithTextureTracking::CompositorFakeWebGraphics
{
}
-PassOwnPtr<WebGraphicsContext3D> TestHooks::createContext()
+PassOwnPtr<WebCompositorOutputSurface> TestHooks::createOutputSurface()
{
- return CompositorFakeWebGraphicsContext3DWithTextureTracking::create(WebGraphicsContext3D::Attributes());
+ return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3DWithTextureTracking::create(WebGraphicsContext3D::Attributes()));
}
PassOwnPtr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testHooks, const CCLayerTreeSettings& settings, CCLayerTreeHostImplClient* client)
@@ -167,7 +164,7 @@ public:
layerTreeHost->setRootLayer(rootLayer);
// LayerTreeHostImpl won't draw if it has 1x1 viewport.
- layerTreeHost->setViewportSize(IntSize(1, 1));
+ layerTreeHost->setViewportSize(IntSize(1, 1), IntSize(1, 1));
layerTreeHost->rootLayer()->setLayerAnimationDelegate(testHooks);
@@ -226,9 +223,9 @@ public:
m_testHooks->applyScrollAndScale(scrollDelta, scale);
}
- virtual PassOwnPtr<WebGraphicsContext3D> createContext3D() OVERRIDE
+ virtual PassOwnPtr<WebCompositorOutputSurface> createOutputSurface() OVERRIDE
{
- return m_testHooks->createContext();
+ return m_testHooks->createOutputSurface();
}
virtual void willCommit() OVERRIDE
@@ -249,9 +246,9 @@ public:
{
}
- virtual void didRecreateContext(bool succeeded) OVERRIDE
+ virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE
{
- m_testHooks->didRecreateContext(succeeded);
+ m_testHooks->didRecreateOutputSurface(succeeded);
}
virtual void scheduleComposite() OVERRIDE
diff --git a/Source/WebKit/chromium/tests/CCThreadedTest.h b/Source/WebKit/chromium/tests/CCThreadedTest.h
index 75886effe..946b65fd1 100644
--- a/Source/WebKit/chromium/tests/CCThreadedTest.h
+++ b/Source/WebKit/chromium/tests/CCThreadedTest.h
@@ -26,11 +26,11 @@
#define CCThreadedTest_h
#include "CompositorFakeWebGraphicsContext3D.h"
-#include "cc/CCLayerAnimationDelegate.h"
#include "cc/CCLayerTreeHost.h"
#include "cc/CCLayerTreeHostImpl.h"
#include "cc/CCScopedThreadProxy.h"
#include <gtest/gtest.h>
+#include <public/WebAnimationDelegate.h>
namespace WebCore {
class CCLayerImpl;
@@ -47,7 +47,7 @@ class WebThread;
namespace WebKitTests {
// Used by test stubs to notify the test when something interesting happens.
-class TestHooks : public WebCore::CCLayerAnimationDelegate {
+class TestHooks : public WebKit::WebAnimationDelegate {
public:
virtual void beginCommitOnCCThread(WebCore::CCLayerTreeHostImpl*) { }
virtual void commitCompleteOnCCThread(WebCore::CCLayerTreeHostImpl*) { }
@@ -58,17 +58,17 @@ public:
virtual void applyScrollAndScale(const WebCore::IntSize&, float) { }
virtual void updateAnimations(double monotonicTime) { }
virtual void layout() { }
- virtual void didRecreateContext(bool succeeded) { }
+ virtual void didRecreateOutputSurface(bool succeeded) { }
virtual void didAddAnimation() { }
virtual void didCommit() { }
virtual void didCommitAndDrawFrame() { }
virtual void scheduleComposite() { }
- // Implementation of CCLayerAnimationDelegate
- virtual void notifyAnimationStarted(double time) { }
- virtual void notifyAnimationFinished(double time) { }
+ // Implementation of WebAnimationDelegate
+ virtual void notifyAnimationStarted(double time) OVERRIDE { }
+ virtual void notifyAnimationFinished(double time) OVERRIDE { }
- virtual PassOwnPtr<WebKit::WebGraphicsContext3D> createContext();
+ virtual PassOwnPtr<WebKit::WebCompositorOutputSurface> createOutputSurface();
};
class TimeoutTask;
diff --git a/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp
index a0850b251..8d3ca4219 100644
--- a/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp
+++ b/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp
@@ -52,6 +52,8 @@ static PassOwnPtr<CCTiledLayerImpl> createLayer(const IntSize& tileSize, const I
layer->setDrawOpacity(1);
layer->setBounds(layerSize);
layer->setContentBounds(layerSize);
+ layer->createRenderSurface();
+ layer->setRenderTarget(layer.get());
CCResourceProvider::ResourceId resourceId = 1;
for (int i = 0; i < tiler->numTilesX(); ++i)
diff --git a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp
index ec2105327..54f29bbef 100644
--- a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp
+++ b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp
@@ -115,9 +115,9 @@ void FakeTiledLayerChromium::setNeedsDisplayRect(const FloatRect& rect)
TiledLayerChromium::setNeedsDisplayRect(rect);
}
-void FakeTiledLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion, CCRenderingStats& stats)
+void FakeTiledLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTracker* occlusion, CCRenderingStats& stats)
{
- updateContentRect(updater, visibleContentRect(), occlusion, stats);
+ updateContentRect(queue, visibleContentRect(), occlusion, stats);
}
void FakeTiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& calculator)
diff --git a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h
index de1eb66c6..c75932acf 100644
--- a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h
+++ b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h
@@ -35,7 +35,7 @@
#include "cc/CCGraphicsContext.h"
#include "cc/CCPrioritizedTexture.h"
#include "cc/CCResourceProvider.h"
-#include "cc/CCTextureUpdater.h"
+#include "cc/CCTextureUpdateQueue.h"
#include "cc/CCTiledLayerImpl.h"
namespace WebKitTests {
@@ -122,7 +122,7 @@ public:
const WebCore::FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRect; }
// Updates the visibleContentRect().
- virtual void update(WebCore::CCTextureUpdater&, const WebCore::CCOcclusionTracker*, WebCore::CCRenderingStats&) OVERRIDE;
+ virtual void update(WebCore::CCTextureUpdateQueue&, const WebCore::CCOcclusionTracker*, WebCore::CCRenderingStats&) OVERRIDE;
virtual void setTexturePriorities(const WebCore::CCPriorityCalculator&) OVERRIDE;
@@ -153,7 +153,7 @@ protected:
class FakeTextureCopier : public WebCore::TextureCopier {
public:
- virtual void copyTexture(unsigned, unsigned, const WebCore::IntSize&) { }
+ virtual void copyTexture(Parameters) { }
virtual void flush() { }
};
@@ -162,7 +162,7 @@ public:
virtual bool isBusy() { return false; }
virtual void beginUploads() { }
virtual void endUploads() { }
- virtual void uploadTexture(WebCore::LayerTextureUpdater::Texture* texture, WebCore::CCResourceProvider* resourceProvider, const WebCore::IntRect sourceRect, const WebCore::IntRect destRect) { texture->updateRect(resourceProvider, sourceRect, destRect); }
+ virtual void uploadTexture(WebCore::CCResourceProvider* resourceProvider, Parameters upload) { upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destRect); }
};
}
diff --git a/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp b/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp
index ace7410c3..fd72e96ed 100644
--- a/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp
+++ b/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp
@@ -26,17 +26,17 @@
#include "Canvas2DLayerBridge.h"
+#include "FakeWebCompositorOutputSurface.h"
#include "FakeWebGraphicsContext3D.h"
#include "GraphicsContext3DPrivate.h"
#include "ImageBuffer.h"
#include "LayerChromium.h"
-#include "WebCompositor.h"
-#include "WebKit.h"
#include "cc/CCGraphicsContext.h"
#include "cc/CCRenderingStats.h"
-#include "cc/CCTextureUpdater.h"
-#include "platform/WebKitPlatformSupport.h"
-#include "platform/WebThread.h"
+#include "cc/CCTextureUpdateQueue.h"
+#include <public/Platform.h>
+#include <public/WebCompositor.h>
+#include <public/WebThread.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -75,7 +75,7 @@ protected:
void fullLifecycleTest(ThreadMode threadMode, DeferralMode deferralMode)
{
RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext));
- OwnPtr<CCGraphicsContext> ccImplContext = CCGraphicsContext::create3D(adoptPtr(new MockCanvasContext));
+ OwnPtr<CCGraphicsContext> ccImplContext = FakeWebCompositorOutputSurface::create(adoptPtr(new MockCanvasContext));
MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(mainContext.get()));
MockCanvasContext& implMock = *static_cast<MockCanvasContext*>(ccImplContext->context3D());
@@ -143,17 +143,4 @@ TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleThreadedDeferred)
fullLifecycleTest(Threaded, Deferred);
}
-TEST(Canvas2DLayerBridgeTest2, testClearClient)
-{
- GraphicsContext3D::Attributes attrs;
-
- RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext));
- OwnPtr<Canvas2DLayerBridge> bridge = Canvas2DLayerBridge::create(mainContext.get(), IntSize(100, 100), Deferred, 1);
- RefPtr<LayerChromium> layer = bridge->layer();
- bridge.clear();
- CCTextureUpdater updater;
- CCRenderingStats stats;
- layer->update(updater, 0, stats);
-}
-
} // namespace
diff --git a/Source/WebKit/chromium/tests/CompositorFakeWebGraphicsContext3D.h b/Source/WebKit/chromium/tests/CompositorFakeWebGraphicsContext3D.h
index 0790639d5..469e25c31 100644
--- a/Source/WebKit/chromium/tests/CompositorFakeWebGraphicsContext3D.h
+++ b/Source/WebKit/chromium/tests/CompositorFakeWebGraphicsContext3D.h
@@ -26,6 +26,7 @@
#define CompositorFakeWebGraphicsContext3D_h
#include "FakeWebGraphicsContext3D.h"
+#include <wtf/PassOwnPtr.h>
namespace WebKit {
diff --git a/Source/WebKit/chromium/tests/FakeCCGraphicsContext.h b/Source/WebKit/chromium/tests/FakeCCGraphicsContext.h
index beb4ef366..33c4b3046 100644
--- a/Source/WebKit/chromium/tests/FakeCCGraphicsContext.h
+++ b/Source/WebKit/chromium/tests/FakeCCGraphicsContext.h
@@ -27,13 +27,15 @@
#define FakeCCGraphicsContext_h
#include "CompositorFakeWebGraphicsContext3D.h"
+#include "FakeWebCompositorOutputSurface.h"
#include "cc/CCGraphicsContext.h"
+#include <public/WebCompositorOutputSurface.h>
namespace WebKit {
static inline PassOwnPtr<WebCore::CCGraphicsContext> createFakeCCGraphicsContext()
{
- return WebCore::CCGraphicsContext::create3D(CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()));
+ return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()));
}
} // namespace WebKit
diff --git a/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h b/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h
index 0b3c3fe9e..84804da96 100755
--- a/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h
+++ b/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h
@@ -28,6 +28,8 @@
#include "config.h"
#include "CompositorFakeWebGraphicsContext3D.h"
+#include "FakeWebCompositorOutputSurface.h"
+
#include "cc/CCLayerTreeHost.h"
namespace WebCore {
@@ -39,12 +41,13 @@ public:
virtual void updateAnimations(double monotonicFrameBeginTime) OVERRIDE { }
virtual void layout() OVERRIDE { }
virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) OVERRIDE { }
- virtual PassOwnPtr<WebKit::WebGraphicsContext3D> createContext3D() OVERRIDE
+
+ virtual PassOwnPtr<WebKit::WebCompositorOutputSurface> createOutputSurface() OVERRIDE
{
WebKit::WebGraphicsContext3D::Attributes attrs;
- return WebKit::CompositorFakeWebGraphicsContext3D::create(WebKit::WebGraphicsContext3D::Attributes());
+ return WebKit::FakeWebCompositorOutputSurface::create(WebKit::CompositorFakeWebGraphicsContext3D::create(attrs));
}
- virtual void didRecreateContext(bool success) OVERRIDE { }
+ virtual void didRecreateOutputSurface(bool success) OVERRIDE { }
virtual void willCommit() OVERRIDE { }
virtual void didCommit() OVERRIDE { }
virtual void didCommitAndDrawFrame() OVERRIDE { }
diff --git a/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp b/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
index 720630e17..afffc1623 100644
--- a/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
+++ b/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
@@ -26,9 +26,10 @@
#include "config.h"
#include "FakeWebGraphicsContext3D.h"
-
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
using namespace WebCore;
using namespace WebKit;
diff --git a/Source/WebKit/chromium/tests/FakeWebCompositorOutputSurface.h b/Source/WebKit/chromium/tests/FakeWebCompositorOutputSurface.h
new file mode 100644
index 000000000..c20c9f991
--- /dev/null
+++ b/Source/WebKit/chromium/tests/FakeWebCompositorOutputSurface.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FakeWebCompositorOutputSurface_h
+#define FakeWebCompositorOutputSurface_h
+
+#include <public/WebCompositorOutputSurface.h>
+#include <public/WebGraphicsContext3D.h>
+
+namespace WebKit {
+
+class FakeWebCompositorOutputSurface : public WebCompositorOutputSurface {
+public:
+ static inline PassOwnPtr<FakeWebCompositorOutputSurface> create(PassOwnPtr<WebGraphicsContext3D> context3D)
+ {
+ return adoptPtr(new FakeWebCompositorOutputSurface(context3D));
+ }
+
+
+ virtual bool bindToClient(WebCompositorOutputSurfaceClient* client) OVERRIDE
+ {
+ ASSERT(client);
+ if (!m_context3D->makeContextCurrent())
+ return false;
+ m_client = client;
+ return true;
+ }
+
+ virtual const Capabilities& capabilities() const OVERRIDE
+ {
+ return m_capabilities;
+ }
+
+ virtual WebGraphicsContext3D* context3D() const OVERRIDE
+ {
+ return m_context3D.get();
+ }
+
+ virtual void sendFrameToParentCompositor(const WebCompositorFrame&) OVERRIDE
+ {
+ }
+
+private:
+ explicit FakeWebCompositorOutputSurface(PassOwnPtr<WebGraphicsContext3D> context3D)
+ {
+ m_context3D = context3D;
+ }
+
+ OwnPtr<WebGraphicsContext3D> m_context3D;
+ Capabilities m_capabilities;
+ WebCompositorOutputSurfaceClient* m_client;
+};
+
+} // namespace WebKit
+
+#endif // FakeWebCompositorOutputSurface_h
diff --git a/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h b/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h
index b864c35fd..bd3545f45 100644
--- a/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h
+++ b/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h
@@ -27,7 +27,7 @@
#define FakeWebGraphicsContext3D_h
#include "GraphicsContext3D.h"
-#include "platform/WebGraphicsContext3D.h"
+#include <public/WebGraphicsContext3D.h>
namespace WebKit {
diff --git a/Source/WebKit/chromium/tests/FakeWebScrollbarThemeGeometry.h b/Source/WebKit/chromium/tests/FakeWebScrollbarThemeGeometry.h
new file mode 100644
index 000000000..0ca5436f2
--- /dev/null
+++ b/Source/WebKit/chromium/tests/FakeWebScrollbarThemeGeometry.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FakeWebScrollbarThemeGeometry_h
+#define FakeWebScrollbarThemeGeometry_h
+
+#include <public/WebScrollbarThemeGeometry.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+class FakeWebScrollbarThemeGeometry : public WebKit::WebScrollbarThemeGeometry {
+public:
+ static PassOwnPtr<WebKit::WebScrollbarThemeGeometry> create() { return adoptPtr(new WebKit::FakeWebScrollbarThemeGeometry()); }
+
+ virtual WebKit::WebScrollbarThemeGeometry* clone() const OVERRIDE
+ {
+ return new FakeWebScrollbarThemeGeometry();
+ }
+
+ virtual int thumbPosition(WebScrollbar*) OVERRIDE { return 0; }
+ virtual int thumbLength(WebScrollbar*) OVERRIDE { return 0; }
+ virtual int trackPosition(WebScrollbar*) OVERRIDE { return 0; }
+ virtual int trackLength(WebScrollbar*) OVERRIDE { return 0; }
+ virtual bool hasButtons(WebScrollbar*) OVERRIDE { return false; }
+ virtual bool hasThumb(WebScrollbar*) OVERRIDE { return false; }
+ virtual WebRect trackRect(WebScrollbar*) OVERRIDE { return WebRect(); }
+ virtual WebRect thumbRect(WebScrollbar*) OVERRIDE { return WebRect(); }
+ virtual int minimumThumbLength(WebScrollbar*) OVERRIDE { return 0; }
+ virtual int scrollbarThickness(WebScrollbar*) OVERRIDE { return 0; }
+ virtual WebRect backButtonStartRect(WebScrollbar*) OVERRIDE { return WebRect(); }
+ virtual WebRect backButtonEndRect(WebScrollbar*) OVERRIDE { return WebRect(); }
+ virtual WebRect forwardButtonStartRect(WebScrollbar*) OVERRIDE { return WebRect(); }
+ virtual WebRect forwardButtonEndRect(WebScrollbar*) OVERRIDE { return WebRect(); }
+ virtual WebRect constrainTrackRectToTrackPieces(WebScrollbar*, const WebRect&) OVERRIDE { return WebRect(); }
+
+ virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startTrack, WebRect& thumb, WebRect& endTrack) OVERRIDE
+ {
+ startTrack = WebRect();
+ thumb = WebRect();
+ endTrack = WebRect();
+ }
+};
+
+} // namespace WebKit
+
+#endif // FakeWebScrollbarThemeGeometry_h
diff --git a/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp
index 91aeb7ca5..21d0705b8 100644
--- a/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp
@@ -36,11 +36,10 @@
#include "Matrix3DTransformOperation.h"
#include "RotateTransformOperation.h"
#include "TranslateTransformOperation.h"
-#include "WebCompositor.h"
-
#include "cc/CCLayerTreeHost.h"
#include "cc/CCLayerTreeHostImpl.h"
#include "cc/CCSingleThreadProxy.h"
+#include <public/WebCompositor.h>
#include <gtest/gtest.h>
#include <public/WebGraphicsContext3D.h>
@@ -71,7 +70,7 @@ public:
bool success = layerTreeHost->initialize();
EXPECT_TRUE(success);
layerTreeHost->setRootLayer(LayerChromium::create());
- layerTreeHost->setViewportSize(IntSize(1, 1));
+ layerTreeHost->setViewportSize(IntSize(1, 1), IntSize(1, 1));
return layerTreeHost.release();
}
@@ -95,7 +94,7 @@ public:
WebCompositor::setAcceleratedAnimationEnabled(true);
WebCompositor::initialize(0);
m_graphicsLayer = static_pointer_cast<GraphicsLayerChromium>(GraphicsLayer::create(&m_client));
- m_platformLayer = static_cast<LayerChromium*>(m_graphicsLayer->platformLayer());
+ m_platformLayer = m_graphicsLayer->platformLayer()->unwrap<LayerChromium>();
m_layerTreeHost = MockLayerTreeHost::create();
m_platformLayer->setLayerTreeHost(m_layerTreeHost.get());
}
@@ -133,7 +132,7 @@ TEST_F(GraphicsLayerChromiumTest, updateLayerPreserves3DWithAnimations)
m_graphicsLayer->setPreserves3D(true);
- m_platformLayer = static_cast<LayerChromium*>(m_graphicsLayer->platformLayer());
+ m_platformLayer = m_graphicsLayer->platformLayer()->unwrap<LayerChromium>();
ASSERT_TRUE(m_platformLayer);
ASSERT_TRUE(m_platformLayer->hasActiveAnimation());
@@ -142,7 +141,7 @@ TEST_F(GraphicsLayerChromiumTest, updateLayerPreserves3DWithAnimations)
m_graphicsLayer->setPreserves3D(false);
- m_platformLayer = static_cast<LayerChromium*>(m_graphicsLayer->platformLayer());
+ m_platformLayer = m_graphicsLayer->platformLayer()->unwrap<LayerChromium>();
ASSERT_TRUE(m_platformLayer);
ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
diff --git a/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp b/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp
index d9e3d697b..91df126a5 100644
--- a/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp
+++ b/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp
@@ -74,7 +74,7 @@ public:
{
return adoptRef(new FailingBackingStore);
}
- virtual bool createIDBDatabaseMetaData(const String&, const String&, int64_t&)
+ virtual bool createIDBDatabaseMetaData(const String&, const String&, int64_t, int64_t&)
{
return false;
}
diff --git a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
index 536d785b9..8862b58d4 100644
--- a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
+++ b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
@@ -33,9 +33,10 @@ namespace WebCore {
class IDBFakeBackingStore : public IDBBackingStore {
public:
virtual void getDatabaseNames(Vector<String>& foundNames) OVERRIDE { }
- virtual bool getIDBDatabaseMetaData(const String& name, String& foundVersion, int64_t& foundId) OVERRIDE { return false; }
- virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t& rowId) OVERRIDE { return true; }
+ virtual bool getIDBDatabaseMetaData(const String& name, String& foundVersion, int64_t& foundIntVersion, int64_t& foundId) OVERRIDE { return false; }
+ virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId) OVERRIDE { return true; }
virtual bool updateIDBDatabaseMetaData(int64_t rowId, const String& version) OVERRIDE { return false; }
+ virtual bool updateIDBDatabaseIntVersion(int64_t rowId, int64_t version) OVERRIDE { return false; }
virtual bool deleteDatabase(const String& name) OVERRIDE { return false; }
virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) OVERRIDE { }
diff --git a/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp b/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp
index 137699c30..1b2ff6fe1 100644
--- a/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp
+++ b/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp
@@ -84,6 +84,24 @@ TEST(IDBLevelDBCodingTest, EncodeByte)
EXPECT_EQ(expected, encodeByte(c));
}
+TEST(IDBLevelDBCodingTest, DecodeByte)
+{
+ Vector<unsigned char> testCases;
+ testCases.append(0);
+ testCases.append(1);
+ testCases.append(255);
+
+ for (size_t i = 0; i < testCases.size(); ++i) {
+ unsigned char n = testCases[i];
+ Vector<char> v = encodeByte(n);
+
+ unsigned char res;
+ const char* p = decodeByte(v.data(), v.data() + v.size(), res);
+ EXPECT_EQ(n, res);
+ EXPECT_EQ(v.data() + v.size(), p);
+ }
+}
+
TEST(IDBLevelDBCodingTest, EncodeBool)
{
{
@@ -187,8 +205,10 @@ TEST(IDBLevelDBCodingTest, EncodeVarInt)
EXPECT_EQ(static_cast<size_t>(2), encodeVarInt(255).size());
EXPECT_EQ(static_cast<size_t>(2), encodeVarInt(256).size());
EXPECT_EQ(static_cast<size_t>(5), encodeVarInt(0xffffffff).size());
+ EXPECT_EQ(static_cast<size_t>(8), encodeVarInt(0xfffffffffffffLL).size());
+ EXPECT_EQ(static_cast<size_t>(9), encodeVarInt(0x7fffffffffffffffLL).size());
#ifdef NDEBUG
- EXPECT_EQ(static_cast<size_t>(8), encodeInt(-100).size());
+ EXPECT_EQ(static_cast<size_t>(10), encodeVarInt(-100).size());
#endif
}
@@ -682,6 +702,24 @@ TEST(IDBLevelDBCodingTest, ComparisonTest)
}
}
+TEST(IDBLevelDBCodingTest, EncodeVarIntVSEncodeByteTest)
+{
+ Vector<unsigned char> testCases;
+ testCases.append(0);
+ testCases.append(1);
+ testCases.append(127);
+
+ for (size_t i = 0; i < testCases.size(); ++i) {
+ unsigned char n = testCases[i];
+
+ Vector<char> vA = encodeByte(n);
+ Vector<char> vB = encodeVarInt(static_cast<int64_t>(n));
+
+ EXPECT_EQ(vA.size(), vB.size());
+ EXPECT_EQ(*(vA.data()), *(vB.data()));
+ }
+}
+
} // namespace
#endif // USE(LEVELDB)
diff --git a/Source/WebKit/chromium/tests/IDBRequestTest.cpp b/Source/WebKit/chromium/tests/IDBRequestTest.cpp
new file mode 100644
index 000000000..0f3b77527
--- /dev/null
+++ b/Source/WebKit/chromium/tests/IDBRequestTest.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "IDBRequest.h"
+
+#include "IDBCursorBackendInterface.h"
+#include "IDBDatabaseBackendImpl.h"
+#include "IDBTransactionCoordinator.h"
+
+#include <gtest/gtest.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+using namespace WebCore;
+
+namespace {
+
+TEST(IDBRequestTest, EventsAfterStopping)
+{
+ ScriptExecutionContext* context = 0;
+ IDBTransaction* transaction = 0;
+ RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::createInvalid(), transaction);
+ EXPECT_EQ(request->readyState(), "pending");
+ request->stop();
+
+ // Ensure none of the following raise assertions in stopped state:
+ request->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR, "Description goes here."));
+ request->onSuccess(DOMStringList::create());
+ request->onSuccess(PassRefPtr<IDBDatabaseBackendInterface>());
+ request->onSuccess(PassRefPtr<IDBCursorBackendInterface>());
+ request->onSuccess(IDBKey::createInvalid());
+ request->onSuccess(PassRefPtr<IDBTransactionBackendInterface>());
+ request->onSuccess(SerializedScriptValue::nullValue());
+ request->onSuccess(SerializedScriptValue::nullValue(), IDBKey::createInvalid(), IDBKeyPath());
+ request->onSuccessWithContinuation();
+}
+
+} // namespace
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp
index a932ab61c..1a14d75bc 100644
--- a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp
@@ -29,13 +29,12 @@
#include "CCLayerTreeTestCommon.h"
#include "FakeCCLayerTreeHostClient.h"
#include "LayerPainterChromium.h"
-#include "NonCompositedContentHost.h"
-#include "WebCompositor.h"
#include "cc/CCLayerImpl.h"
#include "cc/CCLayerTreeHost.h"
#include "cc/CCSingleThreadProxy.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebCompositor.h>
#include <public/WebTransformationMatrix.h>
using namespace WebCore;
@@ -495,7 +494,7 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior)
// Test properties that should not call needsDisplay and needsCommit when changed.
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleContentRect(IntRect(0, 0, 40, 50)));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setIsNonCompositedContent(true));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUseLCDText(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setRenderTarget(0));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(WebTransformationMatrix()));
diff --git a/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
index d861164f6..c4bddc5fb 100644
--- a/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
@@ -26,13 +26,14 @@
#include "LayerRendererChromium.h"
#include "CCTestCommon.h"
+#include "FakeWebCompositorOutputSurface.h"
#include "FakeWebGraphicsContext3D.h"
#include "GraphicsContext3D.h"
-#include "WebCompositor.h"
#include "cc/CCDrawQuad.h"
#include "cc/CCPrioritizedTextureManager.h"
#include "cc/CCSettings.h"
#include "cc/CCSingleThreadProxy.h"
+#include <public/WebCompositor.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -128,7 +129,7 @@ protected:
LayerRendererChromiumTest()
: m_suggestHaveBackbufferYes(1, true)
, m_suggestHaveBackbufferNo(1, false)
- , m_context(CCGraphicsContext::create3D(adoptPtr(new FrameCountingMemoryAllocationSettingContext())))
+ , m_context(FakeWebCompositorOutputSurface::create(adoptPtr(new FrameCountingMemoryAllocationSettingContext())))
, m_resourceProvider(CCResourceProvider::create(m_context.get()))
, m_layerRendererChromium(&m_mockClient, m_resourceProvider.get())
{
@@ -147,7 +148,7 @@ protected:
void swapBuffers()
{
- m_layerRendererChromium.swapBuffers(IntRect());
+ m_layerRendererChromium.swapBuffers();
}
FrameCountingMemoryAllocationSettingContext* context() { return static_cast<FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); }
@@ -224,7 +225,7 @@ TEST_F(LayerRendererChromiumTest, DiscardedBackbufferIsRecreatedForScopeDuration
EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
m_layerRendererChromium.setVisible(true);
- m_layerRendererChromium.drawFrame(m_mockClient.renderPassesInDrawOrder(), m_mockClient.renderPasses(), FloatRect());
+ m_layerRendererChromium.drawFrame(m_mockClient.renderPassesInDrawOrder(), m_mockClient.renderPasses());
EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
swapBuffers();
@@ -239,7 +240,7 @@ TEST_F(LayerRendererChromiumTest, FramebufferDiscardedAfterReadbackWhenNotVisibl
EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
char pixels[4];
- m_layerRendererChromium.drawFrame(m_mockClient.renderPassesInDrawOrder(), m_mockClient.renderPasses(), FloatRect());
+ m_layerRendererChromium.drawFrame(m_mockClient.renderPassesInDrawOrder(), m_mockClient.renderPasses());
EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
m_layerRendererChromium.getFramebufferPixels(pixels, IntRect(0, 0, 1, 1));
@@ -318,7 +319,7 @@ TEST(LayerRendererChromiumTest2, initializationDoesNotMakeSynchronousCalls)
{
CCScopedSettings scopedSettings;
FakeCCRendererClient mockClient;
- OwnPtr<CCGraphicsContext> context(CCGraphicsContext::create3D(adoptPtr(new ForbidSynchronousCallContext)));
+ OwnPtr<CCGraphicsContext> context(FakeWebCompositorOutputSurface::create(adoptPtr(new ForbidSynchronousCallContext)));
OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get()));
FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get());
@@ -362,7 +363,7 @@ TEST(LayerRendererChromiumTest2, initializationWithQuicklyLostContextDoesNotAsse
{
CCScopedSettings scopedSettings;
FakeCCRendererClient mockClient;
- OwnPtr<CCGraphicsContext> context(CCGraphicsContext::create3D(adoptPtr(new LoseContextOnFirstGetContext)));
+ OwnPtr<CCGraphicsContext> context(FakeWebCompositorOutputSurface::create(adoptPtr(new LoseContextOnFirstGetContext)));
OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get()));
FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get());
@@ -384,7 +385,7 @@ public:
TEST(LayerRendererChromiumTest2, initializationWithoutGpuMemoryManagerExtensionSupportShouldDefaultToNonZeroAllocation)
{
FakeCCRendererClient mockClient;
- OwnPtr<CCGraphicsContext> context(CCGraphicsContext::create3D(adoptPtr(new ContextThatDoesNotSupportMemoryManagmentExtensions)));
+ OwnPtr<CCGraphicsContext> context(FakeWebCompositorOutputSurface::create(adoptPtr(new ContextThatDoesNotSupportMemoryManagmentExtensions)));
OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get()));
FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get());
@@ -411,7 +412,7 @@ private:
TEST(LayerRendererChromiumTest2, opaqueBackground)
{
FakeCCRendererClient mockClient;
- OwnPtr<CCGraphicsContext> ccContext(CCGraphicsContext::create3D(adoptPtr(new ClearCountingContext)));
+ OwnPtr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::create(adoptPtr(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext->context3D());
OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(ccContext.get()));
FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get());
@@ -420,7 +421,7 @@ TEST(LayerRendererChromiumTest2, opaqueBackground)
EXPECT_TRUE(layerRendererChromium.initialize());
- layerRendererChromium.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPasses(), FloatRect());
+ layerRendererChromium.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPasses());
// On DEBUG builds, render passes with opaque background clear to blue to
// easily see regions that were not drawn on the screen.
@@ -434,7 +435,7 @@ TEST(LayerRendererChromiumTest2, opaqueBackground)
TEST(LayerRendererChromiumTest2, transparentBackground)
{
FakeCCRendererClient mockClient;
- OwnPtr<CCGraphicsContext> ccContext(CCGraphicsContext::create3D(adoptPtr(new ClearCountingContext)));
+ OwnPtr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::create(adoptPtr(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext->context3D());
OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(ccContext.get()));
FakeLayerRendererChromium layerRendererChromium(&mockClient, resourceProvider.get());
@@ -443,7 +444,7 @@ TEST(LayerRendererChromiumTest2, transparentBackground)
EXPECT_TRUE(layerRendererChromium.initialize());
- layerRendererChromium.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPasses(), FloatRect());
+ layerRendererChromium.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPasses());
EXPECT_EQ(1, context->clearCount());
}
diff --git a/Source/WebKit/chromium/tests/LocaleMacTest.cpp b/Source/WebKit/chromium/tests/LocaleMacTest.cpp
index 1150a301a..f6b0f6292 100644
--- a/Source/WebKit/chromium/tests/LocaleMacTest.cpp
+++ b/Source/WebKit/chromium/tests/LocaleMacTest.cpp
@@ -118,6 +118,12 @@ protected:
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
return locale->timeAMPMLabels()[index];
}
+
+ String decimalSeparator(const String& localeString)
+ {
+ OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
+ return locale->localizedDecimalSeparator();
+ }
#endif
};
@@ -207,4 +213,44 @@ TEST_F(LocaleMacTest, timeAMPMLabels)
EXPECT_STREQ("\xE5\x8D\x88\xE5\x89\x8D", timeAMPMLabel("ja_JP", 0).utf8().data());
EXPECT_STREQ("\xE5\x8D\x88\xE5\xBE\x8C", timeAMPMLabel("ja_JP", 1).utf8().data());
}
+
+TEST_F(LocaleMacTest, decimalSeparator)
+{
+ EXPECT_STREQ(".", decimalSeparator("en_US").utf8().data());
+ EXPECT_STREQ(",", decimalSeparator("fr_FR").utf8().data());
+}
#endif
+
+static void testNumberIsReversible(const String& localeString, const char* original, const char* shouldHave = 0)
+{
+ OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
+ String localized = locale->convertToLocalizedNumber(original);
+ if (shouldHave)
+ EXPECT_TRUE(localized.contains(shouldHave));
+ String converted = locale->convertFromLocalizedNumber(localized);
+ EXPECT_STREQ(original, converted.utf8().data());
+}
+
+void testNumbers(const String& localeString, const char* decimalSeparatorShouldBe = 0)
+{
+ testNumberIsReversible(localeString, "123456789012345678901234567890");
+ testNumberIsReversible(localeString, "-123.456", decimalSeparatorShouldBe);
+ testNumberIsReversible(localeString, ".456", decimalSeparatorShouldBe);
+ testNumberIsReversible(localeString, "-0.456", decimalSeparatorShouldBe);
+}
+
+TEST_F(LocaleMacTest, localizedNumberRoundTrip)
+{
+ // Test some of major locales.
+ testNumbers("en_US", ".");
+ testNumbers("fr_FR", ",");
+ testNumbers("ar");
+ testNumbers("de_DE");
+ testNumbers("es_ES");
+ testNumbers("fa");
+ testNumbers("ja_JP");
+ testNumbers("ko_KR");
+ testNumbers("zh_CN");
+ testNumbers("zh_HK");
+ testNumbers("zh_TW");
+}
diff --git a/Source/WebKit/chromium/tests/LocaleWinTest.cpp b/Source/WebKit/chromium/tests/LocaleWinTest.cpp
index 8da2f4461..5f5642e91 100644
--- a/Source/WebKit/chromium/tests/LocaleWinTest.cpp
+++ b/Source/WebKit/chromium/tests/LocaleWinTest.cpp
@@ -57,10 +57,19 @@ protected:
};
// See http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx
+ // Note that some locales are country-neutral.
enum {
- EnglishUS = 0x409,
- FrenchFR = 0x40C,
- JapaneseJP = 0x411,
+ ArabicEG = 0x0C01, // ar-eg
+ ChineseCN = 0x0804, // zh-cn
+ ChineseHK = 0x0C04, // zh-hk
+ ChineseTW = 0x0404, // zh-tw
+ German = 0x0407, // de
+ EnglishUS = 0x409, // en-us
+ FrenchFR = 0x40C, // fr
+ JapaneseJP = 0x411, // ja
+ KoreanKR = 0x0412, // ko
+ Persian = 0x0429, // fa
+ Spanish = 0x040A, // es
};
DateComponents dateComponents(int year, int month, int day)
@@ -131,6 +140,12 @@ protected:
OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
return locale->timeAMPMLabels()[index];
}
+
+ String decimalSeparator(LCID lcid)
+ {
+ OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
+ return locale->localizedDecimalSeparator();
+ }
#endif
};
@@ -328,4 +343,52 @@ TEST_F(LocaleWinTest, timeAMPMLabels)
EXPECT_STREQ("\xE5\x8D\x88\xE5\x89\x8D", timeAMPMLabel(JapaneseJP, 0).utf8().data());
EXPECT_STREQ("\xE5\x8D\x88\xE5\xBE\x8C", timeAMPMLabel(JapaneseJP, 1).utf8().data());
}
+
+TEST_F(LocaleWinTest, decimalSeparator)
+{
+ EXPECT_STREQ(".", decimalSeparator(EnglishUS).utf8().data());
+ EXPECT_STREQ(",", decimalSeparator(FrenchFR).utf8().data());
+}
#endif
+
+static void testNumberIsReversible(LCID lcid, const char* original, const char* shouldHave = 0)
+{
+ OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
+ String localized = locale->convertToLocalizedNumber(original);
+ if (shouldHave)
+ EXPECT_TRUE(localized.contains(shouldHave));
+ String converted = locale->convertFromLocalizedNumber(localized);
+ EXPECT_STREQ(original, converted.utf8().data());
+}
+
+void testNumbers(LCID lcid)
+{
+ testNumberIsReversible(lcid, "123456789012345678901234567890");
+ testNumberIsReversible(lcid, "-123.456");
+ testNumberIsReversible(lcid, ".456");
+ testNumberIsReversible(lcid, "-0.456");
+}
+
+TEST_F(LocaleWinTest, localizedNumberRoundTrip)
+{
+ testNumberIsReversible(EnglishUS, "123456789012345678901234567890");
+ testNumberIsReversible(EnglishUS, "-123.456", ".");
+ testNumberIsReversible(EnglishUS, ".456", ".");
+ testNumberIsReversible(EnglishUS, "-0.456", ".");
+
+ testNumberIsReversible(FrenchFR, "123456789012345678901234567890");
+ testNumberIsReversible(FrenchFR, "-123.456", ",");
+ testNumberIsReversible(FrenchFR, ".456", ",");
+ testNumberIsReversible(FrenchFR, "-0.456", ",");
+
+ // Test some of major locales.
+ testNumbers(ArabicEG);
+ testNumbers(German);
+ testNumbers(Spanish);
+ testNumbers(Persian);
+ testNumbers(JapaneseJP);
+ testNumbers(KoreanKR);
+ testNumbers(ChineseCN);
+ testNumbers(ChineseHK);
+ testNumbers(ChineseTW);
+}
diff --git a/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp b/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
new file mode 100644
index 000000000..052936dab
--- /dev/null
+++ b/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "DataRef.h"
+#include "MemoryInstrumentationImpl.h"
+
+#include <gtest/gtest.h>
+
+#include <wtf/HashSet.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+namespace {
+
+class NotInstrumented {
+public:
+ char m_data[42];
+};
+
+class Instrumented {
+public:
+ Instrumented() : m_notInstrumented(new NotInstrumented) { }
+ virtual ~Instrumented() { delete m_notInstrumented; }
+
+ virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+ {
+ MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+ info.addMember(m_notInstrumented);
+ }
+ NotInstrumented* m_notInstrumented;
+};
+
+TEST(MemoryInstrumentationTest, sizeOf)
+{
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ Instrumented instrumented;
+ impl.addRootObject(instrumented);
+ EXPECT_EQ(sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(1, visitedObjects.size());
+}
+
+TEST(MemoryInstrumentationTest, nullCheck)
+{
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ Instrumented* instrumented = 0;
+ impl.addRootObject(instrumented);
+ EXPECT_EQ(0u, impl.reportedSizeForAllTypes());
+ EXPECT_EQ(0, visitedObjects.size());
+}
+
+TEST(MemoryInstrumentationTest, ptrVsRef)
+{
+ {
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ Instrumented instrumented;
+ impl.addRootObject(&instrumented);
+ EXPECT_EQ(sizeof(Instrumented) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(2, visitedObjects.size());
+ }
+ {
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ Instrumented instrumented;
+ impl.addRootObject(instrumented);
+ EXPECT_EQ(sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(1, visitedObjects.size());
+ }
+}
+
+TEST(MemoryInstrumentationTest, ownPtr)
+{
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ OwnPtr<Instrumented> instrumented(adoptPtr(new Instrumented));
+ impl.addRootObject(instrumented);
+ EXPECT_EQ(sizeof(Instrumented) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(2, visitedObjects.size());
+}
+
+class InstrumentedRefPtr : public RefCounted<InstrumentedRefPtr> {
+public:
+ InstrumentedRefPtr() : m_notInstrumented(new NotInstrumented) { }
+ virtual ~InstrumentedRefPtr() { delete m_notInstrumented; }
+ static PassRefPtr<InstrumentedRefPtr> create() { return adoptRef(new InstrumentedRefPtr()); }
+
+ virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+ {
+ MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+ info.addMember(m_notInstrumented);
+ }
+ NotInstrumented* m_notInstrumented;
+};
+
+TEST(MemoryInstrumentationTest, dataRef)
+{
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ DataRef<InstrumentedRefPtr> instrumentedRefPtr;
+ instrumentedRefPtr.init();
+ impl.addRootObject(instrumentedRefPtr);
+ EXPECT_EQ(sizeof(InstrumentedRefPtr) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(2, visitedObjects.size());
+}
+
+TEST(MemoryInstrumentationTest, refPtr)
+{
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ RefPtr<InstrumentedRefPtr> instrumentedRefPtr(adoptRef(new InstrumentedRefPtr));
+ impl.addRootObject(instrumentedRefPtr);
+ EXPECT_EQ(sizeof(InstrumentedRefPtr) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(2, visitedObjects.size());
+}
+
+class InstrumentedWithOwnPtr : public Instrumented {
+public:
+ InstrumentedWithOwnPtr() : m_notInstrumentedOwnPtr(adoptPtr(new NotInstrumented)) { }
+
+ virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+ {
+ MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ Instrumented::reportMemoryUsage(memoryObjectInfo);
+ info.addMember(m_notInstrumentedOwnPtr);
+ }
+ OwnPtr<NotInstrumented> m_notInstrumentedOwnPtr;
+};
+
+TEST(MemoryInstrumentationTest, ownPtrNotInstrumented)
+{
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ InstrumentedWithOwnPtr instrumentedWithOwnPtr;
+ impl.addRootObject(instrumentedWithOwnPtr);
+ EXPECT_EQ(2 * sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(2, visitedObjects.size());
+}
+
+class InstrumentedOther {
+public:
+ InstrumentedOther() : m_data(0) { }
+
+ void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+ {
+ MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::Other);
+ }
+ int m_data;
+};
+
+class InstrumentedDOM {
+public:
+ InstrumentedDOM() : m_instrumentedOther(adoptPtr(new InstrumentedOther)) { }
+
+ void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+ {
+ MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+ info.addInstrumentedMember(m_instrumentedOther);
+ }
+ OwnPtr<InstrumentedOther> m_instrumentedOther;
+};
+
+TEST(MemoryInstrumentationTest, ownerTypePropagation)
+{
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ OwnPtr<InstrumentedDOM> instrumentedDOM(adoptPtr(new InstrumentedDOM));
+ impl.addRootObject(instrumentedDOM);
+ EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedOther), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedOther), impl.totalSize(MemoryInstrumentation::DOM));
+ EXPECT_EQ(2, visitedObjects.size());
+}
+
+class NonVirtualInstrumented {
+public:
+ void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+ {
+ MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+ info.addInstrumentedMember(m_instrumented);
+ }
+
+ Instrumented m_instrumented;
+};
+
+TEST(MemoryInstrumentationTest, visitFirstMemberInNonVirtualClass)
+{
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ NonVirtualInstrumented nonVirtualInstrumented;
+ impl.addRootObject(&nonVirtualInstrumented);
+ EXPECT_EQ(sizeof(NonVirtualInstrumented) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(2, visitedObjects.size());
+}
+
+} // namespace
+
diff --git a/Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp b/Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp
index 6c6c359a9..927d4a9c3 100644
--- a/Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp
+++ b/Source/WebKit/chromium/tests/ScrollAnimatorNoneTest.cpp
@@ -64,6 +64,7 @@ public:
MOCK_METHOD1(setScrollOffsetFromAnimation, void(const IntPoint&));
MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*());
+ virtual IntPoint scrollPosition() const { return IntPoint(); }
virtual int visibleHeight() const { return 768; }
virtual int visibleWidth() const { return 1024; }
diff --git a/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp
index d2cd9befc..0e3b1fbdb 100644
--- a/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp
@@ -26,12 +26,17 @@
#include "ScrollbarLayerChromium.h"
+#include "FakeWebScrollbarThemeGeometry.h"
#include "Scrollbar.h"
#include "Settings.h"
#include "TreeSynchronizer.h"
+#include "cc/CCScrollbarAnimationController.h"
#include "cc/CCScrollbarLayerImpl.h"
#include "cc/CCSingleThreadProxy.h"
#include <gtest/gtest.h>
+#include <public/WebScrollbar.h>
+#include <public/WebScrollbarThemeGeometry.h>
+#include <public/WebScrollbarThemePainter.h>
using namespace WebCore;
@@ -60,7 +65,7 @@ public:
virtual bool isScrollableAreaActive() const { return false; }
virtual bool isScrollViewScrollbar() const { return false; }
- virtual IntPoint convertFromContainingWindow(const IntPoint& windowPoint) { return IntPoint(); }
+ virtual IntPoint convertFromContainingWindow(const IntPoint& windowPoint) { return windowPoint; }
virtual bool isCustomScrollbar() const { return false; }
virtual ScrollbarOrientation orientation() const { return HorizontalScrollbar; }
@@ -83,6 +88,8 @@ public:
virtual bool enabled() const { return false; }
virtual void setEnabled(bool) { }
+ virtual bool isOverlayScrollbar() const { return false; }
+
MockScrollbar() : Scrollbar(0, HorizontalScrollbar, RegularScrollbar) { }
virtual ~MockScrollbar() { }
};
@@ -91,12 +98,15 @@ TEST(ScrollbarLayerChromiumTest, resolveScrollLayerPointer)
{
DebugScopedSetImplThread impl;
+ RefPtr<MockScrollbar> mockScrollbar = adoptRef(new MockScrollbar);
+ WebKit::WebScrollbarThemePainter painter(0, mockScrollbar.get());
+
Settings::setMockScrollbarsEnabled(true);
{
- RefPtr<MockScrollbar> scrollbar = adoptRef(new MockScrollbar);
+ OwnPtr<WebKit::WebScrollbar> scrollbar = WebKit::WebScrollbar::create(mockScrollbar.get());
RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create();
RefPtr<LayerChromium> child1 = LayerChromium::create();
- RefPtr<LayerChromium> child2 = ScrollbarLayerChromium::create(scrollbar.get(), child1->id());
+ RefPtr<LayerChromium> child2 = ScrollbarLayerChromium::create(scrollbar.release(), painter, WebKit::FakeWebScrollbarThemeGeometry::create(), child1->id());
layerTreeRoot->addChild(child1);
layerTreeRoot->addChild(child2);
@@ -105,14 +115,15 @@ TEST(ScrollbarLayerChromiumTest, resolveScrollLayerPointer)
CCLayerImpl* ccChild1 = ccLayerTreeRoot->children()[0].get();
CCScrollbarLayerImpl* ccChild2 = static_cast<CCScrollbarLayerImpl*>(ccLayerTreeRoot->children()[1].get());
- EXPECT_EQ(ccChild1, ccChild2->scrollLayer());
+ EXPECT_TRUE(ccChild1->scrollbarAnimationController());
+ EXPECT_EQ(ccChild1->horizontalScrollbarLayer(), ccChild2);
}
{ // another traverse order
- RefPtr<MockScrollbar> scrollbar = adoptRef(new MockScrollbar);
+ OwnPtr<WebKit::WebScrollbar> scrollbar = WebKit::WebScrollbar::create(mockScrollbar.get());
RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create();
RefPtr<LayerChromium> child2 = LayerChromium::create();
- RefPtr<LayerChromium> child1 = ScrollbarLayerChromium::create(scrollbar.get(), child2->id());
+ RefPtr<LayerChromium> child1 = ScrollbarLayerChromium::create(scrollbar.release(), painter, WebKit::FakeWebScrollbarThemeGeometry::create(), child2->id());
layerTreeRoot->addChild(child1);
layerTreeRoot->addChild(child2);
@@ -121,8 +132,56 @@ TEST(ScrollbarLayerChromiumTest, resolveScrollLayerPointer)
CCScrollbarLayerImpl* ccChild1 = static_cast<CCScrollbarLayerImpl*>(ccLayerTreeRoot->children()[0].get());
CCLayerImpl* ccChild2 = ccLayerTreeRoot->children()[1].get();
- EXPECT_EQ(ccChild1->scrollLayer(), ccChild2);
+ EXPECT_TRUE(ccChild2->scrollbarAnimationController());
+ EXPECT_EQ(ccChild2->horizontalScrollbarLayer(), ccChild1);
}
}
+TEST(ScrollbarLayerChromiumTest, scrollOffsetSynchronization)
+{
+ DebugScopedSetImplThread impl;
+
+ RefPtr<MockScrollbar> mockScrollbar = adoptRef(new MockScrollbar);
+ WebKit::WebScrollbarThemePainter painter(0, mockScrollbar.get());
+
+ Settings::setMockScrollbarsEnabled(true);
+
+ OwnPtr<WebKit::WebScrollbar> scrollbar = WebKit::WebScrollbar::create(mockScrollbar.get());
+ RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create();
+ RefPtr<LayerChromium> contentLayer = LayerChromium::create();
+ RefPtr<LayerChromium> scrollbarLayer = ScrollbarLayerChromium::create(scrollbar.release(), painter, WebKit::FakeWebScrollbarThemeGeometry::create(), layerTreeRoot->id());
+ layerTreeRoot->addChild(contentLayer);
+ layerTreeRoot->addChild(scrollbarLayer);
+
+ layerTreeRoot->setScrollPosition(IntPoint(10, 20));
+ layerTreeRoot->setMaxScrollPosition(IntSize(30, 50));
+ contentLayer->setBounds(IntSize(100, 200));
+
+ OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr, 0);
+
+ CCScrollbarLayerImpl* ccScrollbarLayer = static_cast<CCScrollbarLayerImpl*>(ccLayerTreeRoot->children()[1].get());
+
+ EXPECT_EQ(10, ccScrollbarLayer->currentPos());
+ EXPECT_EQ(100, ccScrollbarLayer->totalSize());
+ EXPECT_EQ(30, ccScrollbarLayer->maximum());
+
+ layerTreeRoot->setScrollPosition(IntPoint(100, 200));
+ layerTreeRoot->setMaxScrollPosition(IntSize(300, 500));
+ contentLayer->setBounds(IntSize(1000, 2000));
+
+ CCScrollbarAnimationController* scrollbarController = ccLayerTreeRoot->scrollbarAnimationController();
+ ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release(), 0);
+ EXPECT_EQ(scrollbarController, ccLayerTreeRoot->scrollbarAnimationController());
+
+ EXPECT_EQ(100, ccScrollbarLayer->currentPos());
+ EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
+ EXPECT_EQ(300, ccScrollbarLayer->maximum());
+
+ ccLayerTreeRoot->scrollBy(FloatSize(12, 34));
+
+ EXPECT_EQ(112, ccScrollbarLayer->currentPos());
+ EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
+ EXPECT_EQ(300, ccScrollbarLayer->maximum());
+}
+
}
diff --git a/Source/WebKit/chromium/tests/TextureCopierTest.cpp b/Source/WebKit/chromium/tests/TextureCopierTest.cpp
index 776e23bfd..432dd7c4a 100644
--- a/Source/WebKit/chromium/tests/TextureCopierTest.cpp
+++ b/Source/WebKit/chromium/tests/TextureCopierTest.cpp
@@ -27,7 +27,6 @@
#include "TextureCopier.h"
#include "FakeWebGraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -76,5 +75,6 @@ TEST(TextureCopierTest, testDrawArraysCopy)
int destTextureId = 2;
IntSize size(256, 128);
OwnPtr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create(mockContext.get(), false));
- copier->copyTexture(sourceTextureId, destTextureId, size);
+ TextureCopier::Parameters copy = { sourceTextureId, destTextureId, size };
+ copier->copyTexture(copy);
}
diff --git a/Source/WebKit/chromium/tests/TextureLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TextureLayerChromiumTest.cpp
index d0cc3d96f..54e253995 100644
--- a/Source/WebKit/chromium/tests/TextureLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/TextureLayerChromiumTest.cpp
@@ -27,10 +27,10 @@
#include "TextureLayerChromium.h"
#include "FakeCCLayerTreeHostClient.h"
-#include "WebCompositor.h"
#include "cc/CCLayerTreeHost.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebCompositor.h>
using namespace WebCore;
using ::testing::Mock;
diff --git a/Source/WebKit/chromium/tests/ThrottledTextureUploaderTest.cpp b/Source/WebKit/chromium/tests/ThrottledTextureUploaderTest.cpp
index 39a57d131..3660c9412 100644
--- a/Source/WebKit/chromium/tests/ThrottledTextureUploaderTest.cpp
+++ b/Source/WebKit/chromium/tests/ThrottledTextureUploaderTest.cpp
@@ -26,8 +26,8 @@
#include "ThrottledTextureUploader.h"
+#include "Extensions3DChromium.h"
#include "FakeWebGraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
index e39fe7e56..bab7168c4 100644
--- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
@@ -33,11 +33,12 @@
#include "FakeCCGraphicsContext.h"
#include "FakeCCLayerTreeHostClient.h"
#include "LayerPainterChromium.h"
-#include "WebCompositor.h"
#include "cc/CCOverdrawMetrics.h"
#include "cc/CCRenderingStats.h"
#include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread
+#include "cc/CCTextureUpdateController.h"
#include <gtest/gtest.h>
+#include <public/WebCompositor.h>
#include <public/WebTransformationMatrix.h>
using namespace WebCore;
@@ -57,7 +58,7 @@ class TestCCOcclusionTracker : public CCOcclusionTracker {
public:
TestCCOcclusionTracker()
: CCOcclusionTracker(IntRect(0, 0, 1000, 1000), true)
- , m_scissorRectInScreen(IntRect(0, 0, 1000, 1000))
+ , m_layerClipRectInTarget(IntRect(0, 0, 1000, 1000))
{
// Pretend we have visited a render surface.
m_stack.append(StackObject());
@@ -66,10 +67,10 @@ public:
void setOcclusion(const Region& occlusion) { m_stack.last().occlusionInScreen = occlusion; }
protected:
- virtual IntRect layerScissorRectInTargetSurface(const LayerChromium* layer) const { return m_scissorRectInScreen; }
+ virtual IntRect layerClipRectInTarget(const LayerChromium* layer) const OVERRIDE { return m_layerClipRectInTarget; }
private:
- IntRect m_scissorRectInScreen;
+ IntRect m_layerClipRectInTarget;
};
class TiledLayerChromiumTest : public testing::Test {
@@ -89,12 +90,12 @@ public:
void updateTextures(int count = 500)
{
- m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, count);
+ CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, &m_queue, count);
}
public:
OwnPtr<CCGraphicsContext> m_context;
OwnPtr<CCResourceProvider> m_resourceProvider;
- CCTextureUpdater m_updater;
+ CCTextureUpdateQueue m_queue;
CCRenderingStats m_stats;
FakeTextureCopier m_copier;
FakeTextureUploader m_uploader;
@@ -118,7 +119,7 @@ TEST_F(TiledLayerChromiumTest, pushDirtyTiles)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
@@ -131,7 +132,7 @@ TEST_F(TiledLayerChromiumTest, pushDirtyTiles)
// ....but then only update one of them.
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
layer->pushPropertiesTo(layerImpl.get());
// We should only have the first tile since the other tile was invalidated but not painted.
@@ -149,13 +150,14 @@ TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles)
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(IntSize(100, 200));
+ layer->setDrawableContentRect(IntRect(0, 0, 100, 200));
layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
layer->invalidateContentRect(IntRect(0, 0, 100, 200));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), &occluded, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
@@ -171,7 +173,7 @@ TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles)
layer->invalidateContentRect(IntRect(0, 0, 50, 50));
// ....but the area is occluded.
occluded.setOcclusion(IntRect(0, 0, 50, 50));
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), &occluded, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
@@ -199,7 +201,7 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
@@ -221,7 +223,7 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles)
// This should recreate and update the deleted textures.
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
@@ -250,7 +252,7 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, visibleRect, 0, m_stats);
+ layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
updateTextures();
// We should need idle-painting for 3x3 tiles in the center.
@@ -266,7 +268,7 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, visibleRect, 0, m_stats);
+ layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
EXPECT_TRUE(layer->needsIdlePaint(visibleRect));
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
@@ -317,8 +319,8 @@ TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed)
layer2->setTexturePriorities(m_priorityCalculator);
layer1->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer1->updateContentRect(m_updater, layerRect, 0, m_stats);
- layer2->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0, m_stats);
+ layer1->updateContentRect(m_queue, layerRect, 0, m_stats);
+ layer2->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
// We should need idle-painting for both remaining tiles in layer2.
EXPECT_TRUE(layer2->needsIdlePaint(layer2Rect));
@@ -335,7 +337,7 @@ TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed)
layer2->setTexturePriorities(m_priorityCalculator);
layer1->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer2->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0, m_stats);
+ layer2->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
// Oh well, commit the frame and push.
updateTextures();
@@ -355,8 +357,8 @@ TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed)
layer2->setTexturePriorities(m_priorityCalculator);
layer1->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer2->updateContentRect(m_updater, layer2Rect, 0, m_stats);
- layer1->updateContentRect(m_updater, layerRect, 0, m_stats);
+ layer2->updateContentRect(m_queue, layer2Rect, 0, m_stats);
+ layer1->updateContentRect(m_queue, layerRect, 0, m_stats);
updateTextures();
layer1->pushPropertiesTo(layerImpl1.get());
@@ -387,7 +389,7 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), &occluded, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
@@ -412,7 +414,7 @@ TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
@@ -442,11 +444,11 @@ TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
layer2->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer1->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer1->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
// Invalidate a tile on layer1
layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer1.get());
- layer2->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer2->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
updateTextures();
layer1->pushPropertiesTo(layer1Impl.get());
@@ -482,8 +484,8 @@ TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLay
// Invalidate a tile on layer2
layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer2.get());
- layer1->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
- layer2->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer1->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer2->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
updateTextures();
layer1->pushPropertiesTo(layer1Impl.get());
layer2->pushPropertiesTo(layer2Impl.get());
@@ -517,7 +519,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, visibleRect, 0, m_stats);
+ layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
// Idle-painting should see no more priority tiles for painting.
EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
@@ -530,7 +532,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, visibleRect, 0, m_stats);
+ layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
// We shouldn't signal we need another idle paint.
EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
@@ -559,7 +561,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer)
textureManager->prioritizeTextures();
// Empty layers don't paint or idle-paint.
- layer->updateContentRect(m_updater, contentRect, 0, m_stats);
+ layer->updateContentRect(m_queue, contentRect, 0, m_stats);
// Empty layers don't have tiles.
EXPECT_EQ(0u, layer->numPaintedTiles());
@@ -595,7 +597,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers)
// Paint / idle-paint.
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, visibleRect, 0, m_stats);
+ layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
// Non-visible layers don't need idle paint.
EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
@@ -658,7 +660,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, visibleRect, 0, m_stats);
+ layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
}
@@ -671,7 +673,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, visibleRect, 0, m_stats);
+ layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
}
@@ -694,7 +696,7 @@ TEST_F(TiledLayerChromiumTest, invalidateFromPrepare)
layer->invalidateContentRect(IntRect(0, 0, 100, 200));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
updateTextures(1000);
layer->pushPropertiesTo(layerImpl.get());
@@ -705,7 +707,7 @@ TEST_F(TiledLayerChromiumTest, invalidateFromPrepare)
layer->fakeLayerTextureUpdater()->clearPrepareCount();
// Invoke updateContentRect again. As the layer is valid updateContentRect shouldn't be invoked on
// the LayerTextureUpdater.
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
updateTextures(1000);
EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount());
@@ -713,12 +715,12 @@ TEST_F(TiledLayerChromiumTest, invalidateFromPrepare)
// setRectToInvalidate triggers invalidateContentRect() being invoked from updateContentRect.
layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50), layer.get());
layer->fakeLayerTextureUpdater()->clearPrepareCount();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
updateTextures(1000);
EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount());
layer->fakeLayerTextureUpdater()->clearPrepareCount();
// The layer should still be invalid as updateContentRect invoked invalidate.
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
updateTextures(1000);
EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount());
}
@@ -745,7 +747,7 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, contentBounds, 0, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, 0, m_stats);
EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 300, 300 * 0.8), layer->updateRect());
updateTextures();
@@ -753,7 +755,7 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
layer->invalidateContentRect(contentBounds);
- layer->updateContentRect(m_updater, contentBounds, 0, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, 0, m_stats);
EXPECT_FLOAT_RECT_EQ(FloatRect(layerBounds), layer->updateRect());
updateTextures();
@@ -762,7 +764,7 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled)
layer->invalidateContentRect(partialDamage);
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, contentBounds, 0, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, 0, m_stats);
EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect());
}
@@ -784,7 +786,7 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges)
// Push the tiles to the impl side and check that there is exactly one.
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 100), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
@@ -801,7 +803,7 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges)
// The impl side should get 2x2 tiles now.
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 200, 200), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 200, 200), 0, m_stats);
updateTextures();
layer->pushPropertiesTo(layerImpl.get());
EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
@@ -813,7 +815,7 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges)
// impl side.
layer->setNeedsDisplay();
layer->setTexturePriorities(m_priorityCalculator);
- layer->updateContentRect(m_updater, IntRect(1, 0, 0, 1), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(1, 0, 0, 1), 0, m_stats);
textureManager->prioritizeTextures();
layer->pushPropertiesTo(layerImpl.get());
@@ -852,9 +854,9 @@ TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset)
childLayer->invalidateContentRect(contentRect);
ccLayerTreeHost->setRootLayer(rootLayer);
- ccLayerTreeHost->setViewportSize(IntSize(300, 300));
+ ccLayerTreeHost->setViewportSize(IntSize(300, 300), IntSize(300, 300));
- ccLayerTreeHost->updateLayers(m_updater, memoryLimit);
+ ccLayerTreeHost->updateLayers(m_queue, memoryLimit);
// We'll skip the root layer.
EXPECT_TRUE(rootLayer->skipsDraw());
@@ -865,7 +867,7 @@ TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset)
// Remove the child layer.
rootLayer->removeAllChildren();
- ccLayerTreeHost->updateLayers(m_updater, memoryLimit);
+ ccLayerTreeHost->updateLayers(m_queue, memoryLimit);
EXPECT_FALSE(rootLayer->skipsDraw());
ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProvider.get());
@@ -885,7 +887,7 @@ TEST_F(TiledLayerChromiumTest, resizeToSmaller)
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 700, 700), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 700, 700), 0, m_stats);
layer->setBounds(IntSize(200, 200));
layer->invalidateContentRect(IntRect(0, 0, 200, 200));
@@ -904,7 +906,7 @@ TEST_F(TiledLayerChromiumTest, hugeLayerUpdateCrash)
// Ensure no crash for bounds where size * size would overflow an int.
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 700, 700), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 700, 700), 0, m_stats);
}
TEST_F(TiledLayerChromiumTest, partialUpdates)
@@ -930,20 +932,20 @@ TEST_F(TiledLayerChromiumTest, partialUpdates)
layer->invalidateContentRect(contentRect);
ccLayerTreeHost->setRootLayer(layer);
- ccLayerTreeHost->setViewportSize(IntSize(300, 200));
+ ccLayerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200));
// Full update of all 6 tiles.
- ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max());
+ ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max());
{
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
updateTextures(4);
EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
- EXPECT_TRUE(m_updater.hasMoreUpdates());
+ EXPECT_TRUE(m_queue.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
updateTextures(4);
EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount());
- EXPECT_FALSE(m_updater.hasMoreUpdates());
+ EXPECT_FALSE(m_queue.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
layer->pushPropertiesTo(layerImpl.get());
}
@@ -951,17 +953,17 @@ TEST_F(TiledLayerChromiumTest, partialUpdates)
// Full update of 3 tiles and partial update of 3 tiles.
layer->invalidateContentRect(IntRect(0, 0, 300, 150));
- ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max());
+ ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max());
{
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
updateTextures(4);
EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount());
- EXPECT_TRUE(m_updater.hasMoreUpdates());
+ EXPECT_TRUE(m_queue.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
updateTextures(4);
EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount());
- EXPECT_FALSE(m_updater.hasMoreUpdates());
+ EXPECT_FALSE(m_queue.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
layer->pushPropertiesTo(layerImpl.get());
}
@@ -972,14 +974,14 @@ TEST_F(TiledLayerChromiumTest, partialUpdates)
{
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
- ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max());
+ ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max());
updateTextures(4);
EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount());
- EXPECT_TRUE(m_updater.hasMoreUpdates());
+ EXPECT_TRUE(m_queue.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
updateTextures(4);
EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
- EXPECT_FALSE(m_updater.hasMoreUpdates());
+ EXPECT_FALSE(m_queue.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
layer->pushPropertiesTo(layerImpl.get());
}
@@ -999,14 +1001,14 @@ TEST_F(TiledLayerChromiumTest, partialUpdates)
{
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
- ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max());
+ ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max());
updateTextures(4);
EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
- EXPECT_TRUE(m_updater.hasMoreUpdates());
+ EXPECT_TRUE(m_queue.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
updateTextures(4);
EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount());
- EXPECT_FALSE(m_updater.hasMoreUpdates());
+ EXPECT_FALSE(m_queue.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
layer->pushPropertiesTo(layerImpl.get());
}
@@ -1017,10 +1019,10 @@ TEST_F(TiledLayerChromiumTest, partialUpdates)
{
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
- ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max());
+ ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max());
updateTextures(4);
EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
- EXPECT_FALSE(m_updater.hasMoreUpdates());
+ EXPECT_FALSE(m_queue.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
layer->pushPropertiesTo(layerImpl.get());
}
@@ -1042,12 +1044,13 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion)
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(IntSize(100, 200));
+ layer->setDrawableContentRect(IntRect(0, 0, 100, 200));
layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
layer->invalidateContentRect(IntRect(0, 0, 100, 200));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 100, 200), 0, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->prepareRectCount());
}
@@ -1062,12 +1065,13 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
layer->setBounds(IntSize(600, 600));
occluded.setOcclusion(IntRect(200, 200, 300, 100));
+ layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1075,10 +1079,12 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload());
layer->fakeLayerTextureUpdater()->clearPrepareRectCount();
+ layer->setTexturePriorities(m_priorityCalculator);
+ textureManager->prioritizeTextures();
occluded.setOcclusion(IntRect(250, 200, 300, 100));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
EXPECT_EQ(36-2, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1086,10 +1092,12 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload());
layer->fakeLayerTextureUpdater()->clearPrepareRectCount();
+ layer->setTexturePriorities(m_priorityCalculator);
+ textureManager->prioritizeTextures();
occluded.setOcclusion(IntRect(250, 250, 300, 100));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
EXPECT_EQ(36, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1109,12 +1117,13 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
// The partially occluded tiles (by the 150 occlusion height) are visible beyond the occlusion, so not culled.
occluded.setOcclusion(IntRect(200, 200, 300, 150));
+ layer->setDrawableContentRect(IntRect(0, 0, 600, 360));
layer->setVisibleContentRect(IntRect(0, 0, 600, 360));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 360), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 360), &occluded, m_stats);
EXPECT_EQ(24-3, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1125,11 +1134,12 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
// Now the visible region stops at the edge of the occlusion so the partly visible tiles become fully occluded.
occluded.setOcclusion(IntRect(200, 200, 300, 150));
+ layer->setDrawableContentRect(IntRect(0, 0, 600, 350));
layer->setVisibleContentRect(IntRect(0, 0, 600, 350));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 350), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 350), &occluded, m_stats);
EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1140,11 +1150,12 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
// Now the visible region is even smaller than the occlusion, it should have the same result.
occluded.setOcclusion(IntRect(200, 200, 300, 150));
+ layer->setDrawableContentRect(IntRect(0, 0, 600, 340));
layer->setVisibleContentRect(IntRect(0, 0, 600, 340));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 340), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 340), &occluded, m_stats);
EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1164,11 +1175,12 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation)
layer->setBounds(IntSize(600, 600));
occluded.setOcclusion(IntRect(200, 200, 300, 100));
+ layer->setDrawableContentRect(IntRect(0, 0, 600, 600));
layer->setVisibleContentRect(IntRect(0, 0, 600, 600));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount());
{
DebugScopedSetImplThread implThread;
@@ -1180,9 +1192,11 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation)
EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload());
layer->fakeLayerTextureUpdater()->clearPrepareRectCount();
+ layer->setTexturePriorities(m_priorityCalculator);
+ textureManager->prioritizeTextures();
// Repaint without marking it dirty. The 3 culled tiles will be pre-painted now.
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1207,11 +1221,12 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms)
layer->setDrawTransform(screenTransform);
occluded.setOcclusion(IntRect(100, 100, 150, 50));
+ layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1238,11 +1253,12 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
layer->setScreenSpaceTransform(drawTransform);
occluded.setOcclusion(IntRect(200, 200, 300, 100));
+ layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
// The content is half the size of the layer (so the number of tiles is fewer).
// In this case, the content is 300x300, and since the tile size is 100, the
// number of tiles 3x3.
@@ -1258,11 +1274,12 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
// a different layer space. In this case the occluded region catches the
// blown up tiles.
occluded.setOcclusion(IntRect(200, 200, 300, 200));
+ layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1278,11 +1295,12 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
layer->setDrawTransform(screenTransform);
occluded.setOcclusion(IntRect(100, 100, 150, 100));
+ layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
layer->invalidateContentRect(IntRect(0, 0, 600, 600));
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
- layer->updateContentRect(m_updater, IntRect(0, 0, 600, 600), &occluded, m_stats);
+ layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1306,6 +1324,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
IntRect visibleBounds = IntRect(0, 0, 100, 150);
layer->setBounds(contentBounds.size());
+ layer->setDrawableContentRect(visibleBounds);
layer->setVisibleContentRect(visibleBounds);
layer->setDrawOpacity(1);
@@ -1315,7 +1334,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
// If the layer doesn't paint opaque content, then the visibleContentOpaqueRegion should be empty.
layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
layer->invalidateContentRect(contentBounds);
- layer->updateContentRect(m_updater, contentBounds, &occluded, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
opaqueContents = layer->visibleContentOpaqueRegion();
EXPECT_TRUE(opaqueContents.isEmpty());
@@ -1328,7 +1347,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
opaquePaintRect = IntRect(10, 10, 90, 190);
layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect);
layer->invalidateContentRect(contentBounds);
- layer->updateContentRect(m_updater, contentBounds, &occluded, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds());
@@ -1341,7 +1360,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
// If we paint again without invalidating, the same stuff should be opaque.
layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
- layer->updateContentRect(m_updater, contentBounds, &occluded, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds());
@@ -1356,7 +1375,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
// not be affected.
layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
layer->invalidateContentRect(IntRect(0, 0, 1, 1));
- layer->updateContentRect(m_updater, contentBounds, &occluded, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds());
@@ -1371,7 +1390,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
// not be affected.
layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
layer->invalidateContentRect(IntRect(10, 10, 1, 1));
- layer->updateContentRect(m_updater, contentBounds, &occluded, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
EXPECT_EQ_RECT(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqueContents.bounds());
@@ -1399,6 +1418,7 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics)
IntRect visibleBounds = IntRect(0, 0, 100, 300);
layer->setBounds(contentBounds.size());
+ layer->setDrawableContentRect(visibleBounds);
layer->setVisibleContentRect(visibleBounds);
layer->setDrawOpacity(1);
@@ -1408,7 +1428,7 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics)
// Invalidates and paints the whole layer.
layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
layer->invalidateContentRect(contentBounds);
- layer->updateContentRect(m_updater, contentBounds, &occluded, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
EXPECT_TRUE(opaqueContents.isEmpty());
@@ -1423,7 +1443,7 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics)
layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
layer->invalidateContentRect(IntRect(0, 0, 1, 1));
layer->invalidateContentRect(IntRect(50, 200, 10, 10));
- layer->updateContentRect(m_updater, contentBounds, &occluded, m_stats);
+ layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
EXPECT_TRUE(opaqueContents.isEmpty());
@@ -1458,6 +1478,7 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca
root->setBounds(rootRect.size());
root->setAnchorPoint(FloatPoint());
+ root->setDrawableContentRect(rootRect);
root->setVisibleContentRect(rootRect);
root->addChild(surface);
@@ -1471,27 +1492,29 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca
child->setAnchorPoint(FloatPoint());
child->setPosition(childRect.location());
child->setVisibleContentRect(childRect);
+ child->setDrawableContentRect(rootRect);
child2->setBounds(child2Rect.size());
child2->setAnchorPoint(FloatPoint());
child2->setPosition(child2Rect.location());
child2->setVisibleContentRect(child2Rect);
+ child2->setDrawableContentRect(rootRect);
ccLayerTreeHost->setRootLayer(root);
- ccLayerTreeHost->setViewportSize(rootRect.size());
+ ccLayerTreeHost->setViewportSize(rootRect.size(), rootRect.size());
// With a huge memory limit, all layers should update and push their textures.
root->invalidateContentRect(rootRect);
child->invalidateContentRect(childRect);
child2->invalidateContentRect(child2Rect);
- ccLayerTreeHost->updateLayers(m_updater, std::numeric_limits<size_t>::max());
+ ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max());
{
DebugScopedSetImplThread implThread;
updateTextures(1000);
EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount());
EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount());
EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount());
- EXPECT_FALSE(m_updater.hasMoreUpdates());
+ EXPECT_FALSE(m_queue.hasMoreUpdates());
root->fakeLayerTextureUpdater()->clearUpdateCount();
child->fakeLayerTextureUpdater()->clearUpdateCount();
@@ -1519,14 +1542,14 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca
root->invalidateContentRect(rootRect);
child->invalidateContentRect(childRect);
child2->invalidateContentRect(child2Rect);
- ccLayerTreeHost->updateLayers(m_updater, (3 * 2 + 3 * 1) * (100 * 100) * 4);
+ ccLayerTreeHost->updateLayers(m_queue, (3 * 2 + 3 * 1) * (100 * 100) * 4);
{
DebugScopedSetImplThread implThread;
updateTextures(1000);
EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount());
EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount());
EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount());
- EXPECT_FALSE(m_updater.hasMoreUpdates());
+ EXPECT_FALSE(m_queue.hasMoreUpdates());
root->fakeLayerTextureUpdater()->clearUpdateCount();
child->fakeLayerTextureUpdater()->clearUpdateCount();
@@ -1555,14 +1578,14 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca
root->invalidateContentRect(rootRect);
child->invalidateContentRect(childRect);
child2->invalidateContentRect(child2Rect);
- ccLayerTreeHost->updateLayers(m_updater, (3 * 1) * (100 * 100) * 4);
+ ccLayerTreeHost->updateLayers(m_queue, (3 * 1) * (100 * 100) * 4);
{
DebugScopedSetImplThread implThread;
updateTextures(1000);
EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount());
EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount());
EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount());
- EXPECT_FALSE(m_updater.hasMoreUpdates());
+ EXPECT_FALSE(m_queue.hasMoreUpdates());
root->fakeLayerTextureUpdater()->clearUpdateCount();
child->fakeLayerTextureUpdater()->clearUpdateCount();
@@ -1646,12 +1669,13 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
IntRect contentRect(0, 0, 45, 47);
EXPECT_EQ(contentRect.size(), layer->contentBounds());
layer->setVisibleContentRect(contentRect);
+ layer->setDrawableContentRect(contentRect);
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
// Update the whole tile.
- layer->updateContentRect(m_updater, contentRect, 0, m_stats);
+ layer->updateContentRect(m_queue, contentRect, 0, m_stats);
layer->trackingLayerPainter()->resetPaintedRect();
EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect());
@@ -1663,7 +1687,7 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
// Invalidate the entire layer in content space. When painting, the rect given to webkit should match the layer's bounds.
layer->invalidateContentRect(contentRect);
- layer->updateContentRect(m_updater, contentRect, 0, m_stats);
+ layer->updateContentRect(m_queue, contentRect, 0, m_stats);
EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
}
@@ -1681,12 +1705,13 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali
IntRect contentRect(IntPoint(), layer->contentBounds());
layer->setVisibleContentRect(contentRect);
+ layer->setDrawableContentRect(contentRect);
layer->setTexturePriorities(m_priorityCalculator);
textureManager->prioritizeTextures();
// Update the whole tile.
- layer->updateContentRect(m_updater, contentRect, 0, m_stats);
+ layer->updateContentRect(m_queue, contentRect, 0, m_stats);
layer->trackingLayerPainter()->resetPaintedRect();
EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect());
@@ -1698,7 +1723,7 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali
// Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds.
layer->setNeedsDisplayRect(layerRect);
- layer->updateContentRect(m_updater, contentRect, 0, m_stats);
+ layer->updateContentRect(m_queue, contentRect, 0, m_stats);
EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
}
diff --git a/Source/WebKit/chromium/tests/WebAnimationTest.cpp b/Source/WebKit/chromium/tests/WebAnimationTest.cpp
index df830cae6..c2ccc4503 100644
--- a/Source/WebKit/chromium/tests/WebAnimationTest.cpp
+++ b/Source/WebKit/chromium/tests/WebAnimationTest.cpp
@@ -47,7 +47,7 @@ namespace {
TEST(WebAnimationTest, MAYBE_DefaultSettings)
{
WebFloatAnimationCurve curve;
- WebAnimation animation(curve, WebAnimation::WebAnimationOpacity);
+ WebAnimation animation(curve, WebAnimation::TargetPropertyOpacity);
// Ensure that the defaults are correct.
EXPECT_EQ(1, animation.iterations());
@@ -68,7 +68,7 @@ TEST(WebAnimationTest, MAYBE_DefaultSettings)
TEST(WebAnimationTest, MAYBE_ModifiedSettings)
{
WebFloatAnimationCurve curve;
- WebAnimation animation(curve, WebAnimation::WebAnimationOpacity);
+ WebAnimation animation(curve, WebAnimation::TargetPropertyOpacity);
animation.setIterations(2);
animation.setStartTime(2);
animation.setTimeOffset(2);
diff --git a/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp b/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp
index d5b68a867..902fac981 100644
--- a/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp
+++ b/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp
@@ -27,14 +27,14 @@
#include "WebCompositorInputHandlerImpl.h"
-#include "WebCompositor.h"
#include "WebCompositorInputHandlerClient.h"
#include "WebInputEvent.h"
#include "cc/CCActiveGestureAnimation.h"
#include "cc/CCInputHandler.h"
#include "cc/CCSingleThreadProxy.h"
-#include "platform/WebFloatPoint.h"
-#include "platform/WebPoint.h"
+#include <public/WebCompositor.h>
+#include <public/WebFloatPoint.h>
+#include <public/WebPoint.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp
index 9b745e029..cd23d6268 100644
--- a/Source/WebKit/chromium/tests/WebFrameTest.cpp
+++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp
@@ -804,4 +804,54 @@ TEST_F(WebFrameTest, GetFullHtmlOfPage)
EXPECT_TRUE(selectionHtml.isEmpty());
}
+class TestExecuteScriptDuringDidCreateScriptContext : public WebFrameClient {
+public:
+ virtual void didCreateScriptContext(WebFrame* frame, v8::Handle<v8::Context> context, int extensionGroup, int worldId) OVERRIDE
+ {
+ frame->executeScript(WebScriptSource("window.history = 'replaced';"));
+ }
+};
+
+TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext)
+{
+ registerMockedHttpURLLoad("hello_world.html");
+
+ TestExecuteScriptDuringDidCreateScriptContext webFrameClient;
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "hello_world.html", true, &webFrameClient);
+
+ webView->mainFrame()->reload();
+ webkit_support::ServeAsynchronousMockedRequests();
+}
+
+class TestDidCreateFrameWebFrameClient : public WebFrameClient {
+public:
+ TestDidCreateFrameWebFrameClient() : m_frameCount(0), m_parent(0)
+ {
+ }
+
+ virtual void didCreateFrame(WebFrame* parent, WebFrame* child)
+ {
+ m_frameCount++;
+ if (!m_parent)
+ m_parent = parent;
+ }
+
+ int m_frameCount;
+ WebFrame* m_parent;
+};
+
+TEST_F(WebFrameTest, DidCreateFrame)
+{
+ registerMockedHttpURLLoad("iframes_test.html");
+ registerMockedHttpURLLoad("visible_iframe.html");
+ registerMockedHttpURLLoad("invisible_iframe.html");
+ registerMockedHttpURLLoad("zero_sized_iframe.html");
+
+ TestDidCreateFrameWebFrameClient webFrameClient;
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test.html", false, &webFrameClient);
+
+ EXPECT_EQ(webFrameClient.m_frameCount, 3);
+ EXPECT_EQ(webFrameClient.m_parent, webView->mainFrame());
+}
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/WebLayerTest.cpp b/Source/WebKit/chromium/tests/WebLayerTest.cpp
index 12deb5991..5381173ef 100644
--- a/Source/WebKit/chromium/tests/WebLayerTest.cpp
+++ b/Source/WebKit/chromium/tests/WebLayerTest.cpp
@@ -23,19 +23,19 @@
*/
#include "config.h"
-#include "platform/WebLayer.h"
+#include <public/WebLayer.h>
#include "CompositorFakeWebGraphicsContext3D.h"
-#include "WebCompositor.h"
-#include "platform/WebContentLayer.h"
-#include "platform/WebContentLayerClient.h"
-#include "platform/WebExternalTextureLayer.h"
-#include "platform/WebFloatPoint.h"
-#include "platform/WebFloatRect.h"
-#include "platform/WebLayerTreeView.h"
-#include "platform/WebLayerTreeViewClient.h"
-#include "platform/WebRect.h"
-#include "platform/WebSize.h"
+#include <public/WebCompositor.h>
+#include <public/WebContentLayer.h>
+#include <public/WebContentLayerClient.h>
+#include <public/WebExternalTextureLayer.h>
+#include <public/WebFloatPoint.h>
+#include <public/WebFloatRect.h>
+#include <public/WebLayerTreeView.h>
+#include <public/WebLayerTreeViewClient.h>
+#include <public/WebRect.h>
+#include <public/WebSize.h>
#include <gmock/gmock.h>
@@ -58,6 +58,8 @@ public:
virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { }
virtual WebGraphicsContext3D* createContext3D() { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); }
virtual void didRebindGraphicsContext(bool success) { }
+ virtual WebCompositorOutputSurface* createOutputSurface() { return 0; }
+ virtual void didRecreateOutputSurface(bool success) { }
virtual void willCommit() { }
virtual void didCommitAndDrawFrame() { }
virtual void didCompleteSwapBuffers() { }
diff --git a/Source/WebKit/chromium/tests/WebLayerTreeViewTest.cpp b/Source/WebKit/chromium/tests/WebLayerTreeViewTest.cpp
index 2df259f76..4f0330035 100644
--- a/Source/WebKit/chromium/tests/WebLayerTreeViewTest.cpp
+++ b/Source/WebKit/chromium/tests/WebLayerTreeViewTest.cpp
@@ -24,15 +24,16 @@
#include "config.h"
-#include "platform/WebLayerTreeView.h"
+#include <public/WebLayerTreeView.h>
#include "CompositorFakeWebGraphicsContext3D.h"
-#include "WebCompositor.h"
-#include "public/WebLayer.h"
-#include "public/WebLayerTreeViewClient.h"
-#include "public/WebThread.h"
+#include "FakeWebCompositorOutputSurface.h"
#include <gmock/gmock.h>
#include <public/Platform.h>
+#include <public/WebCompositor.h>
+#include <public/WebLayer.h>
+#include <public/WebLayerTreeViewClient.h>
+#include <public/WebThread.h>
using namespace WebKit;
using testing::Mock;
@@ -48,8 +49,13 @@ public:
MOCK_METHOD0(didBeginFrame, void());
virtual void layout() OVERRIDE { }
virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) OVERRIDE { }
- virtual WebGraphicsContext3D* createContext3D() OVERRIDE { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); }
- virtual void didRebindGraphicsContext(bool success) OVERRIDE { }
+
+ virtual WebCompositorOutputSurface* createOutputSurface() OVERRIDE
+ {
+ return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes())).leakPtr();
+ }
+ virtual void didRecreateOutputSurface(bool) OVERRIDE { }
+
MOCK_METHOD0(willCommit, void());
MOCK_METHOD0(didCommit, void());
virtual void didCommitAndDrawFrame() OVERRIDE { }
diff --git a/Source/WebKit/chromium/tests/data/hello_world.html b/Source/WebKit/chromium/tests/data/hello_world.html
new file mode 100644
index 000000000..75ab18b58
--- /dev/null
+++ b/Source/WebKit/chromium/tests/data/hello_world.html
@@ -0,0 +1,3 @@
+<script>
+document.write("Hello, world.");
+</script>