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

Side by Side Diff: cc/layers/layer.h

Issue 2130053002: cc: Clean up Layer and LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@start_minor_layer_cleanup
Patch Set: Rebase Created 4 years, 5 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
« no previous file with comments | « no previous file | cc/layers/layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CC_LAYERS_LAYER_H_ 5 #ifndef CC_LAYERS_LAYER_H_
6 #define CC_LAYERS_LAYER_H_ 6 #define CC_LAYERS_LAYER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <unordered_map> 13 #include <unordered_map>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "cc/animation/element_id.h" 20 #include "cc/animation/element_id.h"
21 #include "cc/animation/target_property.h" 21 #include "cc/animation/target_property.h"
22 #include "cc/base/cc_export.h" 22 #include "cc/base/cc_export.h"
23 #include "cc/base/region.h" 23 #include "cc/base/region.h"
24 #include "cc/debug/micro_benchmark.h" 24 #include "cc/debug/micro_benchmark.h"
25 #include "cc/input/input_handler.h" 25 #include "cc/input/input_handler.h"
26 #include "cc/layers/layer_collections.h" 26 #include "cc/layers/layer_collections.h"
27 #include "cc/layers/layer_position_constraint.h" 27 #include "cc/layers/layer_position_constraint.h"
28 #include "cc/layers/paint_properties.h" 28 #include "cc/layers/paint_properties.h"
29 #include "cc/output/filter_operations.h" 29 #include "cc/output/filter_operations.h"
30 #include "cc/trees/mutator_host_client.h"
30 #include "cc/trees/property_tree.h" 31 #include "cc/trees/property_tree.h"
31 #include "third_party/skia/include/core/SkColor.h" 32 #include "third_party/skia/include/core/SkColor.h"
32 #include "third_party/skia/include/core/SkPicture.h" 33 #include "third_party/skia/include/core/SkPicture.h"
33 #include "third_party/skia/include/core/SkXfermode.h" 34 #include "third_party/skia/include/core/SkXfermode.h"
34 #include "ui/gfx/geometry/point3_f.h" 35 #include "ui/gfx/geometry/point3_f.h"
35 #include "ui/gfx/geometry/rect.h" 36 #include "ui/gfx/geometry/rect.h"
36 #include "ui/gfx/geometry/rect_f.h" 37 #include "ui/gfx/geometry/rect_f.h"
37 #include "ui/gfx/geometry/scroll_offset.h" 38 #include "ui/gfx/geometry/scroll_offset.h"
38 #include "ui/gfx/transform.h" 39 #include "ui/gfx/transform.h"
39 40
40 namespace gfx { 41 namespace gfx {
41 class BoxF; 42 class BoxF;
42 } 43 }
43 44
44 namespace base { 45 namespace base {
45 namespace trace_event { 46 namespace trace_event {
46 class ConvertableToTraceFormat; 47 class ConvertableToTraceFormat;
47 } 48 }
48 } 49 }
49 50
50 namespace cc { 51 namespace cc {
51 52
53 class AnimationHost;
52 class CopyOutputRequest; 54 class CopyOutputRequest;
53 class LayerAnimationEventObserver; 55 class LayerAnimationEventObserver;
54 class LayerClient; 56 class LayerClient;
55 class LayerImpl; 57 class LayerImpl;
56 class LayerTreeHost; 58 class LayerTreeHost;
57 class LayerTreeHostCommon; 59 class LayerTreeHostCommon;
58 class LayerTreeImpl; 60 class LayerTreeImpl;
59 class LayerTreeSettings; 61 class LayerTreeSettings;
60 class RenderingStatsInstrumentation; 62 class RenderingStatsInstrumentation;
61 class ResourceUpdateQueue; 63 class ResourceUpdateQueue;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void SetMaskLayer(Layer* mask_layer); 128 void SetMaskLayer(Layer* mask_layer);
127 Layer* mask_layer() { return inputs_.mask_layer.get(); } 129 Layer* mask_layer() { return inputs_.mask_layer.get(); }
128 const Layer* mask_layer() const { return inputs_.mask_layer.get(); } 130 const Layer* mask_layer() const { return inputs_.mask_layer.get(); }
129 131
130 virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect); 132 virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect);
131 void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::Rect(bounds())); } 133 void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::Rect(bounds())); }
132 134
133 virtual void SetOpacity(float opacity); 135 virtual void SetOpacity(float opacity);
134 float opacity() const { return inputs_.opacity; } 136 float opacity() const { return inputs_.opacity; }
135 float EffectiveOpacity() const; 137 float EffectiveOpacity() const;
136 bool OpacityIsAnimating() const;
137 bool HasPotentiallyRunningOpacityAnimation() const;
138 virtual bool OpacityCanAnimateOnImplThread() const; 138 virtual bool OpacityCanAnimateOnImplThread() const;
139 139
140 virtual bool AlwaysUseActiveTreeOpacity() const; 140 virtual bool AlwaysUseActiveTreeOpacity() const;
141 141
142 void SetBlendMode(SkXfermode::Mode blend_mode); 142 void SetBlendMode(SkXfermode::Mode blend_mode);
143 SkXfermode::Mode blend_mode() const { return inputs_.blend_mode; } 143 SkXfermode::Mode blend_mode() const { return inputs_.blend_mode; }
144 144
145 void set_draw_blend_mode(SkXfermode::Mode blend_mode) { 145 void set_draw_blend_mode(SkXfermode::Mode blend_mode) {
146 if (draw_blend_mode_ == blend_mode) 146 if (draw_blend_mode_ == blend_mode)
147 return; 147 return;
(...skipping 10 matching lines...) Expand all
158 // drawn over a black and fully transparent background, creating an isolated 158 // drawn over a black and fully transparent background, creating an isolated
159 // group. It should be used along with SetBlendMode(), in order to restrict 159 // group. It should be used along with SetBlendMode(), in order to restrict
160 // layers within the group to blend with layers outside this group. 160 // layers within the group to blend with layers outside this group.
161 void SetIsRootForIsolatedGroup(bool root); 161 void SetIsRootForIsolatedGroup(bool root);
162 bool is_root_for_isolated_group() const { 162 bool is_root_for_isolated_group() const {
163 return inputs_.is_root_for_isolated_group; 163 return inputs_.is_root_for_isolated_group;
164 } 164 }
165 165
166 void SetFilters(const FilterOperations& filters); 166 void SetFilters(const FilterOperations& filters);
167 const FilterOperations& filters() const { return inputs_.filters; } 167 const FilterOperations& filters() const { return inputs_.filters; }
168 bool FilterIsAnimating() const;
169 bool HasPotentiallyRunningFilterAnimation() const;
170 168
171 // Background filters are filters applied to what is behind this layer, when 169 // Background filters are filters applied to what is behind this layer, when
172 // they are viewed through non-opaque regions in this layer. They are used 170 // they are viewed through non-opaque regions in this layer. They are used
173 // through the WebLayer interface, and are not exposed to HTML. 171 // through the WebLayer interface, and are not exposed to HTML.
174 void SetBackgroundFilters(const FilterOperations& filters); 172 void SetBackgroundFilters(const FilterOperations& filters);
175 const FilterOperations& background_filters() const { 173 const FilterOperations& background_filters() const {
176 return inputs_.background_filters; 174 return inputs_.background_filters;
177 } 175 }
178 176
179 virtual void SetContentsOpaque(bool opaque); 177 virtual void SetContentsOpaque(bool opaque);
(...skipping 11 matching lines...) Expand all
191 return gfx::Vector2dF(); 189 return gfx::Vector2dF();
192 } 190 }
193 191
194 void SetPositionConstraint(const LayerPositionConstraint& constraint); 192 void SetPositionConstraint(const LayerPositionConstraint& constraint);
195 const LayerPositionConstraint& position_constraint() const { 193 const LayerPositionConstraint& position_constraint() const {
196 return inputs_.position_constraint; 194 return inputs_.position_constraint;
197 } 195 }
198 196
199 void SetTransform(const gfx::Transform& transform); 197 void SetTransform(const gfx::Transform& transform);
200 const gfx::Transform& transform() const { return inputs_.transform; } 198 const gfx::Transform& transform() const { return inputs_.transform; }
201 bool TransformIsAnimating() const;
202 bool HasPotentiallyRunningTransformAnimation() const;
203 bool HasOnlyTranslationTransforms() const;
204 bool AnimationsPreserveAxisAlignment() const;
205
206 bool MaximumTargetScale(float* max_scale) const;
207 bool AnimationStartScale(float* start_scale) const;
208 199
209 void SetTransformOrigin(const gfx::Point3F&); 200 void SetTransformOrigin(const gfx::Point3F&);
210 gfx::Point3F transform_origin() const { return inputs_.transform_origin; } 201 gfx::Point3F transform_origin() const { return inputs_.transform_origin; }
211 202
212 bool HasAnyAnimationTargetingProperty(TargetProperty::Type property) const;
213
214 bool ScrollOffsetAnimationWasInterrupted() const;
215
216 void SetScrollParent(Layer* parent); 203 void SetScrollParent(Layer* parent);
217 204
218 Layer* scroll_parent() { return inputs_.scroll_parent; } 205 Layer* scroll_parent() { return inputs_.scroll_parent; }
219 const Layer* scroll_parent() const { return inputs_.scroll_parent; } 206 const Layer* scroll_parent() const { return inputs_.scroll_parent; }
220 207
221 void AddScrollChild(Layer* child);
222 void RemoveScrollChild(Layer* child);
223
224 std::set<Layer*>* scroll_children() { return scroll_children_.get(); } 208 std::set<Layer*>* scroll_children() { return scroll_children_.get(); }
225 const std::set<Layer*>* scroll_children() const { 209 const std::set<Layer*>* scroll_children() const {
226 return scroll_children_.get(); 210 return scroll_children_.get();
227 } 211 }
228 212
229 void SetClipParent(Layer* ancestor); 213 void SetClipParent(Layer* ancestor);
230 214
231 Layer* clip_parent() { return inputs_.clip_parent; } 215 Layer* clip_parent() { return inputs_.clip_parent; }
232 const Layer* clip_parent() const { return inputs_.clip_parent; } 216 const Layer* clip_parent() const { return inputs_.clip_parent; }
233 217
234 void AddClipChild(Layer* child);
235 void RemoveClipChild(Layer* child);
236
237 std::set<Layer*>* clip_children() { return clip_children_.get(); } 218 std::set<Layer*>* clip_children() { return clip_children_.get(); }
238 const std::set<Layer*>* clip_children() const { 219 const std::set<Layer*>* clip_children() const {
239 return clip_children_.get(); 220 return clip_children_.get();
240 } 221 }
241 222
242 // TODO(enne): Fix style here (and everywhere) once LayerImpl does the same. 223 // TODO(enne): Fix style here (and everywhere) once LayerImpl does the same.
243 gfx::Transform screen_space_transform() const; 224 gfx::Transform screen_space_transform() const;
244 225
245 void set_num_unclipped_descendants(size_t descendants) { 226 void set_num_unclipped_descendants(size_t descendants) {
246 num_unclipped_descendants_ = descendants; 227 num_unclipped_descendants_ = descendants;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 virtual ScrollbarLayerInterface* ToScrollbarLayer(); 396 virtual ScrollbarLayerInterface* ToScrollbarLayer();
416 397
417 virtual sk_sp<SkPicture> GetPicture() const; 398 virtual sk_sp<SkPicture> GetPicture() const;
418 399
419 // Constructs a LayerImpl of the correct runtime type for this Layer type. 400 // Constructs a LayerImpl of the correct runtime type for this Layer type.
420 virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); 401 virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
421 402
422 bool NeedsDisplayForTesting() const { return !inputs_.update_rect.IsEmpty(); } 403 bool NeedsDisplayForTesting() const { return !inputs_.update_rect.IsEmpty(); }
423 void ResetNeedsDisplayForTesting() { inputs_.update_rect = gfx::Rect(); } 404 void ResetNeedsDisplayForTesting() { inputs_.update_rect = gfx::Rect(); }
424 405
425 RenderingStatsInstrumentation* rendering_stats_instrumentation() const;
426
427 const PaintProperties& paint_properties() const { 406 const PaintProperties& paint_properties() const {
428 return paint_properties_; 407 return paint_properties_;
429 } 408 }
430 409
431 void SetNeedsPushProperties(); 410 void SetNeedsPushProperties();
432 void ResetNeedsPushPropertiesForTesting(); 411 void ResetNeedsPushPropertiesForTesting();
433 412
434 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); 413 virtual void RunMicroBenchmark(MicroBenchmark* benchmark);
435 414
436 void Set3dSortingContextId(int id); 415 void Set3dSortingContextId(int id);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 void SetMutableProperties(uint32_t properties); 480 void SetMutableProperties(uint32_t properties);
502 uint32_t mutable_properties() const { return inputs_.mutable_properties; } 481 uint32_t mutable_properties() const { return inputs_.mutable_properties; }
503 482
504 bool HasActiveAnimationForTesting() const; 483 bool HasActiveAnimationForTesting() const;
505 484
506 void SetHasWillChangeTransformHint(bool has_will_change); 485 void SetHasWillChangeTransformHint(bool has_will_change);
507 bool has_will_change_transform_hint() const { 486 bool has_will_change_transform_hint() const {
508 return inputs_.has_will_change_transform_hint; 487 return inputs_.has_will_change_transform_hint;
509 } 488 }
510 489
490 AnimationHost* GetAnimationHost() const;
491
492 ElementListType GetElementTypeForAnimation() const;
493
511 protected: 494 protected:
512 friend class LayerImpl; 495 friend class LayerImpl;
513 friend class TreeSynchronizer; 496 friend class TreeSynchronizer;
514 virtual ~Layer(); 497 virtual ~Layer();
515 Layer(); 498 Layer();
516 499
517 // These SetNeeds functions are in order of severity of update: 500 // These SetNeeds functions are in order of severity of update:
518 // 501 //
519 // Called when this layer has been modified in some way, but isn't sure 502 // Called when this layer has been modified in some way, but isn't sure
520 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers 503 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 gfx::ScrollOffset ScrollOffsetForAnimation() const; 557 gfx::ScrollOffset ScrollOffsetForAnimation() const;
575 void OnFilterAnimated(const FilterOperations& filters); 558 void OnFilterAnimated(const FilterOperations& filters);
576 void OnOpacityAnimated(float opacity); 559 void OnOpacityAnimated(float opacity);
577 void OnTransformAnimated(const gfx::Transform& transform); 560 void OnTransformAnimated(const gfx::Transform& transform);
578 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); 561 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset);
579 void OnTransformIsCurrentlyAnimatingChanged(bool is_animating); 562 void OnTransformIsCurrentlyAnimatingChanged(bool is_animating);
580 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating); 563 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating);
581 void OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating); 564 void OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating);
582 void OnOpacityIsPotentiallyAnimatingChanged(bool has_potential_animation); 565 void OnOpacityIsPotentiallyAnimatingChanged(bool has_potential_animation);
583 566
567 bool FilterIsAnimating() const;
568 bool TransformIsAnimating() const;
569 bool ScrollOffsetAnimationWasInterrupted() const;
570 bool HasOnlyTranslationTransforms() const;
571
572 void AddScrollChild(Layer* child);
573 void RemoveScrollChild(Layer* child);
574
575 void AddClipChild(Layer* child);
576 void RemoveClipChild(Layer* child);
577
584 void SetParent(Layer* layer); 578 void SetParent(Layer* layer);
585 bool DescendantIsFixedToContainerLayer() const; 579 bool DescendantIsFixedToContainerLayer() const;
586 580
587 // This should only be called from RemoveFromParent(). 581 // This should only be called from RemoveFromParent().
588 void RemoveChildOrDependent(Layer* child); 582 void RemoveChildOrDependent(Layer* child);
589 583
590 // If this layer has a scroll parent, it removes |this| from its list of 584 // If this layer has a scroll parent, it removes |this| from its list of
591 // scroll children. 585 // scroll children.
592 void RemoveFromScrollTree(); 586 void RemoveFromScrollTree();
593 587
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 // These all act like draw properties, so don't need push properties. 718 // These all act like draw properties, so don't need push properties.
725 gfx::Rect visible_layer_rect_; 719 gfx::Rect visible_layer_rect_;
726 size_t num_unclipped_descendants_; 720 size_t num_unclipped_descendants_;
727 721
728 DISALLOW_COPY_AND_ASSIGN(Layer); 722 DISALLOW_COPY_AND_ASSIGN(Layer);
729 }; 723 };
730 724
731 } // namespace cc 725 } // namespace cc
732 726
733 #endif // CC_LAYERS_LAYER_H_ 727 #endif // CC_LAYERS_LAYER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/layers/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698