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

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

Powered by Google App Engine
This is Rietveld 408576698