Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / cc / quads / render_pass.h
blob224a0506f0300969f47bf6a028e4e948e804a198
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/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"
23 namespace base {
24 class Value;
27 namespace cc {
29 class DrawQuad;
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> {
35 public:
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 {
48 public:
49 struct Id {
50 int layer_id;
51 int index;
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);
68 ~RenderPass();
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;
75 void SetNew(Id id,
76 gfx::Rect output_rect,
77 gfx::RectF damage_rect,
78 const gfx::Transform& transform_to_root_target);
80 void SetAll(Id id,
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.
90 Id id;
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;
113 QuadList quad_list;
114 SharedQuadStateList shared_quad_state_list;
116 protected:
117 RenderPass();
119 private:
120 DISALLOW_COPY_AND_ASSIGN(RenderPass);
123 } // namespace cc
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)
131 template<>
132 struct hash<cc::RenderPass::Id> {
133 size_t operator()(cc::RenderPass::Id key) const {
134 return base::HashPair(key.layer_id, key.index);
137 #else
138 #error define a hash function for your compiler
139 #endif // COMPILER
140 } // namespace BASE_HASH_NAMESPACE
142 namespace cc {
143 typedef ScopedPtrVector<RenderPass> RenderPassList;
144 typedef base::hash_map<RenderPass::Id, RenderPass*> RenderPassIdHashMap;
145 } // namespace cc
147 #endif // CC_QUADS_RENDER_PASS_H_