| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 SetNeedsCommit(); | 647 SetNeedsCommit(); |
| 648 } | 648 } |
| 649 | 649 |
| 650 void Layer::RemoveClipChild(Layer* child) { | 650 void Layer::RemoveClipChild(Layer* child) { |
| 651 clip_children_->erase(child); | 651 clip_children_->erase(child); |
| 652 if (clip_children_->empty()) | 652 if (clip_children_->empty()) |
| 653 clip_children_.reset(); | 653 clip_children_.reset(); |
| 654 SetNeedsCommit(); | 654 SetNeedsCommit(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 void Layer::SetScrollOffset(gfx::Vector2d scroll_offset) { | 657 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { |
| 658 DCHECK(IsPropertyChangeAllowed()); | 658 DCHECK(IsPropertyChangeAllowed()); |
| 659 | 659 |
| 660 if (scroll_offset_ == scroll_offset) | 660 if (scroll_offset_ == scroll_offset) |
| 661 return; | 661 return; |
| 662 scroll_offset_ = scroll_offset; | 662 scroll_offset_ = scroll_offset; |
| 663 SetNeedsCommit(); | 663 SetNeedsCommit(); |
| 664 } | 664 } |
| 665 | 665 |
| 666 void Layer::SetScrollOffsetFromImplSide(const gfx::Vector2d& scroll_offset) { | 666 void Layer::SetScrollOffsetFromImplSide( |
| 667 const gfx::ScrollOffset& scroll_offset) { |
| 667 DCHECK(IsPropertyChangeAllowed()); | 668 DCHECK(IsPropertyChangeAllowed()); |
| 668 // This function only gets called during a BeginMainFrame, so there | 669 // This function only gets called during a BeginMainFrame, so there |
| 669 // is no need to call SetNeedsUpdate here. | 670 // is no need to call SetNeedsUpdate here. |
| 670 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); | 671 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); |
| 671 if (scroll_offset_ == scroll_offset) | 672 if (scroll_offset_ == scroll_offset) |
| 672 return; | 673 return; |
| 673 scroll_offset_ = scroll_offset; | 674 scroll_offset_ = scroll_offset; |
| 674 SetNeedsPushProperties(); | 675 SetNeedsPushProperties(); |
| 675 if (!did_scroll_callback_.is_null()) | 676 if (!did_scroll_callback_.is_null()) |
| 676 did_scroll_callback_.Run(); | 677 did_scroll_callback_.Run(); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 layer->SetClipChildren(NULL); | 957 layer->SetClipChildren(NULL); |
| 957 } | 958 } |
| 958 | 959 |
| 959 // Adjust the scroll delta to be just the scrolls that have happened since | 960 // Adjust the scroll delta to be just the scrolls that have happened since |
| 960 // the BeginMainFrame was sent. This happens for impl-side painting | 961 // the BeginMainFrame was sent. This happens for impl-side painting |
| 961 // in LayerImpl::ApplyScrollDeltasSinceBeginMainFrame in a separate tree walk. | 962 // in LayerImpl::ApplyScrollDeltasSinceBeginMainFrame in a separate tree walk. |
| 962 if (layer->layer_tree_impl()->settings().impl_side_painting) { | 963 if (layer->layer_tree_impl()->settings().impl_side_painting) { |
| 963 layer->SetScrollOffset(scroll_offset_); | 964 layer->SetScrollOffset(scroll_offset_); |
| 964 } else { | 965 } else { |
| 965 layer->SetScrollOffsetAndDelta( | 966 layer->SetScrollOffsetAndDelta( |
| 966 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | 967 scroll_offset_, |
| 967 layer->SetSentScrollDelta(gfx::Vector2d()); | 968 layer->ScrollDelta() - ToVector2dF(layer->sent_scroll_delta())); |
| 969 layer->SetSentScrollDelta(gfx::ScrollOffset()); |
| 968 } | 970 } |
| 969 | 971 |
| 970 // Wrap the copy_requests_ in a PostTask to the main thread. | 972 // Wrap the copy_requests_ in a PostTask to the main thread. |
| 971 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; | 973 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; |
| 972 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); | 974 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); |
| 973 it != copy_requests_.end(); | 975 it != copy_requests_.end(); |
| 974 ++it) { | 976 ++it) { |
| 975 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 977 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 976 layer_tree_host()->proxy()->MainThreadTaskRunner(); | 978 layer_tree_host()->proxy()->MainThreadTaskRunner(); |
| 977 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); | 979 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 | 1235 |
| 1234 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1236 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 1235 benchmark->RunOnLayer(this); | 1237 benchmark->RunOnLayer(this); |
| 1236 } | 1238 } |
| 1237 | 1239 |
| 1238 bool Layer::HasDelegatedContent() const { | 1240 bool Layer::HasDelegatedContent() const { |
| 1239 return false; | 1241 return false; |
| 1240 } | 1242 } |
| 1241 | 1243 |
| 1242 } // namespace cc | 1244 } // namespace cc |
| OLD | NEW |