OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_tree_host.h" | 7 #include "cc/layer_tree_host.h" |
8 | 8 |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "cc/content_layer.h" | 10 #include "cc/content_layer.h" |
11 #include "cc/content_layer_client.h" | 11 #include "cc/content_layer_client.h" |
12 #include "cc/graphics_context.h" | 12 #include "cc/graphics_context.h" |
13 #include "cc/layer_tree_host_impl.h" | 13 #include "cc/layer_tree_host_impl.h" |
14 #include "cc/settings.h" | 14 #include "cc/settings.h" |
15 #include "cc/single_thread_proxy.h" | 15 #include "cc/single_thread_proxy.h" |
16 #include "cc/test/fake_web_compositor_output_surface.h" | 16 #include "cc/test/fake_web_compositor_output_surface.h" |
17 #include "cc/test/geometry_test_utils.h" | 17 #include "cc/test/geometry_test_utils.h" |
18 #include "cc/test/layer_tree_test_common.h" | 18 #include "cc/test/layer_tree_test_common.h" |
19 #include "cc/test/occlusion_tracker_test_common.h" | 19 #include "cc/test/occlusion_tracker_test_common.h" |
20 #include "cc/resource_update_queue.h" | 20 #include "cc/resource_update_queue.h" |
21 #include "cc/timing_function.h" | 21 #include "cc/timing_function.h" |
22 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
23 #include "third_party/khronos/GLES2/gl2.h" | 23 #include "third_party/khronos/GLES2/gl2.h" |
24 #include "third_party/khronos/GLES2/gl2ext.h" | 24 #include "third_party/khronos/GLES2/gl2ext.h" |
| 25 #include "ui/gfx/point_conversions.h" |
| 26 #include "ui/gfx/size_conversions.h" |
25 #include <public/WebLayerScrollClient.h> | 27 #include <public/WebLayerScrollClient.h> |
26 #include <public/WebSize.h> | 28 #include <public/WebSize.h> |
27 | 29 |
28 using namespace cc; | 30 using namespace cc; |
29 using namespace WebKit; | 31 using namespace WebKit; |
30 using namespace WebKitTests; | 32 using namespace WebKitTests; |
31 | 33 |
32 namespace { | 34 namespace { |
33 | 35 |
34 class LayerTreeHostTest : public ThreadedTest { }; | 36 class LayerTreeHostTest : public ThreadedTest { }; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 // After the first commit, we should not be able to draw. | 304 // After the first commit, we should not be able to draw. |
303 EXPECT_FALSE(impl->canDraw()); | 305 EXPECT_FALSE(impl->canDraw()); |
304 } | 306 } |
305 } | 307 } |
306 | 308 |
307 virtual void didCommit() OVERRIDE | 309 virtual void didCommit() OVERRIDE |
308 { | 310 { |
309 m_numCommits++; | 311 m_numCommits++; |
310 if (m_numCommits == 1) { | 312 if (m_numCommits == 1) { |
311 // Make the viewport empty so the host says it can't draw. | 313 // Make the viewport empty so the host says it can't draw. |
312 m_layerTreeHost->setViewportSize(IntSize(0, 0), IntSize(0, 0)); | 314 m_layerTreeHost->setViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); |
313 | 315 |
314 scoped_array<char> pixels(new char[4]); | 316 scoped_array<char> pixels(new char[4]); |
315 m_layerTreeHost->compositeAndReadback(static_cast<void*>(pixels.get(
)), IntRect(0, 0, 1, 1)); | 317 m_layerTreeHost->compositeAndReadback(static_cast<void*>(pixels.get(
)), IntRect(0, 0, 1, 1)); |
316 } else if (m_numCommits == 2) { | 318 } else if (m_numCommits == 2) { |
317 m_layerTreeHost->setNeedsRedraw(); | 319 m_layerTreeHost->setNeedsRedraw(); |
318 m_layerTreeHost->setNeedsCommit(); | 320 m_layerTreeHost->setNeedsCommit(); |
319 } else | 321 } else |
320 endTest(); | 322 endTest(); |
321 } | 323 } |
322 | 324 |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 } | 985 } |
984 | 986 |
985 // This test verifies that properties on the layer tree host are commited to the
impl side. | 987 // This test verifies that properties on the layer tree host are commited to the
impl side. |
986 class LayerTreeHostTestCommit : public LayerTreeHostTest { | 988 class LayerTreeHostTestCommit : public LayerTreeHostTest { |
987 public: | 989 public: |
988 | 990 |
989 LayerTreeHostTestCommit() { } | 991 LayerTreeHostTestCommit() { } |
990 | 992 |
991 virtual void beginTest() OVERRIDE | 993 virtual void beginTest() OVERRIDE |
992 { | 994 { |
993 m_layerTreeHost->setViewportSize(IntSize(20, 20), IntSize(20, 20)); | 995 m_layerTreeHost->setViewportSize(gfx::Size(20, 20), gfx::Size(20, 20)); |
994 m_layerTreeHost->setBackgroundColor(SK_ColorGRAY); | 996 m_layerTreeHost->setBackgroundColor(SK_ColorGRAY); |
995 m_layerTreeHost->setPageScaleFactorAndLimits(5, 5, 5); | 997 m_layerTreeHost->setPageScaleFactorAndLimits(5, 5, 5); |
996 | 998 |
997 postSetNeedsCommitToMainThread(); | 999 postSetNeedsCommitToMainThread(); |
998 } | 1000 } |
999 | 1001 |
1000 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1002 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1001 { | 1003 { |
1002 EXPECT_EQ(IntSize(20, 20), impl->layoutViewportSize()); | 1004 EXPECT_EQ(gfx::Size(20, 20), impl->layoutViewportSize()); |
1003 EXPECT_EQ(SK_ColorGRAY, impl->backgroundColor()); | 1005 EXPECT_EQ(SK_ColorGRAY, impl->backgroundColor()); |
1004 EXPECT_EQ(5, impl->pageScaleFactor()); | 1006 EXPECT_EQ(5, impl->pageScaleFactor()); |
1005 | 1007 |
1006 endTest(); | 1008 endTest(); |
1007 } | 1009 } |
1008 | 1010 |
1009 virtual void afterTest() OVERRIDE { } | 1011 virtual void afterTest() OVERRIDE { } |
1010 }; | 1012 }; |
1011 | 1013 |
1012 TEST_F(LayerTreeHostTestCommit, runTest) | 1014 TEST_F(LayerTreeHostTestCommit, runTest) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 { | 1154 { |
1153 ContentLayer::update(queue, occlusion, stats); | 1155 ContentLayer::update(queue, occlusion, stats); |
1154 m_paintContentsCount++; | 1156 m_paintContentsCount++; |
1155 } | 1157 } |
1156 | 1158 |
1157 private: | 1159 private: |
1158 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client) | 1160 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client) |
1159 : ContentLayer(client) | 1161 : ContentLayer(client) |
1160 , m_paintContentsCount(0) | 1162 , m_paintContentsCount(0) |
1161 { | 1163 { |
1162 setAnchorPoint(FloatPoint(0, 0)); | 1164 setAnchorPoint(gfx::PointF(0, 0)); |
1163 setBounds(IntSize(10, 10)); | 1165 setBounds(gfx::Size(10, 10)); |
1164 setIsDrawable(true); | 1166 setIsDrawable(true); |
1165 } | 1167 } |
1166 virtual ~ContentLayerWithUpdateTracking() | 1168 virtual ~ContentLayerWithUpdateTracking() |
1167 { | 1169 { |
1168 } | 1170 } |
1169 | 1171 |
1170 int m_paintContentsCount; | 1172 int m_paintContentsCount; |
1171 }; | 1173 }; |
1172 | 1174 |
1173 // Layer opacity change during paint should not prevent compositor resources fro
m being updated during commit. | 1175 // Layer opacity change during paint should not prevent compositor resources fro
m being updated during commit. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 bool drawsContent() const { return true; } | 1219 bool drawsContent() const { return true; } |
1218 MOCK_CONST_METHOD0(preserves3D, bool()); | 1220 MOCK_CONST_METHOD0(preserves3D, bool()); |
1219 void paintContents(SkCanvas*, const gfx::Rect&, gfx::RectF&) OVERRIDE { } | 1221 void paintContents(SkCanvas*, const gfx::Rect&, gfx::RectF&) OVERRIDE { } |
1220 void notifySyncRequired() { } | 1222 void notifySyncRequired() { } |
1221 }; | 1223 }; |
1222 | 1224 |
1223 class NoScaleContentLayer : public ContentLayer { | 1225 class NoScaleContentLayer : public ContentLayer { |
1224 public: | 1226 public: |
1225 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } | 1227 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } |
1226 | 1228 |
1227 virtual IntSize contentBounds() const OVERRIDE { return bounds(); } | 1229 virtual gfx::Size contentBounds() const OVERRIDE { return bounds(); } |
1228 virtual float contentsScaleX() const OVERRIDE { return 1.0; } | 1230 virtual float contentsScaleX() const OVERRIDE { return 1.0; } |
1229 virtual float contentsScaleY() const OVERRIDE { return 1.0; } | 1231 virtual float contentsScaleY() const OVERRIDE { return 1.0; } |
1230 | 1232 |
1231 private: | 1233 private: |
1232 explicit NoScaleContentLayer(ContentLayerClient* client) | 1234 explicit NoScaleContentLayer(ContentLayerClient* client) |
1233 : ContentLayer(client) { } | 1235 : ContentLayer(client) { } |
1234 virtual ~NoScaleContentLayer() { } | 1236 virtual ~NoScaleContentLayer() { } |
1235 }; | 1237 }; |
1236 | 1238 |
1237 // Ensures that when opacity is being animated, this value does not cause the su
btree to be skipped. | 1239 // Ensures that when opacity is being animated, this value does not cause the su
btree to be skipped. |
1238 class LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public LayerTreeHost
Test { | 1240 class LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public LayerTreeHost
Test { |
1239 public: | 1241 public: |
1240 LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity() | 1242 LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity() |
1241 : m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_client)) | 1243 : m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_client)) |
1242 { | 1244 { |
1243 } | 1245 } |
1244 | 1246 |
1245 virtual void beginTest() OVERRIDE | 1247 virtual void beginTest() OVERRIDE |
1246 { | 1248 { |
1247 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 1249 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
1248 m_layerTreeHost->rootLayer()->addChild(m_updateCheckLayer); | 1250 m_layerTreeHost->rootLayer()->addChild(m_updateCheckLayer); |
1249 m_updateCheckLayer->setOpacity(0); | 1251 m_updateCheckLayer->setOpacity(0); |
1250 m_updateCheckLayer->setDrawOpacity(0); | 1252 m_updateCheckLayer->setDrawOpacity(0); |
1251 postAddAnimationToMainThread(m_updateCheckLayer.get()); | 1253 postAddAnimationToMainThread(m_updateCheckLayer.get()); |
1252 } | 1254 } |
1253 | 1255 |
1254 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 1256 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
1255 { | 1257 { |
1256 endTest(); | 1258 endTest(); |
1257 } | 1259 } |
(...skipping 22 matching lines...) Expand all Loading... |
1280 public: | 1282 public: |
1281 | 1283 |
1282 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() | 1284 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() |
1283 : m_rootLayer(NoScaleContentLayer::create(&m_client)) | 1285 : m_rootLayer(NoScaleContentLayer::create(&m_client)) |
1284 , m_childLayer(ContentLayer::create(&m_client)) | 1286 , m_childLayer(ContentLayer::create(&m_client)) |
1285 { | 1287 { |
1286 } | 1288 } |
1287 | 1289 |
1288 virtual void beginTest() OVERRIDE | 1290 virtual void beginTest() OVERRIDE |
1289 { | 1291 { |
1290 m_layerTreeHost->setViewportSize(IntSize(40, 40), IntSize(60, 60)); | 1292 m_layerTreeHost->setViewportSize(gfx::Size(40, 40), gfx::Size(60, 60)); |
1291 m_layerTreeHost->setDeviceScaleFactor(1.5); | 1293 m_layerTreeHost->setDeviceScaleFactor(1.5); |
1292 EXPECT_EQ(IntSize(40, 40), m_layerTreeHost->layoutViewportSize()); | 1294 EXPECT_EQ(gfx::Size(40, 40), m_layerTreeHost->layoutViewportSize()); |
1293 EXPECT_EQ(IntSize(60, 60), m_layerTreeHost->deviceViewportSize()); | 1295 EXPECT_EQ(gfx::Size(60, 60), m_layerTreeHost->deviceViewportSize()); |
1294 | 1296 |
1295 m_rootLayer->addChild(m_childLayer); | 1297 m_rootLayer->addChild(m_childLayer); |
1296 | 1298 |
1297 m_rootLayer->setIsDrawable(true); | 1299 m_rootLayer->setIsDrawable(true); |
1298 m_rootLayer->setBounds(IntSize(30, 30)); | 1300 m_rootLayer->setBounds(gfx::Size(30, 30)); |
1299 m_rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 1301 m_rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
1300 | 1302 |
1301 m_childLayer->setIsDrawable(true); | 1303 m_childLayer->setIsDrawable(true); |
1302 m_childLayer->setPosition(IntPoint(2, 2)); | 1304 m_childLayer->setPosition(gfx::Point(2, 2)); |
1303 m_childLayer->setBounds(IntSize(10, 10)); | 1305 m_childLayer->setBounds(gfx::Size(10, 10)); |
1304 m_childLayer->setAnchorPoint(FloatPoint(0, 0)); | 1306 m_childLayer->setAnchorPoint(FloatPoint(0, 0)); |
1305 | 1307 |
1306 m_layerTreeHost->setRootLayer(m_rootLayer); | 1308 m_layerTreeHost->setRootLayer(m_rootLayer); |
1307 } | 1309 } |
1308 | 1310 |
1309 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1311 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1310 { | 1312 { |
1311 // Get access to protected methods. | 1313 // Get access to protected methods. |
1312 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im
pl); | 1314 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im
pl); |
1313 | 1315 |
1314 // Should only do one commit. | 1316 // Should only do one commit. |
1315 EXPECT_EQ(0, impl->sourceFrameNumber()); | 1317 EXPECT_EQ(0, impl->sourceFrameNumber()); |
1316 // Device scale factor should come over to impl. | 1318 // Device scale factor should come over to impl. |
1317 EXPECT_NEAR(impl->deviceScaleFactor(), 1.5, 0.00001); | 1319 EXPECT_NEAR(impl->deviceScaleFactor(), 1.5, 0.00001); |
1318 | 1320 |
1319 // Both layers are on impl. | 1321 // Both layers are on impl. |
1320 ASSERT_EQ(1u, impl->rootLayer()->children().size()); | 1322 ASSERT_EQ(1u, impl->rootLayer()->children().size()); |
1321 | 1323 |
1322 // Device viewport is scaled. | 1324 // Device viewport is scaled. |
1323 EXPECT_EQ(IntSize(40, 40), impl->layoutViewportSize()); | 1325 EXPECT_EQ(gfx::Size(40, 40), impl->layoutViewportSize()); |
1324 EXPECT_EQ(IntSize(60, 60), impl->deviceViewportSize()); | 1326 EXPECT_EQ(gfx::Size(60, 60), impl->deviceViewportSize()); |
1325 | 1327 |
1326 LayerImpl* root = impl->rootLayer(); | 1328 LayerImpl* root = impl->rootLayer(); |
1327 LayerImpl* child = impl->rootLayer()->children()[0]; | 1329 LayerImpl* child = impl->rootLayer()->children()[0]; |
1328 | 1330 |
1329 // Positions remain in layout pixels. | 1331 // Positions remain in layout pixels. |
1330 EXPECT_EQ(IntPoint(0, 0), root->position()); | 1332 EXPECT_EQ(gfx::Point(0, 0), root->position()); |
1331 EXPECT_EQ(IntPoint(2, 2), child->position()); | 1333 EXPECT_EQ(gfx::Point(2, 2), child->position()); |
1332 | 1334 |
1333 // Compute all the layer transforms for the frame. | 1335 // Compute all the layer transforms for the frame. |
1334 MockLayerTreeHostImpl::LayerList renderSurfaceLayerList; | 1336 MockLayerTreeHostImpl::LayerList renderSurfaceLayerList; |
1335 mockImpl->calculateRenderSurfaceLayerList(renderSurfaceLayerList); | 1337 mockImpl->calculateRenderSurfaceLayerList(renderSurfaceLayerList); |
1336 | 1338 |
1337 // Both layers should be drawing into the root render surface. | 1339 // Both layers should be drawing into the root render surface. |
1338 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 1340 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
1339 ASSERT_EQ(root->renderSurface(), renderSurfaceLayerList[0]->renderSurfac
e()); | 1341 ASSERT_EQ(root->renderSurface(), renderSurfaceLayerList[0]->renderSurfac
e()); |
1340 ASSERT_EQ(2u, root->renderSurface()->layerList().size()); | 1342 ASSERT_EQ(2u, root->renderSurface()->layerList().size()); |
1341 | 1343 |
1342 // The root render surface is the size of the viewport. | 1344 // The root render surface is the size of the viewport. |
1343 EXPECT_RECT_EQ(IntRect(0, 0, 60, 60), root->renderSurface()->contentRect
()); | 1345 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), root->renderSurface()->contentRe
ct()); |
1344 | 1346 |
1345 // The content bounds of the child should be scaled. | 1347 // The content bounds of the child should be scaled. |
1346 IntSize childBoundsScaled = child->bounds(); | 1348 gfx::Size childBoundsScaled = child->bounds(); |
1347 childBoundsScaled.scale(1.5); | 1349 childBoundsScaled = gfx::ToRoundedSize(childBoundsScaled.Scale(1.5)); |
1348 EXPECT_EQ(childBoundsScaled, child->contentBounds()); | 1350 EXPECT_EQ(childBoundsScaled, child->contentBounds()); |
1349 | 1351 |
1350 WebTransformationMatrix scaleTransform; | 1352 WebTransformationMatrix scaleTransform; |
1351 scaleTransform.scale(impl->deviceScaleFactor()); | 1353 scaleTransform.scale(impl->deviceScaleFactor()); |
1352 | 1354 |
1353 // The root layer is scaled by 2x. | 1355 // The root layer is scaled by 2x. |
1354 WebTransformationMatrix rootScreenSpaceTransform = scaleTransform; | 1356 WebTransformationMatrix rootScreenSpaceTransform = scaleTransform; |
1355 WebTransformationMatrix rootDrawTransform = scaleTransform; | 1357 WebTransformationMatrix rootDrawTransform = scaleTransform; |
1356 | 1358 |
1357 EXPECT_EQ(rootDrawTransform, root->drawTransform()); | 1359 EXPECT_EQ(rootDrawTransform, root->drawTransform()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 LayerTreeHostTestAtomicCommit() | 1394 LayerTreeHostTestAtomicCommit() |
1393 : m_layer(ContentLayerWithUpdateTracking::create(&m_client)) | 1395 : m_layer(ContentLayerWithUpdateTracking::create(&m_client)) |
1394 { | 1396 { |
1395 // Make sure partial texture updates are turned off. | 1397 // Make sure partial texture updates are turned off. |
1396 m_settings.maxPartialTextureUpdates = 0; | 1398 m_settings.maxPartialTextureUpdates = 0; |
1397 } | 1399 } |
1398 | 1400 |
1399 virtual void beginTest() OVERRIDE | 1401 virtual void beginTest() OVERRIDE |
1400 { | 1402 { |
1401 m_layerTreeHost->setRootLayer(m_layer); | 1403 m_layerTreeHost->setRootLayer(m_layer); |
1402 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 1404 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
1403 | 1405 |
1404 postSetNeedsCommitToMainThread(); | 1406 postSetNeedsCommitToMainThread(); |
1405 postSetNeedsRedrawToMainThread(); | 1407 postSetNeedsRedrawToMainThread(); |
1406 } | 1408 } |
1407 | 1409 |
1408 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1410 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1409 { | 1411 { |
1410 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); | 1412 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); |
1411 | 1413 |
1412 switch (impl->sourceFrameNumber()) { | 1414 switch (impl->sourceFrameNumber()) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 private: | 1468 private: |
1467 MockContentLayerClient m_client; | 1469 MockContentLayerClient m_client; |
1468 scoped_refptr<ContentLayerWithUpdateTracking> m_layer; | 1470 scoped_refptr<ContentLayerWithUpdateTracking> m_layer; |
1469 }; | 1471 }; |
1470 | 1472 |
1471 TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread) | 1473 TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread) |
1472 { | 1474 { |
1473 runTest(true); | 1475 runTest(true); |
1474 } | 1476 } |
1475 | 1477 |
1476 static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const WebT
ransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& posi
tion, const IntSize& bounds, bool opaque) | 1478 static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const WebT
ransformationMatrix& transform, const gfx::PointF& anchor, const gfx::PointF& po
sition, const gfx::Size& bounds, bool opaque) |
1477 { | 1479 { |
1478 layer->removeAllChildren(); | 1480 layer->removeAllChildren(); |
1479 if (parent) | 1481 if (parent) |
1480 parent->addChild(layer); | 1482 parent->addChild(layer); |
1481 layer->setTransform(transform); | 1483 layer->setTransform(transform); |
1482 layer->setAnchorPoint(anchor); | 1484 layer->setAnchorPoint(anchor); |
1483 layer->setPosition(position); | 1485 layer->setPosition(position); |
1484 layer->setBounds(bounds); | 1486 layer->setBounds(bounds); |
1485 layer->setContentsOpaque(opaque); | 1487 layer->setContentsOpaque(opaque); |
1486 } | 1488 } |
1487 | 1489 |
1488 class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest
{ | 1490 class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest
{ |
1489 public: | 1491 public: |
1490 LayerTreeHostTestAtomicCommitWithPartialUpdate() | 1492 LayerTreeHostTestAtomicCommitWithPartialUpdate() |
1491 : m_parent(ContentLayerWithUpdateTracking::create(&m_client)) | 1493 : m_parent(ContentLayerWithUpdateTracking::create(&m_client)) |
1492 , m_child(ContentLayerWithUpdateTracking::create(&m_client)) | 1494 , m_child(ContentLayerWithUpdateTracking::create(&m_client)) |
1493 , m_numCommits(0) | 1495 , m_numCommits(0) |
1494 { | 1496 { |
1495 // Allow one partial texture update. | 1497 // Allow one partial texture update. |
1496 m_settings.maxPartialTextureUpdates = 1; | 1498 m_settings.maxPartialTextureUpdates = 1; |
1497 } | 1499 } |
1498 | 1500 |
1499 virtual void beginTest() OVERRIDE | 1501 virtual void beginTest() OVERRIDE |
1500 { | 1502 { |
1501 m_layerTreeHost->setRootLayer(m_parent); | 1503 m_layerTreeHost->setRootLayer(m_parent); |
1502 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20)); | 1504 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); |
1503 | 1505 |
1504 WebTransformationMatrix identityMatrix; | 1506 WebTransformationMatrix identityMatrix; |
1505 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, FloatPoi
nt(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); | 1507 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi
ntF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); |
1506 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr
ix, FloatPoint(0, 0), FloatPoint(0, 10), IntSize(10, 10), false); | 1508 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); |
1507 | 1509 |
1508 postSetNeedsCommitToMainThread(); | 1510 postSetNeedsCommitToMainThread(); |
1509 postSetNeedsRedrawToMainThread(); | 1511 postSetNeedsRedrawToMainThread(); |
1510 } | 1512 } |
1511 | 1513 |
1512 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1514 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1513 { | 1515 { |
1514 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); | 1516 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); |
1515 | 1517 |
1516 switch (impl->sourceFrameNumber()) { | 1518 switch (impl->sourceFrameNumber()) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 virtual void layout() OVERRIDE | 1585 virtual void layout() OVERRIDE |
1584 { | 1586 { |
1585 switch (m_numCommits++) { | 1587 switch (m_numCommits++) { |
1586 case 0: | 1588 case 0: |
1587 case 1: | 1589 case 1: |
1588 m_parent->setNeedsDisplay(); | 1590 m_parent->setNeedsDisplay(); |
1589 m_child->setNeedsDisplay(); | 1591 m_child->setNeedsDisplay(); |
1590 break; | 1592 break; |
1591 case 2: | 1593 case 2: |
1592 // Damage part of layers. | 1594 // Damage part of layers. |
1593 m_parent->setNeedsDisplayRect(FloatRect(0, 0, 5, 5)); | 1595 m_parent->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
1594 m_child->setNeedsDisplayRect(FloatRect(0, 0, 5, 5)); | 1596 m_child->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
1595 break; | 1597 break; |
1596 case 3: | 1598 case 3: |
1597 m_child->setNeedsDisplay(); | 1599 m_child->setNeedsDisplay(); |
1598 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 1600 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10
)); |
1599 break; | 1601 break; |
1600 case 4: | 1602 case 4: |
1601 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20)); | 1603 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20
)); |
1602 break; | 1604 break; |
1603 default: | 1605 default: |
1604 NOTREACHED(); | 1606 NOTREACHED(); |
1605 break; | 1607 break; |
1606 } | 1608 } |
1607 } | 1609 } |
1608 | 1610 |
1609 virtual void afterTest() OVERRIDE | 1611 virtual void afterTest() OVERRIDE |
1610 { | 1612 { |
1611 } | 1613 } |
(...skipping 26 matching lines...) Expand all Loading... |
1638 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; } | 1640 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; } |
1639 void clearOccludedScreenSpace() { m_occludedScreenSpace = Region(); } | 1641 void clearOccludedScreenSpace() { m_occludedScreenSpace = Region(); } |
1640 | 1642 |
1641 private: | 1643 private: |
1642 TestLayer() : Layer() { } | 1644 TestLayer() : Layer() { } |
1643 virtual ~TestLayer() { } | 1645 virtual ~TestLayer() { } |
1644 | 1646 |
1645 Region m_occludedScreenSpace; | 1647 Region m_occludedScreenSpace; |
1646 }; | 1648 }; |
1647 | 1649 |
1648 static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, co
nst WebTransformationMatrix& transform, const FloatPoint& anchor, const FloatPoi
nt& position, const IntSize& bounds, bool opaque) | 1650 static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, co
nst WebTransformationMatrix& transform, const gfx::PointF& anchor, const gfx::Po
intF& position, const gfx::Size& bounds, bool opaque) |
1649 { | 1651 { |
1650 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou
nds, opaque); | 1652 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou
nds, opaque); |
1651 layer->clearOccludedScreenSpace(); | 1653 layer->clearOccludedScreenSpace(); |
1652 } | 1654 } |
1653 | 1655 |
1654 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest { | 1656 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest { |
1655 public: | 1657 public: |
1656 LayerTreeHostTestLayerOcclusion() { } | 1658 LayerTreeHostTestLayerOcclusion() { } |
1657 | 1659 |
1658 virtual void beginTest() OVERRIDE | 1660 virtual void beginTest() OVERRIDE |
1659 { | 1661 { |
1660 scoped_refptr<TestLayer> rootLayer = TestLayer::create(); | 1662 scoped_refptr<TestLayer> rootLayer = TestLayer::create(); |
1661 scoped_refptr<TestLayer> child = TestLayer::create(); | 1663 scoped_refptr<TestLayer> child = TestLayer::create(); |
1662 scoped_refptr<TestLayer> child2 = TestLayer::create(); | 1664 scoped_refptr<TestLayer> child2 = TestLayer::create(); |
1663 scoped_refptr<TestLayer> grandChild = TestLayer::create(); | 1665 scoped_refptr<TestLayer> grandChild = TestLayer::create(); |
1664 scoped_refptr<TestLayer> mask = TestLayer::create(); | 1666 scoped_refptr<TestLayer> mask = TestLayer::create(); |
1665 | 1667 |
1666 WebTransformationMatrix identityMatrix; | 1668 WebTransformationMatrix identityMatrix; |
1667 WebTransformationMatrix childTransform; | 1669 WebTransformationMatrix childTransform; |
1668 childTransform.translate(250, 250); | 1670 childTransform.translate(250, 250); |
1669 childTransform.rotate(90); | 1671 childTransform.rotate(90); |
1670 childTransform.translate(-250, -250); | 1672 childTransform.translate(-250, -250); |
1671 | 1673 |
1672 child->setMasksToBounds(true); | 1674 child->setMasksToBounds(true); |
1673 | 1675 |
1674 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS
urface for a nice visual of these layers and how they end up | 1676 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS
urface for a nice visual of these layers and how they end up |
1675 // positioned on the screen. | 1677 // positioned on the screen. |
1676 | 1678 |
1677 // The child layer is rotated and the grandChild is opaque, but clipped
to the child and rootLayer | 1679 // The child layer is rotated and the grandChild is opaque, but clipped
to the child and rootLayer |
1678 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1680 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1679 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); | 1681 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), false); |
1680 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1682 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1681 | 1683 |
1682 m_layerTreeHost->setRootLayer(rootLayer); | 1684 m_layerTreeHost->setRootLayer(rootLayer); |
1683 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1685 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1684 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 1686 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
1685 ResourceUpdateQueue queue; | 1687 ResourceUpdateQueue queue; |
1686 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1688 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1687 m_layerTreeHost->commitComplete(); | 1689 m_layerTreeHost->commitComplete(); |
1688 | 1690 |
1689 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds()); | 1691 EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds()); |
1690 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); | 1692 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); |
1691 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b
ounds()); | 1693 EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace()
.bounds()); |
1692 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); | 1694 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); |
1693 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), rootLayer->occludedScreenSpace
().bounds()); | 1695 EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), rootLayer->occludedScreenSpa
ce().bounds()); |
1694 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); | 1696 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); |
1695 | 1697 |
1696 // If the child layer is opaque, then it adds to the occlusion seen by t
he rootLayer. | 1698 // If the child layer is opaque, then it adds to the occlusion seen by t
he rootLayer. |
1697 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPo
int(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1699 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1698 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor
m, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); | 1700 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor
m, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
1699 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1701 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1700 | 1702 |
1701 m_layerTreeHost->setRootLayer(rootLayer); | 1703 m_layerTreeHost->setRootLayer(rootLayer); |
1702 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1704 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1703 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1705 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1704 m_layerTreeHost->commitComplete(); | 1706 m_layerTreeHost->commitComplete(); |
1705 | 1707 |
1706 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds()); | 1708 EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds()); |
1707 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); | 1709 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); |
1708 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b
ounds()); | 1710 EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace()
.bounds()); |
1709 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); | 1711 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); |
1710 EXPECT_RECT_EQ(IntRect(30, 30, 170, 170), rootLayer->occludedScreenSpace
().bounds()); | 1712 EXPECT_RECT_EQ(gfx::Rect(30, 30, 170, 170), rootLayer->occludedScreenSpa
ce().bounds()); |
1711 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); | 1713 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); |
1712 | 1714 |
1713 // Add a second child to the root layer and the regions should merge | 1715 // Add a second child to the root layer and the regions should merge |
1714 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1716 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1715 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(70, 20), IntSize(500, 500), true); | 1717 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(70, 20), gfx::Size(500, 500), true); |
1716 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); | 1718 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
1717 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1719 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1718 | 1720 |
1719 m_layerTreeHost->setRootLayer(rootLayer); | 1721 m_layerTreeHost->setRootLayer(rootLayer); |
1720 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1722 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1721 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1723 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1722 m_layerTreeHost->commitComplete(); | 1724 m_layerTreeHost->commitComplete(); |
1723 | 1725 |
1724 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds()); | 1726 EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds()); |
1725 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); | 1727 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); |
1726 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b
ounds()); | 1728 EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace()
.bounds()); |
1727 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); | 1729 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); |
1728 EXPECT_RECT_EQ(IntRect(30, 30, 170, 170), child2->occludedScreenSpace().
bounds()); | 1730 EXPECT_RECT_EQ(gfx::Rect(30, 30, 170, 170), child2->occludedScreenSpace(
).bounds()); |
1729 EXPECT_EQ(1u, child2->occludedScreenSpace().rects().size()); | 1731 EXPECT_EQ(1u, child2->occludedScreenSpace().rects().size()); |
1730 EXPECT_RECT_EQ(IntRect(30, 20, 170, 180), rootLayer->occludedScreenSpace
().bounds()); | 1732 EXPECT_RECT_EQ(gfx::Rect(30, 20, 170, 180), rootLayer->occludedScreenSpa
ce().bounds()); |
1731 EXPECT_EQ(2u, rootLayer->occludedScreenSpace().rects().size()); | 1733 EXPECT_EQ(2u, rootLayer->occludedScreenSpace().rects().size()); |
1732 | 1734 |
1733 // Move the second child to be sure. | 1735 // Move the second child to be sure. |
1734 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1736 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1735 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); | 1737 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); |
1736 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); | 1738 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
1737 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1739 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1738 | 1740 |
1739 m_layerTreeHost->setRootLayer(rootLayer); | 1741 m_layerTreeHost->setRootLayer(rootLayer); |
1740 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1742 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1741 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1743 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1742 m_layerTreeHost->commitComplete(); | 1744 m_layerTreeHost->commitComplete(); |
1743 | 1745 |
1744 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds()); | 1746 EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds()); |
1745 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); | 1747 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); |
1746 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b
ounds()); | 1748 EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace()
.bounds()); |
1747 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); | 1749 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); |
1748 EXPECT_RECT_EQ(IntRect(30, 30, 170, 170), child2->occludedScreenSpace().
bounds()); | 1750 EXPECT_RECT_EQ(gfx::Rect(30, 30, 170, 170), child2->occludedScreenSpace(
).bounds()); |
1749 EXPECT_EQ(1u, child2->occludedScreenSpace().rects().size()); | 1751 EXPECT_EQ(1u, child2->occludedScreenSpace().rects().size()); |
1750 EXPECT_RECT_EQ(IntRect(10, 30, 190, 170), rootLayer->occludedScreenSpace
().bounds()); | 1752 EXPECT_RECT_EQ(gfx::Rect(10, 30, 190, 170), rootLayer->occludedScreenSpa
ce().bounds()); |
1751 EXPECT_EQ(2u, rootLayer->occludedScreenSpace().rects().size()); | 1753 EXPECT_EQ(2u, rootLayer->occludedScreenSpace().rects().size()); |
1752 | 1754 |
1753 // If the child layer has a mask on it, then it shouldn't contribute to
occlusion on stuff below it | 1755 // If the child layer has a mask on it, then it shouldn't contribute to
occlusion on stuff below it |
1754 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPo
int(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1756 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1755 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); | 1757 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); |
1756 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor
m, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); | 1758 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor
m, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
1757 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1759 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1758 | 1760 |
1759 child->setMaskLayer(mask.get()); | 1761 child->setMaskLayer(mask.get()); |
1760 | 1762 |
1761 m_layerTreeHost->setRootLayer(rootLayer); | 1763 m_layerTreeHost->setRootLayer(rootLayer); |
1762 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1764 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1763 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1765 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1764 m_layerTreeHost->commitComplete(); | 1766 m_layerTreeHost->commitComplete(); |
1765 | 1767 |
1766 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds()); | 1768 EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds()); |
1767 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); | 1769 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); |
1768 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b
ounds()); | 1770 EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace()
.bounds()); |
1769 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); | 1771 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); |
1770 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds()); | 1772 EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds()); |
1771 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); | 1773 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); |
1772 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace
().bounds()); | 1774 EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpa
ce().bounds()); |
1773 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); | 1775 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); |
1774 | 1776 |
1775 // If the child layer with a mask is below child2, then child2 should co
ntribute to occlusion on everything, and child shouldn't contribute to the rootL
ayer | 1777 // If the child layer with a mask is below child2, then child2 should co
ntribute to occlusion on everything, and child shouldn't contribute to the rootL
ayer |
1776 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPo
int(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1778 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1777 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor
m, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); | 1779 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor
m, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
1778 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1780 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1779 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); | 1781 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); |
1780 | 1782 |
1781 child->setMaskLayer(mask.get()); | 1783 child->setMaskLayer(mask.get()); |
1782 | 1784 |
1783 m_layerTreeHost->setRootLayer(rootLayer); | 1785 m_layerTreeHost->setRootLayer(rootLayer); |
1784 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1786 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1785 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1787 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1786 m_layerTreeHost->commitComplete(); | 1788 m_layerTreeHost->commitComplete(); |
1787 | 1789 |
1788 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds()); | 1790 EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds()); |
1789 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); | 1791 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); |
1790 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), grandChild->occludedScreenSpac
e().bounds()); | 1792 EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), grandChild->occludedScreenSp
ace().bounds()); |
1791 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); | 1793 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); |
1792 EXPECT_RECT_EQ(IntRect(10, 40, 190, 160), child->occludedScreenSpace().b
ounds()); | 1794 EXPECT_RECT_EQ(gfx::Rect(10, 40, 190, 160), child->occludedScreenSpace()
.bounds()); |
1793 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); | 1795 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); |
1794 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace
().bounds()); | 1796 EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpa
ce().bounds()); |
1795 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); | 1797 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); |
1796 | 1798 |
1797 // If the child layer has a non-opaque drawOpacity, then it shouldn't co
ntribute to occlusion on stuff below it | 1799 // If the child layer has a non-opaque drawOpacity, then it shouldn't co
ntribute to occlusion on stuff below it |
1798 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1800 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1799 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); | 1801 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); |
1800 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); | 1802 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
1801 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1803 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1802 | 1804 |
1803 child->setMaskLayer(0); | 1805 child->setMaskLayer(0); |
1804 child->setOpacity(0.5); | 1806 child->setOpacity(0.5); |
1805 | 1807 |
1806 m_layerTreeHost->setRootLayer(rootLayer); | 1808 m_layerTreeHost->setRootLayer(rootLayer); |
1807 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1809 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1808 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1810 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1809 m_layerTreeHost->commitComplete(); | 1811 m_layerTreeHost->commitComplete(); |
1810 | 1812 |
1811 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds()); | 1813 EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds()); |
1812 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); | 1814 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); |
1813 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b
ounds()); | 1815 EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace()
.bounds()); |
1814 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); | 1816 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); |
1815 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds()); | 1817 EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds()); |
1816 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); | 1818 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); |
1817 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace
().bounds()); | 1819 EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpa
ce().bounds()); |
1818 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); | 1820 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); |
1819 | 1821 |
1820 // If the child layer with non-opaque drawOpacity is below child2, then
child2 should contribute to occlusion on everything, and child shouldn't contrib
ute to the rootLayer | 1822 // If the child layer with non-opaque drawOpacity is below child2, then
child2 should contribute to occlusion on everything, and child shouldn't contrib
ute to the rootLayer |
1821 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1823 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1822 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); | 1824 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
1823 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1825 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1824 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); | 1826 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); |
1825 | 1827 |
1826 child->setMaskLayer(0); | 1828 child->setMaskLayer(0); |
1827 child->setOpacity(0.5); | 1829 child->setOpacity(0.5); |
1828 | 1830 |
1829 m_layerTreeHost->setRootLayer(rootLayer); | 1831 m_layerTreeHost->setRootLayer(rootLayer); |
1830 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1832 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1831 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1833 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1832 m_layerTreeHost->commitComplete(); | 1834 m_layerTreeHost->commitComplete(); |
1833 | 1835 |
1834 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds()); | 1836 EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds()); |
1835 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); | 1837 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); |
1836 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), grandChild->occludedScreenSpac
e().bounds()); | 1838 EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), grandChild->occludedScreenSp
ace().bounds()); |
1837 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); | 1839 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); |
1838 EXPECT_RECT_EQ(IntRect(10, 40, 190, 160), child->occludedScreenSpace().b
ounds()); | 1840 EXPECT_RECT_EQ(gfx::Rect(10, 40, 190, 160), child->occludedScreenSpace()
.bounds()); |
1839 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); | 1841 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); |
1840 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace
().bounds()); | 1842 EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpa
ce().bounds()); |
1841 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); | 1843 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); |
1842 | 1844 |
1843 // Kill the layerTreeHost immediately. | 1845 // Kill the layerTreeHost immediately. |
1844 m_layerTreeHost->setRootLayer(0); | 1846 m_layerTreeHost->setRootLayer(0); |
1845 m_layerTreeHost.reset(); | 1847 m_layerTreeHost.reset(); |
1846 | 1848 |
1847 endTest(); | 1849 endTest(); |
1848 } | 1850 } |
1849 | 1851 |
1850 virtual void afterTest() OVERRIDE | 1852 virtual void afterTest() OVERRIDE |
(...skipping 18 matching lines...) Expand all Loading... |
1869 WebTransformationMatrix identityMatrix; | 1871 WebTransformationMatrix identityMatrix; |
1870 WebTransformationMatrix childTransform; | 1872 WebTransformationMatrix childTransform; |
1871 childTransform.translate(250, 250); | 1873 childTransform.translate(250, 250); |
1872 childTransform.rotate(90); | 1874 childTransform.rotate(90); |
1873 childTransform.translate(-250, -250); | 1875 childTransform.translate(-250, -250); |
1874 | 1876 |
1875 child->setMasksToBounds(true); | 1877 child->setMasksToBounds(true); |
1876 | 1878 |
1877 // If the child layer has a filter that changes alpha values, and is bel
ow child2, then child2 should contribute to occlusion on everything, | 1879 // If the child layer has a filter that changes alpha values, and is bel
ow child2, then child2 should contribute to occlusion on everything, |
1878 // and child shouldn't contribute to the rootLayer | 1880 // and child shouldn't contribute to the rootLayer |
1879 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1881 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1880 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); | 1882 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
1881 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1883 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1882 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); | 1884 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); |
1883 | 1885 |
1884 { | 1886 { |
1885 WebFilterOperations filters; | 1887 WebFilterOperations filters; |
1886 filters.append(WebFilterOperation::createOpacityFilter(0.5)); | 1888 filters.append(WebFilterOperation::createOpacityFilter(0.5)); |
1887 child->setFilters(filters); | 1889 child->setFilters(filters); |
1888 } | 1890 } |
1889 | 1891 |
1890 m_layerTreeHost->setRootLayer(rootLayer); | 1892 m_layerTreeHost->setRootLayer(rootLayer); |
1891 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1893 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1892 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 1894 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
1893 ResourceUpdateQueue queue; | 1895 ResourceUpdateQueue queue; |
1894 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1896 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1895 m_layerTreeHost->commitComplete(); | 1897 m_layerTreeHost->commitComplete(); |
1896 | 1898 |
1897 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds()); | 1899 EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds()); |
1898 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); | 1900 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); |
1899 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), grandChild->occludedScreenSpac
e().bounds()); | 1901 EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), grandChild->occludedScreenSp
ace().bounds()); |
1900 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); | 1902 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); |
1901 EXPECT_RECT_EQ(IntRect(10, 40, 190, 160), child->occludedScreenSpace().b
ounds()); | 1903 EXPECT_RECT_EQ(gfx::Rect(10, 40, 190, 160), child->occludedScreenSpace()
.bounds()); |
1902 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); | 1904 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); |
1903 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace
().bounds()); | 1905 EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpa
ce().bounds()); |
1904 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); | 1906 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); |
1905 | 1907 |
1906 // If the child layer has a filter that moves pixels/changes alpha, and
is below child2, then child should not inherit occlusion from outside its subtre
e, | 1908 // If the child layer has a filter that moves pixels/changes alpha, and
is below child2, then child should not inherit occlusion from outside its subtre
e, |
1907 // and should not contribute to the rootLayer | 1909 // and should not contribute to the rootLayer |
1908 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1910 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1909 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); | 1911 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
1910 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); | 1912 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
1911 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); | 1913 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); |
1912 | 1914 |
1913 { | 1915 { |
1914 WebFilterOperations filters; | 1916 WebFilterOperations filters; |
1915 filters.append(WebFilterOperation::createBlurFilter(10)); | 1917 filters.append(WebFilterOperation::createBlurFilter(10)); |
1916 child->setFilters(filters); | 1918 child->setFilters(filters); |
1917 } | 1919 } |
1918 | 1920 |
1919 m_layerTreeHost->setRootLayer(rootLayer); | 1921 m_layerTreeHost->setRootLayer(rootLayer); |
1920 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1922 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
1921 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1923 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1922 m_layerTreeHost->commitComplete(); | 1924 m_layerTreeHost->commitComplete(); |
1923 | 1925 |
1924 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds()); | 1926 EXPECT_RECT_EQ(cc::IntRect(), child2->occludedScreenSpace().bounds()); |
1925 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); | 1927 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); |
1926 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds()); | 1928 EXPECT_RECT_EQ(cc::IntRect(), grandChild->occludedScreenSpace().bounds()
); |
1927 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); | 1929 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); |
1928 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b
ounds()); | 1930 EXPECT_RECT_EQ(cc::IntRect(30, 40, 170, 160), child->occludedScreenSpace
().bounds()); |
1929 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); | 1931 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); |
1930 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace
().bounds()); | 1932 EXPECT_RECT_EQ(cc::IntRect(10, 70, 190, 130), rootLayer->occludedScreenS
pace().bounds()); |
1931 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); | 1933 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); |
1932 | 1934 |
1933 // Kill the layerTreeHost immediately. | 1935 // Kill the layerTreeHost immediately. |
1934 m_layerTreeHost->setRootLayer(0); | 1936 m_layerTreeHost->setRootLayer(0); |
1935 m_layerTreeHost.reset(); | 1937 m_layerTreeHost.reset(); |
1936 | 1938 |
1937 LayerTreeHost::setNeedsFilterContext(false); | 1939 LayerTreeHost::setNeedsFilterContext(false); |
1938 endTest(); | 1940 endTest(); |
1939 } | 1941 } |
1940 | 1942 |
(...skipping 14 matching lines...) Expand all Loading... |
1955 Region occluded; | 1957 Region occluded; |
1956 const WebTransformationMatrix identityMatrix; | 1958 const WebTransformationMatrix identityMatrix; |
1957 std::vector<scoped_refptr<TestLayer> > layers; | 1959 std::vector<scoped_refptr<TestLayer> > layers; |
1958 std::vector<scoped_refptr<TestLayer> > children; | 1960 std::vector<scoped_refptr<TestLayer> > children; |
1959 int numSurfaces = 20; | 1961 int numSurfaces = 20; |
1960 scoped_refptr<TestLayer> replica = TestLayer::create(); | 1962 scoped_refptr<TestLayer> replica = TestLayer::create(); |
1961 | 1963 |
1962 for (int i = 0; i < numSurfaces; ++i) { | 1964 for (int i = 0; i < numSurfaces; ++i) { |
1963 layers.push_back(TestLayer::create()); | 1965 layers.push_back(TestLayer::create()); |
1964 if (!i) { | 1966 if (!i) { |
1965 setTestLayerPropertiesForTesting(layers.back().get(), 0, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); | 1967 setTestLayerPropertiesForTesting(layers.back().get(), 0, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
1966 layers.back()->createRenderSurface(); | 1968 layers.back()->createRenderSurface(); |
1967 } else { | 1969 } else { |
1968 setTestLayerPropertiesForTesting(layers.back().get(), layers[lay
ers.size()-2].get(), identityMatrix, FloatPoint(0, 0), FloatPoint(1, 1), IntSize
(200-i, 200-i), true); | 1970 setTestLayerPropertiesForTesting(layers.back().get(), layers[lay
ers.size()-2].get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(1, 1), gfx::
Size(200-i, 200-i), true); |
1969 layers.back()->setMasksToBounds(true); | 1971 layers.back()->setMasksToBounds(true); |
1970 layers.back()->setReplicaLayer(replica.get()); // Make it have a
RenderSurfaceImpl | 1972 layers.back()->setReplicaLayer(replica.get()); // Make it have a
RenderSurfaceImpl |
1971 } | 1973 } |
1972 } | 1974 } |
1973 | 1975 |
1974 for (int i = 1; i < numSurfaces; ++i) { | 1976 for (int i = 1; i < numSurfaces; ++i) { |
1975 children.push_back(TestLayer::create()); | 1977 children.push_back(TestLayer::create()); |
1976 setTestLayerPropertiesForTesting(children.back().get(), layers[i].ge
t(), identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), fals
e); | 1978 setTestLayerPropertiesForTesting(children.back().get(), layers[i].ge
t(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500),
false); |
1977 } | 1979 } |
1978 | 1980 |
1979 m_layerTreeHost->setRootLayer(layers[0].get()); | 1981 m_layerTreeHost->setRootLayer(layers[0].get()); |
1980 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds(
)); | 1982 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds(
)); |
1981 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 1983 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
1982 ResourceUpdateQueue queue; | 1984 ResourceUpdateQueue queue; |
1983 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1985 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1984 m_layerTreeHost->commitComplete(); | 1986 m_layerTreeHost->commitComplete(); |
1985 | 1987 |
1986 for (int i = 0; i < numSurfaces-1; ++i) { | 1988 for (int i = 0; i < numSurfaces-1; ++i) { |
1987 IntRect expectedOcclusion(i+1, i+1, 200-i-1, 200-i-1); | 1989 cc::IntRect expectedOcclusion(i+1, i+1, 200-i-1, 200-i-1); |
1988 | 1990 |
1989 EXPECT_RECT_EQ(expectedOcclusion, layers[i]->occludedScreenSpace().b
ounds()); | 1991 EXPECT_RECT_EQ(expectedOcclusion, layers[i]->occludedScreenSpace().b
ounds()); |
1990 EXPECT_EQ(1u, layers[i]->occludedScreenSpace().rects().size()); | 1992 EXPECT_EQ(1u, layers[i]->occludedScreenSpace().rects().size()); |
1991 } | 1993 } |
1992 | 1994 |
1993 // Kill the layerTreeHost immediately. | 1995 // Kill the layerTreeHost immediately. |
1994 m_layerTreeHost->setRootLayer(0); | 1996 m_layerTreeHost->setRootLayer(0); |
1995 m_layerTreeHost.reset(); | 1997 m_layerTreeHost.reset(); |
1996 | 1998 |
1997 endTest(); | 1999 endTest(); |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3067 , m_numDrawLayers(0) | 3069 , m_numDrawLayers(0) |
3068 { | 3070 { |
3069 } | 3071 } |
3070 | 3072 |
3071 virtual void beginTest() OVERRIDE | 3073 virtual void beginTest() OVERRIDE |
3072 { | 3074 { |
3073 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 3075 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); |
3074 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); | 3076 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); |
3075 | 3077 |
3076 m_contentLayer = ContentLayer::create(&m_mockDelegate); | 3078 m_contentLayer = ContentLayer::create(&m_mockDelegate); |
3077 m_contentLayer->setBounds(IntSize(10, 10)); | 3079 m_contentLayer->setBounds(gfx::Size(10, 10)); |
3078 m_contentLayer->setPosition(FloatPoint(0, 0)); | 3080 m_contentLayer->setPosition(gfx::PointF(0, 0)); |
3079 m_contentLayer->setAnchorPoint(FloatPoint(0, 0)); | 3081 m_contentLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3080 m_contentLayer->setIsDrawable(true); | 3082 m_contentLayer->setIsDrawable(true); |
3081 m_layerTreeHost->rootLayer()->addChild(m_contentLayer); | 3083 m_layerTreeHost->rootLayer()->addChild(m_contentLayer); |
3082 | 3084 |
3083 postSetNeedsCommitToMainThread(); | 3085 postSetNeedsCommitToMainThread(); |
3084 } | 3086 } |
3085 | 3087 |
3086 virtual void didCommit() OVERRIDE | 3088 virtual void didCommit() OVERRIDE |
3087 { | 3089 { |
3088 m_contentLayer->setNeedsDisplay(); | 3090 m_contentLayer->setNeedsDisplay(); |
3089 } | 3091 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 LayerTreeHostTestAdjustPointForZoom() | 3129 LayerTreeHostTestAdjustPointForZoom() |
3128 { | 3130 { |
3129 } | 3131 } |
3130 | 3132 |
3131 virtual void beginTest() OVERRIDE | 3133 virtual void beginTest() OVERRIDE |
3132 { | 3134 { |
3133 WebTransformationMatrix m; | 3135 WebTransformationMatrix m; |
3134 m.translate(250, 360); | 3136 m.translate(250, 360); |
3135 m.scale(2); | 3137 m.scale(2); |
3136 | 3138 |
3137 IntPoint point(400, 550); | 3139 gfx::Point point(400, 550); |
3138 IntPoint transformedPoint; | 3140 gfx::Point transformedPoint; |
3139 | 3141 |
3140 // Unit transform, no change expected. | 3142 // Unit transform, no change expected. |
3141 m_layerTreeHost->setImplTransform(WebTransformationMatrix()); | 3143 m_layerTreeHost->setImplTransform(WebTransformationMatrix()); |
3142 transformedPoint = roundedIntPoint(m_layerTreeHost->adjustEventPointForP
inchZoom(point)); | 3144 transformedPoint = gfx::ToRoundedPoint(m_layerTreeHost->adjustEventPoint
ForPinchZoom(point)); |
3143 EXPECT_EQ(point.x(), transformedPoint.x()); | 3145 EXPECT_EQ(point.x(), transformedPoint.x()); |
3144 EXPECT_EQ(point.y(), transformedPoint.y()); | 3146 EXPECT_EQ(point.y(), transformedPoint.y()); |
3145 | 3147 |
3146 m_layerTreeHost->setImplTransform(m); | 3148 m_layerTreeHost->setImplTransform(m); |
3147 | 3149 |
3148 // Apply m^(-1): 138 = 400/2 - 250/4; 185 = 550/2 - 360/4. | 3150 // Apply m^(-1): 138 = 400/2 - 250/4; 185 = 550/2 - 360/4. |
3149 transformedPoint = roundedIntPoint(m_layerTreeHost->adjustEventPointForP
inchZoom(point)); | 3151 transformedPoint = gfx::ToRoundedPoint(m_layerTreeHost->adjustEventPoint
ForPinchZoom(point)); |
3150 EXPECT_EQ(138, transformedPoint.x()); | 3152 EXPECT_EQ(138, transformedPoint.x()); |
3151 EXPECT_EQ(185, transformedPoint.y()); | 3153 EXPECT_EQ(185, transformedPoint.y()); |
3152 endTest(); | 3154 endTest(); |
3153 } | 3155 } |
3154 | 3156 |
3155 virtual void afterTest() OVERRIDE | 3157 virtual void afterTest() OVERRIDE |
3156 { | 3158 { |
3157 } | 3159 } |
3158 }; | 3160 }; |
3159 | 3161 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3264 int m_numCommitsDeferred; | 3266 int m_numCommitsDeferred; |
3265 int m_numCompleteCommits; | 3267 int m_numCompleteCommits; |
3266 }; | 3268 }; |
3267 | 3269 |
3268 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) | 3270 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) |
3269 { | 3271 { |
3270 runTest(true); | 3272 runTest(true); |
3271 } | 3273 } |
3272 | 3274 |
3273 } // namespace | 3275 } // namespace |
OLD | NEW |