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 QuadList::ReverseIterator BackToFrontIterator; |
| 45 typedef 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 return quad_list.AllocateAndConstruct<DrawQuadType>(); |
81 quad_list.push_back(draw_quad.template PassAs<DrawQuad>()); | |
82 return static_cast<DrawQuadType*>(quad_list.back()); | |
83 } | 88 } |
84 | 89 |
85 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( | 90 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( |
86 const RenderPassDrawQuad* quad, | 91 const RenderPassDrawQuad* quad, |
87 const SharedQuadState* shared_quad_state, | 92 const SharedQuadState* shared_quad_state, |
88 RenderPassId render_pass_id); | 93 RenderPassId render_pass_id); |
89 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, | 94 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, |
90 const SharedQuadState* shared_quad_state); | 95 const SharedQuadState* shared_quad_state); |
91 | 96 |
92 // Uniquely identifies the render pass in the compositor's current frame. | 97 // Uniquely identifies the render pass in the compositor's current frame. |
(...skipping 19 matching lines...) Expand all Loading... |
112 QuadList quad_list; | 117 QuadList quad_list; |
113 SharedQuadStateList shared_quad_state_list; | 118 SharedQuadStateList shared_quad_state_list; |
114 | 119 |
115 protected: | 120 protected: |
116 explicit RenderPass(size_t num_layers); | 121 explicit RenderPass(size_t num_layers); |
117 RenderPass(); | 122 RenderPass(); |
118 | 123 |
119 private: | 124 private: |
120 template <typename DrawQuadType> | 125 template <typename DrawQuadType> |
121 DrawQuadType* CopyFromAndAppendTypedDrawQuad(const DrawQuad* quad) { | 126 DrawQuadType* CopyFromAndAppendTypedDrawQuad(const DrawQuad* quad) { |
122 scoped_ptr<DrawQuadType> draw_quad = | 127 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 } | 128 } |
127 | 129 |
128 DISALLOW_COPY_AND_ASSIGN(RenderPass); | 130 DISALLOW_COPY_AND_ASSIGN(RenderPass); |
129 }; | 131 }; |
130 | 132 |
131 } // namespace cc | 133 } // namespace cc |
132 | 134 |
133 namespace BASE_HASH_NAMESPACE { | 135 namespace BASE_HASH_NAMESPACE { |
134 #if defined(COMPILER_MSVC) | 136 #if defined(COMPILER_MSVC) |
135 inline size_t hash_value(const cc::RenderPassId& key) { | 137 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 | 148 #error define a hash function for your compiler |
147 #endif // COMPILER | 149 #endif // COMPILER |
148 } // namespace BASE_HASH_NAMESPACE | 150 } // namespace BASE_HASH_NAMESPACE |
149 | 151 |
150 namespace cc { | 152 namespace cc { |
151 typedef ScopedPtrVector<RenderPass> RenderPassList; | 153 typedef ScopedPtrVector<RenderPass> RenderPassList; |
152 typedef base::hash_map<RenderPassId, RenderPass*> RenderPassIdHashMap; | 154 typedef base::hash_map<RenderPassId, RenderPass*> RenderPassIdHashMap; |
153 } // namespace cc | 155 } // namespace cc |
154 | 156 |
155 #endif // CC_QUADS_RENDER_PASS_H_ | 157 #endif // CC_QUADS_RENDER_PASS_H_ |
OLD | NEW |