| 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 "skia/ext/refptr.h" | 15 #include "skia/ext/refptr.h" |
| 16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 17 #include "ui/gfx/rect_f.h" | 17 #include "ui/gfx/rect_f.h" |
| 18 #include "ui/gfx/transform.h" | 18 #include "ui/gfx/transform.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class Value; | 21 class Value; |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 namespace cc { | 24 namespace cc { |
| 25 | 25 |
| 26 class DrawQuad; | 26 class DrawQuad; |
| 27 class RenderPassDrawQuad; |
| 27 class CopyOutputRequest; | 28 class CopyOutputRequest; |
| 28 class SharedQuadState; | 29 class SharedQuadState; |
| 29 | 30 |
| 30 // A list of DrawQuad objects, sorted internally in front-to-back order. | 31 // A list of DrawQuad objects, sorted internally in front-to-back order. |
| 31 class QuadList : public ScopedPtrVector<DrawQuad> { | 32 class QuadList : public ScopedPtrVector<DrawQuad> { |
| 32 public: | 33 public: |
| 33 typedef reverse_iterator BackToFrontIterator; | 34 typedef reverse_iterator BackToFrontIterator; |
| 34 typedef const_reverse_iterator ConstBackToFrontIterator; | 35 typedef const_reverse_iterator ConstBackToFrontIterator; |
| 35 | 36 |
| 36 inline BackToFrontIterator BackToFrontBegin() { return rbegin(); } | 37 inline BackToFrontIterator BackToFrontBegin() { return rbegin(); } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 scoped_ptr<base::Value> AsValue() const; | 90 scoped_ptr<base::Value> AsValue() const; |
| 90 | 91 |
| 91 SharedQuadState* CreateAndAppendSharedQuadState(); | 92 SharedQuadState* CreateAndAppendSharedQuadState(); |
| 92 template <typename DrawQuadType> | 93 template <typename DrawQuadType> |
| 93 DrawQuadType* CreateAndAppendDrawQuad() { | 94 DrawQuadType* CreateAndAppendDrawQuad() { |
| 94 scoped_ptr<DrawQuadType> draw_quad = DrawQuadType::Create(); | 95 scoped_ptr<DrawQuadType> draw_quad = DrawQuadType::Create(); |
| 95 quad_list.push_back(draw_quad.template PassAs<DrawQuad>()); | 96 quad_list.push_back(draw_quad.template PassAs<DrawQuad>()); |
| 96 return static_cast<DrawQuadType*>(quad_list.back()); | 97 return static_cast<DrawQuadType*>(quad_list.back()); |
| 97 } | 98 } |
| 98 | 99 |
| 100 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( |
| 101 const RenderPassDrawQuad* quad, |
| 102 const SharedQuadState* shared_quad_state, |
| 103 RenderPass::Id render_pass_id); |
| 104 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, |
| 105 const SharedQuadState* shared_quad_state); |
| 106 |
| 99 // Uniquely identifies the render pass in the compositor's current frame. | 107 // Uniquely identifies the render pass in the compositor's current frame. |
| 100 Id id; | 108 Id id; |
| 101 | 109 |
| 102 // These are in the space of the render pass' physical pixels. | 110 // These are in the space of the render pass' physical pixels. |
| 103 gfx::Rect output_rect; | 111 gfx::Rect output_rect; |
| 104 gfx::Rect damage_rect; | 112 gfx::Rect damage_rect; |
| 105 | 113 |
| 106 // Transforms from the origin of the |output_rect| to the origin of the root | 114 // Transforms from the origin of the |output_rect| to the origin of the root |
| 107 // render pass' |output_rect|. | 115 // render pass' |output_rect|. |
| 108 gfx::Transform transform_to_root_target; | 116 gfx::Transform transform_to_root_target; |
| 109 | 117 |
| 110 // If false, the pixels in the render pass' texture are all opaque. | 118 // If false, the pixels in the render pass' texture are all opaque. |
| 111 bool has_transparent_background; | 119 bool has_transparent_background; |
| 112 | 120 |
| 113 // If non-empty, the renderer should produce a copy of the render pass' | 121 // If non-empty, the renderer should produce a copy of the render pass' |
| 114 // contents as a bitmap, and give a copy of the bitmap to each callback in | 122 // contents as a bitmap, and give a copy of the bitmap to each callback in |
| 115 // this list. This property should not be serialized between compositors, as | 123 // this list. This property should not be serialized between compositors, as |
| 116 // it only makes sense in the root compositor. | 124 // it only makes sense in the root compositor. |
| 117 ScopedPtrVector<CopyOutputRequest> copy_requests; | 125 ScopedPtrVector<CopyOutputRequest> copy_requests; |
| 118 | 126 |
| 119 QuadList quad_list; | 127 QuadList quad_list; |
| 120 SharedQuadStateList shared_quad_state_list; | 128 SharedQuadStateList shared_quad_state_list; |
| 121 | 129 |
| 122 protected: | 130 protected: |
| 123 explicit RenderPass(size_t num_layers); | 131 explicit RenderPass(size_t num_layers); |
| 124 RenderPass(); | 132 RenderPass(); |
| 125 | 133 |
| 126 private: | 134 private: |
| 135 template <typename DrawQuadType> |
| 136 DrawQuadType* CopyFromAndAppendTypedDrawQuad(const DrawQuadType* quad) { |
| 137 scoped_ptr<DrawQuadType> draw_quad = |
| 138 make_scoped_ptr(new DrawQuadType(*quad)); |
| 139 quad_list.push_back(draw_quad.template PassAs<DrawQuad>()); |
| 140 return static_cast<DrawQuadType*>(quad_list.back()); |
| 141 } |
| 142 |
| 127 DISALLOW_COPY_AND_ASSIGN(RenderPass); | 143 DISALLOW_COPY_AND_ASSIGN(RenderPass); |
| 128 }; | 144 }; |
| 129 | 145 |
| 130 } // namespace cc | 146 } // namespace cc |
| 131 | 147 |
| 132 namespace BASE_HASH_NAMESPACE { | 148 namespace BASE_HASH_NAMESPACE { |
| 133 #if defined(COMPILER_MSVC) | 149 #if defined(COMPILER_MSVC) |
| 134 inline size_t hash_value(const cc::RenderPass::Id& key) { | 150 inline size_t hash_value(const cc::RenderPass::Id& key) { |
| 135 return base::HashPair(key.layer_id, key.index); | 151 return base::HashPair(key.layer_id, key.index); |
| 136 } | 152 } |
| 137 #elif defined(COMPILER_GCC) | 153 #elif defined(COMPILER_GCC) |
| 138 template<> | 154 template<> |
| 139 struct hash<cc::RenderPass::Id> { | 155 struct hash<cc::RenderPass::Id> { |
| 140 size_t operator()(cc::RenderPass::Id key) const { | 156 size_t operator()(cc::RenderPass::Id key) const { |
| 141 return base::HashPair(key.layer_id, key.index); | 157 return base::HashPair(key.layer_id, key.index); |
| 142 } | 158 } |
| 143 }; | 159 }; |
| 144 #else | 160 #else |
| 145 #error define a hash function for your compiler | 161 #error define a hash function for your compiler |
| 146 #endif // COMPILER | 162 #endif // COMPILER |
| 147 } // namespace BASE_HASH_NAMESPACE | 163 } // namespace BASE_HASH_NAMESPACE |
| 148 | 164 |
| 149 namespace cc { | 165 namespace cc { |
| 150 typedef ScopedPtrVector<RenderPass> RenderPassList; | 166 typedef ScopedPtrVector<RenderPass> RenderPassList; |
| 151 typedef base::hash_map<RenderPass::Id, RenderPass*> RenderPassIdHashMap; | 167 typedef base::hash_map<RenderPass::Id, RenderPass*> RenderPassIdHashMap; |
| 152 } // namespace cc | 168 } // namespace cc |
| 153 | 169 |
| 154 #endif // CC_QUADS_RENDER_PASS_H_ | 170 #endif // CC_QUADS_RENDER_PASS_H_ |
| OLD | NEW |