| OLD | NEW |
| 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 Loading... |
| 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 return cc_layer_->scroll_offset(); |
| 533 } |
| 534 |
| 535 void Layer::SetScrollOffset(const gfx::ScrollOffset& offset) { |
| 536 #if 0 |
| 537 if (IsDrawn()) |
| 538 ScheduleDraw(); |
| 539 cc_layer_->SetScrollOffsetFromImplSide(offset, nullptr); |
| 540 #else |
| 541 bool scrolled_on_impl_side = |
| 542 GetCompositor() && |
| 543 GetCompositor()->ScrollLayerTo(cc_layer_->id(), offset); |
| 544 |
| 545 if (!scrolled_on_impl_side) |
| 546 cc_layer_->SetScrollOffset(offset); |
| 547 #endif |
| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 if (animator_) { | 1090 if (animator_) { |
| 1061 animator_->ResetCompositor(compositor); | 1091 animator_->ResetCompositor(compositor); |
| 1062 animator_->RemoveFromCollection(collection); | 1092 animator_->RemoveFromCollection(collection); |
| 1063 } | 1093 } |
| 1064 | 1094 |
| 1065 for (auto* child : children_) | 1095 for (auto* child : children_) |
| 1066 child->ResetCompositorForAnimatorsInTree(compositor); | 1096 child->ResetCompositorForAnimatorsInTree(compositor); |
| 1067 } | 1097 } |
| 1068 | 1098 |
| 1069 } // namespace ui | 1099 } // namespace ui |
| OLD | NEW |