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

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

Issue 260963008: Fixing crash in PictureLayerImpl::MarkVisibleResourcesAsRequired when low-res tiles are disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing conditions Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 impl.quad_list(), 2272 impl.quad_list(),
2273 gfx::Rect(layer_bounds), 2273 gfx::Rect(layer_bounds),
2274 occluded, 2274 occluded,
2275 &partially_occluded_count); 2275 &partially_occluded_count);
2276 // The layer outputs one quad, which is partially occluded. 2276 // The layer outputs one quad, which is partially occluded.
2277 EXPECT_EQ(100u - 10u, impl.quad_list().size()); 2277 EXPECT_EQ(100u - 10u, impl.quad_list().size());
2278 EXPECT_EQ(10u + 10u, partially_occluded_count); 2278 EXPECT_EQ(10u + 10u, partially_occluded_count);
2279 } 2279 }
2280 } 2280 }
2281 2281
2282 class NoLowResTilingsSettings : public ImplSidePaintingSettings {
2283 public:
2284 NoLowResTilingsSettings() { create_low_res_tiling = false; }
2285 };
2286
2287 class NoLowResPictureLayerImplTest : public PictureLayerImplTest {
2288 public:
2289 NoLowResPictureLayerImplTest()
2290 : PictureLayerImplTest(NoLowResTilingsSettings()) {}
2291 };
2292
2293 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) {
2294 gfx::Size tile_size(400, 400);
2295 gfx::Size layer_bounds(1300, 1900);
2296
2297 scoped_refptr<FakePicturePileImpl> pending_pile =
2298 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2299 scoped_refptr<FakePicturePileImpl> active_pile =
2300 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2301
2302 float result_scale_x, result_scale_y;
2303 gfx::Size result_bounds;
2304
2305 SetupTrees(pending_pile, active_pile);
2306 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
2307
2308 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
2309 EXPECT_LT(low_res_factor, 1.f);
2310
2311 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale
2312 1.7f, // device scale
2313 3.2f, // page scale
2314 1.f, // maximum animation scale
2315 false,
2316 &result_scale_x,
2317 &result_scale_y,
2318 &result_bounds);
2319 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
2320 EXPECT_FLOAT_EQ(1.3f,
2321 pending_layer_->tilings()->tiling_at(0)->contents_scale());
2322
2323 // If we change the layer's CSS scale factor, then we should not get new
2324 // tilings.
2325 pending_layer_->CalculateContentsScale(1.8f, // ideal contents scale
2326 1.7f, // device scale
2327 3.2f, // page scale
2328 1.f, // maximum animation scale
2329 false,
2330 &result_scale_x,
2331 &result_scale_y,
2332 &result_bounds);
2333 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
2334 EXPECT_FLOAT_EQ(1.3f,
2335 pending_layer_->tilings()->tiling_at(0)->contents_scale());
2336
2337 // If we change the page scale factor, then we should get new tilings.
2338 pending_layer_->CalculateContentsScale(1.8f, // ideal contents scale
2339 1.7f, // device scale
2340 2.2f, // page scale
2341 1.f, // maximum animation scale
2342 false,
2343 &result_scale_x,
2344 &result_scale_y,
2345 &result_bounds);
2346 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
2347 EXPECT_FLOAT_EQ(1.8f,
2348 pending_layer_->tilings()->tiling_at(0)->contents_scale());
2349
2350 // If we change the device scale factor, then we should get new tilings.
2351 pending_layer_->CalculateContentsScale(1.9f, // ideal contents scale
2352 1.4f, // device scale
2353 2.2f, // page scale
2354 1.f, // maximum animation scale
2355 false,
2356 &result_scale_x,
2357 &result_scale_y,
2358 &result_bounds);
2359 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings());
2360 EXPECT_FLOAT_EQ(1.9f,
2361 pending_layer_->tilings()->tiling_at(0)->contents_scale());
2362
2363 // If we change the device scale factor, but end up at the same total scale
2364 // factor somehow, then we don't get new tilings.
2365 pending_layer_->CalculateContentsScale(1.9f, // ideal contents scale
2366 2.2f, // device scale
2367 1.4f, // page scale
2368 1.f, // maximum animation scale
2369 false,
2370 &result_scale_x,
2371 &result_scale_y,
2372 &result_bounds);
2373 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings());
2374 EXPECT_FLOAT_EQ(1.9f,
2375 pending_layer_->tilings()->tiling_at(0)->contents_scale());
2376 }
2377
2378 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredNullTiles) {
2379 gfx::Size tile_size(100, 100);
2380 gfx::Size layer_bounds(1000, 1000);
2381
2382 scoped_refptr<FakePicturePileImpl> pending_pile =
2383 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
2384 // Layers with entirely empty piles can't get tilings.
2385 pending_pile->AddRecordingAt(0, 0);
2386
2387 SetupPendingTree(pending_pile);
2388
2389 ASSERT_TRUE(pending_layer_->CanHaveTilings());
2390 pending_layer_->AddTiling(1.0f);
2391 pending_layer_->AddTiling(2.0f);
2392
2393 // It should be safe to call this (and MarkVisibleResourcesAsRequired)
2394 // on a layer with no recordings.
2395 host_impl_.pending_tree()->UpdateDrawProperties();
2396 pending_layer_->MarkVisibleResourcesAsRequired();
2397 }
2398
2399 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) {
2400 gfx::Size layer_bounds(400, 400);
2401 gfx::Size tile_size(100, 100);
2402 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
2403
2404 CreateHighLowResAndSetAllTilesVisible();
2405
2406 Tile* some_active_tile =
2407 active_layer_->HighResTiling()->AllTilesForTesting()[0];
2408 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
2409
2410 // All tiles shared (no invalidation), so even though the active tree's
2411 // tiles aren't ready, there is nothing required.
2412 pending_layer_->MarkVisibleResourcesAsRequired();
2413 AssertNoTilesRequired(pending_layer_->HighResTiling());
2414 if (host_impl_.settings().create_low_res_tiling) {
2415 AssertNoTilesRequired(pending_layer_->LowResTiling());
2416 }
2417 }
2418
2419 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
2420 gfx::Size layer_bounds(400, 400);
2421 gfx::Size tile_size(100, 100);
2422 scoped_refptr<FakePicturePileImpl> pending_pile =
2423 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2424 // This pile will create tilings, but has no recordings so will not create any
2425 // tiles. This is attempting to simulate scrolling past the end of recorded
2426 // content on the active layer, where the recordings are so far away that
2427 // no tiles are created.
2428 scoped_refptr<FakePicturePileImpl> active_pile =
2429 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
2430 tile_size, layer_bounds);
2431 SetupTrees(pending_pile, active_pile);
2432 pending_layer_->set_fixed_tile_size(tile_size);
2433 active_layer_->set_fixed_tile_size(tile_size);
2434
2435 CreateHighLowResAndSetAllTilesVisible();
2436
2437 // Active layer has tilings, but no tiles due to missing recordings.
2438 EXPECT_TRUE(active_layer_->CanHaveTilings());
2439 EXPECT_EQ(active_layer_->tilings()->num_tilings(),
2440 host_impl_.settings().create_low_res_tiling ? 2u : 1u);
2441 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
2442
2443 // Since the active layer has no tiles at all, the pending layer doesn't
2444 // need content in order to activate.
2445 pending_layer_->MarkVisibleResourcesAsRequired();
2446 AssertNoTilesRequired(pending_layer_->HighResTiling());
2447 if (host_impl_.settings().create_low_res_tiling)
2448 AssertNoTilesRequired(pending_layer_->LowResTiling());
2449 }
2450
2451 TEST_F(NoLowResPictureLayerImplTest, TileManagerRegisterUnregister) {
2452 gfx::Size tile_size(100, 100);
2453 gfx::Size layer_bounds(400, 400);
2454
2455 scoped_refptr<FakePicturePileImpl> pending_pile =
2456 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2457 scoped_refptr<FakePicturePileImpl> active_pile =
2458 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2459
2460 SetupTrees(pending_pile, active_pile);
2461
2462 std::vector<TileManager::PairedPictureLayer> paired_layers;
2463 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers);
2464 EXPECT_EQ(0u, paired_layers.size());
2465
2466 // Update tile priorities will force the layer to register itself.
2467 float dummy_contents_scale_x;
2468 float dummy_contents_scale_y;
2469 gfx::Size dummy_content_bounds;
2470 active_layer_->CalculateContentsScale(1.f,
2471 1.f,
2472 1.f,
2473 1.f,
2474 false,
2475 &dummy_contents_scale_x,
2476 &dummy_contents_scale_y,
2477 &dummy_content_bounds);
2478 active_layer_->UpdateTilePriorities();
2479 host_impl_.pending_tree()->UpdateDrawProperties();
2480 pending_layer_->CalculateContentsScale(1.f,
2481 1.f,
2482 1.f,
2483 1.f,
2484 false,
2485 &dummy_contents_scale_x,
2486 &dummy_contents_scale_y,
2487 &dummy_content_bounds);
2488 pending_layer_->UpdateTilePriorities();
2489
2490 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers);
2491 EXPECT_EQ(1u, paired_layers.size());
2492 EXPECT_EQ(active_layer_, paired_layers[0].active_layer);
2493 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer);
2494
2495 // Destroy and recreate tile manager.
2496 host_impl_.DidLoseOutputSurface();
2497 scoped_ptr<TestWebGraphicsContext3D> context =
2498 TestWebGraphicsContext3D::Create();
2499 host_impl_.InitializeRenderer(
2500 FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>());
2501
2502 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers);
2503 EXPECT_EQ(0u, paired_layers.size());
2504
2505 active_layer_->CalculateContentsScale(1.f,
2506 1.f,
2507 1.f,
2508 1.f,
2509 false,
2510 &dummy_contents_scale_x,
2511 &dummy_contents_scale_y,
2512 &dummy_content_bounds);
2513 active_layer_->UpdateTilePriorities();
2514 host_impl_.pending_tree()->UpdateDrawProperties();
2515 pending_layer_->CalculateContentsScale(1.f,
2516 1.f,
2517 1.f,
2518 1.f,
2519 false,
2520 &dummy_contents_scale_x,
2521 &dummy_contents_scale_y,
2522 &dummy_content_bounds);
2523 pending_layer_->UpdateTilePriorities();
2524
2525 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers);
2526 EXPECT_EQ(1u, paired_layers.size());
2527 EXPECT_EQ(active_layer_, paired_layers[0].active_layer);
2528 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer);
2529 }
2530
2531 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
2532 base::TimeTicks time_ticks;
2533 host_impl_.SetCurrentFrameTimeTicks(time_ticks);
2534
2535 gfx::Size tile_size(100, 100);
2536 gfx::Size layer_bounds(400, 400);
2537
2538 scoped_refptr<FakePicturePileImpl> pending_pile =
2539 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2540 scoped_refptr<FakePicturePileImpl> active_pile =
2541 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2542
2543 SetupTrees(pending_pile, active_pile);
2544
2545 Region invalidation;
2546 AddDefaultTilingsWithInvalidation(invalidation);
2547 float dummy_contents_scale_x;
2548 float dummy_contents_scale_y;
2549 gfx::Size dummy_content_bounds;
2550 active_layer_->CalculateContentsScale(1.f,
2551 1.f,
2552 1.f,
2553 1.f,
2554 false,
2555 &dummy_contents_scale_x,
2556 &dummy_contents_scale_y,
2557 &dummy_content_bounds);
2558
2559 // UpdateTilePriorities with valid viewport. Should update tile viewport.
2560 bool valid_for_tile_management = true;
2561 gfx::Rect viewport = gfx::Rect(layer_bounds);
2562 gfx::Transform transform;
2563 host_impl_.SetExternalDrawConstraints(
2564 transform, viewport, viewport, valid_for_tile_management);
2565 active_layer_->draw_properties().visible_content_rect = viewport;
2566 active_layer_->draw_properties().screen_space_transform = transform;
2567 active_layer_->UpdateTilePriorities();
2568
2569 gfx::Rect visible_rect_for_tile_priority =
2570 active_layer_->visible_rect_for_tile_priority();
2571 EXPECT_FALSE(visible_rect_for_tile_priority.IsEmpty());
2572 gfx::Size viewport_size_for_tile_priority =
2573 active_layer_->viewport_size_for_tile_priority();
2574 EXPECT_FALSE(viewport_size_for_tile_priority.IsEmpty());
2575 gfx::Transform screen_space_transform_for_tile_priority =
2576 active_layer_->screen_space_transform_for_tile_priority();
2577
2578 // Expand viewport and set it as invalid for prioritizing tiles.
2579 // Should not update tile viewport.
2580 time_ticks += base::TimeDelta::FromMilliseconds(200);
2581 host_impl_.SetCurrentFrameTimeTicks(time_ticks);
2582 valid_for_tile_management = false;
2583 viewport = gfx::ScaleToEnclosingRect(viewport, 2);
2584 transform.Translate(1.f, 1.f);
2585 active_layer_->draw_properties().visible_content_rect = viewport;
2586 active_layer_->draw_properties().screen_space_transform = transform;
2587 host_impl_.SetExternalDrawConstraints(
2588 transform, viewport, viewport, valid_for_tile_management);
2589 active_layer_->UpdateTilePriorities();
2590
2591 EXPECT_RECT_EQ(visible_rect_for_tile_priority,
2592 active_layer_->visible_rect_for_tile_priority());
2593 EXPECT_SIZE_EQ(viewport_size_for_tile_priority,
2594 active_layer_->viewport_size_for_tile_priority());
2595 EXPECT_TRANSFORMATION_MATRIX_EQ(
2596 screen_space_transform_for_tile_priority,
2597 active_layer_->screen_space_transform_for_tile_priority());
2598
2599 // Keep expanded viewport but mark it valid. Should update tile viewport.
2600 time_ticks += base::TimeDelta::FromMilliseconds(200);
2601 host_impl_.SetCurrentFrameTimeTicks(time_ticks);
2602 valid_for_tile_management = true;
2603 host_impl_.SetExternalDrawConstraints(
2604 transform, viewport, viewport, valid_for_tile_management);
2605 active_layer_->UpdateTilePriorities();
2606
2607 EXPECT_FALSE(visible_rect_for_tile_priority ==
2608 active_layer_->visible_rect_for_tile_priority());
2609 EXPECT_FALSE(viewport_size_for_tile_priority ==
2610 active_layer_->viewport_size_for_tile_priority());
2611 EXPECT_FALSE(screen_space_transform_for_tile_priority ==
2612 active_layer_->screen_space_transform_for_tile_priority());
2613 }
2614
2615 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportAfterReleaseResources) {
2616 base::TimeTicks time_ticks;
2617 host_impl_.SetCurrentFrameTimeTicks(time_ticks);
2618
2619 gfx::Size tile_size(100, 100);
2620 gfx::Size layer_bounds(400, 400);
2621
2622 scoped_refptr<FakePicturePileImpl> pending_pile =
2623 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2624 scoped_refptr<FakePicturePileImpl> active_pile =
2625 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2626
2627 SetupTrees(pending_pile, active_pile);
2628
2629 Region invalidation;
2630 AddDefaultTilingsWithInvalidation(invalidation);
2631
2632 bool valid_for_tile_management = false;
2633 gfx::Rect viewport = gfx::Rect(layer_bounds);
2634 host_impl_.SetExternalDrawConstraints(
2635 gfx::Transform(), viewport, viewport, valid_for_tile_management);
2636 ResetTilingsAndRasterScales();
2637 host_impl_.pending_tree()->UpdateDrawProperties();
2638 host_impl_.active_tree()->UpdateDrawProperties();
2639 EXPECT_TRUE(active_layer_->HighResTiling());
2640
2641 size_t num_tilings = active_layer_->num_tilings();
2642 active_layer_->UpdateTilePriorities();
2643 pending_layer_->AddTiling(0.5f);
2644 EXPECT_EQ(num_tilings + 1, active_layer_->num_tilings());
2645 }
2646
2647 TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) {
2648 gfx::Size tile_size(400, 400);
2649 gfx::Size layer_bounds(1300, 1900);
2650
2651 scoped_refptr<FakePicturePileImpl> pending_pile =
2652 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2653 scoped_refptr<FakePicturePileImpl> active_pile =
2654 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2655
2656 float result_scale_x, result_scale_y;
2657 gfx::Size result_bounds;
2658 std::vector<PictureLayerTiling*> used_tilings;
2659
2660 SetupTrees(pending_pile, active_pile);
2661 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
2662
2663 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
2664 EXPECT_LT(low_res_factor, 1.f);
2665
2666 float device_scale = 1.7f;
2667 float page_scale = 3.2f;
2668
2669 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false);
2670 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings());
2671
2672 // We only have ideal tilings, so they aren't removed.
2673 used_tilings.clear();
2674 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2675 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings());
2676
2677 // Changing the ideal but not creating new tilings.
2678 SetContentsScaleOnBothLayers(1.5f, device_scale, page_scale, 1.f, false);
2679 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings());
2680
2681 // The tilings are still our target scale, so they aren't removed.
2682 used_tilings.clear();
2683 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2684 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings());
2685
2686 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2.
2687 page_scale = 1.2f;
2688 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, false);
2689 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
2690 EXPECT_FLOAT_EQ(1.f,
2691 active_layer_->tilings()->tiling_at(1)->contents_scale());
2692
2693 // Mark the non-ideal tilings as used. They won't be removed.
2694 used_tilings.clear();
2695 used_tilings.push_back(active_layer_->tilings()->tiling_at(1));
2696 used_tilings.push_back(active_layer_->tilings()->tiling_at(3));
2697 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2698 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
2699
2700 // Now move the ideal scale to 0.5. Our target stays 1.2.
2701 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, false);
2702
2703 // The high resolution tiling is between target and ideal, so is not
2704 // removed. The low res tiling for the old ideal=1.0 scale is removed.
2705 used_tilings.clear();
2706 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2707 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
2708
2709 // Now move the ideal scale to 1.0. Our target stays 1.2.
2710 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false);
2711
2712 // All the tilings are between are target and the ideal, so they are not
2713 // removed.
2714 used_tilings.clear();
2715 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2716 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
2717
2718 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2.
2719 active_layer_->CalculateContentsScale(1.1f,
2720 device_scale,
2721 page_scale,
2722 1.f,
2723 false,
2724 &result_scale_x,
2725 &result_scale_y,
2726 &result_bounds);
2727
2728 // Because the pending layer's ideal scale is still 1.0, our tilings fall
2729 // in the range [1.0,1.2] and are kept.
2730 used_tilings.clear();
2731 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2732 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
2733
2734 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays
2735 // 1.2 still.
2736 pending_layer_->CalculateContentsScale(1.1f,
2737 device_scale,
2738 page_scale,
2739 1.f,
2740 false,
2741 &result_scale_x,
2742 &result_scale_y,
2743 &result_bounds);
2744
2745 // Our 1.0 tiling now falls outside the range between our ideal scale and our
2746 // target raster scale. But it is in our used tilings set, so nothing is
2747 // deleted.
2748 used_tilings.clear();
2749 used_tilings.push_back(active_layer_->tilings()->tiling_at(1));
2750 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2751 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
2752
2753 // If we remove it from our used tilings set, it is outside the range to keep
2754 // so it is deleted.
2755 used_tilings.clear();
2756 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2757 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings());
2758 }
2759
2760 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) {
2761 gfx::Size tile_size(400, 400);
2762 gfx::Size layer_bounds(1300, 1900);
2763
2764 scoped_refptr<FakePicturePileImpl> pending_pile =
2765 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2766 scoped_refptr<FakePicturePileImpl> active_pile =
2767 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2768
2769 float result_scale_x, result_scale_y;
2770 gfx::Size result_bounds;
2771
2772 SetupTrees(pending_pile, active_pile);
2773 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
2774
2775 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale
2776 2.7f, // device scale
2777 3.2f, // page scale
2778 1.f, // maximum animation scale
2779 false,
2780 &result_scale_x,
2781 &result_scale_y,
2782 &result_bounds);
2783 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
2784
2785 // All tilings should be removed when losing output surface.
2786 active_layer_->ReleaseResources();
2787 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
2788 pending_layer_->ReleaseResources();
2789 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
2790
2791 // This should create new tilings.
2792 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale
2793 2.7f, // device scale
2794 3.2f, // page scale
2795 1.f, // maximum animation scale
2796 false,
2797 &result_scale_x,
2798 &result_scale_y,
2799 &result_bounds);
2800 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
2801 }
2802
2282 } // namespace 2803 } // namespace
2283 } // namespace cc 2804 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698