Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / cc / layers / layer_impl.h
blob2cfa04082ef703f3d0bd15ab54481fa7b6239614
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 <map>
9 #include <set>
10 #include <string>
11 #include <vector>
13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/values.h"
16 #include "cc/animation/animation_delegate.h"
17 #include "cc/animation/layer_animation_controller.h"
18 #include "cc/animation/layer_animation_value_observer.h"
19 #include "cc/animation/layer_animation_value_provider.h"
20 #include "cc/base/cc_export.h"
21 #include "cc/base/region.h"
22 #include "cc/base/scoped_ptr_vector.h"
23 #include "cc/base/synced_property.h"
24 #include "cc/debug/frame_timing_request.h"
25 #include "cc/input/input_handler.h"
26 #include "cc/input/scrollbar.h"
27 #include "cc/layers/draw_properties.h"
28 #include "cc/layers/layer_lists.h"
29 #include "cc/layers/layer_position_constraint.h"
30 #include "cc/layers/render_surface_impl.h"
31 #include "cc/layers/scroll_blocks_on.h"
32 #include "cc/output/filter_operations.h"
33 #include "cc/quads/shared_quad_state.h"
34 #include "cc/resources/resource_provider.h"
35 #include "cc/resources/tile_priority.h"
36 #include "skia/ext/refptr.h"
37 #include "third_party/skia/include/core/SkColor.h"
38 #include "third_party/skia/include/core/SkImageFilter.h"
39 #include "third_party/skia/include/core/SkPicture.h"
40 #include "ui/gfx/geometry/point3_f.h"
41 #include "ui/gfx/geometry/rect.h"
42 #include "ui/gfx/geometry/rect_f.h"
43 #include "ui/gfx/geometry/scroll_offset.h"
44 #include "ui/gfx/transform.h"
46 namespace base {
47 namespace trace_event {
48 class ConvertableToTraceFormat;
49 class TracedValue;
51 class DictionaryValue;
54 namespace cc {
56 class LayerTreeHostImpl;
57 class LayerTreeImpl;
58 class MicroBenchmarkImpl;
59 class Occlusion;
60 template <typename LayerType>
61 class OcclusionTracker;
62 class RenderPass;
63 class RenderPassId;
64 class Renderer;
65 class ScrollbarAnimationController;
66 class ScrollbarLayerImplBase;
67 class SimpleEnclosedRegion;
68 class Tile;
70 struct AppendQuadsData;
72 enum DrawMode {
73 DRAW_MODE_NONE,
74 DRAW_MODE_HARDWARE,
75 DRAW_MODE_SOFTWARE,
76 DRAW_MODE_RESOURCELESS_SOFTWARE
79 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
80 public LayerAnimationValueProvider,
81 public AnimationDelegate {
82 public:
83 typedef SyncedProperty<AdditionGroup<gfx::ScrollOffset>> SyncedScrollOffset;
84 typedef LayerImplList RenderSurfaceListType;
85 typedef LayerImplList LayerListType;
86 typedef RenderSurfaceImpl RenderSurfaceType;
88 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 };
90 static scoped_ptr<LayerImpl> Create(
91 LayerTreeImpl* tree_impl,
92 int id,
93 scoped_refptr<SyncedScrollOffset> scroll_offset) {
94 return make_scoped_ptr(new LayerImpl(tree_impl, id, scroll_offset));
97 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
98 return make_scoped_ptr(new LayerImpl(tree_impl, id));
101 ~LayerImpl() override;
103 int id() const { return layer_id_; }
105 // LayerAnimationValueProvider implementation.
106 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
108 // LayerAnimationValueObserver implementation.
109 void OnFilterAnimated(const FilterOperations& filters) override;
110 void OnOpacityAnimated(float opacity) override;
111 void OnTransformAnimated(const gfx::Transform& transform) override;
112 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override;
113 void OnAnimationWaitingForDeletion() override;
114 bool IsActive() const override;
116 // AnimationDelegate implementation.
117 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
118 Animation::TargetProperty target_property,
119 int group) override{};
120 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
121 Animation::TargetProperty target_property,
122 int group) override;
124 // Tree structure.
125 LayerImpl* parent() { return parent_; }
126 const LayerImpl* parent() const { return parent_; }
127 const OwnedLayerImplList& children() const { return children_; }
128 OwnedLayerImplList& children() { return children_; }
129 LayerImpl* child_at(size_t index) const { return children_[index]; }
130 void AddChild(scoped_ptr<LayerImpl> child);
131 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child);
132 void SetParent(LayerImpl* parent);
134 // Warning: This does not preserve tree structure invariants.
135 void ClearChildList();
137 bool HasAncestor(const LayerImpl* ancestor) const;
139 void SetScrollParent(LayerImpl* parent);
141 LayerImpl* scroll_parent() { return scroll_parent_; }
142 const LayerImpl* scroll_parent() const { return scroll_parent_; }
144 void SetScrollChildren(std::set<LayerImpl*>* children);
146 std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); }
147 const std::set<LayerImpl*>* scroll_children() const {
148 return scroll_children_.get();
151 void SetNumDescendantsThatDrawContent(int num_descendants);
152 void SetClipParent(LayerImpl* ancestor);
154 LayerImpl* clip_parent() {
155 return clip_parent_;
157 const LayerImpl* clip_parent() const {
158 return clip_parent_;
161 void SetClipChildren(std::set<LayerImpl*>* children);
163 std::set<LayerImpl*>* clip_children() { return clip_children_.get(); }
164 const std::set<LayerImpl*>* clip_children() const {
165 return clip_children_.get();
168 void PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests);
169 // Can only be called when the layer has a copy request.
170 void TakeCopyRequestsAndTransformToTarget(
171 ScopedPtrVector<CopyOutputRequest>* request);
172 bool HasCopyRequest() const { return !copy_requests_.empty(); }
174 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer);
175 LayerImpl* mask_layer() { return mask_layer_.get(); }
176 const LayerImpl* mask_layer() const { return mask_layer_.get(); }
177 scoped_ptr<LayerImpl> TakeMaskLayer();
179 void SetReplicaLayer(scoped_ptr<LayerImpl> replica_layer);
180 LayerImpl* replica_layer() { return replica_layer_.get(); }
181 const LayerImpl* replica_layer() const { return replica_layer_.get(); }
182 scoped_ptr<LayerImpl> TakeReplicaLayer();
184 bool has_mask() const { return mask_layer_; }
185 bool has_replica() const { return replica_layer_; }
186 bool replica_has_mask() const {
187 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_);
190 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; }
192 void PopulateSharedQuadState(SharedQuadState* state) const;
193 void PopulateScaledSharedQuadState(SharedQuadState* state, float scale) const;
194 // WillDraw must be called before AppendQuads. If WillDraw returns false,
195 // AppendQuads and DidDraw will not be called. If WillDraw returns true,
196 // DidDraw is guaranteed to be called before another WillDraw or before
197 // the layer is destroyed. To enforce this, any class that overrides
198 // WillDraw/DidDraw must call the base class version only if WillDraw
199 // returns true.
200 virtual bool WillDraw(DrawMode draw_mode,
201 ResourceProvider* resource_provider);
202 virtual void AppendQuads(RenderPass* render_pass,
203 AppendQuadsData* append_quads_data) {}
204 virtual void DidDraw(ResourceProvider* resource_provider);
206 virtual void GetContentsResourceId(ResourceProvider::ResourceId* resource_id,
207 gfx::Size* resource_size) const;
209 virtual bool HasDelegatedContent() const;
210 virtual bool HasContributingDelegatedRenderPasses() const;
211 virtual RenderPassId FirstContributingRenderPassId() const;
212 virtual RenderPassId NextContributingRenderPassId(RenderPassId id) const;
214 virtual void NotifyTileStateChanged(const Tile* tile) {}
216 virtual ScrollbarLayerImplBase* ToScrollbarLayer();
218 // Returns true if this layer has content to draw.
219 void SetDrawsContent(bool draws_content);
220 bool DrawsContent() const { return draws_content_; }
222 int NumDescendantsThatDrawContent() const;
223 void SetHideLayerAndSubtree(bool hide);
224 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; }
226 void SetTransformOrigin(const gfx::Point3F& transform_origin);
227 gfx::Point3F transform_origin() const { return transform_origin_; }
229 void SetBackgroundColor(SkColor background_color);
230 SkColor background_color() const { return background_color_; }
231 // If contents_opaque(), return an opaque color else return a
232 // non-opaque color. Tries to return background_color(), if possible.
233 SkColor SafeOpaqueBackgroundColor() const;
235 void SetFilters(const FilterOperations& filters);
236 const FilterOperations& filters() const { return filters_; }
237 bool FilterIsAnimating() const;
238 bool FilterIsAnimatingOnImplOnly() const;
240 void SetBackgroundFilters(const FilterOperations& filters);
241 const FilterOperations& background_filters() const {
242 return background_filters_;
245 void SetMasksToBounds(bool masks_to_bounds);
246 bool masks_to_bounds() const { return masks_to_bounds_; }
248 void SetContentsOpaque(bool opaque);
249 bool contents_opaque() const { return contents_opaque_; }
251 void SetOpacity(float opacity);
252 float opacity() const { return opacity_; }
253 bool OpacityIsAnimating() const;
254 bool OpacityIsAnimatingOnImplOnly() const;
256 void SetBlendMode(SkXfermode::Mode);
257 SkXfermode::Mode blend_mode() const { return blend_mode_; }
258 bool uses_default_blend_mode() const {
259 return blend_mode_ == SkXfermode::kSrcOver_Mode;
262 void SetIsRootForIsolatedGroup(bool root);
263 bool is_root_for_isolated_group() const {
264 return is_root_for_isolated_group_;
267 void SetPosition(const gfx::PointF& position);
268 gfx::PointF position() const { return position_; }
270 void SetIsContainerForFixedPositionLayers(bool container) {
271 is_container_for_fixed_position_layers_ = container;
273 // This is a non-trivial function in Layer.
274 bool IsContainerForFixedPositionLayers() const {
275 return is_container_for_fixed_position_layers_;
278 gfx::Vector2dF FixedContainerSizeDelta() const;
280 void SetPositionConstraint(const LayerPositionConstraint& constraint) {
281 position_constraint_ = constraint;
283 const LayerPositionConstraint& position_constraint() const {
284 return position_constraint_;
287 void SetShouldFlattenTransform(bool flatten);
288 bool should_flatten_transform() const { return should_flatten_transform_; }
290 bool Is3dSorted() const { return sorting_context_id_ != 0; }
292 void SetUseParentBackfaceVisibility(bool use) {
293 use_parent_backface_visibility_ = use;
295 bool use_parent_backface_visibility() const {
296 return use_parent_backface_visibility_;
299 bool ShowDebugBorders() const;
301 // These invalidate the host's render surface layer list. The caller
302 // is responsible for calling set_needs_update_draw_properties on the tree
303 // so that its list can be recreated.
304 void ClearRenderSurfaceLayerList();
305 void SetHasRenderSurface(bool has_render_surface);
307 RenderSurfaceImpl* render_surface() const { return render_surface_.get(); }
309 DrawProperties<LayerImpl>& draw_properties() {
310 return draw_properties_;
312 const DrawProperties<LayerImpl>& draw_properties() const {
313 return draw_properties_;
316 // The following are shortcut accessors to get various information from
317 // draw_properties_
318 const gfx::Transform& draw_transform() const {
319 return draw_properties_.target_space_transform;
321 const gfx::Transform& screen_space_transform() const {
322 return draw_properties_.screen_space_transform;
324 float draw_opacity() const { return draw_properties_.opacity; }
325 SkXfermode::Mode draw_blend_mode() const {
326 return draw_properties_.blend_mode;
328 bool draw_opacity_is_animating() const {
329 return draw_properties_.opacity_is_animating;
331 bool draw_transform_is_animating() const {
332 return draw_properties_.target_space_transform_is_animating;
334 bool screen_space_transform_is_animating() const {
335 return draw_properties_.screen_space_transform_is_animating;
337 bool screen_space_opacity_is_animating() const {
338 return draw_properties_.screen_space_opacity_is_animating;
340 bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; }
341 bool is_clipped() const { return draw_properties_.is_clipped; }
342 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; }
343 gfx::Rect drawable_content_rect() const {
344 return draw_properties_.drawable_content_rect;
346 gfx::Rect visible_content_rect() const {
347 return draw_properties_.visible_content_rect;
349 LayerImpl* render_target() {
350 DCHECK(!draw_properties_.render_target ||
351 draw_properties_.render_target->render_surface());
352 return draw_properties_.render_target;
354 const LayerImpl* render_target() const {
355 DCHECK(!draw_properties_.render_target ||
356 draw_properties_.render_target->render_surface());
357 return draw_properties_.render_target;
360 int num_unclipped_descendants() const {
361 return draw_properties_.num_unclipped_descendants;
364 // The client should be responsible for setting bounds, content bounds and
365 // contents scale to appropriate values. LayerImpl doesn't calculate any of
366 // them from the other values.
368 void SetBounds(const gfx::Size& bounds);
369 gfx::Size bounds() const;
370 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions
371 // of pixels) due to use of single precision float.
372 gfx::SizeF BoundsForScrolling() const;
373 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta);
374 gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
376 void SetContentBounds(const gfx::Size& content_bounds);
377 gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
379 float contents_scale_x() const { return draw_properties_.contents_scale_x; }
380 float contents_scale_y() const { return draw_properties_.contents_scale_y; }
381 void SetContentsScale(float contents_scale_x, float contents_scale_y);
383 bool IsExternalFlingActive() const;
385 void SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset);
386 void SetCurrentScrollOffsetFromDelegate(
387 const gfx::ScrollOffset& scroll_offset);
388 void PushScrollOffsetFromMainThread(const gfx::ScrollOffset& scroll_offset);
389 // This method is similar to PushScrollOffsetFromMainThread but will cause the
390 // scroll offset given to clobber any scroll changes on the active tree in the
391 // time until this value is pushed to the active tree.
392 void PushScrollOffsetFromMainThreadAndClobberActiveValue(
393 const gfx::ScrollOffset& scroll_offset);
394 gfx::ScrollOffset PullDeltaForMainThread();
395 gfx::ScrollOffset CurrentScrollOffset() const;
396 gfx::ScrollOffset BaseScrollOffset() const;
397 gfx::Vector2dF ScrollDelta() const;
398 void SetScrollDelta(const gfx::Vector2dF& delta);
400 gfx::ScrollOffset MaxScrollOffset() const;
401 gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset) const;
402 gfx::Vector2dF ClampScrollToMaxScrollOffset();
403 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer,
404 LayerImpl* scrollbar_clip_layer,
405 bool on_resize) const;
406 void SetScrollCompensationAdjustment(const gfx::Vector2dF& scroll_offset) {
407 scroll_compensation_adjustment_ = scroll_offset;
409 gfx::Vector2dF ScrollCompensationAdjustment() const {
410 return scroll_compensation_adjustment_;
413 // Returns the delta of the scroll that was outside of the bounds of the
414 // initial scroll
415 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll);
417 void SetScrollClipLayer(int scroll_clip_layer_id);
418 LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; }
419 bool scrollable() const { return !!scroll_clip_layer_; }
421 void set_user_scrollable_horizontal(bool scrollable) {
422 user_scrollable_horizontal_ = scrollable;
424 bool user_scrollable_horizontal() const {
425 return user_scrollable_horizontal_;
427 void set_user_scrollable_vertical(bool scrollable) {
428 user_scrollable_vertical_ = scrollable;
430 bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
432 bool user_scrollable(ScrollbarOrientation orientation) const;
434 void ApplySentScrollDeltasFromAbortedCommit();
436 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) {
437 should_scroll_on_main_thread_ = should_scroll_on_main_thread;
439 bool should_scroll_on_main_thread() const {
440 return should_scroll_on_main_thread_;
443 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) {
444 have_wheel_event_handlers_ = have_wheel_event_handlers;
446 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; }
448 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers) {
449 have_scroll_event_handlers_ = have_scroll_event_handlers;
451 bool have_scroll_event_handlers() const {
452 return have_scroll_event_handlers_;
455 void SetNonFastScrollableRegion(const Region& region) {
456 non_fast_scrollable_region_ = region;
458 const Region& non_fast_scrollable_region() const {
459 return non_fast_scrollable_region_;
462 void SetTouchEventHandlerRegion(const Region& region) {
463 touch_event_handler_region_ = region;
465 const Region& touch_event_handler_region() const {
466 return touch_event_handler_region_;
469 void SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on) {
470 scroll_blocks_on_ = scroll_blocks_on;
472 ScrollBlocksOn scroll_blocks_on() const { return scroll_blocks_on_; }
473 void SetDrawCheckerboardForMissingTiles(bool checkerboard) {
474 draw_checkerboard_for_missing_tiles_ = checkerboard;
476 bool draw_checkerboard_for_missing_tiles() const {
477 return draw_checkerboard_for_missing_tiles_;
480 InputHandler::ScrollStatus TryScroll(
481 const gfx::PointF& screen_space_point,
482 InputHandler::ScrollInputType type,
483 ScrollBlocksOn effective_block_mode) const;
485 void SetDoubleSided(bool double_sided);
486 bool double_sided() const { return double_sided_; }
488 void SetTransform(const gfx::Transform& transform);
489 const gfx::Transform& transform() const { return transform_; }
490 bool TransformIsAnimating() const;
491 bool TransformIsAnimatingOnImplOnly() const;
492 void SetTransformAndInvertibility(const gfx::Transform& transform,
493 bool transform_is_invertible);
494 bool transform_is_invertible() const { return transform_is_invertible_; }
496 // Note this rect is in layer space (not content space).
497 void SetUpdateRect(const gfx::Rect& update_rect);
498 gfx::Rect update_rect() const { return update_rect_; }
500 void AddDamageRect(const gfx::RectF& damage_rect);
502 const gfx::RectF& damage_rect() const { return damage_rect_; }
504 virtual base::DictionaryValue* LayerTreeAsJson() const;
506 void SetStackingOrderChanged(bool stacking_order_changed);
508 bool LayerPropertyChanged() const { return layer_property_changed_; }
510 void ResetAllChangeTrackingForSubtree();
512 LayerAnimationController* layer_animation_controller() {
513 return layer_animation_controller_.get();
516 const LayerAnimationController* layer_animation_controller() const {
517 return layer_animation_controller_.get();
520 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const;
522 virtual void DidBecomeActive();
524 virtual void DidBeginTracing();
526 // Release resources held by this layer. Called when the output surface
527 // that rendered this layer was lost or a rendering mode switch has occured.
528 virtual void ReleaseResources();
530 // Recreate resources that are required after they were released by a
531 // ReleaseResources call.
532 virtual void RecreateResources();
534 ScrollbarAnimationController* scrollbar_animation_controller() const {
535 return scrollbar_animation_controller_.get();
538 typedef std::set<ScrollbarLayerImplBase*> ScrollbarSet;
539 ScrollbarSet* scrollbars() { return scrollbars_.get(); }
540 void ClearScrollbars();
541 void AddScrollbar(ScrollbarLayerImplBase* layer);
542 void RemoveScrollbar(ScrollbarLayerImplBase* layer);
543 bool HasScrollbar(ScrollbarOrientation orientation) const;
544 void ScrollbarParametersDidChange(bool on_resize);
545 int clip_height() {
546 return scroll_clip_layer_ ? scroll_clip_layer_->bounds().height() : 0;
549 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const;
551 virtual skia::RefPtr<SkPicture> GetPicture();
553 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
554 virtual void PushPropertiesTo(LayerImpl* layer);
556 virtual void GetAllTilesAndPrioritiesForTracing(
557 std::map<const Tile*, TilePriority>* tile_map) const;
558 virtual void AsValueInto(base::trace_event::TracedValue* dict) const;
560 virtual size_t GPUMemoryUsageInBytes() const;
562 void SetNeedsPushProperties();
563 void AddDependentNeedsPushProperties();
564 void RemoveDependentNeedsPushProperties();
565 bool parent_should_know_need_push_properties() const {
566 return needs_push_properties() || descendant_needs_push_properties();
569 bool needs_push_properties() const { return needs_push_properties_; }
570 bool descendant_needs_push_properties() const {
571 return num_dependents_need_push_properties_ > 0;
574 virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark);
576 virtual void SetDebugInfo(
577 scoped_refptr<base::trace_event::ConvertableToTraceFormat> other);
579 bool IsDrawnRenderSurfaceLayerListMember() const;
581 void Set3dSortingContextId(int id);
582 int sorting_context_id() { return sorting_context_id_; }
584 void PassFrameTimingRequests(
585 std::vector<FrameTimingRequest>* frame_timing_requests);
586 const std::vector<FrameTimingRequest>& frame_timing_requests() const {
587 return frame_timing_requests_;
589 void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids);
591 SyncedScrollOffset* synced_scroll_offset() { return scroll_offset_.get(); }
593 // Get the correct invalidation region instead of conservative Rect
594 // for layers that provide it.
595 virtual Region GetInvalidationRegion();
597 virtual gfx::Rect GetEnclosingRectInTargetSpace() const;
599 protected:
600 LayerImpl(LayerTreeImpl* layer_impl,
601 int id,
602 scoped_refptr<SyncedScrollOffset> scroll_offset);
603 LayerImpl(LayerTreeImpl* layer_impl, int id);
605 // Get the color and size of the layer's debug border.
606 virtual void GetDebugBorderProperties(SkColor* color, float* width) const;
608 void AppendDebugBorderQuad(RenderPass* render_pass,
609 const gfx::Size& content_bounds,
610 const SharedQuadState* shared_quad_state,
611 AppendQuadsData* append_quads_data) const;
612 void AppendDebugBorderQuad(RenderPass* render_pass,
613 const gfx::Size& content_bounds,
614 const SharedQuadState* shared_quad_state,
615 AppendQuadsData* append_quads_data,
616 SkColor color,
617 float width) const;
619 void NoteLayerPropertyChanged();
620 void NoteLayerPropertyChangedForSubtree();
622 // Note carefully this does not affect the current layer.
623 void NoteLayerPropertyChangedForDescendants();
625 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const;
627 private:
628 void PushScrollOffset(const gfx::ScrollOffset* scroll_offset);
629 // If the new scroll offset is assigned from the root scroll offset delegate,
630 // LayerImpl won't inform the root scroll offset delegate about the scroll
631 // change to avoid feedback.
632 void DidUpdateScrollOffset(bool is_from_root_delegate);
633 void NoteLayerPropertyChangedForDescendantsInternal();
635 virtual const char* LayerTypeAsString() const;
637 // Properties internal to LayerImpl
638 LayerImpl* parent_;
639 OwnedLayerImplList children_;
641 LayerImpl* scroll_parent_;
643 // Storing a pointer to a set rather than a set since this will be rarely
644 // used. If this pointer turns out to be too heavy, we could have this (and
645 // the scroll parent above) be stored in a LayerImpl -> scroll_info
646 // map somewhere.
647 scoped_ptr<std::set<LayerImpl*>> scroll_children_;
649 LayerImpl* clip_parent_;
650 scoped_ptr<std::set<LayerImpl*>> clip_children_;
652 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
653 // confirm newly assigned layer is still the previous one
654 int mask_layer_id_;
655 scoped_ptr<LayerImpl> mask_layer_;
656 int replica_layer_id_; // ditto
657 scoped_ptr<LayerImpl> replica_layer_;
658 int layer_id_;
659 LayerTreeImpl* layer_tree_impl_;
661 // Properties dynamically changeable on active tree.
662 scoped_refptr<SyncedScrollOffset> scroll_offset_;
663 gfx::Vector2dF bounds_delta_;
665 // Properties synchronized from the associated Layer.
666 gfx::Point3F transform_origin_;
667 gfx::Size bounds_;
668 LayerImpl* scroll_clip_layer_;
669 bool scrollable_ : 1;
670 bool should_scroll_on_main_thread_ : 1;
671 bool have_wheel_event_handlers_ : 1;
672 bool have_scroll_event_handlers_ : 1;
674 static_assert(SCROLL_BLOCKS_ON_MAX < (1 << 3), "ScrollBlocksOn too big");
675 ScrollBlocksOn scroll_blocks_on_ : 3;
677 bool user_scrollable_horizontal_ : 1;
678 bool user_scrollable_vertical_ : 1;
679 bool stacking_order_changed_ : 1;
680 // Whether the "back" of this layer should draw.
681 bool double_sided_ : 1;
682 bool should_flatten_transform_ : 1;
684 // Tracks if drawing-related properties have changed since last redraw.
685 bool layer_property_changed_ : 1;
687 bool masks_to_bounds_ : 1;
688 bool contents_opaque_ : 1;
689 bool is_root_for_isolated_group_ : 1;
690 bool use_parent_backface_visibility_ : 1;
691 bool draw_checkerboard_for_missing_tiles_ : 1;
692 bool draws_content_ : 1;
693 bool hide_layer_and_subtree_ : 1;
695 // Cache transform_'s invertibility.
696 bool transform_is_invertible_ : 1;
698 // Set for the layer that other layers are fixed to.
699 bool is_container_for_fixed_position_layers_ : 1;
700 Region non_fast_scrollable_region_;
701 Region touch_event_handler_region_;
702 SkColor background_color_;
704 float opacity_;
705 SkXfermode::Mode blend_mode_;
706 gfx::PointF position_;
707 gfx::Transform transform_;
709 LayerPositionConstraint position_constraint_;
711 gfx::Vector2dF scroll_compensation_adjustment_;
713 int num_descendants_that_draw_content_;
715 // The global depth value of the center of the layer. This value is used
716 // to sort layers from back to front.
717 float draw_depth_;
719 FilterOperations filters_;
720 FilterOperations background_filters_;
722 protected:
723 friend class TreeSynchronizer;
725 // This flag is set when the layer needs to push properties to the active
726 // side.
727 bool needs_push_properties_;
729 // The number of direct children or dependent layers that need to be recursed
730 // to in order for them or a descendent of them to push properties to the
731 // active side.
732 int num_dependents_need_push_properties_;
734 // Layers that share a sorting context id will be sorted together in 3d
735 // space. 0 is a special value that means this layer will not be sorted and
736 // will be drawn in paint order.
737 int sorting_context_id_;
739 DrawMode current_draw_mode_;
741 private:
742 // Rect indicating what was repainted/updated during update.
743 // Note that plugin layers bypass this and leave it empty.
744 // Uses layer (not content) space.
745 gfx::Rect update_rect_;
747 // This rect is in layer space.
748 gfx::RectF damage_rect_;
750 // Manages animations for this layer.
751 scoped_refptr<LayerAnimationController> layer_animation_controller_;
753 // Manages scrollbars for this layer
754 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_;
756 scoped_ptr<ScrollbarSet> scrollbars_;
758 ScopedPtrVector<CopyOutputRequest> copy_requests_;
760 // Group of properties that need to be computed based on the layer tree
761 // hierarchy before layers can be drawn.
762 DrawProperties<LayerImpl> draw_properties_;
764 scoped_refptr<base::trace_event::ConvertableToTraceFormat> debug_info_;
765 scoped_ptr<RenderSurfaceImpl> render_surface_;
767 std::vector<FrameTimingRequest> frame_timing_requests_;
768 bool frame_timing_requests_dirty_;
770 DISALLOW_COPY_AND_ASSIGN(LayerImpl);
773 } // namespace cc
775 #endif // CC_LAYERS_LAYER_IMPL_H_