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.
8 #include "third_party/skia/include/core/SkColorPriv.h"
12 class WebGraphicsContext3D
;
17 class VertexShaderPosTex
{
21 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
22 std::string
getShaderString() const;
24 int matrixLocation() const { return m_matrixLocation
; }
30 class VertexShaderPosTexYUVStretch
{
32 VertexShaderPosTexYUVStretch();
34 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
35 std::string
getShaderString() const;
37 int matrixLocation() const { return m_matrixLocation
; }
38 int texScaleLocation() const { return m_texScaleLocation
; }
42 int m_texScaleLocation
;
45 class VertexShaderPos
{
49 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
50 std::string
getShaderString() const;
52 int matrixLocation() const { return m_matrixLocation
; }
58 class VertexShaderPosTexIdentity
{
60 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
) { }
61 std::string
getShaderString() const;
64 class VertexShaderPosTexTransform
{
66 VertexShaderPosTexTransform();
68 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
69 std::string
getShaderString() const;
71 int matrixLocation() const { return m_matrixLocation
; }
72 int texTransformLocation() const { return m_texTransformLocation
; }
73 int vertexOpacityLocation() const { return m_vertexOpacityLocation
; }
77 int m_texTransformLocation
;
78 int m_vertexOpacityLocation
;
81 class VertexShaderQuad
{
85 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
86 std::string
getShaderString() const;
88 int matrixLocation() const { return m_matrixLocation
; }
89 int pointLocation() const { return m_pointLocation
; }
90 int texScaleLocation() const { return m_texScaleLocation
; }
95 int m_texScaleLocation
;
98 class VertexShaderTile
{
102 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
103 std::string
getShaderString() const;
105 int matrixLocation() const { return m_matrixLocation
; }
106 int pointLocation() const { return m_pointLocation
; }
107 int vertexTexTransformLocation() const { return m_vertexTexTransformLocation
; }
110 int m_matrixLocation
;
112 int m_vertexTexTransformLocation
;
115 class VertexShaderVideoTransform
{
117 VertexShaderVideoTransform();
119 bool init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
120 std::string
getShaderString() const;
122 int matrixLocation() const { return m_matrixLocation
; }
123 int texMatrixLocation() const { return m_texMatrixLocation
; }
126 int m_matrixLocation
;
127 int m_texMatrixLocation
;
130 class FragmentTexAlphaBinding
{
132 FragmentTexAlphaBinding();
134 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
135 int alphaLocation() const { return m_alphaLocation
; }
136 int edgeLocation() const { return -1; }
137 int fragmentTexTransformLocation() const { return -1; }
138 int samplerLocation() const { return m_samplerLocation
; }
141 int m_samplerLocation
;
145 class FragmentTexOpaqueBinding
{
147 FragmentTexOpaqueBinding();
149 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
150 int alphaLocation() const { return -1; }
151 int edgeLocation() const { return -1; }
152 int fragmentTexTransformLocation() const { return -1; }
153 int samplerLocation() const { return m_samplerLocation
; }
156 int m_samplerLocation
;
159 class FragmentShaderRGBATexFlipVaryingAlpha
: public FragmentTexOpaqueBinding
{
161 std::string
getShaderString() const;
164 class FragmentShaderRGBATexVaryingAlpha
: public FragmentTexOpaqueBinding
{
166 std::string
getShaderString() const;
169 class FragmentShaderRGBATexAlpha
: public FragmentTexAlphaBinding
{
171 std::string
getShaderString() const;
174 class FragmentShaderRGBATexRectFlipVaryingAlpha
: public FragmentTexAlphaBinding
{
176 std::string
getShaderString() const;
179 class FragmentShaderRGBATexRectVaryingAlpha
: public FragmentTexAlphaBinding
{
181 std::string
getShaderString() const;
184 class FragmentShaderRGBATexOpaque
: public FragmentTexOpaqueBinding
{
186 std::string
getShaderString() const;
189 class FragmentShaderRGBATex
: public FragmentTexOpaqueBinding
{
191 std::string
getShaderString() const;
194 // Swizzles the red and blue component of sampled texel with alpha.
195 class FragmentShaderRGBATexSwizzleAlpha
: public FragmentTexAlphaBinding
{
197 std::string
getShaderString() const;
200 // Swizzles the red and blue component of sampled texel without alpha.
201 class FragmentShaderRGBATexSwizzleOpaque
: public FragmentTexOpaqueBinding
{
203 std::string
getShaderString() const;
206 // Fragment shader for external textures.
207 class FragmentShaderOESImageExternal
: public FragmentTexAlphaBinding
{
209 std::string
getShaderString() const;
210 bool init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
212 int m_samplerLocation
;
215 class FragmentShaderRGBATexAlphaAA
{
217 FragmentShaderRGBATexAlphaAA();
219 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
220 std::string
getShaderString() const;
222 int alphaLocation() const { return m_alphaLocation
; }
223 int samplerLocation() const { return m_samplerLocation
; }
224 int edgeLocation() const { return m_edgeLocation
; }
227 int m_samplerLocation
;
232 class FragmentTexClampAlphaAABinding
{
234 FragmentTexClampAlphaAABinding();
236 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
237 int alphaLocation() const { return m_alphaLocation
; }
238 int samplerLocation() const { return m_samplerLocation
; }
239 int fragmentTexTransformLocation() const { return m_fragmentTexTransformLocation
; }
240 int edgeLocation() const { return m_edgeLocation
; }
243 int m_samplerLocation
;
245 int m_fragmentTexTransformLocation
;
249 class FragmentShaderRGBATexClampAlphaAA
: public FragmentTexClampAlphaAABinding
{
251 std::string
getShaderString() const;
254 // Swizzles the red and blue component of sampled texel.
255 class FragmentShaderRGBATexClampSwizzleAlphaAA
: public FragmentTexClampAlphaAABinding
{
257 std::string
getShaderString() const;
260 class FragmentShaderRGBATexAlphaMask
{
262 FragmentShaderRGBATexAlphaMask();
263 std::string
getShaderString() const;
265 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
266 int alphaLocation() const { return m_alphaLocation
; }
267 int samplerLocation() const { return m_samplerLocation
; }
268 int maskSamplerLocation() const { return m_maskSamplerLocation
; }
269 int maskTexCoordScaleLocation() const { return m_maskTexCoordScaleLocation
; }
270 int maskTexCoordOffsetLocation() const { return m_maskTexCoordOffsetLocation
; }
273 int m_samplerLocation
;
274 int m_maskSamplerLocation
;
276 int m_maskTexCoordScaleLocation
;
277 int m_maskTexCoordOffsetLocation
;
280 class FragmentShaderRGBATexAlphaMaskAA
{
282 FragmentShaderRGBATexAlphaMaskAA();
283 std::string
getShaderString() const;
285 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
286 int alphaLocation() const { return m_alphaLocation
; }
287 int samplerLocation() const { return m_samplerLocation
; }
288 int maskSamplerLocation() const { return m_maskSamplerLocation
; }
289 int edgeLocation() const { return m_edgeLocation
; }
290 int maskTexCoordScaleLocation() const { return m_maskTexCoordScaleLocation
; }
291 int maskTexCoordOffsetLocation() const { return m_maskTexCoordOffsetLocation
; }
294 int m_samplerLocation
;
295 int m_maskSamplerLocation
;
298 int m_maskTexCoordScaleLocation
;
299 int m_maskTexCoordOffsetLocation
;
302 class FragmentShaderYUVVideo
{
304 FragmentShaderYUVVideo();
305 std::string
getShaderString() const;
307 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
309 int yTextureLocation() const { return m_yTextureLocation
; }
310 int uTextureLocation() const { return m_uTextureLocation
; }
311 int vTextureLocation() const { return m_vTextureLocation
; }
312 int alphaLocation() const { return m_alphaLocation
; }
313 int yuvMatrixLocation() const { return m_yuvMatrixLocation
; }
314 int yuvAdjLocation() const { return m_yuvAdjLocation
; }
317 int m_yTextureLocation
;
318 int m_uTextureLocation
;
319 int m_vTextureLocation
;
321 int m_yuvMatrixLocation
;
322 int m_yuvAdjLocation
;
325 class FragmentShaderColor
{
327 FragmentShaderColor();
328 std::string
getShaderString() const;
330 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
331 int colorLocation() const { return m_colorLocation
; }
337 class FragmentShaderCheckerboard
{
339 FragmentShaderCheckerboard();
340 std::string
getShaderString() const;
342 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
343 int alphaLocation() const { return m_alphaLocation
; }
344 int texTransformLocation() const { return m_texTransformLocation
; }
345 int frequencyLocation() const { return m_frequencyLocation
; }
346 int colorLocation() const { return m_colorLocation
; }
349 int m_texTransformLocation
;
350 int m_frequencyLocation
;
356 #endif // CC_SHADER_H_