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
3 // found in the LICENSE file.
5 #ifndef CC_LAYERS_LAYER_H_
6 #define CC_LAYERS_LAYER_H_
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/observer_list.h"
15 #include "cc/animation/layer_animation_controller.h"
16 #include "cc/animation/layer_animation_value_observer.h"
17 #include "cc/animation/layer_animation_value_provider.h"
18 #include "cc/base/cc_export.h"
19 #include "cc/base/region.h"
20 #include "cc/base/scoped_ptr_vector.h"
21 #include "cc/debug/frame_timing_request.h"
22 #include "cc/debug/micro_benchmark.h"
23 #include "cc/layers/draw_properties.h"
24 #include "cc/layers/layer_lists.h"
25 #include "cc/layers/layer_position_constraint.h"
26 #include "cc/layers/paint_properties.h"
27 #include "cc/layers/render_surface.h"
28 #include "cc/layers/scroll_blocks_on.h"
29 #include "cc/output/filter_operations.h"
30 #include "cc/trees/property_tree.h"
31 #include "skia/ext/refptr.h"
32 #include "third_party/skia/include/core/SkColor.h"
33 #include "third_party/skia/include/core/SkImageFilter.h"
34 #include "third_party/skia/include/core/SkPicture.h"
35 #include "third_party/skia/include/core/SkXfermode.h"
36 #include "ui/gfx/geometry/point3_f.h"
37 #include "ui/gfx/geometry/rect.h"
38 #include "ui/gfx/geometry/rect_f.h"
39 #include "ui/gfx/geometry/scroll_offset.h"
40 #include "ui/gfx/transform.h"
47 namespace trace_event
{
48 class ConvertableToTraceFormat
;
55 class AnimationDelegate
;
56 struct AnimationEvent
;
57 class CopyOutputRequest
;
58 class LayerAnimationEventObserver
;
63 class LayerTreeHostCommon
;
65 class LayerTreeSettings
;
66 class RenderingStatsInstrumentation
;
67 class ResourceUpdateQueue
;
68 class ScrollbarLayerInterface
;
69 class SimpleEnclosedRegion
;
70 struct AnimationEvent
;
72 // Base class for composited layers. Special layer types are derived from
74 class CC_EXPORT Layer
: public base::RefCounted
<Layer
>,
75 public LayerAnimationValueObserver
,
76 public LayerAnimationValueProvider
{
78 typedef RenderSurfaceLayerList RenderSurfaceListType
;
79 typedef LayerList LayerListType
;
80 typedef RenderSurface RenderSurfaceType
;
86 static scoped_refptr
<Layer
> Create(const LayerSettings
& settings
);
88 int id() const { return layer_id_
; }
91 Layer
* parent() { return parent_
; }
92 const Layer
* parent() const { return parent_
; }
93 void AddChild(scoped_refptr
<Layer
> child
);
94 void InsertChild(scoped_refptr
<Layer
> child
, size_t index
);
95 void ReplaceChild(Layer
* reference
, scoped_refptr
<Layer
> new_layer
);
96 void RemoveFromParent();
97 void RemoveAllChildren();
98 void SetChildren(const LayerList
& children
);
99 bool HasAncestor(const Layer
* ancestor
) const;
101 const LayerList
& children() const { return children_
; }
102 Layer
* child_at(size_t index
) { return children_
[index
].get(); }
104 // This requests the layer and its subtree be rendered and given to the
105 // callback. If the copy is unable to be produced (the layer is destroyed
106 // first), then the callback is called with a nullptr/empty result. If the
107 // request's source property is set, any prior uncommitted requests having the
108 // same source will be aborted.
109 void RequestCopyOfOutput(scoped_ptr
<CopyOutputRequest
> request
);
110 bool HasCopyRequest() const {
111 return !copy_requests_
.empty();
114 virtual void SetBackgroundColor(SkColor background_color
);
115 SkColor
background_color() const { return background_color_
; }
116 // If contents_opaque(), return an opaque color else return a
117 // non-opaque color. Tries to return background_color(), if possible.
118 SkColor
SafeOpaqueBackgroundColor() const;
120 // A layer's bounds are in logical, non-page-scaled pixels (however, the
121 // root layer's bounds are in physical pixels).
122 void SetBounds(const gfx::Size
& bounds
);
123 gfx::Size
bounds() const { return bounds_
; }
125 void SetMasksToBounds(bool masks_to_bounds
);
126 bool masks_to_bounds() const { return masks_to_bounds_
; }
128 void SetMaskLayer(Layer
* mask_layer
);
129 Layer
* mask_layer() { return mask_layer_
.get(); }
130 const Layer
* mask_layer() const { return mask_layer_
.get(); }
132 virtual void SetNeedsDisplayRect(const gfx::Rect
& dirty_rect
);
133 void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::Rect(bounds())); }
135 void SetOpacity(float opacity
);
136 float opacity() const { return opacity_
; }
137 bool OpacityIsAnimating() const;
138 bool HasPotentiallyRunningOpacityAnimation() const;
139 virtual bool OpacityCanAnimateOnImplThread() const;
141 void SetBlendMode(SkXfermode::Mode blend_mode
);
142 SkXfermode::Mode
blend_mode() const { return blend_mode_
; }
144 bool uses_default_blend_mode() const {
145 return blend_mode_
== SkXfermode::kSrcOver_Mode
;
148 // A layer is root for an isolated group when it and all its descendants are
149 // drawn over a black and fully transparent background, creating an isolated
150 // group. It should be used along with SetBlendMode(), in order to restrict
151 // layers within the group to blend with layers outside this group.
152 void SetIsRootForIsolatedGroup(bool root
);
153 bool is_root_for_isolated_group() const {
154 return is_root_for_isolated_group_
;
157 void SetFilters(const FilterOperations
& filters
);
158 const FilterOperations
& filters() const { return filters_
; }
159 bool FilterIsAnimating() const;
161 // Background filters are filters applied to what is behind this layer, when
162 // they are viewed through non-opaque regions in this layer. They are used
163 // through the WebLayer interface, and are not exposed to HTML.
164 void SetBackgroundFilters(const FilterOperations
& filters
);
165 const FilterOperations
& background_filters() const {
166 return background_filters_
;
169 virtual void SetContentsOpaque(bool opaque
);
170 bool contents_opaque() const { return contents_opaque_
; }
172 void SetPosition(const gfx::PointF
& position
);
173 gfx::PointF
position() const { return position_
; }
175 // A layer that is a container for fixed position layers cannot be both
176 // scrollable and have a non-identity transform.
177 void SetIsContainerForFixedPositionLayers(bool container
);
178 bool IsContainerForFixedPositionLayers() const;
180 gfx::Vector2dF
FixedContainerSizeDelta() const {
181 return gfx::Vector2dF();
184 void SetPositionConstraint(const LayerPositionConstraint
& constraint
);
185 const LayerPositionConstraint
& position_constraint() const {
186 return position_constraint_
;
189 void SetTransform(const gfx::Transform
& transform
);
190 const gfx::Transform
& transform() const { return transform_
; }
191 bool TransformIsAnimating() const;
192 bool HasPotentiallyRunningTransformAnimation() const;
193 bool AnimationsPreserveAxisAlignment() const;
194 bool transform_is_invertible() const { return transform_is_invertible_
; }
196 void SetTransformOrigin(const gfx::Point3F
&);
197 gfx::Point3F
transform_origin() const { return transform_origin_
; }
199 bool ScrollOffsetAnimationWasInterrupted() const;
201 void SetScrollParent(Layer
* parent
);
203 Layer
* scroll_parent() { return scroll_parent_
; }
204 const Layer
* scroll_parent() const { return scroll_parent_
; }
206 void AddScrollChild(Layer
* child
);
207 void RemoveScrollChild(Layer
* child
);
209 std::set
<Layer
*>* scroll_children() { return scroll_children_
.get(); }
210 const std::set
<Layer
*>* scroll_children() const {
211 return scroll_children_
.get();
214 void SetClipParent(Layer
* ancestor
);
216 Layer
* clip_parent() { return clip_parent_
; }
217 const Layer
* clip_parent() const {
221 void AddClipChild(Layer
* child
);
222 void RemoveClipChild(Layer
* child
);
224 std::set
<Layer
*>* clip_children() { return clip_children_
.get(); }
225 const std::set
<Layer
*>* clip_children() const {
226 return clip_children_
.get();
229 DrawProperties
<Layer
>& draw_properties() { return draw_properties_
; }
230 const DrawProperties
<Layer
>& draw_properties() const {
231 return draw_properties_
;
234 // The following are shortcut accessors to get various information from
236 const gfx::Transform
& draw_transform() const {
237 return draw_properties_
.target_space_transform
;
239 const gfx::Transform
& screen_space_transform() const {
240 return draw_properties_
.screen_space_transform
;
242 float draw_opacity() const { return draw_properties_
.opacity
; }
243 bool draw_opacity_is_animating() const {
244 return draw_properties_
.opacity_is_animating
;
246 bool draw_transform_is_animating() const {
247 return draw_properties_
.target_space_transform_is_animating
;
249 bool screen_space_transform_is_animating() const {
250 return draw_properties_
.screen_space_transform_is_animating
;
252 bool screen_space_opacity_is_animating() const {
253 return draw_properties_
.screen_space_opacity_is_animating
;
255 bool is_clipped() const { return draw_properties_
.is_clipped
; }
256 gfx::Rect
clip_rect() const { return draw_properties_
.clip_rect
; }
257 gfx::Rect
drawable_content_rect() const {
258 return draw_properties_
.drawable_content_rect
;
260 gfx::Rect
visible_layer_rect() const {
261 return draw_properties_
.visible_layer_rect
;
263 Layer
* render_target() {
264 DCHECK(!draw_properties_
.render_target
||
265 draw_properties_
.render_target
->render_surface());
266 return draw_properties_
.render_target
;
268 const Layer
* render_target() const {
269 DCHECK(!draw_properties_
.render_target
||
270 draw_properties_
.render_target
->render_surface());
271 return draw_properties_
.render_target
;
273 size_t num_unclipped_descendants() const {
274 return draw_properties_
.num_unclipped_descendants
;
277 RenderSurface
* render_surface() const { return render_surface_
.get(); }
278 void SetScrollOffset(const gfx::ScrollOffset
& scroll_offset
);
279 void SetScrollCompensationAdjustment(
280 const gfx::Vector2dF
& scroll_compensation_adjustment
);
281 gfx::Vector2dF
ScrollCompensationAdjustment() const;
283 gfx::ScrollOffset
scroll_offset() const { return scroll_offset_
; }
284 void SetScrollOffsetFromImplSide(const gfx::ScrollOffset
& scroll_offset
);
286 void SetScrollClipLayerId(int clip_layer_id
);
287 bool scrollable() const { return scroll_clip_layer_id_
!= INVALID_ID
; }
289 void SetUserScrollable(bool horizontal
, bool vertical
);
290 bool user_scrollable_horizontal() const {
291 return user_scrollable_horizontal_
;
293 bool user_scrollable_vertical() const { return user_scrollable_vertical_
; }
295 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread
);
296 bool should_scroll_on_main_thread() const {
297 return should_scroll_on_main_thread_
;
300 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers
);
301 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_
; }
303 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers
);
304 bool have_scroll_event_handlers() const {
305 return have_scroll_event_handlers_
;
308 void SetNonFastScrollableRegion(const Region
& non_fast_scrollable_region
);
309 const Region
& non_fast_scrollable_region() const {
310 return non_fast_scrollable_region_
;
313 void SetTouchEventHandlerRegion(const Region
& touch_event_handler_region
);
314 const Region
& touch_event_handler_region() const {
315 return touch_event_handler_region_
;
318 void SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on
);
319 ScrollBlocksOn
scroll_blocks_on() const { return scroll_blocks_on_
; }
321 void set_did_scroll_callback(const base::Closure
& callback
) {
322 did_scroll_callback_
= callback
;
325 void SetDrawCheckerboardForMissingTiles(bool checkerboard
);
326 bool draw_checkerboard_for_missing_tiles() const {
327 return draw_checkerboard_for_missing_tiles_
;
330 void SetForceRenderSurface(bool force_render_surface
);
331 bool force_render_surface() const { return force_render_surface_
; }
333 gfx::Vector2dF
ScrollDelta() const { return gfx::Vector2dF(); }
334 gfx::ScrollOffset
CurrentScrollOffset() const { return scroll_offset_
; }
336 void SetDoubleSided(bool double_sided
);
337 bool double_sided() const { return double_sided_
; }
339 void SetShouldFlattenTransform(bool flatten
);
340 bool should_flatten_transform() const { return should_flatten_transform_
; }
342 bool Is3dSorted() const { return sorting_context_id_
!= 0; }
344 void set_use_parent_backface_visibility(bool use
) {
345 use_parent_backface_visibility_
= use
;
347 bool use_parent_backface_visibility() const {
348 return use_parent_backface_visibility_
;
351 virtual void SetLayerTreeHost(LayerTreeHost
* host
);
353 virtual bool HasDelegatedContent() const;
354 bool HasContributingDelegatedRenderPasses() const { return false; }
356 void SetIsDrawable(bool is_drawable
);
358 void SetHideLayerAndSubtree(bool hide
);
359 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_
; }
361 void SetReplicaLayer(Layer
* layer
);
362 Layer
* replica_layer() { return replica_layer_
.get(); }
363 const Layer
* replica_layer() const { return replica_layer_
.get(); }
365 bool has_mask() const { return !!mask_layer_
.get(); }
366 bool has_replica() const { return !!replica_layer_
.get(); }
367 bool replica_has_mask() const {
368 return replica_layer_
.get() &&
369 (mask_layer_
.get() || replica_layer_
->mask_layer_
.get());
372 int NumDescendantsThatDrawContent() const;
374 // This is only virtual for tests.
375 // TODO(awoloszyn): Remove this once we no longer need it for tests
376 virtual bool DrawsContent() const;
378 // This methods typically need to be overwritten by derived classes.
379 virtual void SavePaintProperties();
380 // Returns true iff anything was updated that needs to be committed.
381 virtual bool Update();
382 virtual bool NeedMoreUpdates();
383 virtual void SetIsMask(bool is_mask
) {}
384 virtual void ReduceMemoryUsage() {}
385 virtual void OnOutputSurfaceCreated() {}
386 virtual bool IsSuitableForGpuRasterization() const;
388 virtual scoped_refptr
<base::trace_event::ConvertableToTraceFormat
>
391 void SetLayerClient(LayerClient
* client
) { client_
= client
; }
393 virtual void PushPropertiesTo(LayerImpl
* layer
);
395 void CreateRenderSurface();
396 void ClearRenderSurface();
398 void ClearRenderSurfaceLayerList();
400 LayerTreeHost
* layer_tree_host() { return layer_tree_host_
; }
401 const LayerTreeHost
* layer_tree_host() const { return layer_tree_host_
; }
403 bool AddAnimation(scoped_ptr
<Animation
> animation
);
404 void PauseAnimation(int animation_id
, double time_offset
);
405 void RemoveAnimation(int animation_id
);
406 void RemoveAnimation(int animation_id
, Animation::TargetProperty property
);
407 LayerAnimationController
* layer_animation_controller() const {
408 return layer_animation_controller_
.get();
410 void SetLayerAnimationControllerForTest(
411 scoped_refptr
<LayerAnimationController
> controller
);
413 void set_layer_animation_delegate(AnimationDelegate
* delegate
) {
414 DCHECK(layer_animation_controller_
);
415 layer_animation_controller_
->set_layer_animation_delegate(delegate
);
418 bool HasActiveAnimation() const;
419 void RegisterForAnimations(AnimationRegistrar
* registrar
);
421 void AddLayerAnimationEventObserver(
422 LayerAnimationEventObserver
* animation_observer
);
423 void RemoveLayerAnimationEventObserver(
424 LayerAnimationEventObserver
* animation_observer
);
426 virtual ScrollbarLayerInterface
* ToScrollbarLayer();
428 virtual skia::RefPtr
<SkPicture
> GetPicture() const;
430 // Constructs a LayerImpl of the correct runtime type for this Layer type.
431 virtual scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
);
433 bool NeedsDisplayForTesting() const { return !update_rect_
.IsEmpty(); }
434 void ResetNeedsDisplayForTesting() { update_rect_
= gfx::Rect(); }
436 RenderingStatsInstrumentation
* rendering_stats_instrumentation() const;
438 const PaintProperties
& paint_properties() const {
439 return paint_properties_
;
442 void SetNeedsPushProperties();
443 bool needs_push_properties() const { return needs_push_properties_
; }
444 bool descendant_needs_push_properties() const {
445 return num_dependents_need_push_properties_
> 0;
447 void reset_needs_push_properties_for_testing() {
448 needs_push_properties_
= false;
451 virtual void RunMicroBenchmark(MicroBenchmark
* benchmark
);
453 void Set3dSortingContextId(int id
);
454 int sorting_context_id() const { return sorting_context_id_
; }
456 void set_property_tree_sequence_number(int sequence_number
) {
457 property_tree_sequence_number_
= sequence_number
;
460 void SetTransformTreeIndex(int index
);
461 int transform_tree_index() const;
463 void SetClipTreeIndex(int index
);
464 int clip_tree_index() const;
466 void SetOpacityTreeIndex(int index
);
467 int opacity_tree_index() const;
469 void set_offset_to_transform_parent(gfx::Vector2dF offset
) {
470 if (offset_to_transform_parent_
== offset
)
472 offset_to_transform_parent_
= offset
;
473 SetNeedsPushProperties();
475 gfx::Vector2dF
offset_to_transform_parent() const {
476 return offset_to_transform_parent_
;
479 // TODO(vollick): Once we transition to transform and clip trees, rename these
480 // functions and related values. The "from property trees" functions below
481 // use the transform and clip trees. Eventually, we will use these functions
482 // to compute the official values, but these functions are retained for
483 // testing purposes until we've migrated.
485 const gfx::Rect
& visible_rect_from_property_trees() const {
486 return visible_rect_from_property_trees_
;
488 void set_visible_rect_from_property_trees(const gfx::Rect
& rect
) {
489 // No push properties here, as this acts like a draw property.
490 visible_rect_from_property_trees_
= rect
;
493 void set_should_flatten_transform_from_property_tree(bool should_flatten
) {
494 if (should_flatten_transform_from_property_tree_
== should_flatten
)
496 should_flatten_transform_from_property_tree_
= should_flatten
;
497 SetNeedsPushProperties();
499 bool should_flatten_transform_from_property_tree() const {
500 return should_flatten_transform_from_property_tree_
;
503 // TODO(vollick): These values are temporary and will be removed as soon as
504 // render surface determinations are moved out of CDP. They only exist because
505 // certain logic depends on whether or not a layer would render to a separate
506 // surface, but CDP destroys surfaces and targets it doesn't need, so without
507 // this boolean, this is impossible to determine after the fact without
508 // wastefully recomputing it. This is public for the time being so that it can
509 // be accessed from CDP.
510 bool has_render_surface() const {
511 return has_render_surface_
;
514 // Sets new frame timing requests for this layer.
515 void SetFrameTimingRequests(const std::vector
<FrameTimingRequest
>& requests
);
517 // Accessor for unit tests
518 const std::vector
<FrameTimingRequest
>& FrameTimingRequests() const {
519 return frame_timing_requests_
;
522 void DidBeginTracing();
523 void set_num_layer_or_descandant_with_copy_request(
524 int num_layer_or_descendants_with_copy_request
) {
525 num_layer_or_descendants_with_copy_request_
=
526 num_layer_or_descendants_with_copy_request
;
529 void set_num_layer_or_descandant_with_input_handler(
530 int num_layer_or_descendants_with_input_handler
) {
531 num_layer_or_descendants_with_input_handler_
=
532 num_layer_or_descendants_with_input_handler
;
535 int num_layer_or_descendants_with_input_handler() {
536 return num_layer_or_descendants_with_input_handler_
;
539 void set_num_children_with_scroll_parent(
540 int num_children_with_scroll_parent
) {
541 num_children_with_scroll_parent_
= num_children_with_scroll_parent
;
544 int num_children_with_scroll_parent() {
545 return num_children_with_scroll_parent_
;
548 void set_visited(bool visited
);
550 void set_layer_or_descendant_is_drawn(bool layer_or_descendant_is_drawn
);
551 bool layer_or_descendant_is_drawn();
552 void set_sorted_for_recursion(bool sorted_for_recursion
);
553 bool sorted_for_recursion();
556 friend class LayerImpl
;
557 friend class TreeSynchronizer
;
560 explicit Layer(const LayerSettings
& settings
);
562 // These SetNeeds functions are in order of severity of update:
564 // Called when this layer has been modified in some way, but isn't sure
565 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers
566 // before it knows whether or not a commit is required.
567 void SetNeedsUpdate();
568 // Called when a property has been modified in a way that the layer
569 // knows immediately that a commit is required. This implies SetNeedsUpdate
570 // as well as SetNeedsPushProperties to push that property.
571 void SetNeedsCommit();
572 // This is identical to SetNeedsCommit, but the former requests a rebuild of
573 // the property trees.
574 void SetNeedsCommitNoRebuild();
575 // Called when there's been a change in layer structure. Implies both
576 // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties.
577 void SetNeedsFullTreeSync();
579 // Called when the next commit should wait until the pending tree is activated
580 // before finishing the commit and unblocking the main thread. Used to ensure
581 // unused resources on the impl thread are returned before commit completes.
582 void SetNextCommitWaitsForActivation();
584 // Will recalculate whether the layer draws content and set draws_content_
586 void UpdateDrawsContent(bool has_drawable_content
);
587 virtual bool HasDrawableContent() const;
589 // Called when the layer's number of drawable descendants changes.
590 void AddDrawableDescendants(int num
);
592 void AddDependentNeedsPushProperties();
593 void RemoveDependentNeedsPushProperties();
594 bool parent_should_know_need_push_properties() const {
595 return needs_push_properties() || descendant_needs_push_properties();
598 bool IsPropertyChangeAllowed() const;
600 // This flag is set when the layer needs to push properties to the impl
602 bool needs_push_properties_
;
604 // The number of direct children or dependent layers that need to be recursed
605 // to in order for them or a descendent of them to push properties to the impl
607 int num_dependents_need_push_properties_
;
609 // Tracks whether this layer may have changed stacking order with its
611 bool stacking_order_changed_
;
613 // The update rect is the region of the compositor resource that was
614 // actually updated by the compositor. For layers that may do updating
615 // outside the compositor's control (i.e. plugin layers), this information
616 // is not available and the update rect will remain empty.
617 // Note this rect is in layer space (not content space).
618 gfx::Rect update_rect_
;
620 scoped_refptr
<Layer
> mask_layer_
;
624 // When true, the layer is about to perform an update. Any commit requests
625 // will be handled implicitly after the update completes.
626 bool ignore_set_needs_commit_
;
628 // Layers that share a sorting context id will be sorted together in 3d
629 // space. 0 is a special value that means this layer will not be sorted and
630 // will be drawn in paint order.
631 int sorting_context_id_
;
634 friend class base::RefCounted
<Layer
>;
635 friend class LayerTreeHostCommon
;
636 void SetParent(Layer
* layer
);
637 bool DescendantIsFixedToContainerLayer() const;
639 // This should only be called during BeginMainFrame since it does not
641 void SetHasRenderSurface(bool has_render_surface
);
643 // This should only be called from RemoveFromParent().
644 void RemoveChildOrDependent(Layer
* child
);
646 // LayerAnimationValueProvider implementation.
647 gfx::ScrollOffset
ScrollOffsetForAnimation() const override
;
649 // LayerAnimationValueObserver implementation.
650 void OnFilterAnimated(const FilterOperations
& filters
) override
;
651 void OnOpacityAnimated(float opacity
) override
;
652 void OnTransformAnimated(const gfx::Transform
& transform
) override
;
653 void OnScrollOffsetAnimated(const gfx::ScrollOffset
& scroll_offset
) override
;
654 void OnAnimationWaitingForDeletion() override
;
655 bool IsActive() const override
;
657 // If this layer has a scroll parent, it removes |this| from its list of
659 void RemoveFromScrollTree();
661 // If this layer has a clip parent, it removes |this| from its list of clip
663 void RemoveFromClipTree();
665 // When we detach or attach layer to new LayerTreeHost, all property trees'
666 // indices becomes invalid.
667 void InvalidatePropertyTreesIndices();
669 void UpdateNumCopyRequestsForSubtree(bool add
);
670 void UpdateNumInputHandlersForSubtree(bool add
);
675 // Layer instances have a weak pointer to their LayerTreeHost.
676 // This pointer value is nil when a Layer is not in a tree and is
677 // updated via SetLayerTreeHost() if a layer moves between trees.
678 LayerTreeHost
* layer_tree_host_
;
680 scoped_refptr
<LayerAnimationController
> layer_animation_controller_
;
685 gfx::ScrollOffset scroll_offset_
;
686 gfx::Vector2dF scroll_compensation_adjustment_
;
687 // This variable indicates which ancestor layer (if any) whose size,
688 // transformed relative to this layer, defines the maximum scroll offset for
690 int scroll_clip_layer_id_
;
691 int num_descendants_that_draw_content_
;
692 int transform_tree_index_
;
693 int opacity_tree_index_
;
694 int clip_tree_index_
;
695 int property_tree_sequence_number_
;
696 int num_layer_or_descendants_with_copy_request_
;
697 int num_layer_or_descendants_with_input_handler_
;
698 int num_children_with_scroll_parent_
;
699 gfx::Vector2dF offset_to_transform_parent_
;
700 bool should_flatten_transform_from_property_tree_
: 1;
701 bool should_scroll_on_main_thread_
: 1;
702 bool have_wheel_event_handlers_
: 1;
703 bool have_scroll_event_handlers_
: 1;
704 bool user_scrollable_horizontal_
: 1;
705 bool user_scrollable_vertical_
: 1;
706 bool is_root_for_isolated_group_
: 1;
707 bool is_container_for_fixed_position_layers_
: 1;
708 bool is_drawable_
: 1;
709 bool draws_content_
: 1;
710 bool hide_layer_and_subtree_
: 1;
711 bool masks_to_bounds_
: 1;
712 bool contents_opaque_
: 1;
713 bool double_sided_
: 1;
714 bool should_flatten_transform_
: 1;
715 bool use_parent_backface_visibility_
: 1;
716 bool draw_checkerboard_for_missing_tiles_
: 1;
717 bool force_render_surface_
: 1;
718 bool transform_is_invertible_
: 1;
719 bool has_render_surface_
: 1;
720 ScrollBlocksOn scroll_blocks_on_
: 3;
721 Region non_fast_scrollable_region_
;
722 Region touch_event_handler_region_
;
723 gfx::PointF position_
;
724 SkColor background_color_
;
726 SkXfermode::Mode blend_mode_
;
727 FilterOperations filters_
;
728 FilterOperations background_filters_
;
729 LayerPositionConstraint position_constraint_
;
730 Layer
* scroll_parent_
;
731 scoped_ptr
<std::set
<Layer
*>> scroll_children_
;
733 // The following three variables are tracker variables. They are bools
734 // wrapped inside an integer variable. If true, their value equals the
735 // LayerTreeHost's meta_information_sequence_number. This wrapping of bools
736 // inside ints is done to avoid a layer tree treewalk to reset their values.
737 int layer_or_descendant_is_drawn_tracker_
;
738 int sorted_for_recursion_tracker_
;
739 int visited_tracker_
;
742 scoped_ptr
<std::set
<Layer
*>> clip_children_
;
744 gfx::Transform transform_
;
745 gfx::Point3F transform_origin_
;
747 // Replica layer used for reflections.
748 scoped_refptr
<Layer
> replica_layer_
;
750 LayerClient
* client_
;
752 ScopedPtrVector
<CopyOutputRequest
> copy_requests_
;
754 base::Closure did_scroll_callback_
;
756 DrawProperties
<Layer
> draw_properties_
;
758 PaintProperties paint_properties_
;
759 // TODO(awoloszyn): This is redundant with has_render_surface_,
760 // and should get removed once it is no longer needed on main thread.
761 scoped_ptr
<RenderSurface
> render_surface_
;
763 gfx::Rect visible_rect_from_property_trees_
;
765 std::vector
<FrameTimingRequest
> frame_timing_requests_
;
766 bool frame_timing_requests_dirty_
;
768 DISALLOW_COPY_AND_ASSIGN(Layer
);
773 #endif // CC_LAYERS_LAYER_H_