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

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

Issue 11896017: Thread ui opacity animations (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Correctly deal with sequences meant to start together Created 7 years, 11 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 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (compositor_) 101 if (compositor_)
102 compositor_->SetRootLayer(NULL); 102 compositor_->SetRootLayer(NULL);
103 if (parent_) 103 if (parent_)
104 parent_->Remove(this); 104 parent_->Remove(this);
105 if (layer_mask_) 105 if (layer_mask_)
106 SetMaskLayer(NULL); 106 SetMaskLayer(NULL);
107 if (layer_mask_back_link_) 107 if (layer_mask_back_link_)
108 layer_mask_back_link_->SetMaskLayer(NULL); 108 layer_mask_back_link_->SetMaskLayer(NULL);
109 for (size_t i = 0; i < children_.size(); ++i) 109 for (size_t i = 0; i < children_.size(); ++i)
110 children_[i]->parent_ = NULL; 110 children_[i]->parent_ = NULL;
111 cc_layer_->removeLayerAnimationEventObserver(this);
111 cc_layer_->removeFromParent(); 112 cc_layer_->removeFromParent();
112 } 113 }
113 114
114 Compositor* Layer::GetCompositor() { 115 Compositor* Layer::GetCompositor() {
115 return GetRoot(this)->compositor_; 116 return GetRoot(this)->compositor_;
116 } 117 }
117 118
118 void Layer::SetCompositor(Compositor* compositor) { 119 void Layer::SetCompositor(Compositor* compositor) {
119 // This function must only be called to set the compositor on the root layer, 120 // This function must only be called to set the compositor on the root layer,
120 // or to reset it. 121 // or to reset it.
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 new_layer = texture_layer_.get(); 424 new_layer = texture_layer_.get();
424 } else { 425 } else {
425 old_texture_layer->willModifyTexture(); 426 old_texture_layer->willModifyTexture();
426 content_layer_ = cc::ContentLayer::create(this); 427 content_layer_ = cc::ContentLayer::create(this);
427 new_layer = content_layer_.get(); 428 new_layer = content_layer_.get();
428 } 429 }
429 if (parent_) { 430 if (parent_) {
430 DCHECK(parent_->cc_layer_); 431 DCHECK(parent_->cc_layer_);
431 parent_->cc_layer_->replaceChild(cc_layer_, new_layer); 432 parent_->cc_layer_->replaceChild(cc_layer_, new_layer);
432 } 433 }
434 cc_layer_->removeLayerAnimationEventObserver(this);
433 cc_layer_= new_layer; 435 cc_layer_= new_layer;
436 cc_layer_->addLayerAnimationEventObserver(this);
434 cc_layer_is_accelerated_ = layer_updated_externally_; 437 cc_layer_is_accelerated_ = layer_updated_externally_;
435 for (size_t i = 0; i < children_.size(); ++i) { 438 for (size_t i = 0; i < children_.size(); ++i) {
436 DCHECK(children_[i]->cc_layer_); 439 DCHECK(children_[i]->cc_layer_);
437 cc_layer_->addChild(children_[i]->cc_layer_); 440 cc_layer_->addChild(children_[i]->cc_layer_);
438 } 441 }
439 cc_layer_->setAnchorPoint(gfx::PointF()); 442 cc_layer_->setAnchorPoint(gfx::PointF());
440 cc_layer_->setContentsOpaque(fills_bounds_opaquely_); 443 cc_layer_->setContentsOpaque(fills_bounds_opaquely_);
441 cc_layer_->setOpacity(visible_ ? opacity_ : 0.f); 444 cc_layer_->setOpacity(visible_ ? opacity_ : 0.f);
442 cc_layer_->setForceRenderSurface(force_render_surface_); 445 cc_layer_->setForceRenderSurface(force_render_surface_);
443 cc_layer_->setIsDrawable(true); 446 cc_layer_->setIsDrawable(true);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 546 }
544 547
545 void Layer::SetForceRenderSurface(bool force) { 548 void Layer::SetForceRenderSurface(bool force) {
546 if (force_render_surface_ == force) 549 if (force_render_surface_ == force)
547 return; 550 return;
548 551
549 force_render_surface_ = force; 552 force_render_surface_ = force;
550 cc_layer_->setForceRenderSurface(force_render_surface_); 553 cc_layer_->setForceRenderSurface(force_render_surface_);
551 } 554 }
552 555
556 void Layer::OnAnimationStarted(const cc::AnimationEvent& event) {
557 if (animator_)
558 animator_->OnThreadedAnimationStarted(event);
559 }
560
553 void Layer::StackRelativeTo(Layer* child, Layer* other, bool above) { 561 void Layer::StackRelativeTo(Layer* child, Layer* other, bool above) {
554 DCHECK_NE(child, other); 562 DCHECK_NE(child, other);
555 DCHECK_EQ(this, child->parent()); 563 DCHECK_EQ(this, child->parent());
556 DCHECK_EQ(this, other->parent()); 564 DCHECK_EQ(this, other->parent());
557 565
558 const size_t child_i = 566 const size_t child_i =
559 std::find(children_.begin(), children_.end(), child) - children_.begin(); 567 std::find(children_.begin(), children_.end(), child) - children_.begin();
560 const size_t other_i = 568 const size_t other_i =
561 std::find(children_.begin(), children_.end(), other) - children_.begin(); 569 std::find(children_.begin(), children_.end(), other) - children_.begin();
562 if ((above && child_i == other_i + 1) || (!above && child_i + 1 == other_i)) 570 if ((above && child_i == other_i + 1) || (!above && child_i + 1 == other_i))
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 } 742 }
735 743
736 SkColor Layer::GetColorForAnimation() const { 744 SkColor Layer::GetColorForAnimation() const {
737 // WebColor is equivalent to SkColor, per WebColor.h. 745 // WebColor is equivalent to SkColor, per WebColor.h.
738 // The NULL check is here since this is invoked regardless of whether we have 746 // The NULL check is here since this is invoked regardless of whether we have
739 // been configured as LAYER_SOLID_COLOR. 747 // been configured as LAYER_SOLID_COLOR.
740 return solid_color_layer_.get() ? 748 return solid_color_layer_.get() ?
741 solid_color_layer_->backgroundColor() : SK_ColorBLACK; 749 solid_color_layer_->backgroundColor() : SK_ColorBLACK;
742 } 750 }
743 751
752 void Layer::AddThreadedAnimation(scoped_ptr<cc::Animation> animation) {
753 DCHECK(cc_layer_);
754 cc_layer_->addAnimation(animation.Pass());
755 }
756
757 void Layer::RemoveThreadedAnimation(int animation_id) {
758 DCHECK(cc_layer_);
759 cc_layer_->removeAnimation(animation_id);
760 }
761
744 void Layer::CreateWebLayer() { 762 void Layer::CreateWebLayer() {
745 if (type_ == LAYER_SOLID_COLOR) { 763 if (type_ == LAYER_SOLID_COLOR) {
746 solid_color_layer_ = cc::SolidColorLayer::create(); 764 solid_color_layer_ = cc::SolidColorLayer::create();
747 cc_layer_ = solid_color_layer_.get(); 765 cc_layer_ = solid_color_layer_.get();
748 } else { 766 } else {
749 content_layer_ = cc::ContentLayer::create(this); 767 content_layer_ = cc::ContentLayer::create(this);
750 cc_layer_ = content_layer_.get(); 768 cc_layer_ = content_layer_.get();
751 } 769 }
752 cc_layer_is_accelerated_ = false; 770 cc_layer_is_accelerated_ = false;
753 cc_layer_->setAnchorPoint(gfx::PointF()); 771 cc_layer_->setAnchorPoint(gfx::PointF());
754 cc_layer_->setContentsOpaque(true); 772 cc_layer_->setContentsOpaque(true);
755 cc_layer_->setIsDrawable(type_ != LAYER_NOT_DRAWN); 773 cc_layer_->setIsDrawable(type_ != LAYER_NOT_DRAWN);
774 cc_layer_->addLayerAnimationEventObserver(this);
756 } 775 }
757 776
758 void Layer::RecomputeTransform() { 777 void Layer::RecomputeTransform() {
759 gfx::Transform scale_translate; 778 gfx::Transform scale_translate;
760 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, 779 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0,
761 0, device_scale_factor_, 0, 780 0, device_scale_factor_, 0,
762 0, 0, 1); 781 0, 0, 1);
763 // Start with the inverse matrix of above. 782 // Start with the inverse matrix of above.
764 gfx::Transform transform; 783 gfx::Transform transform;
765 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, 784 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0,
(...skipping 24 matching lines...) Expand all
790 gfx::PointF uv_bottom_right( 809 gfx::PointF uv_bottom_right(
791 static_cast<float>(size.width())/texture_size.width(), 810 static_cast<float>(size.width())/texture_size.width(),
792 static_cast<float>(size.height())/texture_size.height()); 811 static_cast<float>(size.height())/texture_size.height());
793 texture_layer_->setUV(uv_top_left, uv_bottom_right); 812 texture_layer_->setUV(uv_top_left, uv_bottom_right);
794 813
795 cc_layer_->setBounds(ConvertSizeToPixel(this, size)); 814 cc_layer_->setBounds(ConvertSizeToPixel(this, size));
796 } 815 }
797 } 816 }
798 817
799 } // namespace ui 818 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698