Fix a type mismatch on Windows caused by r201738.
[chromium-blink-merge.git] / cc / quads / render_pass.h
blob4097cbe811134fdb64a8f3690feeec69935fe78d
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/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"
25 namespace cc {
27 class DrawQuad;
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> {
33 public:
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 {
46 public:
47 struct Id {
48 int layer_id;
49 int index;
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);
65 ~RenderPass();
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;
72 void SetNew(Id id,
73 gfx::Rect output_rect,
74 gfx::RectF damage_rect,
75 const gfx::Transform& transform_to_root_target);
77 void SetAll(Id id,
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.
85 Id id;
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;
108 QuadList quad_list;
109 SharedQuadStateList shared_quad_state_list;
111 protected:
112 RenderPass();
114 DISALLOW_COPY_AND_ASSIGN(RenderPass);
117 } // namespace cc
119 namespace BASE_HASH_NAMESPACE {
120 #if defined(COMPILER_MSVC)
121 template<>
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)
127 template<>
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));
134 #else
135 #error define a hash function for your compiler
136 #endif // COMPILER
139 namespace cc {
140 typedef ScopedPtrVector<RenderPass> RenderPassList;
141 typedef base::hash_map<RenderPass::Id, RenderPass*> RenderPassIdHashMap;
142 } // namespace cc
144 #endif // CC_QUADS_RENDER_PASS_H_