Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: cc/tiled_layer_unittest.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiled_layer_impl_unittest.cc ('k') | cc/tree_synchronizer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "cc/tiled_layer.h" 7 #include "cc/tiled_layer.h"
8 8
9 #include "cc/bitmap_content_layer_updater.h" 9 #include "cc/bitmap_content_layer_updater.h"
10 #include "cc/layer_painter.h" 10 #include "cc/layer_painter.h"
11 #include "cc/overdraw_metrics.h" 11 #include "cc/overdraw_metrics.h"
12 #include "cc/rendering_stats.h" 12 #include "cc/rendering_stats.h"
13 #include "cc/resource_update_controller.h" 13 #include "cc/resource_update_controller.h"
14 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread 14 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
15 #include "cc/test/animation_test_common.h" 15 #include "cc/test/animation_test_common.h"
16 #include "cc/test/fake_graphics_context.h" 16 #include "cc/test/fake_graphics_context.h"
17 #include "cc/test/fake_layer_tree_host_client.h" 17 #include "cc/test/fake_layer_tree_host_client.h"
18 #include "cc/test/fake_proxy.h"
18 #include "cc/test/geometry_test_utils.h" 19 #include "cc/test/geometry_test_utils.h"
19 #include "cc/test/tiled_layer_test_common.h" 20 #include "cc/test/tiled_layer_test_common.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/gfx/rect_conversions.h" 22 #include "ui/gfx/rect_conversions.h"
22 #include <public/WebTransformationMatrix.h> 23 #include <public/WebTransformationMatrix.h>
23 24
24 using namespace cc; 25 using namespace cc;
25 using namespace WebKitTests; 26 using namespace WebKitTests;
26 using WebKit::WebTransformationMatrix; 27 using WebKit::WebTransformationMatrix;
27 28
(...skipping 14 matching lines...) Expand all
42 protected: 43 protected:
43 virtual gfx::Rect layerClipRectInTarget(const Layer* layer) const OVERRIDE { return m_layerClipRectInTarget; } 44 virtual gfx::Rect layerClipRectInTarget(const Layer* layer) const OVERRIDE { return m_layerClipRectInTarget; }
44 45
45 private: 46 private:
46 gfx::Rect m_layerClipRectInTarget; 47 gfx::Rect m_layerClipRectInTarget;
47 }; 48 };
48 49
49 class TiledLayerTest : public testing::Test { 50 class TiledLayerTest : public testing::Test {
50 public: 51 public:
51 TiledLayerTest() 52 TiledLayerTest()
52 : m_context(WebKit::createFakeGraphicsContext()) 53 : m_proxy(NULL)
54 , m_context(WebKit::createFakeGraphicsContext())
53 , m_queue(make_scoped_ptr(new ResourceUpdateQueue)) 55 , m_queue(make_scoped_ptr(new ResourceUpdateQueue))
54 , m_resourceManager(PrioritizedResourceManager::create(60*1024*1024, 102 4, Renderer::ContentPool))
55 , m_occlusion(0) 56 , m_occlusion(0)
56 { 57 {
57 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 58 }
59
60 virtual void SetUp()
61 {
62 m_layerTreeHost = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient, m_settings, scoped_ptr<Thread>(NULL));
63 m_proxy = m_layerTreeHost->proxy();
64 m_resourceManager = PrioritizedResourceManager::create(60*1024*1024, 102 4, Renderer::ContentPool, m_proxy);
65 m_layerTreeHost->initializeRendererIfNeeded();
66 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
58 m_resourceProvider = ResourceProvider::create(m_context.get()); 67 m_resourceProvider = ResourceProvider::create(m_context.get());
59 } 68 }
60 69
61 virtual ~TiledLayerTest() 70 virtual ~TiledLayerTest()
62 { 71 {
63 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide r.get()); 72 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide r.get());
64 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 73 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
65 m_resourceProvider.reset(); 74 m_resourceProvider.reset();
66 } 75 }
67 76
68 // Helper classes and functions that set the current thread to be the impl t hread
69 // before doing the action that they wrap.
70 class ScopedFakeTiledLayerImpl { 77 class ScopedFakeTiledLayerImpl {
71 public: 78 public:
72 ScopedFakeTiledLayerImpl(int id) 79 ScopedFakeTiledLayerImpl(int id)
73 { 80 {
74 DebugScopedSetImplThread implThread;
75 m_layerImpl = new FakeTiledLayerImpl(id); 81 m_layerImpl = new FakeTiledLayerImpl(id);
76 } 82 }
77 ~ScopedFakeTiledLayerImpl() 83 ~ScopedFakeTiledLayerImpl()
78 { 84 {
79 DebugScopedSetImplThread implThread;
80 delete m_layerImpl; 85 delete m_layerImpl;
81 } 86 }
82 FakeTiledLayerImpl* get() 87 FakeTiledLayerImpl* get()
83 { 88 {
84 return m_layerImpl; 89 return m_layerImpl;
85 } 90 }
86 FakeTiledLayerImpl* operator->() 91 FakeTiledLayerImpl* operator->()
87 { 92 {
88 return m_layerImpl; 93 return m_layerImpl;
89 } 94 }
90 private: 95 private:
91 FakeTiledLayerImpl* m_layerImpl; 96 FakeTiledLayerImpl* m_layerImpl;
92 }; 97 };
93 void resourceManagerClearAllMemory(PrioritizedResourceManager* resourceManag er, ResourceProvider* resourceProvider) 98 void resourceManagerClearAllMemory(PrioritizedResourceManager* resourceManag er, ResourceProvider* resourceProvider)
94 { 99 {
95 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 100 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
96 resourceManager->clearAllMemory(resourceProvider); 101 resourceManager->clearAllMemory(resourceProvider);
97 resourceManager->reduceMemory(resourceProvider); 102 resourceManager->reduceMemory(resourceProvider);
98 } 103 }
99 void updateTextures() 104 void updateTextures()
100 { 105 {
101 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 106 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
102 DCHECK(m_queue); 107 DCHECK(m_queue);
103 scoped_ptr<ResourceUpdateController> updateController = 108 scoped_ptr<ResourceUpdateController> updateController =
104 ResourceUpdateController::create( 109 ResourceUpdateController::create(
105 NULL, 110 NULL,
106 Proxy::implThread(), 111 m_proxy->implThread(),
107 m_queue.Pass(), 112 m_queue.Pass(),
108 m_resourceProvider.get()); 113 m_resourceProvider.get(),
114 m_proxy->hasImplThread());
109 updateController->finalize(); 115 updateController->finalize();
110 m_queue = make_scoped_ptr(new ResourceUpdateQueue); 116 m_queue = make_scoped_ptr(new ResourceUpdateQueue);
111 } 117 }
112 void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerI mpl) 118 void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerI mpl)
113 { 119 {
114 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 120 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
115 layer->pushPropertiesTo(layerImpl); 121 layer->pushPropertiesTo(layerImpl);
116 } 122 }
117 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) 123 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded)
118 { 124 {
119 DebugScopedSetMainThread mainThread; 125 DebugScopedSetMainThread mainThread(m_proxy);
120 layer->update(*m_queue.get(), occluded, m_stats); 126 layer->update(*m_queue.get(), occluded, m_stats);
121 } 127 }
122 128
123 bool updateAndPush(FakeTiledLayer* layer1, 129 bool updateAndPush(FakeTiledLayer* layer1,
124 FakeTiledLayerImpl* layerImpl1, 130 FakeTiledLayerImpl* layerImpl1,
125 FakeTiledLayer* layer2 = 0, 131 FakeTiledLayer* layer2 = 0,
126 FakeTiledLayerImpl* layerImpl2 = 0) 132 FakeTiledLayerImpl* layerImpl2 = 0)
127 { 133 {
128 // Get textures 134 // Get textures
129 m_resourceManager->clearPriorities(); 135 m_resourceManager->clearPriorities();
(...skipping 19 matching lines...) Expand all
149 updateTextures(); 155 updateTextures();
150 if (layer1) 156 if (layer1)
151 layerPushPropertiesTo(layer1, layerImpl1); 157 layerPushPropertiesTo(layer1, layerImpl1);
152 if (layer2) 158 if (layer2)
153 layerPushPropertiesTo(layer2, layerImpl2); 159 layerPushPropertiesTo(layer2, layerImpl2);
154 160
155 return needsUpdate; 161 return needsUpdate;
156 } 162 }
157 163
158 public: 164 public:
165 Proxy* m_proxy;
166 LayerTreeSettings m_settings;
159 scoped_ptr<GraphicsContext> m_context; 167 scoped_ptr<GraphicsContext> m_context;
160 scoped_ptr<ResourceProvider> m_resourceProvider; 168 scoped_ptr<ResourceProvider> m_resourceProvider;
161 scoped_ptr<ResourceUpdateQueue> m_queue; 169 scoped_ptr<ResourceUpdateQueue> m_queue;
162 RenderingStats m_stats; 170 RenderingStats m_stats;
163 PriorityCalculator m_priorityCalculator; 171 PriorityCalculator m_priorityCalculator;
172 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient;
173 scoped_ptr<LayerTreeHost> m_layerTreeHost;
164 scoped_ptr<PrioritizedResourceManager> m_resourceManager; 174 scoped_ptr<PrioritizedResourceManager> m_resourceManager;
165 TestOcclusionTracker* m_occlusion; 175 TestOcclusionTracker* m_occlusion;
166 }; 176 };
167 177
168 TEST_F(TiledLayerTest, pushDirtyTiles) 178 TEST_F(TiledLayerTest, pushDirtyTiles)
169 { 179 {
170 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 180 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
171 ScopedFakeTiledLayerImpl layerImpl(1); 181 ScopedFakeTiledLayerImpl layerImpl(1);
172 182
173 // The tile size is 100x100, so this invalidates and then paints two tiles. 183 // The tile size is 100x100, so this invalidates and then paints two tiles.
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); 515 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1));
506 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); 516 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0));
507 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); 517 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1));
508 } 518 }
509 519
510 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately) 520 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
511 { 521 {
512 // Create a LayerTreeHost that has the right viewportsize, 522 // Create a LayerTreeHost that has the right viewportsize,
513 // so the layer is considered small enough. 523 // so the layer is considered small enough.
514 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; 524 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
515 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, LayerTreeSettings()); 525 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, LayerTreeSettings(), scoped_ptr<Thread>(NULL));
516 526
517 bool runOutOfMemory[2] = {false, true}; 527 bool runOutOfMemory[2] = {false, true};
518 for (int i = 0; i < 2; i++) { 528 for (int i = 0; i < 2; i++) {
519 // Create a layer with 4x4 tiles. 529 // Create a layer with 4x4 tiles.
520 int layerWidth = 4 * FakeTiledLayer::tileSize().width(); 530 int layerWidth = 4 * FakeTiledLayer::tileSize().width();
521 int layerHeight = 4 * FakeTiledLayer::tileSize().height(); 531 int layerHeight = 4 * FakeTiledLayer::tileSize().height();
522 int memoryForLayer = layerWidth * layerHeight * 4; 532 int memoryForLayer = layerWidth * layerHeight * 4;
523 gfx::Size viewportSize = gfx::Size(layerWidth, layerHeight); 533 gfx::Size viewportSize = gfx::Size(layerWidth, layerHeight);
524 layerTreeHost->setViewportSize(viewportSize, viewportSize); 534 layerTreeHost->setViewportSize(viewportSize, viewportSize);
525 535
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 781
772 layerPushPropertiesTo(layer.get(), layerImpl.get()); 782 layerPushPropertiesTo(layer.get(), layerImpl.get());
773 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); 783 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
774 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 784 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
775 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); 785 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0));
776 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); 786 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1));
777 } 787 }
778 788
779 TEST_F(TiledLayerTest, skipsDrawGetsReset) 789 TEST_F(TiledLayerTest, skipsDrawGetsReset)
780 { 790 {
781 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
782 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, LayerTreeSettings());
783 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded());
784
785 // Create two 300 x 300 tiled layers. 791 // Create two 300 x 300 tiled layers.
786 gfx::Size contentBounds(300, 300); 792 gfx::Size contentBounds(300, 300);
787 gfx::Rect contentRect(gfx::Point(), contentBounds); 793 gfx::Rect contentRect(gfx::Point(), contentBounds);
788 794
789 // We have enough memory for only one of the two layers. 795 // We have enough memory for only one of the two layers.
790 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. 796 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel.
791 797
792 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa yer(layerTreeHost->contentsTextureManager())); 798 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa yer(m_layerTreeHost->contentsTextureManager()));
793 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL ayer(layerTreeHost->contentsTextureManager())); 799 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL ayer(m_layerTreeHost->contentsTextureManager()));
794 rootLayer->addChild(childLayer); 800 rootLayer->addChild(childLayer);
795 801
796 rootLayer->setBounds(contentBounds); 802 rootLayer->setBounds(contentBounds);
797 rootLayer->setVisibleContentRect(contentRect); 803 rootLayer->setVisibleContentRect(contentRect);
798 rootLayer->setPosition(gfx::PointF(0, 0)); 804 rootLayer->setPosition(gfx::PointF(0, 0));
799 childLayer->setBounds(contentBounds); 805 childLayer->setBounds(contentBounds);
800 childLayer->setVisibleContentRect(contentRect); 806 childLayer->setVisibleContentRect(contentRect);
801 childLayer->setPosition(gfx::PointF(0, 0)); 807 childLayer->setPosition(gfx::PointF(0, 0));
802 rootLayer->invalidateContentRect(contentRect); 808 rootLayer->invalidateContentRect(contentRect);
803 childLayer->invalidateContentRect(contentRect); 809 childLayer->invalidateContentRect(contentRect);
804 810
805 layerTreeHost->setRootLayer(rootLayer); 811 m_layerTreeHost->setRootLayer(rootLayer);
806 layerTreeHost->setViewportSize(gfx::Size(300, 300), gfx::Size(300, 300)); 812 m_layerTreeHost->setViewportSize(gfx::Size(300, 300), gfx::Size(300, 300));
807 813
808 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); 814 m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
809 815
810 // We'll skip the root layer. 816 // We'll skip the root layer.
811 EXPECT_TRUE(rootLayer->skipsDraw()); 817 EXPECT_TRUE(rootLayer->skipsDraw());
812 EXPECT_FALSE(childLayer->skipsDraw()); 818 EXPECT_FALSE(childLayer->skipsDraw());
813 819
814 layerTreeHost->commitComplete(); 820 m_layerTreeHost->commitComplete();
815 821
816 // Remove the child layer. 822 // Remove the child layer.
817 rootLayer->removeAllChildren(); 823 rootLayer->removeAllChildren();
818 824
819 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); 825 m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
820 EXPECT_FALSE(rootLayer->skipsDraw()); 826 EXPECT_FALSE(rootLayer->skipsDraw());
821 827
822 resourceManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_res ourceProvider.get()); 828 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r esourceProvider.get());
823 layerTreeHost->setRootLayer(0); 829 m_layerTreeHost->setRootLayer(0);
824 } 830 }
825 831
826 TEST_F(TiledLayerTest, resizeToSmaller) 832 TEST_F(TiledLayerTest, resizeToSmaller)
827 { 833 {
828 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 834 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
829 835
830 layer->setBounds(gfx::Size(700, 700)); 836 layer->setBounds(gfx::Size(700, 700));
831 layer->setVisibleContentRect(gfx::Rect(0, 0, 700, 700)); 837 layer->setVisibleContentRect(gfx::Rect(0, 0, 700, 700));
832 layer->invalidateContentRect(gfx::Rect(0, 0, 700, 700)); 838 layer->invalidateContentRect(gfx::Rect(0, 0, 700, 700));
833 839
(...skipping 13 matching lines...) Expand all
847 layer->setBounds(gfx::Size(size, size)); 853 layer->setBounds(gfx::Size(size, size));
848 layer->setVisibleContentRect(gfx::Rect(0, 0, 700, 700)); 854 layer->setVisibleContentRect(gfx::Rect(0, 0, 700, 700));
849 layer->invalidateContentRect(gfx::Rect(0, 0, size, size)); 855 layer->invalidateContentRect(gfx::Rect(0, 0, size, size));
850 856
851 // Ensure no crash for bounds where size * size would overflow an int. 857 // Ensure no crash for bounds where size * size would overflow an int.
852 layer->setTexturePriorities(m_priorityCalculator); 858 layer->setTexturePriorities(m_priorityCalculator);
853 m_resourceManager->prioritizeTextures(); 859 m_resourceManager->prioritizeTextures();
854 layer->update(*m_queue.get(), 0, m_stats); 860 layer->update(*m_queue.get(), 0, m_stats);
855 } 861 }
856 862
857 TEST_F(TiledLayerTest, partialUpdates) 863 class TiledLayerPartialUpdateTest : public TiledLayerTest {
864 public:
865 TiledLayerPartialUpdateTest()
866 {
867 m_settings.maxPartialTextureUpdates = 4;
868 }
869 };
870
871 TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
858 { 872 {
859 LayerTreeSettings settings;
860 settings.maxPartialTextureUpdates = 4;
861
862 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
863 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, settings);
864 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded());
865
866 // Create one 300 x 200 tiled layer with 3 x 2 tiles. 873 // Create one 300 x 200 tiled layer with 3 x 2 tiles.
867 gfx::Size contentBounds(300, 200); 874 gfx::Size contentBounds(300, 200);
868 gfx::Rect contentRect(gfx::Point(), contentBounds); 875 gfx::Rect contentRect(gfx::Point(), contentBounds);
869 876
870 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( layerTreeHost->contentsTextureManager())); 877 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_layerTreeHost->contentsTextureManager()));
871 layer->setBounds(contentBounds); 878 layer->setBounds(contentBounds);
872 layer->setPosition(gfx::PointF(0, 0)); 879 layer->setPosition(gfx::PointF(0, 0));
873 layer->setVisibleContentRect(contentRect); 880 layer->setVisibleContentRect(contentRect);
874 layer->invalidateContentRect(contentRect); 881 layer->invalidateContentRect(contentRect);
875 882
876 layerTreeHost->setRootLayer(layer); 883 m_layerTreeHost->setRootLayer(layer);
877 layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); 884 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200));
878 885
879 // Full update of all 6 tiles. 886 // Full update of all 6 tiles.
880 layerTreeHost->updateLayers( 887 m_layerTreeHost->updateLayers(
881 *m_queue.get(), std::numeric_limits<size_t>::max()); 888 *m_queue.get(), std::numeric_limits<size_t>::max());
882 { 889 {
883 ScopedFakeTiledLayerImpl layerImpl(1); 890 ScopedFakeTiledLayerImpl layerImpl(1);
884 EXPECT_EQ(6, m_queue->fullUploadSize()); 891 EXPECT_EQ(6, m_queue->fullUploadSize());
885 EXPECT_EQ(0, m_queue->partialUploadSize()); 892 EXPECT_EQ(0, m_queue->partialUploadSize());
886 updateTextures(); 893 updateTextures();
887 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 894 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
888 EXPECT_FALSE(m_queue->hasMoreUpdates()); 895 EXPECT_FALSE(m_queue->hasMoreUpdates());
889 layer->fakeLayerUpdater()->clearUpdateCount(); 896 layer->fakeLayerUpdater()->clearUpdateCount();
890 layerPushPropertiesTo(layer.get(), layerImpl.get()); 897 layerPushPropertiesTo(layer.get(), layerImpl.get());
891 } 898 }
892 layerTreeHost->commitComplete(); 899 m_layerTreeHost->commitComplete();
893 900
894 // Full update of 3 tiles and partial update of 3 tiles. 901 // Full update of 3 tiles and partial update of 3 tiles.
895 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); 902 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150));
896 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max ()); 903 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m ax());
897 { 904 {
898 ScopedFakeTiledLayerImpl layerImpl(1); 905 ScopedFakeTiledLayerImpl layerImpl(1);
899 EXPECT_EQ(3, m_queue->fullUploadSize()); 906 EXPECT_EQ(3, m_queue->fullUploadSize());
900 EXPECT_EQ(3, m_queue->partialUploadSize()); 907 EXPECT_EQ(3, m_queue->partialUploadSize());
901 updateTextures(); 908 updateTextures();
902 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 909 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
903 EXPECT_FALSE(m_queue->hasMoreUpdates()); 910 EXPECT_FALSE(m_queue->hasMoreUpdates());
904 layer->fakeLayerUpdater()->clearUpdateCount(); 911 layer->fakeLayerUpdater()->clearUpdateCount();
905 layerPushPropertiesTo(layer.get(), layerImpl.get()); 912 layerPushPropertiesTo(layer.get(), layerImpl.get());
906 } 913 }
907 layerTreeHost->commitComplete(); 914 m_layerTreeHost->commitComplete();
908 915
909 // Partial update of 6 tiles. 916 // Partial update of 6 tiles.
910 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); 917 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
911 { 918 {
912 ScopedFakeTiledLayerImpl layerImpl(1); 919 ScopedFakeTiledLayerImpl layerImpl(1);
913 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>: :max()); 920 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max());
914 EXPECT_EQ(2, m_queue->fullUploadSize()); 921 EXPECT_EQ(2, m_queue->fullUploadSize());
915 EXPECT_EQ(4, m_queue->partialUploadSize()); 922 EXPECT_EQ(4, m_queue->partialUploadSize());
916 updateTextures(); 923 updateTextures();
917 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 924 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
918 EXPECT_FALSE(m_queue->hasMoreUpdates()); 925 EXPECT_FALSE(m_queue->hasMoreUpdates());
919 layer->fakeLayerUpdater()->clearUpdateCount(); 926 layer->fakeLayerUpdater()->clearUpdateCount();
920 layerPushPropertiesTo(layer.get(), layerImpl.get()); 927 layerPushPropertiesTo(layer.get(), layerImpl.get());
921 } 928 }
922 layerTreeHost->commitComplete(); 929 m_layerTreeHost->commitComplete();
923 930
924 // Checkerboard all tiles. 931 // Checkerboard all tiles.
925 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); 932 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200));
926 { 933 {
927 ScopedFakeTiledLayerImpl layerImpl(1); 934 ScopedFakeTiledLayerImpl layerImpl(1);
928 layerPushPropertiesTo(layer.get(), layerImpl.get()); 935 layerPushPropertiesTo(layer.get(), layerImpl.get());
929 } 936 }
930 layerTreeHost->commitComplete(); 937 m_layerTreeHost->commitComplete();
931 938
932 // Partial update of 6 checkerboard tiles. 939 // Partial update of 6 checkerboard tiles.
933 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); 940 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
934 { 941 {
935 ScopedFakeTiledLayerImpl layerImpl(1); 942 ScopedFakeTiledLayerImpl layerImpl(1);
936 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>: :max()); 943 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max());
937 EXPECT_EQ(6, m_queue->fullUploadSize()); 944 EXPECT_EQ(6, m_queue->fullUploadSize());
938 EXPECT_EQ(0, m_queue->partialUploadSize()); 945 EXPECT_EQ(0, m_queue->partialUploadSize());
939 updateTextures(); 946 updateTextures();
940 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 947 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
941 EXPECT_FALSE(m_queue->hasMoreUpdates()); 948 EXPECT_FALSE(m_queue->hasMoreUpdates());
942 layer->fakeLayerUpdater()->clearUpdateCount(); 949 layer->fakeLayerUpdater()->clearUpdateCount();
943 layerPushPropertiesTo(layer.get(), layerImpl.get()); 950 layerPushPropertiesTo(layer.get(), layerImpl.get());
944 } 951 }
945 layerTreeHost->commitComplete(); 952 m_layerTreeHost->commitComplete();
946 953
947 // Partial update of 4 tiles. 954 // Partial update of 4 tiles.
948 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); 955 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100));
949 { 956 {
950 ScopedFakeTiledLayerImpl layerImpl(1); 957 ScopedFakeTiledLayerImpl layerImpl(1);
951 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>: :max()); 958 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max());
952 EXPECT_EQ(0, m_queue->fullUploadSize()); 959 EXPECT_EQ(0, m_queue->fullUploadSize());
953 EXPECT_EQ(4, m_queue->partialUploadSize()); 960 EXPECT_EQ(4, m_queue->partialUploadSize());
954 updateTextures(); 961 updateTextures();
955 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); 962 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount());
956 EXPECT_FALSE(m_queue->hasMoreUpdates()); 963 EXPECT_FALSE(m_queue->hasMoreUpdates());
957 layer->fakeLayerUpdater()->clearUpdateCount(); 964 layer->fakeLayerUpdater()->clearUpdateCount();
958 layerPushPropertiesTo(layer.get(), layerImpl.get()); 965 layerPushPropertiesTo(layer.get(), layerImpl.get());
959 } 966 }
960 layerTreeHost->commitComplete(); 967 m_layerTreeHost->commitComplete();
961 968
962 resourceManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_res ourceProvider.get()); 969 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r esourceProvider.get());
963 layerTreeHost->setRootLayer(0); 970 m_layerTreeHost->setRootLayer(0);
964 } 971 }
965 972
966 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) 973 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion)
967 { 974 {
968 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 975 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
969 976
970 // The tile size is 100x100, so this invalidates and then paints two tiles. 977 // The tile size is 100x100, so this invalidates and then paints two tiles.
971 layer->setBounds(gfx::Size(100, 200)); 978 layer->setBounds(gfx::Size(100, 200));
972 layer->setDrawableContentRect(gfx::Rect(0, 0, 100, 200)); 979 layer->setDrawableContentRect(gfx::Rect(0, 0, 100, 200));
973 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); 980 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200));
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); 1381 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
1375 } 1382 }
1376 1383
1377 TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated) 1384 TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
1378 { 1385 {
1379 // Tile size is 100x100. 1386 // Tile size is 100x100.
1380 gfx::Rect rootRect(0, 0, 300, 200); 1387 gfx::Rect rootRect(0, 0, 300, 200);
1381 gfx::Rect childRect(0, 0, 300, 100); 1388 gfx::Rect childRect(0, 0, 300, 100);
1382 gfx::Rect child2Rect(0, 100, 300, 100); 1389 gfx::Rect child2Rect(0, 100, 300, 100);
1383 1390
1384 LayerTreeSettings settings; 1391 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(m _layerTreeHost->contentsTextureManager()));
1385 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
1386 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, settings);
1387 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded());
1388
1389 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(l ayerTreeHost->contentsTextureManager()));
1390 scoped_refptr<Layer> surface = Layer::create(); 1392 scoped_refptr<Layer> surface = Layer::create();
1391 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer( layerTreeHost->contentsTextureManager())); 1393 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer( m_layerTreeHost->contentsTextureManager()));
1392 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer (layerTreeHost->contentsTextureManager())); 1394 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer (m_layerTreeHost->contentsTextureManager()));
1393 1395
1394 root->setBounds(rootRect.size()); 1396 root->setBounds(rootRect.size());
1395 root->setAnchorPoint(gfx::PointF()); 1397 root->setAnchorPoint(gfx::PointF());
1396 root->setDrawableContentRect(rootRect); 1398 root->setDrawableContentRect(rootRect);
1397 root->setVisibleContentRect(rootRect); 1399 root->setVisibleContentRect(rootRect);
1398 root->addChild(surface); 1400 root->addChild(surface);
1399 1401
1400 surface->setForceRenderSurface(true); 1402 surface->setForceRenderSurface(true);
1401 surface->setAnchorPoint(gfx::PointF()); 1403 surface->setAnchorPoint(gfx::PointF());
1402 surface->setOpacity(0.5); 1404 surface->setOpacity(0.5);
1403 surface->addChild(child); 1405 surface->addChild(child);
1404 surface->addChild(child2); 1406 surface->addChild(child2);
1405 1407
1406 child->setBounds(childRect.size()); 1408 child->setBounds(childRect.size());
1407 child->setAnchorPoint(gfx::PointF()); 1409 child->setAnchorPoint(gfx::PointF());
1408 child->setPosition(childRect.origin()); 1410 child->setPosition(childRect.origin());
1409 child->setVisibleContentRect(childRect); 1411 child->setVisibleContentRect(childRect);
1410 child->setDrawableContentRect(rootRect); 1412 child->setDrawableContentRect(rootRect);
1411 1413
1412 child2->setBounds(child2Rect.size()); 1414 child2->setBounds(child2Rect.size());
1413 child2->setAnchorPoint(gfx::PointF()); 1415 child2->setAnchorPoint(gfx::PointF());
1414 child2->setPosition(child2Rect.origin()); 1416 child2->setPosition(child2Rect.origin());
1415 child2->setVisibleContentRect(child2Rect); 1417 child2->setVisibleContentRect(child2Rect);
1416 child2->setDrawableContentRect(rootRect); 1418 child2->setDrawableContentRect(rootRect);
1417 1419
1418 layerTreeHost->setRootLayer(root); 1420 m_layerTreeHost->setRootLayer(root);
1419 layerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); 1421 m_layerTreeHost->setViewportSize(rootRect.size(), rootRect.size());
1420 1422
1421 // With a huge memory limit, all layers should update and push their texture s. 1423 // With a huge memory limit, all layers should update and push their texture s.
1422 root->invalidateContentRect(rootRect); 1424 root->invalidateContentRect(rootRect);
1423 child->invalidateContentRect(childRect); 1425 child->invalidateContentRect(childRect);
1424 child2->invalidateContentRect(child2Rect); 1426 child2->invalidateContentRect(child2Rect);
1425 layerTreeHost->updateLayers( 1427 m_layerTreeHost->updateLayers(
1426 *m_queue.get(), std::numeric_limits<size_t>::max()); 1428 *m_queue.get(), std::numeric_limits<size_t>::max());
1427 { 1429 {
1428 updateTextures(); 1430 updateTextures();
1429 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); 1431 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount());
1430 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); 1432 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount());
1431 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); 1433 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount());
1432 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1434 EXPECT_FALSE(m_queue->hasMoreUpdates());
1433 1435
1434 root->fakeLayerUpdater()->clearUpdateCount(); 1436 root->fakeLayerUpdater()->clearUpdateCount();
1435 child->fakeLayerUpdater()->clearUpdateCount(); 1437 child->fakeLayerUpdater()->clearUpdateCount();
1436 child2->fakeLayerUpdater()->clearUpdateCount(); 1438 child2->fakeLayerUpdater()->clearUpdateCount();
1437 1439
1438 ScopedFakeTiledLayerImpl rootImpl(root->id()); 1440 ScopedFakeTiledLayerImpl rootImpl(root->id());
1439 ScopedFakeTiledLayerImpl childImpl(child->id()); 1441 ScopedFakeTiledLayerImpl childImpl(child->id());
1440 ScopedFakeTiledLayerImpl child2Impl(child2->id()); 1442 ScopedFakeTiledLayerImpl child2Impl(child2->id());
1441 layerPushPropertiesTo(root.get(), rootImpl.get()); 1443 layerPushPropertiesTo(root.get(), rootImpl.get());
1442 layerPushPropertiesTo(child.get(), childImpl.get()); 1444 layerPushPropertiesTo(child.get(), childImpl.get());
1443 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1445 layerPushPropertiesTo(child2.get(), child2Impl.get());
1444 1446
1445 for (unsigned i = 0; i < 3; ++i) { 1447 for (unsigned i = 0; i < 3; ++i) {
1446 for (unsigned j = 0; j < 2; ++j) 1448 for (unsigned j = 0; j < 2; ++j)
1447 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1449 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1448 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); 1450 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0));
1449 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); 1451 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0));
1450 } 1452 }
1451 } 1453 }
1452 layerTreeHost->commitComplete(); 1454 m_layerTreeHost->commitComplete();
1453 1455
1454 // With a memory limit that includes only the root layer (3x2 tiles) and hal f the surface that 1456 // With a memory limit that includes only the root layer (3x2 tiles) and hal f the surface that
1455 // the child layers draw into, the child layers will not be allocated. If th e surface isn't 1457 // the child layers draw into, the child layers will not be allocated. If th e surface isn't
1456 // accounted for, then one of the children would fit within the memory limit . 1458 // accounted for, then one of the children would fit within the memory limit .
1457 root->invalidateContentRect(rootRect); 1459 root->invalidateContentRect(rootRect);
1458 child->invalidateContentRect(childRect); 1460 child->invalidateContentRect(childRect);
1459 child2->invalidateContentRect(child2Rect); 1461 child2->invalidateContentRect(child2Rect);
1460 layerTreeHost->updateLayers( 1462 m_layerTreeHost->updateLayers(
1461 *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4); 1463 *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4);
1462 { 1464 {
1463 updateTextures(); 1465 updateTextures();
1464 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); 1466 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount());
1465 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); 1467 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount());
1466 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); 1468 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount());
1467 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1469 EXPECT_FALSE(m_queue->hasMoreUpdates());
1468 1470
1469 root->fakeLayerUpdater()->clearUpdateCount(); 1471 root->fakeLayerUpdater()->clearUpdateCount();
1470 child->fakeLayerUpdater()->clearUpdateCount(); 1472 child->fakeLayerUpdater()->clearUpdateCount();
1471 child2->fakeLayerUpdater()->clearUpdateCount(); 1473 child2->fakeLayerUpdater()->clearUpdateCount();
1472 1474
1473 ScopedFakeTiledLayerImpl rootImpl(root->id()); 1475 ScopedFakeTiledLayerImpl rootImpl(root->id());
1474 ScopedFakeTiledLayerImpl childImpl(child->id()); 1476 ScopedFakeTiledLayerImpl childImpl(child->id());
1475 ScopedFakeTiledLayerImpl child2Impl(child2->id()); 1477 ScopedFakeTiledLayerImpl child2Impl(child2->id());
1476 layerPushPropertiesTo(root.get(), rootImpl.get()); 1478 layerPushPropertiesTo(root.get(), rootImpl.get());
1477 layerPushPropertiesTo(child.get(), childImpl.get()); 1479 layerPushPropertiesTo(child.get(), childImpl.get());
1478 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1480 layerPushPropertiesTo(child2.get(), child2Impl.get());
1479 1481
1480 for (unsigned i = 0; i < 3; ++i) { 1482 for (unsigned i = 0; i < 3; ++i) {
1481 for (unsigned j = 0; j < 2; ++j) 1483 for (unsigned j = 0; j < 2; ++j)
1482 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1484 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1483 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1485 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1484 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1486 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1485 } 1487 }
1486 } 1488 }
1487 layerTreeHost->commitComplete(); 1489 m_layerTreeHost->commitComplete();
1488 1490
1489 // With a memory limit that includes only half the root layer, no contents w ill be 1491 // With a memory limit that includes only half the root layer, no contents w ill be
1490 // allocated. If render surface memory wasn't accounted for, there is enough space 1492 // allocated. If render surface memory wasn't accounted for, there is enough space
1491 // for one of the children layers, but they draw into a surface that can't b e 1493 // for one of the children layers, but they draw into a surface that can't b e
1492 // allocated. 1494 // allocated.
1493 root->invalidateContentRect(rootRect); 1495 root->invalidateContentRect(rootRect);
1494 child->invalidateContentRect(childRect); 1496 child->invalidateContentRect(childRect);
1495 child2->invalidateContentRect(child2Rect); 1497 child2->invalidateContentRect(child2Rect);
1496 layerTreeHost->updateLayers( 1498 m_layerTreeHost->updateLayers(
1497 *m_queue.get(), (3 * 1) * (100 * 100) * 4); 1499 *m_queue.get(), (3 * 1) * (100 * 100) * 4);
1498 { 1500 {
1499 updateTextures(); 1501 updateTextures();
1500 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); 1502 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount());
1501 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); 1503 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount());
1502 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); 1504 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount());
1503 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1505 EXPECT_FALSE(m_queue->hasMoreUpdates());
1504 1506
1505 root->fakeLayerUpdater()->clearUpdateCount(); 1507 root->fakeLayerUpdater()->clearUpdateCount();
1506 child->fakeLayerUpdater()->clearUpdateCount(); 1508 child->fakeLayerUpdater()->clearUpdateCount();
1507 child2->fakeLayerUpdater()->clearUpdateCount(); 1509 child2->fakeLayerUpdater()->clearUpdateCount();
1508 1510
1509 ScopedFakeTiledLayerImpl rootImpl(root->id()); 1511 ScopedFakeTiledLayerImpl rootImpl(root->id());
1510 ScopedFakeTiledLayerImpl childImpl(child->id()); 1512 ScopedFakeTiledLayerImpl childImpl(child->id());
1511 ScopedFakeTiledLayerImpl child2Impl(child2->id()); 1513 ScopedFakeTiledLayerImpl child2Impl(child2->id());
1512 layerPushPropertiesTo(root.get(), rootImpl.get()); 1514 layerPushPropertiesTo(root.get(), rootImpl.get());
1513 layerPushPropertiesTo(child.get(), childImpl.get()); 1515 layerPushPropertiesTo(child.get(), childImpl.get());
1514 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1516 layerPushPropertiesTo(child2.get(), child2Impl.get());
1515 1517
1516 for (unsigned i = 0; i < 3; ++i) { 1518 for (unsigned i = 0; i < 3; ++i) {
1517 for (unsigned j = 0; j < 2; ++j) 1519 for (unsigned j = 0; j < 2; ++j)
1518 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); 1520 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j));
1519 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1521 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1520 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1522 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1521 } 1523 }
1522 } 1524 }
1523 layerTreeHost->commitComplete(); 1525 m_layerTreeHost->commitComplete();
1524 1526
1525 resourceManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_res ourceProvider.get()); 1527 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r esourceProvider.get());
1526 layerTreeHost->setRootLayer(0); 1528 m_layerTreeHost->setRootLayer(0);
1527 } 1529 }
1528 1530
1529 class TrackingLayerPainter : public LayerPainter { 1531 class TrackingLayerPainter : public LayerPainter {
1530 public: 1532 public:
1531 static scoped_ptr<TrackingLayerPainter> create() { return make_scoped_ptr(ne w TrackingLayerPainter()); } 1533 static scoped_ptr<TrackingLayerPainter> create() { return make_scoped_ptr(ne w TrackingLayerPainter()); }
1532 1534
1533 virtual void paint(SkCanvas*, const gfx::Rect& contentRect, gfx::RectF&) OVE RRIDE 1535 virtual void paint(SkCanvas*, const gfx::Rect& contentRect, gfx::RectF&) OVE RRIDE
1534 { 1536 {
1535 m_paintedRect = contentRect; 1537 m_paintedRect = contentRect;
1536 } 1538 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 updateTextures(); 1623 updateTextures();
1622 1624
1623 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. 1625 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds.
1624 layer->setNeedsDisplayRect(layerRect); 1626 layer->setNeedsDisplayRect(layerRect);
1625 layer->update(*m_queue.get(), 0, m_stats); 1627 layer->update(*m_queue.get(), 0, m_stats);
1626 1628
1627 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); 1629 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
1628 } 1630 }
1629 1631
1630 } // anonymous namespace 1632 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/tiled_layer_impl_unittest.cc ('k') | cc/tree_synchronizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698