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_
13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/values.h"
16 #include "cc/animation/animation_delegate.h"
17 #include "cc/animation/layer_animation_controller.h"
18 #include "cc/animation/layer_animation_value_observer.h"
19 #include "cc/animation/layer_animation_value_provider.h"
20 #include "cc/base/cc_export.h"
21 #include "cc/base/region.h"
22 #include "cc/base/scoped_ptr_vector.h"
23 #include "cc/base/synced_property.h"
24 #include "cc/debug/frame_timing_request.h"
25 #include "cc/input/input_handler.h"
26 #include "cc/input/scrollbar.h"
27 #include "cc/layers/draw_properties.h"
28 #include "cc/layers/layer_lists.h"
29 #include "cc/layers/layer_position_constraint.h"
30 #include "cc/layers/render_surface_impl.h"
31 #include "cc/layers/scroll_blocks_on.h"
32 #include "cc/output/filter_operations.h"
33 #include "cc/quads/shared_quad_state.h"
34 #include "cc/resources/resource_provider.h"
35 #include "cc/tiles/tile_priority.h"
36 #include "skia/ext/refptr.h"
37 #include "third_party/skia/include/core/SkColor.h"
38 #include "third_party/skia/include/core/SkImageFilter.h"
39 #include "third_party/skia/include/core/SkPicture.h"
40 #include "ui/gfx/geometry/point3_f.h"
41 #include "ui/gfx/geometry/rect.h"
42 #include "ui/gfx/geometry/rect_f.h"
43 #include "ui/gfx/geometry/scroll_offset.h"
44 #include "ui/gfx/transform.h"
47 namespace trace_event
{
48 class ConvertableToTraceFormat
;
51 class DictionaryValue
;
56 class LayerTreeHostImpl
;
58 class MicroBenchmarkImpl
;
60 template <typename LayerType
>
61 class OcclusionTracker
;
63 class PrioritizedTile
;
67 class ScrollbarAnimationController
;
68 class ScrollbarLayerImplBase
;
69 class SimpleEnclosedRegion
;
73 struct AppendQuadsData
;
79 DRAW_MODE_RESOURCELESS_SOFTWARE
82 class CC_EXPORT LayerImpl
: public LayerAnimationValueObserver
,
83 public LayerAnimationValueProvider
,
84 public AnimationDelegate
{
86 typedef SyncedProperty
<AdditionGroup
<gfx::ScrollOffset
>> SyncedScrollOffset
;
87 typedef LayerImplList RenderSurfaceListType
;
88 typedef LayerImplList LayerListType
;
89 typedef RenderSurfaceImpl RenderSurfaceType
;
91 enum RenderingContextConstants
{ NO_RENDERING_CONTEXT
= 0 };
93 static scoped_ptr
<LayerImpl
> Create(
94 LayerTreeImpl
* tree_impl
,
96 scoped_refptr
<SyncedScrollOffset
> scroll_offset
) {
97 return make_scoped_ptr(new LayerImpl(tree_impl
, id
, scroll_offset
));
100 static scoped_ptr
<LayerImpl
> Create(LayerTreeImpl
* tree_impl
, int id
) {
101 return make_scoped_ptr(new LayerImpl(tree_impl
, id
));
104 ~LayerImpl() override
;
106 int id() const { return layer_id_
; }
108 // LayerAnimationValueProvider implementation.
109 gfx::ScrollOffset
ScrollOffsetForAnimation() const override
;
111 // LayerAnimationValueObserver implementation.
112 void OnFilterAnimated(const FilterOperations
& filters
) override
;
113 void OnOpacityAnimated(float opacity
) override
;
114 void OnTransformAnimated(const gfx::Transform
& transform
) override
;
115 void OnScrollOffsetAnimated(const gfx::ScrollOffset
& scroll_offset
) override
;
116 void OnAnimationWaitingForDeletion() override
;
117 bool IsActive() const override
;
119 // AnimationDelegate implementation.
120 void NotifyAnimationStarted(base::TimeTicks monotonic_time
,
121 Animation::TargetProperty target_property
,
122 int group
) override
{};
123 void NotifyAnimationFinished(base::TimeTicks monotonic_time
,
124 Animation::TargetProperty target_property
,
128 LayerImpl
* parent() { return parent_
; }
129 const LayerImpl
* parent() const { return parent_
; }
130 const OwnedLayerImplList
& children() const { return children_
; }
131 OwnedLayerImplList
& children() { return children_
; }
132 LayerImpl
* child_at(size_t index
) const { return children_
[index
]; }
133 void AddChild(scoped_ptr
<LayerImpl
> child
);
134 scoped_ptr
<LayerImpl
> RemoveChild(LayerImpl
* child
);
135 void SetParent(LayerImpl
* parent
);
137 // Warning: This does not preserve tree structure invariants.
138 void ClearChildList();
140 bool HasAncestor(const LayerImpl
* ancestor
) const;
142 void SetScrollParent(LayerImpl
* parent
);
144 LayerImpl
* scroll_parent() { return scroll_parent_
; }
145 const LayerImpl
* scroll_parent() const { return scroll_parent_
; }
147 void SetScrollChildren(std::set
<LayerImpl
*>* children
);
149 std::set
<LayerImpl
*>* scroll_children() { return scroll_children_
.get(); }
150 const std::set
<LayerImpl
*>* scroll_children() const {
151 return scroll_children_
.get();
154 void set_property_tree_sequence_number(int sequence_number
) {}
156 void SetTransformTreeIndex(int index
);
157 int transform_tree_index() const { return transform_tree_index_
; }
159 void SetClipTreeIndex(int index
);
160 int clip_tree_index() const { return clip_tree_index_
; }
162 void SetOpacityTreeIndex(int index
);
163 int opacity_tree_index() const { return opacity_tree_index_
; }
165 void set_offset_to_transform_parent(const gfx::Vector2dF
& offset
) {
166 offset_to_transform_parent_
= offset
;
167 SetNeedsPushProperties();
169 gfx::Vector2dF
offset_to_transform_parent() const {
170 return offset_to_transform_parent_
;
173 const gfx::Rect
& visible_rect_from_property_trees() const {
174 return visible_rect_from_property_trees_
;
176 void set_visible_rect_from_property_trees(const gfx::Rect
& rect
) {
177 visible_rect_from_property_trees_
= rect
;
180 void set_should_flatten_transform_from_property_tree(bool should_flatten
) {
181 should_flatten_transform_from_property_tree_
= should_flatten
;
182 SetNeedsPushProperties();
184 bool should_flatten_transform_from_property_tree() const {
185 return should_flatten_transform_from_property_tree_
;
188 // For compatibility with Layer.
189 bool has_render_surface() const { return !!render_surface(); }
191 void SetNumDescendantsThatDrawContent(int num_descendants
);
192 void SetClipParent(LayerImpl
* ancestor
);
194 LayerImpl
* clip_parent() {
197 const LayerImpl
* clip_parent() const {
201 void SetClipChildren(std::set
<LayerImpl
*>* children
);
203 std::set
<LayerImpl
*>* clip_children() { return clip_children_
.get(); }
204 const std::set
<LayerImpl
*>* clip_children() const {
205 return clip_children_
.get();
208 void PassCopyRequests(ScopedPtrVector
<CopyOutputRequest
>* requests
);
209 // Can only be called when the layer has a copy request.
210 void TakeCopyRequestsAndTransformToTarget(
211 ScopedPtrVector
<CopyOutputRequest
>* request
);
212 bool HasCopyRequest() const { return !copy_requests_
.empty(); }
214 void SetMaskLayer(scoped_ptr
<LayerImpl
> mask_layer
);
215 LayerImpl
* mask_layer() { return mask_layer_
.get(); }
216 const LayerImpl
* mask_layer() const { return mask_layer_
.get(); }
217 scoped_ptr
<LayerImpl
> TakeMaskLayer();
219 void SetReplicaLayer(scoped_ptr
<LayerImpl
> replica_layer
);
220 LayerImpl
* replica_layer() { return replica_layer_
.get(); }
221 const LayerImpl
* replica_layer() const { return replica_layer_
.get(); }
222 scoped_ptr
<LayerImpl
> TakeReplicaLayer();
224 bool has_mask() const { return mask_layer_
; }
225 bool has_replica() const { return replica_layer_
; }
226 bool replica_has_mask() const {
227 return replica_layer_
&& (mask_layer_
|| replica_layer_
->mask_layer_
);
230 LayerTreeImpl
* layer_tree_impl() const { return layer_tree_impl_
; }
232 void PopulateSharedQuadState(SharedQuadState
* state
) const;
233 void PopulateScaledSharedQuadState(SharedQuadState
* state
, float scale
) const;
234 // WillDraw must be called before AppendQuads. If WillDraw returns false,
235 // AppendQuads and DidDraw will not be called. If WillDraw returns true,
236 // DidDraw is guaranteed to be called before another WillDraw or before
237 // the layer is destroyed. To enforce this, any class that overrides
238 // WillDraw/DidDraw must call the base class version only if WillDraw
240 virtual bool WillDraw(DrawMode draw_mode
,
241 ResourceProvider
* resource_provider
);
242 virtual void AppendQuads(RenderPass
* render_pass
,
243 AppendQuadsData
* append_quads_data
) {}
244 virtual void DidDraw(ResourceProvider
* resource_provider
);
246 // Verify that the resource ids in the quad are valid.
247 void ValidateQuadResources(DrawQuad
* quad
) const {
249 ValidateQuadResourcesInternal(quad
);
253 virtual void GetContentsResourceId(ResourceId
* resource_id
,
254 gfx::Size
* resource_size
) const;
256 virtual bool HasDelegatedContent() const;
257 virtual bool HasContributingDelegatedRenderPasses() const;
258 virtual RenderPassId
FirstContributingRenderPassId() const;
259 virtual RenderPassId
NextContributingRenderPassId(RenderPassId id
) const;
261 virtual void NotifyTileStateChanged(const Tile
* tile
) {}
263 virtual ScrollbarLayerImplBase
* ToScrollbarLayer();
265 // Returns true if this layer has content to draw.
266 void SetDrawsContent(bool draws_content
);
267 bool DrawsContent() const { return draws_content_
; }
269 int NumDescendantsThatDrawContent() const;
270 void SetHideLayerAndSubtree(bool hide
);
271 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_
; }
273 void SetTransformOrigin(const gfx::Point3F
& transform_origin
);
274 gfx::Point3F
transform_origin() const { return transform_origin_
; }
276 void SetBackgroundColor(SkColor background_color
);
277 SkColor
background_color() const { return background_color_
; }
278 // If contents_opaque(), return an opaque color else return a
279 // non-opaque color. Tries to return background_color(), if possible.
280 SkColor
SafeOpaqueBackgroundColor() const;
282 void SetFilters(const FilterOperations
& filters
);
283 const FilterOperations
& filters() const { return filters_
; }
284 bool FilterIsAnimating() const;
285 bool FilterIsAnimatingOnImplOnly() const;
287 void SetBackgroundFilters(const FilterOperations
& filters
);
288 const FilterOperations
& background_filters() const {
289 return background_filters_
;
292 void SetMasksToBounds(bool masks_to_bounds
);
293 bool masks_to_bounds() const { return masks_to_bounds_
; }
295 void SetContentsOpaque(bool opaque
);
296 bool contents_opaque() const { return contents_opaque_
; }
298 void SetOpacity(float opacity
);
299 float opacity() const { return opacity_
; }
300 bool OpacityIsAnimating() const;
301 bool OpacityIsAnimatingOnImplOnly() const;
303 void SetBlendMode(SkXfermode::Mode
);
304 SkXfermode::Mode
blend_mode() const { return blend_mode_
; }
305 bool uses_default_blend_mode() const {
306 return blend_mode_
== SkXfermode::kSrcOver_Mode
;
309 void SetIsRootForIsolatedGroup(bool root
);
310 bool is_root_for_isolated_group() const {
311 return is_root_for_isolated_group_
;
314 void SetPosition(const gfx::PointF
& position
);
315 gfx::PointF
position() const { return position_
; }
317 void SetIsContainerForFixedPositionLayers(bool container
) {
318 is_container_for_fixed_position_layers_
= container
;
320 // This is a non-trivial function in Layer.
321 bool IsContainerForFixedPositionLayers() const {
322 return is_container_for_fixed_position_layers_
;
325 gfx::Vector2dF
FixedContainerSizeDelta() const;
327 void SetPositionConstraint(const LayerPositionConstraint
& constraint
) {
328 position_constraint_
= constraint
;
330 const LayerPositionConstraint
& position_constraint() const {
331 return position_constraint_
;
334 void SetShouldFlattenTransform(bool flatten
);
335 bool should_flatten_transform() const { return should_flatten_transform_
; }
337 bool Is3dSorted() const { return sorting_context_id_
!= 0; }
339 void SetUseParentBackfaceVisibility(bool use
) {
340 use_parent_backface_visibility_
= use
;
342 bool use_parent_backface_visibility() const {
343 return use_parent_backface_visibility_
;
346 bool ShowDebugBorders() const;
348 // These invalidate the host's render surface layer list. The caller
349 // is responsible for calling set_needs_update_draw_properties on the tree
350 // so that its list can be recreated.
351 void ClearRenderSurfaceLayerList();
352 void SetHasRenderSurface(bool has_render_surface
);
354 RenderSurfaceImpl
* render_surface() const { return render_surface_
.get(); }
356 DrawProperties
<LayerImpl
>& draw_properties() {
357 return draw_properties_
;
359 const DrawProperties
<LayerImpl
>& draw_properties() const {
360 return draw_properties_
;
363 // The following are shortcut accessors to get various information from
365 const gfx::Transform
& draw_transform() const {
366 return draw_properties_
.target_space_transform
;
368 const gfx::Transform
& screen_space_transform() const {
369 return draw_properties_
.screen_space_transform
;
371 float draw_opacity() const { return draw_properties_
.opacity
; }
372 SkXfermode::Mode
draw_blend_mode() const {
373 return draw_properties_
.blend_mode
;
375 bool draw_opacity_is_animating() const {
376 return draw_properties_
.opacity_is_animating
;
378 bool draw_transform_is_animating() const {
379 return draw_properties_
.target_space_transform_is_animating
;
381 bool screen_space_transform_is_animating() const {
382 return draw_properties_
.screen_space_transform_is_animating
;
384 bool screen_space_opacity_is_animating() const {
385 return draw_properties_
.screen_space_opacity_is_animating
;
387 bool can_use_lcd_text() const { return draw_properties_
.can_use_lcd_text
; }
388 bool is_clipped() const { return draw_properties_
.is_clipped
; }
389 gfx::Rect
clip_rect() const { return draw_properties_
.clip_rect
; }
390 gfx::Rect
drawable_content_rect() const {
391 return draw_properties_
.drawable_content_rect
;
393 gfx::Rect
visible_content_rect() const {
394 return draw_properties_
.visible_content_rect
;
396 LayerImpl
* render_target() {
397 DCHECK(!draw_properties_
.render_target
||
398 draw_properties_
.render_target
->render_surface());
399 return draw_properties_
.render_target
;
401 const LayerImpl
* render_target() const {
402 DCHECK(!draw_properties_
.render_target
||
403 draw_properties_
.render_target
->render_surface());
404 return draw_properties_
.render_target
;
407 int num_unclipped_descendants() const {
408 return draw_properties_
.num_unclipped_descendants
;
411 // The client should be responsible for setting bounds, content bounds and
412 // contents scale to appropriate values. LayerImpl doesn't calculate any of
413 // them from the other values.
415 void SetBounds(const gfx::Size
& bounds
);
416 gfx::Size
bounds() const;
417 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions
418 // of pixels) due to use of single precision float.
419 gfx::SizeF
BoundsForScrolling() const;
420 void SetBoundsDelta(const gfx::Vector2dF
& bounds_delta
);
421 gfx::Vector2dF
bounds_delta() const { return bounds_delta_
; }
423 void SetContentBounds(const gfx::Size
& content_bounds
);
424 gfx::Size
content_bounds() const { return draw_properties_
.content_bounds
; }
426 float contents_scale_x() const { return draw_properties_
.contents_scale_x
; }
427 float contents_scale_y() const { return draw_properties_
.contents_scale_y
; }
428 void SetContentsScale(float contents_scale_x
, float contents_scale_y
);
430 bool IsExternalFlingActive() const;
432 void SetCurrentScrollOffset(const gfx::ScrollOffset
& scroll_offset
);
433 void SetCurrentScrollOffsetFromDelegate(
434 const gfx::ScrollOffset
& scroll_offset
);
435 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset
& scroll_offset
);
436 // This method is similar to PushScrollOffsetFromMainThread but will cause the
437 // scroll offset given to clobber any scroll changes on the active tree in the
438 // time until this value is pushed to the active tree.
439 void PushScrollOffsetFromMainThreadAndClobberActiveValue(
440 const gfx::ScrollOffset
& scroll_offset
);
441 gfx::ScrollOffset
PullDeltaForMainThread();
442 gfx::ScrollOffset
CurrentScrollOffset() const;
443 gfx::ScrollOffset
BaseScrollOffset() const;
444 gfx::Vector2dF
ScrollDelta() const;
445 void SetScrollDelta(const gfx::Vector2dF
& delta
);
447 gfx::ScrollOffset
MaxScrollOffset() const;
448 gfx::ScrollOffset
ClampScrollOffsetToLimits(gfx::ScrollOffset offset
) const;
449 gfx::Vector2dF
ClampScrollToMaxScrollOffset();
450 void SetScrollbarPosition(ScrollbarLayerImplBase
* scrollbar_layer
,
451 LayerImpl
* scrollbar_clip_layer
,
452 bool on_resize
) const;
453 void SetScrollCompensationAdjustment(const gfx::Vector2dF
& scroll_offset
) {
454 scroll_compensation_adjustment_
= scroll_offset
;
456 gfx::Vector2dF
ScrollCompensationAdjustment() const {
457 return scroll_compensation_adjustment_
;
460 // Returns the delta of the scroll that was outside of the bounds of the
462 gfx::Vector2dF
ScrollBy(const gfx::Vector2dF
& scroll
);
464 void SetScrollClipLayer(int scroll_clip_layer_id
);
465 LayerImpl
* scroll_clip_layer() const { return scroll_clip_layer_
; }
466 bool scrollable() const { return !!scroll_clip_layer_
; }
468 void set_user_scrollable_horizontal(bool scrollable
) {
469 user_scrollable_horizontal_
= scrollable
;
471 bool user_scrollable_horizontal() const {
472 return user_scrollable_horizontal_
;
474 void set_user_scrollable_vertical(bool scrollable
) {
475 user_scrollable_vertical_
= scrollable
;
477 bool user_scrollable_vertical() const { return user_scrollable_vertical_
; }
479 bool user_scrollable(ScrollbarOrientation orientation
) const;
481 void ApplySentScrollDeltasFromAbortedCommit();
483 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread
) {
484 should_scroll_on_main_thread_
= should_scroll_on_main_thread
;
486 bool should_scroll_on_main_thread() const {
487 return should_scroll_on_main_thread_
;
490 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers
) {
491 have_wheel_event_handlers_
= have_wheel_event_handlers
;
493 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_
; }
495 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers
) {
496 have_scroll_event_handlers_
= have_scroll_event_handlers
;
498 bool have_scroll_event_handlers() const {
499 return have_scroll_event_handlers_
;
502 void SetNonFastScrollableRegion(const Region
& region
) {
503 non_fast_scrollable_region_
= region
;
505 const Region
& non_fast_scrollable_region() const {
506 return non_fast_scrollable_region_
;
509 void SetTouchEventHandlerRegion(const Region
& region
) {
510 touch_event_handler_region_
= region
;
512 const Region
& touch_event_handler_region() const {
513 return touch_event_handler_region_
;
516 void SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on
) {
517 scroll_blocks_on_
= scroll_blocks_on
;
519 ScrollBlocksOn
scroll_blocks_on() const { return scroll_blocks_on_
; }
520 void SetDrawCheckerboardForMissingTiles(bool checkerboard
) {
521 draw_checkerboard_for_missing_tiles_
= checkerboard
;
523 bool draw_checkerboard_for_missing_tiles() const {
524 return draw_checkerboard_for_missing_tiles_
;
527 InputHandler::ScrollStatus
TryScroll(
528 const gfx::PointF
& screen_space_point
,
529 InputHandler::ScrollInputType type
,
530 ScrollBlocksOn effective_block_mode
) const;
532 void SetDoubleSided(bool double_sided
);
533 bool double_sided() const { return double_sided_
; }
535 void SetTransform(const gfx::Transform
& transform
);
536 const gfx::Transform
& transform() const { return transform_
; }
537 bool TransformIsAnimating() const;
538 bool TransformIsAnimatingOnImplOnly() const;
539 void SetTransformAndInvertibility(const gfx::Transform
& transform
,
540 bool transform_is_invertible
);
541 bool transform_is_invertible() const { return transform_is_invertible_
; }
543 // Note this rect is in layer space (not content space).
544 void SetUpdateRect(const gfx::Rect
& update_rect
);
545 gfx::Rect
update_rect() const { return update_rect_
; }
547 void AddDamageRect(const gfx::RectF
& damage_rect
);
549 const gfx::RectF
& damage_rect() const { return damage_rect_
; }
551 virtual base::DictionaryValue
* LayerTreeAsJson() const;
553 void SetStackingOrderChanged(bool stacking_order_changed
);
555 bool LayerPropertyChanged() const { return layer_property_changed_
; }
557 void ResetAllChangeTrackingForSubtree();
559 LayerAnimationController
* layer_animation_controller() {
560 return layer_animation_controller_
.get();
563 const LayerAnimationController
* layer_animation_controller() const {
564 return layer_animation_controller_
.get();
567 virtual SimpleEnclosedRegion
VisibleContentOpaqueRegion() const;
569 virtual void DidBecomeActive();
571 virtual void DidBeginTracing();
573 // Release resources held by this layer. Called when the output surface
574 // that rendered this layer was lost or a rendering mode switch has occured.
575 virtual void ReleaseResources();
577 // Recreate resources that are required after they were released by a
578 // ReleaseResources call.
579 virtual void RecreateResources();
581 ScrollbarAnimationController
* scrollbar_animation_controller() const {
582 return scrollbar_animation_controller_
.get();
585 typedef std::set
<ScrollbarLayerImplBase
*> ScrollbarSet
;
586 ScrollbarSet
* scrollbars() { return scrollbars_
.get(); }
587 void ClearScrollbars();
588 void AddScrollbar(ScrollbarLayerImplBase
* layer
);
589 void RemoveScrollbar(ScrollbarLayerImplBase
* layer
);
590 bool HasScrollbar(ScrollbarOrientation orientation
) const;
591 void ScrollbarParametersDidChange(bool on_resize
);
593 return scroll_clip_layer_
? scroll_clip_layer_
->bounds().height() : 0;
596 gfx::Rect
LayerRectToContentRect(const gfx::RectF
& layer_rect
) const;
598 virtual skia::RefPtr
<SkPicture
> GetPicture();
600 virtual scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
);
601 virtual void PushPropertiesTo(LayerImpl
* layer
);
603 virtual void GetAllPrioritizedTilesForTracing(
604 std::vector
<PrioritizedTile
>* prioritized_tiles
) const;
605 virtual void AsValueInto(base::trace_event::TracedValue
* dict
) const;
607 virtual size_t GPUMemoryUsageInBytes() const;
609 void SetNeedsPushProperties();
610 void AddDependentNeedsPushProperties();
611 void RemoveDependentNeedsPushProperties();
612 bool parent_should_know_need_push_properties() const {
613 return needs_push_properties() || descendant_needs_push_properties();
616 bool needs_push_properties() const { return needs_push_properties_
; }
617 bool descendant_needs_push_properties() const {
618 return num_dependents_need_push_properties_
> 0;
621 virtual void RunMicroBenchmark(MicroBenchmarkImpl
* benchmark
);
623 virtual void SetDebugInfo(
624 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> other
);
626 bool IsDrawnRenderSurfaceLayerListMember() const;
628 void Set3dSortingContextId(int id
);
629 int sorting_context_id() { return sorting_context_id_
; }
631 void PassFrameTimingRequests(
632 std::vector
<FrameTimingRequest
>* frame_timing_requests
);
633 const std::vector
<FrameTimingRequest
>& frame_timing_requests() const {
634 return frame_timing_requests_
;
636 void GatherFrameTimingRequestIds(std::vector
<int64_t>* request_ids
);
638 SyncedScrollOffset
* synced_scroll_offset() { return scroll_offset_
.get(); }
640 // Get the correct invalidation region instead of conservative Rect
641 // for layers that provide it.
642 virtual Region
GetInvalidationRegion();
644 virtual gfx::Rect
GetEnclosingRectInTargetSpace() const;
647 LayerImpl(LayerTreeImpl
* layer_impl
,
649 scoped_refptr
<SyncedScrollOffset
> scroll_offset
);
650 LayerImpl(LayerTreeImpl
* layer_impl
, int id
);
652 // Get the color and size of the layer's debug border.
653 virtual void GetDebugBorderProperties(SkColor
* color
, float* width
) const;
655 void AppendDebugBorderQuad(RenderPass
* render_pass
,
656 const gfx::Size
& content_bounds
,
657 const SharedQuadState
* shared_quad_state
,
658 AppendQuadsData
* append_quads_data
) const;
659 void AppendDebugBorderQuad(RenderPass
* render_pass
,
660 const gfx::Size
& content_bounds
,
661 const SharedQuadState
* shared_quad_state
,
662 AppendQuadsData
* append_quads_data
,
666 void NoteLayerPropertyChanged();
667 void NoteLayerPropertyChangedForSubtree();
669 // Note carefully this does not affect the current layer.
670 void NoteLayerPropertyChangedForDescendants();
672 gfx::Rect
GetScaledEnclosingRectInTargetSpace(float scale
) const;
675 void ValidateQuadResourcesInternal(DrawQuad
* quad
) const;
677 void PushScrollOffset(const gfx::ScrollOffset
* scroll_offset
);
678 // If the new scroll offset is assigned from the root scroll offset delegate,
679 // LayerImpl won't inform the root scroll offset delegate about the scroll
680 // change to avoid feedback.
681 void DidUpdateScrollOffset(bool is_from_root_delegate
);
682 void NoteLayerPropertyChangedForDescendantsInternal();
684 virtual const char* LayerTypeAsString() const;
686 // Properties internal to LayerImpl
688 OwnedLayerImplList children_
;
690 LayerImpl
* scroll_parent_
;
692 // Storing a pointer to a set rather than a set since this will be rarely
693 // used. If this pointer turns out to be too heavy, we could have this (and
694 // the scroll parent above) be stored in a LayerImpl -> scroll_info
696 scoped_ptr
<std::set
<LayerImpl
*>> scroll_children_
;
698 LayerImpl
* clip_parent_
;
699 scoped_ptr
<std::set
<LayerImpl
*>> clip_children_
;
701 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
702 // confirm newly assigned layer is still the previous one
704 scoped_ptr
<LayerImpl
> mask_layer_
;
705 int replica_layer_id_
; // ditto
706 scoped_ptr
<LayerImpl
> replica_layer_
;
708 LayerTreeImpl
* layer_tree_impl_
;
710 // Properties dynamically changeable on active tree.
711 scoped_refptr
<SyncedScrollOffset
> scroll_offset_
;
712 gfx::Vector2dF bounds_delta_
;
714 // Properties synchronized from the associated Layer.
715 gfx::Point3F transform_origin_
;
717 LayerImpl
* scroll_clip_layer_
;
719 gfx::Vector2dF offset_to_transform_parent_
;
721 bool scrollable_
: 1;
722 bool should_scroll_on_main_thread_
: 1;
723 bool have_wheel_event_handlers_
: 1;
724 bool have_scroll_event_handlers_
: 1;
726 static_assert(SCROLL_BLOCKS_ON_MAX
< (1 << 3), "ScrollBlocksOn too big");
727 ScrollBlocksOn scroll_blocks_on_
: 3;
729 bool user_scrollable_horizontal_
: 1;
730 bool user_scrollable_vertical_
: 1;
731 bool stacking_order_changed_
: 1;
732 // Whether the "back" of this layer should draw.
733 bool double_sided_
: 1;
734 bool should_flatten_transform_
: 1;
735 bool should_flatten_transform_from_property_tree_
: 1;
737 // Tracks if drawing-related properties have changed since last redraw.
738 bool layer_property_changed_
: 1;
740 bool masks_to_bounds_
: 1;
741 bool contents_opaque_
: 1;
742 bool is_root_for_isolated_group_
: 1;
743 bool use_parent_backface_visibility_
: 1;
744 bool draw_checkerboard_for_missing_tiles_
: 1;
745 bool draws_content_
: 1;
746 bool hide_layer_and_subtree_
: 1;
748 // Cache transform_'s invertibility.
749 bool transform_is_invertible_
: 1;
751 // Set for the layer that other layers are fixed to.
752 bool is_container_for_fixed_position_layers_
: 1;
754 Region non_fast_scrollable_region_
;
755 Region touch_event_handler_region_
;
756 SkColor background_color_
;
759 SkXfermode::Mode blend_mode_
;
760 gfx::PointF position_
;
761 gfx::Transform transform_
;
763 LayerPositionConstraint position_constraint_
;
765 gfx::Vector2dF scroll_compensation_adjustment_
;
767 int num_descendants_that_draw_content_
;
769 gfx::Rect visible_rect_from_property_trees_
;
770 int transform_tree_index_
;
771 int opacity_tree_index_
;
772 int clip_tree_index_
;
774 // The global depth value of the center of the layer. This value is used
775 // to sort layers from back to front.
778 FilterOperations filters_
;
779 FilterOperations background_filters_
;
782 friend class TreeSynchronizer
;
784 // This flag is set when the layer needs to push properties to the active
786 bool needs_push_properties_
;
788 // The number of direct children or dependent layers that need to be recursed
789 // to in order for them or a descendent of them to push properties to the
791 int num_dependents_need_push_properties_
;
793 // Layers that share a sorting context id will be sorted together in 3d
794 // space. 0 is a special value that means this layer will not be sorted and
795 // will be drawn in paint order.
796 int sorting_context_id_
;
798 DrawMode current_draw_mode_
;
801 // Rect indicating what was repainted/updated during update.
802 // Note that plugin layers bypass this and leave it empty.
803 // Uses layer (not content) space.
804 gfx::Rect update_rect_
;
806 // This rect is in layer space.
807 gfx::RectF damage_rect_
;
809 // Manages animations for this layer.
810 scoped_refptr
<LayerAnimationController
> layer_animation_controller_
;
812 // Manages scrollbars for this layer
813 scoped_ptr
<ScrollbarAnimationController
> scrollbar_animation_controller_
;
815 scoped_ptr
<ScrollbarSet
> scrollbars_
;
817 ScopedPtrVector
<CopyOutputRequest
> copy_requests_
;
819 // Group of properties that need to be computed based on the layer tree
820 // hierarchy before layers can be drawn.
821 DrawProperties
<LayerImpl
> draw_properties_
;
823 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> debug_info_
;
824 scoped_ptr
<RenderSurfaceImpl
> render_surface_
;
826 std::vector
<FrameTimingRequest
> frame_timing_requests_
;
827 bool frame_timing_requests_dirty_
;
829 DISALLOW_COPY_AND_ASSIGN(LayerImpl
);
834 #endif // CC_LAYERS_LAYER_IMPL_H_