| 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 | 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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 // been configured as LAYER_SOLID_COLOR. | 805 // been configured as LAYER_SOLID_COLOR. |
| 806 return solid_color_layer_.get() ? | 806 return solid_color_layer_.get() ? |
| 807 solid_color_layer_->backgroundColor() : SK_ColorBLACK; | 807 solid_color_layer_->backgroundColor() : SK_ColorBLACK; |
| 808 } | 808 } |
| 809 | 809 |
| 810 void Layer::AddThreadedAnimation(scoped_ptr<cc::Animation> animation) { | 810 void Layer::AddThreadedAnimation(scoped_ptr<cc::Animation> animation) { |
| 811 DCHECK(cc_layer_); | 811 DCHECK(cc_layer_); |
| 812 // Until this layer has a compositor (and hence cc_layer_ has a | 812 // Until this layer has a compositor (and hence cc_layer_ has a |
| 813 // LayerTreeHost), addAnimation will fail. | 813 // LayerTreeHost), addAnimation will fail. |
| 814 if (GetCompositor()) | 814 if (GetCompositor()) |
| 815 cc_layer_->addAnimation(animation.Pass()); | 815 cc_layer_->AddAnimation(animation.Pass()); |
| 816 else | 816 else |
| 817 pending_threaded_animations_.push_back(animation.Pass()); | 817 pending_threaded_animations_.push_back(animation.Pass()); |
| 818 } | 818 } |
| 819 | 819 |
| 820 namespace{ | 820 namespace{ |
| 821 | 821 |
| 822 struct HasAnimationId { | 822 struct HasAnimationId { |
| 823 HasAnimationId(int id): id_(id) { | 823 HasAnimationId(int id): id_(id) { |
| 824 } | 824 } |
| 825 | 825 |
| 826 bool operator()(cc::Animation* animation) const { | 826 bool operator()(cc::Animation* animation) const { |
| 827 return animation->id() == id_; | 827 return animation->id() == id_; |
| 828 } | 828 } |
| 829 | 829 |
| 830 private: | 830 private: |
| 831 int id_; | 831 int id_; |
| 832 }; | 832 }; |
| 833 | 833 |
| 834 } | 834 } |
| 835 | 835 |
| 836 void Layer::RemoveThreadedAnimation(int animation_id) { | 836 void Layer::RemoveThreadedAnimation(int animation_id) { |
| 837 DCHECK(cc_layer_); | 837 DCHECK(cc_layer_); |
| 838 if (pending_threaded_animations_.size() == 0) { | 838 if (pending_threaded_animations_.size() == 0) { |
| 839 cc_layer_->removeAnimation(animation_id); | 839 cc_layer_->RemoveAnimation(animation_id); |
| 840 return; | 840 return; |
| 841 } | 841 } |
| 842 | 842 |
| 843 pending_threaded_animations_.erase( | 843 pending_threaded_animations_.erase( |
| 844 cc::remove_if(pending_threaded_animations_, | 844 cc::remove_if(pending_threaded_animations_, |
| 845 pending_threaded_animations_.begin(), | 845 pending_threaded_animations_.begin(), |
| 846 pending_threaded_animations_.end(), | 846 pending_threaded_animations_.end(), |
| 847 HasAnimationId(animation_id)), | 847 HasAnimationId(animation_id)), |
| 848 pending_threaded_animations_.end()); | 848 pending_threaded_animations_.end()); |
| 849 } | 849 } |
| 850 | 850 |
| 851 void Layer::SendPendingThreadedAnimations() { | 851 void Layer::SendPendingThreadedAnimations() { |
| 852 for (cc::ScopedPtrVector<cc::Animation>::iterator it = | 852 for (cc::ScopedPtrVector<cc::Animation>::iterator it = |
| 853 pending_threaded_animations_.begin(); | 853 pending_threaded_animations_.begin(); |
| 854 it != pending_threaded_animations_.end(); | 854 it != pending_threaded_animations_.end(); |
| 855 ++it) | 855 ++it) |
| 856 cc_layer_->addAnimation(pending_threaded_animations_.take(it)); | 856 cc_layer_->AddAnimation(pending_threaded_animations_.take(it)); |
| 857 | 857 |
| 858 pending_threaded_animations_.clear(); | 858 pending_threaded_animations_.clear(); |
| 859 | 859 |
| 860 for (size_t i = 0; i < children_.size(); ++i) | 860 for (size_t i = 0; i < children_.size(); ++i) |
| 861 children_[i]->SendPendingThreadedAnimations(); | 861 children_[i]->SendPendingThreadedAnimations(); |
| 862 } | 862 } |
| 863 | 863 |
| 864 void Layer::CreateWebLayer() { | 864 void Layer::CreateWebLayer() { |
| 865 if (type_ == LAYER_SOLID_COLOR) { | 865 if (type_ == LAYER_SOLID_COLOR) { |
| 866 solid_color_layer_ = cc::SolidColorLayer::Create(); | 866 solid_color_layer_ = cc::SolidColorLayer::Create(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 texture_layer_->setUV(uv_top_left, uv_bottom_right); | 911 texture_layer_->setUV(uv_top_left, uv_bottom_right); |
| 912 } else if (delegated_renderer_layer_.get()) { | 912 } else if (delegated_renderer_layer_.get()) { |
| 913 delegated_renderer_layer_->SetDisplaySize( | 913 delegated_renderer_layer_->SetDisplaySize( |
| 914 ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); | 914 ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); |
| 915 size.ClampToMax(delegated_frame_size_in_dip_); | 915 size.ClampToMax(delegated_frame_size_in_dip_); |
| 916 } | 916 } |
| 917 cc_layer_->setBounds(ConvertSizeToPixel(this, size)); | 917 cc_layer_->setBounds(ConvertSizeToPixel(this, size)); |
| 918 } | 918 } |
| 919 | 919 |
| 920 } // namespace ui | 920 } // namespace ui |
| OLD | NEW |