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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
460 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); | 461 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); |
461 | 462 |
462 void Set3dSortingContextId(int id); | 463 void Set3dSortingContextId(int id); |
463 int sorting_context_id() const { return sorting_context_id_; } | 464 int sorting_context_id() const { return sorting_context_id_; } |
464 | 465 |
| 466 void set_transform_tree_index(int index) { transform_tree_index_ = index; } |
| 467 void set_clip_tree_index(int index) { clip_tree_index_ = index; } |
| 468 int clip_tree_index() const { return clip_tree_index_; } |
| 469 int transform_tree_index() const { return transform_tree_index_; } |
| 470 |
| 471 void set_offset_to_transform_parent(gfx::Vector2dF offset) { |
| 472 offset_to_transform_parent_ = offset; |
| 473 } |
| 474 gfx::Vector2dF offset_to_transform_parent() const { |
| 475 return offset_to_transform_parent_; |
| 476 } |
| 477 |
| 478 // TODO(vollick): Once we transition to transform and clip trees, rename these |
| 479 // functions and related values. The "from property trees" functions below |
| 480 // use the transform and clip trees. Eventually, we will use these functions |
| 481 // to compute the official values, but these functions are retained for |
| 482 // testing purposes until we've migrated. |
| 483 |
| 484 const gfx::Rect& visible_rect_from_property_trees() const { |
| 485 return visible_rect_from_property_trees_; |
| 486 } |
| 487 void set_visible_rect_from_property_trees(const gfx::Rect& rect) { |
| 488 visible_rect_from_property_trees_ = rect; |
| 489 } |
| 490 |
| 491 gfx::Transform screen_space_transform_from_property_trees( |
| 492 const TransformTree& tree) const; |
| 493 gfx::Transform draw_transform_from_property_trees( |
| 494 const TransformTree& tree) const; |
| 495 |
| 496 // TODO(vollick): These values are temporary and will be removed as soon as |
| 497 // render surface determinations are moved out of CDP. They only exist because |
| 498 // certain logic depends on whether or not a layer would render to a separate |
| 499 // surface, but CDP destroys surfaces and targets it doesn't need, so without |
| 500 // this boolean, this is impossible to determine after the fact without |
| 501 // wastefully recomputing it. This is public for the time being so that it can |
| 502 // be accessed from CDP. |
| 503 bool has_render_surface() const { |
| 504 return has_render_surface_; |
| 505 } |
| 506 void SetHasRenderSurface(bool has_render_surface) { |
| 507 has_render_surface_ = has_render_surface; |
| 508 } |
| 509 |
465 protected: | 510 protected: |
466 friend class LayerImpl; | 511 friend class LayerImpl; |
467 friend class TreeSynchronizer; | 512 friend class TreeSynchronizer; |
468 ~Layer() override; | 513 ~Layer() override; |
469 | 514 |
470 Layer(); | 515 Layer(); |
471 | 516 |
472 // These SetNeeds functions are in order of severity of update: | 517 // These SetNeeds functions are in order of severity of update: |
473 // | 518 // |
474 // Called when this layer has been modified in some way, but isn't sure | 519 // 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 | 627 |
583 // Layer properties. | 628 // Layer properties. |
584 gfx::Size bounds_; | 629 gfx::Size bounds_; |
585 | 630 |
586 gfx::ScrollOffset scroll_offset_; | 631 gfx::ScrollOffset scroll_offset_; |
587 // This variable indicates which ancestor layer (if any) whose size, | 632 // This variable indicates which ancestor layer (if any) whose size, |
588 // transformed relative to this layer, defines the maximum scroll offset for | 633 // transformed relative to this layer, defines the maximum scroll offset for |
589 // this layer. | 634 // this layer. |
590 int scroll_clip_layer_id_; | 635 int scroll_clip_layer_id_; |
591 int num_descendants_that_draw_content_; | 636 int num_descendants_that_draw_content_; |
| 637 int transform_tree_index_; |
| 638 int opacity_tree_index_; |
| 639 int clip_tree_index_; |
| 640 gfx::Vector2dF offset_to_transform_parent_; |
592 bool should_scroll_on_main_thread_ : 1; | 641 bool should_scroll_on_main_thread_ : 1; |
593 bool have_wheel_event_handlers_ : 1; | 642 bool have_wheel_event_handlers_ : 1; |
594 bool have_scroll_event_handlers_ : 1; | 643 bool have_scroll_event_handlers_ : 1; |
595 bool user_scrollable_horizontal_ : 1; | 644 bool user_scrollable_horizontal_ : 1; |
596 bool user_scrollable_vertical_ : 1; | 645 bool user_scrollable_vertical_ : 1; |
597 bool is_root_for_isolated_group_ : 1; | 646 bool is_root_for_isolated_group_ : 1; |
598 bool is_container_for_fixed_position_layers_ : 1; | 647 bool is_container_for_fixed_position_layers_ : 1; |
599 bool is_drawable_ : 1; | 648 bool is_drawable_ : 1; |
600 bool draws_content_ : 1; | 649 bool draws_content_ : 1; |
601 bool hide_layer_and_subtree_ : 1; | 650 bool hide_layer_and_subtree_ : 1; |
602 bool masks_to_bounds_ : 1; | 651 bool masks_to_bounds_ : 1; |
603 bool contents_opaque_ : 1; | 652 bool contents_opaque_ : 1; |
604 bool double_sided_ : 1; | 653 bool double_sided_ : 1; |
605 bool should_flatten_transform_ : 1; | 654 bool should_flatten_transform_ : 1; |
606 bool use_parent_backface_visibility_ : 1; | 655 bool use_parent_backface_visibility_ : 1; |
607 bool draw_checkerboard_for_missing_tiles_ : 1; | 656 bool draw_checkerboard_for_missing_tiles_ : 1; |
608 bool force_render_surface_ : 1; | 657 bool force_render_surface_ : 1; |
609 bool transform_is_invertible_ : 1; | 658 bool transform_is_invertible_ : 1; |
| 659 bool has_render_surface_ : 1; |
610 Region non_fast_scrollable_region_; | 660 Region non_fast_scrollable_region_; |
611 Region touch_event_handler_region_; | 661 Region touch_event_handler_region_; |
612 gfx::PointF position_; | 662 gfx::PointF position_; |
613 SkColor background_color_; | 663 SkColor background_color_; |
614 float opacity_; | 664 float opacity_; |
615 SkXfermode::Mode blend_mode_; | 665 SkXfermode::Mode blend_mode_; |
616 FilterOperations filters_; | 666 FilterOperations filters_; |
617 FilterOperations background_filters_; | 667 FilterOperations background_filters_; |
618 LayerPositionConstraint position_constraint_; | 668 LayerPositionConstraint position_constraint_; |
619 Layer* scroll_parent_; | 669 Layer* scroll_parent_; |
(...skipping 14 matching lines...) Expand all Loading... |
634 LayerClient* client_; | 684 LayerClient* client_; |
635 | 685 |
636 ScopedPtrVector<CopyOutputRequest> copy_requests_; | 686 ScopedPtrVector<CopyOutputRequest> copy_requests_; |
637 | 687 |
638 base::Closure did_scroll_callback_; | 688 base::Closure did_scroll_callback_; |
639 | 689 |
640 DrawProperties<Layer> draw_properties_; | 690 DrawProperties<Layer> draw_properties_; |
641 | 691 |
642 PaintProperties paint_properties_; | 692 PaintProperties paint_properties_; |
643 | 693 |
| 694 gfx::Rect visible_rect_from_property_trees_; |
644 DISALLOW_COPY_AND_ASSIGN(Layer); | 695 DISALLOW_COPY_AND_ASSIGN(Layer); |
645 }; | 696 }; |
646 | 697 |
647 } // namespace cc | 698 } // namespace cc |
648 | 699 |
649 #endif // CC_LAYERS_LAYER_H_ | 700 #endif // CC_LAYERS_LAYER_H_ |
OLD | NEW |