1 // Copyright 2010 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. 4 5 #ifndef CC_LAYERS_LAYER_H_ 6 #define CC_LAYERS_LAYER_H_ 7 8 #include <set> 9 #include <string> 10 11 #include "base/callback.h" 12 #include "base/memory/ref_counted.h" 13 #include "base/observer_list.h" 14 #include "cc/animation/layer_animation_controller.h" 15 #include "cc/animation/layer_animation_value_observer.h" 16 #include "cc/animation/layer_animation_value_provider.h" 17 #include "cc/base/cc_export.h" 18 #include "cc/base/region.h" 19 #include "cc/base/scoped_ptr_vector.h" 20 #include "cc/debug/micro_benchmark.h" 21 #include "cc/layers/draw_properties.h" 22 #include "cc/layers/layer_lists.h" 23 #include "cc/layers/layer_position_constraint.h" 24 #include "cc/layers/paint_properties.h" 25 #include "cc/layers/render_surface.h" 26 #include "cc/output/filter_operations.h" 27 #include "skia/ext/refptr.h" 28 #include "third_party/skia/include/core/SkColor.h" 29 #include "third_party/skia/include/core/SkImageFilter.h" 30 #include "third_party/skia/include/core/SkPicture.h" 31 #include "third_party/skia/include/core/SkXfermode.h" 32 #include "ui/gfx/point3_f.h" 33 #include "ui/gfx/rect.h" 34 #include "ui/gfx/rect_f.h" 35 #include "ui/gfx/transform.h" 36 37 namespace gfx { 38 class BoxF; 39 } 40 41 namespace base { 42 namespace debug { 43 class ConvertableToTraceFormat; 44 } 45 } 46 47 namespace cc { 48 49 class Animation; 50 class AnimationDelegate; 51 struct AnimationEvent; 52 class CopyOutputRequest; 53 class LayerAnimationDelegate; 54 class LayerAnimationEventObserver; 55 class LayerClient; 56 class LayerImpl; 57 class LayerTreeHost; 58 class LayerTreeImpl; 59 class PriorityCalculator; 60 class RenderingStatsInstrumentation; 61 class ResourceUpdateQueue; 62 class ScrollbarLayerInterface; 63 class SimpleEnclosedRegion; 64 struct AnimationEvent; 65 template <typename LayerType> 66 class OcclusionTracker; 67 68 // Base class for composited layers. Special layer types are derived from 69 // this class. 70 class CC_EXPORT Layer : public base::RefCounted<Layer>, 71 public LayerAnimationValueObserver, 72 public LayerAnimationValueProvider { 73 public: 74 typedef RenderSurfaceLayerList RenderSurfaceListType; 75 typedef LayerList LayerListType; 76 typedef RenderSurface RenderSurfaceType; 77 78 enum LayerIdLabels { 79 INVALID_ID = -1, 80 }; 81 82 static scoped_refptr<Layer> Create(); 83 id()84 int id() const { return layer_id_; } 85 86 Layer* RootLayer(); parent()87 Layer* parent() { return parent_; } parent()88 const Layer* parent() const { return parent_; } 89 void AddChild(scoped_refptr<Layer> child); 90 void InsertChild(scoped_refptr<Layer> child, size_t index); 91 void ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer); 92 void RemoveFromParent(); 93 void RemoveAllChildren(); 94 void SetChildren(const LayerList& children); 95 bool HasAncestor(const Layer* ancestor) const; 96 children()97 const LayerList& children() const { return children_; } child_at(size_t index)98 Layer* child_at(size_t index) { return children_[index].get(); } 99 100 // This requests the layer and its subtree be rendered and given to the 101 // callback. If the copy is unable to be produced (the layer is destroyed 102 // first), then the callback is called with a NULL/empty result. 103 void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> request); HasCopyRequest()104 bool HasCopyRequest() const { 105 return !copy_requests_.empty(); 106 } 107 108 virtual void SetBackgroundColor(SkColor background_color); background_color()109 SkColor background_color() const { return background_color_; } 110 // If contents_opaque(), return an opaque color else return a 111 // non-opaque color. Tries to return background_color(), if possible. 112 SkColor SafeOpaqueBackgroundColor() const; 113 114 // A layer's bounds are in logical, non-page-scaled pixels (however, the 115 // root layer's bounds are in physical pixels). 116 void SetBounds(const gfx::Size& bounds); bounds()117 gfx::Size bounds() const { return bounds_; } 118 119 void SetMasksToBounds(bool masks_to_bounds); masks_to_bounds()120 bool masks_to_bounds() const { return masks_to_bounds_; } 121 122 void SetMaskLayer(Layer* mask_layer); mask_layer()123 Layer* mask_layer() { return mask_layer_.get(); } mask_layer()124 const Layer* mask_layer() const { return mask_layer_.get(); } 125 126 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect); SetNeedsDisplay()127 void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::RectF(bounds())); } 128 129 void SetOpacity(float opacity); opacity()130 float opacity() const { return opacity_; } 131 bool OpacityIsAnimating() const; 132 virtual bool OpacityCanAnimateOnImplThread() const; 133 134 void SetBlendMode(SkXfermode::Mode blend_mode); blend_mode()135 SkXfermode::Mode blend_mode() const { return blend_mode_; } 136 uses_default_blend_mode()137 bool uses_default_blend_mode() const { 138 return blend_mode_ == SkXfermode::kSrcOver_Mode; 139 } 140 141 // A layer is root for an isolated group when it and all its descendants are 142 // drawn over a black and fully transparent background, creating an isolated 143 // group. It should be used along with SetBlendMode(), in order to restrict 144 // layers within the group to blend with layers outside this group. 145 void SetIsRootForIsolatedGroup(bool root); is_root_for_isolated_group()146 bool is_root_for_isolated_group() const { 147 return is_root_for_isolated_group_; 148 } 149 150 void SetFilters(const FilterOperations& filters); filters()151 const FilterOperations& filters() const { return filters_; } 152 bool FilterIsAnimating() const; 153 154 // Background filters are filters applied to what is behind this layer, when 155 // they are viewed through non-opaque regions in this layer. They are used 156 // through the WebLayer interface, and are not exposed to HTML. 157 void SetBackgroundFilters(const FilterOperations& filters); background_filters()158 const FilterOperations& background_filters() const { 159 return background_filters_; 160 } 161 162 virtual void SetContentsOpaque(bool opaque); contents_opaque()163 bool contents_opaque() const { return contents_opaque_; } 164 165 void SetPosition(const gfx::PointF& position); position()166 gfx::PointF position() const { return position_; } 167 168 void SetIsContainerForFixedPositionLayers(bool container); 169 bool IsContainerForFixedPositionLayers() const; 170 171 void SetPositionConstraint(const LayerPositionConstraint& constraint); position_constraint()172 const LayerPositionConstraint& position_constraint() const { 173 return position_constraint_; 174 } 175 176 void SetTransform(const gfx::Transform& transform); transform()177 const gfx::Transform& transform() const { return transform_; } 178 bool TransformIsAnimating() const; transform_is_invertible()179 bool transform_is_invertible() const { return transform_is_invertible_; } 180 181 void SetTransformOrigin(const gfx::Point3F&); transform_origin()182 gfx::Point3F transform_origin() { return transform_origin_; } 183 184 void SetScrollParent(Layer* parent); 185 scroll_parent()186 Layer* scroll_parent() { return scroll_parent_; } scroll_parent()187 const Layer* scroll_parent() const { return scroll_parent_; } 188 189 void AddScrollChild(Layer* child); 190 void RemoveScrollChild(Layer* child); 191 scroll_children()192 std::set<Layer*>* scroll_children() { return scroll_children_.get(); } scroll_children()193 const std::set<Layer*>* scroll_children() const { 194 return scroll_children_.get(); 195 } 196 197 void SetClipParent(Layer* ancestor); 198 clip_parent()199 Layer* clip_parent() { return clip_parent_; } clip_parent()200 const Layer* clip_parent() const { 201 return clip_parent_; 202 } 203 204 void AddClipChild(Layer* child); 205 void RemoveClipChild(Layer* child); 206 clip_children()207 std::set<Layer*>* clip_children() { return clip_children_.get(); } clip_children()208 const std::set<Layer*>* clip_children() const { 209 return clip_children_.get(); 210 } 211 draw_properties()212 DrawProperties<Layer>& draw_properties() { return draw_properties_; } draw_properties()213 const DrawProperties<Layer>& draw_properties() const { 214 return draw_properties_; 215 } 216 217 // The following are shortcut accessors to get various information from 218 // draw_properties_ draw_transform()219 const gfx::Transform& draw_transform() const { 220 return draw_properties_.target_space_transform; 221 } screen_space_transform()222 const gfx::Transform& screen_space_transform() const { 223 return draw_properties_.screen_space_transform; 224 } draw_opacity()225 float draw_opacity() const { return draw_properties_.opacity; } draw_opacity_is_animating()226 bool draw_opacity_is_animating() const { 227 return draw_properties_.opacity_is_animating; 228 } draw_transform_is_animating()229 bool draw_transform_is_animating() const { 230 return draw_properties_.target_space_transform_is_animating; 231 } screen_space_transform_is_animating()232 bool screen_space_transform_is_animating() const { 233 return draw_properties_.screen_space_transform_is_animating; 234 } screen_space_opacity_is_animating()235 bool screen_space_opacity_is_animating() const { 236 return draw_properties_.screen_space_opacity_is_animating; 237 } can_use_lcd_text()238 bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; } is_clipped()239 bool is_clipped() const { return draw_properties_.is_clipped; } clip_rect()240 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; } drawable_content_rect()241 gfx::Rect drawable_content_rect() const { 242 return draw_properties_.drawable_content_rect; 243 } visible_content_rect()244 gfx::Rect visible_content_rect() const { 245 return draw_properties_.visible_content_rect; 246 } render_target()247 Layer* render_target() { 248 DCHECK(!draw_properties_.render_target || 249 draw_properties_.render_target->render_surface()); 250 return draw_properties_.render_target; 251 } render_target()252 const Layer* render_target() const { 253 DCHECK(!draw_properties_.render_target || 254 draw_properties_.render_target->render_surface()); 255 return draw_properties_.render_target; 256 } render_surface()257 RenderSurface* render_surface() const { 258 return draw_properties_.render_surface.get(); 259 } num_unclipped_descendants()260 int num_unclipped_descendants() const { 261 return draw_properties_.num_unclipped_descendants; 262 } 263 264 void SetScrollOffset(gfx::Vector2d scroll_offset); scroll_offset()265 gfx::Vector2d scroll_offset() const { return scroll_offset_; } 266 void SetScrollOffsetFromImplSide(const gfx::Vector2d& scroll_offset); 267 268 void SetScrollClipLayerId(int clip_layer_id); scrollable()269 bool scrollable() const { return scroll_clip_layer_id_ != INVALID_ID; } 270 271 void SetUserScrollable(bool horizontal, bool vertical); user_scrollable_horizontal()272 bool user_scrollable_horizontal() const { 273 return user_scrollable_horizontal_; 274 } user_scrollable_vertical()275 bool user_scrollable_vertical() const { return user_scrollable_vertical_; } 276 277 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread); should_scroll_on_main_thread()278 bool should_scroll_on_main_thread() const { 279 return should_scroll_on_main_thread_; 280 } 281 282 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers); have_wheel_event_handlers()283 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; } 284 285 void SetHaveScrollEventHandlers(bool have_scroll_event_handlers); have_scroll_event_handlers()286 bool have_scroll_event_handlers() const { 287 return have_scroll_event_handlers_; 288 } 289 290 void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region); non_fast_scrollable_region()291 const Region& non_fast_scrollable_region() const { 292 return non_fast_scrollable_region_; 293 } 294 295 void SetTouchEventHandlerRegion(const Region& touch_event_handler_region); touch_event_handler_region()296 const Region& touch_event_handler_region() const { 297 return touch_event_handler_region_; 298 } 299 set_did_scroll_callback(const base::Closure & callback)300 void set_did_scroll_callback(const base::Closure& callback) { 301 did_scroll_callback_ = callback; 302 } 303 304 void SetDrawCheckerboardForMissingTiles(bool checkerboard); draw_checkerboard_for_missing_tiles()305 bool draw_checkerboard_for_missing_tiles() const { 306 return draw_checkerboard_for_missing_tiles_; 307 } 308 309 void SetForceRenderSurface(bool force_render_surface); force_render_surface()310 bool force_render_surface() const { return force_render_surface_; } 311 ScrollDelta()312 gfx::Vector2d ScrollDelta() const { return gfx::Vector2d(); } TotalScrollOffset()313 gfx::Vector2dF TotalScrollOffset() const { 314 // Floating point to match the LayerImpl version. 315 return scroll_offset() + ScrollDelta(); 316 } 317 318 void SetDoubleSided(bool double_sided); double_sided()319 bool double_sided() const { return double_sided_; } 320 321 void SetShouldFlattenTransform(bool flatten); should_flatten_transform()322 bool should_flatten_transform() const { return should_flatten_transform_; } 323 Is3dSorted()324 bool Is3dSorted() const { return sorting_context_id_ != 0; } 325 set_use_parent_backface_visibility(bool use)326 void set_use_parent_backface_visibility(bool use) { 327 use_parent_backface_visibility_ = use; 328 } use_parent_backface_visibility()329 bool use_parent_backface_visibility() const { 330 return use_parent_backface_visibility_; 331 } 332 333 virtual void SetLayerTreeHost(LayerTreeHost* host); 334 335 virtual bool HasDelegatedContent() const; HasContributingDelegatedRenderPasses()336 bool HasContributingDelegatedRenderPasses() const { return false; } 337 338 void SetIsDrawable(bool is_drawable); 339 340 void SetHideLayerAndSubtree(bool hide); hide_layer_and_subtree()341 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; } 342 343 void SetReplicaLayer(Layer* layer); replica_layer()344 Layer* replica_layer() { return replica_layer_.get(); } replica_layer()345 const Layer* replica_layer() const { return replica_layer_.get(); } 346 has_mask()347 bool has_mask() const { return !!mask_layer_.get(); } has_replica()348 bool has_replica() const { return !!replica_layer_.get(); } replica_has_mask()349 bool replica_has_mask() const { 350 return replica_layer_.get() && 351 (mask_layer_.get() || replica_layer_->mask_layer_.get()); 352 } 353 354 int NumDescendantsThatDrawContent() const; 355 356 // This is only virtual for tests. 357 // TODO(awoloszyn): Remove this once we no longer need it for tests 358 virtual bool DrawsContent() const; 359 360 // This methods typically need to be overwritten by derived classes. 361 virtual void SavePaintProperties(); 362 // Returns true iff any resources were updated that need to be committed. 363 virtual bool Update(ResourceUpdateQueue* queue, 364 const OcclusionTracker<Layer>* occlusion); 365 virtual bool NeedMoreUpdates(); SetIsMask(bool is_mask)366 virtual void SetIsMask(bool is_mask) {} ReduceMemoryUsage()367 virtual void ReduceMemoryUsage() {} OnOutputSurfaceCreated()368 virtual void OnOutputSurfaceCreated() {} 369 virtual bool IsSuitableForGpuRasterization() const; 370 371 virtual scoped_refptr<base::debug::ConvertableToTraceFormat> TakeDebugInfo(); 372 SetLayerClient(LayerClient * client)373 void SetLayerClient(LayerClient* client) { client_ = client; } 374 375 virtual void PushPropertiesTo(LayerImpl* layer); 376 377 void CreateRenderSurface(); 378 void ClearRenderSurface(); 379 void ClearRenderSurfaceLayerList(); 380 381 // The contents scale converts from logical, non-page-scaled pixels to target 382 // pixels. The contents scale is 1 for the root layer as it is already in 383 // physical pixels. By default contents scale is forced to be 1 except for 384 // subclasses of ContentsScalingLayer. contents_scale_x()385 float contents_scale_x() const { return draw_properties_.contents_scale_x; } contents_scale_y()386 float contents_scale_y() const { return draw_properties_.contents_scale_y; } content_bounds()387 gfx::Size content_bounds() const { return draw_properties_.content_bounds; } 388 389 virtual void CalculateContentsScale(float ideal_contents_scale, 390 float* contents_scale_x, 391 float* contents_scale_y, 392 gfx::Size* content_bounds); 393 layer_tree_host()394 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } layer_tree_host()395 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } 396 397 // Set the priority of all desired textures in this layer. SetTexturePriorities(const PriorityCalculator & priority_calc)398 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) {} 399 400 bool AddAnimation(scoped_ptr<Animation> animation); 401 void PauseAnimation(int animation_id, double time_offset); 402 void RemoveAnimation(int animation_id); 403 layer_animation_controller()404 LayerAnimationController* layer_animation_controller() { 405 return layer_animation_controller_.get(); 406 } 407 void SetLayerAnimationControllerForTest( 408 scoped_refptr<LayerAnimationController> controller); 409 set_layer_animation_delegate(AnimationDelegate * delegate)410 void set_layer_animation_delegate(AnimationDelegate* delegate) { 411 layer_animation_controller_->set_layer_animation_delegate(delegate); 412 } 413 414 bool HasActiveAnimation() const; 415 416 void AddLayerAnimationEventObserver( 417 LayerAnimationEventObserver* animation_observer); 418 void RemoveLayerAnimationEventObserver( 419 LayerAnimationEventObserver* animation_observer); 420 421 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const; 422 423 virtual ScrollbarLayerInterface* ToScrollbarLayer(); 424 425 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const; 426 427 virtual skia::RefPtr<SkPicture> GetPicture() const; 428 429 // Constructs a LayerImpl of the correct runtime type for this Layer type. 430 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); 431 NeedsDisplayForTesting()432 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } ResetNeedsDisplayForTesting()433 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::RectF(); } 434 435 RenderingStatsInstrumentation* rendering_stats_instrumentation() const; 436 paint_properties()437 const PaintProperties& paint_properties() const { 438 return paint_properties_; 439 } 440 441 // The scale at which contents should be rastered, to match the scale at 442 // which they will drawn to the screen. This scale is a component of the 443 // contents scale but does not include page/device scale factors. 444 // TODO(danakj): This goes away when TiledLayer goes away. set_raster_scale(float scale)445 void set_raster_scale(float scale) { raster_scale_ = scale; } raster_scale()446 float raster_scale() const { return raster_scale_; } raster_scale_is_unknown()447 bool raster_scale_is_unknown() const { return raster_scale_ == 0.f; } 448 449 virtual bool SupportsLCDText() const; 450 451 void SetNeedsPushProperties(); needs_push_properties()452 bool needs_push_properties() const { return needs_push_properties_; } descendant_needs_push_properties()453 bool descendant_needs_push_properties() const { 454 return num_dependents_need_push_properties_ > 0; 455 } reset_needs_push_properties_for_testing()456 void reset_needs_push_properties_for_testing() { 457 needs_push_properties_ = false; 458 } 459 460 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); 461 462 void Set3dSortingContextId(int id); sorting_context_id()463 int sorting_context_id() const { return sorting_context_id_; } 464 465 protected: 466 friend class LayerImpl; 467 friend class TreeSynchronizer; 468 virtual ~Layer(); 469 470 Layer(); 471 472 // These SetNeeds functions are in order of severity of update: 473 // 474 // Called when this layer has been modified in some way, but isn't sure 475 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers 476 // before it knows whether or not a commit is required. 477 void SetNeedsUpdate(); 478 // Called when a property has been modified in a way that the layer 479 // knows immediately that a commit is required. This implies SetNeedsUpdate 480 // as well as SetNeedsPushProperties to push that property. 481 void SetNeedsCommit(); 482 // Called when there's been a change in layer structure. Implies both 483 // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties. 484 void SetNeedsFullTreeSync(); 485 486 // Called when the next commit should wait until the pending tree is activated 487 // before finishing the commit and unblocking the main thread. Used to ensure 488 // unused resources on the impl thread are returned before commit completes. 489 void SetNextCommitWaitsForActivation(); 490 491 // Will recalculate whether the layer draws content and set draws_content_ 492 // appropriately. 493 void UpdateDrawsContent(bool has_drawable_content); 494 virtual bool HasDrawableContent() const; 495 496 // Called when the layer's number of drawable descendants changes. 497 void AddDrawableDescendants(int num); 498 499 void AddDependentNeedsPushProperties(); 500 void RemoveDependentNeedsPushProperties(); parent_should_know_need_push_properties()501 bool parent_should_know_need_push_properties() const { 502 return needs_push_properties() || descendant_needs_push_properties(); 503 } 504 505 bool IsPropertyChangeAllowed() const; 506 reset_raster_scale_to_unknown()507 void reset_raster_scale_to_unknown() { raster_scale_ = 0.f; } 508 509 // This flag is set when the layer needs to push properties to the impl 510 // side. 511 bool needs_push_properties_; 512 513 // The number of direct children or dependent layers that need to be recursed 514 // to in order for them or a descendent of them to push properties to the impl 515 // side. 516 int num_dependents_need_push_properties_; 517 518 // Tracks whether this layer may have changed stacking order with its 519 // siblings. 520 bool stacking_order_changed_; 521 522 // The update rect is the region of the compositor resource that was 523 // actually updated by the compositor. For layers that may do updating 524 // outside the compositor's control (i.e. plugin layers), this information 525 // is not available and the update rect will remain empty. 526 // Note this rect is in layer space (not content space). 527 gfx::RectF update_rect_; 528 529 scoped_refptr<Layer> mask_layer_; 530 531 int layer_id_; 532 533 // When true, the layer is about to perform an update. Any commit requests 534 // will be handled implicitly after the update completes. 535 bool ignore_set_needs_commit_; 536 537 // Layers that share a sorting context id will be sorted together in 3d 538 // space. 0 is a special value that means this layer will not be sorted and 539 // will be drawn in paint order. 540 int sorting_context_id_; 541 542 private: 543 friend class base::RefCounted<Layer>; 544 545 void SetParent(Layer* layer); 546 bool DescendantIsFixedToContainerLayer() const; 547 548 // Returns the index of the child or -1 if not found. 549 int IndexOfChild(const Layer* reference); 550 551 // This should only be called from RemoveFromParent(). 552 void RemoveChildOrDependent(Layer* child); 553 554 // LayerAnimationValueProvider implementation. 555 virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE; 556 557 // LayerAnimationValueObserver implementation. 558 virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE; 559 virtual void OnOpacityAnimated(float opacity) OVERRIDE; 560 virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE; 561 virtual void OnScrollOffsetAnimated( 562 const gfx::Vector2dF& scroll_offset) OVERRIDE; 563 virtual void OnAnimationWaitingForDeletion() OVERRIDE; 564 virtual bool IsActive() const OVERRIDE; 565 566 // If this layer has a scroll parent, it removes |this| from its list of 567 // scroll children. 568 void RemoveFromScrollTree(); 569 570 // If this layer has a clip parent, it removes |this| from its list of clip 571 // children. 572 void RemoveFromClipTree(); 573 574 LayerList children_; 575 Layer* parent_; 576 577 // Layer instances have a weak pointer to their LayerTreeHost. 578 // This pointer value is nil when a Layer is not in a tree and is 579 // updated via SetLayerTreeHost() if a layer moves between trees. 580 LayerTreeHost* layer_tree_host_; 581 582 scoped_refptr<LayerAnimationController> layer_animation_controller_; 583 584 // Layer properties. 585 gfx::Size bounds_; 586 587 gfx::Vector2d scroll_offset_; 588 // This variable indicates which ancestor layer (if any) whose size, 589 // transformed relative to this layer, defines the maximum scroll offset for 590 // this layer. 591 int scroll_clip_layer_id_; 592 int num_descendants_that_draw_content_; 593 bool should_scroll_on_main_thread_ : 1; 594 bool have_wheel_event_handlers_ : 1; 595 bool have_scroll_event_handlers_ : 1; 596 bool user_scrollable_horizontal_ : 1; 597 bool user_scrollable_vertical_ : 1; 598 bool is_root_for_isolated_group_ : 1; 599 bool is_container_for_fixed_position_layers_ : 1; 600 bool is_drawable_ : 1; 601 bool draws_content_ : 1; 602 bool hide_layer_and_subtree_ : 1; 603 bool masks_to_bounds_ : 1; 604 bool contents_opaque_ : 1; 605 bool double_sided_ : 1; 606 bool should_flatten_transform_ : 1; 607 bool use_parent_backface_visibility_ : 1; 608 bool draw_checkerboard_for_missing_tiles_ : 1; 609 bool force_render_surface_ : 1; 610 bool transform_is_invertible_ : 1; 611 Region non_fast_scrollable_region_; 612 Region touch_event_handler_region_; 613 gfx::PointF position_; 614 SkColor background_color_; 615 float opacity_; 616 SkXfermode::Mode blend_mode_; 617 FilterOperations filters_; 618 FilterOperations background_filters_; 619 LayerPositionConstraint position_constraint_; 620 Layer* scroll_parent_; 621 scoped_ptr<std::set<Layer*> > scroll_children_; 622 623 Layer* clip_parent_; 624 scoped_ptr<std::set<Layer*> > clip_children_; 625 626 gfx::Transform transform_; 627 gfx::Point3F transform_origin_; 628 629 // Replica layer used for reflections. 630 scoped_refptr<Layer> replica_layer_; 631 632 // Transient properties. 633 float raster_scale_; 634 635 LayerClient* client_; 636 637 ScopedPtrVector<CopyOutputRequest> copy_requests_; 638 639 base::Closure did_scroll_callback_; 640 641 DrawProperties<Layer> draw_properties_; 642 643 PaintProperties paint_properties_; 644 645 DISALLOW_COPY_AND_ASSIGN(Layer); 646 }; 647 648 } // namespace cc 649 650 #endif // CC_LAYERS_LAYER_H_ 651