Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / cc / layers / layer_impl.h
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.
4
5 #ifndef CC_LAYERS_LAYER_IMPL_H_
6 #define CC_LAYERS_LAYER_IMPL_H_
7
8 #include <set>
9 #include <string>
10
11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h"
14 #include "cc/animation/animation_delegate.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/input/input_handler.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/render_surface_impl.h"
26 #include "cc/output/filter_operations.h"
27 #include "cc/quads/shared_quad_state.h"
28 #include "cc/resources/resource_provider.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 "ui/gfx/point3_f.h"
34 #include "ui/gfx/rect.h"
35 #include "ui/gfx/rect_f.h"
36 #include "ui/gfx/transform.h"
37
38 namespace base {
39 namespace debug {
40 class ConvertableToTraceFormat;
41 class TracedValue;
42 }
43
44 class DictionaryValue;
45 }
46
47 namespace cc {
48
49 class LayerTreeHostImpl;
50 class LayerTreeImpl;
51 class MicroBenchmarkImpl;
52 class Occlusion;
53 template <typename LayerType>
54 class OcclusionTracker;
55 class RenderPass;
56 class RenderPassId;
57 class Renderer;
58 class ScrollbarAnimationController;
59 class ScrollbarLayerImplBase;
60 class SimpleEnclosedRegion;
61 class Tile;
62
63 struct AppendQuadsData;
64
65 enum DrawMode {
66   DRAW_MODE_NONE,
67   DRAW_MODE_HARDWARE,
68   DRAW_MODE_SOFTWARE,
69   DRAW_MODE_RESOURCELESS_SOFTWARE
70 };
71
72 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
73                             public LayerAnimationValueProvider,
74                             public AnimationDelegate {
75  public:
76   // Allows for the ownership of the total scroll offset to be delegated outside
77   // of the layer.
78   class ScrollOffsetDelegate {
79    public:
80     virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_value) = 0;
81     virtual gfx::Vector2dF GetTotalScrollOffset() = 0;
82     virtual bool IsExternalFlingActive() const = 0;
83   };
84
85   typedef LayerImplList RenderSurfaceListType;
86   typedef LayerImplList LayerListType;
87   typedef RenderSurfaceImpl RenderSurfaceType;
88
89   enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 };
90
91   static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
92     return make_scoped_ptr(new LayerImpl(tree_impl, id));
93   }
94
95   virtual ~LayerImpl();
96
97   int id() const { return layer_id_; }
98
99   // LayerAnimationValueProvider implementation.
100   virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE;
101
102   // LayerAnimationValueObserver implementation.
103   virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE;
104   virtual void OnOpacityAnimated(float opacity) OVERRIDE;
105   virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE;
106   virtual void OnScrollOffsetAnimated(
107       const gfx::Vector2dF& scroll_offset) OVERRIDE;
108   virtual void OnAnimationWaitingForDeletion() OVERRIDE;
109   virtual bool IsActive() const OVERRIDE;
110
111   // AnimationDelegate implementation.
112   virtual void NotifyAnimationStarted(
113       base::TimeTicks monotonic_time,
114       Animation::TargetProperty target_property) OVERRIDE{};
115   virtual void NotifyAnimationFinished(
116       base::TimeTicks monotonic_time,
117       Animation::TargetProperty target_property) OVERRIDE;
118
119   // Tree structure.
120   LayerImpl* parent() { return parent_; }
121   const LayerImpl* parent() const { return parent_; }
122   const OwnedLayerImplList& children() const { return children_; }
123   OwnedLayerImplList& children() { return children_; }
124   LayerImpl* child_at(size_t index) const { return children_[index]; }
125   void AddChild(scoped_ptr<LayerImpl> child);
126   scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child);
127   void SetParent(LayerImpl* parent);
128
129   // Warning: This does not preserve tree structure invariants.
130   void ClearChildList();
131
132   bool HasAncestor(const LayerImpl* ancestor) const;
133
134   void SetScrollParent(LayerImpl* parent);
135
136   LayerImpl* scroll_parent() { return scroll_parent_; }
137   const LayerImpl* scroll_parent() const { return scroll_parent_; }
138
139   void SetScrollChildren(std::set<LayerImpl*>* children);
140
141   std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); }
142   const std::set<LayerImpl*>* scroll_children() const {
143     return scroll_children_.get();
144   }
145
146   void SetNumDescendantsThatDrawContent(int num_descendants);
147   void SetClipParent(LayerImpl* ancestor);
148
149   LayerImpl* clip_parent() {
150     return clip_parent_;
151   }
152   const LayerImpl* clip_parent() const {
153     return clip_parent_;
154   }
155
156   void SetClipChildren(std::set<LayerImpl*>* children);
157
158   std::set<LayerImpl*>* clip_children() { return clip_children_.get(); }
159   const std::set<LayerImpl*>* clip_children() const {
160     return clip_children_.get();
161   }
162
163   void PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests);
164   // Can only be called when the layer has a copy request.
165   void TakeCopyRequestsAndTransformToTarget(
166       ScopedPtrVector<CopyOutputRequest>* request);
167   bool HasCopyRequest() const { return !copy_requests_.empty(); }
168
169   void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer);
170   LayerImpl* mask_layer() { return mask_layer_.get(); }
171   const LayerImpl* mask_layer() const { return mask_layer_.get(); }
172   scoped_ptr<LayerImpl> TakeMaskLayer();
173
174   void SetReplicaLayer(scoped_ptr<LayerImpl> replica_layer);
175   LayerImpl* replica_layer() { return replica_layer_.get(); }
176   const LayerImpl* replica_layer() const { return replica_layer_.get(); }
177   scoped_ptr<LayerImpl> TakeReplicaLayer();
178
179   bool has_mask() const { return mask_layer_; }
180   bool has_replica() const { return replica_layer_; }
181   bool replica_has_mask() const {
182     return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_);
183   }
184
185   LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; }
186
187   void PopulateSharedQuadState(SharedQuadState* state) const;
188   // WillDraw must be called before AppendQuads. If WillDraw returns false,
189   // AppendQuads and DidDraw will not be called. If WillDraw returns true,
190   // DidDraw is guaranteed to be called before another WillDraw or before
191   // the layer is destroyed. To enforce this, any class that overrides
192   // WillDraw/DidDraw must call the base class version only if WillDraw
193   // returns true.
194   virtual bool WillDraw(DrawMode draw_mode,
195                         ResourceProvider* resource_provider);
196   virtual void AppendQuads(RenderPass* render_pass,
197                            const OcclusionTracker<LayerImpl>& occlusion_tracker,
198                            AppendQuadsData* append_quads_data) {}
199   virtual void DidDraw(ResourceProvider* resource_provider);
200
201   virtual ResourceProvider::ResourceId ContentsResourceId() const;
202
203   virtual bool HasDelegatedContent() const;
204   virtual bool HasContributingDelegatedRenderPasses() const;
205   virtual RenderPassId FirstContributingRenderPassId() const;
206   virtual RenderPassId NextContributingRenderPassId(RenderPassId id) const;
207
208   virtual void UpdateTiles(const Occlusion& occlusion_in_layer_space) {}
209   virtual void NotifyTileStateChanged(const Tile* tile) {}
210
211   virtual ScrollbarLayerImplBase* ToScrollbarLayer();
212
213   // Returns true if this layer has content to draw.
214   void SetDrawsContent(bool draws_content);
215   bool DrawsContent() const { return draws_content_; }
216
217   int NumDescendantsThatDrawContent() const;
218   void SetHideLayerAndSubtree(bool hide);
219   bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; }
220
221   bool force_render_surface() const { return force_render_surface_; }
222   void SetForceRenderSurface(bool force) { force_render_surface_ = force; }
223
224   void SetTransformOrigin(const gfx::Point3F& transform_origin);
225   gfx::Point3F transform_origin() const { return transform_origin_; }
226
227   void SetBackgroundColor(SkColor background_color);
228   SkColor background_color() const { return background_color_; }
229   // If contents_opaque(), return an opaque color else return a
230   // non-opaque color.  Tries to return background_color(), if possible.
231   SkColor SafeOpaqueBackgroundColor() const;
232
233   void SetFilters(const FilterOperations& filters);
234   const FilterOperations& filters() const { return filters_; }
235   bool FilterIsAnimating() const;
236   bool FilterIsAnimatingOnImplOnly() const;
237
238   void SetBackgroundFilters(const FilterOperations& filters);
239   const FilterOperations& background_filters() const {
240     return background_filters_;
241   }
242
243   void SetMasksToBounds(bool masks_to_bounds);
244   bool masks_to_bounds() const { return masks_to_bounds_; }
245
246   void SetContentsOpaque(bool opaque);
247   bool contents_opaque() const { return contents_opaque_; }
248
249   void SetOpacity(float opacity);
250   float opacity() const { return opacity_; }
251   bool OpacityIsAnimating() const;
252   bool OpacityIsAnimatingOnImplOnly() const;
253
254   void SetBlendMode(SkXfermode::Mode);
255   SkXfermode::Mode blend_mode() const { return blend_mode_; }
256   bool uses_default_blend_mode() const {
257     return blend_mode_ == SkXfermode::kSrcOver_Mode;
258   }
259
260   void SetIsRootForIsolatedGroup(bool root);
261   bool is_root_for_isolated_group() const {
262     return is_root_for_isolated_group_;
263   }
264
265   void SetPosition(const gfx::PointF& position);
266   gfx::PointF position() const { return position_; }
267
268   void SetIsContainerForFixedPositionLayers(bool container) {
269     is_container_for_fixed_position_layers_ = container;
270   }
271   // This is a non-trivial function in Layer.
272   bool IsContainerForFixedPositionLayers() const {
273     return is_container_for_fixed_position_layers_;
274   }
275
276   gfx::Vector2dF FixedContainerSizeDelta() const;
277
278   void SetPositionConstraint(const LayerPositionConstraint& constraint) {
279     position_constraint_ = constraint;
280   }
281   const LayerPositionConstraint& position_constraint() const {
282     return position_constraint_;
283   }
284
285   void SetShouldFlattenTransform(bool flatten);
286   bool should_flatten_transform() const { return should_flatten_transform_; }
287
288   bool Is3dSorted() const { return sorting_context_id_ != 0; }
289
290   void SetUseParentBackfaceVisibility(bool use) {
291     use_parent_backface_visibility_ = use;
292   }
293   bool use_parent_backface_visibility() const {
294     return use_parent_backface_visibility_;
295   }
296
297   bool ShowDebugBorders() const;
298
299   // These invalidate the host's render surface layer list.  The caller
300   // is responsible for calling set_needs_update_draw_properties on the tree
301   // so that its list can be recreated.
302   void CreateRenderSurface();
303   void ClearRenderSurface();
304   void ClearRenderSurfaceLayerList();
305
306   DrawProperties<LayerImpl>& draw_properties() {
307     return draw_properties_;
308   }
309   const DrawProperties<LayerImpl>& draw_properties() const {
310     return draw_properties_;
311   }
312
313   // The following are shortcut accessors to get various information from
314   // draw_properties_
315   const gfx::Transform& draw_transform() const {
316     return draw_properties_.target_space_transform;
317   }
318   const gfx::Transform& screen_space_transform() const {
319     return draw_properties_.screen_space_transform;
320   }
321   float draw_opacity() const { return draw_properties_.opacity; }
322   bool draw_opacity_is_animating() const {
323     return draw_properties_.opacity_is_animating;
324   }
325   bool draw_transform_is_animating() const {
326     return draw_properties_.target_space_transform_is_animating;
327   }
328   bool screen_space_transform_is_animating() const {
329     return draw_properties_.screen_space_transform_is_animating;
330   }
331   bool screen_space_opacity_is_animating() const {
332     return draw_properties_.screen_space_opacity_is_animating;
333   }
334   bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; }
335   bool is_clipped() const { return draw_properties_.is_clipped; }
336   gfx::Rect clip_rect() const { return draw_properties_.clip_rect; }
337   gfx::Rect drawable_content_rect() const {
338     return draw_properties_.drawable_content_rect;
339   }
340   gfx::Rect visible_content_rect() const {
341     return draw_properties_.visible_content_rect;
342   }
343   LayerImpl* render_target() {
344     DCHECK(!draw_properties_.render_target ||
345            draw_properties_.render_target->render_surface());
346     return draw_properties_.render_target;
347   }
348   const LayerImpl* render_target() const {
349     DCHECK(!draw_properties_.render_target ||
350            draw_properties_.render_target->render_surface());
351     return draw_properties_.render_target;
352   }
353   RenderSurfaceImpl* render_surface() const {
354     return draw_properties_.render_surface.get();
355   }
356   int num_unclipped_descendants() const {
357     return draw_properties_.num_unclipped_descendants;
358   }
359
360   // The client should be responsible for setting bounds, content bounds and
361   // contents scale to appropriate values. LayerImpl doesn't calculate any of
362   // them from the other values.
363
364   void SetBounds(const gfx::Size& bounds);
365   gfx::Size bounds() const;
366   void SetBoundsDelta(const gfx::Vector2dF& bounds_delta);
367   gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
368
369   void SetContentBounds(const gfx::Size& content_bounds);
370   gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
371
372   float contents_scale_x() const { return draw_properties_.contents_scale_x; }
373   float contents_scale_y() const { return draw_properties_.contents_scale_y; }
374   void SetContentsScale(float contents_scale_x, float contents_scale_y);
375
376   void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate);
377   bool IsExternalFlingActive() const;
378
379   void SetScrollOffset(const gfx::Vector2d& scroll_offset);
380   void SetScrollOffsetAndDelta(const gfx::Vector2d& scroll_offset,
381                                const gfx::Vector2dF& scroll_delta);
382   gfx::Vector2d scroll_offset() const { return scroll_offset_; }
383
384   gfx::Vector2d MaxScrollOffset() const;
385   gfx::Vector2dF ClampScrollToMaxScrollOffset();
386   void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer,
387                             LayerImpl* scrollbar_clip_layer) const;
388   void SetScrollDelta(const gfx::Vector2dF& scroll_delta);
389   gfx::Vector2dF ScrollDelta() const;
390
391   gfx::Vector2dF TotalScrollOffset() const;
392
393   void SetSentScrollDelta(const gfx::Vector2d& sent_scroll_delta);
394   gfx::Vector2d sent_scroll_delta() const { return sent_scroll_delta_; }
395
396   // Returns the delta of the scroll that was outside of the bounds of the
397   // initial scroll
398   gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll);
399
400   void SetScrollClipLayer(int scroll_clip_layer_id);
401   LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; }
402   bool scrollable() const { return !!scroll_clip_layer_; }
403
404   void set_user_scrollable_horizontal(bool scrollable) {
405     user_scrollable_horizontal_ = scrollable;
406   }
407   void set_user_scrollable_vertical(bool scrollable) {
408     user_scrollable_vertical_ = scrollable;
409   }
410
411   void ApplySentScrollDeltasFromAbortedCommit();
412   void ApplyScrollDeltasSinceBeginMainFrame();
413
414   void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) {
415     should_scroll_on_main_thread_ = should_scroll_on_main_thread;
416   }
417   bool should_scroll_on_main_thread() const {
418     return should_scroll_on_main_thread_;
419   }
420
421   void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) {
422     have_wheel_event_handlers_ = have_wheel_event_handlers;
423   }
424   bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; }
425
426   void SetHaveScrollEventHandlers(bool have_scroll_event_handlers) {
427     have_scroll_event_handlers_ = have_scroll_event_handlers;
428   }
429   bool have_scroll_event_handlers() const {
430     return have_scroll_event_handlers_;
431   }
432
433   void SetNonFastScrollableRegion(const Region& region) {
434     non_fast_scrollable_region_ = region;
435   }
436   const Region& non_fast_scrollable_region() const {
437     return non_fast_scrollable_region_;
438   }
439
440   void SetTouchEventHandlerRegion(const Region& region) {
441     touch_event_handler_region_ = region;
442   }
443   const Region& touch_event_handler_region() const {
444     return touch_event_handler_region_;
445   }
446
447   void SetDrawCheckerboardForMissingTiles(bool checkerboard) {
448     draw_checkerboard_for_missing_tiles_ = checkerboard;
449   }
450   bool draw_checkerboard_for_missing_tiles() const {
451     return draw_checkerboard_for_missing_tiles_;
452   }
453
454   InputHandler::ScrollStatus TryScroll(
455       const gfx::PointF& screen_space_point,
456       InputHandler::ScrollInputType type) const;
457
458   void SetDoubleSided(bool double_sided);
459   bool double_sided() const { return double_sided_; }
460
461   void SetTransform(const gfx::Transform& transform);
462   const gfx::Transform& transform() const { return transform_; }
463   bool TransformIsAnimating() const;
464   bool TransformIsAnimatingOnImplOnly() const;
465   void SetTransformAndInvertibility(const gfx::Transform& transform,
466                                     bool transform_is_invertible);
467   bool transform_is_invertible() const { return transform_is_invertible_; }
468
469   // Note this rect is in layer space (not content space).
470   void SetUpdateRect(const gfx::RectF& update_rect);
471
472   const gfx::RectF& update_rect() const { return update_rect_; }
473
474   void AddDamageRect(const gfx::RectF& damage_rect);
475
476   const gfx::RectF& damage_rect() const { return damage_rect_; }
477
478   virtual base::DictionaryValue* LayerTreeAsJson() const;
479
480   void SetStackingOrderChanged(bool stacking_order_changed);
481
482   bool LayerPropertyChanged() const { return layer_property_changed_; }
483
484   void ResetAllChangeTrackingForSubtree();
485
486   LayerAnimationController* layer_animation_controller() {
487     return layer_animation_controller_.get();
488   }
489
490   const LayerAnimationController* layer_animation_controller() const {
491     return layer_animation_controller_.get();
492   }
493
494   virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const;
495
496   virtual void DidBecomeActive();
497
498   virtual void DidBeginTracing();
499
500   // Release resources held by this layer. Called when the output surface
501   // that rendered this layer was lost or a rendering mode switch has occured.
502   virtual void ReleaseResources();
503
504   ScrollbarAnimationController* scrollbar_animation_controller() const {
505     return scrollbar_animation_controller_.get();
506   }
507
508   typedef std::set<ScrollbarLayerImplBase*> ScrollbarSet;
509   ScrollbarSet* scrollbars() { return scrollbars_.get(); }
510   void ClearScrollbars();
511   void AddScrollbar(ScrollbarLayerImplBase* layer);
512   void RemoveScrollbar(ScrollbarLayerImplBase* layer);
513   bool HasScrollbar(ScrollbarOrientation orientation) const;
514   void ScrollbarParametersDidChange();
515   int clip_height() {
516     return scroll_clip_layer_ ? scroll_clip_layer_->bounds().height() : 0;
517   }
518
519   gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const;
520
521   virtual skia::RefPtr<SkPicture> GetPicture();
522
523   virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
524   virtual void PushPropertiesTo(LayerImpl* layer);
525
526   virtual void GetAllTilesForTracing(std::set<const Tile*>* tiles) const;
527   virtual void AsValueInto(base::debug::TracedValue* dict) const;
528
529   virtual size_t GPUMemoryUsageInBytes() const;
530
531   void SetNeedsPushProperties();
532   void AddDependentNeedsPushProperties();
533   void RemoveDependentNeedsPushProperties();
534   bool parent_should_know_need_push_properties() const {
535     return needs_push_properties() || descendant_needs_push_properties();
536   }
537
538   bool needs_push_properties() const { return needs_push_properties_; }
539   bool descendant_needs_push_properties() const {
540     return num_dependents_need_push_properties_ > 0;
541   }
542
543   virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark);
544
545   virtual void SetDebugInfo(
546       scoped_refptr<base::debug::ConvertableToTraceFormat> other);
547
548   bool IsDrawnRenderSurfaceLayerListMember() const;
549
550   void Set3dSortingContextId(int id);
551   int sorting_context_id() { return sorting_context_id_; }
552
553  protected:
554   LayerImpl(LayerTreeImpl* layer_impl, int id);
555
556   // Get the color and size of the layer's debug border.
557   virtual void GetDebugBorderProperties(SkColor* color, float* width) const;
558
559   void AppendDebugBorderQuad(RenderPass* render_pass,
560                              const gfx::Size& content_bounds,
561                              const SharedQuadState* shared_quad_state,
562                              AppendQuadsData* append_quads_data) const;
563   void AppendDebugBorderQuad(RenderPass* render_pass,
564                              const gfx::Size& content_bounds,
565                              const SharedQuadState* shared_quad_state,
566                              AppendQuadsData* append_quads_data,
567                              SkColor color,
568                              float width) const;
569
570   void NoteLayerPropertyChanged();
571   void NoteLayerPropertyChangedForSubtree();
572
573   // Note carefully this does not affect the current layer.
574   void NoteLayerPropertyChangedForDescendants();
575
576  private:
577   void NoteLayerPropertyChangedForDescendantsInternal();
578
579   virtual const char* LayerTypeAsString() const;
580
581   // Properties internal to LayerImpl
582   LayerImpl* parent_;
583   OwnedLayerImplList children_;
584
585   LayerImpl* scroll_parent_;
586
587   // Storing a pointer to a set rather than a set since this will be rarely
588   // used. If this pointer turns out to be too heavy, we could have this (and
589   // the scroll parent above) be stored in a LayerImpl -> scroll_info
590   // map somewhere.
591   scoped_ptr<std::set<LayerImpl*> > scroll_children_;
592
593   LayerImpl* clip_parent_;
594   scoped_ptr<std::set<LayerImpl*> > clip_children_;
595
596   // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
597   // confirm newly assigned layer is still the previous one
598   int mask_layer_id_;
599   scoped_ptr<LayerImpl> mask_layer_;
600   int replica_layer_id_;  // ditto
601   scoped_ptr<LayerImpl> replica_layer_;
602   int layer_id_;
603   LayerTreeImpl* layer_tree_impl_;
604
605   // Properties synchronized from the associated Layer.
606   gfx::Point3F transform_origin_;
607   gfx::Size bounds_;
608   gfx::Vector2dF bounds_delta_;
609   gfx::Vector2d scroll_offset_;
610   ScrollOffsetDelegate* scroll_offset_delegate_;
611   LayerImpl* scroll_clip_layer_;
612   bool scrollable_ : 1;
613   bool should_scroll_on_main_thread_ : 1;
614   bool have_wheel_event_handlers_ : 1;
615   bool have_scroll_event_handlers_ : 1;
616   bool user_scrollable_horizontal_ : 1;
617   bool user_scrollable_vertical_ : 1;
618   bool stacking_order_changed_ : 1;
619   // Whether the "back" of this layer should draw.
620   bool double_sided_ : 1;
621   bool should_flatten_transform_ : 1;
622
623   // Tracks if drawing-related properties have changed since last redraw.
624   bool layer_property_changed_ : 1;
625
626   bool masks_to_bounds_ : 1;
627   bool contents_opaque_ : 1;
628   bool is_root_for_isolated_group_ : 1;
629   bool use_parent_backface_visibility_ : 1;
630   bool draw_checkerboard_for_missing_tiles_ : 1;
631   bool draws_content_ : 1;
632   bool hide_layer_and_subtree_ : 1;
633   bool force_render_surface_ : 1;
634
635   // Cache transform_'s invertibility.
636   bool transform_is_invertible_ : 1;
637
638   // Set for the layer that other layers are fixed to.
639   bool is_container_for_fixed_position_layers_ : 1;
640   Region non_fast_scrollable_region_;
641   Region touch_event_handler_region_;
642   SkColor background_color_;
643
644   float opacity_;
645   SkXfermode::Mode blend_mode_;
646   gfx::PointF position_;
647   gfx::Transform transform_;
648
649   LayerPositionConstraint position_constraint_;
650
651   gfx::Vector2dF scroll_delta_;
652   gfx::Vector2d sent_scroll_delta_;
653   gfx::Vector2dF last_scroll_offset_;
654
655   int num_descendants_that_draw_content_;
656
657   // The global depth value of the center of the layer. This value is used
658   // to sort layers from back to front.
659   float draw_depth_;
660
661   FilterOperations filters_;
662   FilterOperations background_filters_;
663
664  protected:
665   friend class TreeSynchronizer;
666
667   // This flag is set when the layer needs to push properties to the active
668   // side.
669   bool needs_push_properties_;
670
671   // The number of direct children or dependent layers that need to be recursed
672   // to in order for them or a descendent of them to push properties to the
673   // active side.
674   int num_dependents_need_push_properties_;
675
676   // Layers that share a sorting context id will be sorted together in 3d
677   // space.  0 is a special value that means this layer will not be sorted and
678   // will be drawn in paint order.
679   int sorting_context_id_;
680
681   DrawMode current_draw_mode_;
682
683  private:
684   // Rect indicating what was repainted/updated during update.
685   // Note that plugin layers bypass this and leave it empty.
686   // Uses layer (not content) space.
687   gfx::RectF update_rect_;
688
689   // This rect is in layer space.
690   gfx::RectF damage_rect_;
691
692   // Manages animations for this layer.
693   scoped_refptr<LayerAnimationController> layer_animation_controller_;
694
695   // Manages scrollbars for this layer
696   scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_;
697
698   scoped_ptr<ScrollbarSet> scrollbars_;
699
700   ScopedPtrVector<CopyOutputRequest> copy_requests_;
701
702   // Group of properties that need to be computed based on the layer tree
703   // hierarchy before layers can be drawn.
704   DrawProperties<LayerImpl> draw_properties_;
705
706   scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_;
707
708   DISALLOW_COPY_AND_ASSIGN(LayerImpl);
709 };
710
711 }  // namespace cc
712
713 #endif  // CC_LAYERS_LAYER_IMPL_H_