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

Side by Side Diff: cc/layers/tiled_layer_unittest.cc

Issue 1101823002: CC Animations: Make LayerAnimationController creation optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Plumb LayerSettings parameter for cc::Layer construction. Created 5 years, 7 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
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/layers/tiled_layer.h" 5 #include "cc/layers/tiled_layer.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 layer_tree_host_ = LayerTreeHost::CreateThreaded( 97 layer_tree_host_ = LayerTreeHost::CreateThreaded(
98 &synchonous_output_surface_client_, shared_bitmap_manager_.get(), 98 &synchonous_output_surface_client_, shared_bitmap_manager_.get(),
99 nullptr, nullptr, settings_, base::ThreadTaskRunnerHandle::Get(), 99 nullptr, nullptr, settings_, base::ThreadTaskRunnerHandle::Get(),
100 impl_thread_.task_runner(), nullptr); 100 impl_thread_.task_runner(), nullptr);
101 synchonous_output_surface_client_.SetLayerTreeHost(layer_tree_host_.get()); 101 synchonous_output_surface_client_.SetLayerTreeHost(layer_tree_host_.get());
102 proxy_ = layer_tree_host_->proxy(); 102 proxy_ = layer_tree_host_->proxy();
103 resource_manager_ = PrioritizedResourceManager::Create(proxy_); 103 resource_manager_ = PrioritizedResourceManager::Create(proxy_);
104 layer_tree_host_->SetLayerTreeHostClientReady(); 104 layer_tree_host_->SetLayerTreeHostClientReady();
105 CHECK(synchonous_output_surface_client_.EnsureOutputSurfaceCreated()); 105 CHECK(synchonous_output_surface_client_.EnsureOutputSurfaceCreated());
106 106
107 layer_tree_host_->SetRootLayer(Layer::Create()); 107 layer_tree_host_->SetRootLayer(Layer::Create(layer_settings_));
108 108
109 CHECK(output_surface_->BindToClient(&output_surface_client_)); 109 CHECK(output_surface_->BindToClient(&output_surface_client_));
110 110
111 DebugScopedSetImplThreadAndMainThreadBlocked 111 DebugScopedSetImplThreadAndMainThreadBlocked
112 impl_thread_and_main_thread_blocked(proxy_); 112 impl_thread_and_main_thread_blocked(proxy_);
113 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 113 resource_provider_ = ResourceProvider::Create(output_surface_.get(),
114 shared_bitmap_manager_.get(), 114 shared_bitmap_manager_.get(),
115 nullptr, 115 nullptr,
116 nullptr, 116 nullptr,
117 0, 117 0,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 LayerPushPropertiesTo(layer1.get(), layer_impl1.get()); 227 LayerPushPropertiesTo(layer1.get(), layer_impl1.get());
228 if (layer2.get()) 228 if (layer2.get())
229 LayerPushPropertiesTo(layer2.get(), layer_impl2.get()); 229 LayerPushPropertiesTo(layer2.get(), layer_impl2.get());
230 230
231 return needs_update; 231 return needs_update;
232 } 232 }
233 233
234 public: 234 public:
235 Proxy* proxy_; 235 Proxy* proxy_;
236 LayerTreeSettings settings_; 236 LayerTreeSettings settings_;
237 LayerSettings layer_settings_;
237 FakeOutputSurfaceClient output_surface_client_; 238 FakeOutputSurfaceClient output_surface_client_;
238 scoped_ptr<OutputSurface> output_surface_; 239 scoped_ptr<OutputSurface> output_surface_;
239 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 240 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
240 scoped_ptr<ResourceProvider> resource_provider_; 241 scoped_ptr<ResourceProvider> resource_provider_;
241 scoped_ptr<ResourceUpdateQueue> queue_; 242 scoped_ptr<ResourceUpdateQueue> queue_;
242 PriorityCalculator priority_calculator_; 243 PriorityCalculator priority_calculator_;
243 base::Thread impl_thread_; 244 base::Thread impl_thread_;
244 SynchronousOutputSurfaceClient synchonous_output_surface_client_; 245 SynchronousOutputSurfaceClient synchonous_output_surface_client_;
245 scoped_ptr<LayerTreeHost> layer_tree_host_; 246 scoped_ptr<LayerTreeHost> layer_tree_host_;
246 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; 247 scoped_ptr<FakeLayerTreeHostImpl> host_impl_;
247 scoped_ptr<PrioritizedResourceManager> resource_manager_; 248 scoped_ptr<PrioritizedResourceManager> resource_manager_;
248 TestOcclusionTracker* occlusion_; 249 TestOcclusionTracker* occlusion_;
249 }; 250 };
250 251
251 TEST_F(TiledLayerTest, PushDirtyTiles) { 252 TEST_F(TiledLayerTest, PushDirtyTiles) {
252 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); 253 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
253 254
254 scoped_refptr<FakeTiledLayer> layer = 255 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
255 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 256 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
256 scoped_ptr<FakeTiledLayerImpl> layer_impl = 257 scoped_ptr<FakeTiledLayerImpl> layer_impl =
257 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 258 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
258 RenderSurfaceLayerList render_surface_layer_list; 259 RenderSurfaceLayerList render_surface_layer_list;
259 260
260 layer_tree_host_->root_layer()->AddChild(layer); 261 layer_tree_host_->root_layer()->AddChild(layer);
261 262
262 // The tile size is 100x100, so this invalidates and then paints two tiles. 263 // The tile size is 100x100, so this invalidates and then paints two tiles.
263 layer->SetBounds(gfx::Size(100, 200)); 264 layer->SetBounds(gfx::Size(100, 200));
264 CalcDrawProps(&render_surface_layer_list); 265 CalcDrawProps(&render_surface_layer_list);
265 UpdateAndPush(layer, layer_impl); 266 UpdateAndPush(layer, layer_impl);
(...skipping 11 matching lines...) Expand all
277 // not painted. 278 // not painted.
278 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 279 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
279 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); 280 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1));
280 } 281 }
281 282
282 TEST_F(TiledLayerTest, Scale) { 283 TEST_F(TiledLayerTest, Scale) {
283 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); 284 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
284 285
285 layer_tree_host_->SetDeviceScaleFactor(1.5); 286 layer_tree_host_->SetDeviceScaleFactor(1.5);
286 287
287 scoped_refptr<FakeTiledLayer> layer = 288 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
288 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 289 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
289 scoped_ptr<FakeTiledLayerImpl> layer_impl = 290 scoped_ptr<FakeTiledLayerImpl> layer_impl =
290 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 291 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
291 RenderSurfaceLayerList render_surface_layer_list; 292 RenderSurfaceLayerList render_surface_layer_list;
292 293
293 layer_tree_host_->root_layer()->AddChild(layer); 294 layer_tree_host_->root_layer()->AddChild(layer);
294 295
295 layer->SetBounds(gfx::Size(100, 200)); 296 layer->SetBounds(gfx::Size(100, 200));
296 CalcDrawProps(&render_surface_layer_list); 297 CalcDrawProps(&render_surface_layer_list);
297 298
298 // Change the width so that it doesn't divide cleanly by the scale. 299 // Change the width so that it doesn't divide cleanly by the scale.
299 layer->SetBounds(gfx::Size(101, 200)); 300 layer->SetBounds(gfx::Size(101, 200));
300 UpdateAndPush(layer, layer_impl); 301 UpdateAndPush(layer, layer_impl);
301 302
302 EXPECT_EQ(1.5, layer->fake_layer_updater()->last_contents_width_scale()); 303 EXPECT_EQ(1.5, layer->fake_layer_updater()->last_contents_width_scale());
303 } 304 }
304 305
305 TEST_F(TiledLayerTest, PushOccludedDirtyTiles) { 306 TEST_F(TiledLayerTest, PushOccludedDirtyTiles) {
306 scoped_refptr<FakeTiledLayer> layer = 307 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
307 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 308 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
308 scoped_ptr<FakeTiledLayerImpl> layer_impl = 309 scoped_ptr<FakeTiledLayerImpl> layer_impl =
309 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 310 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
310 TestOcclusionTracker occluded; 311 TestOcclusionTracker occluded;
311 occlusion_ = &occluded; 312 occlusion_ = &occluded;
312 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); 313 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
313 314
314 layer_tree_host_->root_layer()->AddChild(layer); 315 layer_tree_host_->root_layer()->AddChild(layer);
315 316
316 { 317 {
317 RenderSurfaceLayerList render_surface_layer_list; 318 RenderSurfaceLayerList render_surface_layer_list;
(...skipping 21 matching lines...) Expand all
339 // We should still have both tiles, as part of the top tile is still 340 // We should still have both tiles, as part of the top tile is still
340 // unoccluded. 341 // unoccluded.
341 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 342 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
342 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); 343 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1));
343 } 344 }
344 } 345 }
345 346
346 TEST_F(TiledLayerTest, PushDeletedTiles) { 347 TEST_F(TiledLayerTest, PushDeletedTiles) {
347 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); 348 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
348 349
349 scoped_refptr<FakeTiledLayer> layer = 350 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
350 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 351 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
351 scoped_ptr<FakeTiledLayerImpl> layer_impl = 352 scoped_ptr<FakeTiledLayerImpl> layer_impl =
352 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 353 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
353 RenderSurfaceLayerList render_surface_layer_list; 354 RenderSurfaceLayerList render_surface_layer_list;
354 355
355 layer_tree_host_->root_layer()->AddChild(layer); 356 layer_tree_host_->root_layer()->AddChild(layer);
356 357
357 // The tile size is 100x100, so this invalidates and then paints two tiles. 358 // The tile size is 100x100, so this invalidates and then paints two tiles.
358 layer->SetBounds(gfx::Size(100, 200)); 359 layer->SetBounds(gfx::Size(100, 200));
359 CalcDrawProps(&render_surface_layer_list); 360 CalcDrawProps(&render_surface_layer_list);
360 UpdateAndPush(layer, layer_impl); 361 UpdateAndPush(layer, layer_impl);
(...skipping 17 matching lines...) Expand all
378 // This should recreate and update one of the deleted textures. 379 // This should recreate and update one of the deleted textures.
379 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 380 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
380 UpdateAndPush(layer, layer_impl); 381 UpdateAndPush(layer, layer_impl);
381 382
382 // We should have one tiles on the impl side. 383 // We should have one tiles on the impl side.
383 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 384 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
384 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); 385 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1));
385 } 386 }
386 387
387 TEST_F(TiledLayerTest, PushIdlePaintTiles) { 388 TEST_F(TiledLayerTest, PushIdlePaintTiles) {
388 scoped_refptr<FakeTiledLayer> layer = 389 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
389 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 390 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
390 scoped_ptr<FakeTiledLayerImpl> layer_impl = 391 scoped_ptr<FakeTiledLayerImpl> layer_impl =
391 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 392 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
392 RenderSurfaceLayerList render_surface_layer_list; 393 RenderSurfaceLayerList render_surface_layer_list;
393 394
394 layer_tree_host_->root_layer()->AddChild(layer); 395 layer_tree_host_->root_layer()->AddChild(layer);
395 396
396 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the 397 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the
397 // center. This paints 1 visible of the 25 invalid tiles. 398 // center. This paints 1 visible of the 25 invalid tiles.
398 layer->SetBounds(gfx::Size(500, 500)); 399 layer->SetBounds(gfx::Size(500, 500));
399 CalcDrawProps(&render_surface_layer_list); 400 CalcDrawProps(&render_surface_layer_list);
(...skipping 18 matching lines...) Expand all
418 // We should have pre-painted all of the surrounding tiles. 419 // We should have pre-painted all of the surrounding tiles.
419 for (int i = 0; i < 5; i++) { 420 for (int i = 0; i < 5; i++) {
420 for (int j = 0; j < 5; j++) 421 for (int j = 0; j < 5; j++)
421 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(i, j)); 422 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(i, j));
422 } 423 }
423 424
424 EXPECT_FALSE(needs_update); 425 EXPECT_FALSE(needs_update);
425 } 426 }
426 427
427 TEST_F(TiledLayerTest, PredictivePainting) { 428 TEST_F(TiledLayerTest, PredictivePainting) {
428 scoped_refptr<FakeTiledLayer> layer = 429 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
429 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 430 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
430 scoped_ptr<FakeTiledLayerImpl> layer_impl = 431 scoped_ptr<FakeTiledLayerImpl> layer_impl =
431 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 432 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
432 433
433 layer_tree_host_->root_layer()->AddChild(layer); 434 layer_tree_host_->root_layer()->AddChild(layer);
434 435
435 // Prepainting should occur in the scroll direction first, and the 436 // Prepainting should occur in the scroll direction first, and the
436 // visible rect should be extruded only along the dominant axis. 437 // visible rect should be extruded only along the dominant axis.
437 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), gfx::Vector2d(10, 0), 438 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), gfx::Vector2d(10, 0),
438 gfx::Vector2d(0, -10), gfx::Vector2d(0, 10), 439 gfx::Vector2d(0, -10), gfx::Vector2d(0, 10),
439 gfx::Vector2d(10, 20), 440 gfx::Vector2d(10, 20),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 for (int i = 0; i < 20; i++) 498 for (int i = 0; i < 20; i++)
498 needs_update = UpdateAndPush(layer, layer_impl); 499 needs_update = UpdateAndPush(layer, layer_impl);
499 EXPECT_FALSE(needs_update); 500 EXPECT_FALSE(needs_update);
500 } 501 }
501 } 502 }
502 503
503 TEST_F(TiledLayerTest, PushTilesAfterIdlePaintFailed) { 504 TEST_F(TiledLayerTest, PushTilesAfterIdlePaintFailed) {
504 // Start with 2mb of memory, but the test is going to try to use just more 505 // Start with 2mb of memory, but the test is going to try to use just more
505 // than 1mb, so we reduce to 1mb later. 506 // than 1mb, so we reduce to 1mb later.
506 resource_manager_->SetMaxMemoryLimitBytes(2 * 1024 * 1024); 507 resource_manager_->SetMaxMemoryLimitBytes(2 * 1024 * 1024);
507 scoped_refptr<FakeTiledLayer> layer1 = 508 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(
508 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 509 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
509 scoped_ptr<FakeTiledLayerImpl> layer_impl1 = 510 scoped_ptr<FakeTiledLayerImpl> layer_impl1 =
510 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 511 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
511 scoped_refptr<FakeTiledLayer> layer2 = 512 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(
512 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 513 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
513 scoped_ptr<FakeTiledLayerImpl> layer_impl2 = 514 scoped_ptr<FakeTiledLayerImpl> layer_impl2 =
514 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 2)); 515 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 2));
515 RenderSurfaceLayerList render_surface_layer_list; 516 RenderSurfaceLayerList render_surface_layer_list;
516 517
517 layer_tree_host_->root_layer()->AddChild(layer1); 518 layer_tree_host_->root_layer()->AddChild(layer1);
518 layer_tree_host_->root_layer()->AddChild(layer2); 519 layer_tree_host_->root_layer()->AddChild(layer2);
519 520
520 // For this test we have two layers. layer1 exhausts most texture memory, 521 // For this test we have two layers. layer1 exhausts most texture memory,
521 // leaving room for 2 more tiles from layer2, but not all three tiles. First 522 // leaving room for 2 more tiles from layer2, but not all three tiles. First
522 // we paint layer1, and one tile from layer2. Then when we idle paint layer2, 523 // we paint layer1, and one tile from layer2. Then when we idle paint layer2,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 EXPECT_TRUE(layer_impl2->HasResourceIdForTileAt(0, 0)); 559 EXPECT_TRUE(layer_impl2->HasResourceIdForTileAt(0, 0));
559 EXPECT_TRUE(layer_impl2->HasResourceIdForTileAt(0, 0)); 560 EXPECT_TRUE(layer_impl2->HasResourceIdForTileAt(0, 0));
560 EXPECT_TRUE(layer_impl2->HasResourceIdForTileAt(0, 1)); 561 EXPECT_TRUE(layer_impl2->HasResourceIdForTileAt(0, 1));
561 EXPECT_TRUE(layer_impl2->HasResourceIdForTileAt(0, 1)); 562 EXPECT_TRUE(layer_impl2->HasResourceIdForTileAt(0, 1));
562 563
563 EXPECT_FALSE(needs_update); 564 EXPECT_FALSE(needs_update);
564 EXPECT_FALSE(layer_impl2->HasResourceIdForTileAt(0, 2)); 565 EXPECT_FALSE(layer_impl2->HasResourceIdForTileAt(0, 2));
565 } 566 }
566 567
567 TEST_F(TiledLayerTest, PushIdlePaintedOccludedTiles) { 568 TEST_F(TiledLayerTest, PushIdlePaintedOccludedTiles) {
568 scoped_refptr<FakeTiledLayer> layer = 569 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
569 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 570 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
570 scoped_ptr<FakeTiledLayerImpl> layer_impl = 571 scoped_ptr<FakeTiledLayerImpl> layer_impl =
571 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 572 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
572 RenderSurfaceLayerList render_surface_layer_list; 573 RenderSurfaceLayerList render_surface_layer_list;
573 TestOcclusionTracker occluded; 574 TestOcclusionTracker occluded;
574 occlusion_ = &occluded; 575 occlusion_ = &occluded;
575 576
576 layer_tree_host_->root_layer()->AddChild(layer); 577 layer_tree_host_->root_layer()->AddChild(layer);
577 578
578 // The tile size is 100x100, so this invalidates one occluded tile, culls it 579 // The tile size is 100x100, so this invalidates one occluded tile, culls it
579 // during paint, but prepaints it. 580 // during paint, but prepaints it.
580 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(0, 0, 100, 100))); 581 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(0, 0, 100, 100)));
581 582
582 layer->SetBounds(gfx::Size(100, 100)); 583 layer->SetBounds(gfx::Size(100, 100));
583 CalcDrawProps(&render_surface_layer_list); 584 CalcDrawProps(&render_surface_layer_list);
584 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 585 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
585 UpdateAndPush(layer, layer_impl); 586 UpdateAndPush(layer, layer_impl);
586 587
587 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 588 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
588 } 589 }
589 590
590 TEST_F(TiledLayerTest, PushTilesMarkedDirtyDuringPaint) { 591 TEST_F(TiledLayerTest, PushTilesMarkedDirtyDuringPaint) {
591 scoped_refptr<FakeTiledLayer> layer = 592 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
592 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 593 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
593 scoped_ptr<FakeTiledLayerImpl> layer_impl = 594 scoped_ptr<FakeTiledLayerImpl> layer_impl =
594 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 595 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
595 RenderSurfaceLayerList render_surface_layer_list; 596 RenderSurfaceLayerList render_surface_layer_list;
596 597
597 layer_tree_host_->root_layer()->AddChild(layer); 598 layer_tree_host_->root_layer()->AddChild(layer);
598 599
599 // The tile size is 100x100, so this invalidates and then paints two tiles. 600 // The tile size is 100x100, so this invalidates and then paints two tiles.
600 // However, during the paint, we invalidate one of the tiles. This should 601 // However, during the paint, we invalidate one of the tiles. This should
601 // not prevent the tile from being pushed. 602 // not prevent the tile from being pushed.
602 layer->fake_layer_updater()->SetRectToInvalidate( 603 layer->fake_layer_updater()->SetRectToInvalidate(
603 gfx::Rect(0, 50, 100, 50), layer.get()); 604 gfx::Rect(0, 50, 100, 50), layer.get());
604 layer->SetBounds(gfx::Size(100, 200)); 605 layer->SetBounds(gfx::Size(100, 200));
605 CalcDrawProps(&render_surface_layer_list); 606 CalcDrawProps(&render_surface_layer_list);
606 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 607 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
607 UpdateAndPush(layer, layer_impl); 608 UpdateAndPush(layer, layer_impl);
608 609
609 // We should have both tiles on the impl side. 610 // We should have both tiles on the impl side.
610 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); 611 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0));
611 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); 612 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1));
612 } 613 }
613 614
614 TEST_F(TiledLayerTest, PushTilesLayerMarkedDirtyDuringPaintOnNextLayer) { 615 TEST_F(TiledLayerTest, PushTilesLayerMarkedDirtyDuringPaintOnNextLayer) {
615 scoped_refptr<FakeTiledLayer> layer1 = 616 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(
616 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 617 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
617 scoped_refptr<FakeTiledLayer> layer2 = 618 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(
618 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 619 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
619 scoped_ptr<FakeTiledLayerImpl> layer1_impl = 620 scoped_ptr<FakeTiledLayerImpl> layer1_impl =
620 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 621 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
621 scoped_ptr<FakeTiledLayerImpl> layer2_impl = 622 scoped_ptr<FakeTiledLayerImpl> layer2_impl =
622 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 2)); 623 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 2));
623 RenderSurfaceLayerList render_surface_layer_list; 624 RenderSurfaceLayerList render_surface_layer_list;
624 625
625 layer_tree_host_->root_layer()->AddChild(layer1); 626 layer_tree_host_->root_layer()->AddChild(layer1);
626 layer_tree_host_->root_layer()->AddChild(layer2); 627 layer_tree_host_->root_layer()->AddChild(layer2);
627 628
628 // Invalidate a tile on layer1, during update of layer 2. 629 // Invalidate a tile on layer1, during update of layer 2.
629 layer2->fake_layer_updater()->SetRectToInvalidate( 630 layer2->fake_layer_updater()->SetRectToInvalidate(
630 gfx::Rect(0, 50, 100, 50), layer1.get()); 631 gfx::Rect(0, 50, 100, 50), layer1.get());
631 layer1->SetBounds(gfx::Size(100, 200)); 632 layer1->SetBounds(gfx::Size(100, 200));
632 layer2->SetBounds(gfx::Size(100, 200)); 633 layer2->SetBounds(gfx::Size(100, 200));
633 CalcDrawProps(&render_surface_layer_list); 634 CalcDrawProps(&render_surface_layer_list);
634 layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 635 layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
635 layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 636 layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
636 UpdateAndPush(layer1, layer1_impl, layer2, layer2_impl); 637 UpdateAndPush(layer1, layer1_impl, layer2, layer2_impl);
637 638
638 // We should have both tiles on the impl side for all layers. 639 // We should have both tiles on the impl side for all layers.
639 EXPECT_TRUE(layer1_impl->HasResourceIdForTileAt(0, 0)); 640 EXPECT_TRUE(layer1_impl->HasResourceIdForTileAt(0, 0));
640 EXPECT_TRUE(layer1_impl->HasResourceIdForTileAt(0, 1)); 641 EXPECT_TRUE(layer1_impl->HasResourceIdForTileAt(0, 1));
641 EXPECT_TRUE(layer2_impl->HasResourceIdForTileAt(0, 0)); 642 EXPECT_TRUE(layer2_impl->HasResourceIdForTileAt(0, 0));
642 EXPECT_TRUE(layer2_impl->HasResourceIdForTileAt(0, 1)); 643 EXPECT_TRUE(layer2_impl->HasResourceIdForTileAt(0, 1));
643 } 644 }
644 645
645 TEST_F(TiledLayerTest, PushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) { 646 TEST_F(TiledLayerTest, PushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) {
646 scoped_refptr<FakeTiledLayer> layer1 = 647 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(
647 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 648 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
648 scoped_refptr<FakeTiledLayer> layer2 = 649 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(
649 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 650 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
650 scoped_ptr<FakeTiledLayerImpl> layer1_impl = 651 scoped_ptr<FakeTiledLayerImpl> layer1_impl =
651 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 652 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
652 scoped_ptr<FakeTiledLayerImpl> layer2_impl = 653 scoped_ptr<FakeTiledLayerImpl> layer2_impl =
653 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 2)); 654 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 2));
654 RenderSurfaceLayerList render_surface_layer_list; 655 RenderSurfaceLayerList render_surface_layer_list;
655 656
656 layer_tree_host_->root_layer()->AddChild(layer1); 657 layer_tree_host_->root_layer()->AddChild(layer1);
657 layer_tree_host_->root_layer()->AddChild(layer2); 658 layer_tree_host_->root_layer()->AddChild(layer2);
658 659
659 layer1->fake_layer_updater()->SetRectToInvalidate( 660 layer1->fake_layer_updater()->SetRectToInvalidate(
(...skipping 25 matching lines...) Expand all
685 int memory_for_layer = layer_width * layer_height * 4; 686 int memory_for_layer = layer_width * layer_height * 4;
686 layer_tree_host_->SetViewportSize( 687 layer_tree_host_->SetViewportSize(
687 gfx::Size(viewport_width, viewport_height)); 688 gfx::Size(viewport_width, viewport_height));
688 689
689 // Use 10x5 tiles to run out of memory. 690 // Use 10x5 tiles to run out of memory.
690 if (run_out_of_memory[i]) 691 if (run_out_of_memory[i])
691 layer_width *= 2; 692 layer_width *= 2;
692 693
693 resource_manager_->SetMaxMemoryLimitBytes(memory_for_layer); 694 resource_manager_->SetMaxMemoryLimitBytes(memory_for_layer);
694 695
695 scoped_refptr<FakeTiledLayer> layer = 696 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
696 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 697 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
697 scoped_ptr<FakeTiledLayerImpl> layer_impl = 698 scoped_ptr<FakeTiledLayerImpl> layer_impl =
698 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 699 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
699 RenderSurfaceLayerList render_surface_layer_list; 700 RenderSurfaceLayerList render_surface_layer_list;
700 701
701 layer_tree_host_->root_layer()->AddChild(layer); 702 layer_tree_host_->root_layer()->AddChild(layer);
702 703
703 // Full size layer with half being visible. 704 // Full size layer with half being visible.
704 layer->SetBounds(gfx::Size(layer_width, layer_height)); 705 layer->SetBounds(gfx::Size(layer_width, layer_height));
705 gfx::Rect visible_rect(0, 0, layer_width / 2, layer_height); 706 gfx::Rect visible_rect(0, 0, layer_width / 2, layer_height);
706 CalcDrawProps(&render_surface_layer_list); 707 CalcDrawProps(&render_surface_layer_list);
(...skipping 25 matching lines...) Expand all
732 for (int j = 0; j < 5; ++j) 733 for (int j = 0; j < 5; ++j)
733 EXPECT_EQ(layer_impl->HasResourceIdForTileAt(i, j), i < 5); 734 EXPECT_EQ(layer_impl->HasResourceIdForTileAt(i, j), i < 5);
734 } 735 }
735 } 736 }
736 737
737 layer->RemoveFromParent(); 738 layer->RemoveFromParent();
738 } 739 }
739 } 740 }
740 741
741 TEST_F(TiledLayerTest, IdlePaintOutOfMemory) { 742 TEST_F(TiledLayerTest, IdlePaintOutOfMemory) {
742 scoped_refptr<FakeTiledLayer> layer = 743 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
743 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 744 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
744 scoped_ptr<FakeTiledLayerImpl> layer_impl = 745 scoped_ptr<FakeTiledLayerImpl> layer_impl =
745 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 746 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
746 RenderSurfaceLayerList render_surface_layer_list; 747 RenderSurfaceLayerList render_surface_layer_list;
747 748
748 layer_tree_host_->root_layer()->AddChild(layer); 749 layer_tree_host_->root_layer()->AddChild(layer);
749 750
750 // We have enough memory for only the visible rect, so we will run out of 751 // We have enough memory for only the visible rect, so we will run out of
751 // memory in first idle paint. 752 // memory in first idle paint.
752 int memory_limit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. 753 int memory_limit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel.
753 resource_manager_->SetMaxMemoryLimitBytes(memory_limit); 754 resource_manager_->SetMaxMemoryLimitBytes(memory_limit);
754 755
755 // The tile size is 100x100, so this invalidates and then paints two tiles. 756 // The tile size is 100x100, so this invalidates and then paints two tiles.
756 bool needs_update = false; 757 bool needs_update = false;
757 layer->SetBounds(gfx::Size(300, 300)); 758 layer->SetBounds(gfx::Size(300, 300));
758 CalcDrawProps(&render_surface_layer_list); 759 CalcDrawProps(&render_surface_layer_list);
759 layer->draw_properties().visible_content_rect = gfx::Rect(100, 100, 100, 100); 760 layer->draw_properties().visible_content_rect = gfx::Rect(100, 100, 100, 100);
760 for (int i = 0; i < 2; i++) 761 for (int i = 0; i < 2; i++)
761 needs_update = UpdateAndPush(layer, layer_impl); 762 needs_update = UpdateAndPush(layer, layer_impl);
762 763
763 // Idle-painting should see no more priority tiles for painting. 764 // Idle-painting should see no more priority tiles for painting.
764 EXPECT_FALSE(needs_update); 765 EXPECT_FALSE(needs_update);
765 766
766 // We should have one tile on the impl side. 767 // We should have one tile on the impl side.
767 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 1)); 768 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 1));
768 } 769 }
769 770
770 TEST_F(TiledLayerTest, IdlePaintZeroSizedLayer) { 771 TEST_F(TiledLayerTest, IdlePaintZeroSizedLayer) {
771 scoped_refptr<FakeTiledLayer> layer = 772 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
772 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 773 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
773 scoped_ptr<FakeTiledLayerImpl> layer_impl = 774 scoped_ptr<FakeTiledLayerImpl> layer_impl =
774 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 775 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
775 776
776 layer_tree_host_->root_layer()->AddChild(layer); 777 layer_tree_host_->root_layer()->AddChild(layer);
777 778
778 bool animating[2] = { false, true }; 779 bool animating[2] = { false, true };
779 for (int i = 0; i < 2; i++) { 780 for (int i = 0; i < 2; i++) {
780 // Pretend the layer is animating. 781 // Pretend the layer is animating.
781 layer->draw_properties().target_space_transform_is_animating = animating[i]; 782 layer->draw_properties().target_space_transform_is_animating = animating[i];
782 783
(...skipping 11 matching lines...) Expand all
794 795
795 // Empty layers don't need prepaint. 796 // Empty layers don't need prepaint.
796 EXPECT_FALSE(needs_update); 797 EXPECT_FALSE(needs_update);
797 798
798 // Empty layers don't have tiles. 799 // Empty layers don't have tiles.
799 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 0)); 800 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 0));
800 } 801 }
801 } 802 }
802 803
803 TEST_F(TiledLayerTest, IdlePaintNonVisibleLayers) { 804 TEST_F(TiledLayerTest, IdlePaintNonVisibleLayers) {
804 scoped_refptr<FakeTiledLayer> layer = 805 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
805 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 806 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
806 scoped_ptr<FakeTiledLayerImpl> layer_impl = 807 scoped_ptr<FakeTiledLayerImpl> layer_impl =
807 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 808 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
808 809
809 // Alternate between not visible and visible. 810 // Alternate between not visible and visible.
810 gfx::Rect v(0, 0, 100, 100); 811 gfx::Rect v(0, 0, 100, 100);
811 gfx::Rect nv(0, 0, 0, 0); 812 gfx::Rect nv(0, 0, 0, 0);
812 gfx::Rect visible_rect[10] = { nv, nv, v, v, nv, nv, v, v, nv, nv }; 813 gfx::Rect visible_rect[10] = { nv, nv, v, v, nv, nv, v, v, nv, nv };
813 bool invalidate[10] = { true, true, true, true, true, true, true, true, false, 814 bool invalidate[10] = { true, true, true, true, true, true, true, true, false,
814 false }; 815 false };
815 816
(...skipping 16 matching lines...) Expand all
832 bool needs_update = UpdateAndPush(layer, layer_impl); 833 bool needs_update = UpdateAndPush(layer, layer_impl);
833 834
834 // We should never signal idle paint, as we painted the entire layer 835 // We should never signal idle paint, as we painted the entire layer
835 // or the layer was not visible. 836 // or the layer was not visible.
836 EXPECT_FALSE(needs_update); 837 EXPECT_FALSE(needs_update);
837 EXPECT_EQ(layer_impl->HasResourceIdForTileAt(0, 0), have_tile[i]); 838 EXPECT_EQ(layer_impl->HasResourceIdForTileAt(0, 0), have_tile[i]);
838 } 839 }
839 } 840 }
840 841
841 TEST_F(TiledLayerTest, InvalidateFromPrepare) { 842 TEST_F(TiledLayerTest, InvalidateFromPrepare) {
842 scoped_refptr<FakeTiledLayer> layer = 843 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
843 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 844 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
844 scoped_ptr<FakeTiledLayerImpl> layer_impl = 845 scoped_ptr<FakeTiledLayerImpl> layer_impl =
845 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 846 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
846 RenderSurfaceLayerList render_surface_layer_list; 847 RenderSurfaceLayerList render_surface_layer_list;
847 848
848 layer_tree_host_->root_layer()->AddChild(layer); 849 layer_tree_host_->root_layer()->AddChild(layer);
849 850
850 // The tile size is 100x100, so this invalidates and then paints two tiles. 851 // The tile size is 100x100, so this invalidates and then paints two tiles.
851 layer->SetBounds(gfx::Size(100, 200)); 852 layer->SetBounds(gfx::Size(100, 200));
852 CalcDrawProps(&render_surface_layer_list); 853 CalcDrawProps(&render_surface_layer_list);
853 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 854 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
(...skipping 20 matching lines...) Expand all
874 layer->fake_layer_updater()->ClearPrepareCount(); 875 layer->fake_layer_updater()->ClearPrepareCount();
875 876
876 // The layer should still be invalid as update invoked invalidate. 877 // The layer should still be invalid as update invoked invalidate.
877 UpdateAndPush(layer, layer_impl); // visible 878 UpdateAndPush(layer, layer_impl); // visible
878 EXPECT_EQ(1, layer->fake_layer_updater()->prepare_count()); 879 EXPECT_EQ(1, layer->fake_layer_updater()->prepare_count());
879 } 880 }
880 881
881 TEST_F(TiledLayerTest, VerifyUpdateRectWhenContentBoundsAreScaled) { 882 TEST_F(TiledLayerTest, VerifyUpdateRectWhenContentBoundsAreScaled) {
882 // The update rect (that indicates what was actually painted) should be in 883 // The update rect (that indicates what was actually painted) should be in
883 // layer space, not the content space. 884 // layer space, not the content space.
884 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr( 885 scoped_refptr<FakeTiledLayerWithScaledBounds> layer =
885 new FakeTiledLayerWithScaledBounds(resource_manager_.get())); 886 make_scoped_refptr(new FakeTiledLayerWithScaledBounds(
887 layer_settings_, resource_manager_.get()));
886 888
887 layer_tree_host_->root_layer()->AddChild(layer); 889 layer_tree_host_->root_layer()->AddChild(layer);
888 890
889 gfx::Rect layer_bounds(0, 0, 300, 200); 891 gfx::Rect layer_bounds(0, 0, 300, 200);
890 gfx::Rect content_bounds(0, 0, 150, 250); 892 gfx::Rect content_bounds(0, 0, 150, 250);
891 893
892 layer->SetBounds(layer_bounds.size()); 894 layer->SetBounds(layer_bounds.size());
893 layer->SetContentBounds(content_bounds.size()); 895 layer->SetContentBounds(content_bounds.size());
894 layer->draw_properties().visible_content_rect = content_bounds; 896 layer->draw_properties().visible_content_rect = content_bounds;
895 layer->draw_properties().contents_scale_x = .5f; 897 layer->draw_properties().contents_scale_x = .5f;
(...skipping 28 matching lines...) Expand all
924 gfx::Rect partial_damage(30, 100, 10, 10); 926 gfx::Rect partial_damage(30, 100, 10, 10);
925 layer->InvalidateContentRect(partial_damage); 927 layer->InvalidateContentRect(partial_damage);
926 layer->SetTexturePriorities(priority_calculator_); 928 layer->SetTexturePriorities(priority_calculator_);
927 resource_manager_->PrioritizeTextures(); 929 resource_manager_->PrioritizeTextures();
928 layer->SavePaintProperties(); 930 layer->SavePaintProperties();
929 layer->Update(queue_.get(), nullptr); 931 layer->Update(queue_.get(), nullptr);
930 EXPECT_FLOAT_RECT_EQ(gfx::RectF(60, 80, 20, 8), layer->update_rect()); 932 EXPECT_FLOAT_RECT_EQ(gfx::RectF(60, 80, 20, 8), layer->update_rect());
931 } 933 }
932 934
933 TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { 935 TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) {
934 scoped_refptr<FakeTiledLayer> layer = 936 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
935 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 937 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
936 scoped_ptr<FakeTiledLayerImpl> layer_impl = 938 scoped_ptr<FakeTiledLayerImpl> layer_impl =
937 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); 939 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
938 RenderSurfaceLayerList render_surface_layer_list; 940 RenderSurfaceLayerList render_surface_layer_list;
939 941
940 layer_tree_host_->root_layer()->AddChild(layer); 942 layer_tree_host_->root_layer()->AddChild(layer);
941 943
942 // Create a layer with one tile. 944 // Create a layer with one tile.
943 layer->SetBounds(gfx::Size(100, 100)); 945 layer->SetBounds(gfx::Size(100, 100));
944 CalcDrawProps(&render_surface_layer_list); 946 CalcDrawProps(&render_surface_layer_list);
945 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 947 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 } 1000 }
999 1001
1000 TEST_F(TiledLayerTest, SkipsDrawGetsReset) { 1002 TEST_F(TiledLayerTest, SkipsDrawGetsReset) {
1001 // Create two 300 x 300 tiled layers. 1003 // Create two 300 x 300 tiled layers.
1002 gfx::Size content_bounds(300, 300); 1004 gfx::Size content_bounds(300, 300);
1003 gfx::Rect content_rect(content_bounds); 1005 gfx::Rect content_rect(content_bounds);
1004 1006
1005 // We have enough memory for only one of the two layers. 1007 // We have enough memory for only one of the two layers.
1006 int memory_limit = 4 * 300 * 300; // 4 bytes per pixel. 1008 int memory_limit = 4 * 300 * 300; // 4 bytes per pixel.
1007 1009
1008 scoped_refptr<FakeTiledLayer> root_layer = make_scoped_refptr( 1010 scoped_refptr<FakeTiledLayer> root_layer =
1009 new FakeTiledLayer(layer_tree_host_->contents_texture_manager())); 1011 make_scoped_refptr(new FakeTiledLayer(
1010 scoped_refptr<FakeTiledLayer> child_layer = make_scoped_refptr( 1012 layer_settings_, layer_tree_host_->contents_texture_manager()));
1011 new FakeTiledLayer(layer_tree_host_->contents_texture_manager())); 1013 scoped_refptr<FakeTiledLayer> child_layer =
1014 make_scoped_refptr(new FakeTiledLayer(
1015 layer_settings_, layer_tree_host_->contents_texture_manager()));
1012 root_layer->AddChild(child_layer); 1016 root_layer->AddChild(child_layer);
1013 1017
1014 root_layer->SetBounds(content_bounds); 1018 root_layer->SetBounds(content_bounds);
1015 root_layer->draw_properties().visible_content_rect = content_rect; 1019 root_layer->draw_properties().visible_content_rect = content_rect;
1016 root_layer->SetPosition(gfx::PointF(0, 0)); 1020 root_layer->SetPosition(gfx::PointF(0, 0));
1017 child_layer->SetBounds(content_bounds); 1021 child_layer->SetBounds(content_bounds);
1018 child_layer->draw_properties().visible_content_rect = content_rect; 1022 child_layer->draw_properties().visible_content_rect = content_rect;
1019 child_layer->SetPosition(gfx::PointF(0, 0)); 1023 child_layer->SetPosition(gfx::PointF(0, 0));
1020 root_layer->InvalidateContentRect(content_rect); 1024 root_layer->InvalidateContentRect(content_rect);
1021 child_layer->InvalidateContentRect(content_rect); 1025 child_layer->InvalidateContentRect(content_rect);
(...skipping 16 matching lines...) Expand all
1038 1042
1039 layer_tree_host_->UpdateLayers(queue_.get()); 1043 layer_tree_host_->UpdateLayers(queue_.get());
1040 EXPECT_FALSE(root_layer->SkipsDraw()); 1044 EXPECT_FALSE(root_layer->SkipsDraw());
1041 1045
1042 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), 1046 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(),
1043 resource_provider_.get()); 1047 resource_provider_.get());
1044 layer_tree_host_->SetRootLayer(nullptr); 1048 layer_tree_host_->SetRootLayer(nullptr);
1045 } 1049 }
1046 1050
1047 TEST_F(TiledLayerTest, ResizeToSmaller) { 1051 TEST_F(TiledLayerTest, ResizeToSmaller) {
1048 scoped_refptr<FakeTiledLayer> layer = 1052 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
1049 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1053 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
1050 1054
1051 layer_tree_host_->root_layer()->AddChild(layer); 1055 layer_tree_host_->root_layer()->AddChild(layer);
1052 1056
1053 layer->SetBounds(gfx::Size(700, 700)); 1057 layer->SetBounds(gfx::Size(700, 700));
1054 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); 1058 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700);
1055 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700)); 1059 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700));
1056 1060
1057 layer->SetTexturePriorities(priority_calculator_); 1061 layer->SetTexturePriorities(priority_calculator_);
1058 resource_manager_->PrioritizeTextures(); 1062 resource_manager_->PrioritizeTextures();
1059 layer->SavePaintProperties(); 1063 layer->SavePaintProperties();
1060 layer->Update(queue_.get(), nullptr); 1064 layer->Update(queue_.get(), nullptr);
1061 1065
1062 layer->SetBounds(gfx::Size(200, 200)); 1066 layer->SetBounds(gfx::Size(200, 200));
1063 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200)); 1067 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200));
1064 } 1068 }
1065 1069
1066 TEST_F(TiledLayerTest, HugeLayerUpdateCrash) { 1070 TEST_F(TiledLayerTest, HugeLayerUpdateCrash) {
1067 scoped_refptr<FakeTiledLayer> layer = 1071 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
1068 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1072 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
1069 1073
1070 layer_tree_host_->root_layer()->AddChild(layer); 1074 layer_tree_host_->root_layer()->AddChild(layer);
1071 1075
1072 int size = 1 << 30; 1076 int size = 1 << 30;
1073 layer->SetBounds(gfx::Size(size, size)); 1077 layer->SetBounds(gfx::Size(size, size));
1074 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); 1078 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700);
1075 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size)); 1079 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size));
1076 1080
1077 // Ensure no crash for bounds where size * size would overflow an int. 1081 // Ensure no crash for bounds where size * size would overflow an int.
1078 layer->SetTexturePriorities(priority_calculator_); 1082 layer->SetTexturePriorities(priority_calculator_);
1079 resource_manager_->PrioritizeTextures(); 1083 resource_manager_->PrioritizeTextures();
1080 layer->SavePaintProperties(); 1084 layer->SavePaintProperties();
1081 layer->Update(queue_.get(), nullptr); 1085 layer->Update(queue_.get(), nullptr);
1082 } 1086 }
1083 1087
1084 class TiledLayerPartialUpdateTest : public TiledLayerTest { 1088 class TiledLayerPartialUpdateTest : public TiledLayerTest {
1085 public: 1089 public:
1086 TiledLayerPartialUpdateTest() { settings_.max_partial_texture_updates = 4; } 1090 TiledLayerPartialUpdateTest() { settings_.max_partial_texture_updates = 4; }
1087 }; 1091 };
1088 1092
1089 TEST_F(TiledLayerPartialUpdateTest, PartialUpdates) { 1093 TEST_F(TiledLayerPartialUpdateTest, PartialUpdates) {
1090 // Create one 300 x 200 tiled layer with 3 x 2 tiles. 1094 // Create one 300 x 200 tiled layer with 3 x 2 tiles.
1091 gfx::Size content_bounds(300, 200); 1095 gfx::Size content_bounds(300, 200);
1092 gfx::Rect content_rect(content_bounds); 1096 gfx::Rect content_rect(content_bounds);
1093 1097
1094 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr( 1098 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
1095 new FakeTiledLayer(layer_tree_host_->contents_texture_manager())); 1099 layer_settings_, layer_tree_host_->contents_texture_manager()));
1096 layer->SetBounds(content_bounds); 1100 layer->SetBounds(content_bounds);
1097 layer->SetPosition(gfx::PointF(0, 0)); 1101 layer->SetPosition(gfx::PointF(0, 0));
1098 layer->draw_properties().visible_content_rect = content_rect; 1102 layer->draw_properties().visible_content_rect = content_rect;
1099 layer->InvalidateContentRect(content_rect); 1103 layer->InvalidateContentRect(content_rect);
1100 1104
1101 layer_tree_host_->SetRootLayer(layer); 1105 layer_tree_host_->SetRootLayer(layer);
1102 layer_tree_host_->SetViewportSize(gfx::Size(300, 200)); 1106 layer_tree_host_->SetViewportSize(gfx::Size(300, 200));
1103 1107
1104 // Full update of all 6 tiles. 1108 // Full update of all 6 tiles.
1105 layer_tree_host_->UpdateLayers(queue_.get()); 1109 layer_tree_host_->UpdateLayers(queue_.get());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 layer_tree_host_->CommitComplete(); 1194 layer_tree_host_->CommitComplete();
1191 1195
1192 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), 1196 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(),
1193 resource_provider_.get()); 1197 resource_provider_.get());
1194 layer_tree_host_->SetRootLayer(nullptr); 1198 layer_tree_host_->SetRootLayer(nullptr);
1195 } 1199 }
1196 1200
1197 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { 1201 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) {
1198 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); 1202 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
1199 1203
1200 scoped_refptr<FakeTiledLayer> layer = 1204 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
1201 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1205 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
1202 RenderSurfaceLayerList render_surface_layer_list; 1206 RenderSurfaceLayerList render_surface_layer_list;
1203 1207
1204 layer_tree_host_->root_layer()->AddChild(layer); 1208 layer_tree_host_->root_layer()->AddChild(layer);
1205 1209
1206 // The tile size is 100x100, so this invalidates and then paints two tiles. 1210 // The tile size is 100x100, so this invalidates and then paints two tiles.
1207 layer->SetBounds(gfx::Size(100, 200)); 1211 layer->SetBounds(gfx::Size(100, 200));
1208 CalcDrawProps(&render_surface_layer_list); 1212 CalcDrawProps(&render_surface_layer_list);
1209 1213
1210 layer->SetTexturePriorities(priority_calculator_); 1214 layer->SetTexturePriorities(priority_calculator_);
1211 resource_manager_->PrioritizeTextures(); 1215 resource_manager_->PrioritizeTextures();
1212 layer->SavePaintProperties(); 1216 layer->SavePaintProperties();
1213 layer->Update(queue_.get(), nullptr); 1217 layer->Update(queue_.get(), nullptr);
1214 EXPECT_EQ(2, layer->fake_layer_updater()->update_count()); 1218 EXPECT_EQ(2, layer->fake_layer_updater()->update_count());
1215 } 1219 }
1216 1220
1217 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { 1221 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) {
1218 scoped_refptr<FakeTiledLayer> layer = 1222 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
1219 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1223 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
1220 RenderSurfaceLayerList render_surface_layer_list; 1224 RenderSurfaceLayerList render_surface_layer_list;
1221 TestOcclusionTracker occluded; 1225 TestOcclusionTracker occluded;
1222 occlusion_ = &occluded; 1226 occlusion_ = &occluded;
1223 1227
1224 layer_tree_host_->root_layer()->AddChild(layer); 1228 layer_tree_host_->root_layer()->AddChild(layer);
1225 1229
1226 // The tile size is 100x100. 1230 // The tile size is 100x100.
1227 1231
1228 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); 1232 layer_tree_host_->SetViewportSize(gfx::Size(600, 600));
1229 layer->SetBounds(gfx::Size(600, 600)); 1233 layer->SetBounds(gfx::Size(600, 600));
(...skipping 27 matching lines...) Expand all
1257 resource_manager_->PrioritizeTextures(); 1261 resource_manager_->PrioritizeTextures();
1258 1262
1259 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(250, 250, 300, 100))); 1263 occluded.SetOcclusion(SimpleEnclosedRegion(gfx::Rect(250, 250, 300, 100)));
1260 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1264 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1261 layer->SavePaintProperties(); 1265 layer->SavePaintProperties();
1262 layer->Update(queue_.get(), &occluded); 1266 layer->Update(queue_.get(), &occluded);
1263 EXPECT_EQ(36, layer->fake_layer_updater()->update_count()); 1267 EXPECT_EQ(36, layer->fake_layer_updater()->update_count());
1264 } 1268 }
1265 1269
1266 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { 1270 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) {
1267 scoped_refptr<FakeTiledLayer> layer = 1271 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
1268 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1272 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
1269 RenderSurfaceLayerList render_surface_layer_list; 1273 RenderSurfaceLayerList render_surface_layer_list;
1270 TestOcclusionTracker occluded; 1274 TestOcclusionTracker occluded;
1271 occlusion_ = &occluded; 1275 occlusion_ = &occluded;
1272 1276
1273 layer_tree_host_->root_layer()->AddChild(layer); 1277 layer_tree_host_->root_layer()->AddChild(layer);
1274 1278
1275 // The tile size is 100x100. 1279 // The tile size is 100x100.
1276 1280
1277 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); 1281 layer_tree_host_->SetViewportSize(gfx::Size(600, 600));
1278 layer->SetBounds(gfx::Size(600, 600)); 1282 layer->SetBounds(gfx::Size(600, 600));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340); 1318 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340);
1315 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1319 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1316 layer->SetTexturePriorities(priority_calculator_); 1320 layer->SetTexturePriorities(priority_calculator_);
1317 resource_manager_->PrioritizeTextures(); 1321 resource_manager_->PrioritizeTextures();
1318 layer->SavePaintProperties(); 1322 layer->SavePaintProperties();
1319 layer->Update(queue_.get(), &occluded); 1323 layer->Update(queue_.get(), &occluded);
1320 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); 1324 EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count());
1321 } 1325 }
1322 1326
1323 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { 1327 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) {
1324 scoped_refptr<FakeTiledLayer> layer = 1328 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
1325 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1329 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
1326 RenderSurfaceLayerList render_surface_layer_list; 1330 RenderSurfaceLayerList render_surface_layer_list;
1327 TestOcclusionTracker occluded; 1331 TestOcclusionTracker occluded;
1328 occlusion_ = &occluded; 1332 occlusion_ = &occluded;
1329 1333
1330 layer_tree_host_->root_layer()->AddChild(layer); 1334 layer_tree_host_->root_layer()->AddChild(layer);
1331 1335
1332 // The tile size is 100x100. 1336 // The tile size is 100x100.
1333 1337
1334 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); 1338 layer_tree_host_->SetViewportSize(gfx::Size(600, 600));
1335 layer->SetBounds(gfx::Size(600, 600)); 1339 layer->SetBounds(gfx::Size(600, 600));
(...skipping 15 matching lines...) Expand all
1351 resource_manager_->PrioritizeTextures(); 1355 resource_manager_->PrioritizeTextures();
1352 layer->SavePaintProperties(); 1356 layer->SavePaintProperties();
1353 1357
1354 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted 1358 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted
1355 // now. 1359 // now.
1356 layer->Update(queue_.get(), &occluded); 1360 layer->Update(queue_.get(), &occluded);
1357 EXPECT_EQ(3, layer->fake_layer_updater()->update_count()); 1361 EXPECT_EQ(3, layer->fake_layer_updater()->update_count());
1358 } 1362 }
1359 1363
1360 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) { 1364 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) {
1361 scoped_refptr<FakeTiledLayer> layer = 1365 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(
1362 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 1366 new FakeTiledLayer(layer_settings_, resource_manager_.get()));
1363 RenderSurfaceLayerList render_surface_layer_list; 1367 RenderSurfaceLayerList render_surface_layer_list;
1364 TestOcclusionTracker occluded; 1368 TestOcclusionTracker occluded;
1365 occlusion_ = &occluded; 1369 occlusion_ = &occluded;
1366 1370
1367 layer_tree_host_->root_layer()->AddChild(layer); 1371 layer_tree_host_->root_layer()->AddChild(layer);
1368 1372
1369 // The tile size is 100x100. 1373 // The tile size is 100x100.
1370 1374
1371 // This makes sure the painting works when the occluded region (in screen 1375 // This makes sure the painting works when the occluded region (in screen
1372 // space) is transformed differently than the layer. 1376 // space) is transformed differently than the layer.
(...skipping 13 matching lines...) Expand all
1386 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1390 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600));
1387 layer->SetTexturePriorities(priority_calculator_); 1391 layer->SetTexturePriorities(priority_calculator_);
1388 resource_manager_->PrioritizeTextures(); 1392 resource_manager_->PrioritizeTextures();
1389 layer->SavePaintProperties(); 1393 layer->SavePaintProperties();
1390 layer->Update(queue_.get(), &occluded); 1394 layer->Update(queue_.get(), &occluded);
1391 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); 1395 EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count());
1392 } 1396 }
1393 1397
1394 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { 1398 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) {
1395 scoped_refptr<FakeTiledLayer> layer = 1399 scoped_refptr<FakeTiledLayer> layer =
1396 new FakeTiledLayer(resource_manager_.get()); 1400 new FakeTiledLayer(layer_settings_, resource_manager_.get());
1397 RenderSurfaceLayerList render_surface_layer_list; 1401 RenderSurfaceLayerList render_surface_layer_list;
1398 TestOcclusionTracker occluded; 1402 TestOcclusionTracker occluded;
1399 occlusion_ = &occluded; 1403 occlusion_ = &occluded;
1400 1404
1401 scoped_refptr<FakeTiledLayer> scale_layer = 1405 scoped_refptr<FakeTiledLayer> scale_layer =
1402 new FakeTiledLayer(resource_manager_.get()); 1406 new FakeTiledLayer(layer_settings_, resource_manager_.get());
1403 gfx::Transform scale_transform; 1407 gfx::Transform scale_transform;
1404 scale_transform.Scale(2.0, 2.0); 1408 scale_transform.Scale(2.0, 2.0);
1405 scale_layer->SetTransform(scale_transform); 1409 scale_layer->SetTransform(scale_transform);
1406 1410
1407 layer_tree_host_->root_layer()->AddChild(scale_layer); 1411 layer_tree_host_->root_layer()->AddChild(scale_layer);
1408 1412
1409 // The tile size is 100x100. 1413 // The tile size is 100x100.
1410 1414
1411 // This makes sure the painting works when the content space is scaled to 1415 // This makes sure the painting works when the content space is scaled to
1412 // a different layer space. 1416 // a different layer space.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 int visible_tiles3 = 6 * 6 - 6; 1479 int visible_tiles3 = 6 * 6 - 6;
1476 EXPECT_EQ(visible_tiles3, layer->fake_layer_updater()->update_count()); 1480 EXPECT_EQ(visible_tiles3, layer->fake_layer_updater()->update_count());
1477 } 1481 }
1478 1482
1479 TEST_F(TiledLayerTest, DontAllocateContentsWhenTargetSurfaceCantBeAllocated) { 1483 TEST_F(TiledLayerTest, DontAllocateContentsWhenTargetSurfaceCantBeAllocated) {
1480 // Tile size is 100x100. 1484 // Tile size is 100x100.
1481 gfx::Rect root_rect(0, 0, 300, 200); 1485 gfx::Rect root_rect(0, 0, 300, 200);
1482 gfx::Rect child_rect(0, 0, 300, 100); 1486 gfx::Rect child_rect(0, 0, 300, 100);
1483 gfx::Rect child2_rect(0, 100, 300, 100); 1487 gfx::Rect child2_rect(0, 100, 300, 100);
1484 1488
1485 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr( 1489 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(
1486 new FakeTiledLayer(layer_tree_host_->contents_texture_manager())); 1490 layer_settings_, layer_tree_host_->contents_texture_manager()));
1487 scoped_refptr<Layer> surface = Layer::Create(); 1491 scoped_refptr<Layer> surface = Layer::Create(layer_settings_);
1488 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr( 1492 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer(
1489 new FakeTiledLayer(layer_tree_host_->contents_texture_manager())); 1493 layer_settings_, layer_tree_host_->contents_texture_manager()));
1490 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr( 1494 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer(
1491 new FakeTiledLayer(layer_tree_host_->contents_texture_manager())); 1495 layer_settings_, layer_tree_host_->contents_texture_manager()));
1492 1496
1493 root->SetBounds(root_rect.size()); 1497 root->SetBounds(root_rect.size());
1494 root->draw_properties().drawable_content_rect = root_rect; 1498 root->draw_properties().drawable_content_rect = root_rect;
1495 root->draw_properties().visible_content_rect = root_rect; 1499 root->draw_properties().visible_content_rect = root_rect;
1496 root->AddChild(surface); 1500 root->AddChild(surface);
1497 1501
1498 surface->SetForceRenderSurface(true); 1502 surface->SetForceRenderSurface(true);
1499 surface->SetOpacity(0.5); 1503 surface->SetOpacity(0.5);
1500 surface->AddChild(child); 1504 surface->AddChild(child);
1501 surface->AddChild(child2); 1505 surface->AddChild(child2);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 1653
1650 gfx::Rect PaintedRect() const { return painted_rect_; } 1654 gfx::Rect PaintedRect() const { return painted_rect_; }
1651 void ResetPaintedRect() { painted_rect_ = gfx::Rect(); } 1655 void ResetPaintedRect() { painted_rect_ = gfx::Rect(); }
1652 1656
1653 private: 1657 private:
1654 gfx::Rect painted_rect_; 1658 gfx::Rect painted_rect_;
1655 }; 1659 };
1656 1660
1657 class UpdateTrackingTiledLayer : public FakeTiledLayer { 1661 class UpdateTrackingTiledLayer : public FakeTiledLayer {
1658 public: 1662 public:
1659 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) 1663 explicit UpdateTrackingTiledLayer(const LayerSettings& settings,
1660 : FakeTiledLayer(manager) { 1664 PrioritizedResourceManager* manager)
1665 : FakeTiledLayer(settings, manager) {
1661 scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create()); 1666 scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create());
1662 tracking_layer_painter_ = painter.get(); 1667 tracking_layer_painter_ = painter.get();
1663 layer_updater_ = BitmapContentLayerUpdater::Create(painter.Pass(), 0); 1668 layer_updater_ = BitmapContentLayerUpdater::Create(painter.Pass(), 0);
1664 } 1669 }
1665 1670
1666 TrackingLayerPainter* tracking_layer_painter() const { 1671 TrackingLayerPainter* tracking_layer_painter() const {
1667 return tracking_layer_painter_; 1672 return tracking_layer_painter_;
1668 } 1673 }
1669 1674
1670 private: 1675 private:
1671 LayerUpdater* Updater() const override { return layer_updater_.get(); } 1676 LayerUpdater* Updater() const override { return layer_updater_.get(); }
1672 ~UpdateTrackingTiledLayer() override {} 1677 ~UpdateTrackingTiledLayer() override {}
1673 1678
1674 TrackingLayerPainter* tracking_layer_painter_; 1679 TrackingLayerPainter* tracking_layer_painter_;
1675 scoped_refptr<BitmapContentLayerUpdater> layer_updater_; 1680 scoped_refptr<BitmapContentLayerUpdater> layer_updater_;
1676 }; 1681 };
1677 1682
1678 TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { 1683 TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) {
1679 scoped_refptr<UpdateTrackingTiledLayer> layer = 1684 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(
1680 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); 1685 new UpdateTrackingTiledLayer(layer_settings_, resource_manager_.get()));
1681 1686
1682 layer_tree_host_->root_layer()->AddChild(layer); 1687 layer_tree_host_->root_layer()->AddChild(layer);
1683 1688
1684 gfx::Rect layer_rect(0, 0, 30, 31); 1689 gfx::Rect layer_rect(0, 0, 30, 31);
1685 layer->SetPosition(layer_rect.origin()); 1690 layer->SetPosition(layer_rect.origin());
1686 layer->SetBounds(layer_rect.size()); 1691 layer->SetBounds(layer_rect.size());
1687 layer->UpdateContentsScale(1.5f); 1692 layer->UpdateContentsScale(1.5f);
1688 1693
1689 gfx::Rect content_rect(0, 0, 45, 47); 1694 gfx::Rect content_rect(0, 0, 45, 47);
1690 EXPECT_EQ(content_rect.size(), layer->content_bounds()); 1695 EXPECT_EQ(content_rect.size(), layer->content_bounds());
(...skipping 18 matching lines...) Expand all
1709 1714
1710 // Rounding leads to an extra pixel. 1715 // Rounding leads to an extra pixel.
1711 gfx::Rect expanded_layer_rect(layer_rect); 1716 gfx::Rect expanded_layer_rect(layer_rect);
1712 expanded_layer_rect.set_height(32); 1717 expanded_layer_rect.set_height(32);
1713 EXPECT_EQ(expanded_layer_rect, 1718 EXPECT_EQ(expanded_layer_rect,
1714 layer->tracking_layer_painter()->PaintedRect()); 1719 layer->tracking_layer_painter()->PaintedRect());
1715 } 1720 }
1716 1721
1717 TEST_F(TiledLayerTest, 1722 TEST_F(TiledLayerTest,
1718 NonIntegerContentsScaleIsNotDistortedDuringInvalidation) { 1723 NonIntegerContentsScaleIsNotDistortedDuringInvalidation) {
1719 scoped_refptr<UpdateTrackingTiledLayer> layer = 1724 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(
1720 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); 1725 new UpdateTrackingTiledLayer(layer_settings_, resource_manager_.get()));
1721 1726
1722 layer_tree_host_->root_layer()->AddChild(layer); 1727 layer_tree_host_->root_layer()->AddChild(layer);
1723 1728
1724 gfx::Rect layer_rect(0, 0, 30, 31); 1729 gfx::Rect layer_rect(0, 0, 30, 31);
1725 layer->SetPosition(layer_rect.origin()); 1730 layer->SetPosition(layer_rect.origin());
1726 layer->SetBounds(layer_rect.size()); 1731 layer->SetBounds(layer_rect.size());
1727 layer->UpdateContentsScale(1.3f); 1732 layer->UpdateContentsScale(1.3f);
1728 1733
1729 gfx::Rect content_rect(layer->content_bounds()); 1734 gfx::Rect content_rect(layer->content_bounds());
1730 layer->draw_properties().visible_content_rect = content_rect; 1735 layer->draw_properties().visible_content_rect = content_rect;
(...skipping 17 matching lines...) Expand all
1748 1753
1749 // Rounding leads to an extra pixel. 1754 // Rounding leads to an extra pixel.
1750 gfx::Rect expanded_layer_rect(layer_rect); 1755 gfx::Rect expanded_layer_rect(layer_rect);
1751 expanded_layer_rect.set_height(32); 1756 expanded_layer_rect.set_height(32);
1752 EXPECT_EQ(expanded_layer_rect, 1757 EXPECT_EQ(expanded_layer_rect,
1753 layer->tracking_layer_painter()->PaintedRect()); 1758 layer->tracking_layer_painter()->PaintedRect());
1754 } 1759 }
1755 1760
1756 } // namespace 1761 } // namespace
1757 } // namespace cc 1762 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698