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

Side by Side Diff: ui/compositor/layer.cc

Issue 2189583004: [not for review - epic CL] Adding Elastic+Momentum+Layered scrolling to views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Combined rebase Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/compositor/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 bool Layer::HasPendingThreadedAnimationsForTesting() const { 521 bool Layer::HasPendingThreadedAnimationsForTesting() const {
522 return animator_->HasPendingThreadedAnimationsForTesting(); 522 return animator_->HasPendingThreadedAnimationsForTesting();
523 } 523 }
524 524
525 void Layer::SwitchCCLayerForTest() { 525 void Layer::SwitchCCLayerForTest() {
526 scoped_refptr<cc::Layer> new_layer = cc::PictureLayer::Create(this); 526 scoped_refptr<cc::Layer> new_layer = cc::PictureLayer::Create(this);
527 SwitchToLayer(new_layer); 527 SwitchToLayer(new_layer);
528 content_layer_ = new_layer; 528 content_layer_ = new_layer;
529 } 529 }
530 530
531 gfx::ScrollOffset Layer::CurrentScrollOffset() const {
532 const Compositor* compositor = GetCompositor();
533 if (compositor)
534 return compositor->GetScrollOffsetForLayer(cc_layer_->id());
535 return cc_layer_->scroll_offset();
536 }
537
538 void Layer::SetScrollOffset(const gfx::ScrollOffset& offset) {
539 Compositor* compositor = GetCompositor();
540 bool scrolled_on_impl_side =
541 compositor && compositor->ScrollLayerTo(cc_layer_->id(), offset);
542
543 if (!scrolled_on_impl_side)
544 cc_layer_->SetScrollOffset(offset);
545
546 DCHECK_EQ(offset.x(), CurrentScrollOffset().x());
547 DCHECK_EQ(offset.y(), CurrentScrollOffset().y());
548 }
549
550 void Layer::SetScrollable(Layer* parent_clip_layer,
551 bool can_overscroll,
552 const base::Closure& on_scroll) {
553 cc_layer_->SetScrollParent(parent_clip_layer->cc_layer_);
554 cc_layer_->SetIsContainerForFixedPositionLayers(true);
555 cc_layer_->SetScrollClipAndCanOverscroll(parent_clip_layer->cc_layer_->id(),
556 can_overscroll);
557 cc_layer_->set_did_scroll_callback(on_scroll);
558 cc_layer_->SetUserScrollable(true, true);
559 }
560
531 void Layer::SetTextureMailbox( 561 void Layer::SetTextureMailbox(
532 const cc::TextureMailbox& mailbox, 562 const cc::TextureMailbox& mailbox,
533 std::unique_ptr<cc::SingleReleaseCallback> release_callback, 563 std::unique_ptr<cc::SingleReleaseCallback> release_callback,
534 gfx::Size texture_size_in_dip) { 564 gfx::Size texture_size_in_dip) {
535 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); 565 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR);
536 DCHECK(mailbox.IsValid()); 566 DCHECK(mailbox.IsValid());
537 DCHECK(release_callback); 567 DCHECK(release_callback);
538 if (!texture_layer_.get()) { 568 if (!texture_layer_.get()) {
539 scoped_refptr<cc::TextureLayer> new_layer = 569 scoped_refptr<cc::TextureLayer> new_layer =
540 cc::TextureLayer::CreateForMailbox(this); 570 cc::TextureLayer::CreateForMailbox(this);
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 if (animator_) { 1097 if (animator_) {
1068 animator_->ResetCompositor(compositor); 1098 animator_->ResetCompositor(compositor);
1069 animator_->RemoveFromCollection(collection); 1099 animator_->RemoveFromCollection(collection);
1070 } 1100 }
1071 1101
1072 for (auto* child : children_) 1102 for (auto* child : children_)
1073 child->ResetCompositorForAnimatorsInTree(compositor); 1103 child->ResetCompositorForAnimatorsInTree(compositor);
1074 } 1104 }
1075 1105
1076 } // namespace ui 1106 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698