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

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

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

Powered by Google App Engine
This is Rietveld 408576698