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

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

Issue 453533002: cc: Remove unused arguments from CalculateContentsScale (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_unittest.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 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 <set> 7 #include <set>
8 8
9 #include "cc/animation/layer_animation_controller.h" 9 #include "cc/animation/layer_animation_controller.h"
10 #include "cc/animation/transform_operations.h" 10 #include "cc/animation/transform_operations.h"
(...skipping 20 matching lines...) Expand all
31 #include "testing/gmock/include/gmock/gmock.h" 31 #include "testing/gmock/include/gmock/gmock.h"
32 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
33 #include "ui/gfx/quad_f.h" 33 #include "ui/gfx/quad_f.h"
34 #include "ui/gfx/transform.h" 34 #include "ui/gfx/transform.h"
35 35
36 namespace cc { 36 namespace cc {
37 namespace { 37 namespace {
38 38
39 class LayerWithForcedDrawsContent : public Layer { 39 class LayerWithForcedDrawsContent : public Layer {
40 public: 40 public:
41 LayerWithForcedDrawsContent() : Layer(), last_device_scale_factor_(0.f) {} 41 LayerWithForcedDrawsContent() {}
42 42
43 virtual bool DrawsContent() const OVERRIDE; 43 virtual bool DrawsContent() const OVERRIDE;
44 virtual void CalculateContentsScale(float ideal_contents_scale,
45 float device_scale_factor,
46 float page_scale_factor,
47 float maximum_animation_contents_scale,
48 bool animating_transform_to_screen,
49 float* contents_scale_x,
50 float* contents_scale_y,
51 gfx::Size* content_bounds) OVERRIDE;
52
53 float last_device_scale_factor() const { return last_device_scale_factor_; }
54 44
55 private: 45 private:
56 virtual ~LayerWithForcedDrawsContent() {} 46 virtual ~LayerWithForcedDrawsContent() {}
57
58 // Parameters from last CalculateContentsScale.
59 float last_device_scale_factor_;
60 }; 47 };
61 48
62 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; } 49 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; }
63 50
64 void LayerWithForcedDrawsContent::CalculateContentsScale(
65 float ideal_contents_scale,
66 float device_scale_factor,
67 float page_scale_factor,
68 float maximum_animation_contents_scale,
69 bool animating_transform_to_screen,
70 float* contents_scale_x,
71 float* contents_scale_y,
72 gfx::Size* content_bounds) {
73 last_device_scale_factor_ = device_scale_factor;
74 Layer::CalculateContentsScale(ideal_contents_scale,
75 device_scale_factor,
76 page_scale_factor,
77 maximum_animation_contents_scale,
78 animating_transform_to_screen,
79 contents_scale_x,
80 contents_scale_y,
81 content_bounds);
82 }
83
84 class MockContentLayerClient : public ContentLayerClient { 51 class MockContentLayerClient : public ContentLayerClient {
85 public: 52 public:
86 MockContentLayerClient() {} 53 MockContentLayerClient() {}
87 virtual ~MockContentLayerClient() {} 54 virtual ~MockContentLayerClient() {}
88 virtual void PaintContents( 55 virtual void PaintContents(
89 SkCanvas* canvas, 56 SkCanvas* canvas,
90 const gfx::Rect& clip, 57 const gfx::Rect& clip,
91 gfx::RectF* opaque, 58 gfx::RectF* opaque,
92 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE {} 59 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE {}
93 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} 60 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 translate.Translate(50, 50); 1158 translate.Translate(50, 50);
1192 { 1159 {
1193 RenderSurfaceLayerList render_surface_layer_list; 1160 RenderSurfaceLayerList render_surface_layer_list;
1194 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 1161 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
1195 root.get(), root->bounds(), translate, &render_surface_layer_list); 1162 root.get(), root->bounds(), translate, &render_surface_layer_list);
1196 inputs.can_adjust_raster_scales = true; 1163 inputs.can_adjust_raster_scales = true;
1197 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1164 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1198 EXPECT_EQ(translate, root->draw_properties().target_space_transform); 1165 EXPECT_EQ(translate, root->draw_properties().target_space_transform);
1199 EXPECT_EQ(translate, child->draw_properties().target_space_transform); 1166 EXPECT_EQ(translate, child->draw_properties().target_space_transform);
1200 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1167 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1201 EXPECT_EQ(1.f, root->last_device_scale_factor()); 1168 EXPECT_EQ(1.f, root->draw_properties().device_scale_factor);
1202 EXPECT_EQ(1.f, child->last_device_scale_factor()); 1169 EXPECT_EQ(1.f, child->draw_properties().device_scale_factor);
1203 } 1170 }
1204 1171
1205 gfx::Transform scale; 1172 gfx::Transform scale;
1206 scale.Scale(2, 2); 1173 scale.Scale(2, 2);
1207 { 1174 {
1208 RenderSurfaceLayerList render_surface_layer_list; 1175 RenderSurfaceLayerList render_surface_layer_list;
1209 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 1176 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
1210 root.get(), root->bounds(), scale, &render_surface_layer_list); 1177 root.get(), root->bounds(), scale, &render_surface_layer_list);
1211 inputs.can_adjust_raster_scales = true; 1178 inputs.can_adjust_raster_scales = true;
1212 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1179 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1213 EXPECT_EQ(scale, root->draw_properties().target_space_transform); 1180 EXPECT_EQ(scale, root->draw_properties().target_space_transform);
1214 EXPECT_EQ(scale, child->draw_properties().target_space_transform); 1181 EXPECT_EQ(scale, child->draw_properties().target_space_transform);
1215 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1182 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1216 EXPECT_EQ(2.f, root->last_device_scale_factor()); 1183 EXPECT_EQ(2.f, root->draw_properties().device_scale_factor);
1217 EXPECT_EQ(2.f, child->last_device_scale_factor()); 1184 EXPECT_EQ(2.f, child->draw_properties().device_scale_factor);
1218 } 1185 }
1219 1186
1220 gfx::Transform rotate; 1187 gfx::Transform rotate;
1221 rotate.Rotate(2); 1188 rotate.Rotate(2);
1222 { 1189 {
1223 RenderSurfaceLayerList render_surface_layer_list; 1190 RenderSurfaceLayerList render_surface_layer_list;
1224 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 1191 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
1225 root.get(), root->bounds(), rotate, &render_surface_layer_list); 1192 root.get(), root->bounds(), rotate, &render_surface_layer_list);
1226 inputs.can_adjust_raster_scales = true; 1193 inputs.can_adjust_raster_scales = true;
1227 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1194 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1228 EXPECT_EQ(rotate, root->draw_properties().target_space_transform); 1195 EXPECT_EQ(rotate, root->draw_properties().target_space_transform);
1229 EXPECT_EQ(rotate, child->draw_properties().target_space_transform); 1196 EXPECT_EQ(rotate, child->draw_properties().target_space_transform);
1230 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1197 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1231 EXPECT_EQ(1.f, root->last_device_scale_factor()); 1198 EXPECT_EQ(1.f, root->draw_properties().device_scale_factor);
1232 EXPECT_EQ(1.f, child->last_device_scale_factor()); 1199 EXPECT_EQ(1.f, child->draw_properties().device_scale_factor);
1233 } 1200 }
1234 1201
1235 gfx::Transform composite; 1202 gfx::Transform composite;
1236 composite.ConcatTransform(translate); 1203 composite.ConcatTransform(translate);
1237 composite.ConcatTransform(scale); 1204 composite.ConcatTransform(scale);
1238 composite.ConcatTransform(rotate); 1205 composite.ConcatTransform(rotate);
1239 { 1206 {
1240 RenderSurfaceLayerList render_surface_layer_list; 1207 RenderSurfaceLayerList render_surface_layer_list;
1241 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 1208 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
1242 root.get(), root->bounds(), composite, &render_surface_layer_list); 1209 root.get(), root->bounds(), composite, &render_surface_layer_list);
(...skipping 14 matching lines...) Expand all
1257 inputs.device_scale_factor = device_scale_factor; 1224 inputs.device_scale_factor = device_scale_factor;
1258 inputs.can_adjust_raster_scales = true; 1225 inputs.can_adjust_raster_scales = true;
1259 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1226 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1260 gfx::Transform device_scaled_translate = translate; 1227 gfx::Transform device_scaled_translate = translate;
1261 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); 1228 device_scaled_translate.Scale(device_scale_factor, device_scale_factor);
1262 EXPECT_EQ(device_scaled_translate, 1229 EXPECT_EQ(device_scaled_translate,
1263 root->draw_properties().target_space_transform); 1230 root->draw_properties().target_space_transform);
1264 EXPECT_EQ(device_scaled_translate, 1231 EXPECT_EQ(device_scaled_translate,
1265 child->draw_properties().target_space_transform); 1232 child->draw_properties().target_space_transform);
1266 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1233 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1267 EXPECT_EQ(device_scale_factor, root->last_device_scale_factor()); 1234 EXPECT_EQ(device_scale_factor, root->draw_properties().device_scale_factor);
1268 EXPECT_EQ(device_scale_factor, child->last_device_scale_factor()); 1235 EXPECT_EQ(device_scale_factor,
1236 child->draw_properties().device_scale_factor);
1269 } 1237 }
1270 1238
1271 // Verify it composes correctly with page scale. 1239 // Verify it composes correctly with page scale.
1272 float page_scale_factor = 2.f; 1240 float page_scale_factor = 2.f;
1273 1241
1274 { 1242 {
1275 RenderSurfaceLayerList render_surface_layer_list; 1243 RenderSurfaceLayerList render_surface_layer_list;
1276 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 1244 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
1277 root.get(), root->bounds(), translate, &render_surface_layer_list); 1245 root.get(), root->bounds(), translate, &render_surface_layer_list);
1278 inputs.page_scale_factor = page_scale_factor; 1246 inputs.page_scale_factor = page_scale_factor;
1279 inputs.page_scale_application_layer = root.get(); 1247 inputs.page_scale_application_layer = root.get();
1280 inputs.can_adjust_raster_scales = true; 1248 inputs.can_adjust_raster_scales = true;
1281 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1249 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1282 gfx::Transform page_scaled_translate = translate; 1250 gfx::Transform page_scaled_translate = translate;
1283 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); 1251 page_scaled_translate.Scale(page_scale_factor, page_scale_factor);
1284 EXPECT_EQ(translate, root->draw_properties().target_space_transform); 1252 EXPECT_EQ(translate, root->draw_properties().target_space_transform);
1285 EXPECT_EQ(page_scaled_translate, 1253 EXPECT_EQ(page_scaled_translate,
1286 child->draw_properties().target_space_transform); 1254 child->draw_properties().target_space_transform);
1287 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1255 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1288 EXPECT_EQ(1.f, root->last_device_scale_factor()); 1256 EXPECT_EQ(1.f, root->draw_properties().device_scale_factor);
1289 EXPECT_EQ(1.f, child->last_device_scale_factor()); 1257 EXPECT_EQ(1.f, child->draw_properties().device_scale_factor);
1290 } 1258 }
1291 1259
1292 // Verify that it composes correctly with transforms directly on root layer. 1260 // Verify that it composes correctly with transforms directly on root layer.
1293 root->SetTransform(composite); 1261 root->SetTransform(composite);
1294 1262
1295 { 1263 {
1296 RenderSurfaceLayerList render_surface_layer_list; 1264 RenderSurfaceLayerList render_surface_layer_list;
1297 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 1265 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
1298 root.get(), root->bounds(), composite, &render_surface_layer_list); 1266 root.get(), root->bounds(), composite, &render_surface_layer_list);
1299 inputs.can_adjust_raster_scales = true; 1267 inputs.can_adjust_raster_scales = true;
(...skipping 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after
4042 ->render_surface()->layer_list().at(1)->id()); 4010 ->render_surface()->layer_list().at(1)->id());
4043 } 4011 }
4044 4012
4045 class NoScaleContentLayer : public ContentLayer { 4013 class NoScaleContentLayer : public ContentLayer {
4046 public: 4014 public:
4047 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { 4015 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) {
4048 return make_scoped_refptr(new NoScaleContentLayer(client)); 4016 return make_scoped_refptr(new NoScaleContentLayer(client));
4049 } 4017 }
4050 4018
4051 virtual void CalculateContentsScale(float ideal_contents_scale, 4019 virtual void CalculateContentsScale(float ideal_contents_scale,
4052 float device_scale_factor,
4053 float page_scale_factor,
4054 float maximum_animation_contents_scale,
4055 bool animating_transform_to_screen,
4056 float* contents_scale_x, 4020 float* contents_scale_x,
4057 float* contents_scale_y, 4021 float* contents_scale_y,
4058 gfx::Size* content_bounds) OVERRIDE { 4022 gfx::Size* content_bounds) OVERRIDE {
4059 // Skip over the ContentLayer to the base Layer class. 4023 // Skip over the ContentLayer to the base Layer class.
4060 Layer::CalculateContentsScale(ideal_contents_scale, 4024 Layer::CalculateContentsScale(ideal_contents_scale,
4061 device_scale_factor,
4062 page_scale_factor,
4063 maximum_animation_contents_scale,
4064 animating_transform_to_screen,
4065 contents_scale_x, 4025 contents_scale_x,
4066 contents_scale_y, 4026 contents_scale_y,
4067 content_bounds); 4027 content_bounds);
4068 } 4028 }
4069 4029
4070 protected: 4030 protected:
4071 explicit NoScaleContentLayer(ContentLayerClient* client) 4031 explicit NoScaleContentLayer(ContentLayerClient* client)
4072 : ContentLayer(client) {} 4032 : ContentLayer(client) {}
4073 virtual ~NoScaleContentLayer() {} 4033 virtual ~NoScaleContentLayer() {}
4074 }; 4034 };
(...skipping 4518 matching lines...) Expand 10 before | Expand all | Expand 10 after
8593 EXPECT_FLOAT_EQ(4.f, 8553 EXPECT_FLOAT_EQ(4.f,
8594 child1_layer->replica_layer() 8554 child1_layer->replica_layer()
8595 ->mask_layer() 8555 ->mask_layer()
8596 ->draw_properties() 8556 ->draw_properties()
8597 .device_scale_factor); 8557 .device_scale_factor);
8598 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor); 8558 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor);
8599 } 8559 }
8600 8560
8601 } // namespace 8561 } // namespace
8602 } // namespace cc 8562 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698