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

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

Powered by Google App Engine
This is Rietveld 408576698