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_QUADS_RENDER_PASS_H_ | 5 #ifndef CC_QUADS_RENDER_PASS_H_ |
6 #define CC_QUADS_RENDER_PASS_H_ | 6 #define CC_QUADS_RENDER_PASS_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
14 #include "cc/base/scoped_ptr_vector.h" | 14 #include "cc/base/scoped_ptr_vector.h" |
| 15 #include "cc/quads/list_container.h" |
15 #include "cc/quads/render_pass_id.h" | 16 #include "cc/quads/render_pass_id.h" |
16 #include "skia/ext/refptr.h" | 17 #include "skia/ext/refptr.h" |
17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
18 #include "ui/gfx/rect_f.h" | 19 #include "ui/gfx/rect_f.h" |
19 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 namespace debug { | 23 namespace debug { |
23 class TracedValue; | 24 class TracedValue; |
24 } | 25 } |
25 class Value; | 26 class Value; |
26 }; | 27 }; |
27 | 28 |
28 namespace cc { | 29 namespace cc { |
29 | 30 |
30 class DrawQuad; | 31 class DrawQuad; |
| 32 class CopyOutputRequest; |
31 class RenderPassDrawQuad; | 33 class RenderPassDrawQuad; |
32 class CopyOutputRequest; | |
33 class SharedQuadState; | 34 class SharedQuadState; |
34 | 35 |
35 // A list of DrawQuad objects, sorted internally in front-to-back order. | 36 // A list of DrawQuad objects, sorted internally in front-to-back order. |
36 class QuadList : public ScopedPtrVector<DrawQuad> { | 37 class QuadList : public ListContainer<DrawQuad> { |
37 public: | 38 public: |
38 typedef reverse_iterator BackToFrontIterator; | 39 explicit QuadList(size_t default_size_to_reserve); |
39 typedef const_reverse_iterator ConstBackToFrontIterator; | 40 |
| 41 typedef QuadList::ReverseIterator BackToFrontIterator; |
| 42 typedef QuadList::ConstReverseIterator ConstBackToFrontIterator; |
40 | 43 |
41 inline BackToFrontIterator BackToFrontBegin() { return rbegin(); } | 44 inline BackToFrontIterator BackToFrontBegin() { return rbegin(); } |
42 inline BackToFrontIterator BackToFrontEnd() { return rend(); } | 45 inline BackToFrontIterator BackToFrontEnd() { return rend(); } |
43 inline ConstBackToFrontIterator BackToFrontBegin() const { return rbegin(); } | 46 inline ConstBackToFrontIterator BackToFrontBegin() const { return rbegin(); } |
44 inline ConstBackToFrontIterator BackToFrontEnd() const { return rend(); } | 47 inline ConstBackToFrontIterator BackToFrontEnd() const { return rend(); } |
45 }; | 48 }; |
46 | 49 |
47 typedef ScopedPtrVector<SharedQuadState> SharedQuadStateList; | 50 typedef ScopedPtrVector<SharedQuadState> SharedQuadStateList; |
48 | 51 |
49 class CC_EXPORT RenderPass { | 52 class CC_EXPORT RenderPass { |
(...skipping 18 matching lines...) Expand all Loading... |
68 | 71 |
69 void SetAll(RenderPassId id, | 72 void SetAll(RenderPassId id, |
70 const gfx::Rect& output_rect, | 73 const gfx::Rect& output_rect, |
71 const gfx::Rect& damage_rect, | 74 const gfx::Rect& damage_rect, |
72 const gfx::Transform& transform_to_root_target, | 75 const gfx::Transform& transform_to_root_target, |
73 bool has_transparent_background); | 76 bool has_transparent_background); |
74 | 77 |
75 void AsValueInto(base::debug::TracedValue* dict) const; | 78 void AsValueInto(base::debug::TracedValue* dict) const; |
76 | 79 |
77 SharedQuadState* CreateAndAppendSharedQuadState(); | 80 SharedQuadState* CreateAndAppendSharedQuadState(); |
| 81 |
78 template <typename DrawQuadType> | 82 template <typename DrawQuadType> |
79 DrawQuadType* CreateAndAppendDrawQuad() { | 83 DrawQuadType* CreateAndAppendDrawQuad() { |
80 scoped_ptr<DrawQuadType> draw_quad = make_scoped_ptr(new DrawQuadType); | 84 return quad_list.AllocateAndConstruct<DrawQuadType>(); |
81 quad_list.push_back(draw_quad.template PassAs<DrawQuad>()); | |
82 return static_cast<DrawQuadType*>(quad_list.back()); | |
83 } | 85 } |
84 | 86 |
85 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( | 87 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( |
86 const RenderPassDrawQuad* quad, | 88 const RenderPassDrawQuad* quad, |
87 const SharedQuadState* shared_quad_state, | 89 const SharedQuadState* shared_quad_state, |
88 RenderPassId render_pass_id); | 90 RenderPassId render_pass_id); |
89 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, | 91 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, |
90 const SharedQuadState* shared_quad_state); | 92 const SharedQuadState* shared_quad_state); |
91 | 93 |
92 // Uniquely identifies the render pass in the compositor's current frame. | 94 // Uniquely identifies the render pass in the compositor's current frame. |
(...skipping 19 matching lines...) Expand all Loading... |
112 QuadList quad_list; | 114 QuadList quad_list; |
113 SharedQuadStateList shared_quad_state_list; | 115 SharedQuadStateList shared_quad_state_list; |
114 | 116 |
115 protected: | 117 protected: |
116 explicit RenderPass(size_t num_layers); | 118 explicit RenderPass(size_t num_layers); |
117 RenderPass(); | 119 RenderPass(); |
118 | 120 |
119 private: | 121 private: |
120 template <typename DrawQuadType> | 122 template <typename DrawQuadType> |
121 DrawQuadType* CopyFromAndAppendTypedDrawQuad(const DrawQuad* quad) { | 123 DrawQuadType* CopyFromAndAppendTypedDrawQuad(const DrawQuad* quad) { |
122 scoped_ptr<DrawQuadType> draw_quad = | 124 return quad_list.AllocateAndCopyFrom(DrawQuadType::MaterialCast(quad)); |
123 make_scoped_ptr(new DrawQuadType(*DrawQuadType::MaterialCast(quad))); | |
124 quad_list.push_back(draw_quad.template PassAs<DrawQuad>()); | |
125 return static_cast<DrawQuadType*>(quad_list.back()); | |
126 } | 125 } |
127 | 126 |
128 DISALLOW_COPY_AND_ASSIGN(RenderPass); | 127 DISALLOW_COPY_AND_ASSIGN(RenderPass); |
129 }; | 128 }; |
130 | 129 |
131 } // namespace cc | 130 } // namespace cc |
132 | 131 |
133 namespace BASE_HASH_NAMESPACE { | 132 namespace BASE_HASH_NAMESPACE { |
134 #if defined(COMPILER_MSVC) | 133 #if defined(COMPILER_MSVC) |
135 inline size_t hash_value(const cc::RenderPassId& key) { | 134 inline size_t hash_value(const cc::RenderPassId& key) { |
(...skipping 10 matching lines...) Expand all Loading... |
146 #error define a hash function for your compiler | 145 #error define a hash function for your compiler |
147 #endif // COMPILER | 146 #endif // COMPILER |
148 } // namespace BASE_HASH_NAMESPACE | 147 } // namespace BASE_HASH_NAMESPACE |
149 | 148 |
150 namespace cc { | 149 namespace cc { |
151 typedef ScopedPtrVector<RenderPass> RenderPassList; | 150 typedef ScopedPtrVector<RenderPass> RenderPassList; |
152 typedef base::hash_map<RenderPassId, RenderPass*> RenderPassIdHashMap; | 151 typedef base::hash_map<RenderPassId, RenderPass*> RenderPassIdHashMap; |
153 } // namespace cc | 152 } // namespace cc |
154 | 153 |
155 #endif // CC_QUADS_RENDER_PASS_H_ | 154 #endif // CC_QUADS_RENDER_PASS_H_ |
OLD | NEW |