OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_SHADER_H_ | |
6 #define CC_SHADER_H_ | |
7 | |
8 #include "third_party/skia/include/core/SkColorPriv.h" | |
9 #include <string> | |
10 | |
11 namespace WebKit { | |
12 class WebGraphicsContext3D; | |
13 } | |
14 | |
15 namespace cc { | |
16 | |
17 class VertexShaderPosTex { | |
18 public: | |
19 VertexShaderPosTex(); | |
20 | |
21 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
22 std::string getShaderString() const; | |
23 | |
24 int matrixLocation() const { return m_matrixLocation; } | |
25 | |
26 private: | |
27 int m_matrixLocation; | |
28 }; | |
29 | |
30 class VertexShaderPosTexYUVStretch { | |
31 public: | |
32 VertexShaderPosTexYUVStretch(); | |
33 | |
34 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
35 std::string getShaderString() const; | |
36 | |
37 int matrixLocation() const { return m_matrixLocation; } | |
38 int texScaleLocation() const { return m_texScaleLocation; } | |
39 | |
40 private: | |
41 int m_matrixLocation; | |
42 int m_texScaleLocation; | |
43 }; | |
44 | |
45 class VertexShaderPos { | |
46 public: | |
47 VertexShaderPos(); | |
48 | |
49 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
50 std::string getShaderString() const; | |
51 | |
52 int matrixLocation() const { return m_matrixLocation; } | |
53 | |
54 private: | |
55 int m_matrixLocation; | |
56 }; | |
57 | |
58 class VertexShaderPosTexIdentity { | |
59 public: | |
60 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex) { } | |
61 std::string getShaderString() const; | |
62 }; | |
63 | |
64 class VertexShaderPosTexTransform { | |
65 public: | |
66 VertexShaderPosTexTransform(); | |
67 | |
68 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
69 std::string getShaderString() const; | |
70 | |
71 int matrixLocation() const { return m_matrixLocation; } | |
72 int texTransformLocation() const { return m_texTransformLocation; } | |
73 int vertexOpacityLocation() const { return m_vertexOpacityLocation; } | |
74 | |
75 private: | |
76 int m_matrixLocation; | |
77 int m_texTransformLocation; | |
78 int m_vertexOpacityLocation; | |
79 }; | |
80 | |
81 class VertexShaderPosTexTransformFlip : public VertexShaderPosTexTransform { | |
82 public: | |
83 std::string getShaderString() const; | |
84 }; | |
85 | |
86 class VertexShaderQuad { | |
87 public: | |
88 VertexShaderQuad(); | |
89 | |
90 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
91 std::string getShaderString() const; | |
92 | |
93 int matrixLocation() const { return m_matrixLocation; } | |
94 int pointLocation() const { return m_pointLocation; } | |
95 int texScaleLocation() const { return m_texScaleLocation; } | |
96 | |
97 private: | |
98 int m_matrixLocation; | |
99 int m_pointLocation; | |
100 int m_texScaleLocation; | |
101 }; | |
102 | |
103 class VertexShaderTile { | |
104 public: | |
105 VertexShaderTile(); | |
106 | |
107 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
108 std::string getShaderString() const; | |
109 | |
110 int matrixLocation() const { return m_matrixLocation; } | |
111 int pointLocation() const { return m_pointLocation; } | |
112 int vertexTexTransformLocation() const { return m_vertexTexTransformLocation
; } | |
113 | |
114 private: | |
115 int m_matrixLocation; | |
116 int m_pointLocation; | |
117 int m_vertexTexTransformLocation; | |
118 }; | |
119 | |
120 class VertexShaderVideoTransform { | |
121 public: | |
122 VertexShaderVideoTransform(); | |
123 | |
124 bool init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
125 std::string getShaderString() const; | |
126 | |
127 int matrixLocation() const { return m_matrixLocation; } | |
128 int texMatrixLocation() const { return m_texMatrixLocation; } | |
129 | |
130 private: | |
131 int m_matrixLocation; | |
132 int m_texMatrixLocation; | |
133 }; | |
134 | |
135 class FragmentTexAlphaBinding { | |
136 public: | |
137 FragmentTexAlphaBinding(); | |
138 | |
139 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
140 int alphaLocation() const { return m_alphaLocation; } | |
141 int edgeLocation() const { return -1; } | |
142 int fragmentTexTransformLocation() const { return -1; } | |
143 int samplerLocation() const { return m_samplerLocation; } | |
144 | |
145 private: | |
146 int m_samplerLocation; | |
147 int m_alphaLocation; | |
148 }; | |
149 | |
150 class FragmentTexOpaqueBinding { | |
151 public: | |
152 FragmentTexOpaqueBinding(); | |
153 | |
154 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
155 int alphaLocation() const { return -1; } | |
156 int edgeLocation() const { return -1; } | |
157 int fragmentTexTransformLocation() const { return -1; } | |
158 int samplerLocation() const { return m_samplerLocation; } | |
159 | |
160 private: | |
161 int m_samplerLocation; | |
162 }; | |
163 | |
164 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding { | |
165 public: | |
166 std::string getShaderString() const; | |
167 }; | |
168 | |
169 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { | |
170 public: | |
171 std::string getShaderString() const; | |
172 }; | |
173 | |
174 class FragmentShaderRGBATexRectVaryingAlpha : public FragmentTexAlphaBinding { | |
175 public: | |
176 std::string getShaderString() const; | |
177 }; | |
178 | |
179 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { | |
180 public: | |
181 std::string getShaderString() const; | |
182 }; | |
183 | |
184 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding { | |
185 public: | |
186 std::string getShaderString() const; | |
187 }; | |
188 | |
189 // Swizzles the red and blue component of sampled texel with alpha. | |
190 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { | |
191 public: | |
192 std::string getShaderString() const; | |
193 }; | |
194 | |
195 // Swizzles the red and blue component of sampled texel without alpha. | |
196 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding { | |
197 public: | |
198 std::string getShaderString() const; | |
199 }; | |
200 | |
201 // Fragment shader for external textures. | |
202 class FragmentShaderOESImageExternal : public FragmentTexAlphaBinding { | |
203 public: | |
204 std::string getShaderString() const; | |
205 bool init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
206 private: | |
207 int m_samplerLocation; | |
208 }; | |
209 | |
210 class FragmentShaderRGBATexAlphaAA { | |
211 public: | |
212 FragmentShaderRGBATexAlphaAA(); | |
213 | |
214 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
215 std::string getShaderString() const; | |
216 | |
217 int alphaLocation() const { return m_alphaLocation; } | |
218 int samplerLocation() const { return m_samplerLocation; } | |
219 int edgeLocation() const { return m_edgeLocation; } | |
220 | |
221 private: | |
222 int m_samplerLocation; | |
223 int m_alphaLocation; | |
224 int m_edgeLocation; | |
225 }; | |
226 | |
227 class FragmentTexClampAlphaAABinding { | |
228 public: | |
229 FragmentTexClampAlphaAABinding(); | |
230 | |
231 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
232 int alphaLocation() const { return m_alphaLocation; } | |
233 int samplerLocation() const { return m_samplerLocation; } | |
234 int fragmentTexTransformLocation() const { return m_fragmentTexTransformLoca
tion; } | |
235 int edgeLocation() const { return m_edgeLocation; } | |
236 | |
237 private: | |
238 int m_samplerLocation; | |
239 int m_alphaLocation; | |
240 int m_fragmentTexTransformLocation; | |
241 int m_edgeLocation; | |
242 }; | |
243 | |
244 class FragmentShaderRGBATexClampAlphaAA : public FragmentTexClampAlphaAABinding
{ | |
245 public: | |
246 std::string getShaderString() const; | |
247 }; | |
248 | |
249 // Swizzles the red and blue component of sampled texel. | |
250 class FragmentShaderRGBATexClampSwizzleAlphaAA : public FragmentTexClampAlphaAAB
inding { | |
251 public: | |
252 std::string getShaderString() const; | |
253 }; | |
254 | |
255 class FragmentShaderRGBATexAlphaMask { | |
256 public: | |
257 FragmentShaderRGBATexAlphaMask(); | |
258 std::string getShaderString() const; | |
259 | |
260 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
261 int alphaLocation() const { return m_alphaLocation; } | |
262 int samplerLocation() const { return m_samplerLocation; } | |
263 int maskSamplerLocation() const { return m_maskSamplerLocation; } | |
264 int maskTexCoordScaleLocation() const { return m_maskTexCoordScaleLocation;
} | |
265 int maskTexCoordOffsetLocation() const { return m_maskTexCoordOffsetLocation
; } | |
266 | |
267 private: | |
268 int m_samplerLocation; | |
269 int m_maskSamplerLocation; | |
270 int m_alphaLocation; | |
271 int m_maskTexCoordScaleLocation; | |
272 int m_maskTexCoordOffsetLocation; | |
273 }; | |
274 | |
275 class FragmentShaderRGBATexAlphaMaskAA { | |
276 public: | |
277 FragmentShaderRGBATexAlphaMaskAA(); | |
278 std::string getShaderString() const; | |
279 | |
280 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
281 int alphaLocation() const { return m_alphaLocation; } | |
282 int samplerLocation() const { return m_samplerLocation; } | |
283 int maskSamplerLocation() const { return m_maskSamplerLocation; } | |
284 int edgeLocation() const { return m_edgeLocation; } | |
285 int maskTexCoordScaleLocation() const { return m_maskTexCoordScaleLocation;
} | |
286 int maskTexCoordOffsetLocation() const { return m_maskTexCoordOffsetLocation
; } | |
287 | |
288 private: | |
289 int m_samplerLocation; | |
290 int m_maskSamplerLocation; | |
291 int m_alphaLocation; | |
292 int m_edgeLocation; | |
293 int m_maskTexCoordScaleLocation; | |
294 int m_maskTexCoordOffsetLocation; | |
295 }; | |
296 | |
297 class FragmentShaderYUVVideo { | |
298 public: | |
299 FragmentShaderYUVVideo(); | |
300 std::string getShaderString() const; | |
301 | |
302 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
303 | |
304 int yTextureLocation() const { return m_yTextureLocation; } | |
305 int uTextureLocation() const { return m_uTextureLocation; } | |
306 int vTextureLocation() const { return m_vTextureLocation; } | |
307 int alphaLocation() const { return m_alphaLocation; } | |
308 int yuvMatrixLocation() const { return m_yuvMatrixLocation; } | |
309 int yuvAdjLocation() const { return m_yuvAdjLocation; } | |
310 | |
311 private: | |
312 int m_yTextureLocation; | |
313 int m_uTextureLocation; | |
314 int m_vTextureLocation; | |
315 int m_alphaLocation; | |
316 int m_yuvMatrixLocation; | |
317 int m_yuvAdjLocation; | |
318 }; | |
319 | |
320 class FragmentShaderColor { | |
321 public: | |
322 FragmentShaderColor(); | |
323 std::string getShaderString() const; | |
324 | |
325 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
326 int edgeLocation() const { return -1; } | |
327 int colorLocation() const { return m_colorLocation; } | |
328 | |
329 private: | |
330 int m_colorLocation; | |
331 }; | |
332 | |
333 class FragmentShaderColorAA { | |
334 public: | |
335 FragmentShaderColorAA(); | |
336 std::string getShaderString() const; | |
337 | |
338 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
339 int edgeLocation() const { return m_edgeLocation; } | |
340 int colorLocation() const { return m_colorLocation; } | |
341 | |
342 private: | |
343 int m_edgeLocation; | |
344 int m_colorLocation; | |
345 }; | |
346 | |
347 class FragmentShaderCheckerboard { | |
348 public: | |
349 FragmentShaderCheckerboard(); | |
350 std::string getShaderString() const; | |
351 | |
352 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); | |
353 int alphaLocation() const { return m_alphaLocation; } | |
354 int texTransformLocation() const { return m_texTransformLocation; } | |
355 int frequencyLocation() const { return m_frequencyLocation; } | |
356 int colorLocation() const { return m_colorLocation; } | |
357 private: | |
358 int m_alphaLocation; | |
359 int m_texTransformLocation; | |
360 int m_frequencyLocation; | |
361 int m_colorLocation; | |
362 }; | |
363 | |
364 } // namespace cc | |
365 | |
366 #endif // CC_SHADER_H_ | |
OLD | NEW |