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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 } | 239 } |
239 bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; } | 240 bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; } |
240 bool is_clipped() const { return draw_properties_.is_clipped; } | 241 bool is_clipped() const { return draw_properties_.is_clipped; } |
241 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; } | 242 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; } |
242 gfx::Rect drawable_content_rect() const { | 243 gfx::Rect drawable_content_rect() const { |
243 return draw_properties_.drawable_content_rect; | 244 return draw_properties_.drawable_content_rect; |
244 } | 245 } |
245 gfx::Rect visible_content_rect() const { | 246 gfx::Rect visible_content_rect() const { |
246 return draw_properties_.visible_content_rect; | 247 return draw_properties_.visible_content_rect; |
247 } | 248 } |
249 bool has_render_target() const { | |
enne (OOO)
2014/12/10 23:45:59
What does this mean? When does something not have
Ian Vollick
2014/12/12 03:01:47
Yeah, this surprised me too. It can happen when, e
enne (OOO)
2014/12/12 19:05:48
If the subtree is skipped, why are you asking for
Ian Vollick
2014/12/15 21:45:17
Turns out that there are quite a few reasons we sk
| |
250 return draw_properties_.render_target && | |
251 draw_properties_.render_target->render_surface(); | |
252 } | |
248 Layer* render_target() { | 253 Layer* render_target() { |
249 DCHECK(!draw_properties_.render_target || | 254 DCHECK(!draw_properties_.render_target || |
250 draw_properties_.render_target->render_surface()); | 255 draw_properties_.render_target->render_surface()); |
251 return draw_properties_.render_target; | 256 return draw_properties_.render_target; |
252 } | 257 } |
253 const Layer* render_target() const { | 258 const Layer* render_target() const { |
254 DCHECK(!draw_properties_.render_target || | 259 DCHECK(!draw_properties_.render_target || |
255 draw_properties_.render_target->render_surface()); | 260 draw_properties_.render_target->render_surface()); |
256 return draw_properties_.render_target; | 261 return draw_properties_.render_target; |
257 } | 262 } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 | 455 |
451 void SetNeedsPushProperties(); | 456 void SetNeedsPushProperties(); |
452 bool needs_push_properties() const { return needs_push_properties_; } | 457 bool needs_push_properties() const { return needs_push_properties_; } |
453 bool descendant_needs_push_properties() const { | 458 bool descendant_needs_push_properties() const { |
454 return num_dependents_need_push_properties_ > 0; | 459 return num_dependents_need_push_properties_ > 0; |
455 } | 460 } |
456 void reset_needs_push_properties_for_testing() { | 461 void reset_needs_push_properties_for_testing() { |
457 needs_push_properties_ = false; | 462 needs_push_properties_ = false; |
458 } | 463 } |
459 | 464 |
465 bool NeedsVisibleRectUpdated() const; | |
466 | |
460 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); | 467 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); |
461 | 468 |
462 void Set3dSortingContextId(int id); | 469 void Set3dSortingContextId(int id); |
463 int sorting_context_id() const { return sorting_context_id_; } | 470 int sorting_context_id() const { return sorting_context_id_; } |
464 | 471 |
472 void set_transform_tree_index(int index) { transform_tree_index_ = index; } | |
473 void set_clip_tree_index(int index) { clip_tree_index_ = index; } | |
474 int clip_tree_index() const { return clip_tree_index_; } | |
475 int transform_tree_index() const { return transform_tree_index_; } | |
476 | |
477 void set_offset_to_transform_parent(gfx::Vector2dF offset) { | |
478 offset_to_transform_parent_ = offset; | |
479 } | |
480 gfx::Vector2dF offset_to_transform_parent() const { | |
481 return offset_to_transform_parent_; | |
482 } | |
483 | |
484 // TODO(vollick): Once we transition to transform and clip trees, rename these | |
485 // functions and related values. The "debug" functions below use the | |
486 // transform and clip trees. Eventually, we will use these functions to | |
487 // compute the official values, but these functions are retained for testing | |
488 // purposes until we've migrated. | |
489 | |
490 const gfx::Rect& debug_visible_rect() const { return debug_visible_rect_; } | |
enne (OOO)
2014/12/10 23:45:59
bikeshedding, but maybe visible_rect_from_property
Ian Vollick
2014/12/12 03:01:47
Done.
| |
491 void set_debug_visible_rect(const gfx::Rect& rect) { | |
492 debug_visible_rect_ = rect; | |
493 } | |
494 | |
495 gfx::Transform debug_screen_space_transform(const TransformTree& tree) const; | |
496 gfx::Transform debug_draw_transform(const TransformTree& tree) const; | |
497 | |
465 protected: | 498 protected: |
466 friend class LayerImpl; | 499 friend class LayerImpl; |
467 friend class TreeSynchronizer; | 500 friend class TreeSynchronizer; |
468 ~Layer() override; | 501 ~Layer() override; |
469 | 502 |
470 Layer(); | 503 Layer(); |
471 | 504 |
472 // These SetNeeds functions are in order of severity of update: | 505 // These SetNeeds functions are in order of severity of update: |
473 // | 506 // |
474 // Called when this layer has been modified in some way, but isn't sure | 507 // 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 | 615 |
583 // Layer properties. | 616 // Layer properties. |
584 gfx::Size bounds_; | 617 gfx::Size bounds_; |
585 | 618 |
586 gfx::ScrollOffset scroll_offset_; | 619 gfx::ScrollOffset scroll_offset_; |
587 // This variable indicates which ancestor layer (if any) whose size, | 620 // This variable indicates which ancestor layer (if any) whose size, |
588 // transformed relative to this layer, defines the maximum scroll offset for | 621 // transformed relative to this layer, defines the maximum scroll offset for |
589 // this layer. | 622 // this layer. |
590 int scroll_clip_layer_id_; | 623 int scroll_clip_layer_id_; |
591 int num_descendants_that_draw_content_; | 624 int num_descendants_that_draw_content_; |
625 int transform_tree_index_; | |
626 int opacity_tree_index_; | |
627 int clip_tree_index_; | |
628 gfx::Vector2dF offset_to_transform_parent_; | |
592 bool should_scroll_on_main_thread_ : 1; | 629 bool should_scroll_on_main_thread_ : 1; |
593 bool have_wheel_event_handlers_ : 1; | 630 bool have_wheel_event_handlers_ : 1; |
594 bool have_scroll_event_handlers_ : 1; | 631 bool have_scroll_event_handlers_ : 1; |
595 bool user_scrollable_horizontal_ : 1; | 632 bool user_scrollable_horizontal_ : 1; |
596 bool user_scrollable_vertical_ : 1; | 633 bool user_scrollable_vertical_ : 1; |
597 bool is_root_for_isolated_group_ : 1; | 634 bool is_root_for_isolated_group_ : 1; |
598 bool is_container_for_fixed_position_layers_ : 1; | 635 bool is_container_for_fixed_position_layers_ : 1; |
599 bool is_drawable_ : 1; | 636 bool is_drawable_ : 1; |
600 bool draws_content_ : 1; | 637 bool draws_content_ : 1; |
601 bool hide_layer_and_subtree_ : 1; | 638 bool hide_layer_and_subtree_ : 1; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 LayerClient* client_; | 671 LayerClient* client_; |
635 | 672 |
636 ScopedPtrVector<CopyOutputRequest> copy_requests_; | 673 ScopedPtrVector<CopyOutputRequest> copy_requests_; |
637 | 674 |
638 base::Closure did_scroll_callback_; | 675 base::Closure did_scroll_callback_; |
639 | 676 |
640 DrawProperties<Layer> draw_properties_; | 677 DrawProperties<Layer> draw_properties_; |
641 | 678 |
642 PaintProperties paint_properties_; | 679 PaintProperties paint_properties_; |
643 | 680 |
681 gfx::Rect debug_visible_rect_; | |
644 DISALLOW_COPY_AND_ASSIGN(Layer); | 682 DISALLOW_COPY_AND_ASSIGN(Layer); |
645 }; | 683 }; |
646 | 684 |
647 } // namespace cc | 685 } // namespace cc |
648 | 686 |
649 #endif // CC_LAYERS_LAYER_H_ | 687 #endif // CC_LAYERS_LAYER_H_ |
OLD | NEW |