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