| 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 "cc/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/synchronization/lock.h" | 7 #include "base/synchronization/lock.h" |
| 8 #include "cc/content_layer.h" | 8 #include "cc/content_layer.h" |
| 9 #include "cc/content_layer_client.h" | 9 #include "cc/content_layer_client.h" |
| 10 #include "cc/layer_tree_host_impl.h" | 10 #include "cc/layer_tree_host_impl.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 virtual void beginTest() OVERRIDE | 157 virtual void beginTest() OVERRIDE |
| 158 { | 158 { |
| 159 postSetNeedsCommitToMainThread(); | 159 postSetNeedsCommitToMainThread(); |
| 160 postSetNeedsCommitToMainThread(); | 160 postSetNeedsCommitToMainThread(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 163 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 164 { | 164 { |
| 165 m_numDraws++; | 165 m_numDraws++; |
| 166 if (!impl->sourceFrameNumber()) | 166 if (!impl->activeTree()->source_frame_number()) |
| 167 endTest(); | 167 endTest(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 170 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
| 171 { | 171 { |
| 172 m_numCommits++; | 172 m_numCommits++; |
| 173 } | 173 } |
| 174 | 174 |
| 175 virtual void afterTest() OVERRIDE | 175 virtual void afterTest() OVERRIDE |
| 176 { | 176 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 198 { | 198 { |
| 199 } | 199 } |
| 200 | 200 |
| 201 virtual void beginTest() OVERRIDE | 201 virtual void beginTest() OVERRIDE |
| 202 { | 202 { |
| 203 postSetNeedsCommitToMainThread(); | 203 postSetNeedsCommitToMainThread(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 206 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 207 { | 207 { |
| 208 if (!impl->sourceFrameNumber()) | 208 if (impl->activeTree()->source_frame_number() == 0) |
| 209 postSetNeedsCommitToMainThread(); | 209 postSetNeedsCommitToMainThread(); |
| 210 else if (impl->sourceFrameNumber() == 1) | 210 else if (impl->activeTree()->source_frame_number() == 1) |
| 211 endTest(); | 211 endTest(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 214 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
| 215 { | 215 { |
| 216 m_numCommits++; | 216 m_numCommits++; |
| 217 } | 217 } |
| 218 | 218 |
| 219 virtual void afterTest() OVERRIDE | 219 virtual void afterTest() OVERRIDE |
| 220 { | 220 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 242 { | 242 { |
| 243 } | 243 } |
| 244 | 244 |
| 245 virtual void beginTest() OVERRIDE | 245 virtual void beginTest() OVERRIDE |
| 246 { | 246 { |
| 247 postSetNeedsCommitToMainThread(); | 247 postSetNeedsCommitToMainThread(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 250 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 251 { | 251 { |
| 252 EXPECT_EQ(0, impl->sourceFrameNumber()); | 252 EXPECT_EQ(0, impl->activeTree()->source_frame_number()); |
| 253 if (!m_numDraws) | 253 if (!m_numDraws) |
| 254 postSetNeedsRedrawToMainThread(); // Redraw again to verify that the
second redraw doesn't commit. | 254 postSetNeedsRedrawToMainThread(); // Redraw again to verify that the
second redraw doesn't commit. |
| 255 else | 255 else |
| 256 endTest(); | 256 endTest(); |
| 257 m_numDraws++; | 257 m_numDraws++; |
| 258 } | 258 } |
| 259 | 259 |
| 260 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 260 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
| 261 { | 261 { |
| 262 EXPECT_EQ(0, m_numDraws); | 262 EXPECT_EQ(0, m_numDraws); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 289 | 289 |
| 290 virtual void beginTest() OVERRIDE | 290 virtual void beginTest() OVERRIDE |
| 291 { | 291 { |
| 292 postSetNeedsCommitToMainThread(); | 292 postSetNeedsCommitToMainThread(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 295 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 296 { | 296 { |
| 297 // Only the initial draw should bring us here. | 297 // Only the initial draw should bring us here. |
| 298 EXPECT_TRUE(impl->canDraw()); | 298 EXPECT_TRUE(impl->canDraw()); |
| 299 EXPECT_EQ(0, impl->sourceFrameNumber()); | 299 EXPECT_EQ(0, impl->activeTree()->source_frame_number()); |
| 300 } | 300 } |
| 301 | 301 |
| 302 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 302 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 303 { | 303 { |
| 304 if (m_numCommits >= 1) { | 304 if (m_numCommits >= 1) { |
| 305 // After the first commit, we should not be able to draw. | 305 // After the first commit, we should not be able to draw. |
| 306 EXPECT_FALSE(impl->canDraw()); | 306 EXPECT_FALSE(impl->canDraw()); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 | 309 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 | 864 |
| 865 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 865 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 866 { | 866 { |
| 867 LayerImpl* root = impl->rootLayer(); | 867 LayerImpl* root = impl->rootLayer(); |
| 868 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); | 868 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); |
| 869 | 869 |
| 870 root->setScrollable(true); | 870 root->setScrollable(true); |
| 871 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); | 871 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); |
| 872 root->scrollBy(m_scrollAmount); | 872 root->scrollBy(m_scrollAmount); |
| 873 | 873 |
| 874 if (!impl->sourceFrameNumber()) { | 874 if (!impl->activeTree()->source_frame_number()) { |
| 875 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll); | 875 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll); |
| 876 EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount); | 876 EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount); |
| 877 postSetNeedsCommitToMainThread(); | 877 postSetNeedsCommitToMainThread(); |
| 878 } else if (impl->sourceFrameNumber() == 1) { | 878 } else if (impl->activeTree()->source_frame_number() == 1) { |
| 879 EXPECT_VECTOR_EQ(root->scrollOffset(), m_secondScroll); | 879 EXPECT_VECTOR_EQ(root->scrollOffset(), m_secondScroll); |
| 880 EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount); | 880 EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount); |
| 881 endTest(); | 881 endTest(); |
| 882 } | 882 } |
| 883 } | 883 } |
| 884 | 884 |
| 885 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVE
RRIDE | 885 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVE
RRIDE |
| 886 { | 886 { |
| 887 gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset(); | 887 gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset(); |
| 888 m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta); | 888 m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 else if (m_layerTreeHost->commitNumber() == 2) | 931 else if (m_layerTreeHost->commitNumber() == 2) |
| 932 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmo
unt + m_scrollAmount); | 932 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmo
unt + m_scrollAmount); |
| 933 } | 933 } |
| 934 | 934 |
| 935 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 935 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 936 { | 936 { |
| 937 LayerImpl* root = impl->rootLayer(); | 937 LayerImpl* root = impl->rootLayer(); |
| 938 root->setScrollable(true); | 938 root->setScrollable(true); |
| 939 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); | 939 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); |
| 940 | 940 |
| 941 if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() ==
1) { | 941 if (!impl->activeTree()->source_frame_number() && impl->sourceAnimationF
rameNumber() == 1) { |
| 942 // First draw after first commit. | 942 // First draw after first commit. |
| 943 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); | 943 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); |
| 944 root->scrollBy(m_scrollAmount); | 944 root->scrollBy(m_scrollAmount); |
| 945 EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount); | 945 EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount); |
| 946 | 946 |
| 947 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll); | 947 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll); |
| 948 postSetNeedsRedrawToMainThread(); | 948 postSetNeedsRedrawToMainThread(); |
| 949 } else if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumbe
r() == 2) { | 949 } else if (!impl->activeTree()->source_frame_number() && impl->sourceAni
mationFrameNumber() == 2) { |
| 950 // Second draw after first commit. | 950 // Second draw after first commit. |
| 951 EXPECT_EQ(root->scrollDelta(), m_scrollAmount); | 951 EXPECT_EQ(root->scrollDelta(), m_scrollAmount); |
| 952 root->scrollBy(m_scrollAmount); | 952 root->scrollBy(m_scrollAmount); |
| 953 EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount + m_scrollAmoun
t); | 953 EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount + m_scrollAmoun
t); |
| 954 | 954 |
| 955 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll); | 955 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll); |
| 956 postSetNeedsCommitToMainThread(); | 956 postSetNeedsCommitToMainThread(); |
| 957 } else if (impl->sourceFrameNumber() == 1) { | 957 } else if (impl->activeTree()->source_frame_number() == 1) { |
| 958 // Third or later draw after second commit. | 958 // Third or later draw after second commit. |
| 959 EXPECT_GE(impl->sourceAnimationFrameNumber(), 3); | 959 EXPECT_GE(impl->sourceAnimationFrameNumber(), 3); |
| 960 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); | 960 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); |
| 961 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmo
unt + m_scrollAmount); | 961 EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmo
unt + m_scrollAmount); |
| 962 endTest(); | 962 endTest(); |
| 963 } | 963 } |
| 964 } | 964 } |
| 965 | 965 |
| 966 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVE
RRIDE | 966 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVE
RRIDE |
| 967 { | 967 { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 { | 1057 { |
| 1058 gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset(); | 1058 gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset(); |
| 1059 m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta); | 1059 m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta); |
| 1060 m_layerTreeHost->setPageScaleFactorAndLimits(scale, 0.5, 2); | 1060 m_layerTreeHost->setPageScaleFactorAndLimits(scale, 0.5, 2); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1063 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1064 { | 1064 { |
| 1065 impl->processScrollDeltas(); | 1065 impl->processScrollDeltas(); |
| 1066 // We get one commit before the first draw, and the animation doesn't ha
ppen until the second draw. | 1066 // We get one commit before the first draw, and the animation doesn't ha
ppen until the second draw. |
| 1067 if (impl->sourceFrameNumber() == 1) { | 1067 if (impl->activeTree()->source_frame_number() == 1) { |
| 1068 EXPECT_EQ(1.25, impl->pageScaleFactor()); | 1068 EXPECT_EQ(1.25, impl->pageScaleFactor()); |
| 1069 endTest(); | 1069 endTest(); |
| 1070 } else | 1070 } else |
| 1071 postSetNeedsRedrawToMainThread(); | 1071 postSetNeedsRedrawToMainThread(); |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 virtual void afterTest() OVERRIDE | 1074 virtual void afterTest() OVERRIDE |
| 1075 { | 1075 { |
| 1076 } | 1076 } |
| 1077 | 1077 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 m_layerTreeHost->setRootLayer(m_rootLayer); | 1301 m_layerTreeHost->setRootLayer(m_rootLayer); |
| 1302 postSetNeedsCommitToMainThread(); | 1302 postSetNeedsCommitToMainThread(); |
| 1303 } | 1303 } |
| 1304 | 1304 |
| 1305 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1305 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1306 { | 1306 { |
| 1307 // Get access to protected methods. | 1307 // Get access to protected methods. |
| 1308 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im
pl); | 1308 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im
pl); |
| 1309 | 1309 |
| 1310 // Should only do one commit. | 1310 // Should only do one commit. |
| 1311 EXPECT_EQ(0, impl->sourceFrameNumber()); | 1311 EXPECT_EQ(0, impl->activeTree()->source_frame_number()); |
| 1312 // Device scale factor should come over to impl. | 1312 // Device scale factor should come over to impl. |
| 1313 EXPECT_NEAR(impl->deviceScaleFactor(), 1.5, 0.00001); | 1313 EXPECT_NEAR(impl->deviceScaleFactor(), 1.5, 0.00001); |
| 1314 | 1314 |
| 1315 // Both layers are on impl. | 1315 // Both layers are on impl. |
| 1316 ASSERT_EQ(1u, impl->rootLayer()->children().size()); | 1316 ASSERT_EQ(1u, impl->rootLayer()->children().size()); |
| 1317 | 1317 |
| 1318 // Device viewport is scaled. | 1318 // Device viewport is scaled. |
| 1319 EXPECT_EQ(gfx::Size(40, 40), impl->layoutViewportSize()); | 1319 EXPECT_EQ(gfx::Size(40, 40), impl->layoutViewportSize()); |
| 1320 EXPECT_EQ(gfx::Size(60, 60), impl->deviceViewportSize()); | 1320 EXPECT_EQ(gfx::Size(60, 60), impl->deviceViewportSize()); |
| 1321 | 1321 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 1396 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 1397 | 1397 |
| 1398 postSetNeedsCommitToMainThread(); | 1398 postSetNeedsCommitToMainThread(); |
| 1399 postSetNeedsRedrawToMainThread(); | 1399 postSetNeedsRedrawToMainThread(); |
| 1400 } | 1400 } |
| 1401 | 1401 |
| 1402 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1402 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1403 { | 1403 { |
| 1404 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); | 1404 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); |
| 1405 | 1405 |
| 1406 switch (impl->sourceFrameNumber()) { | 1406 switch (impl->activeTree()->source_frame_number()) { |
| 1407 case 0: | 1407 case 0: |
| 1408 // Number of textures should be one. | 1408 // Number of textures should be one. |
| 1409 ASSERT_EQ(1, context->numTextures()); | 1409 ASSERT_EQ(1, context->numTextures()); |
| 1410 // Number of textures used for commit should be one. | 1410 // Number of textures used for commit should be one. |
| 1411 EXPECT_EQ(1, context->numUsedTextures()); | 1411 EXPECT_EQ(1, context->numUsedTextures()); |
| 1412 // Verify that used texture is correct. | 1412 // Verify that used texture is correct. |
| 1413 EXPECT_TRUE(context->usedTexture(context->texture(0))); | 1413 EXPECT_TRUE(context->usedTexture(context->texture(0))); |
| 1414 | 1414 |
| 1415 context->resetUsedTextures(); | 1415 context->resetUsedTextures(); |
| 1416 break; | 1416 break; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1433 } | 1433 } |
| 1434 } | 1434 } |
| 1435 | 1435 |
| 1436 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1436 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1437 { | 1437 { |
| 1438 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); | 1438 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); |
| 1439 | 1439 |
| 1440 // Number of textures used for draw should always be one. | 1440 // Number of textures used for draw should always be one. |
| 1441 EXPECT_EQ(1, context->numUsedTextures()); | 1441 EXPECT_EQ(1, context->numUsedTextures()); |
| 1442 | 1442 |
| 1443 if (impl->sourceFrameNumber() < 1) { | 1443 if (impl->activeTree()->source_frame_number() < 1) { |
| 1444 context->resetUsedTextures(); | 1444 context->resetUsedTextures(); |
| 1445 postSetNeedsCommitToMainThread(); | 1445 postSetNeedsCommitToMainThread(); |
| 1446 postSetNeedsRedrawToMainThread(); | 1446 postSetNeedsRedrawToMainThread(); |
| 1447 } else | 1447 } else |
| 1448 endTest(); | 1448 endTest(); |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 virtual void layout() OVERRIDE | 1451 virtual void layout() OVERRIDE |
| 1452 { | 1452 { |
| 1453 m_layer->setNeedsDisplay(); | 1453 m_layer->setNeedsDisplay(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); | 1500 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); |
| 1501 | 1501 |
| 1502 postSetNeedsCommitToMainThread(); | 1502 postSetNeedsCommitToMainThread(); |
| 1503 postSetNeedsRedrawToMainThread(); | 1503 postSetNeedsRedrawToMainThread(); |
| 1504 } | 1504 } |
| 1505 | 1505 |
| 1506 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1506 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1507 { | 1507 { |
| 1508 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); | 1508 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); |
| 1509 | 1509 |
| 1510 switch (impl->sourceFrameNumber()) { | 1510 switch (impl->activeTree()->source_frame_number()) { |
| 1511 case 0: | 1511 case 0: |
| 1512 // Number of textures should be two. | 1512 // Number of textures should be two. |
| 1513 ASSERT_EQ(2, context->numTextures()); | 1513 ASSERT_EQ(2, context->numTextures()); |
| 1514 // Number of textures used for commit should be two. | 1514 // Number of textures used for commit should be two. |
| 1515 EXPECT_EQ(2, context->numUsedTextures()); | 1515 EXPECT_EQ(2, context->numUsedTextures()); |
| 1516 // Verify that used textures are correct. | 1516 // Verify that used textures are correct. |
| 1517 EXPECT_TRUE(context->usedTexture(context->texture(0))); | 1517 EXPECT_TRUE(context->usedTexture(context->texture(0))); |
| 1518 EXPECT_TRUE(context->usedTexture(context->texture(1))); | 1518 EXPECT_TRUE(context->usedTexture(context->texture(1))); |
| 1519 | 1519 |
| 1520 context->resetUsedTextures(); | 1520 context->resetUsedTextures(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 break; | 1554 break; |
| 1555 } | 1555 } |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1558 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1559 { | 1559 { |
| 1560 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); | 1560 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); |
| 1561 | 1561 |
| 1562 // Number of textures used for drawing should two except for frame 4 | 1562 // Number of textures used for drawing should two except for frame 4 |
| 1563 // where the viewport only contains one layer. | 1563 // where the viewport only contains one layer. |
| 1564 if (impl->sourceFrameNumber() == 3) | 1564 if (impl->activeTree()->source_frame_number() == 3) |
| 1565 EXPECT_EQ(1, context->numUsedTextures()); | 1565 EXPECT_EQ(1, context->numUsedTextures()); |
| 1566 else | 1566 else |
| 1567 EXPECT_EQ(2, context->numUsedTextures()); | 1567 EXPECT_EQ(2, context->numUsedTextures()); |
| 1568 | 1568 |
| 1569 if (impl->sourceFrameNumber() < 4) { | 1569 if (impl->activeTree()->source_frame_number() < 4) { |
| 1570 context->resetUsedTextures(); | 1570 context->resetUsedTextures(); |
| 1571 postSetNeedsCommitToMainThread(); | 1571 postSetNeedsCommitToMainThread(); |
| 1572 postSetNeedsRedrawToMainThread(); | 1572 postSetNeedsRedrawToMainThread(); |
| 1573 } else | 1573 } else |
| 1574 endTest(); | 1574 endTest(); |
| 1575 } | 1575 } |
| 1576 | 1576 |
| 1577 virtual void layout() OVERRIDE | 1577 virtual void layout() OVERRIDE |
| 1578 { | 1578 { |
| 1579 switch (m_numCommits++) { | 1579 switch (m_numCommits++) { |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 m_layerTreeHost->rootLayer()->setScrollable(true); | 2038 m_layerTreeHost->rootLayer()->setScrollable(true); |
| 2039 postSetNeedsCommitToMainThread(); | 2039 postSetNeedsCommitToMainThread(); |
| 2040 } | 2040 } |
| 2041 | 2041 |
| 2042 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 2042 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 2043 { | 2043 { |
| 2044 LayerImpl* root = impl->rootLayer(); | 2044 LayerImpl* root = impl->rootLayer(); |
| 2045 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); | 2045 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); |
| 2046 | 2046 |
| 2047 // Check that a fractional scroll delta is correctly accumulated over mu
ltiple commits. | 2047 // Check that a fractional scroll delta is correctly accumulated over mu
ltiple commits. |
| 2048 if (!impl->sourceFrameNumber()) { | 2048 if (!impl->activeTree()->source_frame_number()) { |
| 2049 EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::Vector2d(0, 0)); | 2049 EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::Vector2d(0, 0)); |
| 2050 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d(0, 0)); | 2050 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d(0, 0)); |
| 2051 postSetNeedsCommitToMainThread(); | 2051 postSetNeedsCommitToMainThread(); |
| 2052 } else if (impl->sourceFrameNumber() == 1) { | 2052 } else if (impl->activeTree()->source_frame_number() == 1) { |
| 2053 EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::ToFlooredVector2d(m_scro
llAmount)); | 2053 EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::ToFlooredVector2d(m_scro
llAmount)); |
| 2054 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2dF(fmod(m_scrollAm
ount.x(), 1), 0)); | 2054 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2dF(fmod(m_scrollAm
ount.x(), 1), 0)); |
| 2055 postSetNeedsCommitToMainThread(); | 2055 postSetNeedsCommitToMainThread(); |
| 2056 } else if (impl->sourceFrameNumber() == 2) { | 2056 } else if (impl->activeTree()->source_frame_number() == 2) { |
| 2057 EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::ToFlooredVector2d(m_scro
llAmount + m_scrollAmount)); | 2057 EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::ToFlooredVector2d(m_scro
llAmount + m_scrollAmount)); |
| 2058 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2dF(fmod(2 * m_scro
llAmount.x(), 1), 0)); | 2058 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2dF(fmod(2 * m_scro
llAmount.x(), 1), 0)); |
| 2059 endTest(); | 2059 endTest(); |
| 2060 } | 2060 } |
| 2061 root->scrollBy(m_scrollAmount); | 2061 root->scrollBy(m_scrollAmount); |
| 2062 } | 2062 } |
| 2063 | 2063 |
| 2064 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVE
RRIDE | 2064 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVE
RRIDE |
| 2065 { | 2065 { |
| 2066 gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset(); | 2066 gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2258 LayerImpl* rootScrollLayer = root->children()[0]; | 2258 LayerImpl* rootScrollLayer = root->children()[0]; |
| 2259 LayerImpl* childLayer = rootScrollLayer->children()[0]; | 2259 LayerImpl* childLayer = rootScrollLayer->children()[0]; |
| 2260 | 2260 |
| 2261 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); | 2261 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); |
| 2262 EXPECT_VECTOR_EQ(rootScrollLayer->scrollDelta(), gfx::Vector2d()); | 2262 EXPECT_VECTOR_EQ(rootScrollLayer->scrollDelta(), gfx::Vector2d()); |
| 2263 EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootS
crollLayer->contentBounds().width()); | 2263 EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootS
crollLayer->contentBounds().width()); |
| 2264 EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, root
ScrollLayer->contentBounds().height()); | 2264 EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, root
ScrollLayer->contentBounds().height()); |
| 2265 EXPECT_EQ(childLayer->bounds().width() * m_deviceScaleFactor, childLayer
->contentBounds().width()); | 2265 EXPECT_EQ(childLayer->bounds().width() * m_deviceScaleFactor, childLayer
->contentBounds().width()); |
| 2266 EXPECT_EQ(childLayer->bounds().height() * m_deviceScaleFactor, childLaye
r->contentBounds().height()); | 2266 EXPECT_EQ(childLayer->bounds().height() * m_deviceScaleFactor, childLaye
r->contentBounds().height()); |
| 2267 | 2267 |
| 2268 switch (impl->sourceFrameNumber()) { | 2268 switch (impl->activeTree()->source_frame_number()) { |
| 2269 case 0: | 2269 case 0: |
| 2270 // Gesture scroll on impl thread. | 2270 // Gesture scroll on impl thread. |
| 2271 EXPECT_EQ(impl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); | 2271 EXPECT_EQ(impl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); |
| 2272 impl->scrollBy(gfx::Point(), m_scrollAmount); | 2272 impl->scrollBy(gfx::Point(), m_scrollAmount); |
| 2273 impl->scrollEnd(); | 2273 impl->scrollEnd(); |
| 2274 | 2274 |
| 2275 EXPECT_VECTOR_EQ(m_initialScroll, childLayer->scrollOffset()); | 2275 EXPECT_VECTOR_EQ(m_initialScroll, childLayer->scrollOffset()); |
| 2276 EXPECT_VECTOR_EQ(m_scrollAmount, childLayer->scrollDelta()); | 2276 EXPECT_VECTOR_EQ(m_scrollAmount, childLayer->scrollDelta()); |
| 2277 break; | 2277 break; |
| 2278 case 1: | 2278 case 1: |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2393 | 2393 |
| 2394 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 2394 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 2395 { | 2395 { |
| 2396 LayerImpl* root = impl->rootLayer(); | 2396 LayerImpl* root = impl->rootLayer(); |
| 2397 LayerImpl* rootScrollLayer = root->children()[0]; | 2397 LayerImpl* rootScrollLayer = root->children()[0]; |
| 2398 | 2398 |
| 2399 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); | 2399 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); |
| 2400 EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootS
crollLayer->contentBounds().width()); | 2400 EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootS
crollLayer->contentBounds().width()); |
| 2401 EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, root
ScrollLayer->contentBounds().height()); | 2401 EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, root
ScrollLayer->contentBounds().height()); |
| 2402 | 2402 |
| 2403 switch (impl->sourceFrameNumber()) { | 2403 switch (impl->activeTree()->source_frame_number()) { |
| 2404 case 0: | 2404 case 0: |
| 2405 // Gesture scroll on impl thread. | 2405 // Gesture scroll on impl thread. |
| 2406 EXPECT_EQ(impl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); | 2406 EXPECT_EQ(impl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); |
| 2407 impl->scrollBy(gfx::Point(), m_scrollAmount); | 2407 impl->scrollBy(gfx::Point(), m_scrollAmount); |
| 2408 impl->scrollEnd(); | 2408 impl->scrollEnd(); |
| 2409 | 2409 |
| 2410 EXPECT_VECTOR_EQ(m_initialScroll, rootScrollLayer->scrollOffset()); | 2410 EXPECT_VECTOR_EQ(m_initialScroll, rootScrollLayer->scrollOffset()); |
| 2411 EXPECT_VECTOR_EQ(m_scrollAmount, rootScrollLayer->scrollDelta()); | 2411 EXPECT_VECTOR_EQ(m_scrollAmount, rootScrollLayer->scrollDelta()); |
| 2412 break; | 2412 break; |
| 2413 case 1: | 2413 case 1: |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2559 | 2559 |
| 2560 postSetNeedsCommitToMainThread(); | 2560 postSetNeedsCommitToMainThread(); |
| 2561 } | 2561 } |
| 2562 | 2562 |
| 2563 virtual void drawLayersOnThread(LayerTreeHostImpl* hostImpl) OVERRIDE | 2563 virtual void drawLayersOnThread(LayerTreeHostImpl* hostImpl) OVERRIDE |
| 2564 { | 2564 { |
| 2565 Renderer* renderer = hostImpl->renderer(); | 2565 Renderer* renderer = hostImpl->renderer(); |
| 2566 RenderPass::Id surface1RenderPassId = hostImpl->rootLayer()->children()[
0]->renderSurface()->renderPassId(); | 2566 RenderPass::Id surface1RenderPassId = hostImpl->rootLayer()->children()[
0]->renderSurface()->renderPassId(); |
| 2567 RenderPass::Id surface2RenderPassId = hostImpl->rootLayer()->children()[
0]->children()[0]->renderSurface()->renderPassId(); | 2567 RenderPass::Id surface2RenderPassId = hostImpl->rootLayer()->children()[
0]->children()[0]->renderSurface()->renderPassId(); |
| 2568 | 2568 |
| 2569 switch (hostImpl->sourceFrameNumber()) { | 2569 switch (hostImpl->activeTree()->source_frame_number()) { |
| 2570 case 0: | 2570 case 0: |
| 2571 EXPECT_TRUE(renderer->haveCachedResourcesForRenderPassId(surface1Ren
derPassId)); | 2571 EXPECT_TRUE(renderer->haveCachedResourcesForRenderPassId(surface1Ren
derPassId)); |
| 2572 EXPECT_TRUE(renderer->haveCachedResourcesForRenderPassId(surface2Ren
derPassId)); | 2572 EXPECT_TRUE(renderer->haveCachedResourcesForRenderPassId(surface2Ren
derPassId)); |
| 2573 | 2573 |
| 2574 // Reduce the memory limit to only fit the root layer and one render
surface. This | 2574 // Reduce the memory limit to only fit the root layer and one render
surface. This |
| 2575 // prevents any contents drawing into surfaces from being allocated. | 2575 // prevents any contents drawing into surfaces from being allocated. |
| 2576 hostImpl->setManagedMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 *
2)); | 2576 hostImpl->setManagedMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 *
2)); |
| 2577 break; | 2577 break; |
| 2578 case 1: | 2578 case 1: |
| 2579 EXPECT_FALSE(renderer->haveCachedResourcesForRenderPassId(surface1Re
nderPassId)); | 2579 EXPECT_FALSE(renderer->haveCachedResourcesForRenderPassId(surface1Re
nderPassId)); |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3351 LayerTreeSettings settings; | 3351 LayerTreeSettings settings; |
| 3352 settings.maxPartialTextureUpdates = 4; | 3352 settings.maxPartialTextureUpdates = 4; |
| 3353 | 3353 |
| 3354 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); | 3354 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); |
| 3355 EXPECT_TRUE(host->initializeRendererIfNeeded()); | 3355 EXPECT_TRUE(host->initializeRendererIfNeeded()); |
| 3356 EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates); | 3356 EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates); |
| 3357 } | 3357 } |
| 3358 | 3358 |
| 3359 } // namespace | 3359 } // namespace |
| 3360 } // namespace cc | 3360 } // namespace cc |
| OLD | NEW |