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_hash_map.h"
15 #include "cc/base/scoped_ptr_vector.h"
16 #include "skia/ext/refptr.h"
17 #include "third_party/skia/include/core/SkColor.h"
18 #include "third_party/skia/include/core/SkImageFilter.h"
19 #include "ui/gfx/rect.h"
20 #include "ui/gfx/rect_f.h"
21 #include "ui/gfx/transform.h"
30 class CopyOutputRequest
;
31 class SharedQuadState
;
33 // A list of DrawQuad objects, sorted internally in front-to-back order.
34 class QuadList
: public ScopedPtrVector
<DrawQuad
> {
36 typedef reverse_iterator BackToFrontIterator
;
37 typedef const_reverse_iterator ConstBackToFrontIterator
;
39 inline BackToFrontIterator
BackToFrontBegin() { return rbegin(); }
40 inline BackToFrontIterator
BackToFrontEnd() { return rend(); }
41 inline ConstBackToFrontIterator
BackToFrontBegin() const { return rbegin(); }
42 inline ConstBackToFrontIterator
BackToFrontEnd() const { return rend(); }
45 typedef ScopedPtrVector
<SharedQuadState
> SharedQuadStateList
;
47 class CC_EXPORT RenderPass
{
53 Id(int layer_id
, int index
) : layer_id(layer_id
), index(index
) {}
54 void* AsTracingId() const;
56 bool operator==(const Id
& other
) const {
57 return layer_id
== other
.layer_id
&& index
== other
.index
;
59 bool operator!=(const Id
& other
) const {
60 return !(*this == other
);
62 bool operator<(const Id
& other
) const {
63 return layer_id
< other
.layer_id
||
64 (layer_id
== other
.layer_id
&& index
< other
.index
);
70 static scoped_ptr
<RenderPass
> Create();
72 // A shallow copy of the render pass, which does not include its quads.
73 scoped_ptr
<RenderPass
> Copy(Id new_id
) const;
76 gfx::Rect output_rect
,
77 gfx::RectF damage_rect
,
78 const gfx::Transform
& transform_to_root_target
);
81 gfx::Rect output_rect
,
82 gfx::RectF damage_rect
,
83 const gfx::Transform
& transform_to_root_target
,
84 bool has_transparent_background
,
85 bool has_occlusion_from_outside_target_surface
);
87 scoped_ptr
<base::Value
> AsValue() const;
89 // Uniquely identifies the render pass in the compositor's current frame.
92 // These are in the space of the render pass' physical pixels.
93 gfx::Rect output_rect
;
94 gfx::RectF damage_rect
;
96 // Transforms from the origin of the |output_rect| to the origin of the root
97 // render pass' |output_rect|.
98 gfx::Transform transform_to_root_target
;
100 // If false, the pixels in the render pass' texture are all opaque.
101 bool has_transparent_background
;
103 // If true, then there may be pixels in the render pass' texture that are not
104 // complete, since they are occluded.
105 bool has_occlusion_from_outside_target_surface
;
107 // If non-empty, the renderer should produce a copy of the render pass'
108 // contents as a bitmap, and give a copy of the bitmap to each callback in
109 // this list. This property should not be serialized between compositors, as
110 // it only makes sense in the root compositor.
111 ScopedPtrVector
<CopyOutputRequest
> copy_requests
;
114 SharedQuadStateList shared_quad_state_list
;
120 DISALLOW_COPY_AND_ASSIGN(RenderPass
);
125 namespace BASE_HASH_NAMESPACE
{
126 #if defined(COMPILER_MSVC)
127 inline size_t hash_value(const cc::RenderPass::Id
& key
) {
128 return base::HashPair(key
.layer_id
, key
.index
);
130 #elif defined(COMPILER_GCC)
132 struct hash
<cc::RenderPass::Id
> {
133 size_t operator()(cc::RenderPass::Id key
) const {
134 return base::HashPair(key
.layer_id
, key
.index
);
138 #error define a hash function for your compiler
140 } // namespace BASE_HASH_NAMESPACE
143 typedef ScopedPtrVector
<RenderPass
> RenderPassList
;
144 typedef base::hash_map
<RenderPass::Id
, RenderPass
*> RenderPassIdHashMap
;
147 #endif // CC_QUADS_RENDER_PASS_H_