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/hash_tables.h"
13 #include "cc/base/cc_export.h"
14 #include "cc/base/hash_pair.h"
15 #include "cc/base/scoped_ptr_hash_map.h"
16 #include "cc/base/scoped_ptr_vector.h"
17 #include "skia/ext/refptr.h"
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations.h"
19 #include "third_party/skia/include/core/SkColor.h"
20 #include "third_party/skia/include/core/SkImageFilter.h"
21 #include "ui/gfx/rect.h"
22 #include "ui/gfx/rect_f.h"
23 #include "ui/gfx/transform.h"
28 class CopyOutputRequest
;
29 class SharedQuadState
;
31 // A list of DrawQuad objects, sorted internally in front-to-back order.
32 class QuadList
: public ScopedPtrVector
<DrawQuad
> {
34 typedef reverse_iterator BackToFrontIterator
;
35 typedef const_reverse_iterator ConstBackToFrontIterator
;
37 inline BackToFrontIterator
BackToFrontBegin() { return rbegin(); }
38 inline BackToFrontIterator
BackToFrontEnd() { return rend(); }
39 inline ConstBackToFrontIterator
BackToFrontBegin() const { return rbegin(); }
40 inline ConstBackToFrontIterator
BackToFrontEnd() const { return rend(); }
43 typedef ScopedPtrVector
<SharedQuadState
> SharedQuadStateList
;
45 class CC_EXPORT RenderPass
{
51 Id(int layer_id
, int index
) : layer_id(layer_id
), index(index
) {}
53 bool operator==(const Id
& other
) const {
54 return layer_id
== other
.layer_id
&& index
== other
.index
;
56 bool operator!=(const Id
& other
) const {
57 return !(*this == other
);
59 bool operator<(const Id
& other
) const {
60 return layer_id
< other
.layer_id
||
61 (layer_id
== other
.layer_id
&& index
< other
.index
);
67 static scoped_ptr
<RenderPass
> Create();
69 // A shallow copy of the render pass, which does not include its quads.
70 scoped_ptr
<RenderPass
> Copy(Id new_id
) const;
73 gfx::Rect output_rect
,
74 gfx::RectF damage_rect
,
75 const gfx::Transform
& transform_to_root_target
);
78 gfx::Rect output_rect
,
79 gfx::RectF damage_rect
,
80 const gfx::Transform
& transform_to_root_target
,
81 bool has_transparent_background
,
82 bool has_occlusion_from_outside_target_surface
);
84 // Uniquely identifies the render pass in the compositor's current frame.
87 // These are in the space of the render pass' physical pixels.
88 gfx::Rect output_rect
;
89 gfx::RectF damage_rect
;
91 // Transforms from the origin of the |output_rect| to the origin of the root
92 // render pass' |output_rect|.
93 gfx::Transform transform_to_root_target
;
95 // If false, the pixels in the render pass' texture are all opaque.
96 bool has_transparent_background
;
98 // If true, then there may be pixels in the render pass' texture that are not
99 // complete, since they are occluded.
100 bool has_occlusion_from_outside_target_surface
;
102 // If non-empty, the renderer should produce a copy of the render pass'
103 // contents as a bitmap, and give a copy of the bitmap to each callback in
104 // this list. This property should not be serialized between compositors, as
105 // it only makes sense in the root compositor.
106 ScopedPtrVector
<CopyOutputRequest
> copy_requests
;
109 SharedQuadStateList shared_quad_state_list
;
114 DISALLOW_COPY_AND_ASSIGN(RenderPass
);
119 namespace BASE_HASH_NAMESPACE
{
120 #if defined(COMPILER_MSVC)
122 inline size_t hash_value
<cc::RenderPass::Id
>(const cc::RenderPass::Id
& key
) {
123 return hash_value
<std::pair
<int, int> >(
124 std::pair
<int, int>(key
.layer_id
, key
.index
));
126 #elif defined(COMPILER_GCC)
128 struct hash
<cc::RenderPass::Id
> {
129 size_t operator()(cc::RenderPass::Id key
) const {
130 return hash
<std::pair
<int, int> >()(
131 std::pair
<int, int>(key
.layer_id
, key
.index
));
135 #error define a hash function for your compiler
140 typedef ScopedPtrVector
<RenderPass
> RenderPassList
;
141 typedef base::hash_map
<RenderPass::Id
, RenderPass
*> RenderPassIdHashMap
;
144 #endif // CC_QUADS_RENDER_PASS_H_