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