OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 double_sided_(true), | 53 double_sided_(true), |
54 should_flatten_transform_(true), | 54 should_flatten_transform_(true), |
55 layer_property_changed_(false), | 55 layer_property_changed_(false), |
56 masks_to_bounds_(false), | 56 masks_to_bounds_(false), |
57 contents_opaque_(false), | 57 contents_opaque_(false), |
58 is_root_for_isolated_group_(false), | 58 is_root_for_isolated_group_(false), |
59 use_parent_backface_visibility_(false), | 59 use_parent_backface_visibility_(false), |
60 draw_checkerboard_for_missing_tiles_(false), | 60 draw_checkerboard_for_missing_tiles_(false), |
61 draws_content_(false), | 61 draws_content_(false), |
62 hide_layer_and_subtree_(false), | 62 hide_layer_and_subtree_(false), |
63 clear_scroll_delta_at_activation_(false), | |
64 transform_is_invertible_(true), | 63 transform_is_invertible_(true), |
65 is_container_for_fixed_position_layers_(false), | 64 is_container_for_fixed_position_layers_(false), |
66 background_color_(0), | 65 background_color_(0), |
67 opacity_(1.0), | 66 opacity_(1.0), |
68 blend_mode_(SkXfermode::kSrcOver_Mode), | 67 blend_mode_(SkXfermode::kSrcOver_Mode), |
69 num_descendants_that_draw_content_(0), | 68 num_descendants_that_draw_content_(0), |
70 draw_depth_(0.f), | 69 draw_depth_(0.f), |
71 needs_push_properties_(false), | 70 needs_push_properties_(false), |
72 num_dependents_need_push_properties_(0), | 71 num_dependents_need_push_properties_(0), |
73 sorting_context_id_(0), | 72 sorting_context_id_(0), |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 void LayerImpl::SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta) { | 349 void LayerImpl::SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta) { |
351 // Pending tree never has sent scroll deltas | 350 // Pending tree never has sent scroll deltas |
352 DCHECK(layer_tree_impl()->IsActiveTree()); | 351 DCHECK(layer_tree_impl()->IsActiveTree()); |
353 | 352 |
354 if (sent_scroll_delta_ == sent_scroll_delta) | 353 if (sent_scroll_delta_ == sent_scroll_delta) |
355 return; | 354 return; |
356 | 355 |
357 sent_scroll_delta_ = sent_scroll_delta; | 356 sent_scroll_delta_ = sent_scroll_delta; |
358 } | 357 } |
359 | 358 |
360 void LayerImpl::ClearScrollDeltaAtActivation() { | |
361 clear_scroll_delta_at_activation_ = true; | |
362 } | |
363 | |
364 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { | 359 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { |
365 gfx::Vector2dF adjusted_scroll = scroll; | 360 gfx::Vector2dF adjusted_scroll = scroll; |
366 if (layer_tree_impl()->settings().use_pinch_virtual_viewport) { | 361 if (layer_tree_impl()->settings().use_pinch_virtual_viewport) { |
367 if (!user_scrollable_horizontal_) | 362 if (!user_scrollable_horizontal_) |
368 adjusted_scroll.set_x(0); | 363 adjusted_scroll.set_x(0); |
369 if (!user_scrollable_vertical_) | 364 if (!user_scrollable_vertical_) |
370 adjusted_scroll.set_y(0); | 365 adjusted_scroll.set_y(0); |
371 } | 366 } |
372 DCHECK(scrollable()); | 367 DCHECK(scrollable()); |
373 gfx::Vector2dF min_delta = -ScrollOffsetToVector2dF(scroll_offset_); | 368 gfx::Vector2dF min_delta = -ScrollOffsetToVector2dF(scroll_offset_); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 537 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
543 | 538 |
544 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() | 539 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() |
545 : Layer::INVALID_ID); | 540 : Layer::INVALID_ID); |
546 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 541 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
547 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 542 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
548 | 543 |
549 // Save the difference but clear the sent delta so that we don't subtract | 544 // Save the difference but clear the sent delta so that we don't subtract |
550 // it again in SetScrollOffsetAndDelta's pending twin mirroring logic. | 545 // it again in SetScrollOffsetAndDelta's pending twin mirroring logic. |
551 gfx::Vector2dF remaining_delta = | 546 gfx::Vector2dF remaining_delta = |
552 clear_scroll_delta_at_activation_ | 547 layer_animation_controller_->scroll_offset_animation_was_interrupted() |
553 ? gfx::Vector2dF() | 548 ? gfx::Vector2dF() |
554 : layer->ScrollDelta() - layer->sent_scroll_delta(); | 549 : layer->ScrollDelta() - layer->sent_scroll_delta(); |
555 clear_scroll_delta_at_activation_ = false; | |
556 | 550 |
557 layer->SetSentScrollDelta(gfx::Vector2dF()); | 551 layer->SetSentScrollDelta(gfx::Vector2dF()); |
558 layer->SetScrollOffsetAndDelta(scroll_offset_, remaining_delta); | 552 layer->SetScrollOffsetAndDelta(scroll_offset_, remaining_delta); |
559 | 553 |
560 layer->Set3dSortingContextId(sorting_context_id_); | 554 layer->Set3dSortingContextId(sorting_context_id_); |
561 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 555 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
562 | 556 |
563 LayerImpl* scroll_parent = nullptr; | 557 LayerImpl* scroll_parent = nullptr; |
564 if (scroll_parent_) { | 558 if (scroll_parent_) { |
565 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 559 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 if (!IsActive()) | 778 if (!IsActive()) |
785 return; | 779 return; |
786 | 780 |
787 SetScrollDelta(scroll_offset.DeltaFrom(scroll_offset_)); | 781 SetScrollDelta(scroll_offset.DeltaFrom(scroll_offset_)); |
788 | 782 |
789 layer_tree_impl_->DidAnimateScrollOffset(); | 783 layer_tree_impl_->DidAnimateScrollOffset(); |
790 } | 784 } |
791 | 785 |
792 void LayerImpl::OnAnimationWaitingForDeletion() {} | 786 void LayerImpl::OnAnimationWaitingForDeletion() {} |
793 | 787 |
794 void LayerImpl::OnScrollOffsetAnimationRemoved() { | |
795 } | |
796 | |
797 bool LayerImpl::IsActive() const { | 788 bool LayerImpl::IsActive() const { |
798 return layer_tree_impl_->IsActiveTree(); | 789 return layer_tree_impl_->IsActiveTree(); |
799 } | 790 } |
800 | 791 |
801 gfx::Size LayerImpl::bounds() const { | 792 gfx::Size LayerImpl::bounds() const { |
802 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); | 793 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); |
803 return gfx::Size(bounds_.width() + delta.x(), | 794 return gfx::Size(bounds_.width() + delta.x(), |
804 bounds_.height() + delta.y()); | 795 bounds_.height() + delta.y()); |
805 } | 796 } |
806 | 797 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 | 1158 |
1168 gfx::Vector2dF LayerImpl::ScrollDelta() const { | 1159 gfx::Vector2dF LayerImpl::ScrollDelta() const { |
1169 if (scroll_offset_delegate_) { | 1160 if (scroll_offset_delegate_) { |
1170 return scroll_offset_delegate_->GetTotalScrollOffset().DeltaFrom( | 1161 return scroll_offset_delegate_->GetTotalScrollOffset().DeltaFrom( |
1171 scroll_offset_); | 1162 scroll_offset_); |
1172 } | 1163 } |
1173 return scroll_delta_; | 1164 return scroll_delta_; |
1174 } | 1165 } |
1175 | 1166 |
1176 void LayerImpl::SetScrollDelta(const gfx::Vector2dF& scroll_delta) { | 1167 void LayerImpl::SetScrollDelta(const gfx::Vector2dF& scroll_delta) { |
1177 if (!IsActive() && clear_scroll_delta_at_activation_) | |
1178 return; | |
1179 SetScrollOffsetAndDelta(scroll_offset_, scroll_delta); | 1168 SetScrollOffsetAndDelta(scroll_offset_, scroll_delta); |
1180 } | 1169 } |
1181 | 1170 |
1182 gfx::ScrollOffset LayerImpl::TotalScrollOffset() const { | 1171 gfx::ScrollOffset LayerImpl::TotalScrollOffset() const { |
1183 return ScrollOffsetWithDelta(scroll_offset_, ScrollDelta()); | 1172 return ScrollOffsetWithDelta(scroll_offset_, ScrollDelta()); |
1184 } | 1173 } |
1185 | 1174 |
1186 void LayerImpl::SetDoubleSided(bool double_sided) { | 1175 void LayerImpl::SetDoubleSided(bool double_sided) { |
1187 if (double_sided_ == double_sided) | 1176 if (double_sided_ == double_sided) |
1188 return; | 1177 return; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 SetNeedsPushProperties(); | 1584 SetNeedsPushProperties(); |
1596 layer_tree_impl()->set_needs_update_draw_properties(); | 1585 layer_tree_impl()->set_needs_update_draw_properties(); |
1597 if (should_have_render_surface) { | 1586 if (should_have_render_surface) { |
1598 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); | 1587 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); |
1599 return; | 1588 return; |
1600 } | 1589 } |
1601 render_surface_.reset(); | 1590 render_surface_.reset(); |
1602 } | 1591 } |
1603 | 1592 |
1604 } // namespace cc | 1593 } // namespace cc |
OLD | NEW |