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

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

Powered by Google App Engine
This is Rietveld 408576698