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