| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_QUADS_RENDER_PASS_H_ | 5 #ifndef CC_QUADS_RENDER_PASS_H_ |
| 6 #define CC_QUADS_RENDER_PASS_H_ | 6 #define CC_QUADS_RENDER_PASS_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
| 14 #include "cc/base/scoped_ptr_vector.h" | 14 #include "cc/base/scoped_ptr_vector.h" |
| 15 #include "cc/quads/render_pass_id.h" |
| 15 #include "skia/ext/refptr.h" | 16 #include "skia/ext/refptr.h" |
| 16 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 17 #include "ui/gfx/rect_f.h" | 18 #include "ui/gfx/rect_f.h" |
| 18 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 namespace debug { | 22 namespace debug { |
| 22 class TracedValue; | 23 class TracedValue; |
| 23 } | 24 } |
| 24 class Value; | 25 class Value; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 40 inline BackToFrontIterator BackToFrontBegin() { return rbegin(); } | 41 inline BackToFrontIterator BackToFrontBegin() { return rbegin(); } |
| 41 inline BackToFrontIterator BackToFrontEnd() { return rend(); } | 42 inline BackToFrontIterator BackToFrontEnd() { return rend(); } |
| 42 inline ConstBackToFrontIterator BackToFrontBegin() const { return rbegin(); } | 43 inline ConstBackToFrontIterator BackToFrontBegin() const { return rbegin(); } |
| 43 inline ConstBackToFrontIterator BackToFrontEnd() const { return rend(); } | 44 inline ConstBackToFrontIterator BackToFrontEnd() const { return rend(); } |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 typedef ScopedPtrVector<SharedQuadState> SharedQuadStateList; | 47 typedef ScopedPtrVector<SharedQuadState> SharedQuadStateList; |
| 47 | 48 |
| 48 class CC_EXPORT RenderPass { | 49 class CC_EXPORT RenderPass { |
| 49 public: | 50 public: |
| 50 struct Id { | |
| 51 int layer_id; | |
| 52 int index; | |
| 53 | |
| 54 Id(int layer_id, int index) : layer_id(layer_id), index(index) {} | |
| 55 void* AsTracingId() const; | |
| 56 | |
| 57 bool operator==(const Id& other) const { | |
| 58 return layer_id == other.layer_id && index == other.index; | |
| 59 } | |
| 60 bool operator!=(const Id& other) const { | |
| 61 return !(*this == other); | |
| 62 } | |
| 63 bool operator<(const Id& other) const { | |
| 64 return layer_id < other.layer_id || | |
| 65 (layer_id == other.layer_id && index < other.index); | |
| 66 } | |
| 67 }; | |
| 68 | |
| 69 ~RenderPass(); | 51 ~RenderPass(); |
| 70 | 52 |
| 71 static scoped_ptr<RenderPass> Create(); | 53 static scoped_ptr<RenderPass> Create(); |
| 72 static scoped_ptr<RenderPass> Create(size_t num_layers); | 54 static scoped_ptr<RenderPass> Create(size_t num_layers); |
| 73 | 55 |
| 74 // A shallow copy of the render pass, which does not include its quads or copy | 56 // A shallow copy of the render pass, which does not include its quads or copy |
| 75 // requests. | 57 // requests. |
| 76 scoped_ptr<RenderPass> Copy(Id new_id) const; | 58 scoped_ptr<RenderPass> Copy(RenderPassId new_id) const; |
| 77 | 59 |
| 78 // A deep copy of the render passes in the list including the quads. | 60 // A deep copy of the render passes in the list including the quads. |
| 79 static void CopyAll(const ScopedPtrVector<RenderPass>& in, | 61 static void CopyAll(const ScopedPtrVector<RenderPass>& in, |
| 80 ScopedPtrVector<RenderPass>* out); | 62 ScopedPtrVector<RenderPass>* out); |
| 81 | 63 |
| 82 void SetNew(Id id, | 64 void SetNew(RenderPassId id, |
| 83 const gfx::Rect& output_rect, | 65 const gfx::Rect& output_rect, |
| 84 const gfx::Rect& damage_rect, | 66 const gfx::Rect& damage_rect, |
| 85 const gfx::Transform& transform_to_root_target); | 67 const gfx::Transform& transform_to_root_target); |
| 86 | 68 |
| 87 void SetAll(Id id, | 69 void SetAll(RenderPassId id, |
| 88 const gfx::Rect& output_rect, | 70 const gfx::Rect& output_rect, |
| 89 const gfx::Rect& damage_rect, | 71 const gfx::Rect& damage_rect, |
| 90 const gfx::Transform& transform_to_root_target, | 72 const gfx::Transform& transform_to_root_target, |
| 91 bool has_transparent_background); | 73 bool has_transparent_background); |
| 92 | 74 |
| 93 void AsValueInto(base::debug::TracedValue* dict) const; | 75 void AsValueInto(base::debug::TracedValue* dict) const; |
| 94 | 76 |
| 95 SharedQuadState* CreateAndAppendSharedQuadState(); | 77 SharedQuadState* CreateAndAppendSharedQuadState(); |
| 96 template <typename DrawQuadType> | 78 template <typename DrawQuadType> |
| 97 DrawQuadType* CreateAndAppendDrawQuad() { | 79 DrawQuadType* CreateAndAppendDrawQuad() { |
| 98 scoped_ptr<DrawQuadType> draw_quad = make_scoped_ptr(new DrawQuadType); | 80 scoped_ptr<DrawQuadType> draw_quad = make_scoped_ptr(new DrawQuadType); |
| 99 quad_list.push_back(draw_quad.template PassAs<DrawQuad>()); | 81 quad_list.push_back(draw_quad.template PassAs<DrawQuad>()); |
| 100 return static_cast<DrawQuadType*>(quad_list.back()); | 82 return static_cast<DrawQuadType*>(quad_list.back()); |
| 101 } | 83 } |
| 102 | 84 |
| 103 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( | 85 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( |
| 104 const RenderPassDrawQuad* quad, | 86 const RenderPassDrawQuad* quad, |
| 105 const SharedQuadState* shared_quad_state, | 87 const SharedQuadState* shared_quad_state, |
| 106 RenderPass::Id render_pass_id); | 88 RenderPassId render_pass_id); |
| 107 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, | 89 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, |
| 108 const SharedQuadState* shared_quad_state); | 90 const SharedQuadState* shared_quad_state); |
| 109 | 91 |
| 110 // Uniquely identifies the render pass in the compositor's current frame. | 92 // Uniquely identifies the render pass in the compositor's current frame. |
| 111 Id id; | 93 RenderPassId id; |
| 112 | 94 |
| 113 // These are in the space of the render pass' physical pixels. | 95 // These are in the space of the render pass' physical pixels. |
| 114 gfx::Rect output_rect; | 96 gfx::Rect output_rect; |
| 115 gfx::Rect damage_rect; | 97 gfx::Rect damage_rect; |
| 116 | 98 |
| 117 // Transforms from the origin of the |output_rect| to the origin of the root | 99 // Transforms from the origin of the |output_rect| to the origin of the root |
| 118 // render pass' |output_rect|. | 100 // render pass' |output_rect|. |
| 119 gfx::Transform transform_to_root_target; | 101 gfx::Transform transform_to_root_target; |
| 120 | 102 |
| 121 // If false, the pixels in the render pass' texture are all opaque. | 103 // If false, the pixels in the render pass' texture are all opaque. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 143 return static_cast<DrawQuadType*>(quad_list.back()); | 125 return static_cast<DrawQuadType*>(quad_list.back()); |
| 144 } | 126 } |
| 145 | 127 |
| 146 DISALLOW_COPY_AND_ASSIGN(RenderPass); | 128 DISALLOW_COPY_AND_ASSIGN(RenderPass); |
| 147 }; | 129 }; |
| 148 | 130 |
| 149 } // namespace cc | 131 } // namespace cc |
| 150 | 132 |
| 151 namespace BASE_HASH_NAMESPACE { | 133 namespace BASE_HASH_NAMESPACE { |
| 152 #if defined(COMPILER_MSVC) | 134 #if defined(COMPILER_MSVC) |
| 153 inline size_t hash_value(const cc::RenderPass::Id& key) { | 135 inline size_t hash_value(const cc::RenderPassId& key) { |
| 154 return base::HashPair(key.layer_id, key.index); | 136 return base::HashPair(key.layer_id, key.index); |
| 155 } | 137 } |
| 156 #elif defined(COMPILER_GCC) | 138 #elif defined(COMPILER_GCC) |
| 157 template<> | 139 template <> |
| 158 struct hash<cc::RenderPass::Id> { | 140 struct hash<cc::RenderPassId> { |
| 159 size_t operator()(cc::RenderPass::Id key) const { | 141 size_t operator()(cc::RenderPassId key) const { |
| 160 return base::HashPair(key.layer_id, key.index); | 142 return base::HashPair(key.layer_id, key.index); |
| 161 } | 143 } |
| 162 }; | 144 }; |
| 163 #else | 145 #else |
| 164 #error define a hash function for your compiler | 146 #error define a hash function for your compiler |
| 165 #endif // COMPILER | 147 #endif // COMPILER |
| 166 } // namespace BASE_HASH_NAMESPACE | 148 } // namespace BASE_HASH_NAMESPACE |
| 167 | 149 |
| 168 namespace cc { | 150 namespace cc { |
| 169 typedef ScopedPtrVector<RenderPass> RenderPassList; | 151 typedef ScopedPtrVector<RenderPass> RenderPassList; |
| 170 typedef base::hash_map<RenderPass::Id, RenderPass*> RenderPassIdHashMap; | 152 typedef base::hash_map<RenderPassId, RenderPass*> RenderPassIdHashMap; |
| 171 } // namespace cc | 153 } // namespace cc |
| 172 | 154 |
| 173 #endif // CC_QUADS_RENDER_PASS_H_ | 155 #endif // CC_QUADS_RENDER_PASS_H_ |
| OLD | NEW |