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

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: Remove DCHECKs, set vars directly Created 7 years, 5 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.
282 scroll_offset_ += sent_scroll_delta_;
283 scroll_delta_ -= sent_scroll_delta_;
284 sent_scroll_delta_ = gfx::Vector2d();
285 }
286
273 InputHandler::ScrollStatus LayerImpl::TryScroll( 287 InputHandler::ScrollStatus LayerImpl::TryScroll(
274 gfx::PointF screen_space_point, 288 gfx::PointF screen_space_point,
275 InputHandler::ScrollInputType type) const { 289 InputHandler::ScrollInputType type) const {
276 if (should_scroll_on_main_thread()) { 290 if (should_scroll_on_main_thread()) {
277 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); 291 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread");
278 return InputHandler::ScrollOnMainThread; 292 return InputHandler::ScrollOnMainThread;
279 } 293 }
280 294
281 if (!screen_space_transform().IsInvertible()) { 295 if (!screen_space_transform().IsInvertible()) {
282 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); 296 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()); 900 pending_twin->SetScrollDelta(scroll_delta - sent_scroll_delta());
887 } 901 }
888 } 902 }
889 903
890 if (scroll_offset_delegate_) { 904 if (scroll_offset_delegate_) {
891 scroll_offset_delegate_->SetTotalScrollOffset( 905 scroll_offset_delegate_->SetTotalScrollOffset(
892 scroll_offset_ + scroll_delta); 906 scroll_offset_ + scroll_delta);
893 } else { 907 } else {
894 scroll_delta_ = scroll_delta; 908 scroll_delta_ = scroll_delta;
895 } 909 }
910
896 NoteLayerPropertyChangedForSubtree(); 911 NoteLayerPropertyChangedForSubtree();
897
898 UpdateScrollbarPositions(); 912 UpdateScrollbarPositions();
899 } 913 }
900 914
901 gfx::Vector2dF LayerImpl::TotalScrollOffset() const { 915 gfx::Vector2dF LayerImpl::TotalScrollOffset() const {
902 return scroll_offset_ + ScrollDelta(); 916 return scroll_offset_ + ScrollDelta();
903 } 917 }
904 918
905 void LayerImpl::SetDoubleSided(bool double_sided) { 919 void LayerImpl::SetDoubleSided(bool double_sided) {
906 if (double_sided_ == double_sided) 920 if (double_sided_ == double_sided)
907 return; 921 return;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 1133
1120 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1134 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1121 1135
1122 scoped_ptr<base::Value> LayerImpl::AsValue() const { 1136 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1123 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1137 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1124 AsValueInto(state.get()); 1138 AsValueInto(state.get());
1125 return state.PassAs<base::Value>(); 1139 return state.PassAs<base::Value>();
1126 } 1140 }
1127 1141
1128 } // namespace cc 1142 } // 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