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.
5 #ifndef ShaderChromium_h
6 #define ShaderChromium_h
8 #if USE(ACCELERATED_COMPOSITING)
10 #include "SkColorPriv.h"
14 class WebGraphicsContext3D
;
19 class VertexShaderPosTex
{
23 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
24 std::string
getShaderString() const;
26 int matrixLocation() const { return m_matrixLocation
; }
32 class VertexShaderPosTexYUVStretch
{
34 VertexShaderPosTexYUVStretch();
36 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
37 std::string
getShaderString() const;
39 int matrixLocation() const { return m_matrixLocation
; }
40 int yWidthScaleFactorLocation() const { return m_yWidthScaleFactorLocation
; }
41 int uvWidthScaleFactorLocation() const { return m_uvWidthScaleFactorLocation
; }
45 int m_yWidthScaleFactorLocation
;
46 int m_uvWidthScaleFactorLocation
;
49 class VertexShaderPos
{
53 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
54 std::string
getShaderString() const;
56 int matrixLocation() const { return m_matrixLocation
; }
62 class VertexShaderPosTexIdentity
{
64 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
) { }
65 std::string
getShaderString() const;
68 class VertexShaderPosTexTransform
{
70 VertexShaderPosTexTransform();
72 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
73 std::string
getShaderString() const;
75 int matrixLocation() const { return m_matrixLocation
; }
76 int texTransformLocation() const { return m_texTransformLocation
; }
80 int m_texTransformLocation
;
83 class VertexShaderQuad
{
87 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
88 std::string
getShaderString() const;
90 int matrixLocation() const { return m_matrixLocation
; }
91 int pointLocation() const { return m_pointLocation
; }
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 FragmentShaderRGBATexFlipAlpha
: public FragmentTexAlphaBinding
{
161 std::string
getShaderString() const;
164 class FragmentShaderRGBATexAlpha
: public FragmentTexAlphaBinding
{
166 std::string
getShaderString() const;
169 class FragmentShaderRGBATexRectFlipAlpha
: public FragmentTexAlphaBinding
{
171 std::string
getShaderString() const;
174 class FragmentShaderRGBATexRectAlpha
: public FragmentTexAlphaBinding
{
176 std::string
getShaderString() const;
179 class FragmentShaderRGBATexOpaque
: public FragmentTexOpaqueBinding
{
181 std::string
getShaderString() const;
184 class FragmentShaderRGBATex
: public FragmentTexOpaqueBinding
{
186 std::string
getShaderString() const;
189 // Swizzles the red and blue component of sampled texel with alpha.
190 class FragmentShaderRGBATexSwizzleAlpha
: public FragmentTexAlphaBinding
{
192 std::string
getShaderString() const;
195 // Swizzles the red and blue component of sampled texel without alpha.
196 class FragmentShaderRGBATexSwizzleOpaque
: public FragmentTexOpaqueBinding
{
198 std::string
getShaderString() const;
201 // Fragment shader for external textures.
202 class FragmentShaderOESImageExternal
: public FragmentTexAlphaBinding
{
204 std::string
getShaderString() const;
205 bool init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
207 int m_samplerLocation
;
210 class FragmentShaderRGBATexAlphaAA
{
212 FragmentShaderRGBATexAlphaAA();
214 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
215 std::string
getShaderString() const;
217 int alphaLocation() const { return m_alphaLocation
; }
218 int samplerLocation() const { return m_samplerLocation
; }
219 int edgeLocation() const { return m_edgeLocation
; }
222 int m_samplerLocation
;
227 class FragmentTexClampAlphaAABinding
{
229 FragmentTexClampAlphaAABinding();
231 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
232 int alphaLocation() const { return m_alphaLocation
; }
233 int samplerLocation() const { return m_samplerLocation
; }
234 int fragmentTexTransformLocation() const { return m_fragmentTexTransformLocation
; }
235 int edgeLocation() const { return m_edgeLocation
; }
238 int m_samplerLocation
;
240 int m_fragmentTexTransformLocation
;
244 class FragmentShaderRGBATexClampAlphaAA
: public FragmentTexClampAlphaAABinding
{
246 std::string
getShaderString() const;
249 // Swizzles the red and blue component of sampled texel.
250 class FragmentShaderRGBATexClampSwizzleAlphaAA
: public FragmentTexClampAlphaAABinding
{
252 std::string
getShaderString() const;
255 class FragmentShaderRGBATexAlphaMask
{
257 FragmentShaderRGBATexAlphaMask();
258 std::string
getShaderString() const;
260 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, 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
; }
268 int m_samplerLocation
;
269 int m_maskSamplerLocation
;
271 int m_maskTexCoordScaleLocation
;
272 int m_maskTexCoordOffsetLocation
;
275 class FragmentShaderRGBATexAlphaMaskAA
{
277 FragmentShaderRGBATexAlphaMaskAA();
278 std::string
getShaderString() const;
280 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, 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
; }
289 int m_samplerLocation
;
290 int m_maskSamplerLocation
;
293 int m_maskTexCoordScaleLocation
;
294 int m_maskTexCoordOffsetLocation
;
297 class FragmentShaderYUVVideo
{
299 FragmentShaderYUVVideo();
300 std::string
getShaderString() const;
302 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
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 ccMatrixLocation() const { return m_ccMatrixLocation
; }
309 int yuvAdjLocation() const { return m_yuvAdjLocation
; }
312 int m_yTextureLocation
;
313 int m_uTextureLocation
;
314 int m_vTextureLocation
;
316 int m_ccMatrixLocation
;
317 int m_yuvAdjLocation
;
320 class FragmentShaderColor
{
322 FragmentShaderColor();
323 std::string
getShaderString() const;
325 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
326 int colorLocation() const { return m_colorLocation
; }
332 class FragmentShaderCheckerboard
{
334 FragmentShaderCheckerboard();
335 std::string
getShaderString() const;
337 void init(WebKit::WebGraphicsContext3D
*, unsigned program
, bool usingBindUniform
, int* baseUniformIndex
);
338 int alphaLocation() const { return m_alphaLocation
; }
339 int texTransformLocation() const { return m_texTransformLocation
; }
340 int frequencyLocation() const { return m_frequencyLocation
; }
341 int colorLocation() const { return m_colorLocation
; }
344 int m_texTransformLocation
;
345 int m_frequencyLocation
;
351 #endif // USE(ACCELERATED_COMPOSITING)