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

Side by Side Diff: cc/tiled_layer_unittest.cc

Issue 11519018: [cc] Make LayerImpls point at LayerTreeImpl instead of LTHI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 "cc/tiled_layer.h" 5 #include "cc/tiled_layer.h"
6 6
7 #include "cc/bitmap_content_layer_updater.h" 7 #include "cc/bitmap_content_layer_updater.h"
8 #include "cc/layer_painter.h" 8 #include "cc/layer_painter.h"
9 #include "cc/overdraw_metrics.h" 9 #include "cc/overdraw_metrics.h"
10 #include "cc/rendering_stats.h" 10 #include "cc/rendering_stats.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 virtual ~TiledLayerTest() 69 virtual ~TiledLayerTest()
70 { 70 {
71 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide r.get()); 71 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide r.get());
72 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy); 72 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
73 m_resourceProvider.reset(); 73 m_resourceProvider.reset();
74 m_hostImpl.reset(); 74 m_hostImpl.reset();
75 } 75 }
76 76
77 class ScopedFakeTiledLayerImpl { 77 class ScopedFakeTiledLayerImpl {
78 public: 78 public:
79 ScopedFakeTiledLayerImpl(LayerTreeHostImpl* hostImpl, int id) 79 ScopedFakeTiledLayerImpl(LayerTreeImpl* treeImpl, int id)
80 { 80 {
81 m_layerImpl = new FakeTiledLayerImpl(hostImpl, id); 81 m_layerImpl = new FakeTiledLayerImpl(treeImpl, id);
82 } 82 }
83 ~ScopedFakeTiledLayerImpl() 83 ~ScopedFakeTiledLayerImpl()
84 { 84 {
85 delete m_layerImpl; 85 delete m_layerImpl;
86 } 86 }
87 FakeTiledLayerImpl* get() 87 FakeTiledLayerImpl* get()
88 { 88 {
89 return m_layerImpl; 89 return m_layerImpl;
90 } 90 }
91 FakeTiledLayerImpl* operator->() 91 FakeTiledLayerImpl* operator->()
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; 175 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient;
176 scoped_ptr<LayerTreeHost> m_layerTreeHost; 176 scoped_ptr<LayerTreeHost> m_layerTreeHost;
177 scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl; 177 scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl;
178 scoped_ptr<PrioritizedResourceManager> m_resourceManager; 178 scoped_ptr<PrioritizedResourceManager> m_resourceManager;
179 TestOcclusionTracker* m_occlusion; 179 TestOcclusionTracker* m_occlusion;
180 }; 180 };
181 181
182 TEST_F(TiledLayerTest, pushDirtyTiles) 182 TEST_F(TiledLayerTest, pushDirtyTiles)
183 { 183 {
184 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 184 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
185 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 185 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
186 186
187 // The tile size is 100x100, so this invalidates and then paints two tiles. 187 // The tile size is 100x100, so this invalidates and then paints two tiles.
188 layer->setBounds(gfx::Size(100, 200)); 188 layer->setBounds(gfx::Size(100, 200));
189 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 189 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
190 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); 190 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200));
191 updateAndPush(layer.get(), layerImpl.get()); 191 updateAndPush(layer.get(), layerImpl.get());
192 192
193 // We should have both tiles on the impl side. 193 // We should have both tiles on the impl side.
194 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 194 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
195 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 195 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
196 196
197 // Invalidates both tiles, but then only update one of them. 197 // Invalidates both tiles, but then only update one of them.
198 layer->setBounds(gfx::Size(100, 200)); 198 layer->setBounds(gfx::Size(100, 200));
199 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 199 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
200 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); 200 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200));
201 updateAndPush(layer.get(), layerImpl.get()); 201 updateAndPush(layer.get(), layerImpl.get());
202 202
203 // We should only have the first tile since the other tile was invalidated b ut not painted. 203 // We should only have the first tile since the other tile was invalidated b ut not painted.
204 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 204 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
205 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 205 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
206 } 206 }
207 207
208 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) 208 TEST_F(TiledLayerTest, pushOccludedDirtyTiles)
209 { 209 {
210 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 210 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
211 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 211 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
212 TestOcclusionTracker occluded; 212 TestOcclusionTracker occluded;
213 m_occlusion = &occluded; 213 m_occlusion = &occluded;
214 214
215 // The tile size is 100x100, so this invalidates and then paints two tiles. 215 // The tile size is 100x100, so this invalidates and then paints two tiles.
216 layer->setBounds(gfx::Size(100, 200)); 216 layer->setBounds(gfx::Size(100, 200));
217 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 217 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
218 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 100, 200); 218 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 100, 200);
219 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); 219 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200));
220 updateAndPush(layer.get(), layerImpl.get()); 220 updateAndPush(layer.get(), layerImpl.get());
221 221
(...skipping 16 matching lines...) Expand all
238 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); 238 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
239 239
240 // We should still have both tiles, as part of the top tile is still unocclu ded. 240 // We should still have both tiles, as part of the top tile is still unocclu ded.
241 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 241 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
242 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 242 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
243 } 243 }
244 244
245 TEST_F(TiledLayerTest, pushDeletedTiles) 245 TEST_F(TiledLayerTest, pushDeletedTiles)
246 { 246 {
247 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 247 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
248 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 248 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
249 249
250 // The tile size is 100x100, so this invalidates and then paints two tiles. 250 // The tile size is 100x100, so this invalidates and then paints two tiles.
251 layer->setBounds(gfx::Size(100, 200)); 251 layer->setBounds(gfx::Size(100, 200));
252 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 252 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
253 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); 253 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200));
254 updateAndPush(layer.get(), layerImpl.get()); 254 updateAndPush(layer.get(), layerImpl.get());
255 255
256 // We should have both tiles on the impl side. 256 // We should have both tiles on the impl side.
257 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 257 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
258 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 258 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
(...skipping 14 matching lines...) Expand all
273 updateAndPush(layer.get(), layerImpl.get()); 273 updateAndPush(layer.get(), layerImpl.get());
274 274
275 // We should have one tiles on the impl side. 275 // We should have one tiles on the impl side.
276 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 276 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
277 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 277 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
278 } 278 }
279 279
280 TEST_F(TiledLayerTest, pushIdlePaintTiles) 280 TEST_F(TiledLayerTest, pushIdlePaintTiles)
281 { 281 {
282 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 282 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
283 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 283 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
284 284
285 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter. 285 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter.
286 // This paints 1 visible of the 25 invalid tiles. 286 // This paints 1 visible of the 25 invalid tiles.
287 layer->setBounds(gfx::Size(500, 500)); 287 layer->setBounds(gfx::Size(500, 500));
288 layer->drawProperties().visible_content_rect = gfx::Rect(200, 200, 100, 100) ; 288 layer->drawProperties().visible_content_rect = gfx::Rect(200, 200, 100, 100) ;
289 layer->invalidateContentRect(gfx::Rect(0, 0, 500, 500)); 289 layer->invalidateContentRect(gfx::Rect(0, 0, 500, 500));
290 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 290 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
291 // We should need idle-painting for surrounding tiles. 291 // We should need idle-painting for surrounding tiles.
292 EXPECT_TRUE(needsUpdate); 292 EXPECT_TRUE(needsUpdate);
293 293
(...skipping 15 matching lines...) Expand all
309 for (int j = 0; j < 5; j++) 309 for (int j = 0; j < 5; j++)
310 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j)); 310 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j));
311 } 311 }
312 312
313 EXPECT_FALSE(needsUpdate); 313 EXPECT_FALSE(needsUpdate);
314 } 314 }
315 315
316 TEST_F(TiledLayerTest, predictivePainting) 316 TEST_F(TiledLayerTest, predictivePainting)
317 { 317 {
318 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 318 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
319 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 319 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
320 320
321 // Prepainting should occur in the scroll direction first, and the 321 // Prepainting should occur in the scroll direction first, and the
322 // visible rect should be extruded only along the dominant axis. 322 // visible rect should be extruded only along the dominant axis.
323 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), 323 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0),
324 gfx::Vector2d(10, 0), 324 gfx::Vector2d(10, 0),
325 gfx::Vector2d(0, -10), 325 gfx::Vector2d(0, -10),
326 gfx::Vector2d(0, 10), 326 gfx::Vector2d(0, 10),
327 gfx::Vector2d(10, 20), 327 gfx::Vector2d(10, 20),
328 gfx::Vector2d(-20, 10) }; 328 gfx::Vector2d(-20, 10) };
329 // We should push all tiles that touch the extruded visible rect. 329 // We should push all tiles that touch the extruded visible rect.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 383 needsUpdate = updateAndPush(layer.get(), layerImpl.get());
384 EXPECT_FALSE(needsUpdate); 384 EXPECT_FALSE(needsUpdate);
385 } 385 }
386 } 386 }
387 387
388 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed) 388 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed)
389 { 389 {
390 // 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. 390 // 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.
391 m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); 391 m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024);
392 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 392 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
393 ScopedFakeTiledLayerImpl layerImpl1(m_hostImpl.get(), 1); 393 ScopedFakeTiledLayerImpl layerImpl1(m_hostImpl->activeTree(), 1);
394 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 394 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
395 ScopedFakeTiledLayerImpl layerImpl2(m_hostImpl.get(), 2); 395 ScopedFakeTiledLayerImpl layerImpl2(m_hostImpl->activeTree(), 2);
396 396
397 // For this test we have two layers. layer1 exhausts most texture memory, le aving room for 2 more tiles from 397 // For this test we have two layers. layer1 exhausts most texture memory, le aving room for 2 more tiles from
398 // layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint 398 // layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint
399 // layer2, we will fail on the third tile of layer2, and this should not lea ve the second tile in a bad state. 399 // layer2, we will fail on the third tile of layer2, and this should not lea ve the second tile in a bad state.
400 400
401 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou gh for 2 tiles only in the other layer. 401 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou gh for 2 tiles only in the other layer.
402 gfx::Rect layer1Rect(0, 0, 100, 2400); 402 gfx::Rect layer1Rect(0, 0, 100, 2400);
403 403
404 // This requires 4*30000 bytes of memory. 404 // This requires 4*30000 bytes of memory.
405 gfx::Rect layer2Rect(0, 0, 100, 300); 405 gfx::Rect layer2Rect(0, 0, 100, 300);
(...skipping 29 matching lines...) Expand all
435 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); 435 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1));
436 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); 436 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1));
437 437
438 EXPECT_FALSE(needsUpdate); 438 EXPECT_FALSE(needsUpdate);
439 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2)); 439 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2));
440 } 440 }
441 441
442 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) 442 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles)
443 { 443 {
444 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 444 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
445 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 445 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
446 TestOcclusionTracker occluded; 446 TestOcclusionTracker occluded;
447 m_occlusion = &occluded; 447 m_occlusion = &occluded;
448 448
449 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it. 449 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it.
450 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100)); 450 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100));
451 451
452 layer->setBounds(gfx::Size(100, 100)); 452 layer->setBounds(gfx::Size(100, 100));
453 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 453 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
454 updateAndPush(layer.get(), layerImpl.get()); 454 updateAndPush(layer.get(), layerImpl.get());
455 455
456 // We should have the prepainted tile on the impl side, but culled it during paint. 456 // We should have the prepainted tile on the impl side, but culled it during paint.
457 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 457 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
458 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); 458 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload());
459 } 459 }
460 460
461 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) 461 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint)
462 { 462 {
463 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 463 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
464 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 464 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
465 465
466 // The tile size is 100x100, so this invalidates and then paints two tiles. 466 // The tile size is 100x100, so this invalidates and then paints two tiles.
467 // However, during the paint, we invalidate one of the tiles. This should 467 // However, during the paint, we invalidate one of the tiles. This should
468 // not prevent the tile from being pushed. 468 // not prevent the tile from being pushed.
469 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la yer.get()); 469 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la yer.get());
470 layer->setBounds(gfx::Size(100, 200)); 470 layer->setBounds(gfx::Size(100, 200));
471 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 471 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
472 updateAndPush(layer.get(), layerImpl.get()); 472 updateAndPush(layer.get(), layerImpl.get());
473 473
474 // We should have both tiles on the impl side. 474 // We should have both tiles on the impl side.
475 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 475 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
476 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 476 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
477 } 477 }
478 478
479 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) 479 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
480 { 480 {
481 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 481 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
482 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 482 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
483 ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl.get(), 1); 483 ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl->activeTree(), 1);
484 ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl.get(), 2); 484 ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl->activeTree(), 2);
485 485
486 // Invalidate a tile on layer1, during update of layer 2. 486 // Invalidate a tile on layer1, during update of layer 2.
487 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer1.get()); 487 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer1.get());
488 layer1->setBounds(gfx::Size(100, 200)); 488 layer1->setBounds(gfx::Size(100, 200));
489 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 489 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
490 layer2->setBounds(gfx::Size(100, 200)); 490 layer2->setBounds(gfx::Size(100, 200));
491 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 491 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
492 updateAndPush(layer1.get(), layer1Impl.get(), 492 updateAndPush(layer1.get(), layer1Impl.get(),
493 layer2.get(), layer2Impl.get()); 493 layer2.get(), layer2Impl.get());
494 494
495 // We should have both tiles on the impl side for all layers. 495 // We should have both tiles on the impl side for all layers.
496 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); 496 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0));
497 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); 497 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1));
498 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); 498 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0));
499 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); 499 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1));
500 } 500 }
501 501
502 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) 502 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer)
503 { 503 {
504 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 504 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
505 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 505 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
506 ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl.get(), 1); 506 ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl->activeTree(), 1);
507 ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl.get(), 2); 507 ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl->activeTree(), 2);
508 508
509 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer2.get()); 509 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer2.get());
510 layer1->setBounds(gfx::Size(100, 200)); 510 layer1->setBounds(gfx::Size(100, 200));
511 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 511 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
512 layer2->setBounds(gfx::Size(100, 200)); 512 layer2->setBounds(gfx::Size(100, 200));
513 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 513 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
514 updateAndPush(layer1.get(), layer1Impl.get(), 514 updateAndPush(layer1.get(), layer1Impl.get(),
515 layer2.get(), layer2Impl.get()); 515 layer2.get(), layer2Impl.get());
516 516
517 // We should have both tiles on the impl side for all layers. 517 // We should have both tiles on the impl side for all layers.
(...skipping 20 matching lines...) Expand all
538 int memoryForLayer = layerWidth * layerHeight * 4; 538 int memoryForLayer = layerWidth * layerHeight * 4;
539 layerTreeHost->setViewportSize(gfx::Size(layerWidth, layerHeight), gfx:: Size(layerWidth, layerHeight)); 539 layerTreeHost->setViewportSize(gfx::Size(layerWidth, layerHeight), gfx:: Size(layerWidth, layerHeight));
540 540
541 // Use 10x5 tiles to run out of memory. 541 // Use 10x5 tiles to run out of memory.
542 if (runOutOfMemory[i]) 542 if (runOutOfMemory[i])
543 layerWidth *= 2; 543 layerWidth *= 2;
544 544
545 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer); 545 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer);
546 546
547 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa yer(m_resourceManager.get())); 547 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa yer(m_resourceManager.get()));
548 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 548 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
549 549
550 // Full size layer with half being visible. 550 // Full size layer with half being visible.
551 gfx::Size contentBounds(layerWidth, layerHeight); 551 gfx::Size contentBounds(layerWidth, layerHeight);
552 gfx::Rect contentRect(gfx::Point(), contentBounds); 552 gfx::Rect contentRect(gfx::Point(), contentBounds);
553 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh t)); 553 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh t));
554 554
555 // Pretend the layer is animating. 555 // Pretend the layer is animating.
556 layer->drawProperties().target_space_transform_is_animating = true; 556 layer->drawProperties().target_space_transform_is_animating = true;
557 layer->setBounds(contentBounds); 557 layer->setBounds(contentBounds);
558 layer->drawProperties().visible_content_rect = visibleRect; 558 layer->drawProperties().visible_content_rect = visibleRect;
(...skipping 21 matching lines...) Expand all
580 for (int j = 0; j < 5; ++j) 580 for (int j = 0; j < 5; ++j)
581 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 5); 581 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 5);
582 } 582 }
583 } 583 }
584 } 584 }
585 } 585 }
586 586
587 TEST_F(TiledLayerTest, idlePaintOutOfMemory) 587 TEST_F(TiledLayerTest, idlePaintOutOfMemory)
588 { 588 {
589 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 589 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
590 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 590 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
591 591
592 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint. 592 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint.
593 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. 593 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel.
594 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); 594 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit);
595 595
596 // The tile size is 100x100, so this invalidates and then paints two tiles. 596 // The tile size is 100x100, so this invalidates and then paints two tiles.
597 bool needsUpdate = false; 597 bool needsUpdate = false;
598 layer->setBounds(gfx::Size(300, 300)); 598 layer->setBounds(gfx::Size(300, 300));
599 layer->drawProperties().visible_content_rect = gfx::Rect(100, 100, 100, 100) ; 599 layer->drawProperties().visible_content_rect = gfx::Rect(100, 100, 100, 100) ;
600 for (int i = 0; i < 2; i++) 600 for (int i = 0; i < 2; i++)
601 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 601 needsUpdate = updateAndPush(layer.get(), layerImpl.get());
602 602
603 // Idle-painting should see no more priority tiles for painting. 603 // Idle-painting should see no more priority tiles for painting.
604 EXPECT_FALSE(needsUpdate); 604 EXPECT_FALSE(needsUpdate);
605 605
606 // We should have one tile on the impl side. 606 // We should have one tile on the impl side.
607 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); 607 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1));
608 } 608 }
609 609
610 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) 610 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer)
611 { 611 {
612 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 612 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
613 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 613 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
614 614
615 bool animating[2] = {false, true}; 615 bool animating[2] = {false, true};
616 for (int i = 0; i < 2; i++) { 616 for (int i = 0; i < 2; i++) {
617 // Pretend the layer is animating. 617 // Pretend the layer is animating.
618 layer->drawProperties().target_space_transform_is_animating = animating[ i]; 618 layer->drawProperties().target_space_transform_is_animating = animating[ i];
619 619
620 // The layer's bounds are empty. 620 // The layer's bounds are empty.
621 // Empty layers don't paint or idle-paint. 621 // Empty layers don't paint or idle-paint.
622 layer->setBounds(gfx::Size()); 622 layer->setBounds(gfx::Size());
623 layer->drawProperties().visible_content_rect = gfx::Rect(); 623 layer->drawProperties().visible_content_rect = gfx::Rect();
624 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 624 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
625 625
626 // Empty layers don't have tiles. 626 // Empty layers don't have tiles.
627 EXPECT_EQ(0u, layer->numPaintedTiles()); 627 EXPECT_EQ(0u, layer->numPaintedTiles());
628 628
629 // Empty layers don't need prepaint. 629 // Empty layers don't need prepaint.
630 EXPECT_FALSE(needsUpdate); 630 EXPECT_FALSE(needsUpdate);
631 631
632 // Empty layers don't have tiles. 632 // Empty layers don't have tiles.
633 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); 633 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
634 } 634 }
635 } 635 }
636 636
637 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) 637 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers)
638 { 638 {
639 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 639 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
640 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 640 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
641 641
642 // Alternate between not visible and visible. 642 // Alternate between not visible and visible.
643 gfx::Rect v(0, 0, 100, 100); 643 gfx::Rect v(0, 0, 100, 100);
644 gfx::Rect nv(0, 0, 0, 0); 644 gfx::Rect nv(0, 0, 0, 0);
645 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; 645 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv};
646 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false }; 646 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false };
647 647
648 // We should not have any tiles except for when the layer was visible 648 // We should not have any tiles except for when the layer was visible
649 // or after the layer was visible and we didn't invalidate. 649 // or after the layer was visible and we didn't invalidate.
650 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true }; 650 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true };
651 651
652 for (int i = 0; i < 10; i++) { 652 for (int i = 0; i < 10; i++) {
653 layer->setBounds(gfx::Size(100, 100)); 653 layer->setBounds(gfx::Size(100, 100));
654 layer->drawProperties().visible_content_rect = visibleRect[i]; 654 layer->drawProperties().visible_content_rect = visibleRect[i];
655 655
656 if (invalidate[i]) 656 if (invalidate[i])
657 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100)); 657 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100));
658 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 658 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
659 659
660 // We should never signal idle paint, as we painted the entire layer 660 // We should never signal idle paint, as we painted the entire layer
661 // or the layer was not visible. 661 // or the layer was not visible.
662 EXPECT_FALSE(needsUpdate); 662 EXPECT_FALSE(needsUpdate);
663 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); 663 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]);
664 } 664 }
665 } 665 }
666 666
667 TEST_F(TiledLayerTest, invalidateFromPrepare) 667 TEST_F(TiledLayerTest, invalidateFromPrepare)
668 { 668 {
669 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 669 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
670 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 670 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
671 671
672 // The tile size is 100x100, so this invalidates and then paints two tiles. 672 // The tile size is 100x100, so this invalidates and then paints two tiles.
673 layer->setBounds(gfx::Size(100, 200)); 673 layer->setBounds(gfx::Size(100, 200));
674 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 674 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
675 updateAndPush(layer.get(), layerImpl.get()); 675 updateAndPush(layer.get(), layerImpl.get());
676 676
677 // We should have both tiles on the impl side. 677 // We should have both tiles on the impl side.
678 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 678 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
679 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 679 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
680 680
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 layer->invalidateContentRect(partialDamage); 733 layer->invalidateContentRect(partialDamage);
734 layer->setTexturePriorities(m_priorityCalculator); 734 layer->setTexturePriorities(m_priorityCalculator);
735 m_resourceManager->prioritizeTextures(); 735 m_resourceManager->prioritizeTextures();
736 layer->update(*m_queue.get(), 0, m_stats); 736 layer->update(*m_queue.get(), 0, m_stats);
737 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); 737 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect());
738 } 738 }
739 739
740 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) 740 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges)
741 { 741 {
742 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 742 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
743 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 743 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
744 744
745 // Create a layer with one tile. 745 // Create a layer with one tile.
746 layer->setBounds(gfx::Size(100, 100)); 746 layer->setBounds(gfx::Size(100, 100));
747 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 747 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
748 748
749 // Invalidate the entire layer. 749 // Invalidate the entire layer.
750 layer->setNeedsDisplay(); 750 layer->setNeedsDisplay();
751 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect ()); 751 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect ());
752 752
753 // Push the tiles to the impl side and check that there is exactly one. 753 // Push the tiles to the impl side and check that there is exactly one.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 layer->drawProperties().visible_content_rect = contentRect; 885 layer->drawProperties().visible_content_rect = contentRect;
886 layer->invalidateContentRect(contentRect); 886 layer->invalidateContentRect(contentRect);
887 887
888 m_layerTreeHost->setRootLayer(layer); 888 m_layerTreeHost->setRootLayer(layer);
889 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); 889 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200));
890 890
891 // Full update of all 6 tiles. 891 // Full update of all 6 tiles.
892 m_layerTreeHost->updateLayers( 892 m_layerTreeHost->updateLayers(
893 *m_queue.get(), std::numeric_limits<size_t>::max()); 893 *m_queue.get(), std::numeric_limits<size_t>::max());
894 { 894 {
895 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 895 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
896 EXPECT_EQ(6, m_queue->fullUploadSize()); 896 EXPECT_EQ(6, m_queue->fullUploadSize());
897 EXPECT_EQ(0, m_queue->partialUploadSize()); 897 EXPECT_EQ(0, m_queue->partialUploadSize());
898 updateTextures(); 898 updateTextures();
899 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 899 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
900 EXPECT_FALSE(m_queue->hasMoreUpdates()); 900 EXPECT_FALSE(m_queue->hasMoreUpdates());
901 layer->fakeLayerUpdater()->clearUpdateCount(); 901 layer->fakeLayerUpdater()->clearUpdateCount();
902 layerPushPropertiesTo(layer.get(), layerImpl.get()); 902 layerPushPropertiesTo(layer.get(), layerImpl.get());
903 } 903 }
904 m_layerTreeHost->commitComplete(); 904 m_layerTreeHost->commitComplete();
905 905
906 // Full update of 3 tiles and partial update of 3 tiles. 906 // Full update of 3 tiles and partial update of 3 tiles.
907 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); 907 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150));
908 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m ax()); 908 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m ax());
909 { 909 {
910 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 910 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
911 EXPECT_EQ(3, m_queue->fullUploadSize()); 911 EXPECT_EQ(3, m_queue->fullUploadSize());
912 EXPECT_EQ(3, m_queue->partialUploadSize()); 912 EXPECT_EQ(3, m_queue->partialUploadSize());
913 updateTextures(); 913 updateTextures();
914 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 914 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
915 EXPECT_FALSE(m_queue->hasMoreUpdates()); 915 EXPECT_FALSE(m_queue->hasMoreUpdates());
916 layer->fakeLayerUpdater()->clearUpdateCount(); 916 layer->fakeLayerUpdater()->clearUpdateCount();
917 layerPushPropertiesTo(layer.get(), layerImpl.get()); 917 layerPushPropertiesTo(layer.get(), layerImpl.get());
918 } 918 }
919 m_layerTreeHost->commitComplete(); 919 m_layerTreeHost->commitComplete();
920 920
921 // Partial update of 6 tiles. 921 // Partial update of 6 tiles.
922 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); 922 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
923 { 923 {
924 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 924 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
925 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); 925 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max());
926 EXPECT_EQ(2, m_queue->fullUploadSize()); 926 EXPECT_EQ(2, m_queue->fullUploadSize());
927 EXPECT_EQ(4, m_queue->partialUploadSize()); 927 EXPECT_EQ(4, m_queue->partialUploadSize());
928 updateTextures(); 928 updateTextures();
929 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 929 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
930 EXPECT_FALSE(m_queue->hasMoreUpdates()); 930 EXPECT_FALSE(m_queue->hasMoreUpdates());
931 layer->fakeLayerUpdater()->clearUpdateCount(); 931 layer->fakeLayerUpdater()->clearUpdateCount();
932 layerPushPropertiesTo(layer.get(), layerImpl.get()); 932 layerPushPropertiesTo(layer.get(), layerImpl.get());
933 } 933 }
934 m_layerTreeHost->commitComplete(); 934 m_layerTreeHost->commitComplete();
935 935
936 // Checkerboard all tiles. 936 // Checkerboard all tiles.
937 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); 937 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200));
938 { 938 {
939 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 939 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
940 layerPushPropertiesTo(layer.get(), layerImpl.get()); 940 layerPushPropertiesTo(layer.get(), layerImpl.get());
941 } 941 }
942 m_layerTreeHost->commitComplete(); 942 m_layerTreeHost->commitComplete();
943 943
944 // Partial update of 6 checkerboard tiles. 944 // Partial update of 6 checkerboard tiles.
945 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); 945 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
946 { 946 {
947 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 947 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
948 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); 948 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max());
949 EXPECT_EQ(6, m_queue->fullUploadSize()); 949 EXPECT_EQ(6, m_queue->fullUploadSize());
950 EXPECT_EQ(0, m_queue->partialUploadSize()); 950 EXPECT_EQ(0, m_queue->partialUploadSize());
951 updateTextures(); 951 updateTextures();
952 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 952 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
953 EXPECT_FALSE(m_queue->hasMoreUpdates()); 953 EXPECT_FALSE(m_queue->hasMoreUpdates());
954 layer->fakeLayerUpdater()->clearUpdateCount(); 954 layer->fakeLayerUpdater()->clearUpdateCount();
955 layerPushPropertiesTo(layer.get(), layerImpl.get()); 955 layerPushPropertiesTo(layer.get(), layerImpl.get());
956 } 956 }
957 m_layerTreeHost->commitComplete(); 957 m_layerTreeHost->commitComplete();
958 958
959 // Partial update of 4 tiles. 959 // Partial update of 4 tiles.
960 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); 960 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100));
961 { 961 {
962 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); 962 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1);
963 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); 963 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max());
964 EXPECT_EQ(0, m_queue->fullUploadSize()); 964 EXPECT_EQ(0, m_queue->fullUploadSize());
965 EXPECT_EQ(4, m_queue->partialUploadSize()); 965 EXPECT_EQ(4, m_queue->partialUploadSize());
966 updateTextures(); 966 updateTextures();
967 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); 967 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount());
968 EXPECT_FALSE(m_queue->hasMoreUpdates()); 968 EXPECT_FALSE(m_queue->hasMoreUpdates());
969 layer->fakeLayerUpdater()->clearUpdateCount(); 969 layer->fakeLayerUpdater()->clearUpdateCount();
970 layerPushPropertiesTo(layer.get(), layerImpl.get()); 970 layerPushPropertiesTo(layer.get(), layerImpl.get());
971 } 971 }
972 m_layerTreeHost->commitComplete(); 972 m_layerTreeHost->commitComplete();
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 updateTextures(); 1432 updateTextures();
1433 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); 1433 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount());
1434 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); 1434 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount());
1435 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); 1435 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount());
1436 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1436 EXPECT_FALSE(m_queue->hasMoreUpdates());
1437 1437
1438 root->fakeLayerUpdater()->clearUpdateCount(); 1438 root->fakeLayerUpdater()->clearUpdateCount();
1439 child->fakeLayerUpdater()->clearUpdateCount(); 1439 child->fakeLayerUpdater()->clearUpdateCount();
1440 child2->fakeLayerUpdater()->clearUpdateCount(); 1440 child2->fakeLayerUpdater()->clearUpdateCount();
1441 1441
1442 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl.get(), root->id()); 1442 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl->activeTree(), root->id());
1443 ScopedFakeTiledLayerImpl childImpl(m_hostImpl.get(), child->id()); 1443 ScopedFakeTiledLayerImpl childImpl(m_hostImpl->activeTree(), child->id() );
1444 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl.get(), child2->id()); 1444 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl->activeTree(), child2->id ());
1445 layerPushPropertiesTo(root.get(), rootImpl.get()); 1445 layerPushPropertiesTo(root.get(), rootImpl.get());
1446 layerPushPropertiesTo(child.get(), childImpl.get()); 1446 layerPushPropertiesTo(child.get(), childImpl.get());
1447 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1447 layerPushPropertiesTo(child2.get(), child2Impl.get());
1448 1448
1449 for (unsigned i = 0; i < 3; ++i) { 1449 for (unsigned i = 0; i < 3; ++i) {
1450 for (unsigned j = 0; j < 2; ++j) 1450 for (unsigned j = 0; j < 2; ++j)
1451 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1451 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1452 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); 1452 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0));
1453 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); 1453 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0));
1454 } 1454 }
(...skipping 12 matching lines...) Expand all
1467 updateTextures(); 1467 updateTextures();
1468 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); 1468 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount());
1469 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); 1469 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount());
1470 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); 1470 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount());
1471 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1471 EXPECT_FALSE(m_queue->hasMoreUpdates());
1472 1472
1473 root->fakeLayerUpdater()->clearUpdateCount(); 1473 root->fakeLayerUpdater()->clearUpdateCount();
1474 child->fakeLayerUpdater()->clearUpdateCount(); 1474 child->fakeLayerUpdater()->clearUpdateCount();
1475 child2->fakeLayerUpdater()->clearUpdateCount(); 1475 child2->fakeLayerUpdater()->clearUpdateCount();
1476 1476
1477 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl.get(), root->id()); 1477 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl->activeTree(), root->id());
1478 ScopedFakeTiledLayerImpl childImpl(m_hostImpl.get(), child->id()); 1478 ScopedFakeTiledLayerImpl childImpl(m_hostImpl->activeTree(), child->id() );
1479 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl.get(), child2->id()); 1479 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl->activeTree(), child2->id ());
1480 layerPushPropertiesTo(root.get(), rootImpl.get()); 1480 layerPushPropertiesTo(root.get(), rootImpl.get());
1481 layerPushPropertiesTo(child.get(), childImpl.get()); 1481 layerPushPropertiesTo(child.get(), childImpl.get());
1482 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1482 layerPushPropertiesTo(child2.get(), child2Impl.get());
1483 1483
1484 for (unsigned i = 0; i < 3; ++i) { 1484 for (unsigned i = 0; i < 3; ++i) {
1485 for (unsigned j = 0; j < 2; ++j) 1485 for (unsigned j = 0; j < 2; ++j)
1486 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1486 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1487 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1487 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1488 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1488 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1489 } 1489 }
(...skipping 13 matching lines...) Expand all
1503 updateTextures(); 1503 updateTextures();
1504 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); 1504 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount());
1505 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); 1505 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount());
1506 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); 1506 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount());
1507 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1507 EXPECT_FALSE(m_queue->hasMoreUpdates());
1508 1508
1509 root->fakeLayerUpdater()->clearUpdateCount(); 1509 root->fakeLayerUpdater()->clearUpdateCount();
1510 child->fakeLayerUpdater()->clearUpdateCount(); 1510 child->fakeLayerUpdater()->clearUpdateCount();
1511 child2->fakeLayerUpdater()->clearUpdateCount(); 1511 child2->fakeLayerUpdater()->clearUpdateCount();
1512 1512
1513 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl.get(), root->id()); 1513 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl->activeTree(), root->id());
1514 ScopedFakeTiledLayerImpl childImpl(m_hostImpl.get(), child->id()); 1514 ScopedFakeTiledLayerImpl childImpl(m_hostImpl->activeTree(), child->id() );
1515 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl.get(), child2->id()); 1515 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl->activeTree(), child2->id ());
1516 layerPushPropertiesTo(root.get(), rootImpl.get()); 1516 layerPushPropertiesTo(root.get(), rootImpl.get());
1517 layerPushPropertiesTo(child.get(), childImpl.get()); 1517 layerPushPropertiesTo(child.get(), childImpl.get());
1518 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1518 layerPushPropertiesTo(child2.get(), child2Impl.get());
1519 1519
1520 for (unsigned i = 0; i < 3; ++i) { 1520 for (unsigned i = 0; i < 3; ++i) {
1521 for (unsigned j = 0; j < 2; ++j) 1521 for (unsigned j = 0; j < 2; ++j)
1522 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); 1522 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j));
1523 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1523 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1524 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1524 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1525 } 1525 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1626
1627 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. 1627 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds.
1628 layer->setNeedsDisplayRect(layerRect); 1628 layer->setNeedsDisplayRect(layerRect);
1629 layer->update(*m_queue.get(), 0, m_stats); 1629 layer->update(*m_queue.get(), 0, m_stats);
1630 1630
1631 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); 1631 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
1632 } 1632 }
1633 1633
1634 } // namespace 1634 } // namespace
1635 } // namespace cc 1635 } // namespace cc
OLDNEW
« cc/layer.h ('K') | « cc/tiled_layer_impl_unittest.cc ('k') | cc/tree_synchronizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698