| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 }; | 282 }; |
| 283 | 283 |
| 284 TEST_F(LayerTreeHostTestSetNeedsRedraw, runMultiThread) | 284 TEST_F(LayerTreeHostTestSetNeedsRedraw, runMultiThread) |
| 285 { | 285 { |
| 286 runTest(true); | 286 runTest(true); |
| 287 } | 287 } |
| 288 | 288 |
| 289 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { | 289 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
| 290 public: | 290 public: |
| 291 LayerTreeHostTestNoExtraCommitFromInvalidate() | 291 LayerTreeHostTestNoExtraCommitFromInvalidate() |
| 292 : m_rootLayer(ContentLayer::create(&m_client)) | 292 : m_rootLayer(ContentLayer::Create(&m_client)) |
| 293 { | 293 { |
| 294 } | 294 } |
| 295 | 295 |
| 296 virtual void beginTest() OVERRIDE | 296 virtual void beginTest() OVERRIDE |
| 297 { | 297 { |
| 298 m_rootLayer->setAutomaticallyComputeRasterScale(false); | 298 m_rootLayer->SetAutomaticallyComputeRasterScale(false); |
| 299 m_rootLayer->setIsDrawable(true); | 299 m_rootLayer->SetIsDrawable(true); |
| 300 m_rootLayer->setBounds(gfx::Size(1, 1)); | 300 m_rootLayer->SetBounds(gfx::Size(1, 1)); |
| 301 m_layerTreeHost->setRootLayer(m_rootLayer); | 301 m_layerTreeHost->setRootLayer(m_rootLayer); |
| 302 postSetNeedsCommitToMainThread(); | 302 postSetNeedsCommitToMainThread(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 virtual void didCommit() OVERRIDE | 305 virtual void didCommit() OVERRIDE |
| 306 { | 306 { |
| 307 switch (m_layerTreeHost->commitNumber()) { | 307 switch (m_layerTreeHost->commitNumber()) { |
| 308 case 1: | 308 case 1: |
| 309 // Changing the content bounds will cause a single commit! | 309 // Changing the content bounds will cause a single commit! |
| 310 m_rootLayer->setRasterScale(4.0f); | 310 m_rootLayer->SetRasterScale(4.0f); |
| 311 break; | 311 break; |
| 312 default: | 312 default: |
| 313 // No extra commits. | 313 // No extra commits. |
| 314 EXPECT_EQ(2, m_layerTreeHost->commitNumber()); | 314 EXPECT_EQ(2, m_layerTreeHost->commitNumber()); |
| 315 endTest(); | 315 endTest(); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 virtual void afterTest() OVERRIDE | 319 virtual void afterTest() OVERRIDE |
| 320 { | 320 { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest { | 667 class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest { |
| 668 public: | 668 public: |
| 669 | 669 |
| 670 LayerTreeHostTestStartPageScaleAnimation() | 670 LayerTreeHostTestStartPageScaleAnimation() |
| 671 : m_animationRequested(false) | 671 : m_animationRequested(false) |
| 672 { | 672 { |
| 673 } | 673 } |
| 674 | 674 |
| 675 virtual void beginTest() OVERRIDE | 675 virtual void beginTest() OVERRIDE |
| 676 { | 676 { |
| 677 m_layerTreeHost->rootLayer()->setScrollable(true); | 677 m_layerTreeHost->rootLayer()->SetScrollable(true); |
| 678 m_layerTreeHost->rootLayer()->setScrollOffset(gfx::Vector2d()); | 678 m_layerTreeHost->rootLayer()->SetScrollOffset(gfx::Vector2d()); |
| 679 postSetNeedsCommitToMainThread(); | 679 postSetNeedsCommitToMainThread(); |
| 680 postSetNeedsRedrawToMainThread(); | 680 postSetNeedsRedrawToMainThread(); |
| 681 } | 681 } |
| 682 | 682 |
| 683 void requestStartPageScaleAnimation() | 683 void requestStartPageScaleAnimation() |
| 684 { | 684 { |
| 685 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->rootLayer()->SetScrollable(true); |
| 691 impl->rootLayer()->setScrollOffset(gfx::Vector2d()); | 691 impl->rootLayer()->SetScrollOffset(gfx::Vector2d()); |
| 692 impl->activeTree()->SetPageScaleFactorAndLimits(impl->activeTree()->page
_scale_factor(), 0.5, 2); | 692 impl->activeTree()->SetPageScaleFactorAndLimits(impl->activeTree()->page
_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->rootLayer()->scrollOffset(); | 703 gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scroll_offset(); |
| 704 m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta); | 704 m_layerTreeHost->rootLayer()->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->activeTree()->source_frame_number() == 1) { |
| 713 EXPECT_EQ(1.25, impl->activeTree()->page_scale_factor()); | 713 EXPECT_EQ(1.25, impl->activeTree()->page_scale_factor()); |
| 714 endTest(); | 714 endTest(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 776 |
| 777 void setTestLayer(Layer* testLayer) | 777 void setTestLayer(Layer* testLayer) |
| 778 { | 778 { |
| 779 m_testLayer = testLayer; | 779 m_testLayer = testLayer; |
| 780 } | 780 } |
| 781 | 781 |
| 782 virtual void paintContents(SkCanvas*, const gfx::Rect&, gfx::RectF&) OVERRID
E | 782 virtual void paintContents(SkCanvas*, const gfx::Rect&, gfx::RectF&) OVERRID
E |
| 783 { | 783 { |
| 784 // Set layer opacity to 0. | 784 // Set layer opacity to 0. |
| 785 if (m_testLayer) | 785 if (m_testLayer) |
| 786 m_testLayer->setOpacity(0); | 786 m_testLayer->SetOpacity(0); |
| 787 } | 787 } |
| 788 | 788 |
| 789 private: | 789 private: |
| 790 Layer* m_testLayer; | 790 Layer* m_testLayer; |
| 791 }; | 791 }; |
| 792 | 792 |
| 793 class ContentLayerWithUpdateTracking : public ContentLayer { | 793 class ContentLayerWithUpdateTracking : public ContentLayer { |
| 794 public: | 794 public: |
| 795 static scoped_refptr<ContentLayerWithUpdateTracking> create(ContentLayerClie
nt* client) { return make_scoped_refptr(new ContentLayerWithUpdateTracking(clien
t)); } | 795 static scoped_refptr<ContentLayerWithUpdateTracking> Create(ContentLayerClie
nt* client) { return make_scoped_refptr(new ContentLayerWithUpdateTracking(clien
t)); } |
| 796 | 796 |
| 797 int paintContentsCount() { return m_paintContentsCount; } | 797 int paintContentsCount() { return m_paintContentsCount; } |
| 798 void resetPaintContentsCount() { m_paintContentsCount = 0; } | 798 void resetPaintContentsCount() { m_paintContentsCount = 0; } |
| 799 | 799 |
| 800 virtual void update(ResourceUpdateQueue& queue, const OcclusionTracker* occl
usion, RenderingStats* stats) OVERRIDE | 800 virtual void Update(ResourceUpdateQueue* queue, const OcclusionTracker* occl
usion, RenderingStats* stats) OVERRIDE |
| 801 { | 801 { |
| 802 ContentLayer::update(queue, occlusion, stats); | 802 ContentLayer::Update(queue, occlusion, stats); |
| 803 m_paintContentsCount++; | 803 m_paintContentsCount++; |
| 804 } | 804 } |
| 805 | 805 |
| 806 private: | 806 private: |
| 807 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client) | 807 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client) |
| 808 : ContentLayer(client) | 808 : ContentLayer(client) |
| 809 , m_paintContentsCount(0) | 809 , m_paintContentsCount(0) |
| 810 { | 810 { |
| 811 setAnchorPoint(gfx::PointF(0, 0)); | 811 SetAnchorPoint(gfx::PointF(0, 0)); |
| 812 setBounds(gfx::Size(10, 10)); | 812 SetBounds(gfx::Size(10, 10)); |
| 813 setIsDrawable(true); | 813 SetIsDrawable(true); |
| 814 } | 814 } |
| 815 virtual ~ContentLayerWithUpdateTracking() | 815 virtual ~ContentLayerWithUpdateTracking() |
| 816 { | 816 { |
| 817 } | 817 } |
| 818 | 818 |
| 819 int m_paintContentsCount; | 819 int m_paintContentsCount; |
| 820 }; | 820 }; |
| 821 | 821 |
| 822 // Layer opacity change during paint should not prevent compositor resources fro
m being updated during commit. | 822 // Layer opacity change during paint should not prevent compositor resources fro
m being updated during commit. |
| 823 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { | 823 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { |
| 824 public: | 824 public: |
| 825 LayerTreeHostTestOpacityChange() | 825 LayerTreeHostTestOpacityChange() |
| 826 : m_testOpacityChangeDelegate() | 826 : m_testOpacityChangeDelegate() |
| 827 , m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_testOpaci
tyChangeDelegate)) | 827 , m_updateCheckLayer(ContentLayerWithUpdateTracking::Create(&m_testOpaci
tyChangeDelegate)) |
| 828 { | 828 { |
| 829 m_testOpacityChangeDelegate.setTestLayer(m_updateCheckLayer.get()); | 829 m_testOpacityChangeDelegate.setTestLayer(m_updateCheckLayer.get()); |
| 830 } | 830 } |
| 831 | 831 |
| 832 virtual void beginTest() OVERRIDE | 832 virtual void beginTest() OVERRIDE |
| 833 { | 833 { |
| 834 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 834 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 835 m_layerTreeHost->rootLayer()->addChild(m_updateCheckLayer); | 835 m_layerTreeHost->rootLayer()->AddChild(m_updateCheckLayer); |
| 836 | 836 |
| 837 postSetNeedsCommitToMainThread(); | 837 postSetNeedsCommitToMainThread(); |
| 838 } | 838 } |
| 839 | 839 |
| 840 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 840 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
| 841 { | 841 { |
| 842 endTest(); | 842 endTest(); |
| 843 } | 843 } |
| 844 | 844 |
| 845 virtual void afterTest() OVERRIDE | 845 virtual void afterTest() OVERRIDE |
| 846 { | 846 { |
| 847 // update() should have been called once. | 847 // Update() should have been called once. |
| 848 EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount()); | 848 EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount()); |
| 849 | 849 |
| 850 // clear m_updateCheckLayer so LayerTreeHost dies. | 850 // clear m_updateCheckLayer so LayerTreeHost dies. |
| 851 m_updateCheckLayer = NULL; | 851 m_updateCheckLayer = NULL; |
| 852 } | 852 } |
| 853 | 853 |
| 854 private: | 854 private: |
| 855 TestOpacityChangeLayerDelegate m_testOpacityChangeDelegate; | 855 TestOpacityChangeLayerDelegate m_testOpacityChangeDelegate; |
| 856 scoped_refptr<ContentLayerWithUpdateTracking> m_updateCheckLayer; | 856 scoped_refptr<ContentLayerWithUpdateTracking> m_updateCheckLayer; |
| 857 }; | 857 }; |
| 858 | 858 |
| 859 TEST_F(LayerTreeHostTestOpacityChange, runMultiThread) | 859 TEST_F(LayerTreeHostTestOpacityChange, runMultiThread) |
| 860 { | 860 { |
| 861 runTest(true); | 861 runTest(true); |
| 862 } | 862 } |
| 863 | 863 |
| 864 class NoScaleContentLayer : public ContentLayer { | 864 class NoScaleContentLayer : public ContentLayer { |
| 865 public: | 865 public: |
| 866 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } | 866 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } |
| 867 | 867 |
| 868 virtual void calculateContentsScale( | 868 virtual void CalculateContentsScale( |
| 869 float idealContentsScale, | 869 float ideal_contents_scale, |
| 870 bool animatingTransformToScreen, | 870 bool animating_transform_to_screen, |
| 871 float* contentsScaleX, | 871 float* contents_scale_x, |
| 872 float* contentsScaleY, | 872 float* contents_scale_y, |
| 873 gfx::Size* contentBounds) OVERRIDE | 873 gfx::Size* contentBounds) OVERRIDE |
| 874 { | 874 { |
| 875 // Skip over the ContentLayer's method to the base Layer class. | 875 // Skip over the ContentLayer's method to the base Layer class. |
| 876 Layer::calculateContentsScale( | 876 Layer::CalculateContentsScale( |
| 877 idealContentsScale, | 877 ideal_contents_scale, |
| 878 animatingTransformToScreen, | 878 animating_transform_to_screen, |
| 879 contentsScaleX, | 879 contents_scale_x, |
| 880 contentsScaleY, | 880 contents_scale_y, |
| 881 contentBounds); | 881 contentBounds); |
| 882 } | 882 } |
| 883 | 883 |
| 884 private: | 884 private: |
| 885 explicit NoScaleContentLayer(ContentLayerClient* client) | 885 explicit NoScaleContentLayer(ContentLayerClient* client) |
| 886 : ContentLayer(client) { } | 886 : ContentLayer(client) { } |
| 887 virtual ~NoScaleContentLayer() { } | 887 virtual ~NoScaleContentLayer() { } |
| 888 }; | 888 }; |
| 889 | 889 |
| 890 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers : public LayerTr
eeHostTest { | 890 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers : public LayerTr
eeHostTest { |
| 891 public: | 891 public: |
| 892 | 892 |
| 893 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() | 893 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() |
| 894 : m_rootLayer(NoScaleContentLayer::create(&m_client)) | 894 : m_rootLayer(NoScaleContentLayer::Create(&m_client)) |
| 895 , m_childLayer(ContentLayer::create(&m_client)) | 895 , m_childLayer(ContentLayer::Create(&m_client)) |
| 896 { | 896 { |
| 897 } | 897 } |
| 898 | 898 |
| 899 virtual void beginTest() OVERRIDE | 899 virtual void beginTest() OVERRIDE |
| 900 { | 900 { |
| 901 m_layerTreeHost->setViewportSize(gfx::Size(40, 40), gfx::Size(60, 60)); | 901 m_layerTreeHost->setViewportSize(gfx::Size(40, 40), gfx::Size(60, 60)); |
| 902 m_layerTreeHost->setDeviceScaleFactor(1.5); | 902 m_layerTreeHost->setDeviceScaleFactor(1.5); |
| 903 EXPECT_EQ(gfx::Size(40, 40), m_layerTreeHost->layoutViewportSize()); | 903 EXPECT_EQ(gfx::Size(40, 40), m_layerTreeHost->layoutViewportSize()); |
| 904 EXPECT_EQ(gfx::Size(60, 60), m_layerTreeHost->deviceViewportSize()); | 904 EXPECT_EQ(gfx::Size(60, 60), m_layerTreeHost->deviceViewportSize()); |
| 905 | 905 |
| 906 m_rootLayer->addChild(m_childLayer); | 906 m_rootLayer->AddChild(m_childLayer); |
| 907 | 907 |
| 908 m_rootLayer->setIsDrawable(true); | 908 m_rootLayer->SetIsDrawable(true); |
| 909 m_rootLayer->setBounds(gfx::Size(30, 30)); | 909 m_rootLayer->SetBounds(gfx::Size(30, 30)); |
| 910 m_rootLayer->setAnchorPoint(gfx::PointF(0, 0)); | 910 m_rootLayer->SetAnchorPoint(gfx::PointF(0, 0)); |
| 911 | 911 |
| 912 m_childLayer->setIsDrawable(true); | 912 m_childLayer->SetIsDrawable(true); |
| 913 m_childLayer->setPosition(gfx::Point(2, 2)); | 913 m_childLayer->SetPosition(gfx::Point(2, 2)); |
| 914 m_childLayer->setBounds(gfx::Size(10, 10)); | 914 m_childLayer->SetBounds(gfx::Size(10, 10)); |
| 915 m_childLayer->setAnchorPoint(gfx::PointF(0, 0)); | 915 m_childLayer->SetAnchorPoint(gfx::PointF(0, 0)); |
| 916 | 916 |
| 917 m_layerTreeHost->setRootLayer(m_rootLayer); | 917 m_layerTreeHost->setRootLayer(m_rootLayer); |
| 918 | 918 |
| 919 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 919 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
| 920 ResourceUpdateQueue queue; | 920 ResourceUpdateQueue queue; |
| 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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 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.renderSurfaceLayerList; |
| 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->renderSurface(), renderSurfaceLayerList[0]->renderSurfac
e()); | 959 ASSERT_EQ(root->render_surface(), renderSurfaceLayerList[0]->render_surf
ace()); |
| 960 ASSERT_EQ(2u, root->renderSurface()->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->renderSurface()->content_r
ect()); | 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->contentBounds()); | 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->deviceScaleFactor(), impl->deviceScaleFactor(
)); |
| 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->drawTransform()); | 976 EXPECT_EQ(rootDrawTransform, root->draw_transform()); |
| 977 EXPECT_EQ(rootScreenSpaceTransform, root->screenSpaceTransform()); | 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; |
| 981 childScreenSpaceTransform.Translate(3, 3); | 981 childScreenSpaceTransform.Translate(3, 3); |
| 982 gfx::Transform childDrawTransform = childScreenSpaceTransform; | 982 gfx::Transform childDrawTransform = childScreenSpaceTransform; |
| 983 | 983 |
| 984 EXPECT_TRANSFORMATION_MATRIX_EQ(childDrawTransform, child->drawTransform
()); | 984 EXPECT_TRANSFORMATION_MATRIX_EQ(childDrawTransform, child->draw_transfor
m()); |
| 985 EXPECT_TRANSFORMATION_MATRIX_EQ(childScreenSpaceTransform, child->screen
SpaceTransform()); | 985 EXPECT_TRANSFORMATION_MATRIX_EQ(childScreenSpaceTransform, child->screen
_space_transform()); |
| 986 | 986 |
| 987 endTest(); | 987 endTest(); |
| 988 } | 988 } |
| 989 | 989 |
| 990 virtual void afterTest() OVERRIDE | 990 virtual void afterTest() OVERRIDE |
| 991 { | 991 { |
| 992 m_rootLayer = NULL; | 992 m_rootLayer = NULL; |
| 993 m_childLayer = NULL; | 993 m_childLayer = NULL; |
| 994 } | 994 } |
| 995 | 995 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1011 { | 1011 { |
| 1012 // Make sure partial texture updates are turned off. | 1012 // Make sure partial texture updates are turned off. |
| 1013 m_settings.maxPartialTextureUpdates = 0; | 1013 m_settings.maxPartialTextureUpdates = 0; |
| 1014 // Linear fade animator prevents scrollbars from drawing immediately. | 1014 // Linear fade animator prevents scrollbars from drawing immediately. |
| 1015 m_settings.useLinearFadeScrollbarAnimator = false; | 1015 m_settings.useLinearFadeScrollbarAnimator = false; |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 virtual void setupTree() OVERRIDE | 1018 virtual void setupTree() OVERRIDE |
| 1019 { | 1019 { |
| 1020 m_layer = FakeContentLayer::Create(&m_client); | 1020 m_layer = FakeContentLayer::Create(&m_client); |
| 1021 m_layer->setBounds(gfx::Size(10, 20)); | 1021 m_layer->SetBounds(gfx::Size(10, 20)); |
| 1022 | 1022 |
| 1023 bool paint_scrollbar = true; | 1023 bool paint_scrollbar = true; |
| 1024 bool has_thumb = false; | 1024 bool has_thumb = false; |
| 1025 m_scrollbar = FakeScrollbarLayer::Create( | 1025 m_scrollbar = FakeScrollbarLayer::Create( |
| 1026 paint_scrollbar, has_thumb, m_layer->id()); | 1026 paint_scrollbar, has_thumb, m_layer->id()); |
| 1027 m_scrollbar->setPosition(gfx::Point(0, 10)); | 1027 m_scrollbar->SetPosition(gfx::Point(0, 10)); |
| 1028 m_scrollbar->setBounds(gfx::Size(10, 10)); | 1028 m_scrollbar->SetBounds(gfx::Size(10, 10)); |
| 1029 | 1029 |
| 1030 m_layer->addChild(m_scrollbar); | 1030 m_layer->AddChild(m_scrollbar); |
| 1031 | 1031 |
| 1032 m_layerTreeHost->setRootLayer(m_layer); | 1032 m_layerTreeHost->setRootLayer(m_layer); |
| 1033 LayerTreeHostTest::setupTree(); | 1033 LayerTreeHostTest::setupTree(); |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 virtual void beginTest() OVERRIDE | 1036 virtual void beginTest() OVERRIDE |
| 1037 { | 1037 { |
| 1038 postSetNeedsCommitToMainThread(); | 1038 postSetNeedsCommitToMainThread(); |
| 1039 } | 1039 } |
| 1040 | 1040 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 { | 1086 { |
| 1087 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->outputSurface()->context3d()); | 1087 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D
*>(impl->outputSurface()->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(); |
| 1098 } | 1098 } |
| 1099 | 1099 |
| 1100 virtual void afterTest() OVERRIDE | 1100 virtual void afterTest() OVERRIDE |
| 1101 { | 1101 { |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 private: | 1104 private: |
| 1105 FakeContentLayerClient m_client; | 1105 FakeContentLayerClient m_client; |
| 1106 scoped_refptr<FakeContentLayer> m_layer; | 1106 scoped_refptr<FakeContentLayer> m_layer; |
| 1107 scoped_refptr<FakeScrollbarLayer> m_scrollbar; | 1107 scoped_refptr<FakeScrollbarLayer> m_scrollbar; |
| 1108 }; | 1108 }; |
| 1109 | 1109 |
| 1110 TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread) | 1110 TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread) |
| 1111 { | 1111 { |
| 1112 runTest(true); | 1112 runTest(true); |
| 1113 } | 1113 } |
| 1114 | 1114 |
| 1115 static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const gfx:
:Transform& transform, const gfx::PointF& anchor, const gfx::PointF& position, c
onst gfx::Size& bounds, bool opaque) | 1115 static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const gfx:
:Transform& transform, const gfx::PointF& anchor, const gfx::PointF& position, c
onst gfx::Size& bounds, bool opaque) |
| 1116 { | 1116 { |
| 1117 layer->removeAllChildren(); | 1117 layer->RemoveAllChildren(); |
| 1118 if (parent) | 1118 if (parent) |
| 1119 parent->addChild(layer); | 1119 parent->AddChild(layer); |
| 1120 layer->setTransform(transform); | 1120 layer->SetTransform(transform); |
| 1121 layer->setAnchorPoint(anchor); | 1121 layer->SetAnchorPoint(anchor); |
| 1122 layer->setPosition(position); | 1122 layer->SetPosition(position); |
| 1123 layer->setBounds(bounds); | 1123 layer->SetBounds(bounds); |
| 1124 layer->setContentsOpaque(opaque); | 1124 layer->SetContentsOpaque(opaque); |
| 1125 } | 1125 } |
| 1126 | 1126 |
| 1127 class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest
{ | 1127 class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest
{ |
| 1128 public: | 1128 public: |
| 1129 LayerTreeHostTestAtomicCommitWithPartialUpdate() | 1129 LayerTreeHostTestAtomicCommitWithPartialUpdate() |
| 1130 : m_numCommits(0) | 1130 : m_numCommits(0) |
| 1131 { | 1131 { |
| 1132 // Allow one partial texture update. | 1132 // Allow one partial texture update. |
| 1133 m_settings.maxPartialTextureUpdates = 1; | 1133 m_settings.maxPartialTextureUpdates = 1; |
| 1134 // Linear fade animator prevents scrollbars from drawing immediately. | 1134 // Linear fade animator prevents scrollbars from drawing immediately. |
| 1135 m_settings.useLinearFadeScrollbarAnimator = false; | 1135 m_settings.useLinearFadeScrollbarAnimator = false; |
| 1136 } | 1136 } |
| 1137 | 1137 |
| 1138 virtual void setupTree() OVERRIDE | 1138 virtual void setupTree() OVERRIDE |
| 1139 { | 1139 { |
| 1140 m_parent = FakeContentLayer::Create(&m_client); | 1140 parent_ = FakeContentLayer::Create(&m_client); |
| 1141 m_parent->setBounds(gfx::Size(10, 20)); | 1141 parent_->SetBounds(gfx::Size(10, 20)); |
| 1142 | 1142 |
| 1143 m_child = FakeContentLayer::Create(&m_client); | 1143 m_child = FakeContentLayer::Create(&m_client); |
| 1144 m_child->setPosition(gfx::Point(0, 10)); | 1144 m_child->SetPosition(gfx::Point(0, 10)); |
| 1145 m_child->setBounds(gfx::Size(3, 10)); | 1145 m_child->SetBounds(gfx::Size(3, 10)); |
| 1146 | 1146 |
| 1147 bool paint_scrollbar = true; | 1147 bool paint_scrollbar = true; |
| 1148 bool has_thumb = false; | 1148 bool has_thumb = false; |
| 1149 m_scrollbarWithPaints = FakeScrollbarLayer::Create( | 1149 m_scrollbarWithPaints = FakeScrollbarLayer::Create( |
| 1150 paint_scrollbar, has_thumb, m_parent->id()); | 1150 paint_scrollbar, has_thumb, parent_->id()); |
| 1151 m_scrollbarWithPaints->setPosition(gfx::Point(3, 10)); | 1151 m_scrollbarWithPaints->SetPosition(gfx::Point(3, 10)); |
| 1152 m_scrollbarWithPaints->setBounds(gfx::Size(3, 10)); | 1152 m_scrollbarWithPaints->SetBounds(gfx::Size(3, 10)); |
| 1153 | 1153 |
| 1154 paint_scrollbar = false; | 1154 paint_scrollbar = false; |
| 1155 m_scrollbarWithoutPaints = FakeScrollbarLayer::Create( | 1155 m_scrollbarWithoutPaints = FakeScrollbarLayer::Create( |
| 1156 paint_scrollbar, has_thumb, m_parent->id()); | 1156 paint_scrollbar, has_thumb, parent_->id()); |
| 1157 m_scrollbarWithoutPaints->setPosition(gfx::Point(6, 10)); | 1157 m_scrollbarWithoutPaints->SetPosition(gfx::Point(6, 10)); |
| 1158 m_scrollbarWithoutPaints->setBounds(gfx::Size(3, 10)); | 1158 m_scrollbarWithoutPaints->SetBounds(gfx::Size(3, 10)); |
| 1159 | 1159 |
| 1160 m_parent->addChild(m_child); | 1160 parent_->AddChild(m_child); |
| 1161 m_parent->addChild(m_scrollbarWithPaints); | 1161 parent_->AddChild(m_scrollbarWithPaints); |
| 1162 m_parent->addChild(m_scrollbarWithoutPaints); | 1162 parent_->AddChild(m_scrollbarWithoutPaints); |
| 1163 | 1163 |
| 1164 m_layerTreeHost->setRootLayer(m_parent); | 1164 m_layerTreeHost->setRootLayer(parent_); |
| 1165 LayerTreeHostTest::setupTree(); | 1165 LayerTreeHostTest::setupTree(); |
| 1166 } | 1166 } |
| 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 { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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++) { |
| 1277 case 0: | 1277 case 0: |
| 1278 case 1: | 1278 case 1: |
| 1279 m_parent->setNeedsDisplay(); | 1279 parent_->SetNeedsDisplay(); |
| 1280 m_child->setNeedsDisplay(); | 1280 m_child->SetNeedsDisplay(); |
| 1281 m_scrollbarWithPaints->setNeedsDisplay(); | 1281 m_scrollbarWithPaints->SetNeedsDisplay(); |
| 1282 m_scrollbarWithoutPaints->setNeedsDisplay(); | 1282 m_scrollbarWithoutPaints->SetNeedsDisplay(); |
| 1283 break; | 1283 break; |
| 1284 case 2: | 1284 case 2: |
| 1285 // Damage part of layers. | 1285 // Damage part of layers. |
| 1286 m_parent->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); | 1286 parent_->SetNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
| 1287 m_child->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); | 1287 m_child->SetNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
| 1288 m_scrollbarWithPaints->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); | 1288 m_scrollbarWithPaints->SetNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
| 1289 m_scrollbarWithoutPaints->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)
); | 1289 m_scrollbarWithoutPaints->SetNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)
); |
| 1290 break; | 1290 break; |
| 1291 case 3: | 1291 case 3: |
| 1292 m_child->setNeedsDisplay(); | 1292 m_child->SetNeedsDisplay(); |
| 1293 m_scrollbarWithPaints->setNeedsDisplay(); | 1293 m_scrollbarWithPaints->SetNeedsDisplay(); |
| 1294 m_scrollbarWithoutPaints->setNeedsDisplay(); | 1294 m_scrollbarWithoutPaints->SetNeedsDisplay(); |
| 1295 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10
)); | 1295 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10
)); |
| 1296 break; | 1296 break; |
| 1297 case 4: | 1297 case 4: |
| 1298 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20
)); | 1298 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20
)); |
| 1299 break; | 1299 break; |
| 1300 case 5: | 1300 case 5: |
| 1301 break; | 1301 break; |
| 1302 default: | 1302 default: |
| 1303 NOTREACHED(); | 1303 NOTREACHED(); |
| 1304 break; | 1304 break; |
| 1305 } | 1305 } |
| 1306 } | 1306 } |
| 1307 | 1307 |
| 1308 virtual void afterTest() OVERRIDE | 1308 virtual void afterTest() OVERRIDE |
| 1309 { | 1309 { |
| 1310 } | 1310 } |
| 1311 | 1311 |
| 1312 private: | 1312 private: |
| 1313 FakeContentLayerClient m_client; | 1313 FakeContentLayerClient m_client; |
| 1314 scoped_refptr<FakeContentLayer> m_parent; | 1314 scoped_refptr<FakeContentLayer> parent_; |
| 1315 scoped_refptr<FakeContentLayer> m_child; | 1315 scoped_refptr<FakeContentLayer> m_child; |
| 1316 scoped_refptr<FakeScrollbarLayer> m_scrollbarWithPaints; | 1316 scoped_refptr<FakeScrollbarLayer> m_scrollbarWithPaints; |
| 1317 scoped_refptr<FakeScrollbarLayer> m_scrollbarWithoutPaints; | 1317 scoped_refptr<FakeScrollbarLayer> m_scrollbarWithoutPaints; |
| 1318 int m_numCommits; | 1318 int m_numCommits; |
| 1319 }; | 1319 }; |
| 1320 | 1320 |
| 1321 TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread) | 1321 TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread) |
| 1322 { | 1322 { |
| 1323 runTest(true); | 1323 runTest(true); |
| 1324 } | 1324 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 class LayerTreeHostTestCompositeAndReadbackCleanup : public LayerTreeHostTest { | 1377 class LayerTreeHostTestCompositeAndReadbackCleanup : public LayerTreeHostTest { |
| 1378 public: | 1378 public: |
| 1379 LayerTreeHostTestCompositeAndReadbackCleanup() { } | 1379 LayerTreeHostTestCompositeAndReadbackCleanup() { } |
| 1380 | 1380 |
| 1381 virtual void beginTest() OVERRIDE | 1381 virtual void beginTest() OVERRIDE |
| 1382 { | 1382 { |
| 1383 Layer* rootLayer = m_layerTreeHost->rootLayer(); | 1383 Layer* rootLayer = m_layerTreeHost->rootLayer(); |
| 1384 | 1384 |
| 1385 char pixels[4]; | 1385 char pixels[4]; |
| 1386 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), gfx::
Rect(0, 0, 1, 1)); | 1386 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), gfx::
Rect(0, 0, 1, 1)); |
| 1387 EXPECT_FALSE(rootLayer->renderSurface()); | 1387 EXPECT_FALSE(rootLayer->render_surface()); |
| 1388 | 1388 |
| 1389 endTest(); | 1389 endTest(); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 virtual void afterTest() OVERRIDE | 1392 virtual void afterTest() OVERRIDE |
| 1393 { | 1393 { |
| 1394 } | 1394 } |
| 1395 }; | 1395 }; |
| 1396 | 1396 |
| 1397 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackCleanup) | 1397 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackCleanup) |
| 1398 | 1398 |
| 1399 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit : public L
ayerTreeHostTest { | 1399 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit : public L
ayerTreeHostTest { |
| 1400 public: | 1400 public: |
| 1401 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit() | 1401 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit() |
| 1402 : m_rootLayer(ContentLayerWithUpdateTracking::create(&m_fakeDelegate)) | 1402 : m_rootLayer(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate)) |
| 1403 , m_surfaceLayer1(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) | 1403 , m_surfaceLayer1(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate
)) |
| 1404 , m_replicaLayer1(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) | 1404 , m_replicaLayer1(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate
)) |
| 1405 , m_surfaceLayer2(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) | 1405 , m_surfaceLayer2(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate
)) |
| 1406 , m_replicaLayer2(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) | 1406 , m_replicaLayer2(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate
)) |
| 1407 { | 1407 { |
| 1408 } | 1408 } |
| 1409 | 1409 |
| 1410 virtual void initializeSettings(LayerTreeSettings& settings) OVERRIDE | 1410 virtual void initializeSettings(LayerTreeSettings& settings) OVERRIDE |
| 1411 { | 1411 { |
| 1412 settings.cacheRenderPassContents = true; | 1412 settings.cacheRenderPassContents = true; |
| 1413 } | 1413 } |
| 1414 | 1414 |
| 1415 virtual void beginTest() OVERRIDE | 1415 virtual void beginTest() OVERRIDE |
| 1416 { | 1416 { |
| 1417 m_layerTreeHost->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100
)); | 1417 m_layerTreeHost->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100
)); |
| 1418 | 1418 |
| 1419 m_rootLayer->setBounds(gfx::Size(100, 100)); | 1419 m_rootLayer->SetBounds(gfx::Size(100, 100)); |
| 1420 m_surfaceLayer1->setBounds(gfx::Size(100, 100)); | 1420 m_surfaceLayer1->SetBounds(gfx::Size(100, 100)); |
| 1421 m_surfaceLayer1->setForceRenderSurface(true); | 1421 m_surfaceLayer1->SetForceRenderSurface(true); |
| 1422 m_surfaceLayer1->setOpacity(0.5); | 1422 m_surfaceLayer1->SetOpacity(0.5); |
| 1423 m_surfaceLayer2->setBounds(gfx::Size(100, 100)); | 1423 m_surfaceLayer2->SetBounds(gfx::Size(100, 100)); |
| 1424 m_surfaceLayer2->setForceRenderSurface(true); | 1424 m_surfaceLayer2->SetForceRenderSurface(true); |
| 1425 m_surfaceLayer2->setOpacity(0.5); | 1425 m_surfaceLayer2->SetOpacity(0.5); |
| 1426 | 1426 |
| 1427 m_surfaceLayer1->setReplicaLayer(m_replicaLayer1.get()); | 1427 m_surfaceLayer1->SetReplicaLayer(m_replicaLayer1.get()); |
| 1428 m_surfaceLayer2->setReplicaLayer(m_replicaLayer2.get()); | 1428 m_surfaceLayer2->SetReplicaLayer(m_replicaLayer2.get()); |
| 1429 | 1429 |
| 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]->renderSurface()->RenderPassId(); | 1440 RenderPass::Id surface1RenderPassId = hostImpl->rootLayer()->children()[
0]->render_surface()->RenderPassId(); |
| 1441 RenderPass::Id surface2RenderPassId = hostImpl->rootLayer()->children()[
0]->children()[0]->renderSurface()->RenderPassId(); | 1441 RenderPass::Id surface2RenderPassId = hostImpl->rootLayer()->children()[
0]->children()[0]->render_surface()->RenderPassId(); |
| 1442 | 1442 |
| 1443 switch (hostImpl->activeTree()->source_frame_number()) { | 1443 switch (hostImpl->activeTree()->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; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1478 scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer1; | 1478 scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer1; |
| 1479 scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer1; | 1479 scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer1; |
| 1480 scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer2; | 1480 scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer2; |
| 1481 scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer2; | 1481 scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer2; |
| 1482 }; | 1482 }; |
| 1483 | 1483 |
| 1484 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOuts
ideMemoryLimit) | 1484 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOuts
ideMemoryLimit) |
| 1485 | 1485 |
| 1486 class EvictionTestLayer : public Layer { | 1486 class EvictionTestLayer : public Layer { |
| 1487 public: | 1487 public: |
| 1488 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr
(new EvictionTestLayer()); } | 1488 static scoped_refptr<EvictionTestLayer> Create() { return make_scoped_refptr
(new EvictionTestLayer()); } |
| 1489 | 1489 |
| 1490 virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, Rendering
Stats*) OVERRIDE; | 1490 virtual void Update(ResourceUpdateQueue*, const OcclusionTracker*, Rendering
Stats*) OVERRIDE; |
| 1491 virtual bool drawsContent() const OVERRIDE { return true; } | 1491 virtual bool DrawsContent() const OVERRIDE { return true; } |
| 1492 | 1492 |
| 1493 virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl* treeImpl) OVERR
IDE; | 1493 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* treeImpl) OVERR
IDE; |
| 1494 virtual void pushPropertiesTo(LayerImpl*) OVERRIDE; | 1494 virtual void PushPropertiesTo(LayerImpl*) OVERRIDE; |
| 1495 virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE; | 1495 virtual void SetTexturePriorities(const PriorityCalculator&) OVERRIDE; |
| 1496 | 1496 |
| 1497 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa
ckingTexture() : false; } | 1497 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa
ckingTexture() : false; } |
| 1498 | 1498 |
| 1499 private: | 1499 private: |
| 1500 EvictionTestLayer() : Layer() { } | 1500 EvictionTestLayer() : Layer() { } |
| 1501 virtual ~EvictionTestLayer() { } | 1501 virtual ~EvictionTestLayer() { } |
| 1502 | 1502 |
| 1503 void createTextureIfNeeded() | 1503 void createTextureIfNeeded() |
| 1504 { | 1504 { |
| 1505 if (m_texture.get()) | 1505 if (m_texture.get()) |
| 1506 return; | 1506 return; |
| 1507 m_texture = PrioritizedResource::create(layerTreeHost()->contentsTexture
Manager()); | 1507 m_texture = PrioritizedResource::create(layer_tree_host()->contentsTextu
reManager()); |
| 1508 m_texture->setDimensions(gfx::Size(10, 10), GL_RGBA); | 1508 m_texture->setDimensions(gfx::Size(10, 10), GL_RGBA); |
| 1509 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); | 1509 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 scoped_ptr<PrioritizedResource> m_texture; | 1512 scoped_ptr<PrioritizedResource> m_texture; |
| 1513 SkBitmap m_bitmap; | 1513 SkBitmap m_bitmap; |
| 1514 }; | 1514 }; |
| 1515 | 1515 |
| 1516 class EvictionTestLayerImpl : public LayerImpl { | 1516 class EvictionTestLayerImpl : public LayerImpl { |
| 1517 public: | 1517 public: |
| 1518 static scoped_ptr<EvictionTestLayerImpl> create(LayerTreeImpl* treeImpl, int
id) | 1518 static scoped_ptr<EvictionTestLayerImpl> Create(LayerTreeImpl* treeImpl, int
id) |
| 1519 { | 1519 { |
| 1520 return make_scoped_ptr(new EvictionTestLayerImpl(treeImpl, id)); | 1520 return make_scoped_ptr(new EvictionTestLayerImpl(treeImpl, id)); |
| 1521 } | 1521 } |
| 1522 virtual ~EvictionTestLayerImpl() { } | 1522 virtual ~EvictionTestLayerImpl() { } |
| 1523 | 1523 |
| 1524 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData&) OVERRIDE | 1524 virtual void AppendQuads(QuadSink* quad_sink, |
| 1525 AppendQuadsData* append_quads_data) OVERRIDE |
| 1525 { | 1526 { |
| 1526 ASSERT_TRUE(m_hasTexture); | 1527 ASSERT_TRUE(m_hasTexture); |
| 1527 ASSERT_NE(0u, layerTreeImpl()->resource_provider()->num_resources()); | 1528 ASSERT_NE(0u, layer_tree_impl()->resource_provider()->num_resources()); |
| 1528 } | 1529 } |
| 1529 | 1530 |
| 1530 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; } | 1531 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; } |
| 1531 | 1532 |
| 1532 private: | 1533 private: |
| 1533 EvictionTestLayerImpl(LayerTreeImpl* treeImpl, int id) | 1534 EvictionTestLayerImpl(LayerTreeImpl* treeImpl, int id) |
| 1534 : LayerImpl(treeImpl, id) | 1535 : LayerImpl(treeImpl, id) |
| 1535 , m_hasTexture(false) { } | 1536 , m_hasTexture(false) { } |
| 1536 | 1537 |
| 1537 bool m_hasTexture; | 1538 bool m_hasTexture; |
| 1538 }; | 1539 }; |
| 1539 | 1540 |
| 1540 void EvictionTestLayer::setTexturePriorities(const PriorityCalculator&) | 1541 void EvictionTestLayer::SetTexturePriorities(const PriorityCalculator&) |
| 1541 { | 1542 { |
| 1542 createTextureIfNeeded(); | 1543 createTextureIfNeeded(); |
| 1543 if (!m_texture.get()) | 1544 if (!m_texture.get()) |
| 1544 return; | 1545 return; |
| 1545 m_texture->setRequestPriority(PriorityCalculator::uiPriority(true)); | 1546 m_texture->setRequestPriority(PriorityCalculator::uiPriority(true)); |
| 1546 } | 1547 } |
| 1547 | 1548 |
| 1548 void EvictionTestLayer::update(ResourceUpdateQueue& queue, const OcclusionTracke
r*, RenderingStats*) | 1549 void EvictionTestLayer::Update(ResourceUpdateQueue* queue, const OcclusionTracke
r*, RenderingStats*) |
| 1549 { | 1550 { |
| 1550 createTextureIfNeeded(); | 1551 createTextureIfNeeded(); |
| 1551 if (!m_texture.get()) | 1552 if (!m_texture.get()) |
| 1552 return; | 1553 return; |
| 1553 | 1554 |
| 1554 gfx::Rect fullRect(0, 0, 10, 10); | 1555 gfx::Rect fullRect(0, 0, 10, 10); |
| 1555 ResourceUpdate upload = ResourceUpdate::Create( | 1556 ResourceUpdate upload = ResourceUpdate::Create( |
| 1556 m_texture.get(), &m_bitmap, fullRect, fullRect, gfx::Vector2d()); | 1557 m_texture.get(), &m_bitmap, fullRect, fullRect, gfx::Vector2d()); |
| 1557 queue.appendFullUpload(upload); | 1558 queue->appendFullUpload(upload); |
| 1558 } | 1559 } |
| 1559 | 1560 |
| 1560 scoped_ptr<LayerImpl> EvictionTestLayer::createLayerImpl(LayerTreeImpl* treeImpl
) | 1561 scoped_ptr<LayerImpl> EvictionTestLayer::CreateLayerImpl(LayerTreeImpl* treeImpl
) |
| 1561 { | 1562 { |
| 1562 return EvictionTestLayerImpl::create(treeImpl, m_layerId).PassAs<LayerImpl>(
); | 1563 return EvictionTestLayerImpl::Create(treeImpl, layer_id_).PassAs<LayerImpl>(
); |
| 1563 } | 1564 } |
| 1564 | 1565 |
| 1565 void EvictionTestLayer::pushPropertiesTo(LayerImpl* layerImpl) | 1566 void EvictionTestLayer::PushPropertiesTo(LayerImpl* layerImpl) |
| 1566 { | 1567 { |
| 1567 Layer::pushPropertiesTo(layerImpl); | 1568 Layer::PushPropertiesTo(layerImpl); |
| 1568 | 1569 |
| 1569 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l
ayerImpl); | 1570 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l
ayerImpl); |
| 1570 testLayerImpl->setHasTexture(m_texture->haveBackingTexture()); | 1571 testLayerImpl->setHasTexture(m_texture->haveBackingTexture()); |
| 1571 } | 1572 } |
| 1572 | 1573 |
| 1573 class LayerTreeHostTestEvictTextures : public LayerTreeHostTest { | 1574 class LayerTreeHostTestEvictTextures : public LayerTreeHostTest { |
| 1574 public: | 1575 public: |
| 1575 LayerTreeHostTestEvictTextures() | 1576 LayerTreeHostTestEvictTextures() |
| 1576 : m_layer(EvictionTestLayer::create()) | 1577 : m_layer(EvictionTestLayer::Create()) |
| 1577 , m_implForEvictTextures(0) | 1578 , m_implForEvictTextures(0) |
| 1578 , m_numCommits(0) | 1579 , m_numCommits(0) |
| 1579 { | 1580 { |
| 1580 } | 1581 } |
| 1581 | 1582 |
| 1582 virtual void beginTest() OVERRIDE | 1583 virtual void beginTest() OVERRIDE |
| 1583 { | 1584 { |
| 1584 m_layerTreeHost->setRootLayer(m_layer); | 1585 m_layerTreeHost->setRootLayer(m_layer); |
| 1585 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); | 1586 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); |
| 1586 | 1587 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 public: | 1708 public: |
| 1708 LayerTreeHostTestContinuousCommit() | 1709 LayerTreeHostTestContinuousCommit() |
| 1709 : m_numCommitComplete(0) | 1710 : m_numCommitComplete(0) |
| 1710 , m_numDrawLayers(0) | 1711 , m_numDrawLayers(0) |
| 1711 { | 1712 { |
| 1712 } | 1713 } |
| 1713 | 1714 |
| 1714 virtual void beginTest() OVERRIDE | 1715 virtual void beginTest() OVERRIDE |
| 1715 { | 1716 { |
| 1716 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 1717 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 1717 m_layerTreeHost->rootLayer()->setBounds(gfx::Size(10, 10)); | 1718 m_layerTreeHost->rootLayer()->SetBounds(gfx::Size(10, 10)); |
| 1718 | 1719 |
| 1719 postSetNeedsCommitToMainThread(); | 1720 postSetNeedsCommitToMainThread(); |
| 1720 } | 1721 } |
| 1721 | 1722 |
| 1722 virtual void didCommit() OVERRIDE | 1723 virtual void didCommit() OVERRIDE |
| 1723 { | 1724 { |
| 1724 if (m_numDrawLayers == 2) | 1725 if (m_numDrawLayers == 2) |
| 1725 return; | 1726 return; |
| 1726 postSetNeedsCommitToMainThread(); | 1727 postSetNeedsCommitToMainThread(); |
| 1727 } | 1728 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 public: | 1760 public: |
| 1760 LayerTreeHostTestContinuousInvalidate() | 1761 LayerTreeHostTestContinuousInvalidate() |
| 1761 : m_numCommitComplete(0) | 1762 : m_numCommitComplete(0) |
| 1762 , m_numDrawLayers(0) | 1763 , m_numDrawLayers(0) |
| 1763 { | 1764 { |
| 1764 } | 1765 } |
| 1765 | 1766 |
| 1766 virtual void beginTest() OVERRIDE | 1767 virtual void beginTest() OVERRIDE |
| 1767 { | 1768 { |
| 1768 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 1769 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 1769 m_layerTreeHost->rootLayer()->setBounds(gfx::Size(10, 10)); | 1770 m_layerTreeHost->rootLayer()->SetBounds(gfx::Size(10, 10)); |
| 1770 | 1771 |
| 1771 m_contentLayer = ContentLayer::create(&m_fakeDelegate); | 1772 m_contentLayer = ContentLayer::Create(&m_fakeDelegate); |
| 1772 m_contentLayer->setBounds(gfx::Size(10, 10)); | 1773 m_contentLayer->SetBounds(gfx::Size(10, 10)); |
| 1773 m_contentLayer->setPosition(gfx::PointF(0, 0)); | 1774 m_contentLayer->SetPosition(gfx::PointF(0, 0)); |
| 1774 m_contentLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1775 m_contentLayer->SetAnchorPoint(gfx::PointF(0, 0)); |
| 1775 m_contentLayer->setIsDrawable(true); | 1776 m_contentLayer->SetIsDrawable(true); |
| 1776 m_layerTreeHost->rootLayer()->addChild(m_contentLayer); | 1777 m_layerTreeHost->rootLayer()->AddChild(m_contentLayer); |
| 1777 | 1778 |
| 1778 postSetNeedsCommitToMainThread(); | 1779 postSetNeedsCommitToMainThread(); |
| 1779 } | 1780 } |
| 1780 | 1781 |
| 1781 virtual void didCommit() OVERRIDE | 1782 virtual void didCommit() OVERRIDE |
| 1782 { | 1783 { |
| 1783 if (m_numDrawLayers == 2) | 1784 if (m_numDrawLayers == 2) |
| 1784 return; | 1785 return; |
| 1785 m_contentLayer->setNeedsDisplay(); | 1786 m_contentLayer->SetNeedsDisplay(); |
| 1786 } | 1787 } |
| 1787 | 1788 |
| 1788 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 1789 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
| 1789 { | 1790 { |
| 1790 if (m_numDrawLayers == 1) | 1791 if (m_numDrawLayers == 1) |
| 1791 m_numCommitComplete++; | 1792 m_numCommitComplete++; |
| 1792 } | 1793 } |
| 1793 | 1794 |
| 1794 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1795 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
| 1795 { | 1796 { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1990 settings.maxPartialTextureUpdates = 4; | 1991 settings.maxPartialTextureUpdates = 4; |
| 1991 | 1992 |
| 1992 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); | 1993 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); |
| 1993 EXPECT_TRUE(host->initializeRendererIfNeeded()); | 1994 EXPECT_TRUE(host->initializeRendererIfNeeded()); |
| 1994 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); | 1995 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); |
| 1995 } | 1996 } |
| 1996 | 1997 |
| 1997 class LayerTreeHostTestCapturePicture : public LayerTreeHostTest { | 1998 class LayerTreeHostTestCapturePicture : public LayerTreeHostTest { |
| 1998 public: | 1999 public: |
| 1999 LayerTreeHostTestCapturePicture() | 2000 LayerTreeHostTestCapturePicture() |
| 2000 : m_bounds(gfx::Size(100, 100)) | 2001 : bounds_(gfx::Size(100, 100)) |
| 2001 , m_layer(PictureLayer::create(&m_contentClient)) | 2002 , m_layer(PictureLayer::Create(&m_contentClient)) |
| 2002 { | 2003 { |
| 2003 m_settings.implSidePainting = true; | 2004 m_settings.implSidePainting = true; |
| 2004 } | 2005 } |
| 2005 | 2006 |
| 2006 class FillRectContentLayerClient : public ContentLayerClient { | 2007 class FillRectContentLayerClient : public ContentLayerClient { |
| 2007 public: | 2008 public: |
| 2008 virtual void paintContents(SkCanvas* canvas, const gfx::Rect& clip, gfx:
:RectF& opaque) OVERRIDE | 2009 virtual void paintContents(SkCanvas* canvas, const gfx::Rect& clip, gfx:
:RectF& opaque) OVERRIDE |
| 2009 { | 2010 { |
| 2010 SkPaint paint; | 2011 SkPaint paint; |
| 2011 paint.setColor(SK_ColorGREEN); | 2012 paint.setColor(SK_ColorGREEN); |
| 2012 | 2013 |
| 2013 SkRect rect = SkRect::MakeWH(canvas->getDeviceSize().width(), canvas
->getDeviceSize().height()); | 2014 SkRect rect = SkRect::MakeWH(canvas->getDeviceSize().width(), canvas
->getDeviceSize().height()); |
| 2014 opaque = gfx::RectF(rect.width(), rect.height()); | 2015 opaque = gfx::RectF(rect.width(), rect.height()); |
| 2015 canvas->drawRect(rect, paint); | 2016 canvas->drawRect(rect, paint); |
| 2016 } | 2017 } |
| 2017 }; | 2018 }; |
| 2018 | 2019 |
| 2019 virtual void beginTest() OVERRIDE | 2020 virtual void beginTest() OVERRIDE |
| 2020 { | 2021 { |
| 2021 m_layer->setIsDrawable(true); | 2022 m_layer->SetIsDrawable(true); |
| 2022 m_layer->setBounds(m_bounds); | 2023 m_layer->SetBounds(bounds_); |
| 2023 m_layerTreeHost->setViewportSize(m_bounds, m_bounds); | 2024 m_layerTreeHost->setViewportSize(bounds_, bounds_); |
| 2024 m_layerTreeHost->setRootLayer(m_layer); | 2025 m_layerTreeHost->setRootLayer(m_layer); |
| 2025 | 2026 |
| 2026 EXPECT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 2027 EXPECT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
| 2027 postSetNeedsCommitToMainThread(); | 2028 postSetNeedsCommitToMainThread(); |
| 2028 } | 2029 } |
| 2029 | 2030 |
| 2030 virtual void didCommitAndDrawFrame() OVERRIDE | 2031 virtual void didCommitAndDrawFrame() OVERRIDE |
| 2031 { | 2032 { |
| 2032 m_picture = m_layerTreeHost->capturePicture(); | 2033 m_picture = m_layerTreeHost->capturePicture(); |
| 2033 endTest(); | 2034 endTest(); |
| 2034 } | 2035 } |
| 2035 | 2036 |
| 2036 virtual void afterTest() OVERRIDE | 2037 virtual void afterTest() OVERRIDE |
| 2037 { | 2038 { |
| 2038 EXPECT_EQ(m_bounds, gfx::Size(m_picture->width(), m_picture->height())); | 2039 EXPECT_EQ(bounds_, gfx::Size(m_picture->width(), m_picture->height())); |
| 2039 | 2040 |
| 2040 SkBitmap bitmap; | 2041 SkBitmap bitmap; |
| 2041 bitmap.setConfig(SkBitmap::kARGB_8888_Config, m_bounds.width(), m_bounds
.height()); | 2042 bitmap.setConfig(SkBitmap::kARGB_8888_Config, bounds_.width(), bounds_.h
eight()); |
| 2042 bitmap.allocPixels(); | 2043 bitmap.allocPixels(); |
| 2043 bitmap.eraseARGB(0, 0, 0, 0); | 2044 bitmap.eraseARGB(0, 0, 0, 0); |
| 2044 SkCanvas canvas(bitmap); | 2045 SkCanvas canvas(bitmap); |
| 2045 | 2046 |
| 2046 m_picture->draw(&canvas); | 2047 m_picture->draw(&canvas); |
| 2047 | 2048 |
| 2048 bitmap.lockPixels(); | 2049 bitmap.lockPixels(); |
| 2049 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels()); | 2050 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels()); |
| 2050 EXPECT_EQ(SK_ColorGREEN, pixels[0]); | 2051 EXPECT_EQ(SK_ColorGREEN, pixels[0]); |
| 2051 bitmap.unlockPixels(); | 2052 bitmap.unlockPixels(); |
| 2052 } | 2053 } |
| 2053 | 2054 |
| 2054 private: | 2055 private: |
| 2055 gfx::Size m_bounds; | 2056 gfx::Size bounds_; |
| 2056 FillRectContentLayerClient m_contentClient; | 2057 FillRectContentLayerClient m_contentClient; |
| 2057 scoped_refptr<PictureLayer> m_layer; | 2058 scoped_refptr<PictureLayer> m_layer; |
| 2058 skia::RefPtr<SkPicture> m_picture; | 2059 skia::RefPtr<SkPicture> m_picture; |
| 2059 }; | 2060 }; |
| 2060 | 2061 |
| 2061 MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicture); | 2062 MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicture); |
| 2062 | 2063 |
| 2063 class LayerTreeHostTestMaxPendingFrames : public LayerTreeHostTest { | 2064 class LayerTreeHostTestMaxPendingFrames : public LayerTreeHostTest { |
| 2064 public: | 2065 public: |
| 2065 LayerTreeHostTestMaxPendingFrames() | 2066 LayerTreeHostTestMaxPendingFrames() |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2117 : m_rootLayer(FakeContentLayer::Create(&m_client)) | 2118 : m_rootLayer(FakeContentLayer::Create(&m_client)) |
| 2118 , m_childLayer1(FakeContentLayer::Create(&m_client)) | 2119 , m_childLayer1(FakeContentLayer::Create(&m_client)) |
| 2119 , m_childLayer2(FakeContentLayer::Create(&m_client)) | 2120 , m_childLayer2(FakeContentLayer::Create(&m_client)) |
| 2120 , m_numCommits(0) | 2121 , m_numCommits(0) |
| 2121 { | 2122 { |
| 2122 } | 2123 } |
| 2123 | 2124 |
| 2124 virtual void beginTest() OVERRIDE | 2125 virtual void beginTest() OVERRIDE |
| 2125 { | 2126 { |
| 2126 m_layerTreeHost->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100
)); | 2127 m_layerTreeHost->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100
)); |
| 2127 m_rootLayer->setBounds(gfx::Size(100, 100)); | 2128 m_rootLayer->SetBounds(gfx::Size(100, 100)); |
| 2128 m_childLayer1->setBounds(gfx::Size(100, 100)); | 2129 m_childLayer1->SetBounds(gfx::Size(100, 100)); |
| 2129 m_childLayer2->setBounds(gfx::Size(100, 100)); | 2130 m_childLayer2->SetBounds(gfx::Size(100, 100)); |
| 2130 m_rootLayer->addChild(m_childLayer1); | 2131 m_rootLayer->AddChild(m_childLayer1); |
| 2131 m_rootLayer->addChild(m_childLayer2); | 2132 m_rootLayer->AddChild(m_childLayer2); |
| 2132 m_layerTreeHost->setRootLayer(m_rootLayer); | 2133 m_layerTreeHost->setRootLayer(m_rootLayer); |
| 2133 postSetNeedsCommitToMainThread(); | 2134 postSetNeedsCommitToMainThread(); |
| 2134 } | 2135 } |
| 2135 | 2136 |
| 2136 virtual void didSetVisibleOnImplTree(LayerTreeHostImpl* hostImpl, bool visib
le) OVERRIDE | 2137 virtual void didSetVisibleOnImplTree(LayerTreeHostImpl* hostImpl, bool visib
le) OVERRIDE |
| 2137 { | 2138 { |
| 2138 // One backing should remain unevicted. | 2139 // One backing should remain unevicted. |
| 2139 EXPECT_EQ( | 2140 EXPECT_EQ( |
| 2140 100 * 100 * 4 * 1, | 2141 100 * 100 * 4 * 1, |
| 2141 m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); | 2142 m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2189 scoped_refptr<FakeContentLayer> m_rootLayer; | 2190 scoped_refptr<FakeContentLayer> m_rootLayer; |
| 2190 scoped_refptr<FakeContentLayer> m_childLayer1; | 2191 scoped_refptr<FakeContentLayer> m_childLayer1; |
| 2191 scoped_refptr<FakeContentLayer> m_childLayer2; | 2192 scoped_refptr<FakeContentLayer> m_childLayer2; |
| 2192 int m_numCommits; | 2193 int m_numCommits; |
| 2193 }; | 2194 }; |
| 2194 | 2195 |
| 2195 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvi
cted) | 2196 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvi
cted) |
| 2196 | 2197 |
| 2197 } // namespace | 2198 } // namespace |
| 2198 } // namespace cc | 2199 } // namespace cc |
| OLD | NEW |