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 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "cc/animation/layer_animation_controller.h" | 15 #include "cc/animation/layer_animation_controller.h" |
16 #include "cc/animation/layer_animation_value_observer.h" | 16 #include "cc/animation/layer_animation_value_observer.h" |
17 #include "cc/animation/layer_animation_value_provider.h" | 17 #include "cc/animation/layer_animation_value_provider.h" |
18 #include "cc/base/cc_export.h" | 18 #include "cc/base/cc_export.h" |
19 #include "cc/base/region.h" | 19 #include "cc/base/region.h" |
20 #include "cc/base/scoped_ptr_vector.h" | 20 #include "cc/base/scoped_ptr_vector.h" |
21 #include "cc/debug/frame_timing_request.h" | 21 #include "cc/debug/frame_timing_request.h" |
22 #include "cc/debug/micro_benchmark.h" | 22 #include "cc/debug/micro_benchmark.h" |
23 #include "cc/layers/layer_lists.h" | 23 #include "cc/layers/layer_lists.h" |
24 #include "cc/layers/layer_position_constraint.h" | 24 #include "cc/layers/layer_position_constraint.h" |
25 #include "cc/layers/paint_properties.h" | 25 #include "cc/layers/paint_properties.h" |
26 #include "cc/layers/scroll_blocks_on.h" | 26 #include "cc/layers/scroll_blocks_on.h" |
27 #include "cc/output/filter_operations.h" | 27 #include "cc/output/filter_operations.h" |
28 #include "cc/proto/layer.pb.h" | |
28 #include "cc/trees/property_tree.h" | 29 #include "cc/trees/property_tree.h" |
29 #include "skia/ext/refptr.h" | 30 #include "skia/ext/refptr.h" |
30 #include "third_party/skia/include/core/SkColor.h" | 31 #include "third_party/skia/include/core/SkColor.h" |
31 #include "third_party/skia/include/core/SkImageFilter.h" | 32 #include "third_party/skia/include/core/SkImageFilter.h" |
32 #include "third_party/skia/include/core/SkPicture.h" | 33 #include "third_party/skia/include/core/SkPicture.h" |
33 #include "third_party/skia/include/core/SkXfermode.h" | 34 #include "third_party/skia/include/core/SkXfermode.h" |
34 #include "ui/gfx/geometry/point3_f.h" | 35 #include "ui/gfx/geometry/point3_f.h" |
35 #include "ui/gfx/geometry/rect.h" | 36 #include "ui/gfx/geometry/rect.h" |
36 #include "ui/gfx/geometry/rect_f.h" | 37 #include "ui/gfx/geometry/rect_f.h" |
37 #include "ui/gfx/geometry/scroll_offset.h" | 38 #include "ui/gfx/geometry/scroll_offset.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
67 class SimpleEnclosedRegion; | 68 class SimpleEnclosedRegion; |
68 struct AnimationEvent; | 69 struct AnimationEvent; |
69 | 70 |
70 // Base class for composited layers. Special layer types are derived from | 71 // Base class for composited layers. Special layer types are derived from |
71 // this class. | 72 // this class. |
72 class CC_EXPORT Layer : public base::RefCounted<Layer>, | 73 class CC_EXPORT Layer : public base::RefCounted<Layer>, |
73 public LayerAnimationValueObserver, | 74 public LayerAnimationValueObserver, |
74 public LayerAnimationValueProvider { | 75 public LayerAnimationValueProvider { |
75 public: | 76 public: |
76 typedef LayerList LayerListType; | 77 typedef LayerList LayerListType; |
78 typedef base::hash_map<int, scoped_refptr<Layer>> LayerIdMap; | |
77 | 79 |
78 enum LayerIdLabels { | 80 enum LayerIdLabels { |
79 INVALID_ID = -1, | 81 INVALID_ID = -1, |
80 }; | 82 }; |
81 | 83 |
82 static scoped_refptr<Layer> Create(const LayerSettings& settings); | 84 static scoped_refptr<Layer> Create(const LayerSettings& settings); |
83 | 85 |
84 int id() const { return layer_id_; } | 86 int id() const { return layer_id_; } |
85 | 87 |
86 Layer* RootLayer(); | 88 Layer* RootLayer(); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 virtual void SetIsMask(bool is_mask) {} | 353 virtual void SetIsMask(bool is_mask) {} |
352 virtual bool IsSuitableForGpuRasterization() const; | 354 virtual bool IsSuitableForGpuRasterization() const; |
353 | 355 |
354 virtual scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 356 virtual scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
355 TakeDebugInfo(); | 357 TakeDebugInfo(); |
356 | 358 |
357 void SetLayerClient(LayerClient* client) { client_ = client; } | 359 void SetLayerClient(LayerClient* client) { client_ = client; } |
358 | 360 |
359 virtual void PushPropertiesTo(LayerImpl* layer); | 361 virtual void PushPropertiesTo(LayerImpl* layer); |
360 | 362 |
363 // Return the proto::LayerType that should be used for serialization of the | |
364 // current layer. | |
365 virtual proto::LayerType GetTypeForProtoSerialization() const; | |
366 | |
367 // Recursively iterate over this layer and all children and write the | |
368 // hierarchical structure to the given LayerNode proto. In addition to the | |
369 // structure itself, the Layer id and type is also written to facilitate | |
370 // construction of the correct layer on the client. | |
371 | |
372 void ToLayerNodeProto(proto::LayerNode* proto) const; | |
vmpstr
2015/10/26 17:51:45
I meant like
// comment
// comment
void function
nyquist
2015/10/26 19:01:53
Wow... I don't even... Sorry... :-/
| |
373 // Recursively iterate over the given LayerNode proto and read the structure | |
374 // into this node and its children. The |layer_map| should be used to look | |
375 // for previously existing Layers, since they should be re-used between each | |
376 // hierarchy update. | |
377 virtual void FromLayerNodeProto(const proto::LayerNode& proto, | |
vmpstr
2015/10/26 17:51:45
Can this also be non virtual?
nyquist
2015/10/26 19:01:53
Doh... Yeah! Done.
| |
378 const LayerIdMap& layer_map); | |
379 | |
361 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } | 380 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } |
362 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } | 381 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } |
363 | 382 |
364 bool AddAnimation(scoped_ptr<Animation> animation); | 383 bool AddAnimation(scoped_ptr<Animation> animation); |
365 void PauseAnimation(int animation_id, double time_offset); | 384 void PauseAnimation(int animation_id, double time_offset); |
366 void RemoveAnimation(int animation_id); | 385 void RemoveAnimation(int animation_id); |
367 void RemoveAnimation(int animation_id, Animation::TargetProperty property); | 386 void RemoveAnimation(int animation_id, Animation::TargetProperty property); |
368 LayerAnimationController* layer_animation_controller() const { | 387 LayerAnimationController* layer_animation_controller() const { |
369 return layer_animation_controller_.get(); | 388 return layer_animation_controller_.get(); |
370 } | 389 } |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 | 732 |
714 std::vector<FrameTimingRequest> frame_timing_requests_; | 733 std::vector<FrameTimingRequest> frame_timing_requests_; |
715 bool frame_timing_requests_dirty_; | 734 bool frame_timing_requests_dirty_; |
716 | 735 |
717 DISALLOW_COPY_AND_ASSIGN(Layer); | 736 DISALLOW_COPY_AND_ASSIGN(Layer); |
718 }; | 737 }; |
719 | 738 |
720 } // namespace cc | 739 } // namespace cc |
721 | 740 |
722 #endif // CC_LAYERS_LAYER_H_ | 741 #endif // CC_LAYERS_LAYER_H_ |
OLD | NEW |