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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 347 |
348 RenderPassId LayerImpl::NextContributingRenderPassId(RenderPassId id) const { | 348 RenderPassId LayerImpl::NextContributingRenderPassId(RenderPassId id) const { |
349 return RenderPassId(0, 0); | 349 return RenderPassId(0, 0); |
350 } | 350 } |
351 | 351 |
352 ResourceProvider::ResourceId LayerImpl::ContentsResourceId() const { | 352 ResourceProvider::ResourceId LayerImpl::ContentsResourceId() const { |
353 NOTREACHED(); | 353 NOTREACHED(); |
354 return 0; | 354 return 0; |
355 } | 355 } |
356 | 356 |
357 void LayerImpl::SetSentScrollDelta(const gfx::Vector2d& sent_scroll_delta) { | 357 void LayerImpl::SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta) { |
358 // Pending tree never has sent scroll deltas | 358 // Pending tree never has sent scroll deltas |
359 DCHECK(layer_tree_impl()->IsActiveTree()); | 359 DCHECK(layer_tree_impl()->IsActiveTree()); |
360 | 360 |
361 if (sent_scroll_delta_ == sent_scroll_delta) | 361 if (sent_scroll_delta_ == sent_scroll_delta) |
362 return; | 362 return; |
363 | 363 |
364 sent_scroll_delta_ = sent_scroll_delta; | 364 sent_scroll_delta_ = sent_scroll_delta; |
365 } | 365 } |
366 | 366 |
367 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { | 367 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { |
(...skipping 25 matching lines...) Expand all Loading... |
393 // This function should not change the total scroll offset; it just shifts | 393 // This function should not change the total scroll offset; it just shifts |
394 // some of the scroll delta to the scroll offset. Therefore, adjust these | 394 // some of the scroll delta to the scroll offset. Therefore, adjust these |
395 // variables directly rather than calling the scroll offset delegate to | 395 // variables directly rather than calling the scroll offset delegate to |
396 // avoid sending it multiple spurious calls. | 396 // avoid sending it multiple spurious calls. |
397 // | 397 // |
398 // Because of the way scroll delta is calculated with a delegate, this will | 398 // Because of the way scroll delta is calculated with a delegate, this will |
399 // leave the total scroll offset unchanged on this layer regardless of | 399 // leave the total scroll offset unchanged on this layer regardless of |
400 // whether a delegate is being used. | 400 // whether a delegate is being used. |
401 scroll_offset_ += sent_scroll_delta_; | 401 scroll_offset_ += sent_scroll_delta_; |
402 scroll_delta_ -= sent_scroll_delta_; | 402 scroll_delta_ -= sent_scroll_delta_; |
403 sent_scroll_delta_ = gfx::Vector2d(); | 403 sent_scroll_delta_ = gfx::Vector2dF(); |
404 } | 404 } |
405 | 405 |
406 void LayerImpl::ApplyScrollDeltasSinceBeginMainFrame() { | 406 void LayerImpl::ApplyScrollDeltasSinceBeginMainFrame() { |
407 // Only the pending tree can have missing scrolls. | 407 // Only the pending tree can have missing scrolls. |
408 DCHECK(layer_tree_impl()->IsPendingTree()); | 408 DCHECK(layer_tree_impl()->IsPendingTree()); |
409 if (!scrollable()) | 409 if (!scrollable()) |
410 return; | 410 return; |
411 | 411 |
412 // Pending tree should never have sent scroll deltas. | 412 // Pending tree should never have sent scroll deltas. |
413 DCHECK(sent_scroll_delta().IsZero()); | 413 DCHECK(sent_scroll_delta().IsZero()); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 layer->SetShouldFlattenTransform(should_flatten_transform_); | 532 layer->SetShouldFlattenTransform(should_flatten_transform_); |
533 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 533 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
534 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 534 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
535 | 535 |
536 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() | 536 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() |
537 : Layer::INVALID_ID); | 537 : Layer::INVALID_ID); |
538 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 538 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
539 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 539 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
540 layer->SetScrollOffsetAndDelta( | 540 layer->SetScrollOffsetAndDelta( |
541 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | 541 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); |
542 layer->SetSentScrollDelta(gfx::Vector2d()); | 542 layer->SetSentScrollDelta(gfx::Vector2dF()); |
543 layer->Set3dSortingContextId(sorting_context_id_); | 543 layer->Set3dSortingContextId(sorting_context_id_); |
544 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 544 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
545 | 545 |
546 LayerImpl* scroll_parent = NULL; | 546 LayerImpl* scroll_parent = NULL; |
547 if (scroll_parent_) { | 547 if (scroll_parent_) { |
548 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 548 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
549 DCHECK(scroll_parent); | 549 DCHECK(scroll_parent); |
550 } | 550 } |
551 | 551 |
552 layer->SetScrollParent(scroll_parent); | 552 layer->SetScrollParent(scroll_parent); |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 scroll_offset_delegate_ = scroll_offset_delegate; | 1071 scroll_offset_delegate_ = scroll_offset_delegate; |
1072 if (scroll_offset_delegate_) | 1072 if (scroll_offset_delegate_) |
1073 scroll_offset_delegate_->SetTotalScrollOffset(total_offset); | 1073 scroll_offset_delegate_->SetTotalScrollOffset(total_offset); |
1074 } | 1074 } |
1075 | 1075 |
1076 bool LayerImpl::IsExternalFlingActive() const { | 1076 bool LayerImpl::IsExternalFlingActive() const { |
1077 return scroll_offset_delegate_ && | 1077 return scroll_offset_delegate_ && |
1078 scroll_offset_delegate_->IsExternalFlingActive(); | 1078 scroll_offset_delegate_->IsExternalFlingActive(); |
1079 } | 1079 } |
1080 | 1080 |
1081 void LayerImpl::SetScrollOffset(const gfx::Vector2d& scroll_offset) { | 1081 void LayerImpl::SetScrollOffset(const gfx::Vector2dF& scroll_offset) { |
1082 SetScrollOffsetAndDelta(scroll_offset, ScrollDelta()); | 1082 SetScrollOffsetAndDelta(scroll_offset, ScrollDelta()); |
1083 } | 1083 } |
1084 | 1084 |
1085 void LayerImpl::SetScrollOffsetAndDelta(const gfx::Vector2d& scroll_offset, | 1085 void LayerImpl::SetScrollOffsetAndDelta(const gfx::Vector2dF& scroll_offset, |
1086 const gfx::Vector2dF& scroll_delta) { | 1086 const gfx::Vector2dF& scroll_delta) { |
1087 bool changed = false; | 1087 bool changed = false; |
1088 | 1088 |
1089 last_scroll_offset_ = scroll_offset; | 1089 last_scroll_offset_ = scroll_offset; |
1090 | 1090 |
1091 if (scroll_offset_ != scroll_offset) { | 1091 if (scroll_offset_ != scroll_offset) { |
1092 changed = true; | 1092 changed = true; |
1093 scroll_offset_ = scroll_offset; | 1093 scroll_offset_ = scroll_offset; |
1094 | 1094 |
1095 if (scroll_offset_delegate_) | 1095 if (scroll_offset_delegate_) |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 } | 1540 } |
1541 | 1541 |
1542 void LayerImpl::NotifyAnimationFinished( | 1542 void LayerImpl::NotifyAnimationFinished( |
1543 base::TimeTicks monotonic_time, | 1543 base::TimeTicks monotonic_time, |
1544 Animation::TargetProperty target_property) { | 1544 Animation::TargetProperty target_property) { |
1545 if (target_property == Animation::ScrollOffset) | 1545 if (target_property == Animation::ScrollOffset) |
1546 layer_tree_impl_->InputScrollAnimationFinished(); | 1546 layer_tree_impl_->InputScrollAnimationFinished(); |
1547 } | 1547 } |
1548 | 1548 |
1549 } // namespace cc | 1549 } // namespace cc |
OLD | NEW |