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/resources/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
;
65 class ScrollbarAnimationController
;
66 class ScrollbarLayerImplBase
;
67 class SimpleEnclosedRegion
;
70 struct AppendQuadsData
;
76 DRAW_MODE_RESOURCELESS_SOFTWARE
79 class CC_EXPORT LayerImpl
: public LayerAnimationValueObserver
,
80 public LayerAnimationValueProvider
,
81 public AnimationDelegate
{
83 // Allows for the ownership of the total scroll offset to be delegated outside
85 class ScrollOffsetDelegate
{
87 virtual void SetCurrentScrollOffset(const gfx::ScrollOffset
& new_value
) = 0;
88 virtual gfx::ScrollOffset
GetCurrentScrollOffset() = 0;
89 virtual bool IsExternalFlingActive() const = 0;
90 virtual void Update() const = 0;
93 typedef SyncedProperty
<AdditionGroup
<gfx::ScrollOffset
>> SyncedScrollOffset
;
94 typedef LayerImplList RenderSurfaceListType
;
95 typedef LayerImplList LayerListType
;
96 typedef RenderSurfaceImpl RenderSurfaceType
;
98 enum RenderingContextConstants
{ NO_RENDERING_CONTEXT
= 0 };
100 static scoped_ptr
<LayerImpl
> Create(
101 LayerTreeImpl
* tree_impl
,
103 scoped_refptr
<SyncedScrollOffset
> scroll_offset
) {
104 return make_scoped_ptr(new LayerImpl(tree_impl
, id
, scroll_offset
));
107 static scoped_ptr
<LayerImpl
> Create(LayerTreeImpl
* tree_impl
, int id
) {
108 return make_scoped_ptr(new LayerImpl(tree_impl
, id
));
111 ~LayerImpl() override
;
113 int id() const { return layer_id_
; }
115 // LayerAnimationValueProvider implementation.
116 gfx::ScrollOffset
ScrollOffsetForAnimation() const override
;
118 // LayerAnimationValueObserver implementation.
119 void OnFilterAnimated(const FilterOperations
& filters
) override
;
120 void OnOpacityAnimated(float opacity
) override
;
121 void OnTransformAnimated(const gfx::Transform
& transform
) override
;
122 void OnScrollOffsetAnimated(const gfx::ScrollOffset
& scroll_offset
) override
;
123 void OnAnimationWaitingForDeletion() override
;
124 bool IsActive() const override
;
126 // AnimationDelegate implementation.
127 void NotifyAnimationStarted(base::TimeTicks monotonic_time
,
128 Animation::TargetProperty target_property
,
129 int group
) override
{};
130 void NotifyAnimationFinished(base::TimeTicks monotonic_time
,
131 Animation::TargetProperty target_property
,
135 LayerImpl
* parent() { return parent_
; }
136 const LayerImpl
* parent() const { return parent_
; }
137 const OwnedLayerImplList
& children() const { return children_
; }
138 OwnedLayerImplList
& children() { return children_
; }
139 LayerImpl
* child_at(size_t index
) const { return children_
[index
]; }
140 void AddChild(scoped_ptr
<LayerImpl
> child
);
141 scoped_ptr
<LayerImpl
> RemoveChild(LayerImpl
* child
);
142 void SetParent(LayerImpl
* parent
);
144 // Warning: This does not preserve tree structure invariants.
145 void ClearChildList();
147 bool HasAncestor(const LayerImpl
* ancestor
) const;
149 void SetScrollParent(LayerImpl
* parent
);
151 LayerImpl
* scroll_parent() { return scroll_parent_
; }
152 const LayerImpl
* scroll_parent() const { return scroll_parent_
; }
154 void SetScrollChildren(std::set
<LayerImpl
*>* children
);
156 std::set
<LayerImpl
*>* scroll_children() { return scroll_children_
.get(); }
157 const std::set
<LayerImpl
*>* scroll_children() const {
158 return scroll_children_
.get();
161 void SetNumDescendantsThatDrawContent(int num_descendants
);
162 void SetClipParent(LayerImpl
* ancestor
);
164 LayerImpl
* clip_parent() {
167 const LayerImpl
* clip_parent() const {
171 void SetClipChildren(std::set
<LayerImpl
*>* children
);
173 std::set
<LayerImpl
*>* clip_children() { return clip_children_
.get(); }
174 const std::set
<LayerImpl
*>* clip_children() const {
175 return clip_children_
.get();
178 void PassCopyRequests(ScopedPtrVector
<CopyOutputRequest
>* requests
);
179 // Can only be called when the layer has a copy request.
180 void TakeCopyRequestsAndTransformToTarget(
181 ScopedPtrVector
<CopyOutputRequest
>* request
);
182 bool HasCopyRequest() const { return !copy_requests_
.empty(); }
184 void SetMaskLayer(scoped_ptr
<LayerImpl
> mask_layer
);
185 LayerImpl
* mask_layer() { return mask_layer_
.get(); }
186 const LayerImpl
* mask_layer() const { return mask_layer_
.get(); }
187 scoped_ptr
<LayerImpl
> TakeMaskLayer();
189 void SetReplicaLayer(scoped_ptr
<LayerImpl
> replica_layer
);
190 LayerImpl
* replica_layer() { return replica_layer_
.get(); }
191 const LayerImpl
* replica_layer() const { return replica_layer_
.get(); }
192 scoped_ptr
<LayerImpl
> TakeReplicaLayer();
194 bool has_mask() const { return mask_layer_
; }
195 bool has_replica() const { return replica_layer_
; }
196 bool replica_has_mask() const {
197 return replica_layer_
&& (mask_layer_
|| replica_layer_
->mask_layer_
);
200 LayerTreeImpl
* layer_tree_impl() const { return layer_tree_impl_
; }
202 void PopulateSharedQuadState(SharedQuadState
* state
) const;
203 void PopulateScaledSharedQuadState(SharedQuadState
* state
, float scale
) const;
204 // WillDraw must be called before AppendQuads. If WillDraw returns false,
205 // AppendQuads and DidDraw will not be called. If WillDraw returns true,
206 // DidDraw is guaranteed to be called before another WillDraw or before
207 // the layer is destroyed. To enforce this, any class that overrides
208 // WillDraw/DidDraw must call the base class version only if WillDraw
210 virtual bool WillDraw(DrawMode draw_mode
,
211 ResourceProvider
* resource_provider
);
212 virtual void AppendQuads(RenderPass
* render_pass
,
213 AppendQuadsData
* append_quads_data
) {}
214 virtual void DidDraw(ResourceProvider
* resource_provider
);
216 virtual void GetContentsResourceId(ResourceProvider::ResourceId
* resource_id
,
217 gfx::Size
* resource_size
) const;
219 virtual bool HasDelegatedContent() const;
220 virtual bool HasContributingDelegatedRenderPasses() const;
221 virtual RenderPassId
FirstContributingRenderPassId() const;
222 virtual RenderPassId
NextContributingRenderPassId(RenderPassId id
) const;
224 virtual void NotifyTileStateChanged(const Tile
* tile
) {}
226 virtual ScrollbarLayerImplBase
* ToScrollbarLayer();
228 // Returns true if this layer has content to draw.
229 void SetDrawsContent(bool draws_content
);
230 bool DrawsContent() const { return draws_content_
; }
232 int NumDescendantsThatDrawContent() const;
233 void SetHideLayerAndSubtree(bool hide
);
234 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_
; }
236 void SetTransformOrigin(const gfx::Point3F
& transform_origin
);
237 gfx::Point3F
transform_origin() const { return transform_origin_
; }
239 void SetBackgroundColor(SkColor background_color
);
240 SkColor
background_color() const { return background_color_
; }
241 // If contents_opaque(), return an opaque color else return a
242 // non-opaque color. Tries to return background_color(), if possible.
243 SkColor
SafeOpaqueBackgroundColor() const;
245 void SetFilters(const FilterOperations
& filters
);
246 const FilterOperations
& filters() const { return filters_
; }
247 bool FilterIsAnimating() const;
248 bool FilterIsAnimatingOnImplOnly() const;
250 void SetBackgroundFilters(const FilterOperations
& filters
);
251 const FilterOperations
& background_filters() const {
252 return background_filters_
;
255 void SetMasksToBounds(bool masks_to_bounds
);
256 bool masks_to_bounds() const { return masks_to_bounds_
; }
258 void SetContentsOpaque(bool opaque
);
259 bool contents_opaque() const { return contents_opaque_
; }
261 void SetOpacity(float opacity
);
262 float opacity() const { return opacity_
; }
263 bool OpacityIsAnimating() const;
264 bool OpacityIsAnimatingOnImplOnly() const;
266 void SetBlendMode(SkXfermode::Mode
);
267 SkXfermode::Mode
blend_mode() const { return blend_mode_
; }
268 bool uses_default_blend_mode() const {
269 return blend_mode_
== SkXfermode::kSrcOver_Mode
;
272 void SetIsRootForIsolatedGroup(bool root
);
273 bool is_root_for_isolated_group() const {
274 return is_root_for_isolated_group_
;
277 void SetPosition(const gfx::PointF
& position
);
278 gfx::PointF
position() const { return position_
; }
280 void SetIsContainerForFixedPositionLayers(bool container
) {
281 is_container_for_fixed_position_layers_
= container
;
283 // This is a non-trivial function in Layer.
284 bool IsContainerForFixedPositionLayers() const {
285 return is_container_for_fixed_position_layers_
;
288 gfx::Vector2dF
FixedContainerSizeDelta() const;
290 void SetPositionConstraint(const LayerPositionConstraint
& constraint
) {
291 position_constraint_
= constraint
;
293 const LayerPositionConstraint
& position_constraint() const {
294 return position_constraint_
;
297 void SetShouldFlattenTransform(bool flatten
);
298 bool should_flatten_transform() const { return should_flatten_transform_
; }
300 bool Is3dSorted() const { return sorting_context_id_
!= 0; }
302 void SetUseParentBackfaceVisibility(bool use
) {
303 use_parent_backface_visibility_
= use
;
305 bool use_parent_backface_visibility() const {
306 return use_parent_backface_visibility_
;
309 bool ShowDebugBorders() const;
311 // These invalidate the host's render surface layer list. The caller
312 // is responsible for calling set_needs_update_draw_properties on the tree
313 // so that its list can be recreated.
314 void ClearRenderSurfaceLayerList();
315 void SetHasRenderSurface(bool has_render_surface
);
317 RenderSurfaceImpl
* render_surface() const { return render_surface_
.get(); }
319 DrawProperties
<LayerImpl
>& draw_properties() {
320 return draw_properties_
;
322 const DrawProperties
<LayerImpl
>& draw_properties() const {
323 return draw_properties_
;
326 // The following are shortcut accessors to get various information from
328 const gfx::Transform
& draw_transform() const {
329 return draw_properties_
.target_space_transform
;
331 const gfx::Transform
& screen_space_transform() const {
332 return draw_properties_
.screen_space_transform
;
334 float draw_opacity() const { return draw_properties_
.opacity
; }
335 SkXfermode::Mode
draw_blend_mode() const {
336 return draw_properties_
.blend_mode
;
338 bool draw_opacity_is_animating() const {
339 return draw_properties_
.opacity_is_animating
;
341 bool draw_transform_is_animating() const {
342 return draw_properties_
.target_space_transform_is_animating
;
344 bool screen_space_transform_is_animating() const {
345 return draw_properties_
.screen_space_transform_is_animating
;
347 bool screen_space_opacity_is_animating() const {
348 return draw_properties_
.screen_space_opacity_is_animating
;
350 bool can_use_lcd_text() const { return draw_properties_
.can_use_lcd_text
; }
351 bool is_clipped() const { return draw_properties_
.is_clipped
; }
352 gfx::Rect
clip_rect() const { return draw_properties_
.clip_rect
; }
353 gfx::Rect
drawable_content_rect() const {
354 return draw_properties_
.drawable_content_rect
;
356 gfx::Rect
visible_content_rect() const {
357 return draw_properties_
.visible_content_rect
;
359 LayerImpl
* render_target() {
360 DCHECK(!draw_properties_
.render_target
||
361 draw_properties_
.render_target
->render_surface());
362 return draw_properties_
.render_target
;
364 const LayerImpl
* render_target() const {
365 DCHECK(!draw_properties_
.render_target
||
366 draw_properties_
.render_target
->render_surface());
367 return draw_properties_
.render_target
;
370 int num_unclipped_descendants() const {
371 return draw_properties_
.num_unclipped_descendants
;
374 // The client should be responsible for setting bounds, content bounds and
375 // contents scale to appropriate values. LayerImpl doesn't calculate any of
376 // them from the other values.
378 void SetBounds(const gfx::Size
& bounds
);
379 gfx::Size
bounds() const;
380 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions
381 // of pixels) due to use of single precision float.
382 gfx::SizeF
BoundsForScrolling() const;
383 void SetBoundsDelta(const gfx::Vector2dF
& bounds_delta
);
384 gfx::Vector2dF
bounds_delta() const { return bounds_delta_
; }
386 void SetContentBounds(const gfx::Size
& content_bounds
);
387 gfx::Size
content_bounds() const { return draw_properties_
.content_bounds
; }
389 float contents_scale_x() const { return draw_properties_
.contents_scale_x
; }
390 float contents_scale_y() const { return draw_properties_
.contents_scale_y
; }
391 void SetContentsScale(float contents_scale_x
, float contents_scale_y
);
393 void SetScrollOffsetDelegate(ScrollOffsetDelegate
* scroll_offset_delegate
);
394 void RefreshFromScrollDelegate();
395 bool IsExternalFlingActive() const;
397 void SetCurrentScrollOffset(const gfx::ScrollOffset
& scroll_offset
);
398 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset
& scroll_offset
);
399 // This method is similar to PushScrollOffsetFromMainThread but will cause the
400 // scroll offset given to clobber any scroll changes on the active tree in the
401 // time until this value is pushed to the active tree.
402 void PushScrollOffsetFromMainThreadAndClobberActiveValue(
403 const gfx::ScrollOffset
& scroll_offset
);
404 gfx::ScrollOffset
PullDeltaForMainThread();
405 gfx::ScrollOffset
CurrentScrollOffset() const;
406 gfx::ScrollOffset
BaseScrollOffset() const;
407 gfx::Vector2dF
ScrollDelta() const;
408 void SetScrollDelta(const gfx::Vector2dF
& delta
);
410 gfx::ScrollOffset
MaxScrollOffset() const;
411 gfx::ScrollOffset
ClampScrollOffsetToLimits(gfx::ScrollOffset offset
) const;
412 gfx::Vector2dF
ClampScrollToMaxScrollOffset();
413 void SetScrollbarPosition(ScrollbarLayerImplBase
* scrollbar_layer
,
414 LayerImpl
* scrollbar_clip_layer
,
415 bool on_resize
) const;
416 void SetScrollCompensationAdjustment(const gfx::Vector2dF
& scroll_offset
) {
417 scroll_compensation_adjustment_
= scroll_offset
;
419 gfx::Vector2dF
ScrollCompensationAdjustment() const {
420 return scroll_compensation_adjustment_
;
423 // Returns the delta of the scroll that was outside of the bounds of the
425 gfx::Vector2dF
ScrollBy(const gfx::Vector2dF
& scroll
);
427 void SetScrollClipLayer(int scroll_clip_layer_id
);
428 LayerImpl
* scroll_clip_layer() const { return scroll_clip_layer_
; }
429 bool scrollable() const { return !!scroll_clip_layer_
; }
431 void set_user_scrollable_horizontal(bool scrollable
) {
432 user_scrollable_horizontal_
= scrollable
;
434 bool user_scrollable_horizontal() const {
435 return user_scrollable_horizontal_
;
437 void set_user_scrollable_vertical(bool scrollable
) {
438 user_scrollable_vertical_
= scrollable
;
440 bool user_scrollable_vertical() const { return user_scrollable_vertical_
; }
442 bool user_scrollable(ScrollbarOrientation orientation
) const;
444 void ApplySentScrollDeltasFromAbortedCommit();
446 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread
) {
447 should_scroll_on_main_thread_
= should_scroll_on_main_thread
;
449 bool should_scroll_on_main_thread() const {
450 return should_scroll_on_main_thread_
;
453 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers
) {
454 have_wheel_event_handlers_
= have_wheel_event_handlers
;
456 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_
; }
458 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers
) {
459 have_scroll_event_handlers_
= have_scroll_event_handlers
;
461 bool have_scroll_event_handlers() const {
462 return have_scroll_event_handlers_
;
465 void SetNonFastScrollableRegion(const Region
& region
) {
466 non_fast_scrollable_region_
= region
;
468 const Region
& non_fast_scrollable_region() const {
469 return non_fast_scrollable_region_
;
472 void SetTouchEventHandlerRegion(const Region
& region
) {
473 touch_event_handler_region_
= region
;
475 const Region
& touch_event_handler_region() const {
476 return touch_event_handler_region_
;
479 void SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on
) {
480 scroll_blocks_on_
= scroll_blocks_on
;
482 ScrollBlocksOn
scroll_blocks_on() const { return scroll_blocks_on_
; }
483 void SetDrawCheckerboardForMissingTiles(bool checkerboard
) {
484 draw_checkerboard_for_missing_tiles_
= checkerboard
;
486 bool draw_checkerboard_for_missing_tiles() const {
487 return draw_checkerboard_for_missing_tiles_
;
490 InputHandler::ScrollStatus
TryScroll(
491 const gfx::PointF
& screen_space_point
,
492 InputHandler::ScrollInputType type
,
493 ScrollBlocksOn effective_block_mode
) const;
495 void SetDoubleSided(bool double_sided
);
496 bool double_sided() const { return double_sided_
; }
498 void SetTransform(const gfx::Transform
& transform
);
499 const gfx::Transform
& transform() const { return transform_
; }
500 bool TransformIsAnimating() const;
501 bool TransformIsAnimatingOnImplOnly() const;
502 void SetTransformAndInvertibility(const gfx::Transform
& transform
,
503 bool transform_is_invertible
);
504 bool transform_is_invertible() const { return transform_is_invertible_
; }
506 // Note this rect is in layer space (not content space).
507 void SetUpdateRect(const gfx::Rect
& update_rect
);
508 gfx::Rect
update_rect() const { return update_rect_
; }
510 void AddDamageRect(const gfx::RectF
& damage_rect
);
512 const gfx::RectF
& damage_rect() const { return damage_rect_
; }
514 virtual base::DictionaryValue
* LayerTreeAsJson() const;
516 void SetStackingOrderChanged(bool stacking_order_changed
);
518 bool LayerPropertyChanged() const { return layer_property_changed_
; }
520 void ResetAllChangeTrackingForSubtree();
522 LayerAnimationController
* layer_animation_controller() {
523 return layer_animation_controller_
.get();
526 const LayerAnimationController
* layer_animation_controller() const {
527 return layer_animation_controller_
.get();
530 virtual SimpleEnclosedRegion
VisibleContentOpaqueRegion() const;
532 virtual void DidBecomeActive();
534 virtual void DidBeginTracing();
536 // Release resources held by this layer. Called when the output surface
537 // that rendered this layer was lost or a rendering mode switch has occured.
538 virtual void ReleaseResources();
540 // Recreate resources that are required after they were released by a
541 // ReleaseResources call.
542 virtual void RecreateResources();
544 ScrollbarAnimationController
* scrollbar_animation_controller() const {
545 return scrollbar_animation_controller_
.get();
548 typedef std::set
<ScrollbarLayerImplBase
*> ScrollbarSet
;
549 ScrollbarSet
* scrollbars() { return scrollbars_
.get(); }
550 void ClearScrollbars();
551 void AddScrollbar(ScrollbarLayerImplBase
* layer
);
552 void RemoveScrollbar(ScrollbarLayerImplBase
* layer
);
553 bool HasScrollbar(ScrollbarOrientation orientation
) const;
554 void ScrollbarParametersDidChange(bool on_resize
);
556 return scroll_clip_layer_
? scroll_clip_layer_
->bounds().height() : 0;
559 gfx::Rect
LayerRectToContentRect(const gfx::RectF
& layer_rect
) const;
561 virtual skia::RefPtr
<SkPicture
> GetPicture();
563 virtual scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
);
564 virtual void PushPropertiesTo(LayerImpl
* layer
);
566 virtual void GetAllTilesAndPrioritiesForTracing(
567 std::map
<const Tile
*, TilePriority
>* tile_map
) const;
568 virtual void AsValueInto(base::trace_event::TracedValue
* dict
) const;
570 virtual size_t GPUMemoryUsageInBytes() const;
572 void SetNeedsPushProperties();
573 void AddDependentNeedsPushProperties();
574 void RemoveDependentNeedsPushProperties();
575 bool parent_should_know_need_push_properties() const {
576 return needs_push_properties() || descendant_needs_push_properties();
579 bool needs_push_properties() const { return needs_push_properties_
; }
580 bool descendant_needs_push_properties() const {
581 return num_dependents_need_push_properties_
> 0;
584 virtual void RunMicroBenchmark(MicroBenchmarkImpl
* benchmark
);
586 virtual void SetDebugInfo(
587 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> other
);
589 bool IsDrawnRenderSurfaceLayerListMember() const;
591 void Set3dSortingContextId(int id
);
592 int sorting_context_id() { return sorting_context_id_
; }
594 void PassFrameTimingRequests(
595 std::vector
<FrameTimingRequest
>* frame_timing_requests
);
596 const std::vector
<FrameTimingRequest
>& frame_timing_requests() const {
597 return frame_timing_requests_
;
600 SyncedScrollOffset
* synced_scroll_offset() { return scroll_offset_
.get(); }
602 // Get the correct invalidation region instead of conservative Rect
603 // for layers that provide it.
604 virtual Region
GetInvalidationRegion();
606 virtual gfx::Rect
GetEnclosingRectInTargetSpace() const;
609 LayerImpl(LayerTreeImpl
* layer_impl
,
611 scoped_refptr
<SyncedScrollOffset
> scroll_offset
);
612 LayerImpl(LayerTreeImpl
* layer_impl
, int id
);
614 // Get the color and size of the layer's debug border.
615 virtual void GetDebugBorderProperties(SkColor
* color
, float* width
) const;
617 void AppendDebugBorderQuad(RenderPass
* render_pass
,
618 const gfx::Size
& content_bounds
,
619 const SharedQuadState
* shared_quad_state
,
620 AppendQuadsData
* append_quads_data
) const;
621 void AppendDebugBorderQuad(RenderPass
* render_pass
,
622 const gfx::Size
& content_bounds
,
623 const SharedQuadState
* shared_quad_state
,
624 AppendQuadsData
* append_quads_data
,
628 void NoteLayerPropertyChanged();
629 void NoteLayerPropertyChangedForSubtree();
631 // Note carefully this does not affect the current layer.
632 void NoteLayerPropertyChangedForDescendants();
634 gfx::Rect
GetScaledEnclosingRectInTargetSpace(float scale
) const;
637 void PushScrollOffset(const gfx::ScrollOffset
* scroll_offset
);
638 void DidUpdateScrollOffset();
639 void NoteLayerPropertyChangedForDescendantsInternal();
641 virtual const char* LayerTypeAsString() const;
643 // Properties internal to LayerImpl
645 OwnedLayerImplList children_
;
647 LayerImpl
* scroll_parent_
;
649 // Storing a pointer to a set rather than a set since this will be rarely
650 // used. If this pointer turns out to be too heavy, we could have this (and
651 // the scroll parent above) be stored in a LayerImpl -> scroll_info
653 scoped_ptr
<std::set
<LayerImpl
*>> scroll_children_
;
655 LayerImpl
* clip_parent_
;
656 scoped_ptr
<std::set
<LayerImpl
*>> clip_children_
;
658 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
659 // confirm newly assigned layer is still the previous one
661 scoped_ptr
<LayerImpl
> mask_layer_
;
662 int replica_layer_id_
; // ditto
663 scoped_ptr
<LayerImpl
> replica_layer_
;
665 LayerTreeImpl
* layer_tree_impl_
;
667 // Properties dynamically changeable on active tree.
668 scoped_refptr
<SyncedScrollOffset
> scroll_offset_
;
669 gfx::Vector2dF bounds_delta_
;
671 // Properties synchronized from the associated Layer.
672 gfx::Point3F transform_origin_
;
674 ScrollOffsetDelegate
* scroll_offset_delegate_
;
675 LayerImpl
* scroll_clip_layer_
;
676 bool scrollable_
: 1;
677 bool should_scroll_on_main_thread_
: 1;
678 bool have_wheel_event_handlers_
: 1;
679 bool have_scroll_event_handlers_
: 1;
681 static_assert(SCROLL_BLOCKS_ON_MAX
< (1 << 3), "ScrollBlocksOn too big");
682 ScrollBlocksOn scroll_blocks_on_
: 3;
684 bool user_scrollable_horizontal_
: 1;
685 bool user_scrollable_vertical_
: 1;
686 bool stacking_order_changed_
: 1;
687 // Whether the "back" of this layer should draw.
688 bool double_sided_
: 1;
689 bool should_flatten_transform_
: 1;
691 // Tracks if drawing-related properties have changed since last redraw.
692 bool layer_property_changed_
: 1;
694 bool masks_to_bounds_
: 1;
695 bool contents_opaque_
: 1;
696 bool is_root_for_isolated_group_
: 1;
697 bool use_parent_backface_visibility_
: 1;
698 bool draw_checkerboard_for_missing_tiles_
: 1;
699 bool draws_content_
: 1;
700 bool hide_layer_and_subtree_
: 1;
702 // Cache transform_'s invertibility.
703 bool transform_is_invertible_
: 1;
705 // Set for the layer that other layers are fixed to.
706 bool is_container_for_fixed_position_layers_
: 1;
707 Region non_fast_scrollable_region_
;
708 Region touch_event_handler_region_
;
709 SkColor background_color_
;
712 SkXfermode::Mode blend_mode_
;
713 gfx::PointF position_
;
714 gfx::Transform transform_
;
716 LayerPositionConstraint position_constraint_
;
718 gfx::Vector2dF scroll_compensation_adjustment_
;
720 int num_descendants_that_draw_content_
;
722 // The global depth value of the center of the layer. This value is used
723 // to sort layers from back to front.
726 FilterOperations filters_
;
727 FilterOperations background_filters_
;
730 friend class TreeSynchronizer
;
732 // This flag is set when the layer needs to push properties to the active
734 bool needs_push_properties_
;
736 // The number of direct children or dependent layers that need to be recursed
737 // to in order for them or a descendent of them to push properties to the
739 int num_dependents_need_push_properties_
;
741 // Layers that share a sorting context id will be sorted together in 3d
742 // space. 0 is a special value that means this layer will not be sorted and
743 // will be drawn in paint order.
744 int sorting_context_id_
;
746 DrawMode current_draw_mode_
;
749 // Rect indicating what was repainted/updated during update.
750 // Note that plugin layers bypass this and leave it empty.
751 // Uses layer (not content) space.
752 gfx::Rect update_rect_
;
754 // This rect is in layer space.
755 gfx::RectF damage_rect_
;
757 // Manages animations for this layer.
758 scoped_refptr
<LayerAnimationController
> layer_animation_controller_
;
760 // Manages scrollbars for this layer
761 scoped_ptr
<ScrollbarAnimationController
> scrollbar_animation_controller_
;
763 scoped_ptr
<ScrollbarSet
> scrollbars_
;
765 ScopedPtrVector
<CopyOutputRequest
> copy_requests_
;
767 // Group of properties that need to be computed based on the layer tree
768 // hierarchy before layers can be drawn.
769 DrawProperties
<LayerImpl
> draw_properties_
;
771 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> debug_info_
;
772 scoped_ptr
<RenderSurfaceImpl
> render_surface_
;
774 std::vector
<FrameTimingRequest
> frame_timing_requests_
;
775 bool frame_timing_requests_dirty_
;
777 DISALLOW_COPY_AND_ASSIGN(LayerImpl
);
782 #endif // CC_LAYERS_LAYER_IMPL_H_