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