[Android] Add a device-side test HTTP server via ChromeInstrumentationTestRunner.
[chromium-blink-merge.git] / cc / layers / layer_impl.h
blobd1cf0530586d65e6566df624062c474671ff5626
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 // Updates the layer's tiles. This should return true if meaningful work was
212 // done. That is, if an early-out was hit and as a result the internal state
213 // of tiles didn't change, this function should return false.
214 virtual bool UpdateTiles(const Occlusion& occlusion_in_layer_space,
215 bool resourceless_software_draw);
216 virtual void NotifyTileStateChanged(const Tile* tile) {}
218 virtual ScrollbarLayerImplBase* ToScrollbarLayer();
220 // Returns true if this layer has content to draw.
221 void SetDrawsContent(bool draws_content);
222 bool DrawsContent() const { return draws_content_; }
224 int NumDescendantsThatDrawContent() const;
225 void SetHideLayerAndSubtree(bool hide);
226 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; }
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 ClearRenderSurfaceLayerList();
307 void SetHasRenderSurface(bool has_render_surface);
309 RenderSurfaceImpl* render_surface() const { return render_surface_.get(); }
311 DrawProperties<LayerImpl>& draw_properties() {
312 return draw_properties_;
314 const DrawProperties<LayerImpl>& draw_properties() const {
315 return draw_properties_;
318 // The following are shortcut accessors to get various information from
319 // draw_properties_
320 const gfx::Transform& draw_transform() const {
321 return draw_properties_.target_space_transform;
323 const gfx::Transform& screen_space_transform() const {
324 return draw_properties_.screen_space_transform;
326 float draw_opacity() const { return draw_properties_.opacity; }
327 SkXfermode::Mode draw_blend_mode() const {
328 return draw_properties_.blend_mode;
330 bool draw_opacity_is_animating() const {
331 return draw_properties_.opacity_is_animating;
333 bool draw_transform_is_animating() const {
334 return draw_properties_.target_space_transform_is_animating;
336 bool screen_space_transform_is_animating() const {
337 return draw_properties_.screen_space_transform_is_animating;
339 bool screen_space_opacity_is_animating() const {
340 return draw_properties_.screen_space_opacity_is_animating;
342 bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; }
343 bool is_clipped() const { return draw_properties_.is_clipped; }
344 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; }
345 gfx::Rect drawable_content_rect() const {
346 return draw_properties_.drawable_content_rect;
348 gfx::Rect visible_content_rect() const {
349 return draw_properties_.visible_content_rect;
351 LayerImpl* render_target() {
352 DCHECK(!draw_properties_.render_target ||
353 draw_properties_.render_target->render_surface());
354 return draw_properties_.render_target;
356 const LayerImpl* render_target() const {
357 DCHECK(!draw_properties_.render_target ||
358 draw_properties_.render_target->render_surface());
359 return draw_properties_.render_target;
362 int num_unclipped_descendants() const {
363 return draw_properties_.num_unclipped_descendants;
366 // The client should be responsible for setting bounds, content bounds and
367 // contents scale to appropriate values. LayerImpl doesn't calculate any of
368 // them from the other values.
370 void SetBounds(const gfx::Size& bounds);
371 gfx::Size bounds() const;
372 // Like bounds() but doesn't snap to int. Lossy on giant pages (e.g. millions
373 // of pixels) due to use of single precision float.
374 gfx::SizeF BoundsForScrolling() const;
375 void SetBoundsDelta(const gfx::Vector2dF& bounds_delta);
376 gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
378 void SetContentBounds(const gfx::Size& content_bounds);
379 gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
381 float contents_scale_x() const { return draw_properties_.contents_scale_x; }
382 float contents_scale_y() const { return draw_properties_.contents_scale_y; }
383 void SetContentsScale(float contents_scale_x, float contents_scale_y);
385 void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate);
386 void DidScroll();
387 bool IsExternalFlingActive() const;
389 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset);
390 void SetScrollOffsetAndDelta(const gfx::ScrollOffset& scroll_offset,
391 const gfx::Vector2dF& scroll_delta);
392 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; }
394 gfx::ScrollOffset MaxScrollOffset() const;
395 gfx::Vector2dF ClampScrollToMaxScrollOffset();
396 void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer,
397 LayerImpl* scrollbar_clip_layer,
398 bool on_resize) const;
399 void SetScrollDelta(const gfx::Vector2dF& scroll_delta);
400 gfx::Vector2dF ScrollDelta() const;
402 gfx::ScrollOffset TotalScrollOffset() const;
404 void SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta);
405 gfx::Vector2dF sent_scroll_delta() const { return sent_scroll_delta_; }
407 // Returns the delta of the scroll that was outside of the bounds of the
408 // initial scroll
409 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll);
411 void SetScrollClipLayer(int scroll_clip_layer_id);
412 LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; }
413 bool scrollable() const { return !!scroll_clip_layer_; }
415 void set_user_scrollable_horizontal(bool scrollable) {
416 user_scrollable_horizontal_ = scrollable;
418 bool user_scrollable_horizontal() const {
419 return user_scrollable_horizontal_;
421 void set_user_scrollable_vertical(bool scrollable) {
422 user_scrollable_vertical_ = scrollable;
424 bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
426 bool user_scrollable(ScrollbarOrientation orientation) const;
428 void ApplySentScrollDeltasFromAbortedCommit();
429 void ApplyScrollDeltasSinceBeginMainFrame();
431 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) {
432 should_scroll_on_main_thread_ = should_scroll_on_main_thread;
434 bool should_scroll_on_main_thread() const {
435 return should_scroll_on_main_thread_;
438 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) {
439 have_wheel_event_handlers_ = have_wheel_event_handlers;
441 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; }
443 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers) {
444 have_scroll_event_handlers_ = have_scroll_event_handlers;
446 bool have_scroll_event_handlers() const {
447 return have_scroll_event_handlers_;
450 void SetNonFastScrollableRegion(const Region& region) {
451 non_fast_scrollable_region_ = region;
453 const Region& non_fast_scrollable_region() const {
454 return non_fast_scrollable_region_;
457 void SetTouchEventHandlerRegion(const Region& region) {
458 touch_event_handler_region_ = region;
460 const Region& touch_event_handler_region() const {
461 return touch_event_handler_region_;
464 void SetDrawCheckerboardForMissingTiles(bool checkerboard) {
465 draw_checkerboard_for_missing_tiles_ = checkerboard;
467 bool draw_checkerboard_for_missing_tiles() const {
468 return draw_checkerboard_for_missing_tiles_;
471 InputHandler::ScrollStatus TryScroll(
472 const gfx::PointF& screen_space_point,
473 InputHandler::ScrollInputType type) const;
475 void SetDoubleSided(bool double_sided);
476 bool double_sided() const { return double_sided_; }
478 void SetTransform(const gfx::Transform& transform);
479 const gfx::Transform& transform() const { return transform_; }
480 bool TransformIsAnimating() const;
481 bool TransformIsAnimatingOnImplOnly() const;
482 void SetTransformAndInvertibility(const gfx::Transform& transform,
483 bool transform_is_invertible);
484 bool transform_is_invertible() const { return transform_is_invertible_; }
486 // Note this rect is in layer space (not content space).
487 void SetUpdateRect(const gfx::Rect& update_rect);
488 gfx::Rect update_rect() const { return update_rect_; }
490 void AddDamageRect(const gfx::RectF& damage_rect);
492 const gfx::RectF& damage_rect() const { return damage_rect_; }
494 virtual base::DictionaryValue* LayerTreeAsJson() const;
496 void SetStackingOrderChanged(bool stacking_order_changed);
498 bool LayerPropertyChanged() const { return layer_property_changed_; }
500 void ResetAllChangeTrackingForSubtree();
502 LayerAnimationController* layer_animation_controller() {
503 return layer_animation_controller_.get();
506 const LayerAnimationController* layer_animation_controller() const {
507 return layer_animation_controller_.get();
510 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const;
512 virtual void DidBecomeActive();
514 virtual void DidBeginTracing();
516 // Release resources held by this layer. Called when the output surface
517 // that rendered this layer was lost or a rendering mode switch has occured.
518 virtual void ReleaseResources();
520 ScrollbarAnimationController* scrollbar_animation_controller() const {
521 return scrollbar_animation_controller_.get();
524 typedef std::set<ScrollbarLayerImplBase*> ScrollbarSet;
525 ScrollbarSet* scrollbars() { return scrollbars_.get(); }
526 void ClearScrollbars();
527 void AddScrollbar(ScrollbarLayerImplBase* layer);
528 void RemoveScrollbar(ScrollbarLayerImplBase* layer);
529 bool HasScrollbar(ScrollbarOrientation orientation) const;
530 void ScrollbarParametersDidChange(bool on_resize);
531 int clip_height() {
532 return scroll_clip_layer_ ? scroll_clip_layer_->bounds().height() : 0;
535 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const;
537 virtual skia::RefPtr<SkPicture> GetPicture();
539 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
540 virtual void PushPropertiesTo(LayerImpl* layer);
542 virtual void GetAllTilesForTracing(std::set<const Tile*>* tiles) const;
543 virtual void AsValueInto(base::debug::TracedValue* dict) const;
545 virtual size_t GPUMemoryUsageInBytes() const;
547 void SetNeedsPushProperties();
548 void AddDependentNeedsPushProperties();
549 void RemoveDependentNeedsPushProperties();
550 bool parent_should_know_need_push_properties() const {
551 return needs_push_properties() || descendant_needs_push_properties();
554 bool needs_push_properties() const { return needs_push_properties_; }
555 bool descendant_needs_push_properties() const {
556 return num_dependents_need_push_properties_ > 0;
559 virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark);
561 virtual void SetDebugInfo(
562 scoped_refptr<base::debug::ConvertableToTraceFormat> other);
564 bool IsDrawnRenderSurfaceLayerListMember() const;
566 void Set3dSortingContextId(int id);
567 int sorting_context_id() { return sorting_context_id_; }
569 protected:
570 LayerImpl(LayerTreeImpl* layer_impl, int id);
572 // Get the color and size of the layer's debug border.
573 virtual void GetDebugBorderProperties(SkColor* color, float* width) const;
575 void AppendDebugBorderQuad(RenderPass* render_pass,
576 const gfx::Size& content_bounds,
577 const SharedQuadState* shared_quad_state,
578 AppendQuadsData* append_quads_data) const;
579 void AppendDebugBorderQuad(RenderPass* render_pass,
580 const gfx::Size& content_bounds,
581 const SharedQuadState* shared_quad_state,
582 AppendQuadsData* append_quads_data,
583 SkColor color,
584 float width) const;
586 void NoteLayerPropertyChanged();
587 void NoteLayerPropertyChangedForSubtree();
589 // Note carefully this does not affect the current layer.
590 void NoteLayerPropertyChangedForDescendants();
592 private:
593 void NoteLayerPropertyChangedForDescendantsInternal();
595 virtual const char* LayerTypeAsString() const;
597 // Properties internal to LayerImpl
598 LayerImpl* parent_;
599 OwnedLayerImplList children_;
601 LayerImpl* scroll_parent_;
603 // Storing a pointer to a set rather than a set since this will be rarely
604 // used. If this pointer turns out to be too heavy, we could have this (and
605 // the scroll parent above) be stored in a LayerImpl -> scroll_info
606 // map somewhere.
607 scoped_ptr<std::set<LayerImpl*>> scroll_children_;
609 LayerImpl* clip_parent_;
610 scoped_ptr<std::set<LayerImpl*>> clip_children_;
612 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
613 // confirm newly assigned layer is still the previous one
614 int mask_layer_id_;
615 scoped_ptr<LayerImpl> mask_layer_;
616 int replica_layer_id_; // ditto
617 scoped_ptr<LayerImpl> replica_layer_;
618 int layer_id_;
619 LayerTreeImpl* layer_tree_impl_;
621 // Properties synchronized from the associated Layer.
622 gfx::Point3F transform_origin_;
623 gfx::Size bounds_;
624 gfx::Vector2dF bounds_delta_;
625 gfx::ScrollOffset scroll_offset_;
626 ScrollOffsetDelegate* scroll_offset_delegate_;
627 LayerImpl* scroll_clip_layer_;
628 bool scrollable_ : 1;
629 bool should_scroll_on_main_thread_ : 1;
630 bool have_wheel_event_handlers_ : 1;
631 bool have_scroll_event_handlers_ : 1;
632 bool user_scrollable_horizontal_ : 1;
633 bool user_scrollable_vertical_ : 1;
634 bool stacking_order_changed_ : 1;
635 // Whether the "back" of this layer should draw.
636 bool double_sided_ : 1;
637 bool should_flatten_transform_ : 1;
639 // Tracks if drawing-related properties have changed since last redraw.
640 bool layer_property_changed_ : 1;
642 bool masks_to_bounds_ : 1;
643 bool contents_opaque_ : 1;
644 bool is_root_for_isolated_group_ : 1;
645 bool use_parent_backface_visibility_ : 1;
646 bool draw_checkerboard_for_missing_tiles_ : 1;
647 bool draws_content_ : 1;
648 bool hide_layer_and_subtree_ : 1;
650 // Cache transform_'s invertibility.
651 bool transform_is_invertible_ : 1;
653 // Set for the layer that other layers are fixed to.
654 bool is_container_for_fixed_position_layers_ : 1;
655 Region non_fast_scrollable_region_;
656 Region touch_event_handler_region_;
657 SkColor background_color_;
659 float opacity_;
660 SkXfermode::Mode blend_mode_;
661 gfx::PointF position_;
662 gfx::Transform transform_;
664 LayerPositionConstraint position_constraint_;
666 gfx::Vector2dF scroll_delta_;
667 gfx::Vector2dF sent_scroll_delta_;
668 gfx::ScrollOffset last_scroll_offset_;
670 int num_descendants_that_draw_content_;
672 // The global depth value of the center of the layer. This value is used
673 // to sort layers from back to front.
674 float draw_depth_;
676 FilterOperations filters_;
677 FilterOperations background_filters_;
679 protected:
680 friend class TreeSynchronizer;
682 // This flag is set when the layer needs to push properties to the active
683 // side.
684 bool needs_push_properties_;
686 // The number of direct children or dependent layers that need to be recursed
687 // to in order for them or a descendent of them to push properties to the
688 // active side.
689 int num_dependents_need_push_properties_;
691 // Layers that share a sorting context id will be sorted together in 3d
692 // space. 0 is a special value that means this layer will not be sorted and
693 // will be drawn in paint order.
694 int sorting_context_id_;
696 DrawMode current_draw_mode_;
698 private:
699 // Rect indicating what was repainted/updated during update.
700 // Note that plugin layers bypass this and leave it empty.
701 // Uses layer (not content) space.
702 gfx::Rect update_rect_;
704 // This rect is in layer space.
705 gfx::RectF damage_rect_;
707 // Manages animations for this layer.
708 scoped_refptr<LayerAnimationController> layer_animation_controller_;
710 // Manages scrollbars for this layer
711 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_;
713 scoped_ptr<ScrollbarSet> scrollbars_;
715 ScopedPtrVector<CopyOutputRequest> copy_requests_;
717 // Group of properties that need to be computed based on the layer tree
718 // hierarchy before layers can be drawn.
719 DrawProperties<LayerImpl> draw_properties_;
721 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_;
722 scoped_ptr<RenderSurfaceImpl> render_surface_;
723 DISALLOW_COPY_AND_ASSIGN(LayerImpl);
726 } // namespace cc
728 #endif // CC_LAYERS_LAYER_IMPL_H_