OLD | NEW |
1 // Copyright 2012 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 |
| 5 #ifndef CCRenderPass_h |
| 6 #define CCRenderPass_h |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "cc/hash_pair.h" |
| 10 #include "cc/scoped_ptr_hash_map.h" |
| 11 #include "cc/scoped_ptr_vector.h" |
| 12 #include "CCDrawQuad.h" |
| 13 #include "CCSharedQuadState.h" |
| 14 #include "FloatRect.h" |
| 15 #include "SkColor.h" |
| 16 #include <public/WebFilterOperations.h> |
| 17 #include <public/WebTransformationMatrix.h> |
| 18 #include <vector> |
| 19 |
| 20 namespace cc { |
| 21 |
| 22 class CCLayerImpl; |
| 23 template<typename LayerType, typename SurfaceType> |
| 24 class CCOcclusionTrackerBase; |
| 25 class CCRenderSurface; |
| 26 |
| 27 struct CCAppendQuadsData; |
| 28 |
| 29 typedef CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface> CCOcclusionTrackerI
mpl; |
| 30 |
| 31 // A list of CCDrawQuad objects, sorted internally in front-to-back order. |
| 32 class CCQuadList : public ScopedPtrVector<CCDrawQuad> { |
| 33 public: |
| 34 typedef reverse_iterator backToFrontIterator; |
| 35 typedef const_reverse_iterator constBackToFrontIterator; |
| 36 |
| 37 inline backToFrontIterator backToFrontBegin() { return rbegin(); } |
| 38 inline backToFrontIterator backToFrontEnd() { return rend(); } |
| 39 inline constBackToFrontIterator backToFrontBegin() const { return rbegin();
} |
| 40 inline constBackToFrontIterator backToFrontEnd() const { return rend(); } |
| 41 }; |
| 42 |
| 43 typedef ScopedPtrVector<CCSharedQuadState> CCSharedQuadStateList; |
| 44 |
| 45 class CCRenderPass { |
| 46 public: |
| 47 ~CCRenderPass(); |
| 48 |
| 49 struct Id { |
| 50 int layerId; |
| 51 int index; |
| 52 |
| 53 Id(int layerId, int index) |
| 54 : layerId(layerId) |
| 55 , index(index) |
| 56 { |
| 57 } |
| 58 |
| 59 bool operator==(const Id& other) const { return layerId == other.layerId
&& index == other.index; } |
| 60 bool operator!=(const Id& other) const { return !(*this == other); } |
| 61 bool operator<(const Id& other) const { return layerId < other.layerId |
| (layerId == other.layerId && index < other.index); } |
| 62 }; |
| 63 |
| 64 static scoped_ptr<CCRenderPass> create(Id, IntRect outputRect, const WebKit:
:WebTransformationMatrix& transformToRootTarget); |
| 65 |
| 66 // A shallow copy of the render pass, which does not include its quads. |
| 67 scoped_ptr<CCRenderPass> copy(Id newId) const; |
| 68 |
| 69 void appendQuadsForLayer(CCLayerImpl*, CCOcclusionTrackerImpl*, CCAppendQuad
sData&); |
| 70 void appendQuadsForRenderSurfaceLayer(CCLayerImpl*, const CCRenderPass* cont
ributingRenderPass, CCOcclusionTrackerImpl*, CCAppendQuadsData&); |
| 71 void appendQuadsToFillScreen(CCLayerImpl* rootLayer, SkColor screenBackgroun
dColor, const CCOcclusionTrackerImpl&); |
| 72 |
| 73 const CCQuadList& quadList() const { return m_quadList; } |
| 74 |
| 75 Id id() const { return m_id; } |
| 76 |
| 77 // FIXME: Modify this transform when merging the RenderPass into a parent co
mpositor. |
| 78 // Transforms from quad's original content space to the root target's conten
t space. |
| 79 const WebKit::WebTransformationMatrix& transformToRootTarget() const { retur
n m_transformToRootTarget; } |
| 80 |
| 81 // This denotes the bounds in physical pixels of the output generated by thi
s RenderPass. |
| 82 const IntRect& outputRect() const { return m_outputRect; } |
| 83 |
| 84 FloatRect damageRect() const { return m_damageRect; } |
| 85 void setDamageRect(FloatRect rect) { m_damageRect = rect; } |
| 86 |
| 87 const WebKit::WebFilterOperations& filters() const { return m_filters; } |
| 88 void setFilters(const WebKit::WebFilterOperations& filters) { m_filters = fi
lters; } |
| 89 |
| 90 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back
groundFilters; } |
| 91 void setBackgroundFilters(const WebKit::WebFilterOperations& filters) { m_ba
ckgroundFilters = filters; } |
| 92 |
| 93 bool hasTransparentBackground() const { return m_hasTransparentBackground; } |
| 94 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } |
| 95 |
| 96 bool hasOcclusionFromOutsideTargetSurface() const { return m_hasOcclusionFro
mOutsideTargetSurface; } |
| 97 void setHasOcclusionFromOutsideTargetSurface(bool hasOcclusionFromOutsideTar
getSurface) { m_hasOcclusionFromOutsideTargetSurface = hasOcclusionFromOutsideTa
rgetSurface; } |
| 98 protected: |
| 99 CCRenderPass(Id, IntRect outputRect, const WebKit::WebTransformationMatrix&
transformToRootTarget); |
| 100 |
| 101 Id m_id; |
| 102 CCQuadList m_quadList; |
| 103 CCSharedQuadStateList m_sharedQuadStateList; |
| 104 WebKit::WebTransformationMatrix m_transformToRootTarget; |
| 105 IntRect m_outputRect; |
| 106 FloatRect m_damageRect; |
| 107 bool m_hasTransparentBackground; |
| 108 bool m_hasOcclusionFromOutsideTargetSurface; |
| 109 WebKit::WebFilterOperations m_filters; |
| 110 WebKit::WebFilterOperations m_backgroundFilters; |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(CCRenderPass); |
| 113 }; |
| 114 |
| 115 } // namespace cc |
| 116 |
| 117 namespace BASE_HASH_NAMESPACE { |
| 118 #if defined(COMPILER_MSVC) |
| 119 template<> |
| 120 inline size_t hash_value<cc::CCRenderPass::Id>(const cc::CCRenderPass::Id& key)
{ |
| 121 return hash_value<std::pair<int, int> >(std::pair<int, int>(key.layerId, key
.index)); |
| 122 } |
| 123 #elif defined(COMPILER_GCC) |
| 124 template<> |
| 125 struct hash<cc::CCRenderPass::Id> { |
| 126 size_t operator()(cc::CCRenderPass::Id key) const { |
| 127 return hash<std::pair<int, int> >()(std::pair<int, int>(key.layerId, key
.index)); |
| 128 } |
| 129 }; |
| 130 #else |
| 131 #error define a hash function for your compiler |
| 132 #endif // COMPILER |
| 133 } |
| 134 |
| 135 namespace cc { |
| 136 typedef std::vector<CCRenderPass*> CCRenderPassList; |
| 137 typedef ScopedPtrHashMap<CCRenderPass::Id, CCRenderPass> CCRenderPassIdHashMap; |
| 138 } // namespace cc |
| 139 |
| 140 #endif |
OLD | NEW |