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. 4 5 #ifndef CC_LAYERS_LAYER_IMPL_H_ 6 #define CC_LAYERS_LAYER_IMPL_H_ 7 8 #include <set> 9 #include <string> 10 11 #include "base/logging.h" 12 #include "base/memory/scoped_ptr.h" 13 #include "base/values.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/input/input_handler.h" 21 #include "cc/layers/compositing_reasons.h" 22 #include "cc/layers/draw_properties.h" 23 #include "cc/layers/layer_lists.h" 24 #include "cc/layers/layer_position_constraint.h" 25 #include "cc/layers/render_surface_impl.h" 26 #include "cc/output/filter_operations.h" 27 #include "cc/quads/render_pass.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/rect.h" 35 #include "ui/gfx/rect_f.h" 36 #include "ui/gfx/transform.h" 37 38 namespace base { 39 namespace debug { 40 class ConvertableToTraceFormat; 41 } 42 43 class DictionaryValue; 44 } 45 46 namespace cc { 47 48 class LayerTreeHostImpl; 49 class LayerTreeImpl; 50 class MicroBenchmarkImpl; 51 class QuadSink; 52 class Renderer; 53 class ScrollbarAnimationController; 54 class ScrollbarLayerImplBase; 55 56 struct AppendQuadsData; 57 58 enum DrawMode { 59 DRAW_MODE_NONE, 60 DRAW_MODE_HARDWARE, 61 DRAW_MODE_SOFTWARE, 62 DRAW_MODE_RESOURCELESS_SOFTWARE 63 }; 64 65 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, 66 public LayerAnimationValueProvider { 67 public: 68 typedef LayerImplList RenderSurfaceListType; 69 typedef LayerImplList LayerListType; 70 typedef RenderSurfaceImpl RenderSurfaceType; 71 Create(LayerTreeImpl * tree_impl,int id)72 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 73 return make_scoped_ptr(new LayerImpl(tree_impl, id)); 74 } 75 76 virtual ~LayerImpl(); 77 id()78 int id() const { return layer_id_; } 79 80 // LayerAnimationValueProvider implementation. 81 virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE; 82 83 // LayerAnimationValueObserver implementation. 84 virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE; 85 virtual void OnOpacityAnimated(float opacity) OVERRIDE; 86 virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE; 87 virtual void OnScrollOffsetAnimated(gfx::Vector2dF scroll_offset) OVERRIDE; 88 virtual void OnAnimationWaitingForDeletion() OVERRIDE; 89 virtual bool IsActive() const OVERRIDE; 90 91 // Tree structure. parent()92 LayerImpl* parent() { return parent_; } parent()93 const LayerImpl* parent() const { return parent_; } children()94 const OwnedLayerImplList& children() const { return children_; } children()95 OwnedLayerImplList& children() { return children_; } child_at(size_t index)96 LayerImpl* child_at(size_t index) const { return children_[index]; } 97 void AddChild(scoped_ptr<LayerImpl> child); 98 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child); set_parent(LayerImpl * parent)99 void set_parent(LayerImpl* parent) { parent_ = parent; } 100 // Warning: This does not preserve tree structure invariants. 101 void ClearChildList(); 102 103 bool HasAncestor(const LayerImpl* ancestor) const; 104 105 void SetScrollParent(LayerImpl* parent); 106 scroll_parent()107 LayerImpl* scroll_parent() { return scroll_parent_; } scroll_parent()108 const LayerImpl* scroll_parent() const { return scroll_parent_; } 109 110 void SetScrollChildren(std::set<LayerImpl*>* children); 111 void RemoveScrollChild(LayerImpl* child); 112 scroll_children()113 std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); } scroll_children()114 const std::set<LayerImpl*>* scroll_children() const { 115 return scroll_children_.get(); 116 } 117 118 void SetClipParent(LayerImpl* ancestor); 119 clip_parent()120 LayerImpl* clip_parent() { 121 return clip_parent_; 122 } clip_parent()123 const LayerImpl* clip_parent() const { 124 return clip_parent_; 125 } 126 127 void SetClipChildren(std::set<LayerImpl*>* children); 128 void RemoveClipChild(LayerImpl* child); 129 clip_children()130 std::set<LayerImpl*>* clip_children() { return clip_children_.get(); } clip_children()131 const std::set<LayerImpl*>* clip_children() const { 132 return clip_children_.get(); 133 } 134 135 void PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests); 136 void TakeCopyRequestsAndTransformToTarget( 137 ScopedPtrVector<CopyOutputRequest>* request); HasCopyRequest()138 bool HasCopyRequest() const { return !copy_requests_.empty(); } 139 140 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer); mask_layer()141 LayerImpl* mask_layer() { return mask_layer_.get(); } mask_layer()142 const LayerImpl* mask_layer() const { return mask_layer_.get(); } 143 scoped_ptr<LayerImpl> TakeMaskLayer(); 144 145 void SetReplicaLayer(scoped_ptr<LayerImpl> replica_layer); replica_layer()146 LayerImpl* replica_layer() { return replica_layer_.get(); } replica_layer()147 const LayerImpl* replica_layer() const { return replica_layer_.get(); } 148 scoped_ptr<LayerImpl> TakeReplicaLayer(); 149 has_mask()150 bool has_mask() const { return mask_layer_; } has_replica()151 bool has_replica() const { return replica_layer_; } replica_has_mask()152 bool replica_has_mask() const { 153 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_); 154 } 155 layer_tree_impl()156 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } 157 158 scoped_ptr<SharedQuadState> CreateSharedQuadState() const; 159 // WillDraw must be called before AppendQuads. If WillDraw returns false, 160 // AppendQuads and DidDraw will not be called. If WillDraw returns true, 161 // DidDraw is guaranteed to be called before another WillDraw or before 162 // the layer is destroyed. To enforce this, any class that overrides 163 // WillDraw/DidDraw must call the base class version only if WillDraw 164 // returns true. 165 virtual bool WillDraw(DrawMode draw_mode, 166 ResourceProvider* resource_provider); AppendQuads(QuadSink * quad_sink,AppendQuadsData * append_quads_data)167 virtual void AppendQuads(QuadSink* quad_sink, 168 AppendQuadsData* append_quads_data) {} 169 virtual void DidDraw(ResourceProvider* resource_provider); 170 171 virtual ResourceProvider::ResourceId ContentsResourceId() const; 172 173 virtual bool HasDelegatedContent() const; 174 virtual bool HasContributingDelegatedRenderPasses() const; 175 virtual RenderPass::Id FirstContributingRenderPassId() const; 176 virtual RenderPass::Id NextContributingRenderPassId(RenderPass::Id id) const; 177 UpdateTilePriorities()178 virtual void UpdateTilePriorities() {} 179 180 virtual ScrollbarLayerImplBase* ToScrollbarLayer(); 181 182 // Returns true if this layer has content to draw. 183 void SetDrawsContent(bool draws_content); DrawsContent()184 bool DrawsContent() const { return draws_content_; } 185 186 void SetHideLayerAndSubtree(bool hide); hide_layer_and_subtree()187 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; } 188 force_render_surface()189 bool force_render_surface() const { return force_render_surface_; } SetForceRenderSurface(bool force)190 void SetForceRenderSurface(bool force) { force_render_surface_ = force; } 191 192 void SetAnchorPoint(gfx::PointF anchor_point); anchor_point()193 gfx::PointF anchor_point() const { return anchor_point_; } 194 195 void SetAnchorPointZ(float anchor_point_z); anchor_point_z()196 float anchor_point_z() const { return anchor_point_z_; } 197 198 void SetBackgroundColor(SkColor background_color); background_color()199 SkColor background_color() const { return background_color_; } 200 // If contents_opaque(), return an opaque color else return a 201 // non-opaque color. Tries to return background_color(), if possible. 202 SkColor SafeOpaqueBackgroundColor() const; 203 204 void SetFilters(const FilterOperations& filters); filters()205 const FilterOperations& filters() const { return filters_; } 206 bool FilterIsAnimating() const; 207 bool FilterIsAnimatingOnImplOnly() const; 208 209 void SetBackgroundFilters(const FilterOperations& filters); background_filters()210 const FilterOperations& background_filters() const { 211 return background_filters_; 212 } 213 214 void SetMasksToBounds(bool masks_to_bounds); masks_to_bounds()215 bool masks_to_bounds() const { return masks_to_bounds_; } 216 217 void SetContentsOpaque(bool opaque); contents_opaque()218 bool contents_opaque() const { return contents_opaque_; } 219 220 void SetOpacity(float opacity); opacity()221 float opacity() const { return opacity_; } 222 bool OpacityIsAnimating() const; 223 bool OpacityIsAnimatingOnImplOnly() const; 224 225 void SetBlendMode(SkXfermode::Mode); blend_mode()226 SkXfermode::Mode blend_mode() const { return blend_mode_; } uses_default_blend_mode()227 bool uses_default_blend_mode() const { 228 return blend_mode_ == SkXfermode::kSrcOver_Mode; 229 } 230 231 void SetIsRootForIsolatedGroup(bool root); is_root_for_isolated_group()232 bool is_root_for_isolated_group() const { 233 return is_root_for_isolated_group_; 234 } 235 236 void SetPosition(gfx::PointF position); position()237 gfx::PointF position() const { return position_; } 238 SetIsContainerForFixedPositionLayers(bool container)239 void SetIsContainerForFixedPositionLayers(bool container) { 240 is_container_for_fixed_position_layers_ = container; 241 } 242 // This is a non-trivial function in Layer. IsContainerForFixedPositionLayers()243 bool IsContainerForFixedPositionLayers() const { 244 return is_container_for_fixed_position_layers_; 245 } 246 SetFixedContainerSizeDelta(gfx::Vector2dF delta)247 void SetFixedContainerSizeDelta(gfx::Vector2dF delta) { 248 fixed_container_size_delta_ = delta; 249 } fixed_container_size_delta()250 gfx::Vector2dF fixed_container_size_delta() const { 251 return fixed_container_size_delta_; 252 } 253 SetPositionConstraint(const LayerPositionConstraint & constraint)254 void SetPositionConstraint(const LayerPositionConstraint& constraint) { 255 position_constraint_ = constraint; 256 } position_constraint()257 const LayerPositionConstraint& position_constraint() const { 258 return position_constraint_; 259 } 260 261 void SetPreserves3d(bool preserves_3d); preserves_3d()262 bool preserves_3d() const { return preserves_3d_; } 263 SetUseParentBackfaceVisibility(bool use)264 void SetUseParentBackfaceVisibility(bool use) { 265 use_parent_backface_visibility_ = use; 266 } use_parent_backface_visibility()267 bool use_parent_backface_visibility() const { 268 return use_parent_backface_visibility_; 269 } 270 271 void SetSublayerTransform(const gfx::Transform& sublayer_transform); sublayer_transform()272 const gfx::Transform& sublayer_transform() const { 273 return sublayer_transform_; 274 } 275 276 // Debug layer name. SetDebugName(const std::string & debug_name)277 void SetDebugName(const std::string& debug_name) { debug_name_ = debug_name; } debug_name()278 std::string debug_name() const { return debug_name_; } 279 SetCompositingReasons(CompositingReasons reasons)280 void SetCompositingReasons(CompositingReasons reasons) { 281 compositing_reasons_ = reasons; 282 } 283 compositing_reasons()284 CompositingReasons compositing_reasons() const { 285 return compositing_reasons_; 286 } 287 288 bool ShowDebugBorders() const; 289 290 // These invalidate the host's render surface layer list. The caller 291 // is responsible for calling set_needs_update_draw_properties on the tree 292 // so that its list can be recreated. 293 void CreateRenderSurface(); 294 void ClearRenderSurface(); 295 draw_properties()296 DrawProperties<LayerImpl>& draw_properties() { 297 return draw_properties_; 298 } draw_properties()299 const DrawProperties<LayerImpl>& draw_properties() const { 300 return draw_properties_; 301 } 302 303 // The following are shortcut accessors to get various information from 304 // draw_properties_ draw_transform()305 const gfx::Transform& draw_transform() const { 306 return draw_properties_.target_space_transform; 307 } screen_space_transform()308 const gfx::Transform& screen_space_transform() const { 309 return draw_properties_.screen_space_transform; 310 } draw_opacity()311 float draw_opacity() const { return draw_properties_.opacity; } draw_opacity_is_animating()312 bool draw_opacity_is_animating() const { 313 return draw_properties_.opacity_is_animating; 314 } draw_transform_is_animating()315 bool draw_transform_is_animating() const { 316 return draw_properties_.target_space_transform_is_animating; 317 } screen_space_transform_is_animating()318 bool screen_space_transform_is_animating() const { 319 return draw_properties_.screen_space_transform_is_animating; 320 } screen_space_opacity_is_animating()321 bool screen_space_opacity_is_animating() const { 322 return draw_properties_.screen_space_opacity_is_animating; 323 } can_use_lcd_text()324 bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; } is_clipped()325 bool is_clipped() const { return draw_properties_.is_clipped; } clip_rect()326 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; } drawable_content_rect()327 gfx::Rect drawable_content_rect() const { 328 return draw_properties_.drawable_content_rect; 329 } visible_content_rect()330 gfx::Rect visible_content_rect() const { 331 return draw_properties_.visible_content_rect; 332 } render_target()333 LayerImpl* render_target() { 334 DCHECK(!draw_properties_.render_target || 335 draw_properties_.render_target->render_surface()); 336 return draw_properties_.render_target; 337 } render_target()338 const LayerImpl* render_target() const { 339 DCHECK(!draw_properties_.render_target || 340 draw_properties_.render_target->render_surface()); 341 return draw_properties_.render_target; 342 } render_surface()343 RenderSurfaceImpl* render_surface() const { 344 return draw_properties_.render_surface.get(); 345 } num_unclipped_descendants()346 int num_unclipped_descendants() const { 347 return draw_properties_.num_unclipped_descendants; 348 } 349 350 // The client should be responsible for setting bounds, content bounds and 351 // contents scale to appropriate values. LayerImpl doesn't calculate any of 352 // them from the other values. 353 354 void SetBounds(gfx::Size bounds); bounds()355 gfx::Size bounds() const { return bounds_; } 356 357 void SetContentBounds(gfx::Size content_bounds); content_bounds()358 gfx::Size content_bounds() const { return draw_properties_.content_bounds; } 359 contents_scale_x()360 float contents_scale_x() const { return draw_properties_.contents_scale_x; } contents_scale_y()361 float contents_scale_y() const { return draw_properties_.contents_scale_y; } 362 void SetContentsScale(float contents_scale_x, float contents_scale_y); 363 364 // Computes a box in screen space that should entirely contain the layer's 365 // bounds through the entirety of the layer's current animation. Returns true 366 // and sets |out| to the inflation if there are animations that can inflate 367 // bounds in the path to the root layer. Returns false otherwise. GetAnimationBounds(gfx::BoxF * out)368 bool GetAnimationBounds(gfx::BoxF* out) const { return false; } 369 370 virtual void CalculateContentsScale(float ideal_contents_scale, 371 float device_scale_factor, 372 float page_scale_factor, 373 bool animating_transform_to_screen, 374 float* contents_scale_x, 375 float* contents_scale_y, 376 gfx::Size* content_bounds); 377 378 void SetScrollOffsetDelegate( 379 LayerScrollOffsetDelegate* scroll_offset_delegate); 380 bool IsExternalFlingActive() const; 381 382 void SetScrollOffset(gfx::Vector2d scroll_offset); 383 void SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset, 384 gfx::Vector2dF scroll_delta); scroll_offset()385 gfx::Vector2d scroll_offset() const { return scroll_offset_; } 386 387 void SetMaxScrollOffset(gfx::Vector2d max_scroll_offset); max_scroll_offset()388 gfx::Vector2d max_scroll_offset() const { return max_scroll_offset_; } 389 390 void SetScrollDelta(gfx::Vector2dF scroll_delta); 391 gfx::Vector2dF ScrollDelta() const; 392 393 gfx::Vector2dF TotalScrollOffset() const; 394 395 void SetSentScrollDelta(gfx::Vector2d sent_scroll_delta); sent_scroll_delta()396 gfx::Vector2d sent_scroll_delta() const { return sent_scroll_delta_; } 397 398 // Returns the delta of the scroll that was outside of the bounds of the 399 // initial scroll 400 gfx::Vector2dF ScrollBy(gfx::Vector2dF scroll); 401 SetScrollable(bool scrollable)402 void SetScrollable(bool scrollable) { scrollable_ = scrollable; } scrollable()403 bool scrollable() const { return scrollable_; } 404 set_user_scrollable_horizontal(bool scrollable)405 void set_user_scrollable_horizontal(bool scrollable) { 406 user_scrollable_horizontal_ = scrollable; 407 } set_user_scrollable_vertical(bool scrollable)408 void set_user_scrollable_vertical(bool scrollable) { 409 user_scrollable_vertical_ = scrollable; 410 } 411 412 void ApplySentScrollDeltasFromAbortedCommit(); 413 void ApplyScrollDeltasSinceBeginMainFrame(); 414 SetShouldScrollOnMainThread(bool should_scroll_on_main_thread)415 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) { 416 should_scroll_on_main_thread_ = should_scroll_on_main_thread; 417 } should_scroll_on_main_thread()418 bool should_scroll_on_main_thread() const { 419 return should_scroll_on_main_thread_; 420 } 421 SetHaveWheelEventHandlers(bool have_wheel_event_handlers)422 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) { 423 have_wheel_event_handlers_ = have_wheel_event_handlers; 424 } have_wheel_event_handlers()425 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; } 426 SetNonFastScrollableRegion(const Region & region)427 void SetNonFastScrollableRegion(const Region& region) { 428 non_fast_scrollable_region_ = region; 429 } non_fast_scrollable_region()430 const Region& non_fast_scrollable_region() const { 431 return non_fast_scrollable_region_; 432 } 433 SetTouchEventHandlerRegion(const Region & region)434 void SetTouchEventHandlerRegion(const Region& region) { 435 touch_event_handler_region_ = region; 436 } touch_event_handler_region()437 const Region& touch_event_handler_region() const { 438 return touch_event_handler_region_; 439 } 440 SetDrawCheckerboardForMissingTiles(bool checkerboard)441 void SetDrawCheckerboardForMissingTiles(bool checkerboard) { 442 draw_checkerboard_for_missing_tiles_ = checkerboard; 443 } 444 bool DrawCheckerboardForMissingTiles() const; 445 446 InputHandler::ScrollStatus TryScroll( 447 gfx::PointF screen_space_point, 448 InputHandler::ScrollInputType type) const; 449 450 void SetDoubleSided(bool double_sided); double_sided()451 bool double_sided() const { return double_sided_; } 452 453 void SetTransform(const gfx::Transform& transform); transform()454 const gfx::Transform& transform() const { return transform_; } 455 bool TransformIsAnimating() const; 456 bool TransformIsAnimatingOnImplOnly() const; 457 458 // Note this rect is in layer space (not content space). set_update_rect(const gfx::RectF & update_rect)459 void set_update_rect(const gfx::RectF& update_rect) { 460 update_rect_ = update_rect; 461 } update_rect()462 const gfx::RectF& update_rect() const { return update_rect_; } 463 464 virtual base::DictionaryValue* LayerTreeAsJson() const; 465 466 void SetStackingOrderChanged(bool stacking_order_changed); 467 LayerPropertyChanged()468 bool LayerPropertyChanged() const { 469 return layer_property_changed_ || LayerIsAlwaysDamaged(); 470 } 471 472 void ResetAllChangeTrackingForSubtree(); 473 474 virtual bool LayerIsAlwaysDamaged() const; 475 layer_animation_controller()476 LayerAnimationController* layer_animation_controller() { 477 return layer_animation_controller_.get(); 478 } 479 480 virtual Region VisibleContentOpaqueRegion() const; 481 482 virtual void DidBecomeActive(); 483 484 virtual void DidBeginTracing(); 485 486 // Indicates that the surface previously used to render this layer 487 // was lost and that a new one has been created. Won't be called 488 // until the new surface has been created successfully. 489 virtual void DidLoseOutputSurface(); 490 scrollbar_animation_controller()491 ScrollbarAnimationController* scrollbar_animation_controller() const { 492 return scrollbar_animation_controller_.get(); 493 } 494 495 void SetHorizontalScrollbarLayer(ScrollbarLayerImplBase* scrollbar_layer); horizontal_scrollbar_layer()496 ScrollbarLayerImplBase* horizontal_scrollbar_layer() { 497 return horizontal_scrollbar_layer_; 498 } 499 500 void SetVerticalScrollbarLayer(ScrollbarLayerImplBase* scrollbar_layer); vertical_scrollbar_layer()501 ScrollbarLayerImplBase* vertical_scrollbar_layer() { 502 return vertical_scrollbar_layer_; 503 } 504 505 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const; 506 507 virtual skia::RefPtr<SkPicture> GetPicture(); 508 509 virtual bool AreVisibleResourcesReady() const; 510 511 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); 512 virtual void PushPropertiesTo(LayerImpl* layer); 513 514 scoped_ptr<base::Value> AsValue() const; 515 virtual size_t GPUMemoryUsageInBytes() const; 516 517 // TODO(danakj): Be true only if needed. crbug.com/259511 needs_push_properties()518 bool needs_push_properties() const { return true; } descendant_needs_push_properties()519 bool descendant_needs_push_properties() const { return true; } 520 521 virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark); 522 523 virtual void SetDebugInfo( 524 scoped_refptr<base::debug::ConvertableToTraceFormat> other); 525 526 protected: 527 LayerImpl(LayerTreeImpl* layer_impl, int id); 528 529 // Get the color and size of the layer's debug border. 530 virtual void GetDebugBorderProperties(SkColor* color, float* width) const; 531 532 void AppendDebugBorderQuad(QuadSink* quad_sink, 533 const SharedQuadState* shared_quad_state, 534 AppendQuadsData* append_quads_data) const; 535 void AppendDebugBorderQuad(QuadSink* quad_sink, 536 const SharedQuadState* shared_quad_state, 537 AppendQuadsData* append_quads_data, 538 SkColor color, 539 float width) const; 540 541 virtual void AsValueInto(base::DictionaryValue* dict) const; 542 543 void NoteLayerPropertyChanged(); 544 void NoteLayerPropertyChangedForSubtree(); 545 546 // Note carefully this does not affect the current layer. 547 void NoteLayerPropertyChangedForDescendants(); 548 549 private: 550 void UpdateScrollbarPositions(); 551 552 virtual const char* LayerTypeAsString() const; 553 554 // Properties internal to LayerImpl 555 LayerImpl* parent_; 556 OwnedLayerImplList children_; 557 558 LayerImpl* scroll_parent_; 559 560 // Storing a pointer to a set rather than a set since this will be rarely 561 // used. If this pointer turns out to be too heavy, we could have this (and 562 // the scroll parent above) be stored in a LayerImpl -> scroll_info 563 // map somewhere. 564 scoped_ptr<std::set<LayerImpl*> > scroll_children_; 565 566 LayerImpl* clip_parent_; 567 scoped_ptr<std::set<LayerImpl*> > clip_children_; 568 569 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to 570 // confirm newly assigned layer is still the previous one 571 int mask_layer_id_; 572 scoped_ptr<LayerImpl> mask_layer_; 573 int replica_layer_id_; // ditto 574 scoped_ptr<LayerImpl> replica_layer_; 575 int layer_id_; 576 LayerTreeImpl* layer_tree_impl_; 577 578 // Properties synchronized from the associated Layer. 579 gfx::PointF anchor_point_; 580 float anchor_point_z_; 581 gfx::Size bounds_; 582 gfx::Vector2d scroll_offset_; 583 LayerScrollOffsetDelegate* scroll_offset_delegate_; 584 bool scrollable_ : 1; 585 bool should_scroll_on_main_thread_ : 1; 586 bool have_wheel_event_handlers_ : 1; 587 bool user_scrollable_horizontal_ : 1; 588 bool user_scrollable_vertical_ : 1; 589 bool stacking_order_changed_ : 1; 590 // Whether the "back" of this layer should draw. 591 bool double_sided_ : 1; 592 593 // Tracks if drawing-related properties have changed since last redraw. 594 bool layer_property_changed_ : 1; 595 596 bool masks_to_bounds_ : 1; 597 bool contents_opaque_ : 1; 598 bool is_root_for_isolated_group_ : 1; 599 bool preserves_3d_ : 1; 600 bool use_parent_backface_visibility_ : 1; 601 bool draw_checkerboard_for_missing_tiles_ : 1; 602 bool draws_content_ : 1; 603 bool hide_layer_and_subtree_ : 1; 604 bool force_render_surface_ : 1; 605 606 // Set for the layer that other layers are fixed to. 607 bool is_container_for_fixed_position_layers_ : 1; 608 Region non_fast_scrollable_region_; 609 Region touch_event_handler_region_; 610 SkColor background_color_; 611 612 float opacity_; 613 SkXfermode::Mode blend_mode_; 614 gfx::PointF position_; 615 gfx::Transform sublayer_transform_; 616 gfx::Transform transform_; 617 618 // This property is effective when 619 // is_container_for_fixed_position_layers_ == true, 620 gfx::Vector2dF fixed_container_size_delta_; 621 622 LayerPositionConstraint position_constraint_; 623 624 gfx::Vector2dF scroll_delta_; 625 gfx::Vector2d sent_scroll_delta_; 626 gfx::Vector2d max_scroll_offset_; 627 gfx::Vector2dF last_scroll_offset_; 628 629 // The global depth value of the center of the layer. This value is used 630 // to sort layers from back to front. 631 float draw_depth_; 632 633 // Debug layer name. 634 std::string debug_name_; 635 CompositingReasons compositing_reasons_; 636 637 FilterOperations filters_; 638 FilterOperations background_filters_; 639 640 protected: 641 DrawMode current_draw_mode_; 642 643 private: 644 // Rect indicating what was repainted/updated during update. 645 // Note that plugin layers bypass this and leave it empty. 646 // Uses layer (not content) space. 647 gfx::RectF update_rect_; 648 649 // Manages animations for this layer. 650 scoped_refptr<LayerAnimationController> layer_animation_controller_; 651 652 // Manages scrollbars for this layer 653 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; 654 655 // Weak pointers to this layer's scrollbars, if it has them. Updated during 656 // tree synchronization. 657 ScrollbarLayerImplBase* horizontal_scrollbar_layer_; 658 ScrollbarLayerImplBase* vertical_scrollbar_layer_; 659 660 ScopedPtrVector<CopyOutputRequest> copy_requests_; 661 662 // Group of properties that need to be computed based on the layer tree 663 // hierarchy before layers can be drawn. 664 DrawProperties<LayerImpl> draw_properties_; 665 666 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_; 667 668 DISALLOW_COPY_AND_ASSIGN(LayerImpl); 669 }; 670 671 } // namespace cc 672 673 #endif // CC_LAYERS_LAYER_IMPL_H_ 674