FileSystem mods: Changes to snapshot file creation to remove dependencies on blobs.
[chromium-blink-merge.git] / cc / render_pass.h
blob0a8a8ec9e5f1e1aec8c1d9eabb719a8cb071e61c
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_RENDER_PASS_H_
6 #define CC_RENDER_PASS_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "cc/cc_export.h"
12 #include "cc/hash_pair.h"
13 #include "cc/scoped_ptr_hash_map.h"
14 #include "cc/scoped_ptr_vector.h"
15 #include "skia/ext/refptr.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations.h"
17 #include "third_party/skia/include/core/SkColor.h"
18 #include "third_party/skia/include/core/SkImageFilter.h"
19 #include "ui/gfx/rect_f.h"
20 #include "ui/gfx/transform.h"
22 namespace cc {
24 class DrawQuad;
25 class SharedQuadState;
27 // A list of DrawQuad objects, sorted internally in front-to-back order.
28 class QuadList : public ScopedPtrVector<DrawQuad> {
29 public:
30 typedef reverse_iterator backToFrontIterator;
31 typedef const_reverse_iterator constBackToFrontIterator;
33 inline backToFrontIterator backToFrontBegin() { return rbegin(); }
34 inline backToFrontIterator backToFrontEnd() { return rend(); }
35 inline constBackToFrontIterator backToFrontBegin() const { return rbegin(); }
36 inline constBackToFrontIterator backToFrontEnd() const { return rend(); }
39 typedef ScopedPtrVector<SharedQuadState> SharedQuadStateList;
41 class CC_EXPORT RenderPass {
42 public:
43 struct Id {
44 int layer_id;
45 int index;
47 Id(int layer_id, int index) : layer_id(layer_id), index(index) {}
49 bool operator==(const Id& other) const {
50 return layer_id == other.layer_id && index == other.index;
52 bool operator!=(const Id& other) const {
53 return !(*this == other);
55 bool operator<(const Id& other) const {
56 return layer_id < other.layer_id ||
57 (layer_id == other.layer_id && index < other.index);
61 ~RenderPass();
63 static scoped_ptr<RenderPass> Create();
65 // A shallow copy of the render pass, which does not include its quads.
66 scoped_ptr<RenderPass> Copy(Id newId) const;
68 void SetNew(Id id,
69 gfx::Rect output_rect,
70 gfx::RectF damage_rect,
71 const gfx::Transform& transform_to_root_target);
73 void SetAll(Id id,
74 gfx::Rect output_rect,
75 gfx::RectF damage_rect,
76 const gfx::Transform& transform_to_root_target,
77 bool has_transparent_background,
78 bool has_occlusion_from_outside_target_surface);
80 // Uniquely identifies the render pass in the compositor's current frame.
81 Id id;
83 // These are in the space of the render pass' physical pixels.
84 gfx::Rect output_rect;
85 gfx::RectF damage_rect;
87 // Transforms from the origin of the |output_rect| to the origin of the root
88 // render pass' |output_rect|.
89 gfx::Transform transform_to_root_target;
91 // If false, the pixels in the render pass' texture are all opaque.
92 bool has_transparent_background;
94 // If true, then there may be pixels in the render pass' texture that are not
95 // complete, since they are occluded.
96 bool has_occlusion_from_outside_target_surface;
98 QuadList quad_list;
99 SharedQuadStateList shared_quad_state_list;
101 protected:
102 RenderPass();
104 DISALLOW_COPY_AND_ASSIGN(RenderPass);
107 } // namespace cc
109 namespace BASE_HASH_NAMESPACE {
110 #if defined(COMPILER_MSVC)
111 template<>
112 inline size_t hash_value<cc::RenderPass::Id>(const cc::RenderPass::Id& key) {
113 return hash_value<std::pair<int, int> >(
114 std::pair<int, int>(key.layer_id, key.index));
116 #elif defined(COMPILER_GCC)
117 template<>
118 struct hash<cc::RenderPass::Id> {
119 size_t operator()(cc::RenderPass::Id key) const {
120 return hash<std::pair<int, int> >()(
121 std::pair<int, int>(key.layer_id, key.index));
124 #else
125 #error define a hash function for your compiler
126 #endif // COMPILER
129 namespace cc {
130 typedef ScopedPtrVector<RenderPass> RenderPassList;
131 typedef base::hash_map<RenderPass::Id, RenderPass*> RenderPassIdHashMap;
132 } // namespace cc
134 #endif // CC_RENDER_PASS_H_