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