OLD | NEW |
---|---|
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_LAYERS_LAYER_H_ | 5 #ifndef CC_LAYERS_LAYER_H_ |
6 #define CC_LAYERS_LAYER_H_ | 6 #define CC_LAYERS_LAYER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 | 345 |
346 bool has_mask() const { return !!mask_layer_.get(); } | 346 bool has_mask() const { return !!mask_layer_.get(); } |
347 bool has_replica() const { return !!replica_layer_.get(); } | 347 bool has_replica() const { return !!replica_layer_.get(); } |
348 bool replica_has_mask() const { | 348 bool replica_has_mask() const { |
349 return replica_layer_.get() && | 349 return replica_layer_.get() && |
350 (mask_layer_.get() || replica_layer_->mask_layer_.get()); | 350 (mask_layer_.get() || replica_layer_->mask_layer_.get()); |
351 } | 351 } |
352 | 352 |
353 // These methods typically need to be overwritten by derived classes. | 353 // These methods typically need to be overwritten by derived classes. |
354 virtual bool DrawsContent() const; | 354 virtual bool DrawsContent() const; |
355 virtual int NumDescendantsThatDrawContent() const; | |
355 virtual void SavePaintProperties(); | 356 virtual void SavePaintProperties(); |
356 // Returns true iff any resources were updated that need to be committed. | 357 // Returns true iff any resources were updated that need to be committed. |
357 virtual bool Update(ResourceUpdateQueue* queue, | 358 virtual bool Update(ResourceUpdateQueue* queue, |
358 const OcclusionTracker<Layer>* occlusion); | 359 const OcclusionTracker<Layer>* occlusion); |
359 virtual bool NeedMoreUpdates(); | 360 virtual bool NeedMoreUpdates(); |
360 virtual void SetIsMask(bool is_mask) {} | 361 virtual void SetIsMask(bool is_mask) {} |
361 virtual void ReduceMemoryUsage() {} | 362 virtual void ReduceMemoryUsage() {} |
362 virtual void OnOutputSurfaceCreated() {} | 363 virtual void OnOutputSurfaceCreated() {} |
363 virtual bool IsSuitableForGpuRasterization() const; | 364 virtual bool IsSuitableForGpuRasterization() const; |
364 | 365 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 } | 454 } |
454 void reset_needs_push_properties_for_testing() { | 455 void reset_needs_push_properties_for_testing() { |
455 needs_push_properties_ = false; | 456 needs_push_properties_ = false; |
456 } | 457 } |
457 | 458 |
458 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); | 459 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); |
459 | 460 |
460 void Set3dSortingContextId(int id); | 461 void Set3dSortingContextId(int id); |
461 int sorting_context_id() const { return sorting_context_id_; } | 462 int sorting_context_id() const { return sorting_context_id_; } |
462 | 463 |
464 // Called when our number of Drawable Descendants changes | |
danakj
2014/07/14 15:49:23
nit: s/D/d/g and add a .
awoloszyn
2014/07/14 19:38:33
Done.
| |
465 void AddDrawableDescendants(int num); | |
danakj
2014/07/14 15:49:23
Can these all be protected?
awoloszyn
2014/07/14 19:38:33
Done.
| |
466 void RemoveDrawableDescendants(int num); | |
467 | |
468 void SetDrawsContent(bool draws_content); | |
469 | |
463 protected: | 470 protected: |
464 friend class LayerImpl; | 471 friend class LayerImpl; |
465 friend class TreeSynchronizer; | 472 friend class TreeSynchronizer; |
466 virtual ~Layer(); | 473 virtual ~Layer(); |
467 | 474 |
468 Layer(); | 475 Layer(); |
469 | 476 |
470 // These SetNeeds functions are in order of severity of update: | 477 // These SetNeeds functions are in order of severity of update: |
471 // | 478 // |
472 // Called when this layer has been modified in some way, but isn't sure | 479 // Called when this layer has been modified in some way, but isn't sure |
473 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers | 480 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers |
474 // before it knows whether or not a commit is required. | 481 // before it knows whether or not a commit is required. |
475 void SetNeedsUpdate(); | 482 void SetNeedsUpdate(); |
476 // Called when a property has been modified in a way that the layer | 483 // Called when a property has been modified in a way that the layer |
477 // knows immediately that a commit is required. This implies SetNeedsUpdate | 484 // knows immediately that a commit is required. This implies SetNeedsUpdate |
478 // as well as SetNeedsPushProperties to push that property. | 485 // as well as SetNeedsPushProperties to push that property. |
479 void SetNeedsCommit(); | 486 void SetNeedsCommit(); |
480 // Called when there's been a change in layer structure. Implies both | 487 // Called when there's been a change in layer structure. Implies both |
481 // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties. | 488 // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties. |
482 void SetNeedsFullTreeSync(); | 489 void SetNeedsFullTreeSync(); |
483 | 490 |
484 // Called when the next commit should wait until the pending tree is activated | 491 // Called when the next commit should wait until the pending tree is activated |
485 // before finishing the commit and unblocking the main thread. Used to ensure | 492 // before finishing the commit and unblocking the main thread. Used to ensure |
486 // unused resources on the impl thread are returned before commit completes. | 493 // unused resources on the impl thread are returned before commit completes. |
487 void SetNextCommitWaitsForActivation(); | 494 void SetNextCommitWaitsForActivation(); |
488 | 495 |
496 // Will relcalculate whether or not we draw content and set draws_content_ | |
497 // appropriately. | |
498 virtual void UpdateDrawsContent(bool draws_content); | |
489 void AddDependentNeedsPushProperties(); | 499 void AddDependentNeedsPushProperties(); |
490 void RemoveDependentNeedsPushProperties(); | 500 void RemoveDependentNeedsPushProperties(); |
491 bool parent_should_know_need_push_properties() const { | 501 bool parent_should_know_need_push_properties() const { |
492 return needs_push_properties() || descendant_needs_push_properties(); | 502 return needs_push_properties() || descendant_needs_push_properties(); |
493 } | 503 } |
494 | 504 |
495 bool IsPropertyChangeAllowed() const; | 505 bool IsPropertyChangeAllowed() const; |
496 | 506 |
497 // If this layer has a scroll parent, it removes |this| from its list of | 507 // If this layer has a scroll parent, it removes |this| from its list of |
498 // scroll children. | 508 // scroll children. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
572 scoped_refptr<LayerAnimationController> layer_animation_controller_; | 582 scoped_refptr<LayerAnimationController> layer_animation_controller_; |
573 | 583 |
574 // Layer properties. | 584 // Layer properties. |
575 gfx::Size bounds_; | 585 gfx::Size bounds_; |
576 | 586 |
577 gfx::Vector2d scroll_offset_; | 587 gfx::Vector2d scroll_offset_; |
578 // This variable indicates which ancestor layer (if any) whose size, | 588 // This variable indicates which ancestor layer (if any) whose size, |
579 // transformed relative to this layer, defines the maximum scroll offset for | 589 // transformed relative to this layer, defines the maximum scroll offset for |
580 // this layer. | 590 // this layer. |
581 int scroll_clip_layer_id_; | 591 int scroll_clip_layer_id_; |
592 int num_descendants_that_draw_content_; | |
582 bool should_scroll_on_main_thread_ : 1; | 593 bool should_scroll_on_main_thread_ : 1; |
583 bool have_wheel_event_handlers_ : 1; | 594 bool have_wheel_event_handlers_ : 1; |
584 bool have_scroll_event_handlers_ : 1; | 595 bool have_scroll_event_handlers_ : 1; |
585 bool user_scrollable_horizontal_ : 1; | 596 bool user_scrollable_horizontal_ : 1; |
586 bool user_scrollable_vertical_ : 1; | 597 bool user_scrollable_vertical_ : 1; |
587 bool is_root_for_isolated_group_ : 1; | 598 bool is_root_for_isolated_group_ : 1; |
588 bool is_container_for_fixed_position_layers_ : 1; | 599 bool is_container_for_fixed_position_layers_ : 1; |
589 bool is_drawable_ : 1; | 600 bool is_drawable_ : 1; |
601 bool draws_content_ : 1; | |
590 bool hide_layer_and_subtree_ : 1; | 602 bool hide_layer_and_subtree_ : 1; |
591 bool masks_to_bounds_ : 1; | 603 bool masks_to_bounds_ : 1; |
592 bool contents_opaque_ : 1; | 604 bool contents_opaque_ : 1; |
593 bool double_sided_ : 1; | 605 bool double_sided_ : 1; |
594 bool should_flatten_transform_ : 1; | 606 bool should_flatten_transform_ : 1; |
595 bool use_parent_backface_visibility_ : 1; | 607 bool use_parent_backface_visibility_ : 1; |
596 bool draw_checkerboard_for_missing_tiles_ : 1; | 608 bool draw_checkerboard_for_missing_tiles_ : 1; |
597 bool force_render_surface_ : 1; | 609 bool force_render_surface_ : 1; |
598 bool transform_is_invertible_ : 1; | 610 bool transform_is_invertible_ : 1; |
599 Region non_fast_scrollable_region_; | 611 Region non_fast_scrollable_region_; |
(...skipping 29 matching lines...) Expand all Loading... | |
629 DrawProperties<Layer> draw_properties_; | 641 DrawProperties<Layer> draw_properties_; |
630 | 642 |
631 PaintProperties paint_properties_; | 643 PaintProperties paint_properties_; |
632 | 644 |
633 DISALLOW_COPY_AND_ASSIGN(Layer); | 645 DISALLOW_COPY_AND_ASSIGN(Layer); |
634 }; | 646 }; |
635 | 647 |
636 } // namespace cc | 648 } // namespace cc |
637 | 649 |
638 #endif // CC_LAYERS_LAYER_H_ | 650 #endif // CC_LAYERS_LAYER_H_ |
OLD | NEW |