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

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

Issue 226283004: Rasterize at maximum scale for scale animations on CPU-rasterized layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/picture_image_layer_impl.cc ('k') | cc/layers/picture_layer_impl.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 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_image_layer_impl.h" 5 #include "cc/layers/picture_image_layer_impl.h"
6 6
7 #include "cc/layers/append_quads_data.h" 7 #include "cc/layers/append_quads_data.h"
8 #include "cc/resources/tile_priority.h" 8 #include "cc/resources/tile_priority.h"
9 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 FakePictureLayerTilingClient tiling_client_; 77 FakePictureLayerTilingClient tiling_client_;
78 }; 78 };
79 79
80 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { 80 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) {
81 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); 81 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE));
82 layer->SetDrawsContent(true); 82 layer->SetDrawsContent(true);
83 83
84 float contents_scale_x; 84 float contents_scale_x;
85 float contents_scale_y; 85 float contents_scale_y;
86 gfx::Size content_bounds; 86 gfx::Size content_bounds;
87 layer->CalculateContentsScale(2.f, 3.f, 4.f, false, 87 layer->CalculateContentsScale(2.f,
88 &contents_scale_x, &contents_scale_y, 88 3.f,
89 4.f,
90 1.f,
91 false,
92 &contents_scale_x,
93 &contents_scale_y,
89 &content_bounds); 94 &content_bounds);
90 EXPECT_FLOAT_EQ(1.f, contents_scale_x); 95 EXPECT_FLOAT_EQ(1.f, contents_scale_x);
91 EXPECT_FLOAT_EQ(1.f, contents_scale_y); 96 EXPECT_FLOAT_EQ(1.f, contents_scale_y);
92 EXPECT_EQ(layer->bounds(), content_bounds); 97 EXPECT_EQ(layer->bounds(), content_bounds);
93 } 98 }
94 99
95 TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) { 100 TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) {
96 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); 101 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE));
97 layer->SetBounds(gfx::Size(100, 200)); 102 layer->SetBounds(gfx::Size(100, 200));
98 layer->SetDrawsContent(true); 103 layer->SetDrawsContent(true);
99 104
100 UpdateDrawProperties(); 105 UpdateDrawProperties();
101 106
102 float contents_scale_x; 107 float contents_scale_x;
103 float contents_scale_y; 108 float contents_scale_y;
104 gfx::Size content_bounds; 109 gfx::Size content_bounds;
105 layer->CalculateContentsScale(2.f, 3.f, 4.f, false, 110 layer->CalculateContentsScale(2.f,
106 &contents_scale_x, &contents_scale_y, 111 3.f,
112 4.f,
113 1.f,
114 false,
115 &contents_scale_x,
116 &contents_scale_y,
107 &content_bounds); 117 &content_bounds);
108 layer->UpdateTilePriorities(); 118 layer->UpdateTilePriorities();
109 119
110 EXPECT_TRUE(layer->AreVisibleResourcesReady()); 120 EXPECT_TRUE(layer->AreVisibleResourcesReady());
111 } 121 }
112 122
113 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { 123 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) {
114 scoped_ptr<TestablePictureImageLayerImpl> pending_layer( 124 scoped_ptr<TestablePictureImageLayerImpl> pending_layer(
115 CreateLayer(1, PENDING_TREE)); 125 CreateLayer(1, PENDING_TREE));
116 pending_layer->SetDrawsContent(true); 126 pending_layer->SetDrawsContent(true);
117 127
118 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal 128 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal
119 // to the content scale used by PictureImageLayerImpl. 129 // to the content scale used by PictureImageLayerImpl.
120 const float suggested_ideal_contents_scale = 2.f; 130 const float suggested_ideal_contents_scale = 2.f;
121 const float device_scale_factor = 3.f; 131 const float device_scale_factor = 3.f;
122 const float page_scale_factor = 4.f; 132 const float page_scale_factor = 4.f;
133 const float maximum_animation_contents_scale = 1.f;
123 const bool animating_transform_to_screen = false; 134 const bool animating_transform_to_screen = false;
124 float contents_scale_x; 135 float contents_scale_x;
125 float contents_scale_y; 136 float contents_scale_y;
126 gfx::Size content_bounds; 137 gfx::Size content_bounds;
127 pending_layer->CalculateContentsScale(suggested_ideal_contents_scale, 138 pending_layer->CalculateContentsScale(suggested_ideal_contents_scale,
128 device_scale_factor, 139 device_scale_factor,
129 page_scale_factor, 140 page_scale_factor,
141 maximum_animation_contents_scale,
130 animating_transform_to_screen, 142 animating_transform_to_screen,
131 &contents_scale_x, 143 &contents_scale_x,
132 &contents_scale_y, 144 &contents_scale_y,
133 &content_bounds); 145 &content_bounds);
134 146
135 // Push to active layer. 147 // Push to active layer.
136 host_impl_.ActivatePendingTree(); 148 host_impl_.ActivatePendingTree();
137 scoped_ptr<TestablePictureImageLayerImpl> active_layer( 149 scoped_ptr<TestablePictureImageLayerImpl> active_layer(
138 CreateLayer(1, ACTIVE_TREE)); 150 CreateLayer(1, ACTIVE_TREE));
139 pending_layer->PushPropertiesTo(active_layer.get()); 151 pending_layer->PushPropertiesTo(active_layer.get());
140 active_layer->CalculateContentsScale(suggested_ideal_contents_scale, 152 active_layer->CalculateContentsScale(suggested_ideal_contents_scale,
141 device_scale_factor, 153 device_scale_factor,
142 page_scale_factor, 154 page_scale_factor,
155 maximum_animation_contents_scale,
143 animating_transform_to_screen, 156 animating_transform_to_screen,
144 &contents_scale_x, 157 &contents_scale_x,
145 &contents_scale_y, 158 &contents_scale_y,
146 &content_bounds); 159 &content_bounds);
147 160
148 // Create tile and resource. 161 // Create tile and resource.
149 active_layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 162 active_layer->tilings()->tiling_at(0)->CreateAllTilesForTesting();
150 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( 163 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(
151 active_layer->tilings()->tiling_at(0)->AllTilesForTesting()); 164 active_layer->tilings()->tiling_at(0)->AllTilesForTesting());
152 165
153 // Draw. 166 // Draw.
154 active_layer->draw_properties().visible_content_rect = 167 active_layer->draw_properties().visible_content_rect =
155 gfx::Rect(active_layer->bounds()); 168 gfx::Rect(active_layer->bounds());
156 MockQuadCuller quad_culler; 169 MockQuadCuller quad_culler;
157 AppendQuadsData data; 170 AppendQuadsData data;
158 active_layer->WillDraw(DRAW_MODE_SOFTWARE, NULL); 171 active_layer->WillDraw(DRAW_MODE_SOFTWARE, NULL);
159 active_layer->AppendQuads(&quad_culler, &data); 172 active_layer->AppendQuads(&quad_culler, &data);
160 active_layer->DidDraw(NULL); 173 active_layer->DidDraw(NULL);
161 174
162 EXPECT_EQ(DrawQuad::TILED_CONTENT, quad_culler.quad_list()[0]->material); 175 EXPECT_EQ(DrawQuad::TILED_CONTENT, quad_culler.quad_list()[0]->material);
163 176
164 // Tiles are ready at correct scale, so should not set had_incomplete_tile. 177 // Tiles are ready at correct scale, so should not set had_incomplete_tile.
165 EXPECT_FALSE(data.had_incomplete_tile); 178 EXPECT_FALSE(data.had_incomplete_tile);
166 } 179 }
167 180
168 } // namespace 181 } // namespace
169 } // namespace cc 182 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_image_layer_impl.cc ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698