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

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

Issue 1805343006: cc: Impl thread scroll on ScrollNode instead of LayerImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve comments Created 4 years, 9 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
« 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 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 scroll_state->delta_consumed_for_scroll_sequence() && 200 scroll_state->delta_consumed_for_scroll_sequence() &&
201 scroll_state->current_native_scrolling_node()->owner_id != id()) { 201 scroll_state->current_native_scrolling_node()->owner_id != id()) {
202 return; 202 return;
203 } 203 }
204 204
205 ApplyScroll(scroll_state); 205 ApplyScroll(scroll_state);
206 } 206 }
207 207
208 void LayerImpl::ApplyScroll(ScrollState* scroll_state) { 208 void LayerImpl::ApplyScroll(ScrollState* scroll_state) {
209 DCHECK(scroll_state); 209 DCHECK(scroll_state);
210 layer_tree_impl()->ApplyScroll(this, scroll_state); 210 ScrollNode* node = layer_tree_impl()->property_trees()->scroll_tree.Node(
211 scroll_tree_index());
212 layer_tree_impl()->ApplyScroll(node, scroll_state);
211 } 213 }
212 214
213 void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) { 215 void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) {
214 if (num_descendants_that_draw_content_ == num_descendants) 216 if (num_descendants_that_draw_content_ == num_descendants)
215 return; 217 return;
216 num_descendants_that_draw_content_ = num_descendants; 218 num_descendants_that_draw_content_ = num_descendants;
217 SetNeedsPushProperties(); 219 SetNeedsPushProperties();
218 } 220 }
219 221
220 void LayerImpl::SetClipParent(LayerImpl* ancestor) { 222 void LayerImpl::SetClipParent(LayerImpl* ancestor) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 422 }
421 } 423 }
422 424
423 void LayerImpl::GetContentsResourceId(ResourceId* resource_id, 425 void LayerImpl::GetContentsResourceId(ResourceId* resource_id,
424 gfx::Size* resource_size) const { 426 gfx::Size* resource_size) const {
425 NOTREACHED(); 427 NOTREACHED();
426 *resource_id = 0; 428 *resource_id = 0;
427 } 429 }
428 430
429 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { 431 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) {
430 gfx::ScrollOffset adjusted_scroll(scroll); 432 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree;
431 if (!user_scrollable_horizontal_) 433 ScrollNode* scroll_node = scroll_tree.Node(scroll_tree_index());
432 adjusted_scroll.set_x(0); 434 return scroll_tree.ScrollBy(scroll_node, scroll, layer_tree_impl());
433 if (!user_scrollable_vertical_)
434 adjusted_scroll.set_y(0);
435 DCHECK(scrollable());
436 gfx::ScrollOffset old_offset = CurrentScrollOffset();
437 gfx::ScrollOffset new_offset =
438 ClampScrollOffsetToLimits(old_offset + adjusted_scroll);
439 SetCurrentScrollOffset(new_offset);
440
441 gfx::ScrollOffset unscrolled =
442 old_offset + gfx::ScrollOffset(scroll) - new_offset;
443 return gfx::Vector2dF(unscrolled.x(), unscrolled.y());
444 } 435 }
445 436
446 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { 437 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) {
447 if (scroll_clip_layer_id_ == scroll_clip_layer_id) 438 if (scroll_clip_layer_id_ == scroll_clip_layer_id)
448 return; 439 return;
449 440
450 layer_tree_impl()->UnregisterScrollLayer(this); 441 layer_tree_impl()->UnregisterScrollLayer(this);
451 scroll_clip_layer_id_ = scroll_clip_layer_id; 442 scroll_clip_layer_id_ = scroll_clip_layer_id;
452 layer_tree_impl()->RegisterScrollLayer(this); 443 layer_tree_impl()->RegisterScrollLayer(this);
453 } 444 }
454 445
455 LayerImpl* LayerImpl::scroll_clip_layer() const { 446 LayerImpl* LayerImpl::scroll_clip_layer() const {
456 return layer_tree_impl()->LayerById(scroll_clip_layer_id_); 447 return layer_tree_impl()->LayerById(scroll_clip_layer_id_);
457 } 448 }
458 449
459 bool LayerImpl::scrollable() const { 450 bool LayerImpl::scrollable() const {
460 return scroll_clip_layer_id_ != Layer::INVALID_ID; 451 return scroll_clip_layer_id_ != Layer::INVALID_ID;
461 } 452 }
462 453
454 void LayerImpl::set_user_scrollable_horizontal(bool scrollable) {
455 user_scrollable_horizontal_ = scrollable;
456 }
457
458 void LayerImpl::set_user_scrollable_vertical(bool scrollable) {
459 user_scrollable_vertical_ = scrollable;
460 }
461
463 bool LayerImpl::user_scrollable(ScrollbarOrientation orientation) const { 462 bool LayerImpl::user_scrollable(ScrollbarOrientation orientation) const {
464 return (orientation == HORIZONTAL) ? user_scrollable_horizontal_ 463 return (orientation == HORIZONTAL) ? user_scrollable_horizontal_
465 : user_scrollable_vertical_; 464 : user_scrollable_vertical_;
466 } 465 }
467 466
468 skia::RefPtr<SkPicture> LayerImpl::GetPicture() { 467 skia::RefPtr<SkPicture> LayerImpl::GetPicture() {
469 return skia::RefPtr<SkPicture>(); 468 return skia::RefPtr<SkPicture>();
470 } 469 }
471 470
472 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { 471 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) {
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 .layer_transforms_should_scale_layer_contents) { 1580 .layer_transforms_should_scale_layer_contents) {
1582 return default_scale; 1581 return default_scale;
1583 } 1582 }
1584 1583
1585 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1584 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1586 DrawTransform(), default_scale); 1585 DrawTransform(), default_scale);
1587 return std::max(transform_scales.x(), transform_scales.y()); 1586 return std::max(transform_scales.x(), transform_scales.y());
1588 } 1587 }
1589 1588
1590 } // namespace cc 1589 } // 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