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

Side by Side Diff: cc/tiled_layer_unittest.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months 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 | Annotate | Revision Log
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 "CCOverdrawMetrics.h" 9 #include "CCOverdrawMetrics.h"
10 #include "CCRenderingStats.h" 10 #include "CCRenderingStats.h"
11 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread 11 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread
12 #include "CCTextureUpdateController.h" 12 #include "CCTextureUpdateController.h"
13 #include "cc/bitmap_canvas_layer_texture_updater.h" 13 #include "cc/bitmap_canvas_layer_texture_updater.h"
14 #include "cc/layer_painter.h" 14 #include "cc/layer_painter.h"
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/geometry_test_utils.h" 18 #include "cc/test/geometry_test_utils.h"
19 #include "cc/test/tiled_layer_test_common.h" 19 #include "cc/test/tiled_layer_test_common.h"
20 #include "cc/test/web_compositor_initializer.h" 20 #include "cc/test/web_compositor_initializer.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include <public/WebTransformationMatrix.h> 22 #include <public/WebTransformationMatrix.h>
23 23
24 using namespace cc; 24 using namespace cc;
25 using namespace WebKitTests; 25 using namespace WebKitTests;
26 using WebKit::WebTransformationMatrix; 26 using WebKit::WebTransformationMatrix;
27 27
28 namespace { 28 namespace {
29 29
30 class TestCCOcclusionTracker : public CCOcclusionTracker { 30 class TestOcclusionTracker : public OcclusionTracker {
31 public: 31 public:
32 TestCCOcclusionTracker() 32 TestOcclusionTracker()
33 : CCOcclusionTracker(IntRect(0, 0, 1000, 1000), true) 33 : OcclusionTracker(IntRect(0, 0, 1000, 1000), true)
34 , m_layerClipRectInTarget(IntRect(0, 0, 1000, 1000)) 34 , m_layerClipRectInTarget(IntRect(0, 0, 1000, 1000))
35 { 35 {
36 // Pretend we have visited a render surface. 36 // Pretend we have visited a render surface.
37 m_stack.append(StackObject()); 37 m_stack.append(StackObject());
38 } 38 }
39 39
40 void setOcclusion(const Region& occlusion) { m_stack.last().occlusionInScree n = occlusion; } 40 void setOcclusion(const Region& occlusion) { m_stack.last().occlusionInScree n = occlusion; }
41 41
42 protected: 42 protected:
43 virtual IntRect layerClipRectInTarget(const LayerChromium* layer) const OVER RIDE { return m_layerClipRectInTarget; } 43 virtual IntRect layerClipRectInTarget(const Layer* layer) const OVERRIDE { r eturn m_layerClipRectInTarget; }
44 44
45 private: 45 private:
46 IntRect m_layerClipRectInTarget; 46 IntRect m_layerClipRectInTarget;
47 }; 47 };
48 48
49 class TiledLayerChromiumTest : public testing::Test { 49 class TiledLayerTest : public testing::Test {
50 public: 50 public:
51 TiledLayerChromiumTest() 51 TiledLayerTest()
52 : m_compositorInitializer(0) 52 : m_compositorInitializer(0)
53 , m_context(WebKit::createFakeCCGraphicsContext()) 53 , m_context(WebKit::createFakeGraphicsContext())
54 , m_queue(make_scoped_ptr(new CCTextureUpdateQueue)) 54 , m_queue(make_scoped_ptr(new TextureUpdateQueue))
55 , m_textureManager(CCPrioritizedTextureManager::create(60*1024*1024, 102 4, CCRenderer::ContentPool)) 55 , m_textureManager(PrioritizedTextureManager::create(60*1024*1024, 1024, Renderer::ContentPool))
56 , m_occlusion(0) 56 , m_occlusion(0)
57 { 57 {
58 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 58 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
59 m_resourceProvider = CCResourceProvider::create(m_context.get()); 59 m_resourceProvider = ResourceProvider::create(m_context.get());
60 } 60 }
61 61
62 virtual ~TiledLayerChromiumTest() 62 virtual ~TiledLayerTest()
63 { 63 {
64 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider. get()); 64 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider. get());
65 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 65 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
66 m_resourceProvider.reset(); 66 m_resourceProvider.reset();
67 } 67 }
68 68
69 // Helper classes and functions that set the current thread to be the impl t hread 69 // Helper classes and functions that set the current thread to be the impl t hread
70 // before doing the action that they wrap. 70 // before doing the action that they wrap.
71 class ScopedFakeCCTiledLayerImpl { 71 class ScopedFakeTiledLayerImpl {
72 public: 72 public:
73 ScopedFakeCCTiledLayerImpl(int id) 73 ScopedFakeTiledLayerImpl(int id)
74 { 74 {
75 DebugScopedSetImplThread implThread; 75 DebugScopedSetImplThread implThread;
76 m_layerImpl = new FakeCCTiledLayerImpl(id); 76 m_layerImpl = new FakeTiledLayerImpl(id);
77 } 77 }
78 ~ScopedFakeCCTiledLayerImpl() 78 ~ScopedFakeTiledLayerImpl()
79 { 79 {
80 DebugScopedSetImplThread implThread; 80 DebugScopedSetImplThread implThread;
81 delete m_layerImpl; 81 delete m_layerImpl;
82 } 82 }
83 FakeCCTiledLayerImpl* get() 83 FakeTiledLayerImpl* get()
84 { 84 {
85 return m_layerImpl; 85 return m_layerImpl;
86 } 86 }
87 FakeCCTiledLayerImpl* operator->() 87 FakeTiledLayerImpl* operator->()
88 { 88 {
89 return m_layerImpl; 89 return m_layerImpl;
90 } 90 }
91 private: 91 private:
92 FakeCCTiledLayerImpl* m_layerImpl; 92 FakeTiledLayerImpl* m_layerImpl;
93 }; 93 };
94 void textureManagerClearAllMemory(CCPrioritizedTextureManager* textureManage r, CCResourceProvider* resourceProvider) 94 void textureManagerClearAllMemory(PrioritizedTextureManager* textureManager, ResourceProvider* resourceProvider)
95 { 95 {
96 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 96 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
97 textureManager->clearAllMemory(resourceProvider); 97 textureManager->clearAllMemory(resourceProvider);
98 textureManager->reduceMemory(resourceProvider); 98 textureManager->reduceMemory(resourceProvider);
99 } 99 }
100 void updateTextures() 100 void updateTextures()
101 { 101 {
102 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 102 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
103 ASSERT(m_queue); 103 ASSERT(m_queue);
104 scoped_ptr<CCTextureUpdateController> updateController = 104 scoped_ptr<TextureUpdateController> updateController =
105 CCTextureUpdateController::create( 105 TextureUpdateController::create(
106 NULL, 106 NULL,
107 CCProxy::implThread(), 107 Proxy::implThread(),
108 m_queue.Pass(), 108 m_queue.Pass(),
109 m_resourceProvider.get(), 109 m_resourceProvider.get(),
110 &m_uploader); 110 &m_uploader);
111 updateController->finalize(); 111 updateController->finalize();
112 m_queue = make_scoped_ptr(new CCTextureUpdateQueue); 112 m_queue = make_scoped_ptr(new TextureUpdateQueue);
113 } 113 }
114 void layerPushPropertiesTo(FakeTiledLayerChromium* layer, FakeCCTiledLayerIm pl* layerImpl) 114 void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerI mpl)
115 { 115 {
116 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 116 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
117 layer->pushPropertiesTo(layerImpl); 117 layer->pushPropertiesTo(layerImpl);
118 } 118 }
119 void layerUpdate(FakeTiledLayerChromium* layer, TestCCOcclusionTracker* occl uded) 119 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded)
120 { 120 {
121 DebugScopedSetMainThread mainThread; 121 DebugScopedSetMainThread mainThread;
122 layer->update(*m_queue.get(), occluded, m_stats); 122 layer->update(*m_queue.get(), occluded, m_stats);
123 } 123 }
124 124
125 bool updateAndPush(FakeTiledLayerChromium* layer1, 125 bool updateAndPush(FakeTiledLayer* layer1,
126 FakeCCTiledLayerImpl* layerImpl1, 126 FakeTiledLayerImpl* layerImpl1,
127 FakeTiledLayerChromium* layer2 = 0, 127 FakeTiledLayer* layer2 = 0,
128 FakeCCTiledLayerImpl* layerImpl2 = 0) 128 FakeTiledLayerImpl* layerImpl2 = 0)
129 { 129 {
130 // Get textures 130 // Get textures
131 m_textureManager->clearPriorities(); 131 m_textureManager->clearPriorities();
132 if (layer1) 132 if (layer1)
133 layer1->setTexturePriorities(m_priorityCalculator); 133 layer1->setTexturePriorities(m_priorityCalculator);
134 if (layer2) 134 if (layer2)
135 layer2->setTexturePriorities(m_priorityCalculator); 135 layer2->setTexturePriorities(m_priorityCalculator);
136 m_textureManager->prioritizeTextures(); 136 m_textureManager->prioritizeTextures();
137 137
138 // Update content 138 // Update content
(...skipping 13 matching lines...) Expand all
152 if (layer1) 152 if (layer1)
153 layerPushPropertiesTo(layer1, layerImpl1); 153 layerPushPropertiesTo(layer1, layerImpl1);
154 if (layer2) 154 if (layer2)
155 layerPushPropertiesTo(layer2, layerImpl2); 155 layerPushPropertiesTo(layer2, layerImpl2);
156 156
157 return needsUpdate; 157 return needsUpdate;
158 } 158 }
159 159
160 public: 160 public:
161 WebKitTests::WebCompositorInitializer m_compositorInitializer; 161 WebKitTests::WebCompositorInitializer m_compositorInitializer;
162 scoped_ptr<CCGraphicsContext> m_context; 162 scoped_ptr<GraphicsContext> m_context;
163 scoped_ptr<CCResourceProvider> m_resourceProvider; 163 scoped_ptr<ResourceProvider> m_resourceProvider;
164 scoped_ptr<CCTextureUpdateQueue> m_queue; 164 scoped_ptr<TextureUpdateQueue> m_queue;
165 CCRenderingStats m_stats; 165 RenderingStats m_stats;
166 FakeTextureUploader m_uploader; 166 FakeTextureUploader m_uploader;
167 CCPriorityCalculator m_priorityCalculator; 167 PriorityCalculator m_priorityCalculator;
168 scoped_ptr<CCPrioritizedTextureManager> m_textureManager; 168 scoped_ptr<PrioritizedTextureManager> m_textureManager;
169 TestCCOcclusionTracker* m_occlusion; 169 TestOcclusionTracker* m_occlusion;
170 }; 170 };
171 171
172 TEST_F(TiledLayerChromiumTest, pushDirtyTiles) 172 TEST_F(TiledLayerTest, pushDirtyTiles)
173 { 173 {
174 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 174 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
175 ScopedFakeCCTiledLayerImpl layerImpl(1); 175 ScopedFakeTiledLayerImpl layerImpl(1);
176 176
177 // The tile size is 100x100, so this invalidates and then paints two tiles. 177 // The tile size is 100x100, so this invalidates and then paints two tiles.
178 layer->setBounds(IntSize(100, 200)); 178 layer->setBounds(IntSize(100, 200));
179 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 179 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
180 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 180 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
181 updateAndPush(layer.get(), layerImpl.get()); 181 updateAndPush(layer.get(), layerImpl.get());
182 182
183 // We should have both tiles on the impl side. 183 // We should have both tiles on the impl side.
184 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 184 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
185 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 185 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
186 186
187 // Invalidates both tiles, but then only update one of them. 187 // Invalidates both tiles, but then only update one of them.
188 layer->setBounds(IntSize(100, 200)); 188 layer->setBounds(IntSize(100, 200));
189 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); 189 layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
190 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 190 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
191 updateAndPush(layer.get(), layerImpl.get()); 191 updateAndPush(layer.get(), layerImpl.get());
192 192
193 // We should only have the first tile since the other tile was invalidated b ut not painted. 193 // We should only have the first tile since the other tile was invalidated b ut not painted.
194 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 194 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
195 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 195 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
196 } 196 }
197 197
198 TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) 198 TEST_F(TiledLayerTest, pushOccludedDirtyTiles)
199 { 199 {
200 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 200 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
201 ScopedFakeCCTiledLayerImpl layerImpl(1); 201 ScopedFakeTiledLayerImpl layerImpl(1);
202 TestCCOcclusionTracker occluded; 202 TestOcclusionTracker occluded;
203 m_occlusion = &occluded; 203 m_occlusion = &occluded;
204 204
205 // The tile size is 100x100, so this invalidates and then paints two tiles. 205 // The tile size is 100x100, so this invalidates and then paints two tiles.
206 layer->setBounds(IntSize(100, 200)); 206 layer->setBounds(IntSize(100, 200));
207 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 207 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
208 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 208 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
209 updateAndPush(layer.get(), layerImpl.get()); 209 updateAndPush(layer.get(), layerImpl.get());
210 210
211 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 211 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
212 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1 ); 212 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1 );
(...skipping 11 matching lines...) Expand all
224 224
225 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 225 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
226 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 2500, 1); 226 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 2500, 1);
227 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); 227 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
228 228
229 // We should still have both tiles, as part of the top tile is still unocclu ded. 229 // We should still have both tiles, as part of the top tile is still unocclu ded.
230 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 230 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
231 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 231 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
232 } 232 }
233 233
234 TEST_F(TiledLayerChromiumTest, pushDeletedTiles) 234 TEST_F(TiledLayerTest, pushDeletedTiles)
235 { 235 {
236 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 236 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
237 ScopedFakeCCTiledLayerImpl layerImpl(1); 237 ScopedFakeTiledLayerImpl layerImpl(1);
238 238
239 // The tile size is 100x100, so this invalidates and then paints two tiles. 239 // The tile size is 100x100, so this invalidates and then paints two tiles.
240 layer->setBounds(IntSize(100, 200)); 240 layer->setBounds(IntSize(100, 200));
241 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 241 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
242 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 242 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
243 updateAndPush(layer.get(), layerImpl.get()); 243 updateAndPush(layer.get(), layerImpl.get());
244 244
245 // We should have both tiles on the impl side. 245 // We should have both tiles on the impl side.
246 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 246 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
247 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 247 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
(...skipping 11 matching lines...) Expand all
259 259
260 // This should recreate and update one of the deleted textures. 260 // This should recreate and update one of the deleted textures.
261 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); 261 layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
262 updateAndPush(layer.get(), layerImpl.get()); 262 updateAndPush(layer.get(), layerImpl.get());
263 263
264 // We should have one tiles on the impl side. 264 // We should have one tiles on the impl side.
265 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 265 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
266 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 266 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
267 } 267 }
268 268
269 TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles) 269 TEST_F(TiledLayerTest, pushIdlePaintTiles)
270 { 270 {
271 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 271 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
272 ScopedFakeCCTiledLayerImpl layerImpl(1); 272 ScopedFakeTiledLayerImpl layerImpl(1);
273 273
274 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter. 274 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter.
275 // This paints 1 visible of the 25 invalid tiles. 275 // This paints 1 visible of the 25 invalid tiles.
276 layer->setBounds(IntSize(500, 500)); 276 layer->setBounds(IntSize(500, 500));
277 layer->setVisibleContentRect(IntRect(200, 200, 100, 100)); 277 layer->setVisibleContentRect(IntRect(200, 200, 100, 100));
278 layer->invalidateContentRect(IntRect(0, 0, 500, 500)); 278 layer->invalidateContentRect(IntRect(0, 0, 500, 500));
279 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 279 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
280 // We should need idle-painting for surrounding tiles. 280 // We should need idle-painting for surrounding tiles.
281 EXPECT_TRUE(needsUpdate); 281 EXPECT_TRUE(needsUpdate);
282 282
(...skipping 12 matching lines...) Expand all
295 for (int j = 0; j < 5; j++) 295 for (int j = 0; j < 5; j++)
296 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), idlePaintTiles.co ntains(i, j)); 296 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), idlePaintTiles.co ntains(i, j));
297 } 297 }
298 298
299 // We should always finish painting eventually. 299 // We should always finish painting eventually.
300 for (int i = 0; i < 20; i++) 300 for (int i = 0; i < 20; i++)
301 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 301 needsUpdate = updateAndPush(layer.get(), layerImpl.get());
302 EXPECT_FALSE(needsUpdate); 302 EXPECT_FALSE(needsUpdate);
303 } 303 }
304 304
305 TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) 305 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed)
306 { 306 {
307 // Start with 2mb of memory, but the test is going to try to use just more t han 1mb, so we reduce to 1mb later. 307 // Start with 2mb of memory, but the test is going to try to use just more t han 1mb, so we reduce to 1mb later.
308 m_textureManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); 308 m_textureManager->setMaxMemoryLimitBytes(2 * 1024 * 1024);
309 scoped_refptr<FakeTiledLayerChromium> layer1 = make_scoped_refptr(new FakeTi ledLayerChromium(m_textureManager.get())); 309 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_textureManager.get()));
310 ScopedFakeCCTiledLayerImpl layerImpl1(1); 310 ScopedFakeTiledLayerImpl layerImpl1(1);
311 scoped_refptr<FakeTiledLayerChromium> layer2 = make_scoped_refptr(new FakeTi ledLayerChromium(m_textureManager.get())); 311 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_textureManager.get()));
312 ScopedFakeCCTiledLayerImpl layerImpl2(2); 312 ScopedFakeTiledLayerImpl layerImpl2(2);
313 313
314 // For this test we have two layers. layer1 exhausts most texture memory, le aving room for 2 more tiles from 314 // For this test we have two layers. layer1 exhausts most texture memory, le aving room for 2 more tiles from
315 // layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint 315 // layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint
316 // layer2, we will fail on the third tile of layer2, and this should not lea ve the second tile in a bad state. 316 // layer2, we will fail on the third tile of layer2, and this should not lea ve the second tile in a bad state.
317 317
318 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou gh for 2 tiles only in the other layer. 318 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou gh for 2 tiles only in the other layer.
319 IntRect layer1Rect(0, 0, 100, 2400); 319 IntRect layer1Rect(0, 0, 100, 2400);
320 320
321 // This requires 4*30000 bytes of memory. 321 // This requires 4*30000 bytes of memory.
322 IntRect layer2Rect(0, 0, 100, 300); 322 IntRect layer2Rect(0, 0, 100, 300);
(...skipping 26 matching lines...) Expand all
349 // it failed to idle update the last tile. 349 // it failed to idle update the last tile.
350 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0)); 350 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0));
351 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0)); 351 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0));
352 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); 352 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1));
353 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); 353 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1));
354 354
355 EXPECT_FALSE(needsUpdate); 355 EXPECT_FALSE(needsUpdate);
356 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2)); 356 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2));
357 } 357 }
358 358
359 TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles) 359 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles)
360 { 360 {
361 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 361 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
362 ScopedFakeCCTiledLayerImpl layerImpl(1); 362 ScopedFakeTiledLayerImpl layerImpl(1);
363 TestCCOcclusionTracker occluded; 363 TestOcclusionTracker occluded;
364 m_occlusion = &occluded; 364 m_occlusion = &occluded;
365 365
366 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it. 366 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it.
367 occluded.setOcclusion(IntRect(0, 0, 100, 100)); 367 occluded.setOcclusion(IntRect(0, 0, 100, 100));
368 368
369 layer->setBounds(IntSize(100, 100)); 369 layer->setBounds(IntSize(100, 100));
370 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); 370 layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
371 updateAndPush(layer.get(), layerImpl.get()); 371 updateAndPush(layer.get(), layerImpl.get());
372 372
373 // We should have the prepainted tile on the impl side, but culled it during paint. 373 // We should have the prepainted tile on the impl side, but culled it during paint.
374 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 374 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
375 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); 375 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload());
376 } 376 }
377 377
378 TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) 378 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint)
379 { 379 {
380 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 380 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
381 ScopedFakeCCTiledLayerImpl layerImpl(1); 381 ScopedFakeTiledLayerImpl layerImpl(1);
382 382
383 // The tile size is 100x100, so this invalidates and then paints two tiles. 383 // The tile size is 100x100, so this invalidates and then paints two tiles.
384 // However, during the paint, we invalidate one of the tiles. This should 384 // However, during the paint, we invalidate one of the tiles. This should
385 // not prevent the tile from being pushed. 385 // not prevent the tile from being pushed.
386 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50 ), layer.get()); 386 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50 ), layer.get());
387 layer->setBounds(IntSize(100, 200)); 387 layer->setBounds(IntSize(100, 200));
388 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 388 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
389 updateAndPush(layer.get(), layerImpl.get()); 389 updateAndPush(layer.get(), layerImpl.get());
390 390
391 // We should have both tiles on the impl side. 391 // We should have both tiles on the impl side.
392 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 392 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
393 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 393 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
394 } 394 }
395 395
396 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) 396 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
397 { 397 {
398 scoped_refptr<FakeTiledLayerChromium> layer1 = make_scoped_refptr(new FakeTi ledLayerChromium(m_textureManager.get())); 398 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_textureManager.get()));
399 scoped_refptr<FakeTiledLayerChromium> layer2 = make_scoped_refptr(new FakeTi ledLayerChromium(m_textureManager.get())); 399 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_textureManager.get()));
400 ScopedFakeCCTiledLayerImpl layer1Impl(1); 400 ScopedFakeTiledLayerImpl layer1Impl(1);
401 ScopedFakeCCTiledLayerImpl layer2Impl(2); 401 ScopedFakeTiledLayerImpl layer2Impl(2);
402 402
403 // Invalidate a tile on layer1, during update of layer 2. 403 // Invalidate a tile on layer1, during update of layer 2.
404 layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5 0), layer1.get()); 404 layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5 0), layer1.get());
405 layer1->setBounds(IntSize(100, 200)); 405 layer1->setBounds(IntSize(100, 200));
406 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); 406 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200));
407 layer2->setBounds(IntSize(100, 200)); 407 layer2->setBounds(IntSize(100, 200));
408 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); 408 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200));
409 updateAndPush(layer1.get(), layer1Impl.get(), 409 updateAndPush(layer1.get(), layer1Impl.get(),
410 layer2.get(), layer2Impl.get()); 410 layer2.get(), layer2Impl.get());
411 411
412 // We should have both tiles on the impl side for all layers. 412 // We should have both tiles on the impl side for all layers.
413 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); 413 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0));
414 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); 414 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1));
415 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); 415 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0));
416 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); 416 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1));
417 } 417 }
418 418
419 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLay er) 419 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer)
420 { 420 {
421 scoped_refptr<FakeTiledLayerChromium> layer1 = make_scoped_refptr(new FakeTi ledLayerChromium(m_textureManager.get())); 421 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_textureManager.get()));
422 scoped_refptr<FakeTiledLayerChromium> layer2 = make_scoped_refptr(new FakeTi ledLayerChromium(m_textureManager.get())); 422 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_textureManager.get()));
423 ScopedFakeCCTiledLayerImpl layer1Impl(1); 423 ScopedFakeTiledLayerImpl layer1Impl(1);
424 ScopedFakeCCTiledLayerImpl layer2Impl(2); 424 ScopedFakeTiledLayerImpl layer2Impl(2);
425 425
426 layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5 0), layer2.get()); 426 layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5 0), layer2.get());
427 layer1->setBounds(IntSize(100, 200)); 427 layer1->setBounds(IntSize(100, 200));
428 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); 428 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200));
429 layer2->setBounds(IntSize(100, 200)); 429 layer2->setBounds(IntSize(100, 200));
430 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); 430 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200));
431 updateAndPush(layer1.get(), layer1Impl.get(), 431 updateAndPush(layer1.get(), layer1Impl.get(),
432 layer2.get(), layer2Impl.get()); 432 layer2.get(), layer2Impl.get());
433 433
434 // We should have both tiles on the impl side for all layers. 434 // We should have both tiles on the impl side for all layers.
435 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); 435 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0));
436 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); 436 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1));
437 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); 437 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0));
438 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); 438 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1));
439 } 439 }
440 440
441 TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately) 441 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
442 { 442 {
443 // Create a CCLayerTreeHost that has the right viewportsize, 443 // Create a LayerTreeHost that has the right viewportsize,
444 // so the layer is considered small enough. 444 // so the layer is considered small enough.
445 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; 445 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
446 scoped_ptr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeC CLayerTreeHostClient, CCLayerTreeSettings()); 446 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, LayerTreeSettings());
447 447
448 bool runOutOfMemory[2] = {false, true}; 448 bool runOutOfMemory[2] = {false, true};
449 for (int i = 0; i < 2; i++) { 449 for (int i = 0; i < 2; i++) {
450 // Create a layer with 4x4 tiles. 450 // Create a layer with 4x4 tiles.
451 int layerWidth = 4 * FakeTiledLayerChromium::tileSize().width(); 451 int layerWidth = 4 * FakeTiledLayer::tileSize().width();
452 int layerHeight = 4 * FakeTiledLayerChromium::tileSize().height(); 452 int layerHeight = 4 * FakeTiledLayer::tileSize().height();
453 int memoryForLayer = layerWidth * layerHeight * 4; 453 int memoryForLayer = layerWidth * layerHeight * 4;
454 IntSize viewportSize = IntSize(layerWidth, layerHeight); 454 IntSize viewportSize = IntSize(layerWidth, layerHeight);
455 ccLayerTreeHost->setViewportSize(viewportSize, viewportSize); 455 layerTreeHost->setViewportSize(viewportSize, viewportSize);
456 456
457 // Use 8x4 tiles to run out of memory. 457 // Use 8x4 tiles to run out of memory.
458 if (runOutOfMemory[i]) 458 if (runOutOfMemory[i])
459 layerWidth *= 2; 459 layerWidth *= 2;
460 460
461 m_textureManager->setMaxMemoryLimitBytes(memoryForLayer); 461 m_textureManager->setMaxMemoryLimitBytes(memoryForLayer);
462 462
463 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new Fak eTiledLayerChromium(m_textureManager.get())); 463 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa yer(m_textureManager.get()));
464 ScopedFakeCCTiledLayerImpl layerImpl(1); 464 ScopedFakeTiledLayerImpl layerImpl(1);
465 465
466 // Full size layer with half being visible. 466 // Full size layer with half being visible.
467 IntSize contentBounds(layerWidth, layerHeight); 467 IntSize contentBounds(layerWidth, layerHeight);
468 IntRect contentRect(IntPoint::zero(), contentBounds); 468 IntRect contentRect(IntPoint::zero(), contentBounds);
469 IntRect visibleRect(IntPoint::zero(), IntSize(layerWidth / 2, layerHeigh t)); 469 IntRect visibleRect(IntPoint::zero(), IntSize(layerWidth / 2, layerHeigh t));
470 470
471 // Pretend the layer is animating. 471 // Pretend the layer is animating.
472 layer->setDrawTransformIsAnimating(true); 472 layer->setDrawTransformIsAnimating(true);
473 layer->setBounds(contentBounds); 473 layer->setBounds(contentBounds);
474 layer->setVisibleContentRect(visibleRect); 474 layer->setVisibleContentRect(visibleRect);
475 layer->invalidateContentRect(contentRect); 475 layer->invalidateContentRect(contentRect);
476 layer->setLayerTreeHost(ccLayerTreeHost.get()); 476 layer->setLayerTreeHost(layerTreeHost.get());
477 477
478 // The layer should paint it's entire contents on the first paint 478 // The layer should paint it's entire contents on the first paint
479 // if it is close to the viewport size and has the available memory. 479 // if it is close to the viewport size and has the available memory.
480 layer->setTexturePriorities(m_priorityCalculator); 480 layer->setTexturePriorities(m_priorityCalculator);
481 m_textureManager->prioritizeTextures(); 481 m_textureManager->prioritizeTextures();
482 layer->update(*m_queue.get(), 0, m_stats); 482 layer->update(*m_queue.get(), 0, m_stats);
483 updateTextures(); 483 updateTextures();
484 layerPushPropertiesTo(layer.get(), layerImpl.get()); 484 layerPushPropertiesTo(layer.get(), layerImpl.get());
485 485
486 // We should have all the tiles for the small animated layer. 486 // We should have all the tiles for the small animated layer.
487 // We should still have the visible tiles when we didn't 487 // We should still have the visible tiles when we didn't
488 // have enough memory for all the tiles. 488 // have enough memory for all the tiles.
489 if (!runOutOfMemory[i]) { 489 if (!runOutOfMemory[i]) {
490 for (int i = 0; i < 4; ++i) { 490 for (int i = 0; i < 4; ++i) {
491 for (int j = 0; j < 4; ++j) 491 for (int j = 0; j < 4; ++j)
492 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j)); 492 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j));
493 } 493 }
494 } else { 494 } else {
495 for (int i = 0; i < 8; ++i) { 495 for (int i = 0; i < 8; ++i) {
496 for (int j = 0; j < 4; ++j) 496 for (int j = 0; j < 4; ++j)
497 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 4); 497 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 4);
498 } 498 }
499 } 499 }
500 } 500 }
501 } 501 }
502 502
503 TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) 503 TEST_F(TiledLayerTest, idlePaintOutOfMemory)
504 { 504 {
505 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 505 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
506 ScopedFakeCCTiledLayerImpl layerImpl(1); 506 ScopedFakeTiledLayerImpl layerImpl(1);
507 507
508 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint. 508 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint.
509 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. 509 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel.
510 m_textureManager->setMaxMemoryLimitBytes(memoryLimit); 510 m_textureManager->setMaxMemoryLimitBytes(memoryLimit);
511 511
512 // The tile size is 100x100, so this invalidates and then paints two tiles. 512 // The tile size is 100x100, so this invalidates and then paints two tiles.
513 bool needsUpdate = false; 513 bool needsUpdate = false;
514 layer->setBounds(IntSize(300, 300)); 514 layer->setBounds(IntSize(300, 300));
515 layer->setVisibleContentRect(IntRect(100, 100, 100, 100)); 515 layer->setVisibleContentRect(IntRect(100, 100, 100, 100));
516 for (int i = 0; i < 2; i++) 516 for (int i = 0; i < 2; i++)
517 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 517 needsUpdate = updateAndPush(layer.get(), layerImpl.get());
518 518
519 // Idle-painting should see no more priority tiles for painting. 519 // Idle-painting should see no more priority tiles for painting.
520 EXPECT_FALSE(needsUpdate); 520 EXPECT_FALSE(needsUpdate);
521 521
522 // We should have one tile on the impl side. 522 // We should have one tile on the impl side.
523 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); 523 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1));
524 } 524 }
525 525
526 TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer) 526 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer)
527 { 527 {
528 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 528 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
529 ScopedFakeCCTiledLayerImpl layerImpl(1); 529 ScopedFakeTiledLayerImpl layerImpl(1);
530 530
531 bool animating[2] = {false, true}; 531 bool animating[2] = {false, true};
532 for (int i = 0; i < 2; i++) { 532 for (int i = 0; i < 2; i++) {
533 // Pretend the layer is animating. 533 // Pretend the layer is animating.
534 layer->setDrawTransformIsAnimating(animating[i]); 534 layer->setDrawTransformIsAnimating(animating[i]);
535 535
536 // The layer's bounds are empty. 536 // The layer's bounds are empty.
537 // Empty layers don't paint or idle-paint. 537 // Empty layers don't paint or idle-paint.
538 layer->setBounds(IntSize()); 538 layer->setBounds(IntSize());
539 layer->setVisibleContentRect(IntRect()); 539 layer->setVisibleContentRect(IntRect());
540 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 540 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
541 541
542 // Empty layers don't have tiles. 542 // Empty layers don't have tiles.
543 EXPECT_EQ(0u, layer->numPaintedTiles()); 543 EXPECT_EQ(0u, layer->numPaintedTiles());
544 544
545 // Empty layers don't need prepaint. 545 // Empty layers don't need prepaint.
546 EXPECT_FALSE(needsUpdate); 546 EXPECT_FALSE(needsUpdate);
547 547
548 // Empty layers don't have tiles. 548 // Empty layers don't have tiles.
549 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); 549 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
550 } 550 }
551 } 551 }
552 552
553 TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers) 553 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers)
554 { 554 {
555 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 555 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
556 ScopedFakeCCTiledLayerImpl layerImpl(1); 556 ScopedFakeTiledLayerImpl layerImpl(1);
557 557
558 // Alternate between not visible and visible. 558 // Alternate between not visible and visible.
559 IntRect v(0, 0, 100, 100); 559 IntRect v(0, 0, 100, 100);
560 IntRect nv(0, 0, 0, 0); 560 IntRect nv(0, 0, 0, 0);
561 IntRect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; 561 IntRect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv};
562 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false }; 562 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false };
563 563
564 // We should not have any tiles except for when the layer was visible 564 // We should not have any tiles except for when the layer was visible
565 // or after the layer was visible and we didn't invalidate. 565 // or after the layer was visible and we didn't invalidate.
566 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true }; 566 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true };
567 567
568 for (int i = 0; i < 10; i++) { 568 for (int i = 0; i < 10; i++) {
569 layer->setBounds(IntSize(100, 100)); 569 layer->setBounds(IntSize(100, 100));
570 layer->setVisibleContentRect(visibleRect[i]); 570 layer->setVisibleContentRect(visibleRect[i]);
571 571
572 if (invalidate[i]) 572 if (invalidate[i])
573 layer->invalidateContentRect(IntRect(0, 0, 100, 100)); 573 layer->invalidateContentRect(IntRect(0, 0, 100, 100));
574 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 574 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
575 575
576 // We should never signal idle paint, as we painted the entire layer 576 // We should never signal idle paint, as we painted the entire layer
577 // or the layer was not visible. 577 // or the layer was not visible.
578 EXPECT_FALSE(needsUpdate); 578 EXPECT_FALSE(needsUpdate);
579 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); 579 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]);
580 } 580 }
581 } 581 }
582 582
583 TEST_F(TiledLayerChromiumTest, invalidateFromPrepare) 583 TEST_F(TiledLayerTest, invalidateFromPrepare)
584 { 584 {
585 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 585 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
586 ScopedFakeCCTiledLayerImpl layerImpl(1); 586 ScopedFakeTiledLayerImpl layerImpl(1);
587 587
588 // The tile size is 100x100, so this invalidates and then paints two tiles. 588 // The tile size is 100x100, so this invalidates and then paints two tiles.
589 layer->setBounds(IntSize(100, 200)); 589 layer->setBounds(IntSize(100, 200));
590 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 590 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
591 updateAndPush(layer.get(), layerImpl.get()); 591 updateAndPush(layer.get(), layerImpl.get());
592 592
593 // We should have both tiles on the impl side. 593 // We should have both tiles on the impl side.
594 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 594 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
595 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 595 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
596 596
597 layer->fakeLayerTextureUpdater()->clearPrepareCount(); 597 layer->fakeLayerTextureUpdater()->clearPrepareCount();
598 // Invoke update again. As the layer is valid update shouldn't be invoked on 598 // Invoke update again. As the layer is valid update shouldn't be invoked on
599 // the LayerTextureUpdater. 599 // the LayerTextureUpdater.
600 updateAndPush(layer.get(), layerImpl.get()); 600 updateAndPush(layer.get(), layerImpl.get());
601 EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount()); 601 EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount());
602 602
603 // setRectToInvalidate triggers invalidateContentRect() being invoked from u pdate. 603 // setRectToInvalidate triggers invalidateContentRect() being invoked from u pdate.
604 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50 ), layer.get()); 604 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50 ), layer.get());
605 layer->fakeLayerTextureUpdater()->clearPrepareCount(); 605 layer->fakeLayerTextureUpdater()->clearPrepareCount();
606 layer->invalidateContentRect(IntRect(0, 0, 50, 50)); 606 layer->invalidateContentRect(IntRect(0, 0, 50, 50));
607 updateAndPush(layer.get(), layerImpl.get()); 607 updateAndPush(layer.get(), layerImpl.get());
608 EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); 608 EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount());
609 layer->fakeLayerTextureUpdater()->clearPrepareCount(); 609 layer->fakeLayerTextureUpdater()->clearPrepareCount();
610 610
611 // The layer should still be invalid as update invoked invalidate. 611 // The layer should still be invalid as update invoked invalidate.
612 updateAndPush(layer.get(), layerImpl.get()); // visible 612 updateAndPush(layer.get(), layerImpl.get()); // visible
613 EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); 613 EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount());
614 } 614 }
615 615
616 TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) 616 TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled)
617 { 617 {
618 // The updateRect (that indicates what was actually painted) should be in 618 // The updateRect (that indicates what was actually painted) should be in
619 // layer space, not the content space. 619 // layer space, not the content space.
620 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new FakeTiledLayerWithScaledBounds(m_textureManager.get())); 620 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new FakeTiledLayerWithScaledBounds(m_textureManager.get()));
621 621
622 IntRect layerBounds(0, 0, 300, 200); 622 IntRect layerBounds(0, 0, 300, 200);
623 IntRect contentBounds(0, 0, 200, 250); 623 IntRect contentBounds(0, 0, 200, 250);
624 624
625 layer->setBounds(layerBounds.size()); 625 layer->setBounds(layerBounds.size());
626 layer->setContentBounds(contentBounds.size()); 626 layer->setContentBounds(contentBounds.size());
(...skipping 19 matching lines...) Expand all
646 646
647 // Partial re-paint should also be represented by the updateRect in layer sp ace, not content space. 647 // Partial re-paint should also be represented by the updateRect in layer sp ace, not content space.
648 IntRect partialDamage(30, 100, 10, 10); 648 IntRect partialDamage(30, 100, 10, 10);
649 layer->invalidateContentRect(partialDamage); 649 layer->invalidateContentRect(partialDamage);
650 layer->setTexturePriorities(m_priorityCalculator); 650 layer->setTexturePriorities(m_priorityCalculator);
651 m_textureManager->prioritizeTextures(); 651 m_textureManager->prioritizeTextures();
652 layer->update(*m_queue.get(), 0, m_stats); 652 layer->update(*m_queue.get(), 0, m_stats);
653 EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); 653 EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect());
654 } 654 }
655 655
656 TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) 656 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges)
657 { 657 {
658 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 658 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
659 ScopedFakeCCTiledLayerImpl layerImpl(1); 659 ScopedFakeTiledLayerImpl layerImpl(1);
660 660
661 // Create a layer with one tile. 661 // Create a layer with one tile.
662 layer->setBounds(IntSize(100, 100)); 662 layer->setBounds(IntSize(100, 100));
663 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); 663 layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
664 664
665 // Invalidate the entire layer. 665 // Invalidate the entire layer.
666 layer->setNeedsDisplay(); 666 layer->setNeedsDisplay();
667 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect( )); 667 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect( ));
668 668
669 // Push the tiles to the impl side and check that there is exactly one. 669 // Push the tiles to the impl side and check that there is exactly one.
(...skipping 30 matching lines...) Expand all
700 layer->setTexturePriorities(m_priorityCalculator); 700 layer->setTexturePriorities(m_priorityCalculator);
701 m_textureManager->prioritizeTextures(); 701 m_textureManager->prioritizeTextures();
702 702
703 layerPushPropertiesTo(layer.get(), layerImpl.get()); 703 layerPushPropertiesTo(layer.get(), layerImpl.get());
704 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); 704 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
705 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 705 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
706 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); 706 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0));
707 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); 707 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1));
708 } 708 }
709 709
710 TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset) 710 TEST_F(TiledLayerTest, skipsDrawGetsReset)
711 { 711 {
712 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; 712 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
713 scoped_ptr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeC CLayerTreeHostClient, CCLayerTreeSettings()); 713 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, LayerTreeSettings());
714 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); 714 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded());
715 715
716 // Create two 300 x 300 tiled layers. 716 // Create two 300 x 300 tiled layers.
717 IntSize contentBounds(300, 300); 717 IntSize contentBounds(300, 300);
718 IntRect contentRect(IntPoint::zero(), contentBounds); 718 IntRect contentRect(IntPoint::zero(), contentBounds);
719 719
720 // We have enough memory for only one of the two layers. 720 // We have enough memory for only one of the two layers.
721 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. 721 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel.
722 722
723 scoped_refptr<FakeTiledLayerChromium> rootLayer = make_scoped_refptr(new Fak eTiledLayerChromium(ccLayerTreeHost->contentsTextureManager())); 723 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa yer(layerTreeHost->contentsTextureManager()));
724 scoped_refptr<FakeTiledLayerChromium> childLayer = make_scoped_refptr(new Fa keTiledLayerChromium(ccLayerTreeHost->contentsTextureManager())); 724 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL ayer(layerTreeHost->contentsTextureManager()));
725 rootLayer->addChild(childLayer); 725 rootLayer->addChild(childLayer);
726 726
727 rootLayer->setBounds(contentBounds); 727 rootLayer->setBounds(contentBounds);
728 rootLayer->setVisibleContentRect(contentRect); 728 rootLayer->setVisibleContentRect(contentRect);
729 rootLayer->setPosition(FloatPoint(0, 0)); 729 rootLayer->setPosition(FloatPoint(0, 0));
730 childLayer->setBounds(contentBounds); 730 childLayer->setBounds(contentBounds);
731 childLayer->setVisibleContentRect(contentRect); 731 childLayer->setVisibleContentRect(contentRect);
732 childLayer->setPosition(FloatPoint(0, 0)); 732 childLayer->setPosition(FloatPoint(0, 0));
733 rootLayer->invalidateContentRect(contentRect); 733 rootLayer->invalidateContentRect(contentRect);
734 childLayer->invalidateContentRect(contentRect); 734 childLayer->invalidateContentRect(contentRect);
735 735
736 ccLayerTreeHost->setRootLayer(rootLayer); 736 layerTreeHost->setRootLayer(rootLayer);
737 ccLayerTreeHost->setViewportSize(IntSize(300, 300), IntSize(300, 300)); 737 layerTreeHost->setViewportSize(IntSize(300, 300), IntSize(300, 300));
738 738
739 ccLayerTreeHost->updateLayers(*m_queue.get(), memoryLimit); 739 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
740 740
741 // We'll skip the root layer. 741 // We'll skip the root layer.
742 EXPECT_TRUE(rootLayer->skipsDraw()); 742 EXPECT_TRUE(rootLayer->skipsDraw());
743 EXPECT_FALSE(childLayer->skipsDraw()); 743 EXPECT_FALSE(childLayer->skipsDraw());
744 744
745 ccLayerTreeHost->commitComplete(); 745 layerTreeHost->commitComplete();
746 746
747 // Remove the child layer. 747 // Remove the child layer.
748 rootLayer->removeAllChildren(); 748 rootLayer->removeAllChildren();
749 749
750 ccLayerTreeHost->updateLayers(*m_queue.get(), memoryLimit); 750 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
751 EXPECT_FALSE(rootLayer->skipsDraw()); 751 EXPECT_FALSE(rootLayer->skipsDraw());
752 752
753 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re sourceProvider.get()); 753 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso urceProvider.get());
754 ccLayerTreeHost->setRootLayer(0); 754 layerTreeHost->setRootLayer(0);
755 } 755 }
756 756
757 TEST_F(TiledLayerChromiumTest, resizeToSmaller) 757 TEST_F(TiledLayerTest, resizeToSmaller)
758 { 758 {
759 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 759 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
760 760
761 layer->setBounds(IntSize(700, 700)); 761 layer->setBounds(IntSize(700, 700));
762 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); 762 layer->setVisibleContentRect(IntRect(0, 0, 700, 700));
763 layer->invalidateContentRect(IntRect(0, 0, 700, 700)); 763 layer->invalidateContentRect(IntRect(0, 0, 700, 700));
764 764
765 layer->setTexturePriorities(m_priorityCalculator); 765 layer->setTexturePriorities(m_priorityCalculator);
766 m_textureManager->prioritizeTextures(); 766 m_textureManager->prioritizeTextures();
767 layer->update(*m_queue.get(), 0, m_stats); 767 layer->update(*m_queue.get(), 0, m_stats);
768 768
769 layer->setBounds(IntSize(200, 200)); 769 layer->setBounds(IntSize(200, 200));
770 layer->invalidateContentRect(IntRect(0, 0, 200, 200)); 770 layer->invalidateContentRect(IntRect(0, 0, 200, 200));
771 } 771 }
772 772
773 TEST_F(TiledLayerChromiumTest, hugeLayerUpdateCrash) 773 TEST_F(TiledLayerTest, hugeLayerUpdateCrash)
774 { 774 {
775 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 775 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
776 776
777 int size = 1 << 30; 777 int size = 1 << 30;
778 layer->setBounds(IntSize(size, size)); 778 layer->setBounds(IntSize(size, size));
779 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); 779 layer->setVisibleContentRect(IntRect(0, 0, 700, 700));
780 layer->invalidateContentRect(IntRect(0, 0, size, size)); 780 layer->invalidateContentRect(IntRect(0, 0, size, size));
781 781
782 // Ensure no crash for bounds where size * size would overflow an int. 782 // Ensure no crash for bounds where size * size would overflow an int.
783 layer->setTexturePriorities(m_priorityCalculator); 783 layer->setTexturePriorities(m_priorityCalculator);
784 m_textureManager->prioritizeTextures(); 784 m_textureManager->prioritizeTextures();
785 layer->update(*m_queue.get(), 0, m_stats); 785 layer->update(*m_queue.get(), 0, m_stats);
786 } 786 }
787 787
788 TEST_F(TiledLayerChromiumTest, partialUpdates) 788 TEST_F(TiledLayerTest, partialUpdates)
789 { 789 {
790 CCLayerTreeSettings settings; 790 LayerTreeSettings settings;
791 settings.maxPartialTextureUpdates = 4; 791 settings.maxPartialTextureUpdates = 4;
792 792
793 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; 793 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
794 scoped_ptr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeC CLayerTreeHostClient, settings); 794 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, settings);
795 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); 795 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded());
796 796
797 // Create one 300 x 200 tiled layer with 3 x 2 tiles. 797 // Create one 300 x 200 tiled layer with 3 x 2 tiles.
798 IntSize contentBounds(300, 200); 798 IntSize contentBounds(300, 200);
799 IntRect contentRect(IntPoint::zero(), contentBounds); 799 IntRect contentRect(IntPoint::zero(), contentBounds);
800 800
801 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(ccLayerTreeHost->contentsTextureManager())); 801 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( layerTreeHost->contentsTextureManager()));
802 layer->setBounds(contentBounds); 802 layer->setBounds(contentBounds);
803 layer->setPosition(FloatPoint(0, 0)); 803 layer->setPosition(FloatPoint(0, 0));
804 layer->setVisibleContentRect(contentRect); 804 layer->setVisibleContentRect(contentRect);
805 layer->invalidateContentRect(contentRect); 805 layer->invalidateContentRect(contentRect);
806 806
807 ccLayerTreeHost->setRootLayer(layer); 807 layerTreeHost->setRootLayer(layer);
808 ccLayerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200)); 808 layerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200));
809 809
810 // Full update of all 6 tiles. 810 // Full update of all 6 tiles.
811 ccLayerTreeHost->updateLayers( 811 layerTreeHost->updateLayers(
812 *m_queue.get(), std::numeric_limits<size_t>::max()); 812 *m_queue.get(), std::numeric_limits<size_t>::max());
813 { 813 {
814 ScopedFakeCCTiledLayerImpl layerImpl(1); 814 ScopedFakeTiledLayerImpl layerImpl(1);
815 EXPECT_EQ(6, m_queue->fullUploadSize()); 815 EXPECT_EQ(6, m_queue->fullUploadSize());
816 EXPECT_EQ(0, m_queue->partialUploadSize()); 816 EXPECT_EQ(0, m_queue->partialUploadSize());
817 updateTextures(); 817 updateTextures();
818 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); 818 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount());
819 EXPECT_FALSE(m_queue->hasMoreUpdates()); 819 EXPECT_FALSE(m_queue->hasMoreUpdates());
820 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 820 layer->fakeLayerTextureUpdater()->clearUpdateCount();
821 layerPushPropertiesTo(layer.get(), layerImpl.get()); 821 layerPushPropertiesTo(layer.get(), layerImpl.get());
822 } 822 }
823 ccLayerTreeHost->commitComplete(); 823 layerTreeHost->commitComplete();
824 824
825 // Full update of 3 tiles and partial update of 3 tiles. 825 // Full update of 3 tiles and partial update of 3 tiles.
826 layer->invalidateContentRect(IntRect(0, 0, 300, 150)); 826 layer->invalidateContentRect(IntRect(0, 0, 300, 150));
827 ccLayerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m ax()); 827 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max ());
828 { 828 {
829 ScopedFakeCCTiledLayerImpl layerImpl(1); 829 ScopedFakeTiledLayerImpl layerImpl(1);
830 EXPECT_EQ(3, m_queue->fullUploadSize()); 830 EXPECT_EQ(3, m_queue->fullUploadSize());
831 EXPECT_EQ(3, m_queue->partialUploadSize()); 831 EXPECT_EQ(3, m_queue->partialUploadSize());
832 updateTextures(); 832 updateTextures();
833 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); 833 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount());
834 EXPECT_FALSE(m_queue->hasMoreUpdates()); 834 EXPECT_FALSE(m_queue->hasMoreUpdates());
835 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 835 layer->fakeLayerTextureUpdater()->clearUpdateCount();
836 layerPushPropertiesTo(layer.get(), layerImpl.get()); 836 layerPushPropertiesTo(layer.get(), layerImpl.get());
837 } 837 }
838 ccLayerTreeHost->commitComplete(); 838 layerTreeHost->commitComplete();
839 839
840 // Partial update of 6 tiles. 840 // Partial update of 6 tiles.
841 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); 841 layer->invalidateContentRect(IntRect(50, 50, 200, 100));
842 { 842 {
843 ScopedFakeCCTiledLayerImpl layerImpl(1); 843 ScopedFakeTiledLayerImpl layerImpl(1);
844 ccLayerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); 844 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>: :max());
845 EXPECT_EQ(2, m_queue->fullUploadSize()); 845 EXPECT_EQ(2, m_queue->fullUploadSize());
846 EXPECT_EQ(4, m_queue->partialUploadSize()); 846 EXPECT_EQ(4, m_queue->partialUploadSize());
847 updateTextures(); 847 updateTextures();
848 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); 848 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount());
849 EXPECT_FALSE(m_queue->hasMoreUpdates()); 849 EXPECT_FALSE(m_queue->hasMoreUpdates());
850 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 850 layer->fakeLayerTextureUpdater()->clearUpdateCount();
851 layerPushPropertiesTo(layer.get(), layerImpl.get()); 851 layerPushPropertiesTo(layer.get(), layerImpl.get());
852 } 852 }
853 ccLayerTreeHost->commitComplete(); 853 layerTreeHost->commitComplete();
854 854
855 // Checkerboard all tiles. 855 // Checkerboard all tiles.
856 layer->invalidateContentRect(IntRect(0, 0, 300, 200)); 856 layer->invalidateContentRect(IntRect(0, 0, 300, 200));
857 { 857 {
858 ScopedFakeCCTiledLayerImpl layerImpl(1); 858 ScopedFakeTiledLayerImpl layerImpl(1);
859 layerPushPropertiesTo(layer.get(), layerImpl.get()); 859 layerPushPropertiesTo(layer.get(), layerImpl.get());
860 } 860 }
861 ccLayerTreeHost->commitComplete(); 861 layerTreeHost->commitComplete();
862 862
863 // Partial update of 6 checkerboard tiles. 863 // Partial update of 6 checkerboard tiles.
864 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); 864 layer->invalidateContentRect(IntRect(50, 50, 200, 100));
865 { 865 {
866 ScopedFakeCCTiledLayerImpl layerImpl(1); 866 ScopedFakeTiledLayerImpl layerImpl(1);
867 ccLayerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); 867 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>: :max());
868 EXPECT_EQ(6, m_queue->fullUploadSize()); 868 EXPECT_EQ(6, m_queue->fullUploadSize());
869 EXPECT_EQ(0, m_queue->partialUploadSize()); 869 EXPECT_EQ(0, m_queue->partialUploadSize());
870 updateTextures(); 870 updateTextures();
871 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); 871 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount());
872 EXPECT_FALSE(m_queue->hasMoreUpdates()); 872 EXPECT_FALSE(m_queue->hasMoreUpdates());
873 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 873 layer->fakeLayerTextureUpdater()->clearUpdateCount();
874 layerPushPropertiesTo(layer.get(), layerImpl.get()); 874 layerPushPropertiesTo(layer.get(), layerImpl.get());
875 } 875 }
876 ccLayerTreeHost->commitComplete(); 876 layerTreeHost->commitComplete();
877 877
878 // Partial update of 4 tiles. 878 // Partial update of 4 tiles.
879 layer->invalidateContentRect(IntRect(50, 50, 100, 100)); 879 layer->invalidateContentRect(IntRect(50, 50, 100, 100));
880 { 880 {
881 ScopedFakeCCTiledLayerImpl layerImpl(1); 881 ScopedFakeTiledLayerImpl layerImpl(1);
882 ccLayerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); 882 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>: :max());
883 EXPECT_EQ(0, m_queue->fullUploadSize()); 883 EXPECT_EQ(0, m_queue->fullUploadSize());
884 EXPECT_EQ(4, m_queue->partialUploadSize()); 884 EXPECT_EQ(4, m_queue->partialUploadSize());
885 updateTextures(); 885 updateTextures();
886 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); 886 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
887 EXPECT_FALSE(m_queue->hasMoreUpdates()); 887 EXPECT_FALSE(m_queue->hasMoreUpdates());
888 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 888 layer->fakeLayerTextureUpdater()->clearUpdateCount();
889 layerPushPropertiesTo(layer.get(), layerImpl.get()); 889 layerPushPropertiesTo(layer.get(), layerImpl.get());
890 } 890 }
891 ccLayerTreeHost->commitComplete(); 891 layerTreeHost->commitComplete();
892 892
893 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re sourceProvider.get()); 893 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso urceProvider.get());
894 ccLayerTreeHost->setRootLayer(0); 894 layerTreeHost->setRootLayer(0);
895 } 895 }
896 896
897 TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion) 897 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion)
898 { 898 {
899 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 899 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
900 900
901 // The tile size is 100x100, so this invalidates and then paints two tiles. 901 // The tile size is 100x100, so this invalidates and then paints two tiles.
902 layer->setBounds(IntSize(100, 200)); 902 layer->setBounds(IntSize(100, 200));
903 layer->setDrawableContentRect(IntRect(0, 0, 100, 200)); 903 layer->setDrawableContentRect(IntRect(0, 0, 100, 200));
904 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 904 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
905 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 905 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
906 906
907 layer->setTexturePriorities(m_priorityCalculator); 907 layer->setTexturePriorities(m_priorityCalculator);
908 m_textureManager->prioritizeTextures(); 908 m_textureManager->prioritizeTextures();
909 layer->update(*m_queue.get(), 0, m_stats); 909 layer->update(*m_queue.get(), 0, m_stats);
910 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); 910 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount());
911 } 911 }
912 912
913 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion) 913 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion)
914 { 914 {
915 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 915 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
916 TestCCOcclusionTracker occluded; 916 TestOcclusionTracker occluded;
917 917
918 // The tile size is 100x100. 918 // The tile size is 100x100.
919 919
920 layer->setBounds(IntSize(600, 600)); 920 layer->setBounds(IntSize(600, 600));
921 921
922 occluded.setOcclusion(IntRect(200, 200, 300, 100)); 922 occluded.setOcclusion(IntRect(200, 200, 300, 100));
923 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); 923 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds()));
924 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); 924 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
925 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); 925 layer->invalidateContentRect(IntRect(0, 0, 600, 600));
926 926
(...skipping 26 matching lines...) Expand all
953 occluded.setOcclusion(IntRect(250, 250, 300, 100)); 953 occluded.setOcclusion(IntRect(250, 250, 300, 100));
954 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); 954 layer->invalidateContentRect(IntRect(0, 0, 600, 600));
955 layer->update(*m_queue.get(), &occluded, m_stats); 955 layer->update(*m_queue.get(), &occluded, m_stats);
956 EXPECT_EQ(36, layer->fakeLayerTextureUpdater()->updateCount()); 956 EXPECT_EQ(36, layer->fakeLayerTextureUpdater()->updateCount());
957 957
958 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 958 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
959 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 + 340000 + 360000, 1); 959 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 + 340000 + 360000, 1);
960 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); 960 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload());
961 } 961 }
962 962
963 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints) 963 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
964 { 964 {
965 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 965 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
966 TestCCOcclusionTracker occluded; 966 TestOcclusionTracker occluded;
967 967
968 // The tile size is 100x100. 968 // The tile size is 100x100.
969 969
970 layer->setBounds(IntSize(600, 600)); 970 layer->setBounds(IntSize(600, 600));
971 971
972 // The partially occluded tiles (by the 150 occlusion height) are visible be yond the occlusion, so not culled. 972 // The partially occluded tiles (by the 150 occlusion height) are visible be yond the occlusion, so not culled.
973 occluded.setOcclusion(IntRect(200, 200, 300, 150)); 973 occluded.setOcclusion(IntRect(200, 200, 300, 150));
974 layer->setDrawableContentRect(IntRect(0, 0, 600, 360)); 974 layer->setDrawableContentRect(IntRect(0, 0, 600, 360));
975 layer->setVisibleContentRect(IntRect(0, 0, 600, 360)); 975 layer->setVisibleContentRect(IntRect(0, 0, 600, 360));
976 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); 976 layer->invalidateContentRect(IntRect(0, 0, 600, 600));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 m_textureManager->prioritizeTextures(); 1011 m_textureManager->prioritizeTextures();
1012 layer->update(*m_queue.get(), &occluded, m_stats); 1012 layer->update(*m_queue.get(), &occluded, m_stats);
1013 EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->updateCount()); 1013 EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->updateCount());
1014 1014
1015 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 1015 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
1016 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 + 180000 + 180000, 1); 1016 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 + 180000 + 180000, 1);
1017 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); 1017 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload());
1018 1018
1019 } 1019 }
1020 1020
1021 TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation) 1021 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation)
1022 { 1022 {
1023 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 1023 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
1024 TestCCOcclusionTracker occluded; 1024 TestOcclusionTracker occluded;
1025 1025
1026 // The tile size is 100x100. 1026 // The tile size is 100x100.
1027 1027
1028 layer->setBounds(IntSize(600, 600)); 1028 layer->setBounds(IntSize(600, 600));
1029 1029
1030 occluded.setOcclusion(IntRect(200, 200, 300, 100)); 1030 occluded.setOcclusion(IntRect(200, 200, 300, 100));
1031 layer->setDrawableContentRect(IntRect(0, 0, 600, 600)); 1031 layer->setDrawableContentRect(IntRect(0, 0, 600, 600));
1032 layer->setVisibleContentRect(IntRect(0, 0, 600, 600)); 1032 layer->setVisibleContentRect(IntRect(0, 0, 600, 600));
1033 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); 1033 layer->invalidateContentRect(IntRect(0, 0, 600, 600));
1034 layer->setTexturePriorities(m_priorityCalculator); 1034 layer->setTexturePriorities(m_priorityCalculator);
(...skipping 14 matching lines...) Expand all
1049 1049
1050 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now. 1050 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now.
1051 layer->update(*m_queue.get(), &occluded, m_stats); 1051 layer->update(*m_queue.get(), &occluded, m_stats);
1052 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); 1052 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount());
1053 1053
1054 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 1054 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
1055 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); 1055 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1);
1056 EXPECT_EQ(6, occluded.overdrawMetrics().tilesCulledForUpload()); 1056 EXPECT_EQ(6, occluded.overdrawMetrics().tilesCulledForUpload());
1057 } 1057 }
1058 1058
1059 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms) 1059 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms)
1060 { 1060 {
1061 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 1061 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
1062 TestCCOcclusionTracker occluded; 1062 TestOcclusionTracker occluded;
1063 1063
1064 // The tile size is 100x100. 1064 // The tile size is 100x100.
1065 1065
1066 // This makes sure the painting works when the occluded region (in screen sp ace) 1066 // This makes sure the painting works when the occluded region (in screen sp ace)
1067 // is transformed differently than the layer. 1067 // is transformed differently than the layer.
1068 layer->setBounds(IntSize(600, 600)); 1068 layer->setBounds(IntSize(600, 600));
1069 WebTransformationMatrix screenTransform; 1069 WebTransformationMatrix screenTransform;
1070 screenTransform.scale(0.5); 1070 screenTransform.scale(0.5);
1071 layer->setScreenSpaceTransform(screenTransform); 1071 layer->setScreenSpaceTransform(screenTransform);
1072 layer->setDrawTransform(screenTransform); 1072 layer->setDrawTransform(screenTransform);
1073 1073
1074 occluded.setOcclusion(IntRect(100, 100, 150, 50)); 1074 occluded.setOcclusion(IntRect(100, 100, 150, 50));
1075 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); 1075 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds()));
1076 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); 1076 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
1077 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); 1077 layer->invalidateContentRect(IntRect(0, 0, 600, 600));
1078 layer->setTexturePriorities(m_priorityCalculator); 1078 layer->setTexturePriorities(m_priorityCalculator);
1079 m_textureManager->prioritizeTextures(); 1079 m_textureManager->prioritizeTextures();
1080 layer->update(*m_queue.get(), &occluded, m_stats); 1080 layer->update(*m_queue.get(), &occluded, m_stats);
1081 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->updateCount()); 1081 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->updateCount());
1082 1082
1083 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 1083 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
1084 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); 1084 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1);
1085 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); 1085 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload());
1086 } 1086 }
1087 1087
1088 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling) 1088 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
1089 { 1089 {
1090 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 1090 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
1091 TestCCOcclusionTracker occluded; 1091 TestOcclusionTracker occluded;
1092 1092
1093 // The tile size is 100x100. 1093 // The tile size is 100x100.
1094 1094
1095 // This makes sure the painting works when the content space is scaled to 1095 // This makes sure the painting works when the content space is scaled to
1096 // a different layer space. In this case tiles are scaled to be 200x200 1096 // a different layer space. In this case tiles are scaled to be 200x200
1097 // pixels, which means none should be occluded. 1097 // pixels, which means none should be occluded.
1098 layer->setContentsScale(0.5); 1098 layer->setContentsScale(0.5);
1099 layer->setBounds(IntSize(600, 600)); 1099 layer->setBounds(IntSize(600, 600));
1100 WebTransformationMatrix drawTransform; 1100 WebTransformationMatrix drawTransform;
1101 drawTransform.scale(1 / layer->contentsScale()); 1101 drawTransform.scale(1 / layer->contentsScale());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 layer->setTexturePriorities(m_priorityCalculator); 1151 layer->setTexturePriorities(m_priorityCalculator);
1152 m_textureManager->prioritizeTextures(); 1152 m_textureManager->prioritizeTextures();
1153 layer->update(*m_queue.get(), &occluded, m_stats); 1153 layer->update(*m_queue.get(), &occluded, m_stats);
1154 EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->updateCount()); 1154 EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->updateCount());
1155 1155
1156 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 1156 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
1157 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 + 80000 + 80000, 1); 1157 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 + 80000 + 80000, 1);
1158 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload()); 1158 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload());
1159 } 1159 }
1160 1160
1161 TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) 1161 TEST_F(TiledLayerTest, visibleContentOpaqueRegion)
1162 { 1162 {
1163 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 1163 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
1164 TestCCOcclusionTracker occluded; 1164 TestOcclusionTracker occluded;
1165 1165
1166 // The tile size is 100x100, so this invalidates and then paints two tiles i n various ways. 1166 // The tile size is 100x100, so this invalidates and then paints two tiles i n various ways.
1167 1167
1168 IntRect opaquePaintRect; 1168 IntRect opaquePaintRect;
1169 Region opaqueContents; 1169 Region opaqueContents;
1170 1170
1171 IntRect contentBounds = IntRect(0, 0, 100, 200); 1171 IntRect contentBounds = IntRect(0, 0, 100, 200);
1172 IntRect visibleBounds = IntRect(0, 0, 100, 150); 1172 IntRect visibleBounds = IntRect(0, 0, 100, 150);
1173 1173
1174 layer->setBounds(contentBounds.size()); 1174 layer->setBounds(contentBounds.size());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 opaqueContents = layer->visibleContentOpaqueRegion(); 1243 opaqueContents = layer->visibleContentOpaqueRegion();
1244 EXPECT_RECT_EQ(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqu eContents.bounds()); 1244 EXPECT_RECT_EQ(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqu eContents.bounds());
1245 EXPECT_EQ(1u, opaqueContents.rects().size()); 1245 EXPECT_EQ(1u, opaqueContents.rects().size());
1246 1246
1247 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1, 1); 1247 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1, 1);
1248 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); 1248 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1);
1249 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 20000 - 17100 + 1 + 1, 1); 1249 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 20000 - 17100 + 1 + 1, 1);
1250 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); 1250 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
1251 } 1251 }
1252 1252
1253 TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics) 1253 TEST_F(TiledLayerTest, pixelsPaintedMetrics)
1254 { 1254 {
1255 scoped_refptr<FakeTiledLayerChromium> layer = make_scoped_refptr(new FakeTil edLayerChromium(m_textureManager.get())); 1255 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_textureManager.get()));
1256 TestCCOcclusionTracker occluded; 1256 TestOcclusionTracker occluded;
1257 1257
1258 // The tile size is 100x100, so this invalidates and then paints two tiles i n various ways. 1258 // The tile size is 100x100, so this invalidates and then paints two tiles i n various ways.
1259 1259
1260 IntRect opaquePaintRect; 1260 IntRect opaquePaintRect;
1261 Region opaqueContents; 1261 Region opaqueContents;
1262 1262
1263 IntRect contentBounds = IntRect(0, 0, 100, 300); 1263 IntRect contentBounds = IntRect(0, 0, 100, 300);
1264 IntRect visibleBounds = IntRect(0, 0, 100, 300); 1264 IntRect visibleBounds = IntRect(0, 0, 100, 300);
1265 1265
1266 layer->setBounds(contentBounds.size()); 1266 layer->setBounds(contentBounds.size());
(...skipping 28 matching lines...) Expand all
1295 EXPECT_TRUE(opaqueContents.isEmpty()); 1295 EXPECT_TRUE(opaqueContents.isEmpty());
1296 1296
1297 // The middle tile was painted even though not invalidated. 1297 // The middle tile was painted even though not invalidated.
1298 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1) ; 1298 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1) ;
1299 // The pixels uploaded will not include the non-invalidated tile in the midd le. 1299 // The pixels uploaded will not include the non-invalidated tile in the midd le.
1300 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 1300 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
1301 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 + 1 + 100, 1); 1301 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 + 1 + 100, 1);
1302 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); 1302 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
1303 } 1303 }
1304 1304
1305 TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca ted) 1305 TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
1306 { 1306 {
1307 // Tile size is 100x100. 1307 // Tile size is 100x100.
1308 IntRect rootRect(0, 0, 300, 200); 1308 IntRect rootRect(0, 0, 300, 200);
1309 IntRect childRect(0, 0, 300, 100); 1309 IntRect childRect(0, 0, 300, 100);
1310 IntRect child2Rect(0, 100, 300, 100); 1310 IntRect child2Rect(0, 100, 300, 100);
1311 1311
1312 CCLayerTreeSettings settings; 1312 LayerTreeSettings settings;
1313 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; 1313 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
1314 scoped_ptr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeC CLayerTreeHostClient, settings); 1314 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm plTreeHostClient, settings);
1315 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); 1315 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded());
1316 1316
1317 scoped_refptr<FakeTiledLayerChromium> root = make_scoped_refptr(new FakeTile dLayerChromium(ccLayerTreeHost->contentsTextureManager())); 1317 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(l ayerTreeHost->contentsTextureManager()));
1318 scoped_refptr<LayerChromium> surface = LayerChromium::create(); 1318 scoped_refptr<Layer> surface = Layer::create();
1319 scoped_refptr<FakeTiledLayerChromium> child = make_scoped_refptr(new FakeTil edLayerChromium(ccLayerTreeHost->contentsTextureManager())); 1319 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer( layerTreeHost->contentsTextureManager()));
1320 scoped_refptr<FakeTiledLayerChromium> child2 = make_scoped_refptr(new FakeTi ledLayerChromium(ccLayerTreeHost->contentsTextureManager())); 1320 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer (layerTreeHost->contentsTextureManager()));
1321 1321
1322 root->setBounds(rootRect.size()); 1322 root->setBounds(rootRect.size());
1323 root->setAnchorPoint(FloatPoint()); 1323 root->setAnchorPoint(FloatPoint());
1324 root->setDrawableContentRect(rootRect); 1324 root->setDrawableContentRect(rootRect);
1325 root->setVisibleContentRect(rootRect); 1325 root->setVisibleContentRect(rootRect);
1326 root->addChild(surface); 1326 root->addChild(surface);
1327 1327
1328 surface->setForceRenderSurface(true); 1328 surface->setForceRenderSurface(true);
1329 surface->setAnchorPoint(FloatPoint()); 1329 surface->setAnchorPoint(FloatPoint());
1330 surface->setOpacity(0.5); 1330 surface->setOpacity(0.5);
1331 surface->addChild(child); 1331 surface->addChild(child);
1332 surface->addChild(child2); 1332 surface->addChild(child2);
1333 1333
1334 child->setBounds(childRect.size()); 1334 child->setBounds(childRect.size());
1335 child->setAnchorPoint(FloatPoint()); 1335 child->setAnchorPoint(FloatPoint());
1336 child->setPosition(childRect.location()); 1336 child->setPosition(childRect.location());
1337 child->setVisibleContentRect(childRect); 1337 child->setVisibleContentRect(childRect);
1338 child->setDrawableContentRect(rootRect); 1338 child->setDrawableContentRect(rootRect);
1339 1339
1340 child2->setBounds(child2Rect.size()); 1340 child2->setBounds(child2Rect.size());
1341 child2->setAnchorPoint(FloatPoint()); 1341 child2->setAnchorPoint(FloatPoint());
1342 child2->setPosition(child2Rect.location()); 1342 child2->setPosition(child2Rect.location());
1343 child2->setVisibleContentRect(child2Rect); 1343 child2->setVisibleContentRect(child2Rect);
1344 child2->setDrawableContentRect(rootRect); 1344 child2->setDrawableContentRect(rootRect);
1345 1345
1346 ccLayerTreeHost->setRootLayer(root); 1346 layerTreeHost->setRootLayer(root);
1347 ccLayerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); 1347 layerTreeHost->setViewportSize(rootRect.size(), rootRect.size());
1348 1348
1349 // With a huge memory limit, all layers should update and push their texture s. 1349 // With a huge memory limit, all layers should update and push their texture s.
1350 root->invalidateContentRect(rootRect); 1350 root->invalidateContentRect(rootRect);
1351 child->invalidateContentRect(childRect); 1351 child->invalidateContentRect(childRect);
1352 child2->invalidateContentRect(child2Rect); 1352 child2->invalidateContentRect(child2Rect);
1353 ccLayerTreeHost->updateLayers( 1353 layerTreeHost->updateLayers(
1354 *m_queue.get(), std::numeric_limits<size_t>::max()); 1354 *m_queue.get(), std::numeric_limits<size_t>::max());
1355 { 1355 {
1356 updateTextures(); 1356 updateTextures();
1357 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); 1357 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount());
1358 EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); 1358 EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount());
1359 EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount()); 1359 EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount());
1360 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1360 EXPECT_FALSE(m_queue->hasMoreUpdates());
1361 1361
1362 root->fakeLayerTextureUpdater()->clearUpdateCount(); 1362 root->fakeLayerTextureUpdater()->clearUpdateCount();
1363 child->fakeLayerTextureUpdater()->clearUpdateCount(); 1363 child->fakeLayerTextureUpdater()->clearUpdateCount();
1364 child2->fakeLayerTextureUpdater()->clearUpdateCount(); 1364 child2->fakeLayerTextureUpdater()->clearUpdateCount();
1365 1365
1366 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); 1366 ScopedFakeTiledLayerImpl rootImpl(root->id());
1367 ScopedFakeCCTiledLayerImpl childImpl(child->id()); 1367 ScopedFakeTiledLayerImpl childImpl(child->id());
1368 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); 1368 ScopedFakeTiledLayerImpl child2Impl(child2->id());
1369 layerPushPropertiesTo(root.get(), rootImpl.get()); 1369 layerPushPropertiesTo(root.get(), rootImpl.get());
1370 layerPushPropertiesTo(child.get(), childImpl.get()); 1370 layerPushPropertiesTo(child.get(), childImpl.get());
1371 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1371 layerPushPropertiesTo(child2.get(), child2Impl.get());
1372 1372
1373 for (unsigned i = 0; i < 3; ++i) { 1373 for (unsigned i = 0; i < 3; ++i) {
1374 for (unsigned j = 0; j < 2; ++j) 1374 for (unsigned j = 0; j < 2; ++j)
1375 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1375 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1376 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); 1376 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0));
1377 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); 1377 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0));
1378 } 1378 }
1379 } 1379 }
1380 ccLayerTreeHost->commitComplete(); 1380 layerTreeHost->commitComplete();
1381 1381
1382 // With a memory limit that includes only the root layer (3x2 tiles) and hal f the surface that 1382 // With a memory limit that includes only the root layer (3x2 tiles) and hal f the surface that
1383 // the child layers draw into, the child layers will not be allocated. If th e surface isn't 1383 // the child layers draw into, the child layers will not be allocated. If th e surface isn't
1384 // accounted for, then one of the children would fit within the memory limit . 1384 // accounted for, then one of the children would fit within the memory limit .
1385 root->invalidateContentRect(rootRect); 1385 root->invalidateContentRect(rootRect);
1386 child->invalidateContentRect(childRect); 1386 child->invalidateContentRect(childRect);
1387 child2->invalidateContentRect(child2Rect); 1387 child2->invalidateContentRect(child2Rect);
1388 ccLayerTreeHost->updateLayers( 1388 layerTreeHost->updateLayers(
1389 *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4); 1389 *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4);
1390 { 1390 {
1391 updateTextures(); 1391 updateTextures();
1392 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); 1392 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount());
1393 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); 1393 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount());
1394 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); 1394 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount());
1395 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1395 EXPECT_FALSE(m_queue->hasMoreUpdates());
1396 1396
1397 root->fakeLayerTextureUpdater()->clearUpdateCount(); 1397 root->fakeLayerTextureUpdater()->clearUpdateCount();
1398 child->fakeLayerTextureUpdater()->clearUpdateCount(); 1398 child->fakeLayerTextureUpdater()->clearUpdateCount();
1399 child2->fakeLayerTextureUpdater()->clearUpdateCount(); 1399 child2->fakeLayerTextureUpdater()->clearUpdateCount();
1400 1400
1401 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); 1401 ScopedFakeTiledLayerImpl rootImpl(root->id());
1402 ScopedFakeCCTiledLayerImpl childImpl(child->id()); 1402 ScopedFakeTiledLayerImpl childImpl(child->id());
1403 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); 1403 ScopedFakeTiledLayerImpl child2Impl(child2->id());
1404 layerPushPropertiesTo(root.get(), rootImpl.get()); 1404 layerPushPropertiesTo(root.get(), rootImpl.get());
1405 layerPushPropertiesTo(child.get(), childImpl.get()); 1405 layerPushPropertiesTo(child.get(), childImpl.get());
1406 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1406 layerPushPropertiesTo(child2.get(), child2Impl.get());
1407 1407
1408 for (unsigned i = 0; i < 3; ++i) { 1408 for (unsigned i = 0; i < 3; ++i) {
1409 for (unsigned j = 0; j < 2; ++j) 1409 for (unsigned j = 0; j < 2; ++j)
1410 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1410 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1411 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1411 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1412 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1412 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1413 } 1413 }
1414 } 1414 }
1415 ccLayerTreeHost->commitComplete(); 1415 layerTreeHost->commitComplete();
1416 1416
1417 // With a memory limit that includes only half the root layer, no contents w ill be 1417 // With a memory limit that includes only half the root layer, no contents w ill be
1418 // allocated. If render surface memory wasn't accounted for, there is enough space 1418 // allocated. If render surface memory wasn't accounted for, there is enough space
1419 // for one of the children layers, but they draw into a surface that can't b e 1419 // for one of the children layers, but they draw into a surface that can't b e
1420 // allocated. 1420 // allocated.
1421 root->invalidateContentRect(rootRect); 1421 root->invalidateContentRect(rootRect);
1422 child->invalidateContentRect(childRect); 1422 child->invalidateContentRect(childRect);
1423 child2->invalidateContentRect(child2Rect); 1423 child2->invalidateContentRect(child2Rect);
1424 ccLayerTreeHost->updateLayers( 1424 layerTreeHost->updateLayers(
1425 *m_queue.get(), (3 * 1) * (100 * 100) * 4); 1425 *m_queue.get(), (3 * 1) * (100 * 100) * 4);
1426 { 1426 {
1427 updateTextures(); 1427 updateTextures();
1428 EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); 1428 EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount());
1429 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); 1429 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount());
1430 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); 1430 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount());
1431 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1431 EXPECT_FALSE(m_queue->hasMoreUpdates());
1432 1432
1433 root->fakeLayerTextureUpdater()->clearUpdateCount(); 1433 root->fakeLayerTextureUpdater()->clearUpdateCount();
1434 child->fakeLayerTextureUpdater()->clearUpdateCount(); 1434 child->fakeLayerTextureUpdater()->clearUpdateCount();
1435 child2->fakeLayerTextureUpdater()->clearUpdateCount(); 1435 child2->fakeLayerTextureUpdater()->clearUpdateCount();
1436 1436
1437 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); 1437 ScopedFakeTiledLayerImpl rootImpl(root->id());
1438 ScopedFakeCCTiledLayerImpl childImpl(child->id()); 1438 ScopedFakeTiledLayerImpl childImpl(child->id());
1439 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); 1439 ScopedFakeTiledLayerImpl child2Impl(child2->id());
1440 layerPushPropertiesTo(root.get(), rootImpl.get()); 1440 layerPushPropertiesTo(root.get(), rootImpl.get());
1441 layerPushPropertiesTo(child.get(), childImpl.get()); 1441 layerPushPropertiesTo(child.get(), childImpl.get());
1442 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1442 layerPushPropertiesTo(child2.get(), child2Impl.get());
1443 1443
1444 for (unsigned i = 0; i < 3; ++i) { 1444 for (unsigned i = 0; i < 3; ++i) {
1445 for (unsigned j = 0; j < 2; ++j) 1445 for (unsigned j = 0; j < 2; ++j)
1446 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); 1446 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j));
1447 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1447 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1448 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1448 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1449 } 1449 }
1450 } 1450 }
1451 ccLayerTreeHost->commitComplete(); 1451 layerTreeHost->commitComplete();
1452 1452
1453 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re sourceProvider.get()); 1453 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso urceProvider.get());
1454 ccLayerTreeHost->setRootLayer(0); 1454 layerTreeHost->setRootLayer(0);
1455 } 1455 }
1456 1456
1457 class TrackingLayerPainter : public LayerPainterChromium { 1457 class TrackingLayerPainter : public LayerPainter {
1458 public: 1458 public:
1459 static scoped_ptr<TrackingLayerPainter> create() { return make_scoped_ptr(ne w TrackingLayerPainter()); } 1459 static scoped_ptr<TrackingLayerPainter> create() { return make_scoped_ptr(ne w TrackingLayerPainter()); }
1460 1460
1461 virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect&) OVERRI DE 1461 virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect&) OVERRI DE
1462 { 1462 {
1463 m_paintedRect = contentRect; 1463 m_paintedRect = contentRect;
1464 } 1464 }
1465 1465
1466 const IntRect& paintedRect() const { return m_paintedRect; } 1466 const IntRect& paintedRect() const { return m_paintedRect; }
1467 void resetPaintedRect() { m_paintedRect = IntRect(); } 1467 void resetPaintedRect() { m_paintedRect = IntRect(); }
1468 1468
1469 private: 1469 private:
1470 TrackingLayerPainter() { } 1470 TrackingLayerPainter() { }
1471 1471
1472 IntRect m_paintedRect; 1472 IntRect m_paintedRect;
1473 }; 1473 };
1474 1474
1475 class UpdateTrackingTiledLayerChromium : public FakeTiledLayerChromium { 1475 class UpdateTrackingTiledLayer : public FakeTiledLayer {
1476 public: 1476 public:
1477 explicit UpdateTrackingTiledLayerChromium(CCPrioritizedTextureManager* manag er) 1477 explicit UpdateTrackingTiledLayer(PrioritizedTextureManager* manager)
1478 : FakeTiledLayerChromium(manager) 1478 : FakeTiledLayer(manager)
1479 { 1479 {
1480 scoped_ptr<TrackingLayerPainter> trackingLayerPainter(TrackingLayerPaint er::create()); 1480 scoped_ptr<TrackingLayerPainter> trackingLayerPainter(TrackingLayerPaint er::create());
1481 m_trackingLayerPainter = trackingLayerPainter.get(); 1481 m_trackingLayerPainter = trackingLayerPainter.get();
1482 m_layerTextureUpdater = BitmapCanvasLayerTextureUpdater::create(tracking LayerPainter.PassAs<LayerPainterChromium>()); 1482 m_layerTextureUpdater = BitmapCanvasLayerTextureUpdater::create(tracking LayerPainter.PassAs<LayerPainter>());
1483 } 1483 }
1484 1484
1485 TrackingLayerPainter* trackingLayerPainter() const { return m_trackingLayerP ainter; } 1485 TrackingLayerPainter* trackingLayerPainter() const { return m_trackingLayerP ainter; }
1486 1486
1487 protected: 1487 protected:
1488 virtual ~UpdateTrackingTiledLayerChromium() { } 1488 virtual ~UpdateTrackingTiledLayer() { }
1489 1489
1490 virtual LayerTextureUpdater* textureUpdater() const OVERRIDE { return m_laye rTextureUpdater.get(); } 1490 virtual LayerTextureUpdater* textureUpdater() const OVERRIDE { return m_laye rTextureUpdater.get(); }
1491 1491
1492 private: 1492 private:
1493 TrackingLayerPainter* m_trackingLayerPainter; 1493 TrackingLayerPainter* m_trackingLayerPainter;
1494 scoped_refptr<BitmapCanvasLayerTextureUpdater> m_layerTextureUpdater; 1494 scoped_refptr<BitmapCanvasLayerTextureUpdater> m_layerTextureUpdater;
1495 }; 1495 };
1496 1496
1497 TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) 1497 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
1498 { 1498 {
1499 scoped_refptr<UpdateTrackingTiledLayerChromium> layer = make_scoped_refptr(n ew UpdateTrackingTiledLayerChromium(m_textureManager.get())); 1499 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(m_textureManager.get()));
1500 1500
1501 IntRect layerRect(0, 0, 30, 31); 1501 IntRect layerRect(0, 0, 30, 31);
1502 layer->setPosition(layerRect.location()); 1502 layer->setPosition(layerRect.location());
1503 layer->setBounds(layerRect.size()); 1503 layer->setBounds(layerRect.size());
1504 layer->setContentsScale(1.5); 1504 layer->setContentsScale(1.5);
1505 1505
1506 IntRect contentRect(0, 0, 45, 47); 1506 IntRect contentRect(0, 0, 45, 47);
1507 EXPECT_EQ(contentRect.size(), layer->contentBounds()); 1507 EXPECT_EQ(contentRect.size(), layer->contentBounds());
1508 layer->setVisibleContentRect(contentRect); 1508 layer->setVisibleContentRect(contentRect);
1509 layer->setDrawableContentRect(contentRect); 1509 layer->setDrawableContentRect(contentRect);
1510 1510
1511 layer->setTexturePriorities(m_priorityCalculator); 1511 layer->setTexturePriorities(m_priorityCalculator);
1512 m_textureManager->prioritizeTextures(); 1512 m_textureManager->prioritizeTextures();
1513 1513
1514 // Update the whole tile. 1514 // Update the whole tile.
1515 layer->update(*m_queue.get(), 0, m_stats); 1515 layer->update(*m_queue.get(), 0, m_stats);
1516 layer->trackingLayerPainter()->resetPaintedRect(); 1516 layer->trackingLayerPainter()->resetPaintedRect();
1517 1517
1518 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); 1518 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect());
1519 updateTextures(); 1519 updateTextures();
1520 1520
1521 // Invalidate the entire layer in content space. When painting, the rect giv en to webkit should match the layer's bounds. 1521 // Invalidate the entire layer in content space. When painting, the rect giv en to webkit should match the layer's bounds.
1522 layer->invalidateContentRect(contentRect); 1522 layer->invalidateContentRect(contentRect);
1523 layer->update(*m_queue.get(), 0, m_stats); 1523 layer->update(*m_queue.get(), 0, m_stats);
1524 1524
1525 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); 1525 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
1526 } 1526 }
1527 1527
1528 TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali dation) 1528 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation)
1529 { 1529 {
1530 scoped_refptr<UpdateTrackingTiledLayerChromium> layer = make_scoped_refptr(n ew UpdateTrackingTiledLayerChromium(m_textureManager.get())); 1530 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(m_textureManager.get()));
1531 1531
1532 IntRect layerRect(0, 0, 30, 31); 1532 IntRect layerRect(0, 0, 30, 31);
1533 layer->setPosition(layerRect.location()); 1533 layer->setPosition(layerRect.location());
1534 layer->setBounds(layerRect.size()); 1534 layer->setBounds(layerRect.size());
1535 layer->setContentsScale(1.3f); 1535 layer->setContentsScale(1.3f);
1536 1536
1537 IntRect contentRect(IntPoint(), layer->contentBounds()); 1537 IntRect contentRect(IntPoint(), layer->contentBounds());
1538 layer->setVisibleContentRect(contentRect); 1538 layer->setVisibleContentRect(contentRect);
1539 layer->setDrawableContentRect(contentRect); 1539 layer->setDrawableContentRect(contentRect);
1540 1540
1541 layer->setTexturePriorities(m_priorityCalculator); 1541 layer->setTexturePriorities(m_priorityCalculator);
1542 m_textureManager->prioritizeTextures(); 1542 m_textureManager->prioritizeTextures();
1543 1543
1544 // Update the whole tile. 1544 // Update the whole tile.
1545 layer->update(*m_queue.get(), 0, m_stats); 1545 layer->update(*m_queue.get(), 0, m_stats);
1546 layer->trackingLayerPainter()->resetPaintedRect(); 1546 layer->trackingLayerPainter()->resetPaintedRect();
1547 1547
1548 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); 1548 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect());
1549 updateTextures(); 1549 updateTextures();
1550 1550
1551 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. 1551 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds.
1552 layer->setNeedsDisplayRect(layerRect); 1552 layer->setNeedsDisplayRect(layerRect);
1553 layer->update(*m_queue.get(), 0, m_stats); 1553 layer->update(*m_queue.get(), 0, m_stats);
1554 1554
1555 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); 1555 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
1556 } 1556 }
1557 1557
1558 } // namespace 1558 } // namespace
OLDNEW
« cc/active_animation.h ('K') | « cc/tiled_layer_impl_unittest.cc ('k') | cc/time_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698