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

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

Powered by Google App Engine
This is Rietveld 408576698