1 // Copyright 2011 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_IMPL_H_
6 #define CC_LAYERS_LAYER_IMPL_H_
12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/values.h"
15 #include "cc/animation/animation_delegate.h"
16 #include "cc/animation/layer_animation_controller.h"
17 #include "cc/animation/layer_animation_value_observer.h"
18 #include "cc/animation/layer_animation_value_provider.h"
19 #include "cc/base/cc_export.h"
20 #include "cc/base/region.h"
21 #include "cc/base/scoped_ptr_vector.h"
22 #include "cc/base/synced_property.h"
23 #include "cc/debug/frame_timing_request.h"
24 #include "cc/input/input_handler.h"
25 #include "cc/input/scrollbar.h"
26 #include "cc/layers/draw_properties.h"
27 #include "cc/layers/layer_lists.h"
28 #include "cc/layers/layer_position_constraint.h"
29 #include "cc/layers/render_surface_impl.h"
30 #include "cc/layers/scroll_blocks_on.h"
31 #include "cc/output/filter_operations.h"
32 #include "cc/quads/shared_quad_state.h"
33 #include "cc/resources/resource_provider.h"
34 #include "skia/ext/refptr.h"
35 #include "third_party/skia/include/core/SkColor.h"
36 #include "third_party/skia/include/core/SkImageFilter.h"
37 #include "third_party/skia/include/core/SkPicture.h"
38 #include "ui/gfx/geometry/point3_f.h"
39 #include "ui/gfx/geometry/rect.h"
40 #include "ui/gfx/geometry/rect_f.h"
41 #include "ui/gfx/geometry/scroll_offset.h"
42 #include "ui/gfx/transform.h"
45 namespace trace_event
{
46 class ConvertableToTraceFormat
;
49 class DictionaryValue
;
54 class LayerTreeHostImpl
;
56 class MicroBenchmarkImpl
;
58 template <typename LayerType
>
59 class OcclusionTracker
;
63 class ScrollbarAnimationController
;
64 class ScrollbarLayerImplBase
;
65 class SimpleEnclosedRegion
;
68 struct AppendQuadsData
;
74 DRAW_MODE_RESOURCELESS_SOFTWARE
77 class CC_EXPORT LayerImpl
: public LayerAnimationValueObserver
,
78 public LayerAnimationValueProvider
,
79 public AnimationDelegate
{
81 // Allows for the ownership of the total scroll offset to be delegated outside
83 class ScrollOffsetDelegate
{
85 virtual void SetCurrentScrollOffset(const gfx::ScrollOffset
& new_value
) = 0;
86 virtual gfx::ScrollOffset
GetCurrentScrollOffset() = 0;
87 virtual bool IsExternalFlingActive() const = 0;
88 virtual void Update() const = 0;
91 typedef SyncedProperty
<AdditionGroup
<gfx::ScrollOffset
>> SyncedScrollOffset
;
92 typedef LayerImplList RenderSurfaceListType
;
93 typedef LayerImplList LayerListType
;
94 typedef RenderSurfaceImpl RenderSurfaceType
;
96 enum RenderingContextConstants
{ NO_RENDERING_CONTEXT
= 0 };
98 static scoped_ptr
<LayerImpl
> Create(
99 LayerTreeImpl
* tree_impl
,
101 scoped_refptr
<SyncedScrollOffset
> scroll_offset
) {
102 return make_scoped_ptr(new LayerImpl(tree_impl
, id
, scroll_offset
));
105 static scoped_ptr
<LayerImpl
> Create(LayerTreeImpl
* tree_impl
, int id
) {
106 return make_scoped_ptr(new LayerImpl(tree_impl
, id
));
109 ~LayerImpl() override
;
111 int id() const { return layer_id_
; }
113 // LayerAnimationValueProvider implementation.
114 gfx::ScrollOffset
ScrollOffsetForAnimation() const override
;
116 // LayerAnimationValueObserver implementation.
117 void OnFilterAnimated(const FilterOperations
& filters
) override
;
118 void OnOpacityAnimated(float opacity
) override
;
119 void OnTransformAnimated(const gfx::Transform
& transform
) override
;
120 void OnScrollOffsetAnimated(const gfx::ScrollOffset
& scroll_offset
) override
;
121 void OnAnimationWaitingForDeletion() override
;
122 bool IsActive() const override
;
124 // AnimationDelegate implementation.
125 void NotifyAnimationStarted(base::TimeTicks monotonic_time
,
126 Animation::TargetProperty target_property
,
127 int group
) override
{};
128 void NotifyAnimationFinished(base::TimeTicks monotonic_time
,
129 Animation::TargetProperty target_property
,
133 LayerImpl
* parent() { return parent_
; }
134 const LayerImpl
* parent() const { return parent_
; }
135 const OwnedLayerImplList
& children() const { return children_
; }
136 OwnedLayerImplList
& children() { return children_
; }
137 LayerImpl
* child_at(size_t index
) const { return children_
[index
]; }
138 void AddChild(scoped_ptr
<LayerImpl
> child
);
139 scoped_ptr
<LayerImpl
> RemoveChild(LayerImpl
* child
);
140 void SetParent(LayerImpl
* parent
);
142 // Warning: This does not preserve tree structure invariants.
143 void ClearChildList();
145 bool HasAncestor(const LayerImpl
* ancestor
) const;
147 void SetScrollParent(LayerImpl
* parent
);
149 LayerImpl
* scroll_parent() { return scroll_parent_
; }
150 const LayerImpl
* scroll_parent() const { return scroll_parent_
; }
152 void SetScrollChildren(std::set
<LayerImpl
*>* children
);
154 std::set
<LayerImpl
*>* scroll_children() { return scroll_children_
.get(); }
155 const std::set
<LayerImpl
*>* scroll_children() const {
156 return scroll_children_
.get();
159 void SetNumDescendantsThatDrawContent(int num_descendants
);
160 void SetClipParent(LayerImpl
* ancestor
);
162 LayerImpl
* clip_parent() {
165 const LayerImpl
* clip_parent() const {
169 void SetClipChildren(std::set
<LayerImpl
*>* children
);
171 std::set
<LayerImpl
*>* clip_children() { return clip_children_
.get(); }
172 const std::set
<LayerImpl
*>* clip_children() const {
173 return clip_children_
.get();
176 void PassCopyRequests(ScopedPtrVector
<CopyOutputRequest
>* requests
);
177 // Can only be called when the layer has a copy request.
178 void TakeCopyRequestsAndTransformToTarget(
179 ScopedPtrVector
<CopyOutputRequest
>* request
);
180 bool HasCopyRequest() const { return !copy_requests_
.empty(); }
182 void SetMaskLayer(scoped_ptr
<LayerImpl
> mask_layer
);
183 LayerImpl
* mask_layer() { return mask_layer_
.get(); }
184 const LayerImpl
* mask_layer() const { return mask_layer_
.get(); }
185 scoped_ptr
<LayerImpl
> TakeMaskLayer();
187 void SetReplicaLayer(scoped_ptr
<LayerImpl
> replica_layer
);
188 LayerImpl
* replica_layer() { return replica_layer_
.get(); }
189 const LayerImpl
* replica_layer() const { return replica_layer_
.get(); }
190 scoped_ptr
<LayerImpl
> TakeReplicaLayer();
192 bool has_mask() const { return mask_layer_
; }
193 bool has_replica() const { return replica_layer_
; }
194 bool replica_has_mask() const {
195 return replica_layer_
&& (mask_layer_
|| replica_layer_
->mask_layer_
);
198 LayerTreeImpl
* layer_tree_impl() const { return layer_tree_impl_
; }
200 void PopulateSharedQuadState(SharedQuadState
* state
) const;
201 void PopulateScaledSharedQuadState(SharedQuadState
* state
, float scale
) const;
202 // WillDraw must be called before AppendQuads. If WillDraw returns false,
203 // AppendQuads and DidDraw will not be called. If WillDraw returns true,
204 // DidDraw is guaranteed to be called before another WillDraw or before
205 // the layer is destroyed. To enforce this, any class that overrides
206 // WillDraw/DidDraw must call the base class version only if WillDraw
208 virtual bool WillDraw(DrawMode draw_mode
,
209 ResourceProvider
* resource_provider
);
210 virtual void AppendQuads(RenderPass
* render_pass
,
211 AppendQuadsData
* append_quads_data
) {}
212 virtual void DidDraw(ResourceProvider
* resource_provider
);
214 virtual void GetContentsResourceId(ResourceProvider::ResourceId
* resource_id
,
215 gfx::Size
* resource_size
) const;
217 virtual bool HasDelegatedContent() const;
218 virtual bool HasContributingDelegatedRenderPasses() const;
219 virtual RenderPassId
FirstContributingRenderPassId() const;
220 virtual RenderPassId
NextContributingRenderPassId(RenderPassId id
) const;
222 virtual void NotifyTileStateChanged(const Tile
* tile
) {}
224 virtual ScrollbarLayerImplBase
* ToScrollbarLayer();
226 // Returns true if this layer has content to draw.
227 void SetDrawsContent(bool draws_content
);
228 bool DrawsContent() const { return draws_content_
; }
230 int NumDescendantsThatDrawContent() const;
231 void SetHideLayerAndSubtree(bool hide
);
232 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_
; }
234 void SetTransformOrigin(const gfx::Point3F
& transform_origin
);
235 gfx::Point3F
transform_origin() const { return transform_origin_
; }
237 void SetBackgroundColor(SkColor background_color
);
238 SkColor
background_color() const { return background_color_
; }
239 // If contents_opaque(), return an opaque color else return a
240 // non-opaque color. Tries to return background_color(), if possible.
241 SkColor
SafeOpaqueBackgroundColor() const;
243 void SetFilters(const FilterOperations
& filters
);
244 const FilterOperations
& filters() const { return filters_
; }
245 bool FilterIsAnimating() const;
246 bool FilterIsAnimatingOnImplOnly() const;
248 void SetBackgroundFilters(const FilterOperations
& filters
);
249 const FilterOperations
& background_filters() const {
250 return background_filters_
;
253 void SetMasksToBounds(bool masks_to_bounds
);
254 bool masks_to_bounds() const { return masks_to_bounds_
; }
256 void SetContentsOpaque(bool opaque
);
257 bool contents_opaque() const { return contents_opaque_
; }
259 void SetOpacity(float opacity
);
260 float opacity() const { return opacity_
; }
261 bool OpacityIsAnimating() const;
262 bool OpacityIsAnimatingOnImplOnly() const;
264 void SetBlendMode(SkXfermode::Mode
);
265 SkXfermode::Mode
blend_mode() const { return blend_mode_
; }
266 bool uses_default_blend_mode() const {
267 return blend_mode_
== SkXfermode::kSrcOver_Mode
;
270 void SetIsRootForIsolatedGroup(bool root
);
271 bool is_root_for_isolated_group() const {
272 return is_root_for_isolated_group_
;
275 void SetPosition(const gfx::PointF
& position
);
276 gfx::PointF
position() const { return position_
; }
278 void SetIsContainerForFixedPositionLayers(bool container
) {
279 is_container_for_fixed_position_layers_
= container
;
281 // This is a non-trivial function in Layer.
282 bool IsContainerForFixedPositionLayers() const {
283 return is_container_for_fixed_position_layers_
;
286 gfx::Vector2dF
FixedContainerSizeDelta() const;
288 void SetPositionConstraint(const LayerPositionConstraint
& constraint
) {
289 position_constraint_
= constraint
;
291 const LayerPositionConstraint
& position_constraint() const {
292 return position_constraint_
;
295 void SetShouldFlattenTransform(bool flatten
);
296 bool should_flatten_transform() const { return should_flatten_transform_
; }
298 bool Is3dSorted() const { return sorting_context_id_
!= 0; }
300 void SetUseParentBackfaceVisibility(bool use
) {
301 use_parent_backface_visibility_
= use
;
303 bool use_parent_backface_visibility() const {
304 return use_parent_backface_visibility_
;
307 bool ShowDebugBorders() const;
309 // These invalidate the host's render surface layer list. The caller
310 // is responsible for calling set_needs_update_draw_properties on the tree
311 // so that its list can be recreated.
312 void ClearRenderSurfaceLayerList();
313 void SetHasRenderSurface(bool has_render_surface
);
315 RenderSurfaceImpl
* render_surface() const { return render_surface_
.get(); }
317 DrawProperties
<LayerImpl
>& draw_properties() {
318 return draw_properties_
;
320 const DrawProperties
<LayerImpl
>& draw_properties() const {
321 return draw_properties_
;
324 // The following are shortcut accessors to get various information from
326 const gfx::Transform
& draw_transform() const {
327 return draw_properties_
.target_space_transform
;
329 const gfx::Transform
& screen_space_transform() const {
330 return draw_properties_
.screen_space_transform
;
332 float draw_opacity() const { return draw_properties_
.opacity
; }
333 SkXfermode::Mode
draw_blend_mode() const {
334 return draw_properties_
.blend_mode
;
336 bool draw_opacity_is_animating() const {
337 return draw_properties_
.opacity_is_animating
;
339 bool draw_transform_is_animating() const {
340 return draw_properties_
.target_space_transform_is_animating
;
342 bool screen_space_transform_is_animating() const {
343 return draw_properties_
.screen_space_transform_is_animating
;
345 bool screen_space_opacity_is_animating() const {
346 return draw_properties_
.screen_space_opacity_is_animating
;
348 bool can_use_lcd_text() const { return draw_properties_
.can_use_lcd_text
; }
349 bool is_clipped() const { return draw_properties_
.is_clipped
; }
350 gfx::Rect
clip_rect() const { return draw_properties_
.clip_rect
; }
351 gfx::Rect
drawable_content_rect() const {
352 return draw_properties_
.drawable_content_rect
;
354 gfx::Rect
visible_content_rect() const {
355 return draw_properties_
.visible_content_rect
;
357 LayerImpl
* render_target() {
358 DCHECK(!draw_properties_
.render_target
||
359 draw_properties_
.render_target
->render_surface());
360 return draw_properties_
.render_target
;
362 const LayerImpl
* render_target() const {
363 DCHECK(!draw_properties_
.render_target
||
364 draw_properties_
.render_target
->render_surface());
365 return draw_properties_
.render_target
;
368 int num_unclipped_descendants() const {
369 return draw_properties_
.num_unclipped_descendants
;
372 // The client should be responsible for setting bounds, content bounds and
373 // contents scale to appropriate values. LayerImpl doesn't calculate any of
374 // them from the other values.
376 void SetBounds(const gfx::Size
& bounds
);
377 gfx::Size
bounds() const;
378 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions
379 // of pixels) due to use of single precision float.
380 gfx::SizeF
BoundsForScrolling() const;
381 void SetBoundsDelta(const gfx::Vector2dF
& bounds_delta
);
382 gfx::Vector2dF
bounds_delta() const { return bounds_delta_
; }
384 void SetContentBounds(const gfx::Size
& content_bounds
);
385 gfx::Size
content_bounds() const { return draw_properties_
.content_bounds
; }
387 float contents_scale_x() const { return draw_properties_
.contents_scale_x
; }
388 float contents_scale_y() const { return draw_properties_
.contents_scale_y
; }
389 void SetContentsScale(float contents_scale_x
, float contents_scale_y
);
391 void SetScrollOffsetDelegate(ScrollOffsetDelegate
* scroll_offset_delegate
);
392 void RefreshFromScrollDelegate();
393 bool IsExternalFlingActive() const;
395 void SetCurrentScrollOffset(const gfx::ScrollOffset
& scroll_offset
);
396 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset
& scroll_offset
);
397 // This method is similar to PushScrollOffsetFromMainThread but will cause the
398 // scroll offset given to clobber any scroll changes on the active tree in the
399 // time until this value is pushed to the active tree.
400 void PushScrollOffsetFromMainThreadAndClobberActiveValue(
401 const gfx::ScrollOffset
& scroll_offset
);
402 gfx::ScrollOffset
PullDeltaForMainThread();
403 gfx::ScrollOffset
CurrentScrollOffset() const;
404 gfx::ScrollOffset
BaseScrollOffset() const;
405 gfx::Vector2dF
ScrollDelta() const;
406 void SetScrollDelta(const gfx::Vector2dF
& delta
);
408 gfx::ScrollOffset
MaxScrollOffset() const;
409 gfx::ScrollOffset
ClampScrollOffsetToLimits(gfx::ScrollOffset offset
) const;
410 gfx::Vector2dF
ClampScrollToMaxScrollOffset();
411 void SetScrollbarPosition(ScrollbarLayerImplBase
* scrollbar_layer
,
412 LayerImpl
* scrollbar_clip_layer
,
413 bool on_resize
) const;
414 void SetScrollCompensationAdjustment(const gfx::Vector2dF
& scroll_offset
) {
415 scroll_compensation_adjustment_
= scroll_offset
;
417 gfx::Vector2dF
ScrollCompensationAdjustment() const {
418 return scroll_compensation_adjustment_
;
421 // Returns the delta of the scroll that was outside of the bounds of the
423 gfx::Vector2dF
ScrollBy(const gfx::Vector2dF
& scroll
);
425 void SetScrollClipLayer(int scroll_clip_layer_id
);
426 LayerImpl
* scroll_clip_layer() const { return scroll_clip_layer_
; }
427 bool scrollable() const { return !!scroll_clip_layer_
; }
429 void set_user_scrollable_horizontal(bool scrollable
) {
430 user_scrollable_horizontal_
= scrollable
;
432 bool user_scrollable_horizontal() const {
433 return user_scrollable_horizontal_
;
435 void set_user_scrollable_vertical(bool scrollable
) {
436 user_scrollable_vertical_
= scrollable
;
438 bool user_scrollable_vertical() const { return user_scrollable_vertical_
; }
440 bool user_scrollable(ScrollbarOrientation orientation
) const;
442 void ApplySentScrollDeltasFromAbortedCommit();
444 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread
) {
445 should_scroll_on_main_thread_
= should_scroll_on_main_thread
;
447 bool should_scroll_on_main_thread() const {
448 return should_scroll_on_main_thread_
;
451 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers
) {
452 have_wheel_event_handlers_
= have_wheel_event_handlers
;
454 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_
; }
456 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers
) {
457 have_scroll_event_handlers_
= have_scroll_event_handlers
;
459 bool have_scroll_event_handlers() const {
460 return have_scroll_event_handlers_
;
463 void SetNonFastScrollableRegion(const Region
& region
) {
464 non_fast_scrollable_region_
= region
;
466 const Region
& non_fast_scrollable_region() const {
467 return non_fast_scrollable_region_
;
470 void SetTouchEventHandlerRegion(const Region
& region
) {
471 touch_event_handler_region_
= region
;
473 const Region
& touch_event_handler_region() const {
474 return touch_event_handler_region_
;
477 void SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on
) {
478 scroll_blocks_on_
= scroll_blocks_on
;
480 ScrollBlocksOn
scroll_blocks_on() const { return scroll_blocks_on_
; }
481 void SetDrawCheckerboardForMissingTiles(bool checkerboard
) {
482 draw_checkerboard_for_missing_tiles_
= checkerboard
;
484 bool draw_checkerboard_for_missing_tiles() const {
485 return draw_checkerboard_for_missing_tiles_
;
488 InputHandler::ScrollStatus
TryScroll(
489 const gfx::PointF
& screen_space_point
,
490 InputHandler::ScrollInputType type
,
491 ScrollBlocksOn effective_block_mode
) const;
493 void SetDoubleSided(bool double_sided
);
494 bool double_sided() const { return double_sided_
; }
496 void SetTransform(const gfx::Transform
& transform
);
497 const gfx::Transform
& transform() const { return transform_
; }
498 bool TransformIsAnimating() const;
499 bool TransformIsAnimatingOnImplOnly() const;
500 void SetTransformAndInvertibility(const gfx::Transform
& transform
,
501 bool transform_is_invertible
);
502 bool transform_is_invertible() const { return transform_is_invertible_
; }
504 // Note this rect is in layer space (not content space).
505 void SetUpdateRect(const gfx::Rect
& update_rect
);
506 gfx::Rect
update_rect() const { return update_rect_
; }
508 void AddDamageRect(const gfx::RectF
& damage_rect
);
510 const gfx::RectF
& damage_rect() const { return damage_rect_
; }
512 virtual base::DictionaryValue
* LayerTreeAsJson() const;
514 void SetStackingOrderChanged(bool stacking_order_changed
);
516 bool LayerPropertyChanged() const { return layer_property_changed_
; }
518 void ResetAllChangeTrackingForSubtree();
520 LayerAnimationController
* layer_animation_controller() {
521 return layer_animation_controller_
.get();
524 const LayerAnimationController
* layer_animation_controller() const {
525 return layer_animation_controller_
.get();
528 virtual SimpleEnclosedRegion
VisibleContentOpaqueRegion() const;
530 virtual void DidBecomeActive();
532 virtual void DidBeginTracing();
534 // Release resources held by this layer. Called when the output surface
535 // that rendered this layer was lost or a rendering mode switch has occured.
536 virtual void ReleaseResources();
538 // Recreate resources that are required after they were released by a
539 // ReleaseResources call.
540 virtual void RecreateResources();
542 ScrollbarAnimationController
* scrollbar_animation_controller() const {
543 return scrollbar_animation_controller_
.get();
546 typedef std::set
<ScrollbarLayerImplBase
*> ScrollbarSet
;
547 ScrollbarSet
* scrollbars() { return scrollbars_
.get(); }
548 void ClearScrollbars();
549 void AddScrollbar(ScrollbarLayerImplBase
* layer
);
550 void RemoveScrollbar(ScrollbarLayerImplBase
* layer
);
551 bool HasScrollbar(ScrollbarOrientation orientation
) const;
552 void ScrollbarParametersDidChange(bool on_resize
);
554 return scroll_clip_layer_
? scroll_clip_layer_
->bounds().height() : 0;
557 gfx::Rect
LayerRectToContentRect(const gfx::RectF
& layer_rect
) const;
559 virtual skia::RefPtr
<SkPicture
> GetPicture();
561 virtual scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
);
562 virtual void PushPropertiesTo(LayerImpl
* layer
);
564 virtual void GetAllTilesForTracing(std::set
<const Tile
*>* tiles
) const;
565 virtual void AsValueInto(base::trace_event::TracedValue
* dict
) const;
567 virtual size_t GPUMemoryUsageInBytes() const;
569 void SetNeedsPushProperties();
570 void AddDependentNeedsPushProperties();
571 void RemoveDependentNeedsPushProperties();
572 bool parent_should_know_need_push_properties() const {
573 return needs_push_properties() || descendant_needs_push_properties();
576 bool needs_push_properties() const { return needs_push_properties_
; }
577 bool descendant_needs_push_properties() const {
578 return num_dependents_need_push_properties_
> 0;
581 virtual void RunMicroBenchmark(MicroBenchmarkImpl
* benchmark
);
583 virtual void SetDebugInfo(
584 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> other
);
586 bool IsDrawnRenderSurfaceLayerListMember() const;
588 void Set3dSortingContextId(int id
);
589 int sorting_context_id() { return sorting_context_id_
; }
591 void PassFrameTimingRequests(
592 std::vector
<FrameTimingRequest
>* frame_timing_requests
);
593 const std::vector
<FrameTimingRequest
>& frame_timing_requests() const {
594 return frame_timing_requests_
;
597 SyncedScrollOffset
* synced_scroll_offset() { return scroll_offset_
.get(); }
600 LayerImpl(LayerTreeImpl
* layer_impl
,
602 scoped_refptr
<SyncedScrollOffset
> scroll_offset
);
603 LayerImpl(LayerTreeImpl
* layer_impl
, int id
);
605 // Get the color and size of the layer's debug border.
606 virtual void GetDebugBorderProperties(SkColor
* color
, float* width
) const;
608 void AppendDebugBorderQuad(RenderPass
* render_pass
,
609 const gfx::Size
& content_bounds
,
610 const SharedQuadState
* shared_quad_state
,
611 AppendQuadsData
* append_quads_data
) const;
612 void AppendDebugBorderQuad(RenderPass
* render_pass
,
613 const gfx::Size
& content_bounds
,
614 const SharedQuadState
* shared_quad_state
,
615 AppendQuadsData
* append_quads_data
,
619 void NoteLayerPropertyChanged();
620 void NoteLayerPropertyChangedForSubtree();
622 // Note carefully this does not affect the current layer.
623 void NoteLayerPropertyChangedForDescendants();
626 void PushScrollOffset(const gfx::ScrollOffset
* scroll_offset
);
627 void DidUpdateScrollOffset();
628 void NoteLayerPropertyChangedForDescendantsInternal();
630 virtual const char* LayerTypeAsString() const;
632 // Properties internal to LayerImpl
634 OwnedLayerImplList children_
;
636 LayerImpl
* scroll_parent_
;
638 // Storing a pointer to a set rather than a set since this will be rarely
639 // used. If this pointer turns out to be too heavy, we could have this (and
640 // the scroll parent above) be stored in a LayerImpl -> scroll_info
642 scoped_ptr
<std::set
<LayerImpl
*>> scroll_children_
;
644 LayerImpl
* clip_parent_
;
645 scoped_ptr
<std::set
<LayerImpl
*>> clip_children_
;
647 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
648 // confirm newly assigned layer is still the previous one
650 scoped_ptr
<LayerImpl
> mask_layer_
;
651 int replica_layer_id_
; // ditto
652 scoped_ptr
<LayerImpl
> replica_layer_
;
654 LayerTreeImpl
* layer_tree_impl_
;
656 // Properties dynamically changeable on active tree.
657 scoped_refptr
<SyncedScrollOffset
> scroll_offset_
;
658 gfx::Vector2dF bounds_delta_
;
660 // Properties synchronized from the associated Layer.
661 gfx::Point3F transform_origin_
;
663 ScrollOffsetDelegate
* scroll_offset_delegate_
;
664 LayerImpl
* scroll_clip_layer_
;
665 bool scrollable_
: 1;
666 bool should_scroll_on_main_thread_
: 1;
667 bool have_wheel_event_handlers_
: 1;
668 bool have_scroll_event_handlers_
: 1;
670 static_assert(SCROLL_BLOCKS_ON_MAX
< (1 << 3), "ScrollBlocksOn too big");
671 ScrollBlocksOn scroll_blocks_on_
: 3;
673 bool user_scrollable_horizontal_
: 1;
674 bool user_scrollable_vertical_
: 1;
675 bool stacking_order_changed_
: 1;
676 // Whether the "back" of this layer should draw.
677 bool double_sided_
: 1;
678 bool should_flatten_transform_
: 1;
680 // Tracks if drawing-related properties have changed since last redraw.
681 bool layer_property_changed_
: 1;
683 bool masks_to_bounds_
: 1;
684 bool contents_opaque_
: 1;
685 bool is_root_for_isolated_group_
: 1;
686 bool use_parent_backface_visibility_
: 1;
687 bool draw_checkerboard_for_missing_tiles_
: 1;
688 bool draws_content_
: 1;
689 bool hide_layer_and_subtree_
: 1;
691 // Cache transform_'s invertibility.
692 bool transform_is_invertible_
: 1;
694 // Set for the layer that other layers are fixed to.
695 bool is_container_for_fixed_position_layers_
: 1;
696 Region non_fast_scrollable_region_
;
697 Region touch_event_handler_region_
;
698 SkColor background_color_
;
701 SkXfermode::Mode blend_mode_
;
702 gfx::PointF position_
;
703 gfx::Transform transform_
;
705 LayerPositionConstraint position_constraint_
;
707 gfx::Vector2dF scroll_compensation_adjustment_
;
709 int num_descendants_that_draw_content_
;
711 // The global depth value of the center of the layer. This value is used
712 // to sort layers from back to front.
715 FilterOperations filters_
;
716 FilterOperations background_filters_
;
719 friend class TreeSynchronizer
;
721 // This flag is set when the layer needs to push properties to the active
723 bool needs_push_properties_
;
725 // The number of direct children or dependent layers that need to be recursed
726 // to in order for them or a descendent of them to push properties to the
728 int num_dependents_need_push_properties_
;
730 // Layers that share a sorting context id will be sorted together in 3d
731 // space. 0 is a special value that means this layer will not be sorted and
732 // will be drawn in paint order.
733 int sorting_context_id_
;
735 DrawMode current_draw_mode_
;
738 // Rect indicating what was repainted/updated during update.
739 // Note that plugin layers bypass this and leave it empty.
740 // Uses layer (not content) space.
741 gfx::Rect update_rect_
;
743 // This rect is in layer space.
744 gfx::RectF damage_rect_
;
746 // Manages animations for this layer.
747 scoped_refptr
<LayerAnimationController
> layer_animation_controller_
;
749 // Manages scrollbars for this layer
750 scoped_ptr
<ScrollbarAnimationController
> scrollbar_animation_controller_
;
752 scoped_ptr
<ScrollbarSet
> scrollbars_
;
754 ScopedPtrVector
<CopyOutputRequest
> copy_requests_
;
756 // Group of properties that need to be computed based on the layer tree
757 // hierarchy before layers can be drawn.
758 DrawProperties
<LayerImpl
> draw_properties_
;
760 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> debug_info_
;
761 scoped_ptr
<RenderSurfaceImpl
> render_surface_
;
763 std::vector
<FrameTimingRequest
> frame_timing_requests_
;
764 bool frame_timing_requests_dirty_
;
766 DISALLOW_COPY_AND_ASSIGN(LayerImpl
);
771 #endif // CC_LAYERS_LAYER_IMPL_H_