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

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

Issue 1437413002: cc: Remove ScopedPtrVector and cc::remove_if. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + fix Created 5 years, 1 month 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
« content/common/cc_messages.cc ('K') | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
16 #include "cc/base/scoped_ptr_algorithm.h"
17 #include "cc/layers/delegated_renderer_layer.h" 16 #include "cc/layers/delegated_renderer_layer.h"
18 #include "cc/layers/nine_patch_layer.h" 17 #include "cc/layers/nine_patch_layer.h"
19 #include "cc/layers/picture_layer.h" 18 #include "cc/layers/picture_layer.h"
20 #include "cc/layers/solid_color_layer.h" 19 #include "cc/layers/solid_color_layer.h"
21 #include "cc/layers/surface_layer.h" 20 #include "cc/layers/surface_layer.h"
22 #include "cc/layers/texture_layer.h" 21 #include "cc/layers/texture_layer.h"
23 #include "cc/output/copy_output_request.h" 22 #include "cc/output/copy_output_request.h"
24 #include "cc/output/delegated_frame_data.h" 23 #include "cc/output/delegated_frame_data.h"
25 #include "cc/output/filter_operation.h" 24 #include "cc/output/filter_operation.h"
26 #include "cc/output/filter_operations.h" 25 #include "cc/output/filter_operations.h"
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 void Layer::AddThreadedAnimation(scoped_ptr<cc::Animation> animation) { 975 void Layer::AddThreadedAnimation(scoped_ptr<cc::Animation> animation) {
977 DCHECK(cc_layer_); 976 DCHECK(cc_layer_);
978 // Until this layer has a compositor (and hence cc_layer_ has a 977 // Until this layer has a compositor (and hence cc_layer_ has a
979 // LayerTreeHost), addAnimation will fail. 978 // LayerTreeHost), addAnimation will fail.
980 if (GetCompositor()) 979 if (GetCompositor())
981 cc_layer_->AddAnimation(animation.Pass()); 980 cc_layer_->AddAnimation(animation.Pass());
982 else 981 else
983 pending_threaded_animations_.push_back(animation.Pass()); 982 pending_threaded_animations_.push_back(animation.Pass());
984 } 983 }
985 984
986 namespace{
987
988 struct HasAnimationId {
989 HasAnimationId(int id): id_(id) {
990 }
991
992 bool operator()(cc::Animation* animation) const {
993 return animation->id() == id_;
994 }
995
996 private:
997 int id_;
998 };
999
1000 }
1001
1002 void Layer::RemoveThreadedAnimation(int animation_id) { 985 void Layer::RemoveThreadedAnimation(int animation_id) {
1003 DCHECK(cc_layer_); 986 DCHECK(cc_layer_);
1004 if (pending_threaded_animations_.size() == 0) { 987 if (pending_threaded_animations_.size() == 0) {
1005 cc_layer_->RemoveAnimation(animation_id); 988 cc_layer_->RemoveAnimation(animation_id);
1006 return; 989 return;
1007 } 990 }
1008 991
1009 pending_threaded_animations_.erase( 992 pending_threaded_animations_.erase(
1010 cc::remove_if(&pending_threaded_animations_, 993 std::remove_if(
1011 pending_threaded_animations_.begin(), 994 pending_threaded_animations_.begin(),
1012 pending_threaded_animations_.end(), 995 pending_threaded_animations_.end(),
1013 HasAnimationId(animation_id)), 996 [animation_id](const scoped_ptr<cc::Animation>& animation) {
997 return animation->id() == animation_id;
998 }),
1014 pending_threaded_animations_.end()); 999 pending_threaded_animations_.end());
1015 } 1000 }
1016 1001
1017 LayerAnimatorCollection* Layer::GetLayerAnimatorCollection() { 1002 LayerAnimatorCollection* Layer::GetLayerAnimatorCollection() {
1018 Compositor* compositor = GetCompositor(); 1003 Compositor* compositor = GetCompositor();
1019 return compositor ? compositor->layer_animator_collection() : NULL; 1004 return compositor ? compositor->layer_animator_collection() : NULL;
1020 } 1005 }
1021 1006
1022 void Layer::SendPendingThreadedAnimations() { 1007 void Layer::SendPendingThreadedAnimations() {
1023 for (cc::ScopedPtrVector<cc::Animation>::iterator it = 1008 for (auto& animation : pending_threaded_animations_)
1024 pending_threaded_animations_.begin(); 1009 cc_layer_->AddAnimation(std::move(animation));
1025 it != pending_threaded_animations_.end();
1026 ++it)
1027 cc_layer_->AddAnimation(pending_threaded_animations_.take(it));
1028
1029 pending_threaded_animations_.clear(); 1010 pending_threaded_animations_.clear();
1030 1011
1031 for (size_t i = 0; i < children_.size(); ++i) 1012 for (auto* child : children_)
1032 children_[i]->SendPendingThreadedAnimations(); 1013 child->SendPendingThreadedAnimations();
1033 } 1014 }
1034 1015
1035 void Layer::CreateCcLayer() { 1016 void Layer::CreateCcLayer() {
1036 if (type_ == LAYER_SOLID_COLOR) { 1017 if (type_ == LAYER_SOLID_COLOR) {
1037 solid_color_layer_ = cc::SolidColorLayer::Create(UILayerSettings()); 1018 solid_color_layer_ = cc::SolidColorLayer::Create(UILayerSettings());
1038 cc_layer_ = solid_color_layer_.get(); 1019 cc_layer_ = solid_color_layer_.get();
1039 } else if (type_ == LAYER_NINE_PATCH) { 1020 } else if (type_ == LAYER_NINE_PATCH) {
1040 nine_patch_layer_ = cc::NinePatchLayer::Create(UILayerSettings()); 1021 nine_patch_layer_ = cc::NinePatchLayer::Create(UILayerSettings());
1041 cc_layer_ = nine_patch_layer_.get(); 1022 cc_layer_ = nine_patch_layer_.get();
1042 } else { 1023 } else {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 animator_->RemoveFromCollection(collection); 1073 animator_->RemoveFromCollection(collection);
1093 for (auto* child : children_) 1074 for (auto* child : children_)
1094 child->RemoveAnimatorsInTreeFromCollection(collection); 1075 child->RemoveAnimatorsInTreeFromCollection(collection);
1095 } 1076 }
1096 1077
1097 bool Layer::IsAnimating() const { 1078 bool Layer::IsAnimating() const {
1098 return animator_.get() && animator_->is_animating(); 1079 return animator_.get() && animator_->is_animating();
1099 } 1080 }
1100 1081
1101 } // namespace ui 1082 } // namespace ui
OLDNEW
« content/common/cc_messages.cc ('K') | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698