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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 10 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/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_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 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/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 5139 matching lines...) Expand 10 before | Expand all | Expand 10 after
5150 surface_no_scale_child_scale); 5150 surface_no_scale_child_scale);
5151 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale_child_no_scale); 5151 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale_child_no_scale);
5152 5152
5153 // The parent is scaled up during draw, since its contents are not scaled by 5153 // The parent is scaled up during draw, since its contents are not scaled by
5154 // the transform hierarchy. 5154 // the transform hierarchy.
5155 EXPECT_FLOAT_EQ(initial_parent_scale, 5155 EXPECT_FLOAT_EQ(initial_parent_scale,
5156 parent->draw_transform().matrix().get(0, 0)); 5156 parent->draw_transform().matrix().get(0, 0));
5157 EXPECT_FLOAT_EQ(initial_parent_scale, 5157 EXPECT_FLOAT_EQ(initial_parent_scale,
5158 parent->draw_transform().matrix().get(1, 1)); 5158 parent->draw_transform().matrix().get(1, 1));
5159 5159
5160 // The child surface is scaled up during draw since its subtree is not scaled 5160 // The child surface is not scaled up during draw since its subtree is scaled
5161 // by the transform hierarchy. 5161 // by the transform hierarchy.
5162 EXPECT_FLOAT_EQ( 5162 EXPECT_FLOAT_EQ(
5163 initial_parent_scale * initial_child_scale, 5163 1.f,
5164 surface_scale->render_surface()->draw_transform().matrix().get(0, 0)); 5164 surface_scale->render_surface()->draw_transform().matrix().get(0, 0));
5165 EXPECT_FLOAT_EQ( 5165 EXPECT_FLOAT_EQ(
5166 initial_parent_scale * initial_child_scale, 5166 1.f,
5167 surface_scale->render_surface()->draw_transform().matrix().get(1, 1)); 5167 surface_scale->render_surface()->draw_transform().matrix().get(1, 1));
5168 5168
5169 // The surface_scale's RenderSurface is scaled during draw, so the layer does 5169 // The surface_scale's RenderSurface is not scaled during draw, so the layer
5170 // not need to be scaled when drawing into its surface. 5170 // needs to be scaled when drawing into its surface.
5171 EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(0, 0)); 5171 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
5172 EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(1, 1)); 5172 surface_scale->draw_transform().matrix().get(0, 0));
5173 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
5174 surface_scale->draw_transform().matrix().get(1, 1));
5173 5175
5174 // The surface_scale_child_scale is scaled when drawing into its surface, 5176 // The surface_scale_child_scale is not scaled when drawing into its surface,
5175 // since its content bounds are not scaled by the transform hierarchy. 5177 // since its content bounds are scaled by the transform hierarchy.
5176 EXPECT_FLOAT_EQ( 5178 EXPECT_FLOAT_EQ(
5177 initial_child_scale, 5179 initial_child_scale * initial_child_scale * initial_parent_scale,
5178 surface_scale_child_scale->draw_transform().matrix().get(0, 0)); 5180 surface_scale_child_scale->draw_transform().matrix().get(0, 0));
5179 EXPECT_FLOAT_EQ( 5181 EXPECT_FLOAT_EQ(
5180 initial_child_scale, 5182 initial_child_scale * initial_child_scale * initial_parent_scale,
5181 surface_scale_child_scale->draw_transform().matrix().get(1, 1)); 5183 surface_scale_child_scale->draw_transform().matrix().get(1, 1));
5182 5184
5183 // The surface_scale_child_no_scale has a fixed contents scale of 1, so it 5185 // The surface_scale_child_no_scale is scaled by the device scale, page scale
5184 // needs to be scaled by the device and page scale factors, along with the 5186 // and transform hierarchy.
5185 // transform hierarchy.
5186 EXPECT_FLOAT_EQ( 5187 EXPECT_FLOAT_EQ(
5187 device_scale_factor * page_scale_factor * initial_child_scale, 5188 device_scale_factor * page_scale_factor * initial_parent_scale *
5189 initial_child_scale * initial_child_scale,
5188 surface_scale_child_no_scale->draw_transform().matrix().get(0, 0)); 5190 surface_scale_child_no_scale->draw_transform().matrix().get(0, 0));
5189 EXPECT_FLOAT_EQ( 5191 EXPECT_FLOAT_EQ(
5190 device_scale_factor * page_scale_factor * initial_child_scale, 5192 device_scale_factor * page_scale_factor * initial_parent_scale *
5193 initial_child_scale * initial_child_scale,
5191 surface_scale_child_no_scale->draw_transform().matrix().get(1, 1)); 5194 surface_scale_child_no_scale->draw_transform().matrix().get(1, 1));
5192 5195
5193 // The child surface is scaled up during draw since its subtree is not scaled 5196 // The child surface is not scaled up during draw since its subtree is scaled
5194 // by the transform hierarchy. 5197 // by the transform hierarchy.
5195 EXPECT_FLOAT_EQ( 5198 EXPECT_FLOAT_EQ(
5196 initial_parent_scale * initial_child_scale, 5199 1.f,
5197 surface_no_scale->render_surface()->draw_transform().matrix().get(0, 0)); 5200 surface_no_scale->render_surface()->draw_transform().matrix().get(0, 0));
5198 EXPECT_FLOAT_EQ( 5201 EXPECT_FLOAT_EQ(
5199 initial_parent_scale * initial_child_scale, 5202 1.f,
5200 surface_no_scale->render_surface()->draw_transform().matrix().get(1, 1)); 5203 surface_no_scale->render_surface()->draw_transform().matrix().get(1, 1));
5201 5204
5202 // The surface_no_scale layer has a fixed contents scale of 1, so it needs to 5205 // The surface_no_scale layer has a fixed contents scale of 1, so it needs to
5203 // be scaled by the device and page scale factors. Its surface is already 5206 // be scaled by the device and page scale factors. Its surface is already
5204 // scaled by the transform hierarchy so those don't need to scale the layer's 5207 // scaled by the transform hierarchy so those don't need to scale the layer's
5205 // drawing. 5208 // drawing.
5206 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor, 5209 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale *
5210 device_scale_factor * page_scale_factor,
5207 surface_no_scale->draw_transform().matrix().get(0, 0)); 5211 surface_no_scale->draw_transform().matrix().get(0, 0));
5208 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor, 5212 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale *
5213 device_scale_factor * page_scale_factor,
5209 surface_no_scale->draw_transform().matrix().get(1, 1)); 5214 surface_no_scale->draw_transform().matrix().get(1, 1));
5210 5215
5211 // The surface_no_scale_child_scale has its contents scaled by the page and 5216 // The surface_no_scale_child_scale has its contents scaled by the page and
5212 // device scale factors, but needs to be scaled by the transform hierarchy 5217 // device scale factors, but needs to be scaled by the transform hierarchy
5213 // when drawing. 5218 // when drawing.
5214 EXPECT_FLOAT_EQ( 5219 EXPECT_FLOAT_EQ(
5215 initial_child_scale, 5220 initial_parent_scale * initial_child_scale * initial_child_scale,
5216 surface_no_scale_child_scale->draw_transform().matrix().get(0, 0)); 5221 surface_no_scale_child_scale->draw_transform().matrix().get(0, 0));
5217 EXPECT_FLOAT_EQ( 5222 EXPECT_FLOAT_EQ(
5218 initial_child_scale, 5223 initial_parent_scale * initial_child_scale * initial_child_scale,
5219 surface_no_scale_child_scale->draw_transform().matrix().get(1, 1)); 5224 surface_no_scale_child_scale->draw_transform().matrix().get(1, 1));
5220 5225
5221 // The surface_no_scale_child_no_scale has a fixed contents scale of 1, so it 5226 // The surface_no_scale_child_no_scale needs to be scaled by the device and
5222 // needs to be scaled by the device and page scale factors. It also needs to 5227 // page scale factors and by any transform heirarchy below its target surface.
5223 // be scaled by any transform heirarchy below its target surface.
5224 EXPECT_FLOAT_EQ( 5228 EXPECT_FLOAT_EQ(
5225 device_scale_factor * page_scale_factor * initial_child_scale, 5229 device_scale_factor * page_scale_factor * initial_parent_scale *
5230 initial_child_scale * initial_child_scale,
5226 surface_no_scale_child_no_scale->draw_transform().matrix().get(0, 0)); 5231 surface_no_scale_child_no_scale->draw_transform().matrix().get(0, 0));
5227 EXPECT_FLOAT_EQ( 5232 EXPECT_FLOAT_EQ(
5228 device_scale_factor * page_scale_factor * initial_child_scale, 5233 device_scale_factor * page_scale_factor * initial_parent_scale *
5234 initial_child_scale * initial_child_scale,
5229 surface_no_scale_child_no_scale->draw_transform().matrix().get(1, 1)); 5235 surface_no_scale_child_no_scale->draw_transform().matrix().get(1, 1));
5230 } 5236 }
5231 5237
5232 TEST_F(LayerTreeHostCommonTest, IdealScaleForAnimatingLayer) { 5238 TEST_F(LayerTreeHostCommonTest, IdealScaleForAnimatingLayer) {
5233 MockContentLayerClient delegate; 5239 MockContentLayerClient delegate;
5234 gfx::Transform identity_matrix; 5240 gfx::Transform identity_matrix;
5235 5241
5236 gfx::Transform parent_scale_matrix; 5242 gfx::Transform parent_scale_matrix;
5237 SkMScalar initial_parent_scale = 1.75; 5243 SkMScalar initial_parent_scale = 1.75;
5238 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 5244 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
(...skipping 3337 matching lines...) Expand 10 before | Expand all | Expand 10 after
8576 8582
8577 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 8583 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
8578 8584
8579 gfx::Rect affected_by_delta(0, 0, root_size.width(), 8585 gfx::Rect affected_by_delta(0, 0, root_size.width(),
8580 root_size.height() + 50); 8586 root_size.height() + 50);
8581 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); 8587 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect());
8582 } 8588 }
8583 8589
8584 } // namespace 8590 } // namespace
8585 } // namespace cc 8591 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698