Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: cc/layers/layer_impl.cc

Issue 19106007: cc: Allow the main thread to cancel commits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add more comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/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/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "cc/animation/animation_registrar.h" 9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/scrollbar_animation_controller.h" 10 #include "cc/animation/scrollbar_animation_controller.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 259
260 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { 260 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) {
261 gfx::Vector2dF min_delta = -scroll_offset_; 261 gfx::Vector2dF min_delta = -scroll_offset_;
262 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; 262 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_;
263 // Clamp new_delta so that position + delta stays within scroll bounds. 263 // Clamp new_delta so that position + delta stays within scroll bounds.
264 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); 264 gfx::Vector2dF new_delta = (ScrollDelta() + scroll);
265 new_delta.SetToMax(min_delta); 265 new_delta.SetToMax(min_delta);
266 new_delta.SetToMin(max_delta); 266 new_delta.SetToMin(max_delta);
267 gfx::Vector2dF unscrolled = ScrollDelta() + scroll - new_delta; 267 gfx::Vector2dF unscrolled = ScrollDelta() + scroll - new_delta;
268
269 SetScrollDelta(new_delta); 268 SetScrollDelta(new_delta);
270 return unscrolled; 269 return unscrolled;
271 } 270 }
272 271
272 void LayerImpl::ApplySentScrollDeltas() {
273 // Pending tree never has sent scroll deltas
274 DCHECK(layer_tree_impl()->IsActiveTree());
275
276 // Apply sent scroll deltas to scroll position / scroll delta as if the
277 // main thread had applied them and then committed those values.
278 //
279 // This function should not change the total scroll offset; it just shifts
280 // some of the scroll delta to the scroll offset. Therefore, adjust these
281 // variables directly rather than calling the scroll offset delegate to
282 // avoid sending it multiple spurious calls.
283 //
284 // Because of the way scroll delta is calculated with a delegate, this will
285 // leave the total scroll offset unchanged on this layer regardless of
286 // whether a delegate is being used.
287 scroll_offset_ += sent_scroll_delta_;
288 scroll_delta_ -= sent_scroll_delta_;
289 sent_scroll_delta_ = gfx::Vector2d();
290 }
291
273 InputHandler::ScrollStatus LayerImpl::TryScroll( 292 InputHandler::ScrollStatus LayerImpl::TryScroll(
274 gfx::PointF screen_space_point, 293 gfx::PointF screen_space_point,
275 InputHandler::ScrollInputType type) const { 294 InputHandler::ScrollInputType type) const {
276 if (should_scroll_on_main_thread()) { 295 if (should_scroll_on_main_thread()) {
277 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); 296 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread");
278 return InputHandler::ScrollOnMainThread; 297 return InputHandler::ScrollOnMainThread;
279 } 298 }
280 299
281 if (!screen_space_transform().IsInvertible()) { 300 if (!screen_space_transform().IsInvertible()) {
282 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); 301 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform");
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 pending_twin->SetScrollDelta(scroll_delta - sent_scroll_delta()); 905 pending_twin->SetScrollDelta(scroll_delta - sent_scroll_delta());
887 } 906 }
888 } 907 }
889 908
890 if (scroll_offset_delegate_) { 909 if (scroll_offset_delegate_) {
891 scroll_offset_delegate_->SetTotalScrollOffset( 910 scroll_offset_delegate_->SetTotalScrollOffset(
892 scroll_offset_ + scroll_delta); 911 scroll_offset_ + scroll_delta);
893 } else { 912 } else {
894 scroll_delta_ = scroll_delta; 913 scroll_delta_ = scroll_delta;
895 } 914 }
915
896 NoteLayerPropertyChangedForSubtree(); 916 NoteLayerPropertyChangedForSubtree();
897
898 UpdateScrollbarPositions(); 917 UpdateScrollbarPositions();
899 } 918 }
900 919
901 gfx::Vector2dF LayerImpl::TotalScrollOffset() const { 920 gfx::Vector2dF LayerImpl::TotalScrollOffset() const {
902 return scroll_offset_ + ScrollDelta(); 921 return scroll_offset_ + ScrollDelta();
903 } 922 }
904 923
905 void LayerImpl::SetDoubleSided(bool double_sided) { 924 void LayerImpl::SetDoubleSided(bool double_sided) {
906 if (double_sided_ == double_sided) 925 if (double_sided_ == double_sided)
907 return; 926 return;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 1138
1120 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1139 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1121 1140
1122 scoped_ptr<base::Value> LayerImpl::AsValue() const { 1141 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1123 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1142 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1124 AsValueInto(state.get()); 1143 AsValueInto(state.get());
1125 return state.PassAs<base::Value>(); 1144 return state.PassAs<base::Value>();
1126 } 1145 }
1127 1146
1128 } // namespace cc 1147 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698