OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_QUADS_RENDER_PASS_H_ | |
6 #define CC_QUADS_RENDER_PASS_H_ | |
7 | |
8 #include <utility> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/callback.h" | |
12 #include "base/containers/hash_tables.h" | |
13 #include "cc/base/scoped_ptr_vector.h" | |
14 #include "cc/quads/list_container.h" | |
15 #include "cc/quads/render_pass_id.h" | |
16 #include "skia/ext/refptr.h" | |
17 #include "ui/gfx/geometry/rect.h" | |
18 #include "ui/gfx/geometry/rect_f.h" | |
19 #include "ui/gfx/transform.h" | |
20 | |
21 namespace base { | |
22 namespace trace_event { | |
23 class TracedValue; | |
24 } | |
25 class Value; | |
26 } | |
27 | |
28 namespace cc { | |
29 | |
30 class DrawQuad; | |
31 class CopyOutputRequest; | |
32 class RenderPassDrawQuad; | |
33 class SharedQuadState; | |
34 | |
35 // A list of DrawQuad objects, sorted internally in front-to-back order. | |
36 class QuadList : public ListContainer<DrawQuad> { | |
37 public: | |
38 explicit QuadList(size_t default_size_to_reserve); | |
39 | |
40 typedef QuadList::ReverseIterator BackToFrontIterator; | |
41 typedef QuadList::ConstReverseIterator ConstBackToFrontIterator; | |
42 | |
43 inline BackToFrontIterator BackToFrontBegin() { return rbegin(); } | |
44 inline BackToFrontIterator BackToFrontEnd() { return rend(); } | |
45 inline ConstBackToFrontIterator BackToFrontBegin() const { return rbegin(); } | |
46 inline ConstBackToFrontIterator BackToFrontEnd() const { return rend(); } | |
47 }; | |
48 | |
49 typedef ListContainer<SharedQuadState> SharedQuadStateList; | |
50 | |
51 class RenderPass { | |
52 public: | |
53 ~RenderPass(); | |
54 | |
55 static scoped_ptr<RenderPass> Create(); | |
56 static scoped_ptr<RenderPass> Create(size_t num_layers); | |
57 static scoped_ptr<RenderPass> Create(size_t shared_quad_state_list_size, | |
58 size_t quad_list_size); | |
59 | |
60 // A shallow copy of the render pass, which does not include its quads or copy | |
61 // requests. | |
62 scoped_ptr<RenderPass> Copy(RenderPassId new_id) const; | |
63 | |
64 // A deep copy of the render passes in the list including the quads. | |
65 static void CopyAll(const ScopedPtrVector<RenderPass>& in, | |
66 ScopedPtrVector<RenderPass>* out); | |
67 | |
68 void SetNew(RenderPassId id, | |
69 const gfx::Rect& output_rect, | |
70 const gfx::Rect& damage_rect, | |
71 const gfx::Transform& transform_to_root_target); | |
72 | |
73 void SetAll(RenderPassId id, | |
74 const gfx::Rect& output_rect, | |
75 const gfx::Rect& damage_rect, | |
76 const gfx::Transform& transform_to_root_target, | |
77 bool has_transparent_background); | |
78 | |
79 void AsValueInto(base::trace_event::TracedValue* dict) const; | |
80 | |
81 SharedQuadState* CreateAndAppendSharedQuadState(); | |
82 | |
83 template <typename DrawQuadType> | |
84 DrawQuadType* CreateAndAppendDrawQuad() { | |
85 return quad_list.AllocateAndConstruct<DrawQuadType>(); | |
86 } | |
87 | |
88 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( | |
89 const RenderPassDrawQuad* quad, | |
90 const SharedQuadState* shared_quad_state, | |
91 RenderPassId render_pass_id); | |
92 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, | |
93 const SharedQuadState* shared_quad_state); | |
94 | |
95 // Uniquely identifies the render pass in the compositor's current frame. | |
96 RenderPassId id; | |
97 | |
98 // These are in the space of the render pass' physical pixels. | |
99 gfx::Rect output_rect; | |
100 gfx::Rect damage_rect; | |
101 | |
102 // Transforms from the origin of the |output_rect| to the origin of the root | |
103 // render pass' |output_rect|. | |
104 gfx::Transform transform_to_root_target; | |
105 | |
106 // If false, the pixels in the render pass' texture are all opaque. | |
107 bool has_transparent_background; | |
108 | |
109 // If non-empty, the renderer should produce a copy of the render pass' | |
110 // contents as a bitmap, and give a copy of the bitmap to each callback in | |
111 // this list. This property should not be serialized between compositors, as | |
112 // it only makes sense in the root compositor. | |
113 ScopedPtrVector<CopyOutputRequest> copy_requests; | |
114 | |
115 QuadList quad_list; | |
116 SharedQuadStateList shared_quad_state_list; | |
117 | |
118 protected: | |
119 explicit RenderPass(size_t num_layers); | |
120 RenderPass(); | |
121 RenderPass(size_t shared_quad_state_list_size, size_t quad_list_size); | |
122 | |
123 private: | |
124 template <typename DrawQuadType> | |
125 DrawQuadType* CopyFromAndAppendTypedDrawQuad(const DrawQuad* quad) { | |
126 return quad_list.AllocateAndCopyFrom(DrawQuadType::MaterialCast(quad)); | |
127 } | |
128 | |
129 DISALLOW_COPY_AND_ASSIGN(RenderPass); | |
130 }; | |
131 | |
132 } // namespace cc | |
133 | |
134 namespace BASE_HASH_NAMESPACE { | |
135 template <> | |
136 struct hash<cc::RenderPassId> { | |
137 size_t operator()(cc::RenderPassId key) const { | |
138 return base::HashPair(key.layer_id, key.index); | |
139 } | |
140 }; | |
141 } // namespace BASE_HASH_NAMESPACE | |
142 | |
143 namespace cc { | |
144 typedef ScopedPtrVector<RenderPass> RenderPassList; | |
145 typedef base::hash_map<RenderPassId, RenderPass*> RenderPassIdHashMap; | |
146 } // namespace cc | |
147 | |
148 #endif // CC_QUADS_RENDER_PASS_H_ | |
OLD | NEW |