| 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_RENDER_PASS_H_ | 5 #ifndef CC_RENDER_PASS_H_ |
| 6 #define CC_RENDER_PASS_H_ | 6 #define CC_RENDER_PASS_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "cc/cc_export.h" | 9 #include "cc/cc_export.h" |
| 10 #include "cc/draw_quad.h" | 10 #include "cc/draw_quad.h" |
| 11 #include "cc/hash_pair.h" | 11 #include "cc/hash_pair.h" |
| 12 #include "cc/scoped_ptr_hash_map.h" | 12 #include "cc/scoped_ptr_hash_map.h" |
| 13 #include "cc/scoped_ptr_vector.h" | 13 #include "cc/scoped_ptr_vector.h" |
| 14 #include "cc/shared_quad_state.h" | 14 #include "cc/shared_quad_state.h" |
| 15 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
| 16 #include "ui/gfx/rect_f.h" | 16 #include "ui/gfx/rect_f.h" |
| 17 #include <public/WebFilterOperations.h> | 17 #include <public/WebFilterOperations.h> |
| 18 #include <public/WebTransformationMatrix.h> | 18 #include <public/WebTransformationMatrix.h> |
| 19 #include <vector> | 19 #include <vector> |
| 20 | 20 |
| 21 class SkImageFilter; | 21 class SkImageFilter; |
| 22 | 22 |
| 23 namespace cc { | 23 namespace cc { |
| 24 | 24 |
| 25 class LayerImpl; | |
| 26 template<typename LayerType, typename SurfaceType> | |
| 27 class OcclusionTrackerBase; | |
| 28 class RenderSurfaceImpl; | |
| 29 | |
| 30 struct AppendQuadsData; | |
| 31 | |
| 32 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl; | |
| 33 | |
| 34 // A list of DrawQuad objects, sorted internally in front-to-back order. | 25 // A list of DrawQuad objects, sorted internally in front-to-back order. |
| 35 class QuadList : public ScopedPtrVector<DrawQuad> { | 26 class QuadList : public ScopedPtrVector<DrawQuad> { |
| 36 public: | 27 public: |
| 37 typedef reverse_iterator backToFrontIterator; | 28 typedef reverse_iterator backToFrontIterator; |
| 38 typedef const_reverse_iterator constBackToFrontIterator; | 29 typedef const_reverse_iterator constBackToFrontIterator; |
| 39 | 30 |
| 40 inline backToFrontIterator backToFrontBegin() { return rbegin(); } | 31 inline backToFrontIterator backToFrontBegin() { return rbegin(); } |
| 41 inline backToFrontIterator backToFrontEnd() { return rend(); } | 32 inline backToFrontIterator backToFrontEnd() { return rend(); } |
| 42 inline constBackToFrontIterator backToFrontBegin() const { return rbegin();
} | 33 inline constBackToFrontIterator backToFrontBegin() const { return rbegin(); } |
| 43 inline constBackToFrontIterator backToFrontEnd() const { return rend(); } | 34 inline constBackToFrontIterator backToFrontEnd() const { return rend(); } |
| 44 }; | 35 }; |
| 45 | 36 |
| 46 typedef ScopedPtrVector<SharedQuadState> SharedQuadStateList; | 37 typedef ScopedPtrVector<SharedQuadState> SharedQuadStateList; |
| 47 | 38 |
| 48 class CC_EXPORT RenderPass { | 39 class CC_EXPORT RenderPass { |
| 49 public: | 40 public: |
| 50 ~RenderPass(); | 41 struct Id { |
| 42 int layer_id; |
| 43 int index; |
| 51 | 44 |
| 52 struct Id { | 45 Id(int layer_id, int index) : layer_id(layer_id), index(index) {} |
| 53 int layerId; | |
| 54 int index; | |
| 55 | 46 |
| 56 Id(int layerId, int index) | 47 bool operator==(const Id& other) const { |
| 57 : layerId(layerId) | 48 return layer_id == other.layer_id && index == other.index; |
| 58 , index(index) | 49 } |
| 59 { | 50 bool operator!=(const Id& other) const { |
| 60 } | 51 return !(*this == other); |
| 52 } |
| 53 bool operator<(const Id& other) const { |
| 54 return layer_id < other.layer_id || |
| 55 (layer_id == other.layer_id && index < other.index); |
| 56 } |
| 57 }; |
| 61 | 58 |
| 62 bool operator==(const Id& other) const { return layerId == other.layerId
&& index == other.index; } | 59 ~RenderPass(); |
| 63 bool operator!=(const Id& other) const { return !(*this == other); } | |
| 64 bool operator<(const Id& other) const { return layerId < other.layerId |
| (layerId == other.layerId && index < other.index); } | |
| 65 }; | |
| 66 | 60 |
| 67 static scoped_ptr<RenderPass> create(Id, gfx::Rect outputRect, const WebKit:
:WebTransformationMatrix& transformToRootTarget); | 61 static scoped_ptr<RenderPass> Create(); |
| 68 | 62 |
| 69 // A shallow copy of the render pass, which does not include its quads. | 63 // A shallow copy of the render pass, which does not include its quads. |
| 70 scoped_ptr<RenderPass> copy(Id newId) const; | 64 scoped_ptr<RenderPass> Copy(Id newId) const; |
| 71 | 65 |
| 72 void appendQuadsForLayer(LayerImpl*, OcclusionTrackerImpl*, AppendQuadsData&
); | 66 void SetNew(Id id, |
| 73 void appendQuadsForRenderSurfaceLayer(LayerImpl*, const RenderPass* contribu
tingRenderPass, OcclusionTrackerImpl*, AppendQuadsData&); | 67 gfx::Rect output_rect, |
| 74 void appendQuadsToFillScreen(LayerImpl* rootLayer, SkColor screenBackgroundC
olor, const OcclusionTrackerImpl&); | 68 gfx::RectF damage_rect, |
| 69 const WebKit::WebTransformationMatrix& transform_to_root_target); |
| 75 | 70 |
| 76 const QuadList& quadList() const { return m_quadList; } | 71 void SetAll(Id id, |
| 72 gfx::Rect output_rect, |
| 73 gfx::RectF damage_rect, |
| 74 const WebKit::WebTransformationMatrix& transform_to_root_target, |
| 75 bool has_transparent_background, |
| 76 bool has_occlusion_from_outside_target_surface, |
| 77 const WebKit::WebFilterOperations& filters, |
| 78 SkImageFilter* filter, |
| 79 const WebKit::WebFilterOperations& background_filters); |
| 77 | 80 |
| 78 Id id() const { return m_id; } | 81 // Uniquely identifies the render pass in the compositor's current frame. |
| 82 Id id; |
| 79 | 83 |
| 80 // FIXME: Modify this transform when merging the RenderPass into a parent co
mpositor. | 84 // These are in the space of the render pass' physical pixels. |
| 81 // Transforms from quad's original content space to the root target's conten
t space. | 85 gfx::Rect output_rect; |
| 82 const WebKit::WebTransformationMatrix& transformToRootTarget() const { retur
n m_transformToRootTarget; } | 86 gfx::RectF damage_rect; |
| 83 | 87 |
| 84 // This denotes the bounds in physical pixels of the output generated by thi
s RenderPass. | 88 // Transforms from the origin of the |output_rect| to the origin of the root |
| 85 const gfx::Rect& outputRect() const { return m_outputRect; } | 89 // render pass' |output_rect|. |
| 90 WebKit::WebTransformationMatrix transform_to_root_target; |
| 86 | 91 |
| 87 gfx::RectF damageRect() const { return m_damageRect; } | 92 // If false, the pixels in the render pass' texture are all opaque. |
| 88 void setDamageRect(gfx::RectF rect) { m_damageRect = rect; } | 93 bool has_transparent_background; |
| 89 | 94 |
| 90 const WebKit::WebFilterOperations& filters() const { return m_filters; } | 95 // If true, then there may be pixels in the render pass' texture that are not |
| 91 void setFilters(const WebKit::WebFilterOperations& filters) { m_filters = fi
lters; } | 96 // complete, since they are occluded. |
| 97 bool has_occlusion_from_outside_target_surface; |
| 92 | 98 |
| 93 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back
groundFilters; } | 99 // Deprecated post-processing filters, applied to the pixels in the render |
| 94 void setBackgroundFilters(const WebKit::WebFilterOperations& filters) { m_ba
ckgroundFilters = filters; } | 100 // pass' texture. |
| 101 WebKit::WebFilterOperations filters; |
| 102 // Post-processing filter applied to the pixels in the render pass' texture. |
| 103 SkImageFilter* filter; |
| 95 | 104 |
| 96 SkImageFilter* filter() const { return m_filter; } | 105 // Post-processing filters, applied to the pixels showing through the |
| 97 void setFilter(SkImageFilter* filter); | 106 // background of the render pass, from behind it. |
| 107 WebKit::WebFilterOperations background_filters; |
| 98 | 108 |
| 99 bool hasTransparentBackground() const { return m_hasTransparentBackground; } | 109 QuadList quad_list; |
| 100 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } | 110 SharedQuadStateList shared_quad_state_list; |
| 101 | 111 |
| 102 bool hasOcclusionFromOutsideTargetSurface() const { return m_hasOcclusionFro
mOutsideTargetSurface; } | 112 protected: |
| 103 void setHasOcclusionFromOutsideTargetSurface(bool hasOcclusionFromOutsideTar
getSurface) { m_hasOcclusionFromOutsideTargetSurface = hasOcclusionFromOutsideTa
rgetSurface; } | 113 RenderPass(); |
| 104 protected: | |
| 105 RenderPass(Id, gfx::Rect outputRect, const WebKit::WebTransformationMatrix&
transformToRootTarget); | |
| 106 | 114 |
| 107 Id m_id; | 115 DISALLOW_COPY_AND_ASSIGN(RenderPass); |
| 108 QuadList m_quadList; | |
| 109 SharedQuadStateList m_sharedQuadStateList; | |
| 110 WebKit::WebTransformationMatrix m_transformToRootTarget; | |
| 111 gfx::Rect m_outputRect; | |
| 112 gfx::RectF m_damageRect; | |
| 113 bool m_hasTransparentBackground; | |
| 114 bool m_hasOcclusionFromOutsideTargetSurface; | |
| 115 WebKit::WebFilterOperations m_filters; | |
| 116 WebKit::WebFilterOperations m_backgroundFilters; | |
| 117 SkImageFilter* m_filter; | |
| 118 | |
| 119 DISALLOW_COPY_AND_ASSIGN(RenderPass); | |
| 120 }; | 116 }; |
| 121 | 117 |
| 122 } // namespace cc | 118 } // namespace cc |
| 123 | 119 |
| 124 namespace BASE_HASH_NAMESPACE { | 120 namespace BASE_HASH_NAMESPACE { |
| 125 #if defined(COMPILER_MSVC) | 121 #if defined(COMPILER_MSVC) |
| 126 template<> | 122 template<> |
| 127 inline size_t hash_value<cc::RenderPass::Id>(const cc::RenderPass::Id& key) { | 123 inline size_t hash_value<cc::RenderPass::Id>(const cc::RenderPass::Id& key) { |
| 128 return hash_value<std::pair<int, int> >(std::pair<int, int>(key.layerId, key
.index)); | 124 return hash_value<std::pair<int, int> >( |
| 125 std::pair<int, int>(key.layer_id, key.index)); |
| 129 } | 126 } |
| 130 #elif defined(COMPILER_GCC) | 127 #elif defined(COMPILER_GCC) |
| 131 template<> | 128 template<> |
| 132 struct hash<cc::RenderPass::Id> { | 129 struct hash<cc::RenderPass::Id> { |
| 133 size_t operator()(cc::RenderPass::Id key) const { | 130 size_t operator()(cc::RenderPass::Id key) const { |
| 134 return hash<std::pair<int, int> >()(std::pair<int, int>(key.layerId, key
.index)); | 131 return hash<std::pair<int, int> >()( |
| 135 } | 132 std::pair<int, int>(key.layer_id, key.index)); |
| 133 } |
| 136 }; | 134 }; |
| 137 #else | 135 #else |
| 138 #error define a hash function for your compiler | 136 #error define a hash function for your compiler |
| 139 #endif // COMPILER | 137 #endif // COMPILER |
| 140 } | 138 } |
| 141 | 139 |
| 142 namespace cc { | 140 namespace cc { |
| 143 typedef std::vector<RenderPass*> RenderPassList; | 141 typedef std::vector<RenderPass*> RenderPassList; |
| 144 typedef ScopedPtrHashMap<RenderPass::Id, RenderPass> RenderPassIdHashMap; | 142 typedef ScopedPtrHashMap<RenderPass::Id, RenderPass> RenderPassIdHashMap; |
| 145 } // namespace cc | 143 } // namespace cc |
| 146 | 144 |
| 147 #endif // CC_RENDER_PASS_H_ | 145 #endif // CC_RENDER_PASS_H_ |
| OLD | NEW |