| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 false); | 338 false); |
| 339 scoped_ptr<LayerImpl> clip_layer_scoped_ptr( | 339 scoped_ptr<LayerImpl> clip_layer_scoped_ptr( |
| 340 LayerImpl::Create(host_impl.active_tree(), 4)); | 340 LayerImpl::Create(host_impl.active_tree(), 4)); |
| 341 LayerImpl* clip_layer = clip_layer_scoped_ptr.get(); | 341 LayerImpl* clip_layer = clip_layer_scoped_ptr.get(); |
| 342 | 342 |
| 343 scroll_layer->SetScrollClipLayer(clip_layer->id()); | 343 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
| 344 clip_layer->SetBounds( | 344 clip_layer->SetBounds( |
| 345 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(), | 345 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(), |
| 346 scroll_layer->bounds().height() + kMaxScrollOffset.y())); | 346 scroll_layer->bounds().height() + kMaxScrollOffset.y())); |
| 347 scroll_layer->SetScrollClipLayer(clip_layer->id()); | 347 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
| 348 scroll_layer->SetScrollDelta(kScrollDelta); | 348 SetScrollOffsetDelta(scroll_layer, kScrollDelta); |
| 349 gfx::Transform impl_transform; | 349 gfx::Transform impl_transform; |
| 350 scroll_layer->AddChild(std::move(sublayer_scoped_ptr)); | 350 scroll_layer->AddChild(std::move(sublayer_scoped_ptr)); |
| 351 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get(); | 351 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get(); |
| 352 clip_layer->AddChild(std::move(scroll_layer_scoped_ptr)); | 352 clip_layer->AddChild(std::move(scroll_layer_scoped_ptr)); |
| 353 scroll_layer_raw_ptr->PushScrollOffsetFromMainThread(kScrollOffset); | 353 scroll_layer_raw_ptr->layer_tree_impl() |
| 354 ->property_trees() |
| 355 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer_raw_ptr->id(), |
| 356 kScrollOffset); |
| 354 | 357 |
| 355 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); | 358 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); |
| 356 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 359 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 357 gfx::PointF(), gfx::Size(3, 4), true, false, | 360 gfx::PointF(), gfx::Size(3, 4), true, false, |
| 358 false); | 361 false); |
| 359 root->AddChild(std::move(clip_layer_scoped_ptr)); | 362 root->AddChild(std::move(clip_layer_scoped_ptr)); |
| 360 root->SetHasRenderSurface(true); | 363 root->SetHasRenderSurface(true); |
| 361 | 364 |
| 362 ExecuteCalculateDrawProperties( | 365 ExecuteCalculateDrawProperties( |
| 363 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); | 366 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); |
| (...skipping 6789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7153 container->SetDrawsContent(true); | 7156 container->SetDrawsContent(true); |
| 7154 scroller->SetDrawsContent(true); | 7157 scroller->SetDrawsContent(true); |
| 7155 fixed->SetDrawsContent(true); | 7158 fixed->SetDrawsContent(true); |
| 7156 scroller->AddChild(std::move(fixed)); | 7159 scroller->AddChild(std::move(fixed)); |
| 7157 container->AddChild(std::move(scroller)); | 7160 container->AddChild(std::move(scroller)); |
| 7158 root->AddChild(std::move(container)); | 7161 root->AddChild(std::move(container)); |
| 7159 | 7162 |
| 7160 // Rounded to integers already. | 7163 // Rounded to integers already. |
| 7161 { | 7164 { |
| 7162 gfx::Vector2dF scroll_delta(3.0, 5.0); | 7165 gfx::Vector2dF scroll_delta(3.0, 5.0); |
| 7163 scroll_layer->SetScrollDelta(scroll_delta); | 7166 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
| 7164 | 7167 |
| 7165 LayerImplList render_surface_layer_list; | 7168 LayerImplList render_surface_layer_list; |
| 7166 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 7169 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 7167 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7170 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 7168 root.get(), root->bounds(), &render_surface_layer_list, | 7171 root.get(), root->bounds(), &render_surface_layer_list, |
| 7169 root->layer_tree_impl()->current_render_surface_list_id()); | 7172 root->layer_tree_impl()->current_render_surface_list_id()); |
| 7170 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7173 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 7171 | 7174 |
| 7172 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7175 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 7173 container_layer->draw_properties().screen_space_transform, | 7176 container_layer->draw_properties().screen_space_transform, |
| 7174 fixed_layer->draw_properties().screen_space_transform); | 7177 fixed_layer->draw_properties().screen_space_transform); |
| 7175 EXPECT_VECTOR_EQ( | 7178 EXPECT_VECTOR_EQ( |
| 7176 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7179 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
| 7177 container_offset); | 7180 container_offset); |
| 7178 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() | 7181 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() |
| 7179 .screen_space_transform.To2dTranslation(), | 7182 .screen_space_transform.To2dTranslation(), |
| 7180 container_offset - scroll_delta); | 7183 container_offset - scroll_delta); |
| 7181 } | 7184 } |
| 7182 | 7185 |
| 7183 // Scroll delta requiring rounding. | 7186 // Scroll delta requiring rounding. |
| 7184 { | 7187 { |
| 7185 gfx::Vector2dF scroll_delta(4.1f, 8.1f); | 7188 gfx::Vector2dF scroll_delta(4.1f, 8.1f); |
| 7186 scroll_layer->SetScrollDelta(scroll_delta); | 7189 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
| 7187 | 7190 |
| 7188 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); | 7191 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); |
| 7189 | 7192 |
| 7190 LayerImplList render_surface_layer_list; | 7193 LayerImplList render_surface_layer_list; |
| 7191 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 7194 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 7192 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7195 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 7193 root.get(), root->bounds(), &render_surface_layer_list, | 7196 root.get(), root->bounds(), &render_surface_layer_list, |
| 7194 root->layer_tree_impl()->current_render_surface_list_id()); | 7197 root->layer_tree_impl()->current_render_surface_list_id()); |
| 7195 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7198 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 7196 | 7199 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7209 { | 7212 { |
| 7210 gfx::Transform scaled_container_transform = container_transform; | 7213 gfx::Transform scaled_container_transform = container_transform; |
| 7211 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); | 7214 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); |
| 7212 container_layer->SetTransform(scaled_container_transform); | 7215 container_layer->SetTransform(scaled_container_transform); |
| 7213 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7216 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7214 root->layer_tree_impl() | 7217 root->layer_tree_impl() |
| 7215 ->property_trees() | 7218 ->property_trees() |
| 7216 ->transform_tree.set_source_to_parent_updates_allowed(true); | 7219 ->transform_tree.set_source_to_parent_updates_allowed(true); |
| 7217 | 7220 |
| 7218 gfx::Vector2dF scroll_delta(4.5f, 8.5f); | 7221 gfx::Vector2dF scroll_delta(4.5f, 8.5f); |
| 7219 scroll_layer->SetScrollDelta(scroll_delta); | 7222 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
| 7220 | 7223 |
| 7221 LayerImplList render_surface_layer_list; | 7224 LayerImplList render_surface_layer_list; |
| 7222 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 7225 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 7223 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7226 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 7224 root.get(), root->bounds(), &render_surface_layer_list, | 7227 root.get(), root->bounds(), &render_surface_layer_list, |
| 7225 root->layer_tree_impl()->current_render_surface_list_id()); | 7228 root->layer_tree_impl()->current_render_surface_list_id()); |
| 7226 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7229 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 7227 | 7230 |
| 7228 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7231 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 7229 container_layer->draw_properties().screen_space_transform, | 7232 container_layer->draw_properties().screen_space_transform, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7289 gfx::Size(30, 30), true, false, false); | 7292 gfx::Size(30, 30), true, false, false); |
| 7290 | 7293 |
| 7291 gfx::ScrollOffset scroll_offset(3.3, 4.2); | 7294 gfx::ScrollOffset scroll_offset(3.3, 4.2); |
| 7292 gfx::Vector2dF main_scroll_fractional_part(0.3f, 0.2f); | 7295 gfx::Vector2dF main_scroll_fractional_part(0.3f, 0.2f); |
| 7293 gfx::Vector2dF scroll_delta(0.1f, 0.4f); | 7296 gfx::Vector2dF scroll_delta(0.1f, 0.4f); |
| 7294 // Blink only uses the integer part of the scroll_offset for fixed | 7297 // Blink only uses the integer part of the scroll_offset for fixed |
| 7295 // position layer. | 7298 // position layer. |
| 7296 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(), | 7299 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(), |
| 7297 gfx::PointF(3.0f, 4.0f), gfx::Size(50, 50), true, | 7300 gfx::PointF(3.0f, 4.0f), gfx::Size(50, 50), true, |
| 7298 false, false); | 7301 false, false); |
| 7299 scroll_layer->PushScrollOffsetFromMainThread(scroll_offset); | 7302 scroll_layer->layer_tree_impl() |
| 7300 scroll_layer->SetScrollDelta(scroll_delta); | 7303 ->property_trees() |
| 7304 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| 7305 scroll_offset); |
| 7306 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
| 7301 scroll_layer->SetScrollCompensationAdjustment(main_scroll_fractional_part); | 7307 scroll_layer->SetScrollCompensationAdjustment(main_scroll_fractional_part); |
| 7302 | 7308 |
| 7303 scroller->AddChild(std::move(fixed)); | 7309 scroller->AddChild(std::move(fixed)); |
| 7304 container->AddChild(std::move(scroller)); | 7310 container->AddChild(std::move(scroller)); |
| 7305 root->AddChild(std::move(container)); | 7311 root->AddChild(std::move(container)); |
| 7306 | 7312 |
| 7307 LayerImplList render_surface_layer_list; | 7313 LayerImplList render_surface_layer_list; |
| 7308 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 7314 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 7309 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7315 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 7310 root.get(), root->bounds(), &render_surface_layer_list, | 7316 root.get(), root->bounds(), &render_surface_layer_list, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7373 end_operations.AppendMatrix(end_scale); | 7379 end_operations.AppendMatrix(end_scale); |
| 7374 if (layer_settings().use_compositor_animation_timelines) { | 7380 if (layer_settings().use_compositor_animation_timelines) { |
| 7375 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), | 7381 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), |
| 7376 1.0, start_operations, | 7382 1.0, start_operations, |
| 7377 end_operations); | 7383 end_operations); |
| 7378 } else { | 7384 } else { |
| 7379 AddAnimatedTransformToLayer(animated_layer, 1.0, start_operations, | 7385 AddAnimatedTransformToLayer(animated_layer, 1.0, start_operations, |
| 7380 end_operations); | 7386 end_operations); |
| 7381 } | 7387 } |
| 7382 gfx::Vector2dF scroll_delta(5.f, 9.f); | 7388 gfx::Vector2dF scroll_delta(5.f, 9.f); |
| 7383 scroller->SetScrollDelta(scroll_delta); | 7389 SetScrollOffsetDelta(scroller, scroll_delta); |
| 7384 | 7390 |
| 7385 ExecuteCalculateDrawProperties(root); | 7391 ExecuteCalculateDrawProperties(root); |
| 7386 | 7392 |
| 7387 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); | 7393 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); |
| 7388 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, | 7394 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, |
| 7389 scroller->DrawTransform().To2dTranslation()); | 7395 scroller->DrawTransform().To2dTranslation()); |
| 7390 } | 7396 } |
| 7391 | 7397 |
| 7392 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { | 7398 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { |
| 7393 public: | 7399 public: |
| (...skipping 2805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10199 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10205 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10200 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10206 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10201 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10207 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10202 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10208 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10203 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10209 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10204 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10210 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10205 } | 10211 } |
| 10206 | 10212 |
| 10207 } // namespace | 10213 } // namespace |
| 10208 } // namespace cc | 10214 } // namespace cc |
| OLD | NEW |