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

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 Dana's code review suggestions 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 }
60
61 virtual void SetUp()
62 {
63 m_layerTreeHost = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient, m_settings, NULL);
64 m_proxy = m_layerTreeHost->proxy();
65 m_textureManager = PrioritizedTextureManager::create(60*1024*1024, 1024, Renderer::ContentPool, m_proxy);
66 m_layerTreeHost->initializeRendererIfNeeded();
67 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
59 m_resourceProvider = ResourceProvider::create(m_context.get()); 68 m_resourceProvider = ResourceProvider::create(m_context.get());
60 } 69 }
61 70
62 virtual ~TiledLayerTest() 71 virtual ~TiledLayerTest()
63 { 72 {
64 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider. get()); 73 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider. get());
65 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 74 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
66 m_resourceProvider.reset(); 75 m_resourceProvider.reset();
67 } 76 }
68 77
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 { 78 class ScopedFakeTiledLayerImpl {
72 public: 79 public:
73 ScopedFakeTiledLayerImpl(int id) 80 ScopedFakeTiledLayerImpl(int id)
74 { 81 {
75 DebugScopedSetImplThread implThread;
76 m_layerImpl = new FakeTiledLayerImpl(id); 82 m_layerImpl = new FakeTiledLayerImpl(id);
77 } 83 }
78 ~ScopedFakeTiledLayerImpl() 84 ~ScopedFakeTiledLayerImpl()
79 { 85 {
80 DebugScopedSetImplThread implThread;
81 delete m_layerImpl; 86 delete m_layerImpl;
82 } 87 }
83 FakeTiledLayerImpl* get() 88 FakeTiledLayerImpl* get()
84 { 89 {
85 return m_layerImpl; 90 return m_layerImpl;
86 } 91 }
87 FakeTiledLayerImpl* operator->() 92 FakeTiledLayerImpl* operator->()
88 { 93 {
89 return m_layerImpl; 94 return m_layerImpl;
90 } 95 }
91 private: 96 private:
92 FakeTiledLayerImpl* m_layerImpl; 97 FakeTiledLayerImpl* m_layerImpl;
93 }; 98 };
94 void textureManagerClearAllMemory(PrioritizedTextureManager* textureManager, ResourceProvider* resourceProvider) 99 void textureManagerClearAllMemory(PrioritizedTextureManager* textureManager, ResourceProvider* resourceProvider)
95 { 100 {
96 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 101 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
97 textureManager->clearAllMemory(resourceProvider); 102 textureManager->clearAllMemory(resourceProvider);
98 textureManager->reduceMemory(resourceProvider); 103 textureManager->reduceMemory(resourceProvider);
99 } 104 }
100 void updateTextures() 105 void updateTextures()
101 { 106 {
102 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 107 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
103 DCHECK(m_queue); 108 DCHECK(m_queue);
104 scoped_ptr<TextureUpdateController> updateController = 109 scoped_ptr<TextureUpdateController> updateController =
105 TextureUpdateController::create( 110 TextureUpdateController::create(
106 NULL, 111 NULL,
107 Proxy::implThread(), 112 m_proxy->implThread(),
108 m_queue.Pass(), 113 m_queue.Pass(),
109 m_resourceProvider.get()); 114 m_resourceProvider.get(),
115 m_proxy->hasImplThread());
110 updateController->finalize(); 116 updateController->finalize();
111 m_queue = make_scoped_ptr(new TextureUpdateQueue); 117 m_queue = make_scoped_ptr(new TextureUpdateQueue);
112 } 118 }
113 void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerI mpl) 119 void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerI mpl)
114 { 120 {
115 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 121 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
116 layer->pushPropertiesTo(layerImpl); 122 layer->pushPropertiesTo(layerImpl);
117 } 123 }
118 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) 124 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded)
119 { 125 {
120 DebugScopedSetMainThread mainThread; 126 DebugScopedSetMainThread mainThread(m_proxy);
121 layer->update(*m_queue.get(), occluded, m_stats); 127 layer->update(*m_queue.get(), occluded, m_stats);
122 } 128 }
123 129
124 bool updateAndPush(FakeTiledLayer* layer1, 130 bool updateAndPush(FakeTiledLayer* layer1,
125 FakeTiledLayerImpl* layerImpl1, 131 FakeTiledLayerImpl* layerImpl1,
126 FakeTiledLayer* layer2 = 0, 132 FakeTiledLayer* layer2 = 0,
127 FakeTiledLayerImpl* layerImpl2 = 0) 133 FakeTiledLayerImpl* layerImpl2 = 0)
128 { 134 {
129 // Get textures 135 // Get textures
130 m_textureManager->clearPriorities(); 136 m_textureManager->clearPriorities();
(...skipping 19 matching lines...) Expand all
150 updateTextures(); 156 updateTextures();
151 if (layer1) 157 if (layer1)
152 layerPushPropertiesTo(layer1, layerImpl1); 158 layerPushPropertiesTo(layer1, layerImpl1);
153 if (layer2) 159 if (layer2)
154 layerPushPropertiesTo(layer2, layerImpl2); 160 layerPushPropertiesTo(layer2, layerImpl2);
155 161
156 return needsUpdate; 162 return needsUpdate;
157 } 163 }
158 164
159 public: 165 public:
166 Proxy* m_proxy;
167 LayerTreeSettings m_settings;
160 WebKitTests::WebCompositorInitializer m_compositorInitializer; 168 WebKitTests::WebCompositorInitializer m_compositorInitializer;
161 scoped_ptr<GraphicsContext> m_context; 169 scoped_ptr<GraphicsContext> m_context;
162 scoped_ptr<ResourceProvider> m_resourceProvider; 170 scoped_ptr<ResourceProvider> m_resourceProvider;
163 scoped_ptr<TextureUpdateQueue> m_queue; 171 scoped_ptr<TextureUpdateQueue> m_queue;
164 RenderingStats m_stats; 172 RenderingStats m_stats;
165 PriorityCalculator m_priorityCalculator; 173 PriorityCalculator m_priorityCalculator;
174 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient;
175 scoped_ptr<LayerTreeHost> m_layerTreeHost;
166 scoped_ptr<PrioritizedTextureManager> m_textureManager; 176 scoped_ptr<PrioritizedTextureManager> m_textureManager;
167 TestOcclusionTracker* m_occlusion; 177 TestOcclusionTracker* m_occlusion;
168 }; 178 };
169 179
170 TEST_F(TiledLayerTest, pushDirtyTiles) 180 TEST_F(TiledLayerTest, pushDirtyTiles)
171 { 181 {
172 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get())); 182 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
173 ScopedFakeTiledLayerImpl layerImpl(1); 183 ScopedFakeTiledLayerImpl layerImpl(1);
174 184
175 // The tile size is 100x100, so this invalidates and then paints two tiles. 185 // 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)); 516 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1));
507 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); 517 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0));
508 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); 518 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1));
509 } 519 }
510 520
511 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately) 521 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
512 { 522 {
513 // Create a LayerTreeHost that has the right viewportsize, 523 // Create a LayerTreeHost that has the right viewportsize,
514 // so the layer is considered small enough. 524 // so the layer is considered small enough.
515 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; 525 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
516 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, LayerTreeSettings()); 526 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, LayerTreeSettings(), NULL);
517 527
518 bool runOutOfMemory[2] = {false, true}; 528 bool runOutOfMemory[2] = {false, true};
519 for (int i = 0; i < 2; i++) { 529 for (int i = 0; i < 2; i++) {
520 // Create a layer with 4x4 tiles. 530 // Create a layer with 4x4 tiles.
521 int layerWidth = 4 * FakeTiledLayer::tileSize().width(); 531 int layerWidth = 4 * FakeTiledLayer::tileSize().width();
522 int layerHeight = 4 * FakeTiledLayer::tileSize().height(); 532 int layerHeight = 4 * FakeTiledLayer::tileSize().height();
523 int memoryForLayer = layerWidth * layerHeight * 4; 533 int memoryForLayer = layerWidth * layerHeight * 4;
524 IntSize viewportSize = IntSize(layerWidth, layerHeight); 534 IntSize viewportSize = IntSize(layerWidth, layerHeight);
525 layerTreeHost->setViewportSize(viewportSize, viewportSize); 535 layerTreeHost->setViewportSize(viewportSize, viewportSize);
526 536
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 782
773 layerPushPropertiesTo(layer.get(), layerImpl.get()); 783 layerPushPropertiesTo(layer.get(), layerImpl.get());
774 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); 784 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
775 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 785 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
776 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); 786 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0));
777 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); 787 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1));
778 } 788 }
779 789
780 TEST_F(TiledLayerTest, skipsDrawGetsReset) 790 TEST_F(TiledLayerTest, skipsDrawGetsReset)
781 { 791 {
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. 792 // Create two 300 x 300 tiled layers.
787 IntSize contentBounds(300, 300); 793 IntSize contentBounds(300, 300);
788 IntRect contentRect(IntPoint::zero(), contentBounds); 794 IntRect contentRect(IntPoint::zero(), contentBounds);
789 795
790 // We have enough memory for only one of the two layers. 796 // We have enough memory for only one of the two layers.
791 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. 797 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel.
792 798
793 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa yer(layerTreeHost->contentsTextureManager())); 799 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())); 800 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL ayer(m_layerTreeHost->contentsTextureManager()));
795 rootLayer->addChild(childLayer); 801 rootLayer->addChild(childLayer);
796 802
797 rootLayer->setBounds(contentBounds); 803 rootLayer->setBounds(contentBounds);
798 rootLayer->setVisibleContentRect(contentRect); 804 rootLayer->setVisibleContentRect(contentRect);
799 rootLayer->setPosition(FloatPoint(0, 0)); 805 rootLayer->setPosition(FloatPoint(0, 0));
800 childLayer->setBounds(contentBounds); 806 childLayer->setBounds(contentBounds);
801 childLayer->setVisibleContentRect(contentRect); 807 childLayer->setVisibleContentRect(contentRect);
802 childLayer->setPosition(FloatPoint(0, 0)); 808 childLayer->setPosition(FloatPoint(0, 0));
803 rootLayer->invalidateContentRect(contentRect); 809 rootLayer->invalidateContentRect(contentRect);
804 childLayer->invalidateContentRect(contentRect); 810 childLayer->invalidateContentRect(contentRect);
805 811
806 layerTreeHost->setRootLayer(rootLayer); 812 m_layerTreeHost->setRootLayer(rootLayer);
807 layerTreeHost->setViewportSize(IntSize(300, 300), IntSize(300, 300)); 813 m_layerTreeHost->setViewportSize(IntSize(300, 300), IntSize(300, 300));
808 814
809 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); 815 m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
810 816
811 // We'll skip the root layer. 817 // We'll skip the root layer.
812 EXPECT_TRUE(rootLayer->skipsDraw()); 818 EXPECT_TRUE(rootLayer->skipsDraw());
813 EXPECT_FALSE(childLayer->skipsDraw()); 819 EXPECT_FALSE(childLayer->skipsDraw());
814 820
815 layerTreeHost->commitComplete(); 821 m_layerTreeHost->commitComplete();
816 822
817 // Remove the child layer. 823 // Remove the child layer.
818 rootLayer->removeAllChildren(); 824 rootLayer->removeAllChildren();
819 825
820 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); 826 m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
821 EXPECT_FALSE(rootLayer->skipsDraw()); 827 EXPECT_FALSE(rootLayer->skipsDraw());
822 828
823 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso urceProvider.get()); 829 textureManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_re sourceProvider.get());
824 layerTreeHost->setRootLayer(0); 830 m_layerTreeHost->setRootLayer(0);
825 } 831 }
826 832
827 TEST_F(TiledLayerTest, resizeToSmaller) 833 TEST_F(TiledLayerTest, resizeToSmaller)
828 { 834 {
829 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get())); 835 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
830 836
831 layer->setBounds(IntSize(700, 700)); 837 layer->setBounds(IntSize(700, 700));
832 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); 838 layer->setVisibleContentRect(IntRect(0, 0, 700, 700));
833 layer->invalidateContentRect(IntRect(0, 0, 700, 700)); 839 layer->invalidateContentRect(IntRect(0, 0, 700, 700));
834 840
(...skipping 13 matching lines...) Expand all
848 layer->setBounds(IntSize(size, size)); 854 layer->setBounds(IntSize(size, size));
849 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); 855 layer->setVisibleContentRect(IntRect(0, 0, 700, 700));
850 layer->invalidateContentRect(IntRect(0, 0, size, size)); 856 layer->invalidateContentRect(IntRect(0, 0, size, size));
851 857
852 // Ensure no crash for bounds where size * size would overflow an int. 858 // Ensure no crash for bounds where size * size would overflow an int.
853 layer->setTexturePriorities(m_priorityCalculator); 859 layer->setTexturePriorities(m_priorityCalculator);
854 m_textureManager->prioritizeTextures(); 860 m_textureManager->prioritizeTextures();
855 layer->update(*m_queue.get(), 0, m_stats); 861 layer->update(*m_queue.get(), 0, m_stats);
856 } 862 }
857 863
858 TEST_F(TiledLayerTest, partialUpdates)
859 {
860 LayerTreeSettings settings;
861 settings.maxPartialTextureUpdates = 4;
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.
868 IntSize contentBounds(300, 200);
869 IntRect contentRect(IntPoint::zero(), contentBounds);
870
871 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( layerTreeHost->contentsTextureManager()));
872 layer->setBounds(contentBounds);
873 layer->setPosition(FloatPoint(0, 0));
874 layer->setVisibleContentRect(contentRect);
875 layer->invalidateContentRect(contentRect);
876
877 layerTreeHost->setRootLayer(layer);
878 layerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200));
879
880 // Full update of all 6 tiles.
881 layerTreeHost->updateLayers(
882 *m_queue.get(), std::numeric_limits<size_t>::max());
883 {
884 ScopedFakeTiledLayerImpl layerImpl(1);
885 EXPECT_EQ(6, m_queue->fullUploadSize());
886 EXPECT_EQ(0, m_queue->partialUploadSize());
887 updateTextures();
888 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
889 EXPECT_FALSE(m_queue->hasMoreUpdates());
890 layer->fakeLayerUpdater()->clearUpdateCount();
891 layerPushPropertiesTo(layer.get(), layerImpl.get());
892 }
893 layerTreeHost->commitComplete();
894
895 // Full update of 3 tiles and partial update of 3 tiles.
896 layer->invalidateContentRect(IntRect(0, 0, 300, 150));
897 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max ());
898 {
899 ScopedFakeTiledLayerImpl layerImpl(1);
900 EXPECT_EQ(3, m_queue->fullUploadSize());
901 EXPECT_EQ(3, m_queue->partialUploadSize());
902 updateTextures();
903 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
904 EXPECT_FALSE(m_queue->hasMoreUpdates());
905 layer->fakeLayerUpdater()->clearUpdateCount();
906 layerPushPropertiesTo(layer.get(), layerImpl.get());
907 }
908 layerTreeHost->commitComplete();
909
910 // Partial update of 6 tiles.
911 layer->invalidateContentRect(IntRect(50, 50, 200, 100));
912 {
913 ScopedFakeTiledLayerImpl layerImpl(1);
914 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>: :max());
915 EXPECT_EQ(2, m_queue->fullUploadSize());
916 EXPECT_EQ(4, m_queue->partialUploadSize());
917 updateTextures();
918 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
919 EXPECT_FALSE(m_queue->hasMoreUpdates());
920 layer->fakeLayerUpdater()->clearUpdateCount();
921 layerPushPropertiesTo(layer.get(), layerImpl.get());
922 }
923 layerTreeHost->commitComplete();
924
925 // Checkerboard all tiles.
926 layer->invalidateContentRect(IntRect(0, 0, 300, 200));
927 {
928 ScopedFakeTiledLayerImpl layerImpl(1);
929 layerPushPropertiesTo(layer.get(), layerImpl.get());
930 }
931 layerTreeHost->commitComplete();
932
933 // Partial update of 6 checkerboard tiles.
934 layer->invalidateContentRect(IntRect(50, 50, 200, 100));
935 {
936 ScopedFakeTiledLayerImpl layerImpl(1);
937 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>: :max());
938 EXPECT_EQ(6, m_queue->fullUploadSize());
939 EXPECT_EQ(0, m_queue->partialUploadSize());
940 updateTextures();
941 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
942 EXPECT_FALSE(m_queue->hasMoreUpdates());
943 layer->fakeLayerUpdater()->clearUpdateCount();
944 layerPushPropertiesTo(layer.get(), layerImpl.get());
945 }
946 layerTreeHost->commitComplete();
947
948 // Partial update of 4 tiles.
949 layer->invalidateContentRect(IntRect(50, 50, 100, 100));
950 {
951 ScopedFakeTiledLayerImpl layerImpl(1);
952 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>: :max());
953 EXPECT_EQ(0, m_queue->fullUploadSize());
954 EXPECT_EQ(4, m_queue->partialUploadSize());
955 updateTextures();
956 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount());
957 EXPECT_FALSE(m_queue->hasMoreUpdates());
958 layer->fakeLayerUpdater()->clearUpdateCount();
959 layerPushPropertiesTo(layer.get(), layerImpl.get());
960 }
961 layerTreeHost->commitComplete();
962
963 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso urceProvider.get());
964 layerTreeHost->setRootLayer(0);
965 }
966
967 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) 864 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion)
968 { 865 {
969 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get())); 866 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
970 867
971 // The tile size is 100x100, so this invalidates and then paints two tiles. 868 // The tile size is 100x100, so this invalidates and then paints two tiles.
972 layer->setBounds(IntSize(100, 200)); 869 layer->setBounds(IntSize(100, 200));
973 layer->setDrawableContentRect(IntRect(0, 0, 100, 200)); 870 layer->setDrawableContentRect(IntRect(0, 0, 100, 200));
974 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 871 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
975 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 872 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
976 873
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); 1269 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
1373 } 1270 }
1374 1271
1375 TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated) 1272 TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
1376 { 1273 {
1377 // Tile size is 100x100. 1274 // Tile size is 100x100.
1378 IntRect rootRect(0, 0, 300, 200); 1275 IntRect rootRect(0, 0, 300, 200);
1379 IntRect childRect(0, 0, 300, 100); 1276 IntRect childRect(0, 0, 300, 100);
1380 IntRect child2Rect(0, 100, 300, 100); 1277 IntRect child2Rect(0, 100, 300, 100);
1381 1278
1382 LayerTreeSettings settings; 1279 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(); 1280 scoped_refptr<Layer> surface = Layer::create();
1389 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer( layerTreeHost->contentsTextureManager())); 1281 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer( m_layerTreeHost->contentsTextureManager()));
1390 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer (layerTreeHost->contentsTextureManager())); 1282 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer (m_layerTreeHost->contentsTextureManager()));
1391 1283
1392 root->setBounds(rootRect.size()); 1284 root->setBounds(rootRect.size());
1393 root->setAnchorPoint(FloatPoint()); 1285 root->setAnchorPoint(FloatPoint());
1394 root->setDrawableContentRect(rootRect); 1286 root->setDrawableContentRect(rootRect);
1395 root->setVisibleContentRect(rootRect); 1287 root->setVisibleContentRect(rootRect);
1396 root->addChild(surface); 1288 root->addChild(surface);
1397 1289
1398 surface->setForceRenderSurface(true); 1290 surface->setForceRenderSurface(true);
1399 surface->setAnchorPoint(FloatPoint()); 1291 surface->setAnchorPoint(FloatPoint());
1400 surface->setOpacity(0.5); 1292 surface->setOpacity(0.5);
1401 surface->addChild(child); 1293 surface->addChild(child);
1402 surface->addChild(child2); 1294 surface->addChild(child2);
1403 1295
1404 child->setBounds(childRect.size()); 1296 child->setBounds(childRect.size());
1405 child->setAnchorPoint(FloatPoint()); 1297 child->setAnchorPoint(FloatPoint());
1406 child->setPosition(childRect.location()); 1298 child->setPosition(childRect.location());
1407 child->setVisibleContentRect(childRect); 1299 child->setVisibleContentRect(childRect);
1408 child->setDrawableContentRect(rootRect); 1300 child->setDrawableContentRect(rootRect);
1409 1301
1410 child2->setBounds(child2Rect.size()); 1302 child2->setBounds(child2Rect.size());
1411 child2->setAnchorPoint(FloatPoint()); 1303 child2->setAnchorPoint(FloatPoint());
1412 child2->setPosition(child2Rect.location()); 1304 child2->setPosition(child2Rect.location());
1413 child2->setVisibleContentRect(child2Rect); 1305 child2->setVisibleContentRect(child2Rect);
1414 child2->setDrawableContentRect(rootRect); 1306 child2->setDrawableContentRect(rootRect);
1415 1307
1416 layerTreeHost->setRootLayer(root); 1308 m_layerTreeHost->setRootLayer(root);
1417 layerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); 1309 m_layerTreeHost->setViewportSize(rootRect.size(), rootRect.size());
1418 1310
1419 // With a huge memory limit, all layers should update and push their texture s. 1311 // With a huge memory limit, all layers should update and push their texture s.
1420 root->invalidateContentRect(rootRect); 1312 root->invalidateContentRect(rootRect);
1421 child->invalidateContentRect(childRect); 1313 child->invalidateContentRect(childRect);
1422 child2->invalidateContentRect(child2Rect); 1314 child2->invalidateContentRect(child2Rect);
1423 layerTreeHost->updateLayers( 1315 m_layerTreeHost->updateLayers(
1424 *m_queue.get(), std::numeric_limits<size_t>::max()); 1316 *m_queue.get(), std::numeric_limits<size_t>::max());
1425 { 1317 {
1426 updateTextures(); 1318 updateTextures();
1427 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); 1319 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount());
1428 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); 1320 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount());
1429 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); 1321 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount());
1430 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1322 EXPECT_FALSE(m_queue->hasMoreUpdates());
1431 1323
1432 root->fakeLayerUpdater()->clearUpdateCount(); 1324 root->fakeLayerUpdater()->clearUpdateCount();
1433 child->fakeLayerUpdater()->clearUpdateCount(); 1325 child->fakeLayerUpdater()->clearUpdateCount();
1434 child2->fakeLayerUpdater()->clearUpdateCount(); 1326 child2->fakeLayerUpdater()->clearUpdateCount();
1435 1327
1436 ScopedFakeTiledLayerImpl rootImpl(root->id()); 1328 ScopedFakeTiledLayerImpl rootImpl(root->id());
1437 ScopedFakeTiledLayerImpl childImpl(child->id()); 1329 ScopedFakeTiledLayerImpl childImpl(child->id());
1438 ScopedFakeTiledLayerImpl child2Impl(child2->id()); 1330 ScopedFakeTiledLayerImpl child2Impl(child2->id());
1439 layerPushPropertiesTo(root.get(), rootImpl.get()); 1331 layerPushPropertiesTo(root.get(), rootImpl.get());
1440 layerPushPropertiesTo(child.get(), childImpl.get()); 1332 layerPushPropertiesTo(child.get(), childImpl.get());
1441 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1333 layerPushPropertiesTo(child2.get(), child2Impl.get());
1442 1334
1443 for (unsigned i = 0; i < 3; ++i) { 1335 for (unsigned i = 0; i < 3; ++i) {
1444 for (unsigned j = 0; j < 2; ++j) 1336 for (unsigned j = 0; j < 2; ++j)
1445 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1337 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1446 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); 1338 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0));
1447 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); 1339 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0));
1448 } 1340 }
1449 } 1341 }
1450 layerTreeHost->commitComplete(); 1342 m_layerTreeHost->commitComplete();
1451 1343
1452 // With a memory limit that includes only the root layer (3x2 tiles) and hal f the surface that 1344 // 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 1345 // 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 . 1346 // accounted for, then one of the children would fit within the memory limit .
1455 root->invalidateContentRect(rootRect); 1347 root->invalidateContentRect(rootRect);
1456 child->invalidateContentRect(childRect); 1348 child->invalidateContentRect(childRect);
1457 child2->invalidateContentRect(child2Rect); 1349 child2->invalidateContentRect(child2Rect);
1458 layerTreeHost->updateLayers( 1350 m_layerTreeHost->updateLayers(
1459 *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4); 1351 *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4);
1460 { 1352 {
1461 updateTextures(); 1353 updateTextures();
1462 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); 1354 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount());
1463 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); 1355 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount());
1464 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); 1356 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount());
1465 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1357 EXPECT_FALSE(m_queue->hasMoreUpdates());
1466 1358
1467 root->fakeLayerUpdater()->clearUpdateCount(); 1359 root->fakeLayerUpdater()->clearUpdateCount();
1468 child->fakeLayerUpdater()->clearUpdateCount(); 1360 child->fakeLayerUpdater()->clearUpdateCount();
1469 child2->fakeLayerUpdater()->clearUpdateCount(); 1361 child2->fakeLayerUpdater()->clearUpdateCount();
1470 1362
1471 ScopedFakeTiledLayerImpl rootImpl(root->id()); 1363 ScopedFakeTiledLayerImpl rootImpl(root->id());
1472 ScopedFakeTiledLayerImpl childImpl(child->id()); 1364 ScopedFakeTiledLayerImpl childImpl(child->id());
1473 ScopedFakeTiledLayerImpl child2Impl(child2->id()); 1365 ScopedFakeTiledLayerImpl child2Impl(child2->id());
1474 layerPushPropertiesTo(root.get(), rootImpl.get()); 1366 layerPushPropertiesTo(root.get(), rootImpl.get());
1475 layerPushPropertiesTo(child.get(), childImpl.get()); 1367 layerPushPropertiesTo(child.get(), childImpl.get());
1476 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1368 layerPushPropertiesTo(child2.get(), child2Impl.get());
1477 1369
1478 for (unsigned i = 0; i < 3; ++i) { 1370 for (unsigned i = 0; i < 3; ++i) {
1479 for (unsigned j = 0; j < 2; ++j) 1371 for (unsigned j = 0; j < 2; ++j)
1480 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1372 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1481 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1373 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1482 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1374 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1483 } 1375 }
1484 } 1376 }
1485 layerTreeHost->commitComplete(); 1377 m_layerTreeHost->commitComplete();
1486 1378
1487 // With a memory limit that includes only half the root layer, no contents w ill be 1379 // 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 1380 // 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 1381 // for one of the children layers, but they draw into a surface that can't b e
1490 // allocated. 1382 // allocated.
1491 root->invalidateContentRect(rootRect); 1383 root->invalidateContentRect(rootRect);
1492 child->invalidateContentRect(childRect); 1384 child->invalidateContentRect(childRect);
1493 child2->invalidateContentRect(child2Rect); 1385 child2->invalidateContentRect(child2Rect);
1494 layerTreeHost->updateLayers( 1386 m_layerTreeHost->updateLayers(
1495 *m_queue.get(), (3 * 1) * (100 * 100) * 4); 1387 *m_queue.get(), (3 * 1) * (100 * 100) * 4);
1496 { 1388 {
1497 updateTextures(); 1389 updateTextures();
1498 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); 1390 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount());
1499 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); 1391 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount());
1500 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); 1392 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount());
1501 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1393 EXPECT_FALSE(m_queue->hasMoreUpdates());
1502 1394
1503 root->fakeLayerUpdater()->clearUpdateCount(); 1395 root->fakeLayerUpdater()->clearUpdateCount();
1504 child->fakeLayerUpdater()->clearUpdateCount(); 1396 child->fakeLayerUpdater()->clearUpdateCount();
1505 child2->fakeLayerUpdater()->clearUpdateCount(); 1397 child2->fakeLayerUpdater()->clearUpdateCount();
1506 1398
1507 ScopedFakeTiledLayerImpl rootImpl(root->id()); 1399 ScopedFakeTiledLayerImpl rootImpl(root->id());
1508 ScopedFakeTiledLayerImpl childImpl(child->id()); 1400 ScopedFakeTiledLayerImpl childImpl(child->id());
1509 ScopedFakeTiledLayerImpl child2Impl(child2->id()); 1401 ScopedFakeTiledLayerImpl child2Impl(child2->id());
1510 layerPushPropertiesTo(root.get(), rootImpl.get()); 1402 layerPushPropertiesTo(root.get(), rootImpl.get());
1511 layerPushPropertiesTo(child.get(), childImpl.get()); 1403 layerPushPropertiesTo(child.get(), childImpl.get());
1512 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1404 layerPushPropertiesTo(child2.get(), child2Impl.get());
1513 1405
1514 for (unsigned i = 0; i < 3; ++i) { 1406 for (unsigned i = 0; i < 3; ++i) {
1515 for (unsigned j = 0; j < 2; ++j) 1407 for (unsigned j = 0; j < 2; ++j)
1516 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); 1408 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j));
1517 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1409 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1518 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1410 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1519 } 1411 }
1520 } 1412 }
1521 layerTreeHost->commitComplete(); 1413 m_layerTreeHost->commitComplete();
1522 1414
1523 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso urceProvider.get()); 1415 textureManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_re sourceProvider.get());
1524 layerTreeHost->setRootLayer(0); 1416 m_layerTreeHost->setRootLayer(0);
1525 } 1417 }
1526 1418
1527 class TrackingLayerPainter : public LayerPainter { 1419 class TrackingLayerPainter : public LayerPainter {
1528 public: 1420 public:
1529 static scoped_ptr<TrackingLayerPainter> create() { return make_scoped_ptr(ne w TrackingLayerPainter()); } 1421 static scoped_ptr<TrackingLayerPainter> create() { return make_scoped_ptr(ne w TrackingLayerPainter()); }
1530 1422
1531 virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect&) OVERRI DE 1423 virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect&) OVERRI DE
1532 { 1424 {
1533 m_paintedRect = contentRect; 1425 m_paintedRect = contentRect;
1534 } 1426 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); 1510 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect());
1619 updateTextures(); 1511 updateTextures();
1620 1512
1621 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. 1513 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds.
1622 layer->setNeedsDisplayRect(layerRect); 1514 layer->setNeedsDisplayRect(layerRect);
1623 layer->update(*m_queue.get(), 0, m_stats); 1515 layer->update(*m_queue.get(), 0, m_stats);
1624 1516
1625 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); 1517 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
1626 } 1518 }
1627 1519
1520 class TiledLayerPartialUpdateTest : public TiledLayerTest
1521 {
1522 public:
1523 TiledLayerPartialUpdateTest()
1524 {
1525 m_settings.maxPartialTextureUpdates = 4;
1526 }
1527 };
1528
1529 TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
1530 {
1531 // Create one 300 x 200 tiled layer with 3 x 2 tiles.
1532 IntSize contentBounds(300, 200);
1533 IntRect contentRect(IntPoint::zero(), contentBounds);
1534
1535 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_layerTreeHost->contentsTextureManager()));
1536 layer->setBounds(contentBounds);
1537 layer->setPosition(FloatPoint(0, 0));
1538 layer->setVisibleContentRect(contentRect);
1539 layer->invalidateContentRect(contentRect);
1540
1541 m_layerTreeHost->setRootLayer(layer);
1542 m_layerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200));
1543
1544 // Full update of all 6 tiles.
1545 m_layerTreeHost->updateLayers(
1546 *m_queue.get(), std::numeric_limits<size_t>::max());
1547 {
1548 ScopedFakeTiledLayerImpl layerImpl(1);
1549 EXPECT_EQ(6, m_queue->fullUploadSize());
1550 EXPECT_EQ(0, m_queue->partialUploadSize());
1551 updateTextures();
1552 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
1553 EXPECT_FALSE(m_queue->hasMoreUpdates());
1554 layer->fakeLayerUpdater()->clearUpdateCount();
1555 layerPushPropertiesTo(layer.get(), layerImpl.get());
1556 }
1557 m_layerTreeHost->commitComplete();
1558
1559 // Full update of 3 tiles and partial update of 3 tiles.
1560 layer->invalidateContentRect(IntRect(0, 0, 300, 150));
1561 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m ax());
1562 {
1563 ScopedFakeTiledLayerImpl layerImpl(1);
1564 EXPECT_EQ(3, m_queue->fullUploadSize());
1565 EXPECT_EQ(3, m_queue->partialUploadSize());
1566 updateTextures();
1567 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
1568 EXPECT_FALSE(m_queue->hasMoreUpdates());
1569 layer->fakeLayerUpdater()->clearUpdateCount();
1570 layerPushPropertiesTo(layer.get(), layerImpl.get());
1571 }
1572 m_layerTreeHost->commitComplete();
1573
1574 // Partial update of 6 tiles.
1575 layer->invalidateContentRect(IntRect(50, 50, 200, 100));
1576 {
1577 ScopedFakeTiledLayerImpl layerImpl(1);
1578 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max());
1579 EXPECT_EQ(2, m_queue->fullUploadSize());
1580 EXPECT_EQ(4, m_queue->partialUploadSize());
1581 updateTextures();
1582 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
1583 EXPECT_FALSE(m_queue->hasMoreUpdates());
1584 layer->fakeLayerUpdater()->clearUpdateCount();
1585 layerPushPropertiesTo(layer.get(), layerImpl.get());
1586 }
1587 m_layerTreeHost->commitComplete();
1588
1589 // Checkerboard all tiles.
1590 layer->invalidateContentRect(IntRect(0, 0, 300, 200));
1591 {
1592 ScopedFakeTiledLayerImpl layerImpl(1);
1593 layerPushPropertiesTo(layer.get(), layerImpl.get());
1594 }
1595 m_layerTreeHost->commitComplete();
1596
1597 // Partial update of 6 checkerboard tiles.
1598 layer->invalidateContentRect(IntRect(50, 50, 200, 100));
1599 {
1600 ScopedFakeTiledLayerImpl layerImpl(1);
1601 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max());
1602 EXPECT_EQ(6, m_queue->fullUploadSize());
1603 EXPECT_EQ(0, m_queue->partialUploadSize());
1604 updateTextures();
1605 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
1606 EXPECT_FALSE(m_queue->hasMoreUpdates());
1607 layer->fakeLayerUpdater()->clearUpdateCount();
1608 layerPushPropertiesTo(layer.get(), layerImpl.get());
1609 }
1610 m_layerTreeHost->commitComplete();
1611
1612 // Partial update of 4 tiles.
1613 layer->invalidateContentRect(IntRect(50, 50, 100, 100));
1614 {
1615 ScopedFakeTiledLayerImpl layerImpl(1);
1616 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max());
1617 EXPECT_EQ(0, m_queue->fullUploadSize());
1618 EXPECT_EQ(4, m_queue->partialUploadSize());
1619 updateTextures();
1620 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount());
1621 EXPECT_FALSE(m_queue->hasMoreUpdates());
1622 layer->fakeLayerUpdater()->clearUpdateCount();
1623 layerPushPropertiesTo(layer.get(), layerImpl.get());
1624 }
1625 m_layerTreeHost->commitComplete();
1626
1627 textureManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_re sourceProvider.get());
1628 m_layerTreeHost->setRootLayer(0);
1629 }
1630
1628 } // namespace 1631 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698