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/scroll_blocks_on.h"
28 #include "cc/output/filter_operations.h"
29 #include "cc/trees/property_tree.h"
30 #include "skia/ext/refptr.h"
31 #include "third_party/skia/include/core/SkColor.h"
32 #include "third_party/skia/include/core/SkImageFilter.h"
33 #include "third_party/skia/include/core/SkPicture.h"
34 #include "third_party/skia/include/core/SkXfermode.h"
35 #include "ui/gfx/geometry/point3_f.h"
36 #include "ui/gfx/geometry/rect.h"
37 #include "ui/gfx/geometry/rect_f.h"
38 #include "ui/gfx/geometry/scroll_offset.h"
39 #include "ui/gfx/transform.h"
46 namespace trace_event
{
47 class ConvertableToTraceFormat
;
54 class AnimationDelegate
;
55 struct AnimationEvent
;
56 class CopyOutputRequest
;
57 class LayerAnimationEventObserver
;
62 class LayerTreeHostCommon
;
64 class LayerTreeSettings
;
65 class RenderingStatsInstrumentation
;
66 class ResourceUpdateQueue
;
67 class ScrollbarLayerInterface
;
68 class SimpleEnclosedRegion
;
69 struct AnimationEvent
;
71 // Base class for composited layers. Special layer types are derived from
73 class CC_EXPORT Layer
: public base::RefCounted
<Layer
>,
74 public LayerAnimationValueObserver
,
75 public LayerAnimationValueProvider
{
77 typedef LayerList LayerListType
;
83 static scoped_refptr
<Layer
> Create(const LayerSettings
& settings
);
85 int id() const { return layer_id_
; }
88 Layer
* parent() { return parent_
; }
89 const Layer
* parent() const { return parent_
; }
90 void AddChild(scoped_refptr
<Layer
> child
);
91 void InsertChild(scoped_refptr
<Layer
> child
, size_t index
);
92 void ReplaceChild(Layer
* reference
, scoped_refptr
<Layer
> new_layer
);
93 void RemoveFromParent();
94 void RemoveAllChildren();
95 void SetChildren(const LayerList
& children
);
96 bool HasAncestor(const Layer
* ancestor
) const;
98 const LayerList
& children() const { return children_
; }
99 Layer
* child_at(size_t index
) { return children_
[index
].get(); }
101 // This requests the layer and its subtree be rendered and given to the
102 // callback. If the copy is unable to be produced (the layer is destroyed
103 // first), then the callback is called with a nullptr/empty result. If the
104 // request's source property is set, any prior uncommitted requests having the
105 // same source will be aborted.
106 void RequestCopyOfOutput(scoped_ptr
<CopyOutputRequest
> request
);
107 bool HasCopyRequest() const {
108 return !copy_requests_
.empty();
111 virtual void SetBackgroundColor(SkColor background_color
);
112 SkColor
background_color() const { return background_color_
; }
113 // If contents_opaque(), return an opaque color else return a
114 // non-opaque color. Tries to return background_color(), if possible.
115 SkColor
SafeOpaqueBackgroundColor() const;
117 // A layer's bounds are in logical, non-page-scaled pixels (however, the
118 // root layer's bounds are in physical pixels).
119 void SetBounds(const gfx::Size
& bounds
);
120 gfx::Size
bounds() const { return bounds_
; }
122 void SetMasksToBounds(bool masks_to_bounds
);
123 bool masks_to_bounds() const { return masks_to_bounds_
; }
125 void SetMaskLayer(Layer
* mask_layer
);
126 Layer
* mask_layer() { return mask_layer_
.get(); }
127 const Layer
* mask_layer() const { return mask_layer_
.get(); }
129 virtual void SetNeedsDisplayRect(const gfx::Rect
& dirty_rect
);
130 void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::Rect(bounds())); }
132 void SetOpacity(float opacity
);
133 float opacity() const { return opacity_
; }
134 bool OpacityIsAnimating() const;
135 bool HasPotentiallyRunningOpacityAnimation() const;
136 virtual bool OpacityCanAnimateOnImplThread() const;
138 void SetBlendMode(SkXfermode::Mode blend_mode
);
139 SkXfermode::Mode
blend_mode() const { return blend_mode_
; }
141 void set_draw_blend_mode(SkXfermode::Mode blend_mode
) {
142 if (draw_blend_mode_
== blend_mode
)
144 draw_blend_mode_
= blend_mode
;
145 SetNeedsPushProperties();
147 SkXfermode::Mode
draw_blend_mode() const { return draw_blend_mode_
; }
149 bool uses_default_blend_mode() const {
150 return blend_mode_
== SkXfermode::kSrcOver_Mode
;
153 // A layer is root for an isolated group when it and all its descendants are
154 // drawn over a black and fully transparent background, creating an isolated
155 // group. It should be used along with SetBlendMode(), in order to restrict
156 // layers within the group to blend with layers outside this group.
157 void SetIsRootForIsolatedGroup(bool root
);
158 bool is_root_for_isolated_group() const {
159 return is_root_for_isolated_group_
;
162 void SetFilters(const FilterOperations
& filters
);
163 const FilterOperations
& filters() const { return filters_
; }
164 bool FilterIsAnimating() const;
165 bool HasPotentiallyRunningFilterAnimation() const;
167 // Background filters are filters applied to what is behind this layer, when
168 // they are viewed through non-opaque regions in this layer. They are used
169 // through the WebLayer interface, and are not exposed to HTML.
170 void SetBackgroundFilters(const FilterOperations
& filters
);
171 const FilterOperations
& background_filters() const {
172 return background_filters_
;
175 virtual void SetContentsOpaque(bool opaque
);
176 bool contents_opaque() const { return contents_opaque_
; }
178 void SetPosition(const gfx::PointF
& position
);
179 gfx::PointF
position() const { return position_
; }
181 // A layer that is a container for fixed position layers cannot be both
182 // scrollable and have a non-identity transform.
183 void SetIsContainerForFixedPositionLayers(bool container
);
184 bool IsContainerForFixedPositionLayers() const;
186 gfx::Vector2dF
FixedContainerSizeDelta() const {
187 return gfx::Vector2dF();
190 void SetPositionConstraint(const LayerPositionConstraint
& constraint
);
191 const LayerPositionConstraint
& position_constraint() const {
192 return position_constraint_
;
195 void SetTransform(const gfx::Transform
& transform
);
196 const gfx::Transform
& transform() const { return transform_
; }
197 bool TransformIsAnimating() const;
198 bool HasPotentiallyRunningTransformAnimation() const;
199 bool HasOnlyTranslationTransforms() const;
200 bool AnimationsPreserveAxisAlignment() const;
201 bool transform_is_invertible() const { return transform_is_invertible_
; }
203 bool MaximumTargetScale(float* max_scale
) const;
204 bool AnimationStartScale(float* start_scale
) const;
206 void SetTransformOrigin(const gfx::Point3F
&);
207 gfx::Point3F
transform_origin() const { return transform_origin_
; }
209 bool HasAnyAnimationTargetingProperty(
210 Animation::TargetProperty property
) const;
212 bool ScrollOffsetAnimationWasInterrupted() const;
214 void SetScrollParent(Layer
* parent
);
216 Layer
* scroll_parent() { return scroll_parent_
; }
217 const Layer
* scroll_parent() const { return scroll_parent_
; }
219 void AddScrollChild(Layer
* child
);
220 void RemoveScrollChild(Layer
* child
);
222 std::set
<Layer
*>* scroll_children() { return scroll_children_
.get(); }
223 const std::set
<Layer
*>* scroll_children() const {
224 return scroll_children_
.get();
227 void SetClipParent(Layer
* ancestor
);
229 Layer
* clip_parent() { return clip_parent_
; }
230 const Layer
* clip_parent() const {
234 void AddClipChild(Layer
* child
);
235 void RemoveClipChild(Layer
* child
);
237 std::set
<Layer
*>* clip_children() { return clip_children_
.get(); }
238 const std::set
<Layer
*>* clip_children() const {
239 return clip_children_
.get();
242 DrawProperties
<Layer
>& draw_properties() { return draw_properties_
; }
243 const DrawProperties
<Layer
>& draw_properties() const {
244 return draw_properties_
;
247 // The following are shortcut accessors to get various information from
249 const gfx::Transform
& draw_transform() const {
250 return draw_properties_
.target_space_transform
;
252 const gfx::Transform
& screen_space_transform() const {
253 return draw_properties_
.screen_space_transform
;
255 float draw_opacity() const { return draw_properties_
.opacity
; }
256 bool screen_space_transform_is_animating() const {
257 return draw_properties_
.screen_space_transform_is_animating
;
259 gfx::Rect
clip_rect() const { return draw_properties_
.clip_rect
; }
260 gfx::Rect
drawable_content_rect() const {
261 return draw_properties_
.drawable_content_rect
;
263 gfx::Rect
visible_layer_rect() const {
264 return draw_properties_
.visible_layer_rect
;
266 Layer
* render_target() {
267 DCHECK(!draw_properties_
.render_target
||
268 draw_properties_
.render_target
->has_render_surface());
269 return draw_properties_
.render_target
;
271 const Layer
* render_target() const {
272 DCHECK(!draw_properties_
.render_target
||
273 draw_properties_
.render_target
->has_render_surface());
274 return draw_properties_
.render_target
;
276 size_t num_unclipped_descendants() const {
277 return draw_properties_
.num_unclipped_descendants
;
280 void SetScrollOffset(const gfx::ScrollOffset
& scroll_offset
);
281 void SetScrollCompensationAdjustment(
282 const gfx::Vector2dF
& scroll_compensation_adjustment
);
283 gfx::Vector2dF
ScrollCompensationAdjustment() const;
285 gfx::ScrollOffset
scroll_offset() const { return scroll_offset_
; }
286 void SetScrollOffsetFromImplSide(const gfx::ScrollOffset
& scroll_offset
);
288 void SetScrollClipLayerId(int clip_layer_id
);
289 bool scrollable() const { return scroll_clip_layer_id_
!= INVALID_ID
; }
291 void SetUserScrollable(bool horizontal
, bool vertical
);
292 bool user_scrollable_horizontal() const {
293 return user_scrollable_horizontal_
;
295 bool user_scrollable_vertical() const { return user_scrollable_vertical_
; }
297 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread
);
298 bool should_scroll_on_main_thread() const {
299 return should_scroll_on_main_thread_
;
302 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers
);
303 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_
; }
305 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers
);
306 bool have_scroll_event_handlers() const {
307 return have_scroll_event_handlers_
;
310 void SetNonFastScrollableRegion(const Region
& non_fast_scrollable_region
);
311 const Region
& non_fast_scrollable_region() const {
312 return non_fast_scrollable_region_
;
315 void SetTouchEventHandlerRegion(const Region
& touch_event_handler_region
);
316 const Region
& touch_event_handler_region() const {
317 return touch_event_handler_region_
;
320 void SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on
);
321 ScrollBlocksOn
scroll_blocks_on() const { return scroll_blocks_on_
; }
323 void set_did_scroll_callback(const base::Closure
& callback
) {
324 did_scroll_callback_
= callback
;
327 void SetForceRenderSurface(bool force_render_surface
);
328 bool force_render_surface() const { return force_render_surface_
; }
330 gfx::Vector2dF
ScrollDelta() const { return gfx::Vector2dF(); }
331 gfx::ScrollOffset
CurrentScrollOffset() const { return scroll_offset_
; }
333 void SetDoubleSided(bool double_sided
);
334 bool double_sided() const { return double_sided_
; }
336 void SetShouldFlattenTransform(bool flatten
);
337 bool should_flatten_transform() const { return should_flatten_transform_
; }
339 bool Is3dSorted() const { return sorting_context_id_
!= 0; }
341 void set_use_parent_backface_visibility(bool use
) {
342 use_parent_backface_visibility_
= use
;
344 bool use_parent_backface_visibility() const {
345 return use_parent_backface_visibility_
;
348 virtual void SetLayerTreeHost(LayerTreeHost
* host
);
350 virtual bool HasDelegatedContent() const;
351 bool HasContributingDelegatedRenderPasses() const { return false; }
353 void SetIsDrawable(bool is_drawable
);
355 void SetHideLayerAndSubtree(bool hide
);
356 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_
; }
358 void SetReplicaLayer(Layer
* layer
);
359 Layer
* replica_layer() { return replica_layer_
.get(); }
360 const Layer
* replica_layer() const { return replica_layer_
.get(); }
362 bool has_mask() const { return !!mask_layer_
.get(); }
363 bool has_replica() const { return !!replica_layer_
.get(); }
364 bool replica_has_mask() const {
365 return replica_layer_
.get() &&
366 (mask_layer_
.get() || replica_layer_
->mask_layer_
.get());
369 int NumDescendantsThatDrawContent() const;
371 // This is only virtual for tests.
372 // TODO(awoloszyn): Remove this once we no longer need it for tests
373 virtual bool DrawsContent() const;
375 // This methods typically need to be overwritten by derived classes.
376 virtual void SavePaintProperties();
377 // Returns true iff anything was updated that needs to be committed.
378 virtual bool Update();
379 virtual void SetIsMask(bool is_mask
) {}
380 virtual bool IsSuitableForGpuRasterization() const;
382 virtual scoped_refptr
<base::trace_event::ConvertableToTraceFormat
>
385 void SetLayerClient(LayerClient
* client
) { client_
= client
; }
387 virtual void PushPropertiesTo(LayerImpl
* layer
);
389 LayerTreeHost
* layer_tree_host() { return layer_tree_host_
; }
390 const LayerTreeHost
* layer_tree_host() const { return layer_tree_host_
; }
392 bool AddAnimation(scoped_ptr
<Animation
> animation
);
393 void PauseAnimation(int animation_id
, double time_offset
);
394 void RemoveAnimation(int animation_id
);
395 void RemoveAnimation(int animation_id
, Animation::TargetProperty property
);
396 LayerAnimationController
* layer_animation_controller() const {
397 return layer_animation_controller_
.get();
399 void SetLayerAnimationControllerForTest(
400 scoped_refptr
<LayerAnimationController
> controller
);
402 void set_layer_animation_delegate(AnimationDelegate
* delegate
) {
403 DCHECK(layer_animation_controller_
);
404 layer_animation_controller_
->set_layer_animation_delegate(delegate
);
407 bool HasActiveAnimation() const;
408 void RegisterForAnimations(AnimationRegistrar
* registrar
);
410 void AddLayerAnimationEventObserver(
411 LayerAnimationEventObserver
* animation_observer
);
412 void RemoveLayerAnimationEventObserver(
413 LayerAnimationEventObserver
* animation_observer
);
415 virtual ScrollbarLayerInterface
* ToScrollbarLayer();
417 virtual skia::RefPtr
<SkPicture
> GetPicture() const;
419 // Constructs a LayerImpl of the correct runtime type for this Layer type.
420 virtual scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
);
422 bool NeedsDisplayForTesting() const { return !update_rect_
.IsEmpty(); }
423 void ResetNeedsDisplayForTesting() { update_rect_
= gfx::Rect(); }
425 RenderingStatsInstrumentation
* rendering_stats_instrumentation() const;
427 const PaintProperties
& paint_properties() const {
428 return paint_properties_
;
431 void SetNeedsPushProperties();
432 bool needs_push_properties() const { return needs_push_properties_
; }
433 bool descendant_needs_push_properties() const {
434 return num_dependents_need_push_properties_
> 0;
436 void reset_needs_push_properties_for_testing() {
437 needs_push_properties_
= false;
440 virtual void RunMicroBenchmark(MicroBenchmark
* benchmark
);
442 void Set3dSortingContextId(int id
);
443 int sorting_context_id() const { return sorting_context_id_
; }
445 void set_property_tree_sequence_number(int sequence_number
) {
446 property_tree_sequence_number_
= sequence_number
;
449 void SetTransformTreeIndex(int index
);
450 int transform_tree_index() const;
452 void SetClipTreeIndex(int index
);
453 int clip_tree_index() const;
455 void SetEffectTreeIndex(int index
);
456 int effect_tree_index() const;
458 void set_offset_to_transform_parent(gfx::Vector2dF offset
) {
459 if (offset_to_transform_parent_
== offset
)
461 offset_to_transform_parent_
= offset
;
462 SetNeedsPushProperties();
464 gfx::Vector2dF
offset_to_transform_parent() const {
465 return offset_to_transform_parent_
;
468 // TODO(vollick): Once we transition to transform and clip trees, rename these
469 // functions and related values. The "from property trees" functions below
470 // use the transform and clip trees. Eventually, we will use these functions
471 // to compute the official values, but these functions are retained for
472 // testing purposes until we've migrated.
474 const gfx::Rect
& visible_rect_from_property_trees() const {
475 return visible_rect_from_property_trees_
;
477 void set_visible_rect_from_property_trees(const gfx::Rect
& rect
) {
478 // No push properties here, as this acts like a draw property.
479 visible_rect_from_property_trees_
= rect
;
482 const gfx::Rect
& clip_rect_in_target_space_from_property_trees() const {
483 return clip_rect_in_target_space_from_property_trees_
;
485 void set_clip_rect_in_target_space_from_property_trees(
486 const gfx::Rect
& rect
) {
487 clip_rect_in_target_space_from_property_trees_
= rect
;
490 void set_should_flatten_transform_from_property_tree(bool should_flatten
) {
491 if (should_flatten_transform_from_property_tree_
== should_flatten
)
493 should_flatten_transform_from_property_tree_
= should_flatten
;
494 SetNeedsPushProperties();
496 bool should_flatten_transform_from_property_tree() const {
497 return should_flatten_transform_from_property_tree_
;
500 void set_is_clipped(bool is_clipped
) {
501 if (is_clipped_
== is_clipped
)
503 is_clipped_
= is_clipped
;
504 SetNeedsPushProperties();
506 bool is_clipped() const { return is_clipped_
; }
508 bool has_render_surface() const {
509 return has_render_surface_
;
512 // Sets new frame timing requests for this layer.
513 void SetFrameTimingRequests(const std::vector
<FrameTimingRequest
>& requests
);
515 // Accessor for unit tests
516 const std::vector
<FrameTimingRequest
>& FrameTimingRequests() const {
517 return frame_timing_requests_
;
520 void DidBeginTracing();
521 void set_num_layer_or_descandant_with_copy_request(
522 int num_layer_or_descendants_with_copy_request
) {
523 num_layer_or_descendants_with_copy_request_
=
524 num_layer_or_descendants_with_copy_request
;
527 void set_num_children_with_scroll_parent(
528 int num_children_with_scroll_parent
) {
529 num_children_with_scroll_parent_
= num_children_with_scroll_parent
;
532 int num_children_with_scroll_parent() {
533 return num_children_with_scroll_parent_
;
536 void set_visited(bool visited
);
538 void set_layer_or_descendant_is_drawn(bool layer_or_descendant_is_drawn
);
539 bool layer_or_descendant_is_drawn();
540 void set_sorted_for_recursion(bool sorted_for_recursion
);
541 bool sorted_for_recursion();
544 friend class LayerImpl
;
545 friend class TreeSynchronizer
;
548 explicit Layer(const LayerSettings
& settings
);
550 // These SetNeeds functions are in order of severity of update:
552 // Called when this layer has been modified in some way, but isn't sure
553 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers
554 // before it knows whether or not a commit is required.
555 void SetNeedsUpdate();
556 // Called when a property has been modified in a way that the layer
557 // knows immediately that a commit is required. This implies SetNeedsUpdate
558 // as well as SetNeedsPushProperties to push that property.
559 void SetNeedsCommit();
560 // This is identical to SetNeedsCommit, but the former requests a rebuild of
561 // the property trees.
562 void SetNeedsCommitNoRebuild();
563 // Called when there's been a change in layer structure. Implies both
564 // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties.
565 void SetNeedsFullTreeSync();
567 // Called when the next commit should wait until the pending tree is activated
568 // before finishing the commit and unblocking the main thread. Used to ensure
569 // unused resources on the impl thread are returned before commit completes.
570 void SetNextCommitWaitsForActivation();
572 // Will recalculate whether the layer draws content and set draws_content_
574 void UpdateDrawsContent(bool has_drawable_content
);
575 virtual bool HasDrawableContent() const;
577 // Called when the layer's number of drawable descendants changes.
578 void AddDrawableDescendants(int num
);
580 void AddDependentNeedsPushProperties();
581 void RemoveDependentNeedsPushProperties();
582 bool parent_should_know_need_push_properties() const {
583 return needs_push_properties() || descendant_needs_push_properties();
586 bool IsPropertyChangeAllowed() const;
588 // This flag is set when the layer needs to push properties to the impl
590 bool needs_push_properties_
;
592 // The number of direct children or dependent layers that need to be recursed
593 // to in order for them or a descendent of them to push properties to the impl
595 int num_dependents_need_push_properties_
;
597 // Tracks whether this layer may have changed stacking order with its
599 bool stacking_order_changed_
;
601 // The update rect is the region of the compositor resource that was
602 // actually updated by the compositor. For layers that may do updating
603 // outside the compositor's control (i.e. plugin layers), this information
604 // is not available and the update rect will remain empty.
605 // Note this rect is in layer space (not content space).
606 gfx::Rect update_rect_
;
608 scoped_refptr
<Layer
> mask_layer_
;
612 // When true, the layer is about to perform an update. Any commit requests
613 // will be handled implicitly after the update completes.
614 bool ignore_set_needs_commit_
;
616 // Layers that share a sorting context id will be sorted together in 3d
617 // space. 0 is a special value that means this layer will not be sorted and
618 // will be drawn in paint order.
619 int sorting_context_id_
;
622 friend class base::RefCounted
<Layer
>;
623 friend class LayerTreeHostCommon
;
624 void SetParent(Layer
* layer
);
625 bool DescendantIsFixedToContainerLayer() const;
627 // This should only be called during BeginMainFrame since it does not
629 void SetHasRenderSurface(bool has_render_surface
);
631 // This should only be called from RemoveFromParent().
632 void RemoveChildOrDependent(Layer
* child
);
634 // LayerAnimationValueProvider implementation.
635 gfx::ScrollOffset
ScrollOffsetForAnimation() const override
;
637 // LayerAnimationValueObserver implementation.
638 void OnFilterAnimated(const FilterOperations
& filters
) override
;
639 void OnOpacityAnimated(float opacity
) override
;
640 void OnTransformAnimated(const gfx::Transform
& transform
) override
;
641 void OnScrollOffsetAnimated(const gfx::ScrollOffset
& scroll_offset
) override
;
642 void OnAnimationWaitingForDeletion() override
;
643 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating
) override
;
644 bool IsActive() const override
;
646 // If this layer has a scroll parent, it removes |this| from its list of
648 void RemoveFromScrollTree();
650 // If this layer has a clip parent, it removes |this| from its list of clip
652 void RemoveFromClipTree();
654 // When we detach or attach layer to new LayerTreeHost, all property trees'
655 // indices becomes invalid.
656 void InvalidatePropertyTreesIndices();
658 void UpdateNumCopyRequestsForSubtree(bool add
);
663 // Layer instances have a weak pointer to their LayerTreeHost.
664 // This pointer value is nil when a Layer is not in a tree and is
665 // updated via SetLayerTreeHost() if a layer moves between trees.
666 LayerTreeHost
* layer_tree_host_
;
668 scoped_refptr
<LayerAnimationController
> layer_animation_controller_
;
673 gfx::ScrollOffset scroll_offset_
;
674 gfx::Vector2dF scroll_compensation_adjustment_
;
675 // This variable indicates which ancestor layer (if any) whose size,
676 // transformed relative to this layer, defines the maximum scroll offset for
678 int scroll_clip_layer_id_
;
679 int num_descendants_that_draw_content_
;
680 int transform_tree_index_
;
681 int effect_tree_index_
;
682 int clip_tree_index_
;
683 int property_tree_sequence_number_
;
684 int num_layer_or_descendants_with_copy_request_
;
685 int num_children_with_scroll_parent_
;
686 gfx::Vector2dF offset_to_transform_parent_
;
687 bool should_flatten_transform_from_property_tree_
: 1;
688 bool is_clipped_
: 1;
689 bool should_scroll_on_main_thread_
: 1;
690 bool have_wheel_event_handlers_
: 1;
691 bool have_scroll_event_handlers_
: 1;
692 bool user_scrollable_horizontal_
: 1;
693 bool user_scrollable_vertical_
: 1;
694 bool is_root_for_isolated_group_
: 1;
695 bool is_container_for_fixed_position_layers_
: 1;
696 bool is_drawable_
: 1;
697 bool draws_content_
: 1;
698 bool hide_layer_and_subtree_
: 1;
699 bool masks_to_bounds_
: 1;
700 bool contents_opaque_
: 1;
701 bool double_sided_
: 1;
702 bool should_flatten_transform_
: 1;
703 bool use_parent_backface_visibility_
: 1;
704 bool force_render_surface_
: 1;
705 bool transform_is_invertible_
: 1;
706 bool has_render_surface_
: 1;
707 ScrollBlocksOn scroll_blocks_on_
: 3;
708 Region non_fast_scrollable_region_
;
709 Region touch_event_handler_region_
;
710 gfx::PointF position_
;
711 SkColor background_color_
;
713 SkXfermode::Mode blend_mode_
;
714 // draw_blend_mode may be different than blend_mode_,
715 // when a RenderSurface re-parents the layer's blend_mode.
716 SkXfermode::Mode draw_blend_mode_
;
717 FilterOperations filters_
;
718 FilterOperations background_filters_
;
719 LayerPositionConstraint position_constraint_
;
720 Layer
* scroll_parent_
;
721 scoped_ptr
<std::set
<Layer
*>> scroll_children_
;
723 // The following three variables are tracker variables. They are bools
724 // wrapped inside an integer variable. If true, their value equals the
725 // LayerTreeHost's meta_information_sequence_number. This wrapping of bools
726 // inside ints is done to avoid a layer tree treewalk to reset their values.
727 int layer_or_descendant_is_drawn_tracker_
;
728 int sorted_for_recursion_tracker_
;
729 int visited_tracker_
;
732 scoped_ptr
<std::set
<Layer
*>> clip_children_
;
734 gfx::Transform transform_
;
735 gfx::Point3F transform_origin_
;
737 // Replica layer used for reflections.
738 scoped_refptr
<Layer
> replica_layer_
;
740 LayerClient
* client_
;
742 ScopedPtrVector
<CopyOutputRequest
> copy_requests_
;
744 base::Closure did_scroll_callback_
;
746 DrawProperties
<Layer
> draw_properties_
;
748 PaintProperties paint_properties_
;
750 gfx::Rect visible_rect_from_property_trees_
;
751 gfx::Rect clip_rect_in_target_space_from_property_trees_
;
753 std::vector
<FrameTimingRequest
> frame_timing_requests_
;
754 bool frame_timing_requests_dirty_
;
756 DISALLOW_COPY_AND_ASSIGN(Layer
);
761 #endif // CC_LAYERS_LAYER_H_