CacheStorage: Remove unused return value from put operation
[chromium-blink-merge.git] / cc / layers / layer.h
blob6f10725b08ff536bc30d8b4c5bb05a8198b85856
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_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/observer_list.h"
15 #include "cc/animation/layer_animation_controller.h"
16 #include "cc/animation/layer_animation_value_observer.h"
17 #include "cc/animation/layer_animation_value_provider.h"
18 #include "cc/base/cc_export.h"
19 #include "cc/base/region.h"
20 #include "cc/base/scoped_ptr_vector.h"
21 #include "cc/debug/frame_timing_request.h"
22 #include "cc/debug/micro_benchmark.h"
23 #include "cc/layers/draw_properties.h"
24 #include "cc/layers/layer_lists.h"
25 #include "cc/layers/layer_position_constraint.h"
26 #include "cc/layers/paint_properties.h"
27 #include "cc/layers/render_surface.h"
28 #include "cc/layers/scroll_blocks_on.h"
29 #include "cc/output/filter_operations.h"
30 #include "cc/trees/property_tree.h"
31 #include "skia/ext/refptr.h"
32 #include "third_party/skia/include/core/SkColor.h"
33 #include "third_party/skia/include/core/SkImageFilter.h"
34 #include "third_party/skia/include/core/SkPicture.h"
35 #include "third_party/skia/include/core/SkXfermode.h"
36 #include "ui/gfx/geometry/point3_f.h"
37 #include "ui/gfx/geometry/rect.h"
38 #include "ui/gfx/geometry/rect_f.h"
39 #include "ui/gfx/geometry/scroll_offset.h"
40 #include "ui/gfx/transform.h"
42 namespace gfx {
43 class BoxF;
46 namespace base {
47 namespace trace_event {
48 class ConvertableToTraceFormat;
52 namespace cc {
54 class Animation;
55 class AnimationDelegate;
56 struct AnimationEvent;
57 class CopyOutputRequest;
58 class LayerAnimationEventObserver;
59 class LayerClient;
60 class LayerImpl;
61 class LayerTreeHost;
62 class LayerTreeHostCommon;
63 class LayerTreeImpl;
64 class PriorityCalculator;
65 class RenderingStatsInstrumentation;
66 class ResourceUpdateQueue;
67 class ScrollbarLayerInterface;
68 class SimpleEnclosedRegion;
69 struct AnimationEvent;
70 template <typename LayerType>
71 class OcclusionTracker;
73 // Base class for composited layers. Special layer types are derived from
74 // this class.
75 class CC_EXPORT Layer : public base::RefCounted<Layer>,
76 public LayerAnimationValueObserver,
77 public LayerAnimationValueProvider {
78 public:
79 typedef RenderSurfaceLayerList RenderSurfaceListType;
80 typedef LayerList LayerListType;
81 typedef RenderSurface RenderSurfaceType;
83 enum LayerIdLabels {
84 INVALID_ID = -1,
87 static scoped_refptr<Layer> Create();
89 int id() const { return layer_id_; }
91 Layer* RootLayer();
92 Layer* parent() { return parent_; }
93 const Layer* parent() const { return parent_; }
94 void AddChild(scoped_refptr<Layer> child);
95 void InsertChild(scoped_refptr<Layer> child, size_t index);
96 void ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer);
97 void RemoveFromParent();
98 void RemoveAllChildren();
99 void SetChildren(const LayerList& children);
100 bool HasAncestor(const Layer* ancestor) const;
102 const LayerList& children() const { return children_; }
103 Layer* child_at(size_t index) { return children_[index].get(); }
105 // This requests the layer and its subtree be rendered and given to the
106 // callback. If the copy is unable to be produced (the layer is destroyed
107 // first), then the callback is called with a nullptr/empty result. If the
108 // request's source property is set, any prior uncommitted requests having the
109 // same source will be aborted.
110 void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> request);
111 bool HasCopyRequest() const {
112 return !copy_requests_.empty();
115 virtual void SetBackgroundColor(SkColor background_color);
116 SkColor background_color() const { return background_color_; }
117 // If contents_opaque(), return an opaque color else return a
118 // non-opaque color. Tries to return background_color(), if possible.
119 SkColor SafeOpaqueBackgroundColor() const;
121 // A layer's bounds are in logical, non-page-scaled pixels (however, the
122 // root layer's bounds are in physical pixels).
123 void SetBounds(const gfx::Size& bounds);
124 gfx::Size bounds() const { return bounds_; }
126 void SetMasksToBounds(bool masks_to_bounds);
127 bool masks_to_bounds() const { return masks_to_bounds_; }
129 void SetMaskLayer(Layer* mask_layer);
130 Layer* mask_layer() { return mask_layer_.get(); }
131 const Layer* mask_layer() const { return mask_layer_.get(); }
133 virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect);
134 void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::Rect(bounds())); }
136 void SetOpacity(float opacity);
137 float opacity() const { return opacity_; }
138 bool OpacityIsAnimating() const;
139 virtual bool OpacityCanAnimateOnImplThread() const;
141 void SetBlendMode(SkXfermode::Mode blend_mode);
142 SkXfermode::Mode blend_mode() const { return blend_mode_; }
144 bool uses_default_blend_mode() const {
145 return blend_mode_ == SkXfermode::kSrcOver_Mode;
148 // A layer is root for an isolated group when it and all its descendants are
149 // drawn over a black and fully transparent background, creating an isolated
150 // group. It should be used along with SetBlendMode(), in order to restrict
151 // layers within the group to blend with layers outside this group.
152 void SetIsRootForIsolatedGroup(bool root);
153 bool is_root_for_isolated_group() const {
154 return is_root_for_isolated_group_;
157 void SetFilters(const FilterOperations& filters);
158 const FilterOperations& filters() const { return filters_; }
159 bool FilterIsAnimating() const;
161 // Background filters are filters applied to what is behind this layer, when
162 // they are viewed through non-opaque regions in this layer. They are used
163 // through the WebLayer interface, and are not exposed to HTML.
164 void SetBackgroundFilters(const FilterOperations& filters);
165 const FilterOperations& background_filters() const {
166 return background_filters_;
169 virtual void SetContentsOpaque(bool opaque);
170 bool contents_opaque() const { return contents_opaque_; }
172 void SetPosition(const gfx::PointF& position);
173 gfx::PointF position() const { return position_; }
175 void SetIsContainerForFixedPositionLayers(bool container);
176 bool IsContainerForFixedPositionLayers() const;
178 gfx::Vector2dF FixedContainerSizeDelta() const {
179 return gfx::Vector2dF();
182 void SetPositionConstraint(const LayerPositionConstraint& constraint);
183 const LayerPositionConstraint& position_constraint() const {
184 return position_constraint_;
187 void SetTransform(const gfx::Transform& transform);
188 const gfx::Transform& transform() const { return transform_; }
189 bool TransformIsAnimating() const;
190 bool AnimationsPreserveAxisAlignment() const;
191 bool transform_is_invertible() const { return transform_is_invertible_; }
193 void SetTransformOrigin(const gfx::Point3F&);
194 gfx::Point3F transform_origin() const { return transform_origin_; }
196 void SetScrollParent(Layer* parent);
198 Layer* scroll_parent() { return scroll_parent_; }
199 const Layer* scroll_parent() const { return scroll_parent_; }
201 void AddScrollChild(Layer* child);
202 void RemoveScrollChild(Layer* child);
204 std::set<Layer*>* scroll_children() { return scroll_children_.get(); }
205 const std::set<Layer*>* scroll_children() const {
206 return scroll_children_.get();
209 void SetClipParent(Layer* ancestor);
211 Layer* clip_parent() { return clip_parent_; }
212 const Layer* clip_parent() const {
213 return clip_parent_;
216 void AddClipChild(Layer* child);
217 void RemoveClipChild(Layer* child);
219 std::set<Layer*>* clip_children() { return clip_children_.get(); }
220 const std::set<Layer*>* clip_children() const {
221 return clip_children_.get();
224 DrawProperties<Layer>& draw_properties() { return draw_properties_; }
225 const DrawProperties<Layer>& draw_properties() const {
226 return draw_properties_;
229 // The following are shortcut accessors to get various information from
230 // draw_properties_
231 const gfx::Transform& draw_transform() const {
232 return draw_properties_.target_space_transform;
234 const gfx::Transform& screen_space_transform() const {
235 return draw_properties_.screen_space_transform;
237 float draw_opacity() const { return draw_properties_.opacity; }
238 bool draw_opacity_is_animating() const {
239 return draw_properties_.opacity_is_animating;
241 bool draw_transform_is_animating() const {
242 return draw_properties_.target_space_transform_is_animating;
244 bool screen_space_transform_is_animating() const {
245 return draw_properties_.screen_space_transform_is_animating;
247 bool screen_space_opacity_is_animating() const {
248 return draw_properties_.screen_space_opacity_is_animating;
250 bool is_clipped() const { return draw_properties_.is_clipped; }
251 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; }
252 gfx::Rect drawable_content_rect() const {
253 return draw_properties_.drawable_content_rect;
255 gfx::Rect visible_content_rect() const {
256 return draw_properties_.visible_content_rect;
258 Layer* render_target() {
259 DCHECK(!draw_properties_.render_target ||
260 draw_properties_.render_target->render_surface());
261 return draw_properties_.render_target;
263 const Layer* render_target() const {
264 DCHECK(!draw_properties_.render_target ||
265 draw_properties_.render_target->render_surface());
266 return draw_properties_.render_target;
268 int num_unclipped_descendants() const {
269 return draw_properties_.num_unclipped_descendants;
272 RenderSurface* render_surface() const { return render_surface_.get(); }
273 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset);
274 void SetScrollCompensationAdjustment(
275 const gfx::Vector2dF& scroll_compensation_adjustment);
276 gfx::Vector2dF ScrollCompensationAdjustment() const;
278 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; }
279 void SetScrollOffsetFromImplSide(const gfx::ScrollOffset& scroll_offset);
281 void SetScrollClipLayerId(int clip_layer_id);
282 bool scrollable() const { return scroll_clip_layer_id_ != INVALID_ID; }
284 void SetUserScrollable(bool horizontal, bool vertical);
285 bool user_scrollable_horizontal() const {
286 return user_scrollable_horizontal_;
288 bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
290 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread);
291 bool should_scroll_on_main_thread() const {
292 return should_scroll_on_main_thread_;
295 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers);
296 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; }
298 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers);
299 bool have_scroll_event_handlers() const {
300 return have_scroll_event_handlers_;
303 void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region);
304 const Region& non_fast_scrollable_region() const {
305 return non_fast_scrollable_region_;
308 void SetTouchEventHandlerRegion(const Region& touch_event_handler_region);
309 const Region& touch_event_handler_region() const {
310 return touch_event_handler_region_;
313 void SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on);
314 ScrollBlocksOn scroll_blocks_on() const { return scroll_blocks_on_; }
316 void set_did_scroll_callback(const base::Closure& callback) {
317 did_scroll_callback_ = callback;
320 void SetDrawCheckerboardForMissingTiles(bool checkerboard);
321 bool draw_checkerboard_for_missing_tiles() const {
322 return draw_checkerboard_for_missing_tiles_;
325 void SetForceRenderSurface(bool force_render_surface);
326 bool force_render_surface() const { return force_render_surface_; }
328 gfx::Vector2dF ScrollDelta() const { return gfx::Vector2dF(); }
329 gfx::ScrollOffset CurrentScrollOffset() const { return scroll_offset_; }
331 void SetDoubleSided(bool double_sided);
332 bool double_sided() const { return double_sided_; }
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 set_use_parent_backface_visibility(bool use) {
340 use_parent_backface_visibility_ = use;
342 bool use_parent_backface_visibility() const {
343 return use_parent_backface_visibility_;
346 virtual void SetLayerTreeHost(LayerTreeHost* host);
348 virtual bool HasDelegatedContent() const;
349 bool HasContributingDelegatedRenderPasses() const { return false; }
351 void SetIsDrawable(bool is_drawable);
353 void SetHideLayerAndSubtree(bool hide);
354 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; }
356 void SetReplicaLayer(Layer* layer);
357 Layer* replica_layer() { return replica_layer_.get(); }
358 const Layer* replica_layer() const { return replica_layer_.get(); }
360 bool has_mask() const { return !!mask_layer_.get(); }
361 bool has_replica() const { return !!replica_layer_.get(); }
362 bool replica_has_mask() const {
363 return replica_layer_.get() &&
364 (mask_layer_.get() || replica_layer_->mask_layer_.get());
367 int NumDescendantsThatDrawContent() const;
369 // This is only virtual for tests.
370 // TODO(awoloszyn): Remove this once we no longer need it for tests
371 virtual bool DrawsContent() const;
373 // This methods typically need to be overwritten by derived classes.
374 virtual void SavePaintProperties();
375 // Returns true iff any resources were updated that need to be committed.
376 virtual bool Update(ResourceUpdateQueue* queue,
377 const OcclusionTracker<Layer>* occlusion);
378 virtual bool NeedMoreUpdates();
379 virtual void SetIsMask(bool is_mask) {}
380 virtual void ReduceMemoryUsage() {}
381 virtual void OnOutputSurfaceCreated() {}
382 virtual bool IsSuitableForGpuRasterization() const;
384 virtual scoped_refptr<base::trace_event::ConvertableToTraceFormat>
385 TakeDebugInfo();
387 void SetLayerClient(LayerClient* client) { client_ = client; }
389 virtual void PushPropertiesTo(LayerImpl* layer);
391 void CreateRenderSurface();
392 void ClearRenderSurface();
394 void ClearRenderSurfaceLayerList();
396 // The contents scale converts from logical, non-page-scaled pixels to target
397 // pixels. The contents scale is 1 for the root layer as it is already in
398 // physical pixels. By default contents scale is forced to be 1 except for
399 // subclasses of ContentsScalingLayer.
400 float contents_scale_x() const { return draw_properties_.contents_scale_x; }
401 float contents_scale_y() const { return draw_properties_.contents_scale_y; }
402 gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
404 virtual void CalculateContentsScale(float ideal_contents_scale,
405 float* contents_scale_x,
406 float* contents_scale_y,
407 gfx::Size* content_bounds);
409 LayerTreeHost* layer_tree_host() { return layer_tree_host_; }
410 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
412 // Set the priority of all desired textures in this layer.
413 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) {}
415 bool AddAnimation(scoped_ptr<Animation> animation);
416 void PauseAnimation(int animation_id, double time_offset);
417 void RemoveAnimation(int animation_id);
418 void RemoveAnimation(int animation_id, Animation::TargetProperty property);
420 LayerAnimationController* layer_animation_controller() {
421 return layer_animation_controller_.get();
423 void SetLayerAnimationControllerForTest(
424 scoped_refptr<LayerAnimationController> controller);
426 void set_layer_animation_delegate(AnimationDelegate* delegate) {
427 layer_animation_controller_->set_layer_animation_delegate(delegate);
430 bool HasActiveAnimation() const;
432 void AddLayerAnimationEventObserver(
433 LayerAnimationEventObserver* animation_observer);
434 void RemoveLayerAnimationEventObserver(
435 LayerAnimationEventObserver* animation_observer);
437 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const;
439 virtual ScrollbarLayerInterface* ToScrollbarLayer();
441 gfx::Rect LayerRectToContentRect(const gfx::Rect& layer_rect) const;
443 virtual skia::RefPtr<SkPicture> GetPicture() const;
445 // Constructs a LayerImpl of the correct runtime type for this Layer type.
446 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
448 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); }
449 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); }
451 RenderingStatsInstrumentation* rendering_stats_instrumentation() const;
453 const PaintProperties& paint_properties() const {
454 return paint_properties_;
457 // The scale at which contents should be rastered, to match the scale at
458 // which they will drawn to the screen. This scale is a component of the
459 // contents scale but does not include page/device scale factors.
460 // TODO(danakj): This goes away when TiledLayer goes away.
461 void set_raster_scale(float scale) { raster_scale_ = scale; }
462 float raster_scale() const { return raster_scale_; }
463 bool raster_scale_is_unknown() const { return raster_scale_ == 0.f; }
465 void SetNeedsPushProperties();
466 bool needs_push_properties() const { return needs_push_properties_; }
467 bool descendant_needs_push_properties() const {
468 return num_dependents_need_push_properties_ > 0;
470 void reset_needs_push_properties_for_testing() {
471 needs_push_properties_ = false;
474 virtual void RunMicroBenchmark(MicroBenchmark* benchmark);
476 void Set3dSortingContextId(int id);
477 int sorting_context_id() const { return sorting_context_id_; }
479 void set_transform_tree_index(int index) {
480 if (transform_tree_index_ == index)
481 return;
482 transform_tree_index_ = index;
483 SetNeedsPushProperties();
485 void set_clip_tree_index(int index) {
486 if (clip_tree_index_ == index)
487 return;
488 clip_tree_index_ = index;
489 SetNeedsPushProperties();
491 void set_opacity_tree_index(int index) {
492 if (opacity_tree_index_ == index)
493 return;
494 opacity_tree_index_ = index;
495 SetNeedsPushProperties();
497 int clip_tree_index() const { return clip_tree_index_; }
498 int transform_tree_index() const { return transform_tree_index_; }
499 int opacity_tree_index() const { return opacity_tree_index_; }
501 void set_offset_to_transform_parent(gfx::Vector2dF offset) {
502 if (offset_to_transform_parent_ == offset)
503 return;
504 offset_to_transform_parent_ = offset;
505 SetNeedsPushProperties();
507 gfx::Vector2dF offset_to_transform_parent() const {
508 return offset_to_transform_parent_;
511 // TODO(vollick): Once we transition to transform and clip trees, rename these
512 // functions and related values. The "from property trees" functions below
513 // use the transform and clip trees. Eventually, we will use these functions
514 // to compute the official values, but these functions are retained for
515 // testing purposes until we've migrated.
517 const gfx::Rect& visible_rect_from_property_trees() const {
518 return visible_rect_from_property_trees_;
520 void set_visible_rect_from_property_trees(const gfx::Rect& rect) {
521 // No push properties here, as this acts like a draw property.
522 visible_rect_from_property_trees_ = rect;
525 void set_should_flatten_transform_from_property_tree(bool should_flatten) {
526 if (should_flatten_transform_from_property_tree_ == should_flatten)
527 return;
528 should_flatten_transform_from_property_tree_ = should_flatten;
529 SetNeedsPushProperties();
531 bool should_flatten_transform_from_property_tree() const {
532 return should_flatten_transform_from_property_tree_;
535 // TODO(vollick): These values are temporary and will be removed as soon as
536 // render surface determinations are moved out of CDP. They only exist because
537 // certain logic depends on whether or not a layer would render to a separate
538 // surface, but CDP destroys surfaces and targets it doesn't need, so without
539 // this boolean, this is impossible to determine after the fact without
540 // wastefully recomputing it. This is public for the time being so that it can
541 // be accessed from CDP.
542 bool has_render_surface() const {
543 return has_render_surface_;
546 // Sets new frame timing requests for this layer.
547 void SetFrameTimingRequests(const std::vector<FrameTimingRequest>& requests);
549 // Accessor for unit tests
550 const std::vector<FrameTimingRequest>& FrameTimingRequests() const {
551 return frame_timing_requests_;
554 void DidBeginTracing();
556 protected:
557 friend class LayerImpl;
558 friend class TreeSynchronizer;
559 ~Layer() override;
561 Layer();
563 // These SetNeeds functions are in order of severity of update:
565 // Called when this layer has been modified in some way, but isn't sure
566 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers
567 // before it knows whether or not a commit is required.
568 void SetNeedsUpdate();
569 // Called when a property has been modified in a way that the layer
570 // knows immediately that a commit is required. This implies SetNeedsUpdate
571 // as well as SetNeedsPushProperties to push that property.
572 void SetNeedsCommit();
573 // This is identical to SetNeedsCommit, but the former requests a rebuild of
574 // the property trees.
575 void SetNeedsCommitNoRebuild();
576 // Called when there's been a change in layer structure. Implies both
577 // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties.
578 void SetNeedsFullTreeSync();
580 // Called when the next commit should wait until the pending tree is activated
581 // before finishing the commit and unblocking the main thread. Used to ensure
582 // unused resources on the impl thread are returned before commit completes.
583 void SetNextCommitWaitsForActivation();
585 // Will recalculate whether the layer draws content and set draws_content_
586 // appropriately.
587 void UpdateDrawsContent(bool has_drawable_content);
588 virtual bool HasDrawableContent() const;
590 // Called when the layer's number of drawable descendants changes.
591 void AddDrawableDescendants(int num);
593 void AddDependentNeedsPushProperties();
594 void RemoveDependentNeedsPushProperties();
595 bool parent_should_know_need_push_properties() const {
596 return needs_push_properties() || descendant_needs_push_properties();
599 bool IsPropertyChangeAllowed() const;
601 void reset_raster_scale_to_unknown() { raster_scale_ = 0.f; }
603 // This flag is set when the layer needs to push properties to the impl
604 // side.
605 bool needs_push_properties_;
607 // The number of direct children or dependent layers that need to be recursed
608 // to in order for them or a descendent of them to push properties to the impl
609 // side.
610 int num_dependents_need_push_properties_;
612 // Tracks whether this layer may have changed stacking order with its
613 // siblings.
614 bool stacking_order_changed_;
616 // The update rect is the region of the compositor resource that was
617 // actually updated by the compositor. For layers that may do updating
618 // outside the compositor's control (i.e. plugin layers), this information
619 // is not available and the update rect will remain empty.
620 // Note this rect is in layer space (not content space).
621 gfx::Rect update_rect_;
623 scoped_refptr<Layer> mask_layer_;
625 int layer_id_;
627 // When true, the layer is about to perform an update. Any commit requests
628 // will be handled implicitly after the update completes.
629 bool ignore_set_needs_commit_;
631 // Layers that share a sorting context id will be sorted together in 3d
632 // space. 0 is a special value that means this layer will not be sorted and
633 // will be drawn in paint order.
634 int sorting_context_id_;
636 private:
637 friend class base::RefCounted<Layer>;
638 friend class LayerTreeHostCommon;
639 void SetParent(Layer* layer);
640 bool DescendantIsFixedToContainerLayer() const;
642 // This should only be called during BeginMainFrame since it does not
643 // trigger a Commit.
644 void SetHasRenderSurface(bool has_render_surface);
646 // Returns the index of the child or -1 if not found.
647 int IndexOfChild(const Layer* reference);
649 // This should only be called from RemoveFromParent().
650 void RemoveChildOrDependent(Layer* child);
652 // LayerAnimationValueProvider implementation.
653 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
655 // LayerAnimationValueObserver implementation.
656 void OnFilterAnimated(const FilterOperations& filters) override;
657 void OnOpacityAnimated(float opacity) override;
658 void OnTransformAnimated(const gfx::Transform& transform) override;
659 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override;
660 void OnAnimationWaitingForDeletion() override;
661 bool IsActive() const override;
663 // If this layer has a scroll parent, it removes |this| from its list of
664 // scroll children.
665 void RemoveFromScrollTree();
667 // If this layer has a clip parent, it removes |this| from its list of clip
668 // children.
669 void RemoveFromClipTree();
671 LayerList children_;
672 Layer* parent_;
674 // Layer instances have a weak pointer to their LayerTreeHost.
675 // This pointer value is nil when a Layer is not in a tree and is
676 // updated via SetLayerTreeHost() if a layer moves between trees.
677 LayerTreeHost* layer_tree_host_;
679 scoped_refptr<LayerAnimationController> layer_animation_controller_;
681 // Layer properties.
682 gfx::Size bounds_;
684 gfx::ScrollOffset scroll_offset_;
685 gfx::Vector2dF scroll_compensation_adjustment_;
686 // This variable indicates which ancestor layer (if any) whose size,
687 // transformed relative to this layer, defines the maximum scroll offset for
688 // this layer.
689 int scroll_clip_layer_id_;
690 int num_descendants_that_draw_content_;
691 int transform_tree_index_;
692 int opacity_tree_index_;
693 int clip_tree_index_;
694 gfx::Vector2dF offset_to_transform_parent_;
695 bool should_flatten_transform_from_property_tree_ : 1;
696 bool should_scroll_on_main_thread_ : 1;
697 bool have_wheel_event_handlers_ : 1;
698 bool have_scroll_event_handlers_ : 1;
699 bool user_scrollable_horizontal_ : 1;
700 bool user_scrollable_vertical_ : 1;
701 bool is_root_for_isolated_group_ : 1;
702 bool is_container_for_fixed_position_layers_ : 1;
703 bool is_drawable_ : 1;
704 bool draws_content_ : 1;
705 bool hide_layer_and_subtree_ : 1;
706 bool masks_to_bounds_ : 1;
707 bool contents_opaque_ : 1;
708 bool double_sided_ : 1;
709 bool should_flatten_transform_ : 1;
710 bool use_parent_backface_visibility_ : 1;
711 bool draw_checkerboard_for_missing_tiles_ : 1;
712 bool force_render_surface_ : 1;
713 bool transform_is_invertible_ : 1;
714 bool has_render_surface_ : 1;
715 ScrollBlocksOn scroll_blocks_on_ : 3;
716 Region non_fast_scrollable_region_;
717 Region touch_event_handler_region_;
718 gfx::PointF position_;
719 SkColor background_color_;
720 float opacity_;
721 SkXfermode::Mode blend_mode_;
722 FilterOperations filters_;
723 FilterOperations background_filters_;
724 LayerPositionConstraint position_constraint_;
725 Layer* scroll_parent_;
726 scoped_ptr<std::set<Layer*>> scroll_children_;
728 Layer* clip_parent_;
729 scoped_ptr<std::set<Layer*>> clip_children_;
731 gfx::Transform transform_;
732 gfx::Point3F transform_origin_;
734 // Replica layer used for reflections.
735 scoped_refptr<Layer> replica_layer_;
737 // Transient properties.
738 float raster_scale_;
740 LayerClient* client_;
742 ScopedPtrVector<CopyOutputRequest> copy_requests_;
744 base::Closure did_scroll_callback_;
746 DrawProperties<Layer> draw_properties_;
748 PaintProperties paint_properties_;
749 // TODO(awoloszyn): This is redundant with has_render_surface_,
750 // and should get removed once it is no longer needed on main thread.
751 scoped_ptr<RenderSurface> render_surface_;
753 gfx::Rect visible_rect_from_property_trees_;
755 std::vector<FrameTimingRequest> frame_timing_requests_;
756 bool frame_timing_requests_dirty_;
758 DISALLOW_COPY_AND_ASSIGN(Layer);
761 } // namespace cc
763 #endif // CC_LAYERS_LAYER_H_