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_
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/scoped_ptr_vector.h"
15 #include "skia/ext/refptr.h"
16 #include "third_party/skia/include/core/SkColor.h"
17 #include "third_party/skia/include/core/SkImageFilter.h"
18 #include "ui/gfx/rect.h"
19 #include "ui/gfx/rect_f.h"
20 #include "ui/gfx/transform.h"
29 class CopyOutputRequest
;
30 class SharedQuadState
;
32 // A list of DrawQuad objects, sorted internally in front-to-back order.
33 class QuadList
: public ScopedPtrVector
<DrawQuad
> {
35 typedef reverse_iterator BackToFrontIterator
;
36 typedef const_reverse_iterator ConstBackToFrontIterator
;
38 inline BackToFrontIterator
BackToFrontBegin() { return rbegin(); }
39 inline BackToFrontIterator
BackToFrontEnd() { return rend(); }
40 inline ConstBackToFrontIterator
BackToFrontBegin() const { return rbegin(); }
41 inline ConstBackToFrontIterator
BackToFrontEnd() const { return rend(); }
44 typedef ScopedPtrVector
<SharedQuadState
> SharedQuadStateList
;
46 class CC_EXPORT RenderPass
{
52 Id(int layer_id
, int index
) : layer_id(layer_id
), index(index
) {}
53 void* AsTracingId() const;
55 bool operator==(const Id
& other
) const {
56 return layer_id
== other
.layer_id
&& index
== other
.index
;
58 bool operator!=(const Id
& other
) const {
59 return !(*this == other
);
61 bool operator<(const Id
& other
) const {
62 return layer_id
< other
.layer_id
||
63 (layer_id
== other
.layer_id
&& index
< other
.index
);
69 static scoped_ptr
<RenderPass
> Create();
71 // A shallow copy of the render pass, which does not include its quads.
72 scoped_ptr
<RenderPass
> Copy(Id new_id
) const;
75 gfx::Rect output_rect
,
76 gfx::RectF damage_rect
,
77 const gfx::Transform
& transform_to_root_target
);
80 gfx::Rect output_rect
,
81 gfx::RectF damage_rect
,
82 const gfx::Transform
& transform_to_root_target
,
83 bool has_transparent_background
,
84 bool has_occlusion_from_outside_target_surface
);
86 scoped_ptr
<base::Value
> AsValue() const;
88 // Uniquely identifies the render pass in the compositor's current frame.
91 // These are in the space of the render pass' physical pixels.
92 gfx::Rect output_rect
;
93 gfx::RectF damage_rect
;
95 // Transforms from the origin of the |output_rect| to the origin of the root
96 // render pass' |output_rect|.
97 gfx::Transform transform_to_root_target
;
99 // If false, the pixels in the render pass' texture are all opaque.
100 bool has_transparent_background
;
102 // If true, then there may be pixels in the render pass' texture that are not
103 // complete, since they are occluded.
104 bool has_occlusion_from_outside_target_surface
;
106 // If non-empty, the renderer should produce a copy of the render pass'
107 // contents as a bitmap, and give a copy of the bitmap to each callback in
108 // this list. This property should not be serialized between compositors, as
109 // it only makes sense in the root compositor.
110 ScopedPtrVector
<CopyOutputRequest
> copy_requests
;
113 SharedQuadStateList shared_quad_state_list
;
119 DISALLOW_COPY_AND_ASSIGN(RenderPass
);
124 namespace BASE_HASH_NAMESPACE
{
125 #if defined(COMPILER_MSVC)
126 inline size_t hash_value(const cc::RenderPass::Id
& key
) {
127 return base::HashPair(key
.layer_id
, key
.index
);
129 #elif defined(COMPILER_GCC)
131 struct hash
<cc::RenderPass::Id
> {
132 size_t operator()(cc::RenderPass::Id key
) const {
133 return base::HashPair(key
.layer_id
, key
.index
);
137 #error define a hash function for your compiler
139 } // namespace BASE_HASH_NAMESPACE
142 typedef ScopedPtrVector
<RenderPass
> RenderPassList
;
143 typedef base::hash_map
<RenderPass::Id
, RenderPass
*> RenderPassIdHashMap
;
146 #endif // CC_QUADS_RENDER_PASS_H_