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 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "cc/animation/layer_animation_controller.h" | 14 #include "cc/animation/layer_animation_controller.h" |
15 #include "cc/animation/layer_animation_value_observer.h" | 15 #include "cc/animation/layer_animation_value_observer.h" |
16 #include "cc/animation/layer_animation_value_provider.h" | 16 #include "cc/animation/layer_animation_value_provider.h" |
17 #include "cc/base/cc_export.h" | 17 #include "cc/base/cc_export.h" |
18 #include "cc/base/region.h" | 18 #include "cc/base/region.h" |
19 #include "cc/base/scoped_ptr_vector.h" | 19 #include "cc/base/scoped_ptr_vector.h" |
20 #include "cc/debug/micro_benchmark.h" | 20 #include "cc/debug/micro_benchmark.h" |
21 #include "cc/layers/draw_properties.h" | 21 #include "cc/layers/draw_properties.h" |
22 #include "cc/layers/layer_lists.h" | 22 #include "cc/layers/layer_lists.h" |
23 #include "cc/layers/layer_position_constraint.h" | 23 #include "cc/layers/layer_position_constraint.h" |
24 #include "cc/layers/paint_properties.h" | 24 #include "cc/layers/paint_properties.h" |
25 #include "cc/layers/render_surface.h" | 25 #include "cc/layers/render_surface.h" |
26 #include "cc/output/filter_operations.h" | 26 #include "cc/output/filter_operations.h" |
27 #include "cc/trees/property_tree.h" | |
27 #include "skia/ext/refptr.h" | 28 #include "skia/ext/refptr.h" |
28 #include "third_party/skia/include/core/SkColor.h" | 29 #include "third_party/skia/include/core/SkColor.h" |
29 #include "third_party/skia/include/core/SkImageFilter.h" | 30 #include "third_party/skia/include/core/SkImageFilter.h" |
30 #include "third_party/skia/include/core/SkPicture.h" | 31 #include "third_party/skia/include/core/SkPicture.h" |
31 #include "third_party/skia/include/core/SkXfermode.h" | 32 #include "third_party/skia/include/core/SkXfermode.h" |
32 #include "ui/gfx/geometry/point3_f.h" | 33 #include "ui/gfx/geometry/point3_f.h" |
33 #include "ui/gfx/geometry/rect.h" | 34 #include "ui/gfx/geometry/rect.h" |
34 #include "ui/gfx/geometry/rect_f.h" | 35 #include "ui/gfx/geometry/rect_f.h" |
35 #include "ui/gfx/geometry/scroll_offset.h" | 36 #include "ui/gfx/geometry/scroll_offset.h" |
36 #include "ui/gfx/transform.h" | 37 #include "ui/gfx/transform.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 const LayerPositionConstraint& position_constraint() const { | 174 const LayerPositionConstraint& position_constraint() const { |
174 return position_constraint_; | 175 return position_constraint_; |
175 } | 176 } |
176 | 177 |
177 void SetTransform(const gfx::Transform& transform); | 178 void SetTransform(const gfx::Transform& transform); |
178 const gfx::Transform& transform() const { return transform_; } | 179 const gfx::Transform& transform() const { return transform_; } |
179 bool TransformIsAnimating() const; | 180 bool TransformIsAnimating() const; |
180 bool transform_is_invertible() const { return transform_is_invertible_; } | 181 bool transform_is_invertible() const { return transform_is_invertible_; } |
181 | 182 |
182 void SetTransformOrigin(const gfx::Point3F&); | 183 void SetTransformOrigin(const gfx::Point3F&); |
183 gfx::Point3F transform_origin() { return transform_origin_; } | 184 gfx::Point3F transform_origin() const { return transform_origin_; } |
184 | 185 |
185 void SetScrollParent(Layer* parent); | 186 void SetScrollParent(Layer* parent); |
186 | 187 |
187 Layer* scroll_parent() { return scroll_parent_; } | 188 Layer* scroll_parent() { return scroll_parent_; } |
188 const Layer* scroll_parent() const { return scroll_parent_; } | 189 const Layer* scroll_parent() const { return scroll_parent_; } |
189 | 190 |
190 void AddScrollChild(Layer* child); | 191 void AddScrollChild(Layer* child); |
191 void RemoveScrollChild(Layer* child); | 192 void RemoveScrollChild(Layer* child); |
192 | 193 |
193 std::set<Layer*>* scroll_children() { return scroll_children_.get(); } | 194 std::set<Layer*>* scroll_children() { return scroll_children_.get(); } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 | 451 |
451 void SetNeedsPushProperties(); | 452 void SetNeedsPushProperties(); |
452 bool needs_push_properties() const { return needs_push_properties_; } | 453 bool needs_push_properties() const { return needs_push_properties_; } |
453 bool descendant_needs_push_properties() const { | 454 bool descendant_needs_push_properties() const { |
454 return num_dependents_need_push_properties_ > 0; | 455 return num_dependents_need_push_properties_ > 0; |
455 } | 456 } |
456 void reset_needs_push_properties_for_testing() { | 457 void reset_needs_push_properties_for_testing() { |
457 needs_push_properties_ = false; | 458 needs_push_properties_ = false; |
458 } | 459 } |
459 | 460 |
461 bool NeedsVisibleRectUpdated() const; | |
enne (OOO)
2014/12/16 19:54:28
Could you just call DrawsContent directly elsewher
Ian Vollick
2014/12/16 21:28:18
Done.
| |
462 | |
460 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); | 463 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); |
461 | 464 |
462 void Set3dSortingContextId(int id); | 465 void Set3dSortingContextId(int id); |
463 int sorting_context_id() const { return sorting_context_id_; } | 466 int sorting_context_id() const { return sorting_context_id_; } |
464 | 467 |
468 void set_transform_tree_index(int index) { transform_tree_index_ = index; } | |
469 void set_clip_tree_index(int index) { clip_tree_index_ = index; } | |
470 int clip_tree_index() const { return clip_tree_index_; } | |
471 int transform_tree_index() const { return transform_tree_index_; } | |
472 | |
473 void set_offset_to_transform_parent(gfx::Vector2dF offset) { | |
474 offset_to_transform_parent_ = offset; | |
475 } | |
476 gfx::Vector2dF offset_to_transform_parent() const { | |
477 return offset_to_transform_parent_; | |
478 } | |
479 | |
480 // TODO(vollick): Once we transition to transform and clip trees, rename these | |
481 // functions and related values. The "from property trees" functions below | |
482 // use the transform and clip trees. Eventually, we will use these functions | |
483 // to compute the official values, but these functions are retained for | |
484 // testing purposes until we've migrated. | |
485 | |
486 const gfx::Rect& visible_rect_from_property_trees() const { | |
487 return visible_rect_from_property_trees_; | |
488 } | |
489 void set_visible_rect_from_property_trees(const gfx::Rect& rect) { | |
490 visible_rect_from_property_trees_ = rect; | |
491 } | |
492 | |
493 gfx::Transform screen_space_transform_from_property_trees( | |
494 const TransformTree& tree) const; | |
495 gfx::Transform draw_transform_from_property_trees( | |
496 const TransformTree& tree) const; | |
497 | |
498 // TODO(vollick): These values are temporary and will be removed as soon as | |
499 // render surface determinations are moved out of CDP. They only exist because | |
500 // certain logic depends on whether or not a layer would render to a separate | |
501 // surface, but CDP destroys surfaces and targets it doesn't need, so without | |
502 // this boolean, this is impossible to determine after the fact without | |
503 // wastefully recomputing it. | |
504 const bool should_render_to_separate_surface() const { | |
505 return should_render_to_separate_surface_; | |
506 } | |
507 void set_should_render_to_separate_surface(bool value) { | |
508 should_render_to_separate_surface_ = value; | |
509 } | |
510 | |
465 protected: | 511 protected: |
466 friend class LayerImpl; | 512 friend class LayerImpl; |
467 friend class TreeSynchronizer; | 513 friend class TreeSynchronizer; |
468 ~Layer() override; | 514 ~Layer() override; |
469 | 515 |
470 Layer(); | 516 Layer(); |
471 | 517 |
472 // These SetNeeds functions are in order of severity of update: | 518 // These SetNeeds functions are in order of severity of update: |
473 // | 519 // |
474 // Called when this layer has been modified in some way, but isn't sure | 520 // Called when this layer has been modified in some way, but isn't sure |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 | 628 |
583 // Layer properties. | 629 // Layer properties. |
584 gfx::Size bounds_; | 630 gfx::Size bounds_; |
585 | 631 |
586 gfx::ScrollOffset scroll_offset_; | 632 gfx::ScrollOffset scroll_offset_; |
587 // This variable indicates which ancestor layer (if any) whose size, | 633 // This variable indicates which ancestor layer (if any) whose size, |
588 // transformed relative to this layer, defines the maximum scroll offset for | 634 // transformed relative to this layer, defines the maximum scroll offset for |
589 // this layer. | 635 // this layer. |
590 int scroll_clip_layer_id_; | 636 int scroll_clip_layer_id_; |
591 int num_descendants_that_draw_content_; | 637 int num_descendants_that_draw_content_; |
638 int transform_tree_index_; | |
639 int opacity_tree_index_; | |
640 int clip_tree_index_; | |
641 gfx::Vector2dF offset_to_transform_parent_; | |
592 bool should_scroll_on_main_thread_ : 1; | 642 bool should_scroll_on_main_thread_ : 1; |
593 bool have_wheel_event_handlers_ : 1; | 643 bool have_wheel_event_handlers_ : 1; |
594 bool have_scroll_event_handlers_ : 1; | 644 bool have_scroll_event_handlers_ : 1; |
595 bool user_scrollable_horizontal_ : 1; | 645 bool user_scrollable_horizontal_ : 1; |
596 bool user_scrollable_vertical_ : 1; | 646 bool user_scrollable_vertical_ : 1; |
597 bool is_root_for_isolated_group_ : 1; | 647 bool is_root_for_isolated_group_ : 1; |
598 bool is_container_for_fixed_position_layers_ : 1; | 648 bool is_container_for_fixed_position_layers_ : 1; |
599 bool is_drawable_ : 1; | 649 bool is_drawable_ : 1; |
600 bool draws_content_ : 1; | 650 bool draws_content_ : 1; |
601 bool hide_layer_and_subtree_ : 1; | 651 bool hide_layer_and_subtree_ : 1; |
602 bool masks_to_bounds_ : 1; | 652 bool masks_to_bounds_ : 1; |
603 bool contents_opaque_ : 1; | 653 bool contents_opaque_ : 1; |
604 bool double_sided_ : 1; | 654 bool double_sided_ : 1; |
605 bool should_flatten_transform_ : 1; | 655 bool should_flatten_transform_ : 1; |
606 bool use_parent_backface_visibility_ : 1; | 656 bool use_parent_backface_visibility_ : 1; |
607 bool draw_checkerboard_for_missing_tiles_ : 1; | 657 bool draw_checkerboard_for_missing_tiles_ : 1; |
608 bool force_render_surface_ : 1; | 658 bool force_render_surface_ : 1; |
609 bool transform_is_invertible_ : 1; | 659 bool transform_is_invertible_ : 1; |
660 bool should_render_to_separate_surface_ : 1; | |
enne (OOO)
2014/12/16 19:54:28
You could call this has_render_surface_ to merge w
Ian Vollick
2014/12/16 21:28:18
Done.
| |
610 Region non_fast_scrollable_region_; | 661 Region non_fast_scrollable_region_; |
611 Region touch_event_handler_region_; | 662 Region touch_event_handler_region_; |
612 gfx::PointF position_; | 663 gfx::PointF position_; |
613 SkColor background_color_; | 664 SkColor background_color_; |
614 float opacity_; | 665 float opacity_; |
615 SkXfermode::Mode blend_mode_; | 666 SkXfermode::Mode blend_mode_; |
616 FilterOperations filters_; | 667 FilterOperations filters_; |
617 FilterOperations background_filters_; | 668 FilterOperations background_filters_; |
618 LayerPositionConstraint position_constraint_; | 669 LayerPositionConstraint position_constraint_; |
619 Layer* scroll_parent_; | 670 Layer* scroll_parent_; |
(...skipping 14 matching lines...) Expand all Loading... | |
634 LayerClient* client_; | 685 LayerClient* client_; |
635 | 686 |
636 ScopedPtrVector<CopyOutputRequest> copy_requests_; | 687 ScopedPtrVector<CopyOutputRequest> copy_requests_; |
637 | 688 |
638 base::Closure did_scroll_callback_; | 689 base::Closure did_scroll_callback_; |
639 | 690 |
640 DrawProperties<Layer> draw_properties_; | 691 DrawProperties<Layer> draw_properties_; |
641 | 692 |
642 PaintProperties paint_properties_; | 693 PaintProperties paint_properties_; |
643 | 694 |
695 gfx::Rect visible_rect_from_property_trees_; | |
644 DISALLOW_COPY_AND_ASSIGN(Layer); | 696 DISALLOW_COPY_AND_ASSIGN(Layer); |
645 }; | 697 }; |
646 | 698 |
647 } // namespace cc | 699 } // namespace cc |
648 | 700 |
649 #endif // CC_LAYERS_LAYER_H_ | 701 #endif // CC_LAYERS_LAYER_H_ |
OLD | NEW |