OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ShaderChromium_h |
| 6 #define ShaderChromium_h |
| 7 |
| 8 #if USE(ACCELERATED_COMPOSITING) |
| 9 |
| 10 #include "SkColorPriv.h" |
| 11 #include <string> |
| 12 |
| 13 namespace WebKit { |
| 14 class WebGraphicsContext3D; |
| 15 } |
| 16 |
| 17 namespace cc { |
| 18 |
| 19 class VertexShaderPosTex { |
| 20 public: |
| 21 VertexShaderPosTex(); |
| 22 |
| 23 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); |
| 24 std::string getShaderString() const; |
| 25 |
| 26 int matrixLocation() const { return m_matrixLocation; } |
| 27 |
| 28 private: |
| 29 int m_matrixLocation; |
| 30 }; |
| 31 |
| 32 class VertexShaderPosTexYUVStretch { |
| 33 public: |
| 34 VertexShaderPosTexYUVStretch(); |
| 35 |
| 36 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); |
| 37 std::string getShaderString() const; |
| 38 |
| 39 int matrixLocation() const { return m_matrixLocation; } |
| 40 int yWidthScaleFactorLocation() const { return m_yWidthScaleFactorLocation;
} |
| 41 int uvWidthScaleFactorLocation() const { return m_uvWidthScaleFactorLocation
; } |
| 42 |
| 43 private: |
| 44 int m_matrixLocation; |
| 45 int m_yWidthScaleFactorLocation; |
| 46 int m_uvWidthScaleFactorLocation; |
| 47 }; |
| 48 |
| 49 class VertexShaderPos { |
| 50 public: |
| 51 VertexShaderPos(); |
| 52 |
| 53 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); |
| 54 std::string getShaderString() const; |
| 55 |
| 56 int matrixLocation() const { return m_matrixLocation; } |
| 57 |
| 58 private: |
| 59 int m_matrixLocation; |
| 60 }; |
| 61 |
| 62 class VertexShaderPosTexIdentity { |
| 63 public: |
| 64 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex) { } |
| 65 std::string getShaderString() const; |
| 66 }; |
| 67 |
| 68 class VertexShaderPosTexTransform { |
| 69 public: |
| 70 VertexShaderPosTexTransform(); |
| 71 |
| 72 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); |
| 73 std::string getShaderString() const; |
| 74 |
| 75 int matrixLocation() const { return m_matrixLocation; } |
| 76 int texTransformLocation() const { return m_texTransformLocation; } |
| 77 |
| 78 private: |
| 79 int m_matrixLocation; |
| 80 int m_texTransformLocation; |
| 81 }; |
| 82 |
| 83 class VertexShaderQuad { |
| 84 public: |
| 85 VertexShaderQuad(); |
| 86 |
| 87 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); |
| 88 std::string getShaderString() const; |
| 89 |
| 90 int matrixLocation() const { return m_matrixLocation; } |
| 91 int pointLocation() const { return m_pointLocation; } |
| 92 |
| 93 private: |
| 94 int m_matrixLocation; |
| 95 int m_pointLocation; |
| 96 }; |
| 97 |
| 98 class VertexShaderTile { |
| 99 public: |
| 100 VertexShaderTile(); |
| 101 |
| 102 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); |
| 103 std::string getShaderString() const; |
| 104 |
| 105 int matrixLocation() const { return m_matrixLocation; } |
| 106 int pointLocation() const { return m_pointLocation; } |
| 107 int vertexTexTransformLocation() const { return m_vertexTexTransformLocation
; } |
| 108 |
| 109 private: |
| 110 int m_matrixLocation; |
| 111 int m_pointLocation; |
| 112 int m_vertexTexTransformLocation; |
| 113 }; |
| 114 |
| 115 class VertexShaderVideoTransform { |
| 116 public: |
| 117 VertexShaderVideoTransform(); |
| 118 |
| 119 bool init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, int* baseUniformIndex); |
| 120 std::string getShaderString() const; |
| 121 |
| 122 int matrixLocation() const { return m_matrixLocation; } |
| 123 int texMatrixLocation() const { return m_texMatrixLocation; } |
| 124 |
| 125 private: |
| 126 int m_matrixLocation; |
| 127 int m_texMatrixLocation; |
| 128 }; |
| 129 |
| 130 class FragmentTexAlphaBinding { |
| 131 public: |
| 132 FragmentTexAlphaBinding(); |
| 133 |
| 134 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, 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; } |
| 139 |
| 140 private: |
| 141 int m_samplerLocation; |
| 142 int m_alphaLocation; |
| 143 }; |
| 144 |
| 145 class FragmentTexOpaqueBinding { |
| 146 public: |
| 147 FragmentTexOpaqueBinding(); |
| 148 |
| 149 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, 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; } |
| 154 |
| 155 private: |
| 156 int m_samplerLocation; |
| 157 }; |
| 158 |
| 159 class FragmentShaderRGBATexFlipAlpha : public FragmentTexAlphaBinding { |
| 160 public: |
| 161 std::string getShaderString() const; |
| 162 }; |
| 163 |
| 164 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { |
| 165 public: |
| 166 std::string getShaderString() const; |
| 167 }; |
| 168 |
| 169 class FragmentShaderRGBATexRectFlipAlpha : public FragmentTexAlphaBinding { |
| 170 public: |
| 171 std::string getShaderString() const; |
| 172 }; |
| 173 |
| 174 class FragmentShaderRGBATexRectAlpha : 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 ccMatrixLocation() const { return m_ccMatrixLocation; } |
| 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_ccMatrixLocation; |
| 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 colorLocation() const { return m_colorLocation; } |
| 327 |
| 328 private: |
| 329 int m_colorLocation; |
| 330 }; |
| 331 |
| 332 class FragmentShaderCheckerboard { |
| 333 public: |
| 334 FragmentShaderCheckerboard(); |
| 335 std::string getShaderString() const; |
| 336 |
| 337 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni
form, 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; } |
| 342 private: |
| 343 int m_alphaLocation; |
| 344 int m_texTransformLocation; |
| 345 int m_frequencyLocation; |
| 346 int m_colorLocation; |
| 347 }; |
| 348 |
| 349 } // namespace cc |
| 350 |
| 351 #endif // USE(ACCELERATED_COMPOSITING) |
| 352 |
| 353 #endif |
OLD | NEW |