OLD | NEW |
---|---|
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 draws_content_(false), | 60 draws_content_(false), |
61 hide_layer_and_subtree_(false), | 61 hide_layer_and_subtree_(false), |
62 masks_to_bounds_(false), | 62 masks_to_bounds_(false), |
63 contents_opaque_(false), | 63 contents_opaque_(false), |
64 double_sided_(true), | 64 double_sided_(true), |
65 should_flatten_transform_(true), | 65 should_flatten_transform_(true), |
66 use_parent_backface_visibility_(false), | 66 use_parent_backface_visibility_(false), |
67 draw_checkerboard_for_missing_tiles_(false), | 67 draw_checkerboard_for_missing_tiles_(false), |
68 force_render_surface_(false), | 68 force_render_surface_(false), |
69 transform_is_invertible_(true), | 69 transform_is_invertible_(true), |
70 should_have_render_surface_(false), | |
70 background_color_(0), | 71 background_color_(0), |
71 opacity_(1.f), | 72 opacity_(1.f), |
72 blend_mode_(SkXfermode::kSrcOver_Mode), | 73 blend_mode_(SkXfermode::kSrcOver_Mode), |
73 scroll_parent_(NULL), | 74 scroll_parent_(NULL), |
74 clip_parent_(NULL), | 75 clip_parent_(NULL), |
75 replica_layer_(NULL), | 76 replica_layer_(NULL), |
76 raster_scale_(0.f), | 77 raster_scale_(0.f), |
77 client_(NULL) { | 78 client_(NULL) { |
78 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | 79 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
79 layer_animation_controller_->AddValueObserver(this); | 80 layer_animation_controller_->AddValueObserver(this); |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 870 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
870 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT( | 871 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT( |
871 "devtools.timeline.layers"), | 872 "devtools.timeline.layers"), |
872 &is_tracing); | 873 &is_tracing); |
873 if (is_tracing) | 874 if (is_tracing) |
874 layer->SetDebugInfo(TakeDebugInfo()); | 875 layer->SetDebugInfo(TakeDebugInfo()); |
875 | 876 |
876 layer->SetDoubleSided(double_sided_); | 877 layer->SetDoubleSided(double_sided_); |
877 layer->SetDrawCheckerboardForMissingTiles( | 878 layer->SetDrawCheckerboardForMissingTiles( |
878 draw_checkerboard_for_missing_tiles_); | 879 draw_checkerboard_for_missing_tiles_); |
879 layer->SetForceRenderSurface(force_render_surface_); | |
880 layer->SetDrawsContent(DrawsContent()); | 880 layer->SetDrawsContent(DrawsContent()); |
881 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 881 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
882 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) | 882 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) |
883 layer->SetFilters(filters_); | 883 layer->SetFilters(filters_); |
884 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); | 884 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); |
885 layer->SetBackgroundFilters(background_filters()); | 885 layer->SetBackgroundFilters(background_filters()); |
886 layer->SetMasksToBounds(masks_to_bounds_); | 886 layer->SetMasksToBounds(masks_to_bounds_); |
887 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 887 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
888 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 888 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
889 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 889 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
(...skipping 13 matching lines...) Expand all Loading... | |
903 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 903 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
904 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) | 904 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) |
905 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 905 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
906 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 906 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); |
907 layer->Set3dSortingContextId(sorting_context_id_); | 907 layer->Set3dSortingContextId(sorting_context_id_); |
908 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 908 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
909 | 909 |
910 layer->SetScrollClipLayer(scroll_clip_layer_id_); | 910 layer->SetScrollClipLayer(scroll_clip_layer_id_); |
911 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 911 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
912 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 912 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
913 layer->SetShouldHaveRenderSurface(ShouldHaveRenderSurface()); | |
danakj
2014/08/26 18:06:13
could this just create or destroy the render surfa
awoloszyn
2014/08/28 19:31:42
I changed the impl-side to just create/destroy it'
| |
913 | 914 |
914 LayerImpl* scroll_parent = NULL; | 915 LayerImpl* scroll_parent = NULL; |
915 if (scroll_parent_) { | 916 if (scroll_parent_) { |
916 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 917 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
917 DCHECK(scroll_parent); | 918 DCHECK(scroll_parent); |
918 } | 919 } |
919 | 920 |
920 layer->SetScrollParent(scroll_parent); | 921 layer->SetScrollParent(scroll_parent); |
921 if (scroll_children_) { | 922 if (scroll_children_) { |
922 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 923 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1072 } | 1073 } |
1073 | 1074 |
1074 scoped_refptr<base::debug::ConvertableToTraceFormat> Layer::TakeDebugInfo() { | 1075 scoped_refptr<base::debug::ConvertableToTraceFormat> Layer::TakeDebugInfo() { |
1075 if (client_) | 1076 if (client_) |
1076 return client_->TakeDebugInfo(); | 1077 return client_->TakeDebugInfo(); |
1077 else | 1078 else |
1078 return NULL; | 1079 return NULL; |
1079 } | 1080 } |
1080 | 1081 |
1081 void Layer::CreateRenderSurface() { | 1082 void Layer::CreateRenderSurface() { |
1082 DCHECK(!draw_properties_.render_surface); | 1083 DCHECK(!render_surface_); |
1083 draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this)); | 1084 render_surface_ = make_scoped_ptr(new RenderSurface(this)); |
1084 draw_properties_.render_target = this; | 1085 draw_properties_.render_target = this; |
danakj
2014/08/26 18:06:12
hm.... can this move to CalcDrawProps?
awoloszyn
2014/08/28 19:31:42
I moved setting draw_properties_.render_target int
| |
1085 } | 1086 } |
1086 | 1087 |
1087 void Layer::ClearRenderSurface() { | 1088 void Layer::ClearRenderSurface() { |
1088 draw_properties_.render_surface.reset(); | 1089 render_surface_.reset(); |
1089 } | 1090 } |
1090 | 1091 |
1091 void Layer::ClearRenderSurfaceLayerList() { | 1092 void Layer::ClearRenderSurfaceLayerList() { |
1092 if (draw_properties_.render_surface) | 1093 if (render_surface_) |
1093 draw_properties_.render_surface->layer_list().clear(); | 1094 render_surface_->layer_list().clear(); |
1094 } | 1095 } |
1095 | 1096 |
1096 gfx::Vector2dF Layer::ScrollOffsetForAnimation() const { | 1097 gfx::Vector2dF Layer::ScrollOffsetForAnimation() const { |
1097 return TotalScrollOffset(); | 1098 return TotalScrollOffset(); |
1098 } | 1099 } |
1099 | 1100 |
1100 // On<Property>Animated is called due to an ongoing accelerated animation. | 1101 // On<Property>Animated is called due to an ongoing accelerated animation. |
1101 // Since this animation is also being run on the compositor thread, there | 1102 // Since this animation is also being run on the compositor thread, there |
1102 // is no need to request a commit to push this value over, so the value is | 1103 // is no need to request a commit to push this value over, so the value is |
1103 // set directly rather than by calling Set<Property>. | 1104 // set directly rather than by calling Set<Property>. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1236 } | 1237 } |
1237 | 1238 |
1238 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1239 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1239 benchmark->RunOnLayer(this); | 1240 benchmark->RunOnLayer(this); |
1240 } | 1241 } |
1241 | 1242 |
1242 bool Layer::HasDelegatedContent() const { | 1243 bool Layer::HasDelegatedContent() const { |
1243 return false; | 1244 return false; |
1244 } | 1245 } |
1245 | 1246 |
1247 void Layer::SetShouldHaveRenderSurface(bool should_have) { | |
1248 if (should_have_render_surface_ == should_have) | |
1249 return; | |
1250 should_have_render_surface_ = should_have; | |
1251 SetNeedsPushProperties(); | |
danakj
2014/08/26 18:06:13
ITYM SetNeedsCommit() or else this will just stay
awoloszyn
2014/08/28 19:31:42
This functionality has moved, but I added comments
| |
1252 } | |
1253 | |
1254 void Layer::SetRenderSurfaceActive(bool active) { | |
1255 if (active) { | |
1256 if (!render_surface_) | |
1257 CreateRenderSurface(); | |
1258 return; | |
1259 } | |
1260 ClearRenderSurface(); | |
1261 } | |
1262 | |
1246 } // namespace cc | 1263 } // namespace cc |
OLD | NEW |