| 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/frame_rate_controller.h" | 10 #include "cc/frame_rate_controller.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 virtual void beginTest() OVERRIDE | 164 virtual void beginTest() OVERRIDE |
| 165 { | 165 { |
| 166 postSetNeedsCommitToMainThread(); | 166 postSetNeedsCommitToMainThread(); |
| 167 postSetNeedsCommitToMainThread(); | 167 postSetNeedsCommitToMainThread(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 170 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 171 { | 171 { |
| 172 m_numDraws++; | 172 m_numDraws++; |
| 173 if (!impl->activeTree()->source_frame_number()) | 173 if (!impl->active_tree()->source_frame_number()) |
| 174 endTest(); | 174 endTest(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 177 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
| 178 { | 178 { |
| 179 m_numCommits++; | 179 m_numCommits++; |
| 180 } | 180 } |
| 181 | 181 |
| 182 virtual void afterTest() OVERRIDE | 182 virtual void afterTest() OVERRIDE |
| 183 { | 183 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 205 { | 205 { |
| 206 } | 206 } |
| 207 | 207 |
| 208 virtual void beginTest() OVERRIDE | 208 virtual void beginTest() OVERRIDE |
| 209 { | 209 { |
| 210 postSetNeedsCommitToMainThread(); | 210 postSetNeedsCommitToMainThread(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 213 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 214 { | 214 { |
| 215 if (impl->activeTree()->source_frame_number() == 0) | 215 if (impl->active_tree()->source_frame_number() == 0) |
| 216 postSetNeedsCommitToMainThread(); | 216 postSetNeedsCommitToMainThread(); |
| 217 else if (impl->activeTree()->source_frame_number() == 1) | 217 else if (impl->active_tree()->source_frame_number() == 1) |
| 218 endTest(); | 218 endTest(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 221 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
| 222 { | 222 { |
| 223 m_numCommits++; | 223 m_numCommits++; |
| 224 } | 224 } |
| 225 | 225 |
| 226 virtual void afterTest() OVERRIDE | 226 virtual void afterTest() OVERRIDE |
| 227 { | 227 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 249 { | 249 { |
| 250 } | 250 } |
| 251 | 251 |
| 252 virtual void beginTest() OVERRIDE | 252 virtual void beginTest() OVERRIDE |
| 253 { | 253 { |
| 254 postSetNeedsCommitToMainThread(); | 254 postSetNeedsCommitToMainThread(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 257 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 258 { | 258 { |
| 259 EXPECT_EQ(0, impl->activeTree()->source_frame_number()); | 259 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); |
| 260 if (!m_numDraws) | 260 if (!m_numDraws) |
| 261 postSetNeedsRedrawToMainThread(); // Redraw again to verify that the
second redraw doesn't commit. | 261 postSetNeedsRedrawToMainThread(); // Redraw again to verify that the
second redraw doesn't commit. |
| 262 else | 262 else |
| 263 endTest(); | 263 endTest(); |
| 264 m_numDraws++; | 264 m_numDraws++; |
| 265 } | 265 } |
| 266 | 266 |
| 267 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 267 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
| 268 { | 268 { |
| 269 EXPECT_EQ(0, m_numDraws); | 269 EXPECT_EQ(0, m_numDraws); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 virtual void beginTest() OVERRIDE | 421 virtual void beginTest() OVERRIDE |
| 422 { | 422 { |
| 423 postSetNeedsCommitToMainThread(); | 423 postSetNeedsCommitToMainThread(); |
| 424 } | 424 } |
| 425 | 425 |
| 426 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 426 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 427 { | 427 { |
| 428 if (m_done) | 428 if (m_done) |
| 429 return; | 429 return; |
| 430 // Only the initial draw should bring us here. | 430 // Only the initial draw should bring us here. |
| 431 EXPECT_TRUE(impl->canDraw()); | 431 EXPECT_TRUE(impl->CanDraw()); |
| 432 EXPECT_EQ(0, impl->activeTree()->source_frame_number()); | 432 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); |
| 433 } | 433 } |
| 434 | 434 |
| 435 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 435 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 436 { | 436 { |
| 437 if (m_done) | 437 if (m_done) |
| 438 return; | 438 return; |
| 439 if (m_numCommits >= 1) { | 439 if (m_numCommits >= 1) { |
| 440 // After the first commit, we should not be able to draw. | 440 // After the first commit, we should not be able to draw. |
| 441 EXPECT_FALSE(impl->canDraw()); | 441 EXPECT_FALSE(impl->CanDraw()); |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 | 444 |
| 445 virtual void didCommit() OVERRIDE | 445 virtual void didCommit() OVERRIDE |
| 446 { | 446 { |
| 447 m_numCommits++; | 447 m_numCommits++; |
| 448 if (m_numCommits == 1) { | 448 if (m_numCommits == 1) { |
| 449 // Make the viewport empty so the host says it can't draw. | 449 // Make the viewport empty so the host says it can't draw. |
| 450 m_layerTreeHost->SetViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); | 450 m_layerTreeHost->SetViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); |
| 451 } else if (m_numCommits == 2) { | 451 } else if (m_numCommits == 2) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 { | 640 { |
| 641 m_layerTreeHost->SetViewportSize(gfx::Size(20, 20), gfx::Size(20, 20)); | 641 m_layerTreeHost->SetViewportSize(gfx::Size(20, 20), gfx::Size(20, 20)); |
| 642 m_layerTreeHost->set_background_color(SK_ColorGRAY); | 642 m_layerTreeHost->set_background_color(SK_ColorGRAY); |
| 643 m_layerTreeHost->SetPageScaleFactorAndLimits(5, 5, 5); | 643 m_layerTreeHost->SetPageScaleFactorAndLimits(5, 5, 5); |
| 644 | 644 |
| 645 postSetNeedsCommitToMainThread(); | 645 postSetNeedsCommitToMainThread(); |
| 646 } | 646 } |
| 647 | 647 |
| 648 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 648 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 649 { | 649 { |
| 650 EXPECT_EQ(gfx::Size(20, 20), impl->layoutViewportSize()); | 650 EXPECT_EQ(gfx::Size(20, 20), impl->layout_viewport_size()); |
| 651 EXPECT_EQ(SK_ColorGRAY, impl->activeTree()->background_color()); | 651 EXPECT_EQ(SK_ColorGRAY, impl->active_tree()->background_color()); |
| 652 EXPECT_EQ(5, impl->activeTree()->page_scale_factor()); | 652 EXPECT_EQ(5, impl->active_tree()->page_scale_factor()); |
| 653 | 653 |
| 654 endTest(); | 654 endTest(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 virtual void afterTest() OVERRIDE { } | 657 virtual void afterTest() OVERRIDE { } |
| 658 }; | 658 }; |
| 659 | 659 |
| 660 TEST_F(LayerTreeHostTestCommit, runTest) | 660 TEST_F(LayerTreeHostTestCommit, runTest) |
| 661 { | 661 { |
| 662 runTest(true); | 662 runTest(true); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 680 postSetNeedsRedrawToMainThread(); | 680 postSetNeedsRedrawToMainThread(); |
| 681 } | 681 } |
| 682 | 682 |
| 683 void requestStartPageScaleAnimation() | 683 void requestStartPageScaleAnimation() |
| 684 { | 684 { |
| 685 m_layerTreeHost->StartPageScaleAnimation(gfx::Vector2d(), false, 1.25, b
ase::TimeDelta()); | 685 m_layerTreeHost->StartPageScaleAnimation(gfx::Vector2d(), false, 1.25, b
ase::TimeDelta()); |
| 686 } | 686 } |
| 687 | 687 |
| 688 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 688 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 689 { | 689 { |
| 690 impl->rootLayer()->SetScrollable(true); | 690 impl->active_tree()->root_layer()->SetScrollable(true); |
| 691 impl->rootLayer()->SetScrollOffset(gfx::Vector2d()); | 691 impl->active_tree()->root_layer()->SetScrollOffset(gfx::Vector2d()); |
| 692 impl->activeTree()->SetPageScaleFactorAndLimits(impl->activeTree()->page
_scale_factor(), 0.5, 2); | 692 impl->active_tree()->SetPageScaleFactorAndLimits(impl->active_tree()->pa
ge_scale_factor(), 0.5, 2); |
| 693 | 693 |
| 694 // We request animation only once. | 694 // We request animation only once. |
| 695 if (!m_animationRequested) { | 695 if (!m_animationRequested) { |
| 696 impl->proxy()->MainThread()->postTask(base::Bind(&LayerTreeHostTestS
tartPageScaleAnimation::requestStartPageScaleAnimation, base::Unretained(this)))
; | 696 impl->proxy()->MainThread()->postTask(base::Bind(&LayerTreeHostTestS
tartPageScaleAnimation::requestStartPageScaleAnimation, base::Unretained(this)))
; |
| 697 m_animationRequested = true; | 697 m_animationRequested = true; |
| 698 } | 698 } |
| 699 } | 699 } |
| 700 | 700 |
| 701 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVE
RRIDE | 701 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVE
RRIDE |
| 702 { | 702 { |
| 703 gfx::Vector2d offset = m_layerTreeHost->root_layer()->scroll_offset(); | 703 gfx::Vector2d offset = m_layerTreeHost->root_layer()->scroll_offset(); |
| 704 m_layerTreeHost->root_layer()->SetScrollOffset(offset + scrollDelta); | 704 m_layerTreeHost->root_layer()->SetScrollOffset(offset + scrollDelta); |
| 705 m_layerTreeHost->SetPageScaleFactorAndLimits(scale, 0.5, 2); | 705 m_layerTreeHost->SetPageScaleFactorAndLimits(scale, 0.5, 2); |
| 706 } | 706 } |
| 707 | 707 |
| 708 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 708 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 709 { | 709 { |
| 710 impl->processScrollDeltas(); | 710 impl->ProcessScrollDeltas(); |
| 711 // We get one commit before the first draw, and the animation doesn't ha
ppen until the second draw. | 711 // We get one commit before the first draw, and the animation doesn't ha
ppen until the second draw. |
| 712 if (impl->activeTree()->source_frame_number() == 1) { | 712 if (impl->active_tree()->source_frame_number() == 1) { |
| 713 EXPECT_EQ(1.25, impl->activeTree()->page_scale_factor()); | 713 EXPECT_EQ(1.25, impl->active_tree()->page_scale_factor()); |
| 714 endTest(); | 714 endTest(); |
| 715 } else | 715 } else |
| 716 postSetNeedsRedrawToMainThread(); | 716 postSetNeedsRedrawToMainThread(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 virtual void afterTest() OVERRIDE | 719 virtual void afterTest() OVERRIDE |
| 720 { | 720 { |
| 721 } | 721 } |
| 722 | 722 |
| 723 private: | 723 private: |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 m_layerTreeHost->UpdateLayers(&queue, std::numeric_limits<size_t>::max()
); | 921 m_layerTreeHost->UpdateLayers(&queue, std::numeric_limits<size_t>::max()
); |
| 922 postSetNeedsCommitToMainThread(); | 922 postSetNeedsCommitToMainThread(); |
| 923 } | 923 } |
| 924 | 924 |
| 925 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 925 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 926 { | 926 { |
| 927 // Get access to protected methods. | 927 // Get access to protected methods. |
| 928 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im
pl); | 928 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im
pl); |
| 929 | 929 |
| 930 // Should only do one commit. | 930 // Should only do one commit. |
| 931 EXPECT_EQ(0, impl->activeTree()->source_frame_number()); | 931 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); |
| 932 // Device scale factor should come over to impl. | 932 // Device scale factor should come over to impl. |
| 933 EXPECT_NEAR(impl->deviceScaleFactor(), 1.5, 0.00001); | 933 EXPECT_NEAR(impl->device_scale_factor(), 1.5, 0.00001); |
| 934 | 934 |
| 935 // Both layers are on impl. | 935 // Both layers are on impl. |
| 936 ASSERT_EQ(1u, impl->rootLayer()->children().size()); | 936 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); |
| 937 | 937 |
| 938 // Device viewport is scaled. | 938 // Device viewport is scaled. |
| 939 EXPECT_EQ(gfx::Size(40, 40), impl->layoutViewportSize()); | 939 EXPECT_EQ(gfx::Size(40, 40), impl->layout_viewport_size()); |
| 940 EXPECT_EQ(gfx::Size(60, 60), impl->DeviceViewportSize()); | 940 EXPECT_EQ(gfx::Size(60, 60), impl->device_viewport_size()); |
| 941 | 941 |
| 942 LayerImpl* root = impl->rootLayer(); | 942 LayerImpl* root = impl->active_tree()->root_layer(); |
| 943 LayerImpl* child = impl->rootLayer()->children()[0]; | 943 LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; |
| 944 | 944 |
| 945 // Positions remain in layout pixels. | 945 // Positions remain in layout pixels. |
| 946 EXPECT_EQ(gfx::Point(0, 0), root->position()); | 946 EXPECT_EQ(gfx::Point(0, 0), root->position()); |
| 947 EXPECT_EQ(gfx::Point(2, 2), child->position()); | 947 EXPECT_EQ(gfx::Point(2, 2), child->position()); |
| 948 | 948 |
| 949 // Compute all the layer transforms for the frame. | 949 // Compute all the layer transforms for the frame. |
| 950 LayerTreeHostImpl::FrameData frameData; | 950 LayerTreeHostImpl::FrameData frameData; |
| 951 mockImpl->prepareToDraw(frameData); | 951 mockImpl->PrepareToDraw(&frameData); |
| 952 mockImpl->didDrawAllLayers(frameData); | 952 mockImpl->DidDrawAllLayers(frameData); |
| 953 | 953 |
| 954 const MockLayerTreeHostImpl::LayerList& renderSurfaceLayerList = | 954 const MockLayerTreeHostImpl::LayerList& renderSurfaceLayerList = |
| 955 *frameData.renderSurfaceLayerList; | 955 *frameData.render_surface_layer_list; |
| 956 | 956 |
| 957 // Both layers should be drawing into the root render surface. | 957 // Both layers should be drawing into the root render surface. |
| 958 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 958 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 959 ASSERT_EQ(root->render_surface(), renderSurfaceLayerList[0]->render_surf
ace()); | 959 ASSERT_EQ(root->render_surface(), renderSurfaceLayerList[0]->render_surf
ace()); |
| 960 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 960 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 961 | 961 |
| 962 // The root render surface is the size of the viewport. | 962 // The root render surface is the size of the viewport. |
| 963 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), root->render_surface()->content_
rect()); | 963 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), root->render_surface()->content_
rect()); |
| 964 | 964 |
| 965 // The content bounds of the child should be scaled. | 965 // The content bounds of the child should be scaled. |
| 966 gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bo
unds(), 1.5)); | 966 gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bo
unds(), 1.5)); |
| 967 EXPECT_EQ(childBoundsScaled, child->content_bounds()); | 967 EXPECT_EQ(childBoundsScaled, child->content_bounds()); |
| 968 | 968 |
| 969 gfx::Transform scaleTransform; | 969 gfx::Transform scaleTransform; |
| 970 scaleTransform.Scale(impl->deviceScaleFactor(), impl->deviceScaleFactor(
)); | 970 scaleTransform.Scale(impl->device_scale_factor(), impl->device_scale_fac
tor()); |
| 971 | 971 |
| 972 // The root layer is scaled by 2x. | 972 // The root layer is scaled by 2x. |
| 973 gfx::Transform rootScreenSpaceTransform = scaleTransform; | 973 gfx::Transform rootScreenSpaceTransform = scaleTransform; |
| 974 gfx::Transform rootDrawTransform = scaleTransform; | 974 gfx::Transform rootDrawTransform = scaleTransform; |
| 975 | 975 |
| 976 EXPECT_EQ(rootDrawTransform, root->draw_transform()); | 976 EXPECT_EQ(rootDrawTransform, root->draw_transform()); |
| 977 EXPECT_EQ(rootScreenSpaceTransform, root->screen_space_transform()); | 977 EXPECT_EQ(rootScreenSpaceTransform, root->screen_space_transform()); |
| 978 | 978 |
| 979 // The child is at position 2,2, which is transformed to 3,3 after the s
cale | 979 // The child is at position 2,2, which is transformed to 3,3 after the s
cale |
| 980 gfx::Transform childScreenSpaceTransform; | 980 gfx::Transform childScreenSpaceTransform; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 | 1035 |
| 1036 virtual void beginTest() OVERRIDE | 1036 virtual void beginTest() OVERRIDE |
| 1037 { | 1037 { |
| 1038 postSetNeedsCommitToMainThread(); | 1038 postSetNeedsCommitToMainThread(); |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1041 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1042 { | 1042 { |
| 1043 ASSERT_EQ(0u, m_layerTreeHost->settings().maxPartialTextureUpdates); | 1043 ASSERT_EQ(0u, m_layerTreeHost->settings().maxPartialTextureUpdates); |
| 1044 | 1044 |
| 1045 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->outputSurface()->context3d()); | 1045 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->output_surface()->context3d()); |
| 1046 | 1046 |
| 1047 switch (impl->activeTree()->source_frame_number()) { | 1047 switch (impl->active_tree()->source_frame_number()) { |
| 1048 case 0: | 1048 case 0: |
| 1049 // Number of textures should be one for each layer | 1049 // Number of textures should be one for each layer |
| 1050 ASSERT_EQ(2, context->NumTextures()); | 1050 ASSERT_EQ(2, context->NumTextures()); |
| 1051 // Number of textures used for commit should be one for each layer. | 1051 // Number of textures used for commit should be one for each layer. |
| 1052 EXPECT_EQ(2, context->NumUsedTextures()); | 1052 EXPECT_EQ(2, context->NumUsedTextures()); |
| 1053 // Verify that used texture is correct. | 1053 // Verify that used texture is correct. |
| 1054 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); | 1054 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); |
| 1055 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); | 1055 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
| 1056 | 1056 |
| 1057 context->ResetUsedTextures(); | 1057 context->ResetUsedTextures(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1077 endTest(); | 1077 endTest(); |
| 1078 break; | 1078 break; |
| 1079 default: | 1079 default: |
| 1080 NOTREACHED(); | 1080 NOTREACHED(); |
| 1081 break; | 1081 break; |
| 1082 } | 1082 } |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1085 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1086 { | 1086 { |
| 1087 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->outputSurface()->context3d()); | 1087 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->output_surface()->context3d()); |
| 1088 | 1088 |
| 1089 // Number of textures used for draw should always be one for each layer. | 1089 // Number of textures used for draw should always be one for each layer. |
| 1090 EXPECT_EQ(2, context->NumUsedTextures()); | 1090 EXPECT_EQ(2, context->NumUsedTextures()); |
| 1091 context->ResetUsedTextures(); | 1091 context->ResetUsedTextures(); |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 virtual void layout() OVERRIDE | 1094 virtual void layout() OVERRIDE |
| 1095 { | 1095 { |
| 1096 m_layer->SetNeedsDisplay(); | 1096 m_layer->SetNeedsDisplay(); |
| 1097 m_scrollbar->SetNeedsDisplay(); | 1097 m_scrollbar->SetNeedsDisplay(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 | 1167 |
| 1168 virtual void beginTest() OVERRIDE | 1168 virtual void beginTest() OVERRIDE |
| 1169 { | 1169 { |
| 1170 postSetNeedsCommitToMainThread(); | 1170 postSetNeedsCommitToMainThread(); |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1173 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1174 { | 1174 { |
| 1175 ASSERT_EQ(1u, m_layerTreeHost->settings().maxPartialTextureUpdates); | 1175 ASSERT_EQ(1u, m_layerTreeHost->settings().maxPartialTextureUpdates); |
| 1176 | 1176 |
| 1177 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->outputSurface()->context3d()); | 1177 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->output_surface()->context3d()); |
| 1178 | 1178 |
| 1179 switch (impl->activeTree()->source_frame_number()) { | 1179 switch (impl->active_tree()->source_frame_number()) { |
| 1180 case 0: | 1180 case 0: |
| 1181 // Number of textures should be one for each layer. | 1181 // Number of textures should be one for each layer. |
| 1182 ASSERT_EQ(4, context->NumTextures()); | 1182 ASSERT_EQ(4, context->NumTextures()); |
| 1183 // Number of textures used for commit should be one for each layer. | 1183 // Number of textures used for commit should be one for each layer. |
| 1184 EXPECT_EQ(4, context->NumUsedTextures()); | 1184 EXPECT_EQ(4, context->NumUsedTextures()); |
| 1185 // Verify that used textures are correct. | 1185 // Verify that used textures are correct. |
| 1186 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); | 1186 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); |
| 1187 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); | 1187 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
| 1188 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); | 1188 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); |
| 1189 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); | 1189 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 endTest(); | 1252 endTest(); |
| 1253 break; | 1253 break; |
| 1254 default: | 1254 default: |
| 1255 NOTREACHED(); | 1255 NOTREACHED(); |
| 1256 break; | 1256 break; |
| 1257 } | 1257 } |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1260 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1261 { | 1261 { |
| 1262 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->outputSurface()->context3d()); | 1262 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->output_surface()->context3d()); |
| 1263 | 1263 |
| 1264 // Number of textures used for drawing should one per layer except for | 1264 // Number of textures used for drawing should one per layer except for |
| 1265 // frame 3 where the viewport only contains one layer. | 1265 // frame 3 where the viewport only contains one layer. |
| 1266 if (impl->activeTree()->source_frame_number() == 3) | 1266 if (impl->active_tree()->source_frame_number() == 3) |
| 1267 EXPECT_EQ(1, context->NumUsedTextures()); | 1267 EXPECT_EQ(1, context->NumUsedTextures()); |
| 1268 else | 1268 else |
| 1269 EXPECT_EQ(4, context->NumUsedTextures()); | 1269 EXPECT_EQ(4, context->NumUsedTextures()); |
| 1270 | 1270 |
| 1271 context->ResetUsedTextures(); | 1271 context->ResetUsedTextures(); |
| 1272 } | 1272 } |
| 1273 | 1273 |
| 1274 virtual void layout() OVERRIDE | 1274 virtual void layout() OVERRIDE |
| 1275 { | 1275 { |
| 1276 switch (m_numCommits++) { | 1276 switch (m_numCommits++) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 m_rootLayer->AddChild(m_surfaceLayer1); | 1430 m_rootLayer->AddChild(m_surfaceLayer1); |
| 1431 m_surfaceLayer1->AddChild(m_surfaceLayer2); | 1431 m_surfaceLayer1->AddChild(m_surfaceLayer2); |
| 1432 m_layerTreeHost->SetRootLayer(m_rootLayer); | 1432 m_layerTreeHost->SetRootLayer(m_rootLayer); |
| 1433 | 1433 |
| 1434 postSetNeedsCommitToMainThread(); | 1434 postSetNeedsCommitToMainThread(); |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 virtual void drawLayersOnThread(LayerTreeHostImpl* hostImpl) OVERRIDE | 1437 virtual void drawLayersOnThread(LayerTreeHostImpl* hostImpl) OVERRIDE |
| 1438 { | 1438 { |
| 1439 Renderer* renderer = hostImpl->renderer(); | 1439 Renderer* renderer = hostImpl->renderer(); |
| 1440 RenderPass::Id surface1RenderPassId = hostImpl->rootLayer()->children()[
0]->render_surface()->RenderPassId(); | 1440 RenderPass::Id surface1RenderPassId = hostImpl->active_tree()->root_laye
r()->children()[0]->render_surface()->RenderPassId(); |
| 1441 RenderPass::Id surface2RenderPassId = hostImpl->rootLayer()->children()[
0]->children()[0]->render_surface()->RenderPassId(); | 1441 RenderPass::Id surface2RenderPassId = hostImpl->active_tree()->root_laye
r()->children()[0]->children()[0]->render_surface()->RenderPassId(); |
| 1442 | 1442 |
| 1443 switch (hostImpl->activeTree()->source_frame_number()) { | 1443 switch (hostImpl->active_tree()->source_frame_number()) { |
| 1444 case 0: | 1444 case 0: |
| 1445 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(surface1Ren
derPassId)); | 1445 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(surface1Ren
derPassId)); |
| 1446 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(surface2Ren
derPassId)); | 1446 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(surface2Ren
derPassId)); |
| 1447 | 1447 |
| 1448 // Reduce the memory limit to only fit the root layer and one render
surface. This | 1448 // Reduce the memory limit to only fit the root layer and one render
surface. This |
| 1449 // prevents any contents drawing into surfaces from being allocated. | 1449 // prevents any contents drawing into surfaces from being allocated. |
| 1450 hostImpl->SetManagedMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 *
2)); | 1450 hostImpl->SetManagedMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 *
2)); |
| 1451 break; | 1451 break; |
| 1452 case 1: | 1452 case 1: |
| 1453 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(surface1Re
nderPassId)); | 1453 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(surface1Re
nderPassId)); |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 } | 2135 } |
| 2136 | 2136 |
| 2137 virtual void didSetVisibleOnImplTree(LayerTreeHostImpl* hostImpl, bool visib
le) OVERRIDE | 2137 virtual void didSetVisibleOnImplTree(LayerTreeHostImpl* hostImpl, bool visib
le) OVERRIDE |
| 2138 { | 2138 { |
| 2139 // One backing should remain unevicted. | 2139 // One backing should remain unevicted. |
| 2140 EXPECT_EQ( | 2140 EXPECT_EQ( |
| 2141 100 * 100 * 4 * 1, | 2141 100 * 100 * 4 * 1, |
| 2142 m_layerTreeHost->contents_texture_manager()->memoryUseBytes()); | 2142 m_layerTreeHost->contents_texture_manager()->memoryUseBytes()); |
| 2143 // Make sure that contents textures are marked as having been | 2143 // Make sure that contents textures are marked as having been |
| 2144 // purged. | 2144 // purged. |
| 2145 EXPECT_TRUE(hostImpl->activeTree()->ContentsTexturesPurged()); | 2145 EXPECT_TRUE(hostImpl->active_tree()->ContentsTexturesPurged()); |
| 2146 // End the test in this state. | 2146 // End the test in this state. |
| 2147 endTest(); | 2147 endTest(); |
| 2148 } | 2148 } |
| 2149 | 2149 |
| 2150 virtual void commitCompleteOnThread(LayerTreeHostImpl* hostImpl) OVERRIDE | 2150 virtual void commitCompleteOnThread(LayerTreeHostImpl* hostImpl) OVERRIDE |
| 2151 { | 2151 { |
| 2152 ++m_numCommits; | 2152 ++m_numCommits; |
| 2153 switch(m_numCommits) { | 2153 switch(m_numCommits) { |
| 2154 case 1: | 2154 case 1: |
| 2155 // All three backings should have memory. | 2155 // All three backings should have memory. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2190 scoped_refptr<FakeContentLayer> m_rootLayer; | 2190 scoped_refptr<FakeContentLayer> m_rootLayer; |
| 2191 scoped_refptr<FakeContentLayer> m_childLayer1; | 2191 scoped_refptr<FakeContentLayer> m_childLayer1; |
| 2192 scoped_refptr<FakeContentLayer> m_childLayer2; | 2192 scoped_refptr<FakeContentLayer> m_childLayer2; |
| 2193 int m_numCommits; | 2193 int m_numCommits; |
| 2194 }; | 2194 }; |
| 2195 | 2195 |
| 2196 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvi
cted) | 2196 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvi
cted) |
| 2197 | 2197 |
| 2198 } // namespace | 2198 } // namespace |
| 2199 } // namespace cc | 2199 } // namespace cc |
| OLD | NEW |