• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CC_LAYERS_LAYER_H_
6 #define CC_LAYERS_LAYER_H_
7 
8 #include <set>
9 #include <string>
10 
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/observer_list.h"
14 #include "cc/animation/layer_animation_controller.h"
15 #include "cc/animation/layer_animation_value_observer.h"
16 #include "cc/animation/layer_animation_value_provider.h"
17 #include "cc/base/cc_export.h"
18 #include "cc/base/region.h"
19 #include "cc/base/scoped_ptr_vector.h"
20 #include "cc/debug/micro_benchmark.h"
21 #include "cc/layers/compositing_reasons.h"
22 #include "cc/layers/draw_properties.h"
23 #include "cc/layers/layer_lists.h"
24 #include "cc/layers/layer_position_constraint.h"
25 #include "cc/layers/paint_properties.h"
26 #include "cc/layers/render_surface.h"
27 #include "cc/output/filter_operations.h"
28 #include "cc/trees/occlusion_tracker.h"
29 #include "skia/ext/refptr.h"
30 #include "third_party/skia/include/core/SkColor.h"
31 #include "third_party/skia/include/core/SkImageFilter.h"
32 #include "third_party/skia/include/core/SkPicture.h"
33 #include "third_party/skia/include/core/SkXfermode.h"
34 #include "ui/gfx/rect.h"
35 #include "ui/gfx/rect_f.h"
36 #include "ui/gfx/transform.h"
37 
38 namespace gfx {
39 class BoxF;
40 }
41 
42 namespace base {
43 namespace debug {
44 class ConvertableToTraceFormat;
45 }
46 }
47 
48 namespace cc {
49 
50 class Animation;
51 class AnimationDelegate;
52 struct AnimationEvent;
53 class CopyOutputRequest;
54 class LayerAnimationDelegate;
55 class LayerAnimationEventObserver;
56 class LayerClient;
57 class LayerImpl;
58 class LayerTreeHost;
59 class LayerTreeImpl;
60 class PriorityCalculator;
61 class RenderingStatsInstrumentation;
62 class ResourceUpdateQueue;
63 class ScrollbarLayerInterface;
64 struct AnimationEvent;
65 
66 // Base class for composited layers. Special layer types are derived from
67 // this class.
68 class CC_EXPORT Layer : public base::RefCounted<Layer>,
69                         public LayerAnimationValueObserver,
70                         public LayerAnimationValueProvider {
71  public:
72   typedef RenderSurfaceLayerList RenderSurfaceListType;
73   typedef LayerList LayerListType;
74   typedef RenderSurface RenderSurfaceType;
75 
76   enum LayerIdLabels {
77     INVALID_ID = -1,
78   };
79 
80   static scoped_refptr<Layer> Create();
81 
id()82   int id() const { return layer_id_; }
83 
84   Layer* RootLayer();
parent()85   Layer* parent() { return parent_; }
parent()86   const Layer* parent() const { return parent_; }
87   void AddChild(scoped_refptr<Layer> child);
88   void InsertChild(scoped_refptr<Layer> child, size_t index);
89   void ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer);
90   void RemoveFromParent();
91   void RemoveAllChildren();
92   void SetChildren(const LayerList& children);
93   bool HasAncestor(const Layer* ancestor) const;
94 
children()95   const LayerList& children() const { return children_; }
child_at(size_t index)96   Layer* child_at(size_t index) { return children_[index].get(); }
97 
98   // This requests the layer and its subtree be rendered and given to the
99   // callback. If the copy is unable to be produced (the layer is destroyed
100   // first), then the callback is called with a NULL/empty result.
101   void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> request);
HasCopyRequest()102   bool HasCopyRequest() const {
103     return !copy_requests_.empty();
104   }
105 
106   void SetAnchorPoint(gfx::PointF anchor_point);
anchor_point()107   gfx::PointF anchor_point() const { return anchor_point_; }
108 
109   void SetAnchorPointZ(float anchor_point_z);
anchor_point_z()110   float anchor_point_z() const { return anchor_point_z_; }
111 
112   virtual void SetBackgroundColor(SkColor background_color);
background_color()113   SkColor background_color() const { return background_color_; }
114   // If contents_opaque(), return an opaque color else return a
115   // non-opaque color.  Tries to return background_color(), if possible.
116   SkColor SafeOpaqueBackgroundColor() const;
117 
118   // A layer's bounds are in logical, non-page-scaled pixels (however, the
119   // root layer's bounds are in physical pixels).
120   void SetBounds(gfx::Size bounds);
bounds()121   gfx::Size bounds() const { return bounds_; }
122 
123   void SetMasksToBounds(bool masks_to_bounds);
masks_to_bounds()124   bool masks_to_bounds() const { return masks_to_bounds_; }
125 
126   void SetMaskLayer(Layer* mask_layer);
mask_layer()127   Layer* mask_layer() { return mask_layer_.get(); }
mask_layer()128   const Layer* mask_layer() const { return mask_layer_.get(); }
129 
130   virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect);
SetNeedsDisplay()131   void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::RectF(bounds())); }
132 
133   void SetOpacity(float opacity);
opacity()134   float opacity() const { return opacity_; }
135   bool OpacityIsAnimating() const;
136   virtual bool OpacityCanAnimateOnImplThread() const;
137 
138   void SetBlendMode(SkXfermode::Mode blend_mode);
blend_mode()139   SkXfermode::Mode blend_mode() const { return blend_mode_; }
140 
uses_default_blend_mode()141   bool uses_default_blend_mode() const {
142     return blend_mode_ == SkXfermode::kSrcOver_Mode;
143   }
144 
145   // A layer is root for an isolated group when it and all its descendants are
146   // drawn over a black and fully transparent background, creating an isolated
147   // group. It should be used along with SetBlendMode(), in order to restrict
148   // layers within the group to blend with layers outside this group.
149   void SetIsRootForIsolatedGroup(bool root);
is_root_for_isolated_group()150   bool is_root_for_isolated_group() const {
151     return is_root_for_isolated_group_;
152   }
153 
154   void SetFilters(const FilterOperations& filters);
filters()155   const FilterOperations& filters() const { return filters_; }
156   bool FilterIsAnimating() const;
157 
158   // Background filters are filters applied to what is behind this layer, when
159   // they are viewed through non-opaque regions in this layer. They are used
160   // through the WebLayer interface, and are not exposed to HTML.
161   void SetBackgroundFilters(const FilterOperations& filters);
background_filters()162   const FilterOperations& background_filters() const {
163     return background_filters_;
164   }
165 
166   virtual void SetContentsOpaque(bool opaque);
contents_opaque()167   bool contents_opaque() const { return contents_opaque_; }
168 
169   void SetPosition(gfx::PointF position);
position()170   gfx::PointF position() const { return position_; }
171 
172   void SetIsContainerForFixedPositionLayers(bool container);
173   bool IsContainerForFixedPositionLayers() const;
174 
175   void SetPositionConstraint(const LayerPositionConstraint& constraint);
position_constraint()176   const LayerPositionConstraint& position_constraint() const {
177     return position_constraint_;
178   }
179 
180   void SetSublayerTransform(const gfx::Transform& sublayer_transform);
sublayer_transform()181   const gfx::Transform& sublayer_transform() const {
182     return sublayer_transform_;
183   }
184 
185   void SetTransform(const gfx::Transform& transform);
transform()186   const gfx::Transform& transform() const { return transform_; }
187   bool TransformIsAnimating() const;
188 
189   void SetScrollParent(Layer* parent);
190 
scroll_parent()191   Layer* scroll_parent() { return scroll_parent_; }
scroll_parent()192   const Layer* scroll_parent() const { return scroll_parent_; }
193 
194   void AddScrollChild(Layer* child);
195   void RemoveScrollChild(Layer* child);
196 
scroll_children()197   std::set<Layer*>* scroll_children() { return scroll_children_.get(); }
scroll_children()198   const std::set<Layer*>* scroll_children() const {
199     return scroll_children_.get();
200   }
201 
202   void SetClipParent(Layer* ancestor);
203 
clip_parent()204   Layer* clip_parent() { return clip_parent_; }
clip_parent()205   const Layer* clip_parent() const {
206     return clip_parent_;
207   }
208 
209   void AddClipChild(Layer* child);
210   void RemoveClipChild(Layer* child);
211 
clip_children()212   std::set<Layer*>* clip_children() { return clip_children_.get(); }
clip_children()213   const std::set<Layer*>* clip_children() const {
214     return clip_children_.get();
215   }
216 
draw_properties()217   DrawProperties<Layer>& draw_properties() { return draw_properties_; }
draw_properties()218   const DrawProperties<Layer>& draw_properties() const {
219     return draw_properties_;
220   }
221 
222   // The following are shortcut accessors to get various information from
223   // draw_properties_
draw_transform()224   const gfx::Transform& draw_transform() const {
225     return draw_properties_.target_space_transform;
226   }
screen_space_transform()227   const gfx::Transform& screen_space_transform() const {
228     return draw_properties_.screen_space_transform;
229   }
draw_opacity()230   float draw_opacity() const { return draw_properties_.opacity; }
draw_opacity_is_animating()231   bool draw_opacity_is_animating() const {
232     return draw_properties_.opacity_is_animating;
233   }
draw_transform_is_animating()234   bool draw_transform_is_animating() const {
235     return draw_properties_.target_space_transform_is_animating;
236   }
screen_space_transform_is_animating()237   bool screen_space_transform_is_animating() const {
238     return draw_properties_.screen_space_transform_is_animating;
239   }
screen_space_opacity_is_animating()240   bool screen_space_opacity_is_animating() const {
241     return draw_properties_.screen_space_opacity_is_animating;
242   }
can_use_lcd_text()243   bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; }
is_clipped()244   bool is_clipped() const { return draw_properties_.is_clipped; }
clip_rect()245   gfx::Rect clip_rect() const { return draw_properties_.clip_rect; }
drawable_content_rect()246   gfx::Rect drawable_content_rect() const {
247     return draw_properties_.drawable_content_rect;
248   }
visible_content_rect()249   gfx::Rect visible_content_rect() const {
250     return draw_properties_.visible_content_rect;
251   }
render_target()252   Layer* render_target() {
253     DCHECK(!draw_properties_.render_target ||
254            draw_properties_.render_target->render_surface());
255     return draw_properties_.render_target;
256   }
render_target()257   const Layer* render_target() const {
258     DCHECK(!draw_properties_.render_target ||
259            draw_properties_.render_target->render_surface());
260     return draw_properties_.render_target;
261   }
render_surface()262   RenderSurface* render_surface() const {
263     return draw_properties_.render_surface.get();
264   }
num_unclipped_descendants()265   int num_unclipped_descendants() const {
266     return draw_properties_.num_unclipped_descendants;
267   }
268 
269   void SetScrollOffset(gfx::Vector2d scroll_offset);
scroll_offset()270   gfx::Vector2d scroll_offset() const { return scroll_offset_; }
271   void SetScrollOffsetFromImplSide(gfx::Vector2d scroll_offset);
272 
273   void SetMaxScrollOffset(gfx::Vector2d max_scroll_offset);
max_scroll_offset()274   gfx::Vector2d max_scroll_offset() const { return max_scroll_offset_; }
275 
276   void SetScrollable(bool scrollable);
scrollable()277   bool scrollable() const { return scrollable_; }
278 
279   void SetUserScrollable(bool horizontal, bool vertical);
user_scrollable_horizontal()280   bool user_scrollable_horizontal() const {
281     return user_scrollable_horizontal_;
282   }
user_scrollable_vertical()283   bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
284 
285   void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread);
should_scroll_on_main_thread()286   bool should_scroll_on_main_thread() const {
287     return should_scroll_on_main_thread_;
288   }
289 
290   void SetHaveWheelEventHandlers(bool have_wheel_event_handlers);
have_wheel_event_handlers()291   bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; }
292 
293   void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region);
non_fast_scrollable_region()294   const Region& non_fast_scrollable_region() const {
295     return non_fast_scrollable_region_;
296   }
297 
298   void SetTouchEventHandlerRegion(const Region& touch_event_handler_region);
touch_event_handler_region()299   const Region& touch_event_handler_region() const {
300     return touch_event_handler_region_;
301   }
302 
set_did_scroll_callback(const base::Closure & callback)303   void set_did_scroll_callback(const base::Closure& callback) {
304     did_scroll_callback_ = callback;
305   }
306 
307   void SetDrawCheckerboardForMissingTiles(bool checkerboard);
DrawCheckerboardForMissingTiles()308   bool DrawCheckerboardForMissingTiles() const {
309     return draw_checkerboard_for_missing_tiles_;
310   }
311 
312   void SetForceRenderSurface(bool force_render_surface);
force_render_surface()313   bool force_render_surface() const { return force_render_surface_; }
314 
ScrollDelta()315   gfx::Vector2d ScrollDelta() const { return gfx::Vector2d(); }
TotalScrollOffset()316   gfx::Vector2dF TotalScrollOffset() const {
317     // Floating point to match the LayerImpl version.
318     return scroll_offset() + ScrollDelta();
319   }
320 
321   void SetDoubleSided(bool double_sided);
double_sided()322   bool double_sided() const { return double_sided_; }
323 
SetPreserves3d(bool preserves_3d)324   void SetPreserves3d(bool preserves_3d) { preserves_3d_ = preserves_3d; }
preserves_3d()325   bool preserves_3d() const { return preserves_3d_; }
326 
set_use_parent_backface_visibility(bool use)327   void set_use_parent_backface_visibility(bool use) {
328     use_parent_backface_visibility_ = use;
329   }
use_parent_backface_visibility()330   bool use_parent_backface_visibility() const {
331     return use_parent_backface_visibility_;
332   }
333 
334   virtual void SetLayerTreeHost(LayerTreeHost* host);
335 
HasDelegatedContent()336   bool HasDelegatedContent() const { return false; }
HasContributingDelegatedRenderPasses()337   bool HasContributingDelegatedRenderPasses() const { return false; }
338 
339   void SetIsDrawable(bool is_drawable);
340 
341   void SetHideLayerAndSubtree(bool hide);
hide_layer_and_subtree()342   bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; }
343 
344   void SetReplicaLayer(Layer* layer);
replica_layer()345   Layer* replica_layer() { return replica_layer_.get(); }
replica_layer()346   const Layer* replica_layer() const { return replica_layer_.get(); }
347 
has_mask()348   bool has_mask() const { return !!mask_layer_.get(); }
has_replica()349   bool has_replica() const { return !!replica_layer_.get(); }
replica_has_mask()350   bool replica_has_mask() const {
351     return replica_layer_.get() &&
352            (mask_layer_.get() || replica_layer_->mask_layer_.get());
353   }
354 
355   // These methods typically need to be overwritten by derived classes.
356   virtual bool DrawsContent() const;
357   virtual void SavePaintProperties();
358   // Returns true iff any resources were updated that need to be committed.
359   virtual bool Update(ResourceUpdateQueue* queue,
360                       const OcclusionTracker* occlusion);
361   virtual bool NeedMoreUpdates();
SetIsMask(bool is_mask)362   virtual void SetIsMask(bool is_mask) {}
ReduceMemoryUsage()363   virtual void ReduceMemoryUsage() {}
OnOutputSurfaceCreated()364   virtual void OnOutputSurfaceCreated() {}
365 
366   virtual std::string DebugName();
367   virtual scoped_refptr<base::debug::ConvertableToTraceFormat> TakeDebugInfo();
368 
SetLayerClient(LayerClient * client)369   void SetLayerClient(LayerClient* client) { client_ = client; }
370 
371   void SetCompositingReasons(CompositingReasons reasons);
372 
373   virtual void PushPropertiesTo(LayerImpl* layer);
374 
375   void CreateRenderSurface();
376   void ClearRenderSurface();
377 
378   // The contents scale converts from logical, non-page-scaled pixels to target
379   // pixels. The contents scale is 1 for the root layer as it is already in
380   // physical pixels. By default contents scale is forced to be 1 except for
381   // subclasses of ContentsScalingLayer.
contents_scale_x()382   float contents_scale_x() const { return draw_properties_.contents_scale_x; }
contents_scale_y()383   float contents_scale_y() const { return draw_properties_.contents_scale_y; }
content_bounds()384   gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
385 
386   virtual void CalculateContentsScale(float ideal_contents_scale,
387                                       float device_scale_factor,
388                                       float page_scale_factor,
389                                       bool animating_transform_to_screen,
390                                       float* contents_scale_x,
391                                       float* contents_scale_y,
392                                       gfx::Size* content_bounds);
393 
layer_tree_host()394   LayerTreeHost* layer_tree_host() { return layer_tree_host_; }
layer_tree_host()395   const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
396 
397   // Set the priority of all desired textures in this layer.
SetTexturePriorities(const PriorityCalculator & priority_calc)398   virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) {}
399 
400   bool AddAnimation(scoped_ptr<Animation> animation);
401   void PauseAnimation(int animation_id, double time_offset);
402   void RemoveAnimation(int animation_id);
403 
AnimatedBoundsForBox(const gfx::BoxF & box,gfx::BoxF * bounds)404   bool AnimatedBoundsForBox(const gfx::BoxF& box, gfx::BoxF* bounds) {
405     return layer_animation_controller_->AnimatedBoundsForBox(box, bounds);
406   }
407 
layer_animation_controller()408   LayerAnimationController* layer_animation_controller() {
409     return layer_animation_controller_.get();
410   }
411   void SetLayerAnimationControllerForTest(
412       scoped_refptr<LayerAnimationController> controller);
413 
set_layer_animation_delegate(AnimationDelegate * delegate)414   void set_layer_animation_delegate(AnimationDelegate* delegate) {
415     layer_animation_controller_->set_layer_animation_delegate(delegate);
416   }
417 
418   bool HasActiveAnimation() const;
419 
420   void AddLayerAnimationEventObserver(
421       LayerAnimationEventObserver* animation_observer);
422   void RemoveLayerAnimationEventObserver(
423       LayerAnimationEventObserver* animation_observer);
424 
425   virtual Region VisibleContentOpaqueRegion() const;
426 
427   virtual ScrollbarLayerInterface* ToScrollbarLayer();
428 
429   gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const;
430 
431   virtual skia::RefPtr<SkPicture> GetPicture() const;
432 
433   // Constructs a LayerImpl of the correct runtime type for this Layer type.
434   virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
435 
NeedsDisplayForTesting()436   bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); }
ResetNeedsDisplayForTesting()437   void ResetNeedsDisplayForTesting() { update_rect_ = gfx::RectF(); }
438 
439   RenderingStatsInstrumentation* rendering_stats_instrumentation() const;
440 
paint_properties()441   const PaintProperties& paint_properties() const {
442     return paint_properties_;
443   }
444 
445   // The scale at which contents should be rastered, to match the scale at
446   // which they will drawn to the screen. This scale is a component of the
447   // contents scale but does not include page/device scale factors.
448   // TODO(danakj): This goes away when TiledLayer goes away.
set_raster_scale(float scale)449   void set_raster_scale(float scale) { raster_scale_ = scale; }
raster_scale()450   float raster_scale() const { return raster_scale_; }
raster_scale_is_unknown()451   bool raster_scale_is_unknown() const { return raster_scale_ == 0.f; }
452 
453   virtual bool SupportsLCDText() const;
454 
needs_push_properties()455   bool needs_push_properties() const { return needs_push_properties_; }
descendant_needs_push_properties()456   bool descendant_needs_push_properties() const {
457     return num_dependents_need_push_properties_ > 0;
458   }
459 
460   virtual void RunMicroBenchmark(MicroBenchmark* benchmark);
461 
462  protected:
463   friend class LayerImpl;
464   friend class TreeSynchronizer;
465   virtual ~Layer();
466 
467   Layer();
468 
469   // These SetNeeds functions are in order of severity of update:
470   //
471   // Called when this layer has been modified in some way, but isn't sure
472   // that it needs a commit yet.  It needs CalcDrawProperties and UpdateLayers
473   // before it knows whether or not a commit is required.
474   void SetNeedsUpdate();
475   // Called when a property has been modified in a way that the layer
476   // knows immediately that a commit is required.  This implies SetNeedsUpdate
477   // as well as SetNeedsPushProperties to push that property.
478   void SetNeedsCommit();
479   // Called when there's been a change in layer structure.  Implies both
480   // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties.
481   void SetNeedsFullTreeSync();
482 
483   // Called when the next commit should wait until the pending tree is activated
484   // before finishing the commit and unblocking the main thread. Used to ensure
485   // unused resources on the impl thread are returned before commit completes.
486   void SetNextCommitWaitsForActivation();
487 
488   // Called when the blend mode or filters have been changed.
489   void SetNeedsFilterContextIfNeeded();
490 
491   void SetNeedsPushProperties();
492   void AddDependentNeedsPushProperties();
493   void RemoveDependentNeedsPushProperties();
parent_should_know_need_push_properties()494   bool parent_should_know_need_push_properties() const {
495     return needs_push_properties() || descendant_needs_push_properties();
496   }
497 
498   bool IsPropertyChangeAllowed() const;
499 
500   // If this layer has a scroll parent, it removes |this| from its list of
501   // scroll children.
502   void RemoveFromScrollTree();
503 
504   // If this layer has a clip parent, it removes |this| from its list of clip
505   // children.
506   void RemoveFromClipTree();
507 
reset_raster_scale_to_unknown()508   void reset_raster_scale_to_unknown() { raster_scale_ = 0.f; }
509 
510   // This flag is set when the layer needs to push properties to the impl
511   // side.
512   bool needs_push_properties_;
513 
514   // The number of direct children or dependent layers that need to be recursed
515   // to in order for them or a descendent of them to push properties to the impl
516   // side.
517   int num_dependents_need_push_properties_;
518 
519   // Tracks whether this layer may have changed stacking order with its
520   // siblings.
521   bool stacking_order_changed_;
522 
523   // The update rect is the region of the compositor resource that was
524   // actually updated by the compositor. For layers that may do updating
525   // outside the compositor's control (i.e. plugin layers), this information
526   // is not available and the update rect will remain empty.
527   // Note this rect is in layer space (not content space).
528   gfx::RectF update_rect_;
529 
530   scoped_refptr<Layer> mask_layer_;
531 
532   int layer_id_;
533 
534   // When true, the layer is about to perform an update. Any commit requests
535   // will be handled implicitly after the update completes.
536   bool ignore_set_needs_commit_;
537 
538  private:
539   friend class base::RefCounted<Layer>;
540 
541   void SetParent(Layer* layer);
542   bool DescendantIsFixedToContainerLayer() const;
543 
544   // Returns the index of the child or -1 if not found.
545   int IndexOfChild(const Layer* reference);
546 
547   // This should only be called from RemoveFromParent().
548   void RemoveChildOrDependent(Layer* child);
549 
550   // LayerAnimationValueProvider implementation.
551   virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE;
552 
553   // LayerAnimationValueObserver implementation.
554   virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE;
555   virtual void OnOpacityAnimated(float opacity) OVERRIDE;
556   virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE;
557   virtual void OnScrollOffsetAnimated(gfx::Vector2dF scroll_offset) OVERRIDE;
558   virtual void OnAnimationWaitingForDeletion() OVERRIDE;
559   virtual bool IsActive() const OVERRIDE;
560 
561   LayerList children_;
562   Layer* parent_;
563 
564   // Layer instances have a weak pointer to their LayerTreeHost.
565   // This pointer value is nil when a Layer is not in a tree and is
566   // updated via SetLayerTreeHost() if a layer moves between trees.
567   LayerTreeHost* layer_tree_host_;
568 
569   scoped_refptr<LayerAnimationController> layer_animation_controller_;
570 
571   // Layer properties.
572   gfx::Size bounds_;
573 
574   gfx::Vector2d scroll_offset_;
575   gfx::Vector2d max_scroll_offset_;
576   bool scrollable_ : 1;
577   bool should_scroll_on_main_thread_ : 1;
578   bool have_wheel_event_handlers_ : 1;
579   bool user_scrollable_horizontal_ : 1;
580   bool user_scrollable_vertical_ : 1;
581   bool is_root_for_isolated_group_ : 1;
582   bool is_container_for_fixed_position_layers_ : 1;
583   bool is_drawable_ : 1;
584   bool hide_layer_and_subtree_ : 1;
585   bool masks_to_bounds_ : 1;
586   bool contents_opaque_ : 1;
587   bool double_sided_ : 1;
588   bool preserves_3d_ : 1;
589   bool use_parent_backface_visibility_ : 1;
590   bool draw_checkerboard_for_missing_tiles_ : 1;
591   bool force_render_surface_ : 1;
592   Region non_fast_scrollable_region_;
593   Region touch_event_handler_region_;
594   gfx::PointF position_;
595   gfx::PointF anchor_point_;
596   SkColor background_color_;
597   CompositingReasons compositing_reasons_;
598   float opacity_;
599   SkXfermode::Mode blend_mode_;
600   FilterOperations filters_;
601   FilterOperations background_filters_;
602   float anchor_point_z_;
603   LayerPositionConstraint position_constraint_;
604   Layer* scroll_parent_;
605   scoped_ptr<std::set<Layer*> > scroll_children_;
606 
607   Layer* clip_parent_;
608   scoped_ptr<std::set<Layer*> > clip_children_;
609 
610   gfx::Transform transform_;
611   gfx::Transform sublayer_transform_;
612 
613   // Replica layer used for reflections.
614   scoped_refptr<Layer> replica_layer_;
615 
616   // Transient properties.
617   float raster_scale_;
618 
619   LayerClient* client_;
620 
621   ScopedPtrVector<CopyOutputRequest> copy_requests_;
622 
623   base::Closure did_scroll_callback_;
624 
625   DrawProperties<Layer> draw_properties_;
626 
627   PaintProperties paint_properties_;
628 
629   DISALLOW_COPY_AND_ASSIGN(Layer);
630 };
631 
632 }  // namespace cc
633 
634 #endif  // CC_LAYERS_LAYER_H_
635