ozone: evdev: Move touch ui::Event transformation to EventFactoryEvdev
[chromium-blink-merge.git] / cc / layers / layer_impl.h
blobf52b5de77ce21807418f2b26e0d19c41b6f03449
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>
10 #include <vector>
12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/values.h"
15 #include "cc/animation/animation_delegate.h"
16 #include "cc/animation/layer_animation_controller.h"
17 #include "cc/animation/layer_animation_value_observer.h"
18 #include "cc/animation/layer_animation_value_provider.h"
19 #include "cc/base/cc_export.h"
20 #include "cc/base/region.h"
21 #include "cc/base/scoped_ptr_vector.h"
22 #include "cc/debug/frame_timing_request.h"
23 #include "cc/input/input_handler.h"
24 #include "cc/input/scrollbar.h"
25 #include "cc/layers/draw_properties.h"
26 #include "cc/layers/layer_lists.h"
27 #include "cc/layers/layer_position_constraint.h"
28 #include "cc/layers/render_surface_impl.h"
29 #include "cc/output/filter_operations.h"
30 #include "cc/quads/shared_quad_state.h"
31 #include "cc/resources/resource_provider.h"
32 #include "skia/ext/refptr.h"
33 #include "third_party/skia/include/core/SkColor.h"
34 #include "third_party/skia/include/core/SkImageFilter.h"
35 #include "third_party/skia/include/core/SkPicture.h"
36 #include "ui/gfx/geometry/point3_f.h"
37 #include "ui/gfx/geometry/rect.h"
38 #include "ui/gfx/geometry/rect_f.h"
39 #include "ui/gfx/geometry/scroll_offset.h"
40 #include "ui/gfx/transform.h"
42 namespace base {
43 namespace debug {
44 class ConvertableToTraceFormat;
45 class TracedValue;
48 class DictionaryValue;
51 namespace cc {
53 class LayerTreeHostImpl;
54 class LayerTreeImpl;
55 class MicroBenchmarkImpl;
56 class Occlusion;
57 template <typename LayerType>
58 class OcclusionTracker;
59 class RenderPass;
60 class RenderPassId;
61 class Renderer;
62 class ScrollbarAnimationController;
63 class ScrollbarLayerImplBase;
64 class SimpleEnclosedRegion;
65 class Tile;
67 struct AppendQuadsData;
69 enum DrawMode {
70 DRAW_MODE_NONE,
71 DRAW_MODE_HARDWARE,
72 DRAW_MODE_SOFTWARE,
73 DRAW_MODE_RESOURCELESS_SOFTWARE
76 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
77 public LayerAnimationValueProvider,
78 public AnimationDelegate {
79 public:
80 // Allows for the ownership of the total scroll offset to be delegated outside
81 // of the layer.
82 class ScrollOffsetDelegate {
83 public:
84 virtual void SetTotalScrollOffset(const gfx::ScrollOffset& new_value) = 0;
85 virtual gfx::ScrollOffset GetTotalScrollOffset() = 0;
86 virtual bool IsExternalFlingActive() const = 0;
87 virtual void Update() const = 0;
90 typedef LayerImplList RenderSurfaceListType;
91 typedef LayerImplList LayerListType;
92 typedef RenderSurfaceImpl RenderSurfaceType;
94 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 };
96 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
97 return make_scoped_ptr(new LayerImpl(tree_impl, id));
100 ~LayerImpl() override;
102 int id() const { return layer_id_; }
104 // LayerAnimationValueProvider implementation.
105 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
107 // LayerAnimationValueObserver implementation.
108 void OnFilterAnimated(const FilterOperations& filters) override;
109 void OnOpacityAnimated(float opacity) override;
110 void OnTransformAnimated(const gfx::Transform& transform) override;
111 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override;
112 void OnAnimationWaitingForDeletion() override;
113 bool IsActive() const override;
115 // AnimationDelegate implementation.
116 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
117 Animation::TargetProperty target_property,
118 int group) override{};
119 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
120 Animation::TargetProperty target_property,
121 int group) override;
123 // Tree structure.
124 LayerImpl* parent() { return parent_; }
125 const LayerImpl* parent() const { return parent_; }
126 const OwnedLayerImplList& children() const { return children_; }
127 OwnedLayerImplList& children() { return children_; }
128 LayerImpl* child_at(size_t index) const { return children_[index]; }
129 void AddChild(scoped_ptr<LayerImpl> child);
130 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child);
131 void SetParent(LayerImpl* parent);
133 // Warning: This does not preserve tree structure invariants.
134 void ClearChildList();
136 bool HasAncestor(const LayerImpl* ancestor) const;
138 void SetScrollParent(LayerImpl* parent);
140 LayerImpl* scroll_parent() { return scroll_parent_; }
141 const LayerImpl* scroll_parent() const { return scroll_parent_; }
143 void SetScrollChildren(std::set<LayerImpl*>* children);
145 std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); }
146 const std::set<LayerImpl*>* scroll_children() const {
147 return scroll_children_.get();
150 void SetNumDescendantsThatDrawContent(int num_descendants);
151 void SetClipParent(LayerImpl* ancestor);
153 LayerImpl* clip_parent() {
154 return clip_parent_;
156 const LayerImpl* clip_parent() const {
157 return clip_parent_;
160 void SetClipChildren(std::set<LayerImpl*>* children);
162 std::set<LayerImpl*>* clip_children() { return clip_children_.get(); }
163 const std::set<LayerImpl*>* clip_children() const {
164 return clip_children_.get();
167 void PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests);
168 // Can only be called when the layer has a copy request.
169 void TakeCopyRequestsAndTransformToTarget(
170 ScopedPtrVector<CopyOutputRequest>* request);
171 bool HasCopyRequest() const { return !copy_requests_.empty(); }
173 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer);
174 LayerImpl* mask_layer() { return mask_layer_.get(); }
175 const LayerImpl* mask_layer() const { return mask_layer_.get(); }
176 scoped_ptr<LayerImpl> TakeMaskLayer();
178 void SetReplicaLayer(scoped_ptr<LayerImpl> replica_layer);
179 LayerImpl* replica_layer() { return replica_layer_.get(); }
180 const LayerImpl* replica_layer() const { return replica_layer_.get(); }
181 scoped_ptr<LayerImpl> TakeReplicaLayer();
183 bool has_mask() const { return mask_layer_; }
184 bool has_replica() const { return replica_layer_; }
185 bool replica_has_mask() const {
186 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_);
189 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; }
191 void PopulateSharedQuadState(SharedQuadState* state) const;
192 // WillDraw must be called before AppendQuads. If WillDraw returns false,
193 // AppendQuads and DidDraw will not be called. If WillDraw returns true,
194 // DidDraw is guaranteed to be called before another WillDraw or before
195 // the layer is destroyed. To enforce this, any class that overrides
196 // WillDraw/DidDraw must call the base class version only if WillDraw
197 // returns true.
198 virtual bool WillDraw(DrawMode draw_mode,
199 ResourceProvider* resource_provider);
200 virtual void AppendQuads(RenderPass* render_pass,
201 const Occlusion& occlusion_in_content_space,
202 AppendQuadsData* append_quads_data) {}
203 virtual void DidDraw(ResourceProvider* resource_provider);
205 virtual void GetContentsResourceId(ResourceProvider::ResourceId* resource_id,
206 gfx::Size* resource_size) const;
208 virtual bool HasDelegatedContent() const;
209 virtual bool HasContributingDelegatedRenderPasses() const;
210 virtual RenderPassId FirstContributingRenderPassId() const;
211 virtual RenderPassId NextContributingRenderPassId(RenderPassId id) const;
213 // Updates the layer's tiles. This should return true if meaningful work was
214 // done. That is, if an early-out was hit and as a result the internal state
215 // of tiles didn't change, this function should return false.
216 virtual bool UpdateTiles(const Occlusion& occlusion_in_layer_space,
217 bool resourceless_software_draw);
218 virtual void NotifyTileStateChanged(const Tile* tile) {}
220 virtual ScrollbarLayerImplBase* ToScrollbarLayer();
222 // Returns true if this layer has content to draw.
223 void SetDrawsContent(bool draws_content);
224 bool DrawsContent() const { return draws_content_; }
226 int NumDescendantsThatDrawContent() const;
227 void SetHideLayerAndSubtree(bool hide);
228 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; }
230 void SetTransformOrigin(const gfx::Point3F& transform_origin);
231 gfx::Point3F transform_origin() const { return transform_origin_; }
233 void SetBackgroundColor(SkColor background_color);
234 SkColor background_color() const { return background_color_; }
235 // If contents_opaque(), return an opaque color else return a
236 // non-opaque color. Tries to return background_color(), if possible.
237 SkColor SafeOpaqueBackgroundColor() const;
239 void SetFilters(const FilterOperations& filters);
240 const FilterOperations& filters() const { return filters_; }
241 bool FilterIsAnimating() const;
242 bool FilterIsAnimatingOnImplOnly() const;
244 void SetBackgroundFilters(const FilterOperations& filters);
245 const FilterOperations& background_filters() const {
246 return background_filters_;
249 void SetMasksToBounds(bool masks_to_bounds);
250 bool masks_to_bounds() const { return masks_to_bounds_; }
252 void SetContentsOpaque(bool opaque);
253 bool contents_opaque() const { return contents_opaque_; }
255 void SetOpacity(float opacity);
256 float opacity() const { return opacity_; }
257 bool OpacityIsAnimating() const;
258 bool OpacityIsAnimatingOnImplOnly() const;
260 void SetBlendMode(SkXfermode::Mode);
261 SkXfermode::Mode blend_mode() const { return blend_mode_; }
262 bool uses_default_blend_mode() const {
263 return blend_mode_ == SkXfermode::kSrcOver_Mode;
266 void SetIsRootForIsolatedGroup(bool root);
267 bool is_root_for_isolated_group() const {
268 return is_root_for_isolated_group_;
271 void SetPosition(const gfx::PointF& position);
272 gfx::PointF position() const { return position_; }
274 void SetIsContainerForFixedPositionLayers(bool container) {
275 is_container_for_fixed_position_layers_ = container;
277 // This is a non-trivial function in Layer.
278 bool IsContainerForFixedPositionLayers() const {
279 return is_container_for_fixed_position_layers_;
282 gfx::Vector2dF FixedContainerSizeDelta() const;
284 void SetPositionConstraint(const LayerPositionConstraint& constraint) {
285 position_constraint_ = constraint;
287 const LayerPositionConstraint& position_constraint() const {
288 return position_constraint_;
291 void SetShouldFlattenTransform(bool flatten);
292 bool should_flatten_transform() const { return should_flatten_transform_; }
294 bool Is3dSorted() const { return sorting_context_id_ != 0; }
296 void SetUseParentBackfaceVisibility(bool use) {
297 use_parent_backface_visibility_ = use;
299 bool use_parent_backface_visibility() const {
300 return use_parent_backface_visibility_;
303 bool ShowDebugBorders() const;
305 // These invalidate the host's render surface layer list. The caller
306 // is responsible for calling set_needs_update_draw_properties on the tree
307 // so that its list can be recreated.
308 void ClearRenderSurfaceLayerList();
309 void SetHasRenderSurface(bool has_render_surface);
311 RenderSurfaceImpl* render_surface() const { return render_surface_.get(); }
313 DrawProperties<LayerImpl>& draw_properties() {
314 return draw_properties_;
316 const DrawProperties<LayerImpl>& draw_properties() const {
317 return draw_properties_;
320 // The following are shortcut accessors to get various information from
321 // draw_properties_
322 const gfx::Transform& draw_transform() const {
323 return draw_properties_.target_space_transform;
325 const gfx::Transform& screen_space_transform() const {
326 return draw_properties_.screen_space_transform;
328 float draw_opacity() const { return draw_properties_.opacity; }
329 SkXfermode::Mode draw_blend_mode() const {
330 return draw_properties_.blend_mode;
332 bool draw_opacity_is_animating() const {
333 return draw_properties_.opacity_is_animating;
335 bool draw_transform_is_animating() const {
336 return draw_properties_.target_space_transform_is_animating;
338 bool screen_space_transform_is_animating() const {
339 return draw_properties_.screen_space_transform_is_animating;
341 bool screen_space_opacity_is_animating() const {
342 return draw_properties_.screen_space_opacity_is_animating;
344 bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; }
345 bool is_clipped() const { return draw_properties_.is_clipped; }
346 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; }
347 gfx::Rect drawable_content_rect() const {
348 return draw_properties_.drawable_content_rect;
350 gfx::Rect visible_content_rect() const {
351 return draw_properties_.visible_content_rect;
353 LayerImpl* render_target() {
354 DCHECK(!draw_properties_.render_target ||
355 draw_properties_.render_target->render_surface());
356 return draw_properties_.render_target;
358 const LayerImpl* render_target() const {
359 DCHECK(!draw_properties_.render_target ||
360 draw_properties_.render_target->render_surface());
361 return draw_properties_.render_target;
364 int num_unclipped_descendants() const {
365 return draw_properties_.num_unclipped_descendants;
368 // The client should be responsible for setting bounds, content bounds and
369 // contents scale to appropriate values. LayerImpl doesn't calculate any of
370 // them from the other values.
372 void SetBounds(const gfx::Size& bounds);
373 gfx::Size bounds() const;
374 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions
375 // of pixels) due to use of single precision float.
376 gfx::SizeF BoundsForScrolling() const;
377 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta);
378 gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
380 void SetContentBounds(const gfx::Size& content_bounds);
381 gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
383 float contents_scale_x() const { return draw_properties_.contents_scale_x; }
384 float contents_scale_y() const { return draw_properties_.contents_scale_y; }
385 void SetContentsScale(float contents_scale_x, float contents_scale_y);
387 void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate);
388 void DidScroll();
389 bool IsExternalFlingActive() const;
391 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset);
392 void SetScrollOffsetAndDelta(const gfx::ScrollOffset& scroll_offset,
393 const gfx::Vector2dF& scroll_delta);
394 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; }
396 gfx::ScrollOffset MaxScrollOffset() const;
397 gfx::Vector2dF ClampScrollToMaxScrollOffset();
398 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer,
399 LayerImpl* scrollbar_clip_layer,
400 bool on_resize) const;
401 void SetScrollDelta(const gfx::Vector2dF& scroll_delta);
402 gfx::Vector2dF ScrollDelta() const;
404 gfx::ScrollOffset TotalScrollOffset() const;
406 void SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta);
407 gfx::Vector2dF sent_scroll_delta() const { return sent_scroll_delta_; }
409 // Returns the delta of the scroll that was outside of the bounds of the
410 // initial scroll
411 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll);
413 void SetScrollClipLayer(int scroll_clip_layer_id);
414 LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; }
415 bool scrollable() const { return !!scroll_clip_layer_; }
417 void set_user_scrollable_horizontal(bool scrollable) {
418 user_scrollable_horizontal_ = scrollable;
420 bool user_scrollable_horizontal() const {
421 return user_scrollable_horizontal_;
423 void set_user_scrollable_vertical(bool scrollable) {
424 user_scrollable_vertical_ = scrollable;
426 bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
428 bool user_scrollable(ScrollbarOrientation orientation) const;
430 void ApplySentScrollDeltasFromAbortedCommit();
431 void ApplyScrollDeltasSinceBeginMainFrame();
433 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) {
434 should_scroll_on_main_thread_ = should_scroll_on_main_thread;
436 bool should_scroll_on_main_thread() const {
437 return should_scroll_on_main_thread_;
440 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) {
441 have_wheel_event_handlers_ = have_wheel_event_handlers;
443 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; }
445 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers) {
446 have_scroll_event_handlers_ = have_scroll_event_handlers;
448 bool have_scroll_event_handlers() const {
449 return have_scroll_event_handlers_;
452 void SetNonFastScrollableRegion(const Region& region) {
453 non_fast_scrollable_region_ = region;
455 const Region& non_fast_scrollable_region() const {
456 return non_fast_scrollable_region_;
459 void SetTouchEventHandlerRegion(const Region& region) {
460 touch_event_handler_region_ = region;
462 const Region& touch_event_handler_region() const {
463 return touch_event_handler_region_;
466 void SetDrawCheckerboardForMissingTiles(bool checkerboard) {
467 draw_checkerboard_for_missing_tiles_ = checkerboard;
469 bool draw_checkerboard_for_missing_tiles() const {
470 return draw_checkerboard_for_missing_tiles_;
473 InputHandler::ScrollStatus TryScroll(
474 const gfx::PointF& screen_space_point,
475 InputHandler::ScrollInputType type) const;
477 void SetDoubleSided(bool double_sided);
478 bool double_sided() const { return double_sided_; }
480 void SetTransform(const gfx::Transform& transform);
481 const gfx::Transform& transform() const { return transform_; }
482 bool TransformIsAnimating() const;
483 bool TransformIsAnimatingOnImplOnly() const;
484 void SetTransformAndInvertibility(const gfx::Transform& transform,
485 bool transform_is_invertible);
486 bool transform_is_invertible() const { return transform_is_invertible_; }
488 // Note this rect is in layer space (not content space).
489 void SetUpdateRect(const gfx::Rect& update_rect);
490 gfx::Rect update_rect() const { return update_rect_; }
492 void AddDamageRect(const gfx::RectF& damage_rect);
494 const gfx::RectF& damage_rect() const { return damage_rect_; }
496 virtual base::DictionaryValue* LayerTreeAsJson() const;
498 void SetStackingOrderChanged(bool stacking_order_changed);
500 bool LayerPropertyChanged() const { return layer_property_changed_; }
502 void ResetAllChangeTrackingForSubtree();
504 LayerAnimationController* layer_animation_controller() {
505 return layer_animation_controller_.get();
508 const LayerAnimationController* layer_animation_controller() const {
509 return layer_animation_controller_.get();
512 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const;
514 virtual void DidBecomeActive();
516 virtual void DidBeginTracing();
518 // Release resources held by this layer. Called when the output surface
519 // that rendered this layer was lost or a rendering mode switch has occured.
520 virtual void ReleaseResources();
522 ScrollbarAnimationController* scrollbar_animation_controller() const {
523 return scrollbar_animation_controller_.get();
526 typedef std::set<ScrollbarLayerImplBase*> ScrollbarSet;
527 ScrollbarSet* scrollbars() { return scrollbars_.get(); }
528 void ClearScrollbars();
529 void AddScrollbar(ScrollbarLayerImplBase* layer);
530 void RemoveScrollbar(ScrollbarLayerImplBase* layer);
531 bool HasScrollbar(ScrollbarOrientation orientation) const;
532 void ScrollbarParametersDidChange(bool on_resize);
533 int clip_height() {
534 return scroll_clip_layer_ ? scroll_clip_layer_->bounds().height() : 0;
537 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const;
539 virtual skia::RefPtr<SkPicture> GetPicture();
541 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
542 virtual void PushPropertiesTo(LayerImpl* layer);
544 virtual void GetAllTilesForTracing(std::set<const Tile*>* tiles) const;
545 virtual void AsValueInto(base::debug::TracedValue* dict) const;
547 virtual size_t GPUMemoryUsageInBytes() const;
549 void SetNeedsPushProperties();
550 void AddDependentNeedsPushProperties();
551 void RemoveDependentNeedsPushProperties();
552 bool parent_should_know_need_push_properties() const {
553 return needs_push_properties() || descendant_needs_push_properties();
556 bool needs_push_properties() const { return needs_push_properties_; }
557 bool descendant_needs_push_properties() const {
558 return num_dependents_need_push_properties_ > 0;
561 virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark);
563 virtual void SetDebugInfo(
564 scoped_refptr<base::debug::ConvertableToTraceFormat> other);
566 bool IsDrawnRenderSurfaceLayerListMember() const;
568 void Set3dSortingContextId(int id);
569 int sorting_context_id() { return sorting_context_id_; }
571 void PassFrameTimingRequests(
572 std::vector<FrameTimingRequest>* frame_timing_requests);
573 const std::vector<FrameTimingRequest>& frame_timing_requests() const {
574 return frame_timing_requests_;
577 protected:
578 LayerImpl(LayerTreeImpl* layer_impl, int id);
580 // Get the color and size of the layer's debug border.
581 virtual void GetDebugBorderProperties(SkColor* color, float* width) const;
583 void AppendDebugBorderQuad(RenderPass* render_pass,
584 const gfx::Size& content_bounds,
585 const SharedQuadState* shared_quad_state,
586 AppendQuadsData* append_quads_data) const;
587 void AppendDebugBorderQuad(RenderPass* render_pass,
588 const gfx::Size& content_bounds,
589 const SharedQuadState* shared_quad_state,
590 AppendQuadsData* append_quads_data,
591 SkColor color,
592 float width) const;
594 void NoteLayerPropertyChanged();
595 void NoteLayerPropertyChangedForSubtree();
597 // Note carefully this does not affect the current layer.
598 void NoteLayerPropertyChangedForDescendants();
600 private:
601 void NoteLayerPropertyChangedForDescendantsInternal();
603 virtual const char* LayerTypeAsString() const;
605 // Properties internal to LayerImpl
606 LayerImpl* parent_;
607 OwnedLayerImplList children_;
609 LayerImpl* scroll_parent_;
611 // Storing a pointer to a set rather than a set since this will be rarely
612 // used. If this pointer turns out to be too heavy, we could have this (and
613 // the scroll parent above) be stored in a LayerImpl -> scroll_info
614 // map somewhere.
615 scoped_ptr<std::set<LayerImpl*>> scroll_children_;
617 LayerImpl* clip_parent_;
618 scoped_ptr<std::set<LayerImpl*>> clip_children_;
620 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
621 // confirm newly assigned layer is still the previous one
622 int mask_layer_id_;
623 scoped_ptr<LayerImpl> mask_layer_;
624 int replica_layer_id_; // ditto
625 scoped_ptr<LayerImpl> replica_layer_;
626 int layer_id_;
627 LayerTreeImpl* layer_tree_impl_;
629 // Properties synchronized from the associated Layer.
630 gfx::Point3F transform_origin_;
631 gfx::Size bounds_;
632 gfx::Vector2dF bounds_delta_;
633 gfx::ScrollOffset scroll_offset_;
634 ScrollOffsetDelegate* scroll_offset_delegate_;
635 LayerImpl* scroll_clip_layer_;
636 bool scrollable_ : 1;
637 bool should_scroll_on_main_thread_ : 1;
638 bool have_wheel_event_handlers_ : 1;
639 bool have_scroll_event_handlers_ : 1;
640 bool user_scrollable_horizontal_ : 1;
641 bool user_scrollable_vertical_ : 1;
642 bool stacking_order_changed_ : 1;
643 // Whether the "back" of this layer should draw.
644 bool double_sided_ : 1;
645 bool should_flatten_transform_ : 1;
647 // Tracks if drawing-related properties have changed since last redraw.
648 bool layer_property_changed_ : 1;
650 bool masks_to_bounds_ : 1;
651 bool contents_opaque_ : 1;
652 bool is_root_for_isolated_group_ : 1;
653 bool use_parent_backface_visibility_ : 1;
654 bool draw_checkerboard_for_missing_tiles_ : 1;
655 bool draws_content_ : 1;
656 bool hide_layer_and_subtree_ : 1;
658 // Cache transform_'s invertibility.
659 bool transform_is_invertible_ : 1;
661 // Set for the layer that other layers are fixed to.
662 bool is_container_for_fixed_position_layers_ : 1;
663 Region non_fast_scrollable_region_;
664 Region touch_event_handler_region_;
665 SkColor background_color_;
667 float opacity_;
668 SkXfermode::Mode blend_mode_;
669 gfx::PointF position_;
670 gfx::Transform transform_;
672 LayerPositionConstraint position_constraint_;
674 gfx::Vector2dF scroll_delta_;
675 gfx::Vector2dF sent_scroll_delta_;
676 gfx::ScrollOffset last_scroll_offset_;
678 int num_descendants_that_draw_content_;
680 // The global depth value of the center of the layer. This value is used
681 // to sort layers from back to front.
682 float draw_depth_;
684 FilterOperations filters_;
685 FilterOperations background_filters_;
687 protected:
688 friend class TreeSynchronizer;
690 // This flag is set when the layer needs to push properties to the active
691 // side.
692 bool needs_push_properties_;
694 // The number of direct children or dependent layers that need to be recursed
695 // to in order for them or a descendent of them to push properties to the
696 // active side.
697 int num_dependents_need_push_properties_;
699 // Layers that share a sorting context id will be sorted together in 3d
700 // space. 0 is a special value that means this layer will not be sorted and
701 // will be drawn in paint order.
702 int sorting_context_id_;
704 DrawMode current_draw_mode_;
706 private:
707 // Rect indicating what was repainted/updated during update.
708 // Note that plugin layers bypass this and leave it empty.
709 // Uses layer (not content) space.
710 gfx::Rect update_rect_;
712 // This rect is in layer space.
713 gfx::RectF damage_rect_;
715 // Manages animations for this layer.
716 scoped_refptr<LayerAnimationController> layer_animation_controller_;
718 // Manages scrollbars for this layer
719 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_;
721 scoped_ptr<ScrollbarSet> scrollbars_;
723 ScopedPtrVector<CopyOutputRequest> copy_requests_;
725 // Group of properties that need to be computed based on the layer tree
726 // hierarchy before layers can be drawn.
727 DrawProperties<LayerImpl> draw_properties_;
729 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_;
730 scoped_ptr<RenderSurfaceImpl> render_surface_;
732 std::vector<FrameTimingRequest> frame_timing_requests_;
733 bool frame_timing_requests_dirty_;
735 DISALLOW_COPY_AND_ASSIGN(LayerImpl);
738 } // namespace cc
740 #endif // CC_LAYERS_LAYER_IMPL_H_