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

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

Issue 2289123005: Don't adjust raster scale differently for SW/GPU during Animation (Closed)
Patch Set: unit test Created 4 years, 3 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') | no next file » | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 2568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 // Bounds at starting scale outisde the viewport 2579 // Bounds at starting scale outisde the viewport
2580 animating_transform = true; 2580 animating_transform = true;
2581 starting_animation_scale = 11.f; 2581 starting_animation_scale = 11.f;
2582 2582
2583 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, 2583 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale,
2584 maximum_animation_scale, 2584 maximum_animation_scale,
2585 starting_animation_scale, animating_transform); 2585 starting_animation_scale, animating_transform);
2586 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); 2586 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f);
2587 } 2587 }
2588 2588
2589 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { 2589 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimation) {
2590 gfx::Size viewport_size(1000, 1000); 2590 gfx::Size viewport_size(1000, 1000);
2591 host_impl()->SetViewportSize(viewport_size); 2591 host_impl()->SetViewportSize(viewport_size);
2592 2592
2593 gfx::Size layer_bounds(100, 100); 2593 gfx::Size layer_bounds(100, 100);
2594 SetupDefaultTrees(layer_bounds); 2594 SetupDefaultTrees(layer_bounds);
2595 2595
2596 float contents_scale = 1.f; 2596 float contents_scale = 1.f;
2597 float device_scale = 1.f; 2597 float device_scale = 1.f;
2598 float page_scale = 1.f; 2598 float page_scale = 1.f;
2599 float maximum_animation_scale = 1.f; 2599 float maximum_animation_scale = 1.f;
2600 float starting_animation_scale = 0.f; 2600 float starting_animation_scale = 0.f;
2601 bool animating_transform = false; 2601 bool animating_transform = false;
2602 2602
2603 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); 2603 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f);
2604 2604
2605 // Since we're CPU-rasterizing, starting an animation should cause tiling 2605 // Starting an animation should cause tiling resolution to get set to the
2606 // resolution to get set to the maximum animation scale factor. 2606 // maximum animation scale factor.
2607 animating_transform = true; 2607 animating_transform = true;
2608 maximum_animation_scale = 3.f; 2608 maximum_animation_scale = 3.f;
2609 contents_scale = 2.f; 2609 contents_scale = 2.f;
2610 2610
2611 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, 2611 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale,
2612 maximum_animation_scale, 2612 maximum_animation_scale,
2613 starting_animation_scale, animating_transform); 2613 starting_animation_scale, animating_transform);
2614 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); 2614 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f);
2615 EXPECT_BOTH_TRUE(GetRasterSource()->ShouldAttemptToUseDistanceFieldText()); 2615 EXPECT_BOTH_TRUE(GetRasterSource()->ShouldAttemptToUseDistanceFieldText());
2616 2616
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 // Once we stop animating, a new high-res tiling should be created. 2720 // Once we stop animating, a new high-res tiling should be created.
2721 animating_transform = false; 2721 animating_transform = false;
2722 contents_scale = 11.f; 2722 contents_scale = 11.f;
2723 2723
2724 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, 2724 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale,
2725 maximum_animation_scale, 2725 maximum_animation_scale,
2726 starting_animation_scale, animating_transform); 2726 starting_animation_scale, animating_transform);
2727 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); 2727 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f);
2728 } 2728 }
2729 2729
2730 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForGpuRasterization) {
2731 gfx::Size layer_bounds(100, 100);
2732 gfx::Size viewport_size(1000, 1000);
2733 SetupDefaultTrees(layer_bounds);
2734 host_impl()->SetViewportSize(viewport_size);
2735 host_impl()->SetHasGpuRasterizationTrigger(true);
2736 host_impl()->SetContentIsSuitableForGpuRasterization(true);
2737 host_impl()->CommitComplete();
2738
2739 float contents_scale = 1.f;
2740 float device_scale = 1.3f;
2741 float page_scale = 1.4f;
2742 float maximum_animation_scale = 1.f;
2743 float starting_animation_scale = 0.f;
2744 bool animating_transform = false;
2745
2746 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale,
2747 maximum_animation_scale,
2748 starting_animation_scale, animating_transform);
2749 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f);
2750 EXPECT_BOTH_FALSE(GetRasterSource()->ShouldAttemptToUseDistanceFieldText());
2751
2752 // Since we're GPU-rasterizing, starting an animation should cause tiling
2753 // resolution to get set to the current contents scale.
2754 animating_transform = true;
2755 contents_scale = 2.f;
2756 maximum_animation_scale = 4.f;
2757
2758 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale,
2759 maximum_animation_scale,
2760 starting_animation_scale, animating_transform);
2761 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f);
2762 EXPECT_BOTH_TRUE(GetRasterSource()->ShouldAttemptToUseDistanceFieldText());
2763
2764 // Further changes to scale during the animation should cause a new high-res
2765 // tiling to get created.
2766 contents_scale = 3.f;
2767
2768 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale,
2769 maximum_animation_scale,
2770 starting_animation_scale, animating_transform);
2771 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f);
2772
2773 // Since we're re-rasterizing during the animation, scales smaller than 1
2774 // should be respected.
2775 contents_scale = 0.25f;
2776
2777 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale,
2778 maximum_animation_scale,
2779 starting_animation_scale, animating_transform);
2780 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.25f);
2781
2782 // Once we stop animating, a new high-res tiling should be created.
2783 contents_scale = 4.f;
2784 animating_transform = false;
2785
2786 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale,
2787 maximum_animation_scale,
2788 starting_animation_scale, animating_transform);
2789 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f);
2790 }
2791
2792 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { 2730 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) {
2793 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 2731 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2794 2732
2795 host_impl()->SetViewportSize(gfx::Size(500, 500)); 2733 host_impl()->SetViewportSize(gfx::Size(500, 500));
2796 2734
2797 gfx::Size layer_bounds(1000, 1000); 2735 gfx::Size layer_bounds(1000, 1000);
2798 2736
2799 scoped_refptr<FakeRasterSource> pending_raster_source = 2737 scoped_refptr<FakeRasterSource> pending_raster_source =
2800 FakeRasterSource::CreateFilled(layer_bounds); 2738 FakeRasterSource::CreateFilled(layer_bounds);
2801 2739
(...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after
5022 EXPECT_FLOAT_EQ(expected_contents_scale, 4960 EXPECT_FLOAT_EQ(expected_contents_scale,
5023 pending_layer_ptr->picture_layer_tiling_set() 4961 pending_layer_ptr->picture_layer_tiling_set()
5024 ->FindTilingWithResolution(HIGH_RESOLUTION) 4962 ->FindTilingWithResolution(HIGH_RESOLUTION)
5025 ->contents_scale()) 4963 ->contents_scale())
5026 << "ideal_contents_scale: " << ideal_contents_scale; 4964 << "ideal_contents_scale: " << ideal_contents_scale;
5027 } 4965 }
5028 } 4966 }
5029 4967
5030 } // namespace 4968 } // namespace
5031 } // namespace cc 4969 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698