Delete unused downloads page asset.
[chromium-blink-merge.git] / cc / quads / render_pass.h
blob14caeba7c7af9d0fceadac7435b9795c3d5a9000
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.
5 #ifndef CC_QUADS_RENDER_PASS_H_
6 #define CC_QUADS_RENDER_PASS_H_
8 #include <utility>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/containers/hash_tables.h"
13 #include "cc/base/cc_export.h"
14 #include "cc/base/list_container.h"
15 #include "cc/base/scoped_ptr_vector.h"
16 #include "cc/quads/render_pass_id.h"
17 #include "cc/surfaces/surface_id.h"
18 #include "skia/ext/refptr.h"
19 #include "ui/gfx/geometry/rect.h"
20 #include "ui/gfx/geometry/rect_f.h"
21 #include "ui/gfx/transform.h"
23 namespace base {
24 namespace trace_event {
25 class TracedValue;
27 class Value;
30 namespace cc {
32 class DrawQuad;
33 class CopyOutputRequest;
34 class RenderPassDrawQuad;
35 class SharedQuadState;
37 // A list of DrawQuad objects, sorted internally in front-to-back order.
38 class QuadList : public ListContainer<DrawQuad> {
39 public:
40 explicit QuadList(size_t default_size_to_reserve);
42 typedef QuadList::ReverseIterator BackToFrontIterator;
43 typedef QuadList::ConstReverseIterator ConstBackToFrontIterator;
45 inline BackToFrontIterator BackToFrontBegin() { return rbegin(); }
46 inline BackToFrontIterator BackToFrontEnd() { return rend(); }
47 inline ConstBackToFrontIterator BackToFrontBegin() const { return rbegin(); }
48 inline ConstBackToFrontIterator BackToFrontEnd() const { return rend(); }
51 typedef ListContainer<SharedQuadState> SharedQuadStateList;
53 class CC_EXPORT RenderPass {
54 public:
55 ~RenderPass();
57 static scoped_ptr<RenderPass> Create();
58 static scoped_ptr<RenderPass> Create(size_t num_layers);
59 static scoped_ptr<RenderPass> Create(size_t shared_quad_state_list_size,
60 size_t quad_list_size);
62 // A shallow copy of the render pass, which does not include its quads or copy
63 // requests.
64 scoped_ptr<RenderPass> Copy(RenderPassId new_id) const;
66 // A deep copy of the render passes in the list including the quads.
67 static void CopyAll(const ScopedPtrVector<RenderPass>& in,
68 ScopedPtrVector<RenderPass>* out);
70 void SetNew(RenderPassId id,
71 const gfx::Rect& output_rect,
72 const gfx::Rect& damage_rect,
73 const gfx::Transform& transform_to_root_target);
75 void SetAll(RenderPassId id,
76 const gfx::Rect& output_rect,
77 const gfx::Rect& damage_rect,
78 const gfx::Transform& transform_to_root_target,
79 bool has_transparent_background);
81 void AsValueInto(base::trace_event::TracedValue* dict) const;
83 SharedQuadState* CreateAndAppendSharedQuadState();
85 template <typename DrawQuadType>
86 DrawQuadType* CreateAndAppendDrawQuad() {
87 return quad_list.AllocateAndConstruct<DrawQuadType>();
90 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad(
91 const RenderPassDrawQuad* quad,
92 const SharedQuadState* shared_quad_state,
93 RenderPassId render_pass_id);
94 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad,
95 const SharedQuadState* shared_quad_state);
97 // Uniquely identifies the render pass in the compositor's current frame.
98 RenderPassId id;
100 // These are in the space of the render pass' physical pixels.
101 gfx::Rect output_rect;
102 gfx::Rect damage_rect;
104 // Transforms from the origin of the |output_rect| to the origin of the root
105 // render pass' |output_rect|.
106 gfx::Transform transform_to_root_target;
108 // If false, the pixels in the render pass' texture are all opaque.
109 bool has_transparent_background;
111 // If non-empty, the renderer should produce a copy of the render pass'
112 // contents as a bitmap, and give a copy of the bitmap to each callback in
113 // this list. This property should not be serialized between compositors, as
114 // it only makes sense in the root compositor.
115 ScopedPtrVector<CopyOutputRequest> copy_requests;
117 QuadList quad_list;
118 SharedQuadStateList shared_quad_state_list;
120 // This vector contains the complete set of SurfaceIds referenced by
121 // DrawQuads in quad_list.
122 std::vector<SurfaceId> referenced_surfaces;
124 protected:
125 explicit RenderPass(size_t num_layers);
126 RenderPass();
127 RenderPass(size_t shared_quad_state_list_size, size_t quad_list_size);
129 private:
130 template <typename DrawQuadType>
131 DrawQuadType* CopyFromAndAppendTypedDrawQuad(const DrawQuad* quad) {
132 return quad_list.AllocateAndCopyFrom(DrawQuadType::MaterialCast(quad));
135 DISALLOW_COPY_AND_ASSIGN(RenderPass);
138 } // namespace cc
140 namespace BASE_HASH_NAMESPACE {
141 template <>
142 struct hash<cc::RenderPassId> {
143 size_t operator()(cc::RenderPassId key) const {
144 return base::HashPair(key.layer_id, static_cast<int>(key.index));
147 } // namespace BASE_HASH_NAMESPACE
149 namespace cc {
150 typedef ScopedPtrVector<RenderPass> RenderPassList;
151 typedef base::hash_map<RenderPassId, RenderPass*> RenderPassIdHashMap;
152 } // namespace cc
154 #endif // CC_QUADS_RENDER_PASS_H_