2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef ShaderChromium_h
27 #define ShaderChromium_h
29 #if USE(ACCELERATED_COMPOSITING)
31 #include "PlatformString.h"
34 #include "SkColorPriv.h"
39 class GraphicsContext3D;
41 class VertexShaderPosTex {
45 void init(GraphicsContext3D*, unsigned program);
46 String getShaderString() const;
48 int matrixLocation() const { return m_matrixLocation; }
54 class VertexShaderPosTexYUVStretch {
56 VertexShaderPosTexYUVStretch();
58 void init(GraphicsContext3D*, unsigned program);
59 String getShaderString() const;
61 int matrixLocation() const { return m_matrixLocation; }
62 int yWidthScaleFactorLocation() const { return m_yWidthScaleFactorLocation; }
63 int uvWidthScaleFactorLocation() const { return m_uvWidthScaleFactorLocation; }
67 int m_yWidthScaleFactorLocation;
68 int m_uvWidthScaleFactorLocation;
71 class VertexShaderPos {
75 void init(GraphicsContext3D*, unsigned program);
76 String getShaderString() const;
78 int matrixLocation() const { return m_matrixLocation; }
84 class VertexShaderPosTexTransform {
86 VertexShaderPosTexTransform();
88 void init(GraphicsContext3D*, unsigned program);
89 String getShaderString() const;
91 int matrixLocation() const { return m_matrixLocation; }
92 int texTransformLocation() const { return m_texTransformLocation; }
96 int m_texTransformLocation;
99 class VertexShaderQuad {
103 void init(GraphicsContext3D*, unsigned program);
104 String getShaderString() const;
106 int matrixLocation() const { return m_matrixLocation; }
107 int pointLocation() const { return m_pointLocation; }
110 int m_matrixLocation;
114 class VertexShaderTile {
118 void init(GraphicsContext3D*, unsigned program);
119 String getShaderString() const;
121 int matrixLocation() const { return m_matrixLocation; }
122 int pointLocation() const { return m_pointLocation; }
123 int vertexTexTransformLocation() const { return m_vertexTexTransformLocation; }
126 int m_matrixLocation;
128 int m_vertexTexTransformLocation;
131 class FragmentTexAlphaBinding {
133 FragmentTexAlphaBinding();
135 void init(GraphicsContext3D*, unsigned program);
136 int alphaLocation() const { return m_alphaLocation; }
137 int samplerLocation() const { return m_samplerLocation; }
140 int m_samplerLocation;
144 class FragmentShaderRGBATexFlipAlpha : public FragmentTexAlphaBinding {
146 String getShaderString() const;
149 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding {
151 String getShaderString() const;
154 // Swizzles the red and blue component of sampled texel.
155 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding {
157 String getShaderString() const;
160 class FragmentShaderRGBATexAlphaAA {
162 FragmentShaderRGBATexAlphaAA();
164 void init(GraphicsContext3D*, unsigned program);
165 String getShaderString() const;
167 int alphaLocation() const { return m_alphaLocation; }
168 int samplerLocation() const { return m_samplerLocation; }
169 int edgeLocation() const { return m_edgeLocation; }
172 int m_samplerLocation;
177 class FragmentTexClampAlphaAABinding {
179 FragmentTexClampAlphaAABinding();
181 void init(GraphicsContext3D*, unsigned program);
182 int alphaLocation() const { return m_alphaLocation; }
183 int samplerLocation() const { return m_samplerLocation; }
184 int fragmentTexTransformLocation() const { return m_fragmentTexTransformLocation; }
185 int edgeLocation() const { return m_edgeLocation; }
188 int m_samplerLocation;
190 int m_fragmentTexTransformLocation;
194 class FragmentShaderRGBATexClampAlphaAA : public FragmentTexClampAlphaAABinding {
196 String getShaderString() const;
199 // Swizzles the red and blue component of sampled texel.
200 class FragmentShaderRGBATexClampSwizzleAlphaAA : public FragmentTexClampAlphaAABinding {
202 String getShaderString() const;
205 class FragmentShaderRGBATexAlphaMask {
207 FragmentShaderRGBATexAlphaMask();
208 String getShaderString() const;
210 void init(GraphicsContext3D*, unsigned program);
211 int alphaLocation() const { return m_alphaLocation; }
212 int samplerLocation() const { return m_samplerLocation; }
213 int maskSamplerLocation() const { return m_maskSamplerLocation; }
216 int m_samplerLocation;
217 int m_maskSamplerLocation;
221 class FragmentShaderRGBATexAlphaMaskAA {
223 FragmentShaderRGBATexAlphaMaskAA();
224 String getShaderString() const;
226 void init(GraphicsContext3D*, unsigned program);
227 int alphaLocation() const { return m_alphaLocation; }
228 int samplerLocation() const { return m_samplerLocation; }
229 int maskSamplerLocation() const { return m_maskSamplerLocation; }
230 int edgeLocation() const { return m_edgeLocation; }
233 int m_samplerLocation;
234 int m_maskSamplerLocation;
239 class FragmentShaderYUVVideo {
241 FragmentShaderYUVVideo();
242 String getShaderString() const;
244 void init(GraphicsContext3D*, unsigned program);
246 int yTextureLocation() const { return m_yTextureLocation; }
247 int uTextureLocation() const { return m_uTextureLocation; }
248 int vTextureLocation() const { return m_vTextureLocation; }
249 int alphaLocation() const { return m_alphaLocation; }
250 int ccMatrixLocation() const { return m_ccMatrixLocation; }
251 int yuvAdjLocation() const { return m_yuvAdjLocation; }
254 int m_yTextureLocation;
255 int m_uTextureLocation;
256 int m_vTextureLocation;
258 int m_ccMatrixLocation;
259 int m_yuvAdjLocation;
262 class FragmentShaderColor {
264 FragmentShaderColor();
265 String getShaderString() const;
267 void init(GraphicsContext3D*, unsigned program);
268 int colorLocation() const { return m_colorLocation; }
274 } // namespace WebCore
276 #endif // USE(ACCELERATED_COMPOSITING)