OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 #include "cc/test/fake_impl_proxy.h" | 23 #include "cc/test/fake_impl_proxy.h" |
24 #include "cc/test/fake_layer_tree_host.h" | 24 #include "cc/test/fake_layer_tree_host.h" |
25 #include "cc/test/fake_layer_tree_host_impl.h" | 25 #include "cc/test/fake_layer_tree_host_impl.h" |
26 #include "cc/test/geometry_test_utils.h" | 26 #include "cc/test/geometry_test_utils.h" |
27 #include "cc/test/layer_tree_host_common_test.h" | 27 #include "cc/test/layer_tree_host_common_test.h" |
28 #include "cc/trees/layer_tree_impl.h" | 28 #include "cc/trees/layer_tree_impl.h" |
29 #include "cc/trees/proxy.h" | 29 #include "cc/trees/proxy.h" |
30 #include "cc/trees/single_thread_proxy.h" | 30 #include "cc/trees/single_thread_proxy.h" |
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/geometry/size_conversions.h" | |
34 #include "ui/gfx/quad_f.h" | 33 #include "ui/gfx/quad_f.h" |
35 #include "ui/gfx/transform.h" | 34 #include "ui/gfx/transform.h" |
36 | 35 |
37 namespace cc { | 36 namespace cc { |
38 namespace { | 37 namespace { |
39 | 38 |
40 class LayerWithForcedDrawsContent : public Layer { | 39 class LayerWithForcedDrawsContent : public Layer { |
41 public: | 40 public: |
42 LayerWithForcedDrawsContent() {} | 41 LayerWithForcedDrawsContent() {} |
43 | 42 |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 gfx::PointF(), | 1151 gfx::PointF(), |
1153 gfx::Size(20, 20), | 1152 gfx::Size(20, 20), |
1154 true, | 1153 true, |
1155 false); | 1154 false); |
1156 | 1155 |
1157 gfx::Transform translate; | 1156 gfx::Transform translate; |
1158 translate.Translate(50, 50); | 1157 translate.Translate(50, 50); |
1159 { | 1158 { |
1160 RenderSurfaceLayerList render_surface_layer_list; | 1159 RenderSurfaceLayerList render_surface_layer_list; |
1161 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1160 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1162 root.get(), | 1161 root.get(), root->bounds(), translate, &render_surface_layer_list); |
1163 gfx::ToCeiledSize(root->bounds()), | |
1164 translate, | |
1165 &render_surface_layer_list); | |
1166 inputs.can_adjust_raster_scales = true; | 1162 inputs.can_adjust_raster_scales = true; |
1167 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1163 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1168 EXPECT_EQ(translate, root->draw_properties().target_space_transform); | 1164 EXPECT_EQ(translate, root->draw_properties().target_space_transform); |
1169 EXPECT_EQ(translate, child->draw_properties().target_space_transform); | 1165 EXPECT_EQ(translate, child->draw_properties().target_space_transform); |
1170 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); | 1166 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); |
1171 EXPECT_EQ(1.f, root->draw_properties().device_scale_factor); | 1167 EXPECT_EQ(1.f, root->draw_properties().device_scale_factor); |
1172 EXPECT_EQ(1.f, child->draw_properties().device_scale_factor); | 1168 EXPECT_EQ(1.f, child->draw_properties().device_scale_factor); |
1173 } | 1169 } |
1174 | 1170 |
1175 gfx::Transform scale; | 1171 gfx::Transform scale; |
1176 scale.Scale(2, 2); | 1172 scale.Scale(2, 2); |
1177 { | 1173 { |
1178 RenderSurfaceLayerList render_surface_layer_list; | 1174 RenderSurfaceLayerList render_surface_layer_list; |
1179 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1175 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1180 root.get(), | 1176 root.get(), root->bounds(), scale, &render_surface_layer_list); |
1181 gfx::ToCeiledSize(root->bounds()), | |
1182 scale, | |
1183 &render_surface_layer_list); | |
1184 inputs.can_adjust_raster_scales = true; | 1177 inputs.can_adjust_raster_scales = true; |
1185 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1178 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1186 EXPECT_EQ(scale, root->draw_properties().target_space_transform); | 1179 EXPECT_EQ(scale, root->draw_properties().target_space_transform); |
1187 EXPECT_EQ(scale, child->draw_properties().target_space_transform); | 1180 EXPECT_EQ(scale, child->draw_properties().target_space_transform); |
1188 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); | 1181 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); |
1189 EXPECT_EQ(2.f, root->draw_properties().device_scale_factor); | 1182 EXPECT_EQ(2.f, root->draw_properties().device_scale_factor); |
1190 EXPECT_EQ(2.f, child->draw_properties().device_scale_factor); | 1183 EXPECT_EQ(2.f, child->draw_properties().device_scale_factor); |
1191 } | 1184 } |
1192 | 1185 |
1193 gfx::Transform rotate; | 1186 gfx::Transform rotate; |
1194 rotate.Rotate(2); | 1187 rotate.Rotate(2); |
1195 { | 1188 { |
1196 RenderSurfaceLayerList render_surface_layer_list; | 1189 RenderSurfaceLayerList render_surface_layer_list; |
1197 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1190 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1198 root.get(), | 1191 root.get(), root->bounds(), rotate, &render_surface_layer_list); |
1199 gfx::ToCeiledSize(root->bounds()), | |
1200 rotate, | |
1201 &render_surface_layer_list); | |
1202 inputs.can_adjust_raster_scales = true; | 1192 inputs.can_adjust_raster_scales = true; |
1203 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1193 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1204 EXPECT_EQ(rotate, root->draw_properties().target_space_transform); | 1194 EXPECT_EQ(rotate, root->draw_properties().target_space_transform); |
1205 EXPECT_EQ(rotate, child->draw_properties().target_space_transform); | 1195 EXPECT_EQ(rotate, child->draw_properties().target_space_transform); |
1206 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); | 1196 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); |
1207 EXPECT_EQ(1.f, root->draw_properties().device_scale_factor); | 1197 EXPECT_EQ(1.f, root->draw_properties().device_scale_factor); |
1208 EXPECT_EQ(1.f, child->draw_properties().device_scale_factor); | 1198 EXPECT_EQ(1.f, child->draw_properties().device_scale_factor); |
1209 } | 1199 } |
1210 | 1200 |
1211 gfx::Transform composite; | 1201 gfx::Transform composite; |
1212 composite.ConcatTransform(translate); | 1202 composite.ConcatTransform(translate); |
1213 composite.ConcatTransform(scale); | 1203 composite.ConcatTransform(scale); |
1214 composite.ConcatTransform(rotate); | 1204 composite.ConcatTransform(rotate); |
1215 { | 1205 { |
1216 RenderSurfaceLayerList render_surface_layer_list; | 1206 RenderSurfaceLayerList render_surface_layer_list; |
1217 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1207 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1218 root.get(), | 1208 root.get(), root->bounds(), composite, &render_surface_layer_list); |
1219 gfx::ToCeiledSize(root->bounds()), | |
1220 composite, | |
1221 &render_surface_layer_list); | |
1222 inputs.can_adjust_raster_scales = true; | 1209 inputs.can_adjust_raster_scales = true; |
1223 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1210 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1224 EXPECT_EQ(composite, root->draw_properties().target_space_transform); | 1211 EXPECT_EQ(composite, root->draw_properties().target_space_transform); |
1225 EXPECT_EQ(composite, child->draw_properties().target_space_transform); | 1212 EXPECT_EQ(composite, child->draw_properties().target_space_transform); |
1226 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); | 1213 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); |
1227 } | 1214 } |
1228 | 1215 |
1229 // Verify it composes correctly with device scale. | 1216 // Verify it composes correctly with device scale. |
1230 float device_scale_factor = 1.5f; | 1217 float device_scale_factor = 1.5f; |
1231 | 1218 |
1232 { | 1219 { |
1233 RenderSurfaceLayerList render_surface_layer_list; | 1220 RenderSurfaceLayerList render_surface_layer_list; |
1234 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1221 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1235 root.get(), | 1222 root.get(), root->bounds(), translate, &render_surface_layer_list); |
1236 gfx::ToCeiledSize(root->bounds()), | |
1237 translate, | |
1238 &render_surface_layer_list); | |
1239 inputs.device_scale_factor = device_scale_factor; | 1223 inputs.device_scale_factor = device_scale_factor; |
1240 inputs.can_adjust_raster_scales = true; | 1224 inputs.can_adjust_raster_scales = true; |
1241 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1225 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1242 gfx::Transform device_scaled_translate = translate; | 1226 gfx::Transform device_scaled_translate = translate; |
1243 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); | 1227 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); |
1244 EXPECT_EQ(device_scaled_translate, | 1228 EXPECT_EQ(device_scaled_translate, |
1245 root->draw_properties().target_space_transform); | 1229 root->draw_properties().target_space_transform); |
1246 EXPECT_EQ(device_scaled_translate, | 1230 EXPECT_EQ(device_scaled_translate, |
1247 child->draw_properties().target_space_transform); | 1231 child->draw_properties().target_space_transform); |
1248 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); | 1232 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); |
1249 EXPECT_EQ(device_scale_factor, root->draw_properties().device_scale_factor); | 1233 EXPECT_EQ(device_scale_factor, root->draw_properties().device_scale_factor); |
1250 EXPECT_EQ(device_scale_factor, | 1234 EXPECT_EQ(device_scale_factor, |
1251 child->draw_properties().device_scale_factor); | 1235 child->draw_properties().device_scale_factor); |
1252 } | 1236 } |
1253 | 1237 |
1254 // Verify it composes correctly with page scale. | 1238 // Verify it composes correctly with page scale. |
1255 float page_scale_factor = 2.f; | 1239 float page_scale_factor = 2.f; |
1256 | 1240 |
1257 { | 1241 { |
1258 RenderSurfaceLayerList render_surface_layer_list; | 1242 RenderSurfaceLayerList render_surface_layer_list; |
1259 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1243 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1260 root.get(), | 1244 root.get(), root->bounds(), translate, &render_surface_layer_list); |
1261 gfx::ToCeiledSize(root->bounds()), | |
1262 translate, | |
1263 &render_surface_layer_list); | |
1264 inputs.page_scale_factor = page_scale_factor; | 1245 inputs.page_scale_factor = page_scale_factor; |
1265 inputs.page_scale_application_layer = root.get(); | 1246 inputs.page_scale_application_layer = root.get(); |
1266 inputs.can_adjust_raster_scales = true; | 1247 inputs.can_adjust_raster_scales = true; |
1267 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1248 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1268 gfx::Transform page_scaled_translate = translate; | 1249 gfx::Transform page_scaled_translate = translate; |
1269 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); | 1250 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); |
1270 EXPECT_EQ(translate, root->draw_properties().target_space_transform); | 1251 EXPECT_EQ(translate, root->draw_properties().target_space_transform); |
1271 EXPECT_EQ(page_scaled_translate, | 1252 EXPECT_EQ(page_scaled_translate, |
1272 child->draw_properties().target_space_transform); | 1253 child->draw_properties().target_space_transform); |
1273 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); | 1254 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); |
1274 EXPECT_EQ(1.f, root->draw_properties().device_scale_factor); | 1255 EXPECT_EQ(1.f, root->draw_properties().device_scale_factor); |
1275 EXPECT_EQ(1.f, child->draw_properties().device_scale_factor); | 1256 EXPECT_EQ(1.f, child->draw_properties().device_scale_factor); |
1276 } | 1257 } |
1277 | 1258 |
1278 // Verify that it composes correctly with transforms directly on root layer. | 1259 // Verify that it composes correctly with transforms directly on root layer. |
1279 root->SetTransform(composite); | 1260 root->SetTransform(composite); |
1280 | 1261 |
1281 { | 1262 { |
1282 RenderSurfaceLayerList render_surface_layer_list; | 1263 RenderSurfaceLayerList render_surface_layer_list; |
1283 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1264 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1284 root.get(), | 1265 root.get(), root->bounds(), composite, &render_surface_layer_list); |
1285 gfx::ToCeiledSize(root->bounds()), | |
1286 composite, | |
1287 &render_surface_layer_list); | |
1288 inputs.can_adjust_raster_scales = true; | 1266 inputs.can_adjust_raster_scales = true; |
1289 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1267 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1290 gfx::Transform compositeSquared = composite; | 1268 gfx::Transform compositeSquared = composite; |
1291 compositeSquared.ConcatTransform(composite); | 1269 compositeSquared.ConcatTransform(composite); |
1292 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1270 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1293 compositeSquared, root->draw_properties().target_space_transform); | 1271 compositeSquared, root->draw_properties().target_space_transform); |
1294 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1272 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1295 compositeSquared, child->draw_properties().target_space_transform); | 1273 compositeSquared, child->draw_properties().target_space_transform); |
1296 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); | 1274 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); |
1297 } | 1275 } |
(...skipping 3188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4486 | 4464 |
4487 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 4465 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
4488 host->SetRootLayer(root); | 4466 host->SetRootLayer(root); |
4489 | 4467 |
4490 float device_scale_factor = 2.5f; | 4468 float device_scale_factor = 2.5f; |
4491 float page_scale_factor = 1.f; | 4469 float page_scale_factor = 1.f; |
4492 | 4470 |
4493 { | 4471 { |
4494 RenderSurfaceLayerList render_surface_layer_list; | 4472 RenderSurfaceLayerList render_surface_layer_list; |
4495 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 4473 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
4496 root.get(), | 4474 root.get(), root->bounds(), &render_surface_layer_list); |
4497 gfx::ToCeiledSize(root->bounds()), | |
4498 &render_surface_layer_list); | |
4499 inputs.device_scale_factor = device_scale_factor; | 4475 inputs.device_scale_factor = device_scale_factor; |
4500 inputs.page_scale_factor = page_scale_factor; | 4476 inputs.page_scale_factor = page_scale_factor; |
4501 inputs.page_scale_application_layer = root.get(); | 4477 inputs.page_scale_application_layer = root.get(); |
4502 inputs.can_adjust_raster_scales = true; | 4478 inputs.can_adjust_raster_scales = true; |
4503 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4479 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
4504 | 4480 |
4505 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4481 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
4506 initial_parent_scale, parent); | 4482 initial_parent_scale, parent); |
4507 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4483 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
4508 initial_parent_scale * initial_child_scale, | 4484 initial_parent_scale * initial_child_scale, |
(...skipping 22 matching lines...) Expand all Loading... |
4531 } | 4507 } |
4532 | 4508 |
4533 // If the device_scale_factor or page_scale_factor changes, then it should be | 4509 // If the device_scale_factor or page_scale_factor changes, then it should be |
4534 // updated using the initial transform as the raster scale. | 4510 // updated using the initial transform as the raster scale. |
4535 device_scale_factor = 2.25f; | 4511 device_scale_factor = 2.25f; |
4536 page_scale_factor = 1.25f; | 4512 page_scale_factor = 1.25f; |
4537 | 4513 |
4538 { | 4514 { |
4539 RenderSurfaceLayerList render_surface_layer_list; | 4515 RenderSurfaceLayerList render_surface_layer_list; |
4540 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 4516 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
4541 root.get(), | 4517 root.get(), root->bounds(), &render_surface_layer_list); |
4542 gfx::ToCeiledSize(root->bounds()), | |
4543 &render_surface_layer_list); | |
4544 inputs.device_scale_factor = device_scale_factor; | 4518 inputs.device_scale_factor = device_scale_factor; |
4545 inputs.page_scale_factor = page_scale_factor; | 4519 inputs.page_scale_factor = page_scale_factor; |
4546 inputs.page_scale_application_layer = root.get(); | 4520 inputs.page_scale_application_layer = root.get(); |
4547 inputs.can_adjust_raster_scales = true; | 4521 inputs.can_adjust_raster_scales = true; |
4548 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4522 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
4549 | 4523 |
4550 EXPECT_CONTENTS_SCALE_EQ( | 4524 EXPECT_CONTENTS_SCALE_EQ( |
4551 device_scale_factor * page_scale_factor * initial_parent_scale, parent); | 4525 device_scale_factor * page_scale_factor * initial_parent_scale, parent); |
4552 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4526 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
4553 initial_parent_scale * initial_child_scale, | 4527 initial_parent_scale * initial_child_scale, |
4554 child_scale); | 4528 child_scale); |
4555 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4529 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
4556 initial_parent_scale * initial_child_scale, | 4530 initial_parent_scale * initial_child_scale, |
4557 child_empty); | 4531 child_empty); |
4558 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); | 4532 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); |
4559 } | 4533 } |
4560 | 4534 |
4561 // If the transform changes, we expect the raster scale to be reset to 1.0. | 4535 // If the transform changes, we expect the raster scale to be reset to 1.0. |
4562 SkMScalar second_child_scale = 1.75; | 4536 SkMScalar second_child_scale = 1.75; |
4563 child_scale_matrix.Scale(second_child_scale / initial_child_scale, | 4537 child_scale_matrix.Scale(second_child_scale / initial_child_scale, |
4564 second_child_scale / initial_child_scale); | 4538 second_child_scale / initial_child_scale); |
4565 child_scale->SetTransform(child_scale_matrix); | 4539 child_scale->SetTransform(child_scale_matrix); |
4566 child_empty->SetTransform(child_scale_matrix); | 4540 child_empty->SetTransform(child_scale_matrix); |
4567 | 4541 |
4568 { | 4542 { |
4569 RenderSurfaceLayerList render_surface_layer_list; | 4543 RenderSurfaceLayerList render_surface_layer_list; |
4570 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 4544 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
4571 root.get(), | 4545 root.get(), root->bounds(), &render_surface_layer_list); |
4572 gfx::ToCeiledSize(root->bounds()), | |
4573 &render_surface_layer_list); | |
4574 inputs.device_scale_factor = device_scale_factor; | 4546 inputs.device_scale_factor = device_scale_factor; |
4575 inputs.page_scale_factor = page_scale_factor; | 4547 inputs.page_scale_factor = page_scale_factor; |
4576 inputs.page_scale_application_layer = root.get(); | 4548 inputs.page_scale_application_layer = root.get(); |
4577 inputs.can_adjust_raster_scales = true; | 4549 inputs.can_adjust_raster_scales = true; |
4578 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4550 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
4579 | 4551 |
4580 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4552 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
4581 initial_parent_scale, | 4553 initial_parent_scale, |
4582 parent); | 4554 parent); |
4583 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 4555 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
4584 child_scale); | 4556 child_scale); |
4585 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 4557 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
4586 child_empty); | 4558 child_empty); |
4587 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); | 4559 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); |
4588 } | 4560 } |
4589 | 4561 |
4590 // If the device_scale_factor or page_scale_factor changes, then it should be | 4562 // If the device_scale_factor or page_scale_factor changes, then it should be |
4591 // updated, but still using 1.0 as the raster scale. | 4563 // updated, but still using 1.0 as the raster scale. |
4592 device_scale_factor = 2.75f; | 4564 device_scale_factor = 2.75f; |
4593 page_scale_factor = 1.75f; | 4565 page_scale_factor = 1.75f; |
4594 | 4566 |
4595 { | 4567 { |
4596 RenderSurfaceLayerList render_surface_layer_list; | 4568 RenderSurfaceLayerList render_surface_layer_list; |
4597 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 4569 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
4598 root.get(), | 4570 root.get(), root->bounds(), &render_surface_layer_list); |
4599 gfx::ToCeiledSize(root->bounds()), | |
4600 &render_surface_layer_list); | |
4601 inputs.device_scale_factor = device_scale_factor; | 4571 inputs.device_scale_factor = device_scale_factor; |
4602 inputs.page_scale_factor = page_scale_factor; | 4572 inputs.page_scale_factor = page_scale_factor; |
4603 inputs.page_scale_application_layer = root.get(); | 4573 inputs.page_scale_application_layer = root.get(); |
4604 inputs.can_adjust_raster_scales = true; | 4574 inputs.can_adjust_raster_scales = true; |
4605 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4575 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
4606 | 4576 |
4607 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4577 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
4608 initial_parent_scale, | 4578 initial_parent_scale, |
4609 parent); | 4579 parent); |
4610 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 4580 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4678 | 4648 |
4679 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 4649 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
4680 host->SetRootLayer(root); | 4650 host->SetRootLayer(root); |
4681 | 4651 |
4682 RenderSurfaceLayerList render_surface_layer_list; | 4652 RenderSurfaceLayerList render_surface_layer_list; |
4683 | 4653 |
4684 float device_scale_factor = 2.5f; | 4654 float device_scale_factor = 2.5f; |
4685 float page_scale_factor = 1.f; | 4655 float page_scale_factor = 1.f; |
4686 | 4656 |
4687 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 4657 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
4688 root.get(), | 4658 root.get(), root->bounds(), &render_surface_layer_list); |
4689 gfx::ToCeiledSize(root->bounds()), | |
4690 &render_surface_layer_list); | |
4691 inputs.device_scale_factor = device_scale_factor; | 4659 inputs.device_scale_factor = device_scale_factor; |
4692 inputs.page_scale_factor = page_scale_factor; | 4660 inputs.page_scale_factor = page_scale_factor; |
4693 inputs.page_scale_application_layer = root.get(), | 4661 inputs.page_scale_application_layer = root.get(), |
4694 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4662 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
4695 | 4663 |
4696 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, parent); | 4664 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, parent); |
4697 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 4665 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
4698 child_scale); | 4666 child_scale); |
4699 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 4667 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
4700 child_empty); | 4668 child_empty); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4762 | 4730 |
4763 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 4731 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
4764 host->SetRootLayer(root); | 4732 host->SetRootLayer(root); |
4765 | 4733 |
4766 float device_scale_factor = 2.5f; | 4734 float device_scale_factor = 2.5f; |
4767 float page_scale_factor = 0.01f; | 4735 float page_scale_factor = 0.01f; |
4768 | 4736 |
4769 { | 4737 { |
4770 RenderSurfaceLayerList render_surface_layer_list; | 4738 RenderSurfaceLayerList render_surface_layer_list; |
4771 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 4739 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
4772 root.get(), | 4740 root.get(), root->bounds(), &render_surface_layer_list); |
4773 gfx::ToCeiledSize(root->bounds()), | |
4774 &render_surface_layer_list); | |
4775 inputs.device_scale_factor = device_scale_factor; | 4741 inputs.device_scale_factor = device_scale_factor; |
4776 inputs.page_scale_factor = page_scale_factor; | 4742 inputs.page_scale_factor = page_scale_factor; |
4777 inputs.page_scale_application_layer = root.get(); | 4743 inputs.page_scale_application_layer = root.get(); |
4778 inputs.can_adjust_raster_scales = true; | 4744 inputs.can_adjust_raster_scales = true; |
4779 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4745 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
4780 | 4746 |
4781 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4747 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
4782 initial_parent_scale, | 4748 initial_parent_scale, |
4783 parent); | 4749 parent); |
4784 // The child's scale is < 1, so we should not save and use that scale | 4750 // The child's scale is < 1, so we should not save and use that scale |
4785 // factor. | 4751 // factor. |
4786 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * 1, | 4752 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * 1, |
4787 child_scale); | 4753 child_scale); |
4788 } | 4754 } |
4789 | 4755 |
4790 // When chilld's total scale becomes >= 1, we should save and use that scale | 4756 // When chilld's total scale becomes >= 1, we should save and use that scale |
4791 // factor. | 4757 // factor. |
4792 child_scale_matrix.MakeIdentity(); | 4758 child_scale_matrix.MakeIdentity(); |
4793 SkMScalar final_child_scale = 0.75; | 4759 SkMScalar final_child_scale = 0.75; |
4794 child_scale_matrix.Scale(final_child_scale, final_child_scale); | 4760 child_scale_matrix.Scale(final_child_scale, final_child_scale); |
4795 child_scale->SetTransform(child_scale_matrix); | 4761 child_scale->SetTransform(child_scale_matrix); |
4796 | 4762 |
4797 { | 4763 { |
4798 RenderSurfaceLayerList render_surface_layer_list; | 4764 RenderSurfaceLayerList render_surface_layer_list; |
4799 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 4765 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
4800 root.get(), | 4766 root.get(), root->bounds(), &render_surface_layer_list); |
4801 gfx::ToCeiledSize(root->bounds()), | |
4802 &render_surface_layer_list); | |
4803 inputs.device_scale_factor = device_scale_factor; | 4767 inputs.device_scale_factor = device_scale_factor; |
4804 inputs.page_scale_factor = page_scale_factor; | 4768 inputs.page_scale_factor = page_scale_factor; |
4805 inputs.page_scale_application_layer = root.get(); | 4769 inputs.page_scale_application_layer = root.get(); |
4806 inputs.can_adjust_raster_scales = true; | 4770 inputs.can_adjust_raster_scales = true; |
4807 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4771 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
4808 | 4772 |
4809 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4773 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
4810 initial_parent_scale, | 4774 initial_parent_scale, |
4811 parent); | 4775 parent); |
4812 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4776 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4913 surface_no_scale->AddChild(surface_no_scale_child_no_scale); | 4877 surface_no_scale->AddChild(surface_no_scale_child_no_scale); |
4914 | 4878 |
4915 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 4879 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
4916 host->SetRootLayer(root); | 4880 host->SetRootLayer(root); |
4917 | 4881 |
4918 SkMScalar device_scale_factor = 5; | 4882 SkMScalar device_scale_factor = 5; |
4919 SkMScalar page_scale_factor = 7; | 4883 SkMScalar page_scale_factor = 7; |
4920 | 4884 |
4921 RenderSurfaceLayerList render_surface_layer_list; | 4885 RenderSurfaceLayerList render_surface_layer_list; |
4922 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 4886 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
4923 root.get(), | 4887 root.get(), root->bounds(), &render_surface_layer_list); |
4924 gfx::ToCeiledSize(root->bounds()), | |
4925 &render_surface_layer_list); | |
4926 inputs.device_scale_factor = device_scale_factor; | 4888 inputs.device_scale_factor = device_scale_factor; |
4927 inputs.page_scale_factor = page_scale_factor; | 4889 inputs.page_scale_factor = page_scale_factor; |
4928 inputs.page_scale_application_layer = root.get(); | 4890 inputs.page_scale_application_layer = root.get(); |
4929 inputs.can_adjust_raster_scales = true; | 4891 inputs.can_adjust_raster_scales = true; |
4930 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4892 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
4931 | 4893 |
4932 EXPECT_CONTENTS_SCALE_EQ( | 4894 EXPECT_CONTENTS_SCALE_EQ( |
4933 device_scale_factor * page_scale_factor * initial_parent_scale, parent); | 4895 device_scale_factor * page_scale_factor * initial_parent_scale, parent); |
4934 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 4896 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
4935 initial_parent_scale * initial_child_scale, | 4897 initial_parent_scale * initial_child_scale, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5116 surface_no_scale->AddChild(surface_no_scale_child_no_scale); | 5078 surface_no_scale->AddChild(surface_no_scale_child_no_scale); |
5117 | 5079 |
5118 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 5080 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
5119 host->SetRootLayer(root); | 5081 host->SetRootLayer(root); |
5120 | 5082 |
5121 RenderSurfaceLayerList render_surface_layer_list; | 5083 RenderSurfaceLayerList render_surface_layer_list; |
5122 | 5084 |
5123 SkMScalar device_scale_factor = 5.0; | 5085 SkMScalar device_scale_factor = 5.0; |
5124 SkMScalar page_scale_factor = 7.0; | 5086 SkMScalar page_scale_factor = 7.0; |
5125 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 5087 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
5126 root.get(), | 5088 root.get(), root->bounds(), &render_surface_layer_list); |
5127 gfx::ToCeiledSize(root->bounds()), | |
5128 &render_surface_layer_list); | |
5129 inputs.device_scale_factor = device_scale_factor; | 5089 inputs.device_scale_factor = device_scale_factor; |
5130 inputs.page_scale_factor = page_scale_factor; | 5090 inputs.page_scale_factor = page_scale_factor; |
5131 inputs.page_scale_application_layer = root.get(); | 5091 inputs.page_scale_application_layer = root.get(); |
5132 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5092 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5133 | 5093 |
5134 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 5094 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
5135 parent); | 5095 parent); |
5136 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 5096 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
5137 surface_scale); | 5097 surface_scale); |
5138 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale); | 5098 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5263 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 5223 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
5264 host->SetRootLayer(root); | 5224 host->SetRootLayer(root); |
5265 | 5225 |
5266 // Now put an animating transform on child. | 5226 // Now put an animating transform on child. |
5267 int animation_id = AddAnimatedTransformToController( | 5227 int animation_id = AddAnimatedTransformToController( |
5268 child_scale->layer_animation_controller(), 10.0, 30, 0); | 5228 child_scale->layer_animation_controller(), 10.0, 30, 0); |
5269 | 5229 |
5270 { | 5230 { |
5271 RenderSurfaceLayerList render_surface_layer_list; | 5231 RenderSurfaceLayerList render_surface_layer_list; |
5272 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 5232 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
5273 root.get(), | 5233 root.get(), root->bounds(), &render_surface_layer_list); |
5274 gfx::ToCeiledSize(root->bounds()), | |
5275 &render_surface_layer_list); | |
5276 inputs.can_adjust_raster_scales = true; | 5234 inputs.can_adjust_raster_scales = true; |
5277 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5235 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5278 | 5236 |
5279 EXPECT_CONTENTS_SCALE_EQ(initial_parent_scale, parent); | 5237 EXPECT_CONTENTS_SCALE_EQ(initial_parent_scale, parent); |
5280 // The layers with animating transforms should not compute a contents scale | 5238 // The layers with animating transforms should not compute a contents scale |
5281 // other than 1 until they finish animating. | 5239 // other than 1 until they finish animating. |
5282 EXPECT_CONTENTS_SCALE_EQ(1, child_scale); | 5240 EXPECT_CONTENTS_SCALE_EQ(1, child_scale); |
5283 } | 5241 } |
5284 | 5242 |
5285 // Remove the animation, now it can save a raster scale. | 5243 // Remove the animation, now it can save a raster scale. |
5286 child_scale->layer_animation_controller()->RemoveAnimation(animation_id); | 5244 child_scale->layer_animation_controller()->RemoveAnimation(animation_id); |
5287 | 5245 |
5288 { | 5246 { |
5289 RenderSurfaceLayerList render_surface_layer_list; | 5247 RenderSurfaceLayerList render_surface_layer_list; |
5290 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 5248 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
5291 root.get(), | 5249 root.get(), root->bounds(), &render_surface_layer_list); |
5292 gfx::ToCeiledSize(root->bounds()), | |
5293 &render_surface_layer_list); | |
5294 inputs.can_adjust_raster_scales = true; | 5250 inputs.can_adjust_raster_scales = true; |
5295 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5251 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5296 | 5252 |
5297 EXPECT_CONTENTS_SCALE_EQ(initial_parent_scale, parent); | 5253 EXPECT_CONTENTS_SCALE_EQ(initial_parent_scale, parent); |
5298 // The layers with animating transforms should not compute a contents scale | 5254 // The layers with animating transforms should not compute a contents scale |
5299 // other than 1 until they finish animating. | 5255 // other than 1 until they finish animating. |
5300 EXPECT_CONTENTS_SCALE_EQ(initial_parent_scale * initial_child_scale, | 5256 EXPECT_CONTENTS_SCALE_EQ(initial_parent_scale * initial_child_scale, |
5301 child_scale); | 5257 child_scale); |
5302 } | 5258 } |
5303 } | 5259 } |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5694 child->SetOpacity(0.0f); | 5650 child->SetOpacity(0.0f); |
5695 | 5651 |
5696 // Add opacity animation. | 5652 // Add opacity animation. |
5697 AddOpacityTransitionToController( | 5653 AddOpacityTransitionToController( |
5698 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false); | 5654 child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false); |
5699 | 5655 |
5700 root->AddChild(child.Pass()); | 5656 root->AddChild(child.Pass()); |
5701 | 5657 |
5702 LayerImplList render_surface_layer_list; | 5658 LayerImplList render_surface_layer_list; |
5703 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5659 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5704 root.get(), | 5660 root.get(), root->bounds(), &render_surface_layer_list); |
5705 gfx::ToCeiledSize(root->bounds()), | |
5706 &render_surface_layer_list); | |
5707 inputs.can_adjust_raster_scales = true; | 5661 inputs.can_adjust_raster_scales = true; |
5708 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5662 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5709 | 5663 |
5710 // We should have one render surface and two layers. The child | 5664 // We should have one render surface and two layers. The child |
5711 // layer should be included even though it is transparent. | 5665 // layer should be included even though it is transparent. |
5712 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5666 ASSERT_EQ(1u, render_surface_layer_list.size()); |
5713 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5667 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
5714 } | 5668 } |
5715 | 5669 |
5716 typedef std::tr1::tuple<bool, bool> LCDTextTestParam; | 5670 typedef std::tr1::tuple<bool, bool> LCDTextTestParam; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5906 grand_child->SetHideLayerAndSubtree(true); | 5860 grand_child->SetHideLayerAndSubtree(true); |
5907 | 5861 |
5908 child->AddChild(grand_child); | 5862 child->AddChild(grand_child); |
5909 root->AddChild(child); | 5863 root->AddChild(child); |
5910 | 5864 |
5911 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 5865 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
5912 host->SetRootLayer(root); | 5866 host->SetRootLayer(root); |
5913 | 5867 |
5914 RenderSurfaceLayerList render_surface_layer_list; | 5868 RenderSurfaceLayerList render_surface_layer_list; |
5915 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 5869 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
5916 root.get(), | 5870 root.get(), root->bounds(), &render_surface_layer_list); |
5917 gfx::ToCeiledSize(root->bounds()), | |
5918 &render_surface_layer_list); | |
5919 inputs.can_adjust_raster_scales = true; | 5871 inputs.can_adjust_raster_scales = true; |
5920 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5872 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5921 | 5873 |
5922 // We should have one render surface and two layers. The grand child has | 5874 // We should have one render surface and two layers. The grand child has |
5923 // hidden itself. | 5875 // hidden itself. |
5924 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5876 ASSERT_EQ(1u, render_surface_layer_list.size()); |
5925 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5877 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
5926 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 5878 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); |
5927 EXPECT_EQ(child->id(), root->render_surface()->layer_list().at(1)->id()); | 5879 EXPECT_EQ(child->id(), root->render_surface()->layer_list().at(1)->id()); |
5928 } | 5880 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5964 true, | 5916 true, |
5965 false); | 5917 false); |
5966 grand_child->SetDrawsContent(true); | 5918 grand_child->SetDrawsContent(true); |
5967 grand_child->SetHideLayerAndSubtree(true); | 5919 grand_child->SetHideLayerAndSubtree(true); |
5968 | 5920 |
5969 child->AddChild(grand_child.Pass()); | 5921 child->AddChild(grand_child.Pass()); |
5970 root->AddChild(child.Pass()); | 5922 root->AddChild(child.Pass()); |
5971 | 5923 |
5972 LayerImplList render_surface_layer_list; | 5924 LayerImplList render_surface_layer_list; |
5973 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5925 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5974 root.get(), | 5926 root.get(), root->bounds(), &render_surface_layer_list); |
5975 gfx::ToCeiledSize(root->bounds()), | |
5976 &render_surface_layer_list); | |
5977 inputs.can_adjust_raster_scales = true; | 5927 inputs.can_adjust_raster_scales = true; |
5978 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5928 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5979 | 5929 |
5980 // We should have one render surface and two layers. The grand child has | 5930 // We should have one render surface and two layers. The grand child has |
5981 // hidden itself. | 5931 // hidden itself. |
5982 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5932 ASSERT_EQ(1u, render_surface_layer_list.size()); |
5983 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5933 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
5984 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); | 5934 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); |
5985 EXPECT_EQ(2, root->render_surface()->layer_list().at(1)->id()); | 5935 EXPECT_EQ(2, root->render_surface()->layer_list().at(1)->id()); |
5986 } | 5936 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6024 grand_child->SetIsDrawable(true); | 5974 grand_child->SetIsDrawable(true); |
6025 | 5975 |
6026 child->AddChild(grand_child); | 5976 child->AddChild(grand_child); |
6027 root->AddChild(child); | 5977 root->AddChild(child); |
6028 | 5978 |
6029 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 5979 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
6030 host->SetRootLayer(root); | 5980 host->SetRootLayer(root); |
6031 | 5981 |
6032 RenderSurfaceLayerList render_surface_layer_list; | 5982 RenderSurfaceLayerList render_surface_layer_list; |
6033 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 5983 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
6034 root.get(), | 5984 root.get(), root->bounds(), &render_surface_layer_list); |
6035 gfx::ToCeiledSize(root->bounds()), | |
6036 &render_surface_layer_list); | |
6037 inputs.can_adjust_raster_scales = true; | 5985 inputs.can_adjust_raster_scales = true; |
6038 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5986 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6039 | 5987 |
6040 // We should have one render surface and one layers. The child has | 5988 // We should have one render surface and one layers. The child has |
6041 // hidden itself and the grand child. | 5989 // hidden itself and the grand child. |
6042 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5990 ASSERT_EQ(1u, render_surface_layer_list.size()); |
6043 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5991 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
6044 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 5992 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); |
6045 } | 5993 } |
6046 | 5994 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6081 gfx::Size(30, 30), | 6029 gfx::Size(30, 30), |
6082 true, | 6030 true, |
6083 false); | 6031 false); |
6084 grand_child->SetDrawsContent(true); | 6032 grand_child->SetDrawsContent(true); |
6085 | 6033 |
6086 child->AddChild(grand_child.Pass()); | 6034 child->AddChild(grand_child.Pass()); |
6087 root->AddChild(child.Pass()); | 6035 root->AddChild(child.Pass()); |
6088 | 6036 |
6089 LayerImplList render_surface_layer_list; | 6037 LayerImplList render_surface_layer_list; |
6090 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6038 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
6091 root.get(), | 6039 root.get(), root->bounds(), &render_surface_layer_list); |
6092 gfx::ToCeiledSize(root->bounds()), | |
6093 &render_surface_layer_list); | |
6094 inputs.can_adjust_raster_scales = true; | 6040 inputs.can_adjust_raster_scales = true; |
6095 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6041 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6096 | 6042 |
6097 // We should have one render surface and one layers. The child has | 6043 // We should have one render surface and one layers. The child has |
6098 // hidden itself and the grand child. | 6044 // hidden itself and the grand child. |
6099 ASSERT_EQ(1u, render_surface_layer_list.size()); | 6045 ASSERT_EQ(1u, render_surface_layer_list.size()); |
6100 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 6046 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
6101 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); | 6047 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); |
6102 } | 6048 } |
6103 | 6049 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6195 // hidden subtree on copy_layer. | 6141 // hidden subtree on copy_layer. |
6196 copy_grand_parent->SetHideLayerAndSubtree(true); | 6142 copy_grand_parent->SetHideLayerAndSubtree(true); |
6197 copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true); | 6143 copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true); |
6198 copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true); | 6144 copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true); |
6199 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest( | 6145 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest( |
6200 base::Bind(&EmptyCopyOutputCallback))); | 6146 base::Bind(&EmptyCopyOutputCallback))); |
6201 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 6147 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
6202 | 6148 |
6203 RenderSurfaceLayerList render_surface_layer_list; | 6149 RenderSurfaceLayerList render_surface_layer_list; |
6204 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 6150 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
6205 root.get(), | 6151 root.get(), root->bounds(), &render_surface_layer_list); |
6206 gfx::ToCeiledSize(root->bounds()), | |
6207 &render_surface_layer_list); | |
6208 inputs.can_adjust_raster_scales = true; | 6152 inputs.can_adjust_raster_scales = true; |
6209 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6153 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6210 | 6154 |
6211 EXPECT_TRUE(root->draw_properties().layer_or_descendant_has_copy_request); | 6155 EXPECT_TRUE(root->draw_properties().layer_or_descendant_has_copy_request); |
6212 EXPECT_TRUE(copy_grand_parent->draw_properties(). | 6156 EXPECT_TRUE(copy_grand_parent->draw_properties(). |
6213 layer_or_descendant_has_copy_request); | 6157 layer_or_descendant_has_copy_request); |
6214 EXPECT_TRUE(copy_parent->draw_properties(). | 6158 EXPECT_TRUE(copy_parent->draw_properties(). |
6215 layer_or_descendant_has_copy_request); | 6159 layer_or_descendant_has_copy_request); |
6216 EXPECT_TRUE(copy_layer->draw_properties(). | 6160 EXPECT_TRUE(copy_layer->draw_properties(). |
6217 layer_or_descendant_has_copy_request); | 6161 layer_or_descendant_has_copy_request); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6306 | 6250 |
6307 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 6251 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
6308 host->SetRootLayer(root); | 6252 host->SetRootLayer(root); |
6309 | 6253 |
6310 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest( | 6254 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest( |
6311 base::Bind(&EmptyCopyOutputCallback))); | 6255 base::Bind(&EmptyCopyOutputCallback))); |
6312 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 6256 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
6313 | 6257 |
6314 RenderSurfaceLayerList render_surface_layer_list; | 6258 RenderSurfaceLayerList render_surface_layer_list; |
6315 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 6259 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
6316 root.get(), | 6260 root.get(), root->bounds(), &render_surface_layer_list); |
6317 gfx::ToCeiledSize(root->bounds()), | |
6318 &render_surface_layer_list); | |
6319 inputs.can_adjust_raster_scales = true; | 6261 inputs.can_adjust_raster_scales = true; |
6320 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6262 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6321 | 6263 |
6322 // We should have one render surface, as the others are clipped out. | 6264 // We should have one render surface, as the others are clipped out. |
6323 ASSERT_EQ(1u, render_surface_layer_list.size()); | 6265 ASSERT_EQ(1u, render_surface_layer_list.size()); |
6324 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 6266 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); |
6325 | 6267 |
6326 // The root render surface should only have 1 contributing layer, since the | 6268 // The root render surface should only have 1 contributing layer, since the |
6327 // other layers are empty/clipped away. | 6269 // other layers are empty/clipped away. |
6328 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 6270 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6368 surface_child->SetIsDrawable(true); | 6310 surface_child->SetIsDrawable(true); |
6369 | 6311 |
6370 surface->AddChild(surface_child); | 6312 surface->AddChild(surface_child); |
6371 root->AddChild(surface); | 6313 root->AddChild(surface); |
6372 | 6314 |
6373 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 6315 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
6374 host->SetRootLayer(root); | 6316 host->SetRootLayer(root); |
6375 | 6317 |
6376 RenderSurfaceLayerList render_surface_layer_list; | 6318 RenderSurfaceLayerList render_surface_layer_list; |
6377 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 6319 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
6378 root.get(), | 6320 root.get(), root->bounds(), &render_surface_layer_list); |
6379 gfx::ToCeiledSize(root->bounds()), | |
6380 &render_surface_layer_list); | |
6381 inputs.can_adjust_raster_scales = true; | 6321 inputs.can_adjust_raster_scales = true; |
6382 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6322 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6383 | 6323 |
6384 // The visible_content_rect for the |surface_child| should not be clipped by | 6324 // The visible_content_rect for the |surface_child| should not be clipped by |
6385 // the viewport. | 6325 // the viewport. |
6386 EXPECT_EQ(gfx::Rect(50, 50).ToString(), | 6326 EXPECT_EQ(gfx::Rect(50, 50).ToString(), |
6387 surface_child->visible_content_rect().ToString()); | 6327 surface_child->visible_content_rect().ToString()); |
6388 } | 6328 } |
6389 | 6329 |
6390 TEST_F(LayerTreeHostCommonTest, TransformedClipParent) { | 6330 TEST_F(LayerTreeHostCommonTest, TransformedClipParent) { |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6999 child3->Set3dSortingContextId(1); | 6939 child3->Set3dSortingContextId(1); |
7000 | 6940 |
7001 child2->AddChild(child3.Pass()); | 6941 child2->AddChild(child3.Pass()); |
7002 child1->AddChild(child2.Pass()); | 6942 child1->AddChild(child2.Pass()); |
7003 root->AddChild(child1.Pass()); | 6943 root->AddChild(child1.Pass()); |
7004 | 6944 |
7005 { | 6945 { |
7006 LayerImplList render_surface_layer_list; | 6946 LayerImplList render_surface_layer_list; |
7007 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root.get()); | 6947 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root.get()); |
7008 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6948 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7009 root.get(), | 6949 root.get(), root->bounds(), &render_surface_layer_list); |
7010 gfx::ToCeiledSize(root->bounds()), | |
7011 &render_surface_layer_list); | |
7012 inputs.can_render_to_separate_surface = true; | 6950 inputs.can_render_to_separate_surface = true; |
7013 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6951 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7014 | 6952 |
7015 EXPECT_EQ(2u, render_surface_layer_list.size()); | 6953 EXPECT_EQ(2u, render_surface_layer_list.size()); |
7016 } | 6954 } |
7017 | 6955 |
7018 { | 6956 { |
7019 LayerImplList render_surface_layer_list; | 6957 LayerImplList render_surface_layer_list; |
7020 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6958 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7021 root.get(), | 6959 root.get(), root->bounds(), &render_surface_layer_list); |
7022 gfx::ToCeiledSize(root->bounds()), | |
7023 &render_surface_layer_list); | |
7024 inputs.can_render_to_separate_surface = false; | 6960 inputs.can_render_to_separate_surface = false; |
7025 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6961 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7026 | 6962 |
7027 EXPECT_EQ(1u, render_surface_layer_list.size()); | 6963 EXPECT_EQ(1u, render_surface_layer_list.size()); |
7028 } | 6964 } |
7029 } | 6965 } |
7030 | 6966 |
7031 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { | 6967 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { |
7032 scoped_refptr<Layer> root = Layer::Create(); | 6968 scoped_refptr<Layer> root = Layer::Create(); |
7033 scoped_refptr<Layer> render_surface = Layer::Create(); | 6969 scoped_refptr<Layer> render_surface = Layer::Create(); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7558 gfx::Size(50, 50), | 7494 gfx::Size(50, 50), |
7559 true, | 7495 true, |
7560 false); | 7496 false); |
7561 | 7497 |
7562 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 7498 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
7563 host->SetRootLayer(root); | 7499 host->SetRootLayer(root); |
7564 | 7500 |
7565 RenderSurfaceLayerList render_surface_layer_list; | 7501 RenderSurfaceLayerList render_surface_layer_list; |
7566 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 7502 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
7567 root.get(), | 7503 root.get(), |
7568 gfx::ToCeiledSize(root->bounds()), | 7504 root->bounds(), |
7569 identity_transform, | 7505 identity_transform, |
7570 &render_surface_layer_list); | 7506 &render_surface_layer_list); |
7571 | 7507 |
7572 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7508 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7573 | 7509 |
7574 EXPECT_TRUE(root->render_surface()); | 7510 EXPECT_TRUE(root->render_surface()); |
7575 | 7511 |
7576 EXPECT_EQ(gfx::Rect(0, 0, 20, 20).ToString(), | 7512 EXPECT_EQ(gfx::Rect(0, 0, 20, 20).ToString(), |
7577 scroll_child->clip_rect().ToString()); | 7513 scroll_child->clip_rect().ToString()); |
7578 EXPECT_TRUE(scroll_child->is_clipped()); | 7514 EXPECT_TRUE(scroll_child->is_clipped()); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7694 scroll_child->AddChild(top_content.Pass()); | 7630 scroll_child->AddChild(top_content.Pass()); |
7695 scroll_child->AddChild(bottom_content.Pass()); | 7631 scroll_child->AddChild(bottom_content.Pass()); |
7696 root->AddChild(scroll_child.Pass()); | 7632 root->AddChild(scroll_child.Pass()); |
7697 | 7633 |
7698 scroll_parent_clip->AddChild(scroll_parent.Pass()); | 7634 scroll_parent_clip->AddChild(scroll_parent.Pass()); |
7699 scroll_parent_border->AddChild(scroll_parent_clip.Pass()); | 7635 scroll_parent_border->AddChild(scroll_parent_clip.Pass()); |
7700 root->AddChild(scroll_parent_border.Pass()); | 7636 root->AddChild(scroll_parent_border.Pass()); |
7701 | 7637 |
7702 LayerImplList render_surface_layer_list; | 7638 LayerImplList render_surface_layer_list; |
7703 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7639 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7704 root.get(), | 7640 root.get(), root->bounds(), &render_surface_layer_list); |
7705 gfx::ToCeiledSize(root->bounds()), | |
7706 &render_surface_layer_list); | |
7707 | 7641 |
7708 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7642 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7709 | 7643 |
7710 EXPECT_TRUE(root->render_surface()); | 7644 EXPECT_TRUE(root->render_surface()); |
7711 | 7645 |
7712 // If we don't sort by depth and let the layers get added in the order they | 7646 // If we don't sort by depth and let the layers get added in the order they |
7713 // would normally be visited in, then layers 6 and 7 will be out of order. In | 7647 // would normally be visited in, then layers 6 and 7 will be out of order. In |
7714 // other words, although we've had to shift 5, 6, and 7 to appear before 4 | 7648 // other words, although we've had to shift 5, 6, and 7 to appear before 4 |
7715 // in the list (because of the scroll parent relationship), this should not | 7649 // in the list (because of the scroll parent relationship), this should not |
7716 // have an effect on the the order of 5, 6, and 7 (which had been reordered | 7650 // have an effect on the the order of 5, 6, and 7 (which had been reordered |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7791 container->AddChild(scroller.Pass()); | 7725 container->AddChild(scroller.Pass()); |
7792 root->AddChild(container.Pass()); | 7726 root->AddChild(container.Pass()); |
7793 | 7727 |
7794 // Rounded to integers already. | 7728 // Rounded to integers already. |
7795 { | 7729 { |
7796 gfx::Vector2dF scroll_delta(3.0, 5.0); | 7730 gfx::Vector2dF scroll_delta(3.0, 5.0); |
7797 scroll_layer->SetScrollDelta(scroll_delta); | 7731 scroll_layer->SetScrollDelta(scroll_delta); |
7798 | 7732 |
7799 LayerImplList render_surface_layer_list; | 7733 LayerImplList render_surface_layer_list; |
7800 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7734 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7801 root.get(), | 7735 root.get(), root->bounds(), &render_surface_layer_list); |
7802 gfx::ToCeiledSize(root->bounds()), | |
7803 &render_surface_layer_list); | |
7804 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7736 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7805 | 7737 |
7806 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7738 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7807 container_layer->draw_properties().screen_space_transform, | 7739 container_layer->draw_properties().screen_space_transform, |
7808 fixed_layer->draw_properties().screen_space_transform); | 7740 fixed_layer->draw_properties().screen_space_transform); |
7809 EXPECT_VECTOR_EQ( | 7741 EXPECT_VECTOR_EQ( |
7810 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7742 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7811 container_offset); | 7743 container_offset); |
7812 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() | 7744 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() |
7813 .screen_space_transform.To2dTranslation(), | 7745 .screen_space_transform.To2dTranslation(), |
7814 container_offset - scroll_delta); | 7746 container_offset - scroll_delta); |
7815 } | 7747 } |
7816 | 7748 |
7817 // Scroll delta requiring rounding. | 7749 // Scroll delta requiring rounding. |
7818 { | 7750 { |
7819 gfx::Vector2dF scroll_delta(4.1f, 8.1f); | 7751 gfx::Vector2dF scroll_delta(4.1f, 8.1f); |
7820 scroll_layer->SetScrollDelta(scroll_delta); | 7752 scroll_layer->SetScrollDelta(scroll_delta); |
7821 | 7753 |
7822 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); | 7754 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); |
7823 | 7755 |
7824 LayerImplList render_surface_layer_list; | 7756 LayerImplList render_surface_layer_list; |
7825 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7757 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7826 root.get(), | 7758 root.get(), root->bounds(), &render_surface_layer_list); |
7827 gfx::ToCeiledSize(root->bounds()), | |
7828 &render_surface_layer_list); | |
7829 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7759 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7830 | 7760 |
7831 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7761 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7832 container_layer->draw_properties().screen_space_transform, | 7762 container_layer->draw_properties().screen_space_transform, |
7833 fixed_layer->draw_properties().screen_space_transform); | 7763 fixed_layer->draw_properties().screen_space_transform); |
7834 EXPECT_VECTOR_EQ( | 7764 EXPECT_VECTOR_EQ( |
7835 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7765 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7836 container_offset); | 7766 container_offset); |
7837 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() | 7767 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() |
7838 .screen_space_transform.To2dTranslation(), | 7768 .screen_space_transform.To2dTranslation(), |
7839 container_offset - rounded_scroll_delta); | 7769 container_offset - rounded_scroll_delta); |
7840 } | 7770 } |
7841 | 7771 |
7842 // Scale is applied earlier in the tree. | 7772 // Scale is applied earlier in the tree. |
7843 { | 7773 { |
7844 gfx::Transform scaled_container_transform = container_transform; | 7774 gfx::Transform scaled_container_transform = container_transform; |
7845 scaled_container_transform.Scale3d(3.0, 3.0, 1.0); | 7775 scaled_container_transform.Scale3d(3.0, 3.0, 1.0); |
7846 container_layer->SetTransform(scaled_container_transform); | 7776 container_layer->SetTransform(scaled_container_transform); |
7847 | 7777 |
7848 gfx::Vector2dF scroll_delta(4.5f, 8.5f); | 7778 gfx::Vector2dF scroll_delta(4.5f, 8.5f); |
7849 scroll_layer->SetScrollDelta(scroll_delta); | 7779 scroll_layer->SetScrollDelta(scroll_delta); |
7850 | 7780 |
7851 LayerImplList render_surface_layer_list; | 7781 LayerImplList render_surface_layer_list; |
7852 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7782 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7853 root.get(), | 7783 root.get(), root->bounds(), &render_surface_layer_list); |
7854 gfx::ToCeiledSize(root->bounds()), | |
7855 &render_surface_layer_list); | |
7856 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7784 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7857 | 7785 |
7858 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7786 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7859 container_layer->draw_properties().screen_space_transform, | 7787 container_layer->draw_properties().screen_space_transform, |
7860 fixed_layer->draw_properties().screen_space_transform); | 7788 fixed_layer->draw_properties().screen_space_transform); |
7861 EXPECT_VECTOR_EQ( | 7789 EXPECT_VECTOR_EQ( |
7862 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7790 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7863 container_offset); | 7791 container_offset); |
7864 | 7792 |
7865 container_layer->SetTransform(container_transform); | 7793 container_layer->SetTransform(container_transform); |
7866 } | 7794 } |
7867 | 7795 |
7868 // Scale is applied on the scroll layer itself. | 7796 // Scale is applied on the scroll layer itself. |
7869 { | 7797 { |
7870 gfx::Transform scale_transform; | 7798 gfx::Transform scale_transform; |
7871 scale_transform.Scale3d(3.0, 3.0, 1.0); | 7799 scale_transform.Scale3d(3.0, 3.0, 1.0); |
7872 scroll_layer->SetTransform(scale_transform); | 7800 scroll_layer->SetTransform(scale_transform); |
7873 | 7801 |
7874 gfx::Vector2dF scroll_delta(4.5f, 8.5f); | 7802 gfx::Vector2dF scroll_delta(4.5f, 8.5f); |
7875 scroll_layer->SetScrollDelta(scroll_delta); | 7803 scroll_layer->SetScrollDelta(scroll_delta); |
7876 | 7804 |
7877 LayerImplList render_surface_layer_list; | 7805 LayerImplList render_surface_layer_list; |
7878 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7806 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7879 root.get(), | 7807 root.get(), root->bounds(), &render_surface_layer_list); |
7880 gfx::ToCeiledSize(root->bounds()), | |
7881 &render_surface_layer_list); | |
7882 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7808 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7883 | 7809 |
7884 EXPECT_VECTOR_EQ( | 7810 EXPECT_VECTOR_EQ( |
7885 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7811 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7886 container_offset); | 7812 container_offset); |
7887 | 7813 |
7888 scroll_layer->SetTransform(identity_transform); | 7814 scroll_layer->SetTransform(identity_transform); |
7889 } | 7815 } |
7890 } | 7816 } |
7891 | 7817 |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8684 // by the viewport. | 8610 // by the viewport. |
8685 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); | 8611 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); |
8686 | 8612 |
8687 // Layers drawing to a child render surface should still have their visible | 8613 // Layers drawing to a child render surface should still have their visible |
8688 // content rect clipped by the viewport. | 8614 // content rect clipped by the viewport. |
8689 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); | 8615 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); |
8690 } | 8616 } |
8691 | 8617 |
8692 } // namespace | 8618 } // namespace |
8693 } // namespace cc | 8619 } // namespace cc |
OLD | NEW |