OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_IMPL_H_ | 5 #ifndef CC_LAYERS_LAYER_IMPL_H_ |
6 #define CC_LAYERS_LAYER_IMPL_H_ | 6 #define CC_LAYERS_LAYER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "cc/animation/layer_animation_controller.h" | 13 #include "cc/animation/layer_animation_controller.h" |
14 #include "cc/animation/layer_animation_value_observer.h" | 14 #include "cc/animation/layer_animation_value_observer.h" |
15 #include "cc/base/cc_export.h" | 15 #include "cc/base/cc_export.h" |
16 #include "cc/base/region.h" | 16 #include "cc/base/region.h" |
17 #include "cc/base/scoped_ptr_vector.h" | 17 #include "cc/base/scoped_ptr_vector.h" |
18 #include "cc/input/input_handler.h" | 18 #include "cc/input/input_handler.h" |
19 #include "cc/layers/draw_properties.h" | 19 #include "cc/layers/draw_properties.h" |
| 20 #include "cc/layers/layer_lists.h" |
20 #include "cc/layers/render_surface_impl.h" | 21 #include "cc/layers/render_surface_impl.h" |
21 #include "cc/quads/render_pass.h" | 22 #include "cc/quads/render_pass.h" |
22 #include "cc/quads/shared_quad_state.h" | 23 #include "cc/quads/shared_quad_state.h" |
23 #include "cc/resources/resource_provider.h" | 24 #include "cc/resources/resource_provider.h" |
24 #include "skia/ext/refptr.h" | 25 #include "skia/ext/refptr.h" |
25 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" | 26 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" |
26 #include "third_party/skia/include/core/SkColor.h" | 27 #include "third_party/skia/include/core/SkColor.h" |
27 #include "third_party/skia/include/core/SkImageFilter.h" | 28 #include "third_party/skia/include/core/SkImageFilter.h" |
28 #include "third_party/skia/include/core/SkPicture.h" | 29 #include "third_party/skia/include/core/SkPicture.h" |
29 #include "ui/gfx/rect.h" | 30 #include "ui/gfx/rect.h" |
(...skipping 11 matching lines...) Expand all Loading... |
41 class QuadSink; | 42 class QuadSink; |
42 class Renderer; | 43 class Renderer; |
43 class ScrollbarAnimationController; | 44 class ScrollbarAnimationController; |
44 class ScrollbarLayerImpl; | 45 class ScrollbarLayerImpl; |
45 class Layer; | 46 class Layer; |
46 | 47 |
47 struct AppendQuadsData; | 48 struct AppendQuadsData; |
48 | 49 |
49 class CC_EXPORT LayerImpl : LayerAnimationValueObserver { | 50 class CC_EXPORT LayerImpl : LayerAnimationValueObserver { |
50 public: | 51 public: |
51 typedef ScopedPtrVector<LayerImpl> LayerList; | |
52 | |
53 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 52 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
54 return make_scoped_ptr(new LayerImpl(tree_impl, id)); | 53 return make_scoped_ptr(new LayerImpl(tree_impl, id)); |
55 } | 54 } |
56 | 55 |
57 virtual ~LayerImpl(); | 56 virtual ~LayerImpl(); |
58 | 57 |
59 int id() const { return layer_id_; } | 58 int id() const { return layer_id_; } |
60 | 59 |
61 // LayerAnimationValueObserver implementation. | 60 // LayerAnimationValueObserver implementation. |
62 virtual void OnOpacityAnimated(float opacity) OVERRIDE; | 61 virtual void OnOpacityAnimated(float opacity) OVERRIDE; |
63 virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE; | 62 virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE; |
64 virtual bool IsActive() const OVERRIDE; | 63 virtual bool IsActive() const OVERRIDE; |
65 | 64 |
66 // Tree structure. | 65 // Tree structure. |
67 LayerImpl* parent() { return parent_; } | 66 LayerImpl* parent() { return parent_; } |
68 const LayerImpl* parent() const { return parent_; } | 67 const LayerImpl* parent() const { return parent_; } |
69 const LayerList& children() const { return children_; } | 68 const OwnedLayerImplList& children() const { return children_; } |
70 LayerList& children() { return children_; } | 69 OwnedLayerImplList& children() { return children_; } |
71 LayerImpl* child_at(size_t index) const { return children_[index]; } | 70 LayerImpl* child_at(size_t index) const { return children_[index]; } |
72 void AddChild(scoped_ptr<LayerImpl> child); | 71 void AddChild(scoped_ptr<LayerImpl> child); |
73 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child); | 72 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child); |
74 void set_parent(LayerImpl* parent) { parent_ = parent; } | 73 void set_parent(LayerImpl* parent) { parent_ = parent; } |
75 // Warning: This does not preserve tree structure invariants. | 74 // Warning: This does not preserve tree structure invariants. |
76 void ClearChildList(); | 75 void ClearChildList(); |
77 | 76 |
78 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer); | 77 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer); |
79 LayerImpl* mask_layer() { return mask_layer_.get(); } | 78 LayerImpl* mask_layer() { return mask_layer_.get(); } |
80 const LayerImpl* mask_layer() const { return mask_layer_.get(); } | 79 const LayerImpl* mask_layer() const { return mask_layer_.get(); } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // Debug layer name. | 184 // Debug layer name. |
186 void SetDebugName(const std::string& debug_name) { debug_name_ = debug_name; } | 185 void SetDebugName(const std::string& debug_name) { debug_name_ = debug_name; } |
187 std::string debug_name() const { return debug_name_; } | 186 std::string debug_name() const { return debug_name_; } |
188 | 187 |
189 bool ShowDebugBorders() const; | 188 bool ShowDebugBorders() const; |
190 | 189 |
191 // These invalidate the host's render surface layer list. The caller | 190 // These invalidate the host's render surface layer list. The caller |
192 // is responsible for calling set_needs_update_draw_properties on the tree | 191 // is responsible for calling set_needs_update_draw_properties on the tree |
193 // so that its list can be recreated. | 192 // so that its list can be recreated. |
194 void CreateRenderSurface(); | 193 void CreateRenderSurface(); |
195 void ClearRenderSurface() { draw_properties_.render_surface.reset(); } | 194 void ClearRenderSurface(); |
196 | 195 |
197 DrawProperties<LayerImpl, RenderSurfaceImpl>& draw_properties() { | 196 DrawProperties<LayerImpl, RenderSurfaceImpl>& draw_properties() { |
198 return draw_properties_; | 197 return draw_properties_; |
199 } | 198 } |
200 const DrawProperties<LayerImpl, RenderSurfaceImpl>& draw_properties() const { | 199 const DrawProperties<LayerImpl, RenderSurfaceImpl>& draw_properties() const { |
201 return draw_properties_; | 200 return draw_properties_; |
202 } | 201 } |
203 | 202 |
204 // The following are shortcut accessors to get various information from | 203 // The following are shortcut accessors to get various information from |
205 // draw_properties_ | 204 // draw_properties_ |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 417 |
419 private: | 418 private: |
420 void UpdateScrollbarPositions(); | 419 void UpdateScrollbarPositions(); |
421 | 420 |
422 virtual const char* LayerTypeAsString() const; | 421 virtual const char* LayerTypeAsString() const; |
423 | 422 |
424 void DumpLayer(std::string* str, int indent) const; | 423 void DumpLayer(std::string* str, int indent) const; |
425 | 424 |
426 // Properties internal to LayerImpl | 425 // Properties internal to LayerImpl |
427 LayerImpl* parent_; | 426 LayerImpl* parent_; |
428 LayerList children_; | 427 OwnedLayerImplList children_; |
429 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to | 428 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to |
430 // confirm newly assigned layer is still the previous one | 429 // confirm newly assigned layer is still the previous one |
431 int mask_layer_id_; | 430 int mask_layer_id_; |
432 scoped_ptr<LayerImpl> mask_layer_; | 431 scoped_ptr<LayerImpl> mask_layer_; |
433 int replica_layer_id_; // ditto | 432 int replica_layer_id_; // ditto |
434 scoped_ptr<LayerImpl> replica_layer_; | 433 scoped_ptr<LayerImpl> replica_layer_; |
435 int layer_id_; | 434 int layer_id_; |
436 LayerTreeImpl* layer_tree_impl_; | 435 LayerTreeImpl* layer_tree_impl_; |
437 | 436 |
438 // Properties synchronized from the associated Layer. | 437 // Properties synchronized from the associated Layer. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 // Group of properties that need to be computed based on the layer tree | 519 // Group of properties that need to be computed based on the layer tree |
521 // hierarchy before layers can be drawn. | 520 // hierarchy before layers can be drawn. |
522 DrawProperties<LayerImpl, RenderSurfaceImpl> draw_properties_; | 521 DrawProperties<LayerImpl, RenderSurfaceImpl> draw_properties_; |
523 | 522 |
524 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 523 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
525 }; | 524 }; |
526 | 525 |
527 } // namespace cc | 526 } // namespace cc |
528 | 527 |
529 #endif // CC_LAYERS_LAYER_IMPL_H_ | 528 #endif // CC_LAYERS_LAYER_IMPL_H_ |
OLD | NEW |