OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CC_OUTPUT_SHADER_H_ |
| 6 #define CC_OUTPUT_SHADER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 |
| 12 namespace gfx { |
| 13 class Point; |
| 14 class Size; |
| 15 } |
| 16 |
| 17 namespace gpu { |
| 18 namespace gles2 { |
| 19 class GLES2Interface; |
| 20 } |
| 21 } |
| 22 |
| 23 namespace cc { |
| 24 |
| 25 enum TexCoordPrecision { |
| 26 TEX_COORD_PRECISION_NA = 0, |
| 27 TEX_COORD_PRECISION_MEDIUM = 1, |
| 28 TEX_COORD_PRECISION_HIGH = 2, |
| 29 LAST_TEX_COORD_PRECISION = 2 |
| 30 }; |
| 31 |
| 32 enum SamplerType { |
| 33 SAMPLER_TYPE_NA = 0, |
| 34 SAMPLER_TYPE_2D = 1, |
| 35 SAMPLER_TYPE_2D_RECT = 2, |
| 36 SAMPLER_TYPE_EXTERNAL_OES = 3, |
| 37 LAST_SAMPLER_TYPE = 3 |
| 38 }; |
| 39 |
| 40 enum BlendMode { |
| 41 BLEND_MODE_NONE, |
| 42 BLEND_MODE_NORMAL, |
| 43 BLEND_MODE_SCREEN, |
| 44 BLEND_MODE_OVERLAY, |
| 45 BLEND_MODE_DARKEN, |
| 46 BLEND_MODE_LIGHTEN, |
| 47 BLEND_MODE_COLOR_DODGE, |
| 48 BLEND_MODE_COLOR_BURN, |
| 49 BLEND_MODE_HARD_LIGHT, |
| 50 BLEND_MODE_SOFT_LIGHT, |
| 51 BLEND_MODE_DIFFERENCE, |
| 52 BLEND_MODE_EXCLUSION, |
| 53 BLEND_MODE_MULTIPLY, |
| 54 BLEND_MODE_HUE, |
| 55 BLEND_MODE_SATURATION, |
| 56 BLEND_MODE_COLOR, |
| 57 BLEND_MODE_LUMINOSITY, |
| 58 LAST_BLEND_MODE = BLEND_MODE_LUMINOSITY |
| 59 }; |
| 60 |
| 61 enum MaskMode { |
| 62 NO_MASK = 0, |
| 63 HAS_MASK = 1, |
| 64 LAST_MASK_VALUE = HAS_MASK |
| 65 }; |
| 66 |
| 67 struct ShaderLocations { |
| 68 ShaderLocations(); |
| 69 |
| 70 int sampler = -1; |
| 71 int quad = -1; |
| 72 int edge = -1; |
| 73 int viewport = -1; |
| 74 int mask_sampler = -1; |
| 75 int mask_tex_coord_scale = -1; |
| 76 int mask_tex_coord_offset = -1; |
| 77 int matrix = -1; |
| 78 int alpha = -1; |
| 79 int color_matrix = -1; |
| 80 int color_offset = -1; |
| 81 int tex_transform = -1; |
| 82 int backdrop = -1; |
| 83 int backdrop_rect = -1; |
| 84 int original_backdrop = -1; |
| 85 }; |
| 86 |
| 87 // Note: The highp_threshold_cache must be provided by the caller to make |
| 88 // the caching multi-thread/context safe in an easy low-overhead manner. |
| 89 // The caller must make sure to clear highp_threshold_cache to 0, so it can be |
| 90 // reinitialized, if a new or different context is used. |
| 91 TexCoordPrecision TexCoordPrecisionRequired(gpu::gles2::GLES2Interface* context, |
| 92 int* highp_threshold_cache, |
| 93 int highp_threshold_min, |
| 94 const gfx::Point& max_coordinate); |
| 95 |
| 96 TexCoordPrecision TexCoordPrecisionRequired(gpu::gles2::GLES2Interface* context, |
| 97 int* highp_threshold_cache, |
| 98 int highp_threshold_min, |
| 99 const gfx::Size& max_size); |
| 100 |
| 101 class VertexShaderPosTex { |
| 102 public: |
| 103 VertexShaderPosTex(); |
| 104 |
| 105 void Init(gpu::gles2::GLES2Interface* context, |
| 106 unsigned program, |
| 107 int* base_uniform_index); |
| 108 std::string GetShaderString() const; |
| 109 static std::string GetShaderHead(); |
| 110 static std::string GetShaderBody(); |
| 111 |
| 112 int matrix_location() const { return matrix_location_; } |
| 113 |
| 114 private: |
| 115 int matrix_location_; |
| 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTex); |
| 118 }; |
| 119 |
| 120 class VertexShaderPosTexYUVStretchOffset { |
| 121 public: |
| 122 VertexShaderPosTexYUVStretchOffset(); |
| 123 |
| 124 void Init(gpu::gles2::GLES2Interface* context, |
| 125 unsigned program, |
| 126 int* base_uniform_index); |
| 127 std::string GetShaderString() const; |
| 128 static std::string GetShaderHead(); |
| 129 static std::string GetShaderBody(); |
| 130 |
| 131 int matrix_location() const { return matrix_location_; } |
| 132 int tex_scale_location() const { return tex_scale_location_; } |
| 133 int tex_offset_location() const { return tex_offset_location_; } |
| 134 |
| 135 private: |
| 136 int matrix_location_; |
| 137 int tex_scale_location_; |
| 138 int tex_offset_location_; |
| 139 |
| 140 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexYUVStretchOffset); |
| 141 }; |
| 142 |
| 143 class VertexShaderPos { |
| 144 public: |
| 145 VertexShaderPos(); |
| 146 |
| 147 void Init(gpu::gles2::GLES2Interface* context, |
| 148 unsigned program, |
| 149 int* base_uniform_index); |
| 150 std::string GetShaderString() const; |
| 151 static std::string GetShaderHead(); |
| 152 static std::string GetShaderBody(); |
| 153 |
| 154 int matrix_location() const { return matrix_location_; } |
| 155 |
| 156 private: |
| 157 int matrix_location_; |
| 158 |
| 159 DISALLOW_COPY_AND_ASSIGN(VertexShaderPos); |
| 160 }; |
| 161 |
| 162 class VertexShaderPosTexIdentity { |
| 163 public: |
| 164 void Init(gpu::gles2::GLES2Interface* context, |
| 165 unsigned program, |
| 166 int* base_uniform_index) {} |
| 167 std::string GetShaderString() const; |
| 168 static std::string GetShaderHead(); |
| 169 static std::string GetShaderBody(); |
| 170 }; |
| 171 |
| 172 class VertexShaderPosTexTransform { |
| 173 public: |
| 174 VertexShaderPosTexTransform(); |
| 175 |
| 176 void Init(gpu::gles2::GLES2Interface* context, |
| 177 unsigned program, |
| 178 int* base_uniform_index); |
| 179 std::string GetShaderString() const; |
| 180 static std::string GetShaderHead(); |
| 181 static std::string GetShaderBody(); |
| 182 void FillLocations(ShaderLocations* locations) const; |
| 183 |
| 184 int matrix_location() const { return matrix_location_; } |
| 185 int tex_transform_location() const { return tex_transform_location_; } |
| 186 int vertex_opacity_location() const { return vertex_opacity_location_; } |
| 187 |
| 188 private: |
| 189 int matrix_location_; |
| 190 int tex_transform_location_; |
| 191 int vertex_opacity_location_; |
| 192 |
| 193 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexTransform); |
| 194 }; |
| 195 |
| 196 class VertexShaderQuad { |
| 197 public: |
| 198 VertexShaderQuad(); |
| 199 |
| 200 void Init(gpu::gles2::GLES2Interface* context, |
| 201 unsigned program, |
| 202 int* base_uniform_index); |
| 203 std::string GetShaderString() const; |
| 204 static std::string GetShaderHead(); |
| 205 static std::string GetShaderBody(); |
| 206 |
| 207 int matrix_location() const { return matrix_location_; } |
| 208 int viewport_location() const { return -1; } |
| 209 int quad_location() const { return quad_location_; } |
| 210 int edge_location() const { return -1; } |
| 211 |
| 212 private: |
| 213 int matrix_location_; |
| 214 int quad_location_; |
| 215 |
| 216 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuad); |
| 217 }; |
| 218 |
| 219 class VertexShaderQuadAA { |
| 220 public: |
| 221 VertexShaderQuadAA(); |
| 222 |
| 223 void Init(gpu::gles2::GLES2Interface* context, |
| 224 unsigned program, |
| 225 int* base_uniform_index); |
| 226 std::string GetShaderString() const; |
| 227 static std::string GetShaderHead(); |
| 228 static std::string GetShaderBody(); |
| 229 |
| 230 int matrix_location() const { return matrix_location_; } |
| 231 int viewport_location() const { return viewport_location_; } |
| 232 int quad_location() const { return quad_location_; } |
| 233 int edge_location() const { return edge_location_; } |
| 234 |
| 235 private: |
| 236 int matrix_location_; |
| 237 int viewport_location_; |
| 238 int quad_location_; |
| 239 int edge_location_; |
| 240 |
| 241 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadAA); |
| 242 }; |
| 243 |
| 244 |
| 245 class VertexShaderQuadTexTransformAA { |
| 246 public: |
| 247 VertexShaderQuadTexTransformAA(); |
| 248 |
| 249 void Init(gpu::gles2::GLES2Interface* context, |
| 250 unsigned program, |
| 251 int* base_uniform_index); |
| 252 std::string GetShaderString() const; |
| 253 static std::string GetShaderHead(); |
| 254 static std::string GetShaderBody(); |
| 255 void FillLocations(ShaderLocations* locations) const; |
| 256 |
| 257 int matrix_location() const { return matrix_location_; } |
| 258 int viewport_location() const { return viewport_location_; } |
| 259 int quad_location() const { return quad_location_; } |
| 260 int edge_location() const { return edge_location_; } |
| 261 int tex_transform_location() const { return tex_transform_location_; } |
| 262 |
| 263 private: |
| 264 int matrix_location_; |
| 265 int viewport_location_; |
| 266 int quad_location_; |
| 267 int edge_location_; |
| 268 int tex_transform_location_; |
| 269 |
| 270 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadTexTransformAA); |
| 271 }; |
| 272 |
| 273 class VertexShaderTile { |
| 274 public: |
| 275 VertexShaderTile(); |
| 276 |
| 277 void Init(gpu::gles2::GLES2Interface* context, |
| 278 unsigned program, |
| 279 int* base_uniform_index); |
| 280 std::string GetShaderString() const; |
| 281 static std::string GetShaderHead(); |
| 282 static std::string GetShaderBody(); |
| 283 |
| 284 int matrix_location() const { return matrix_location_; } |
| 285 int viewport_location() const { return -1; } |
| 286 int quad_location() const { return quad_location_; } |
| 287 int edge_location() const { return -1; } |
| 288 int vertex_tex_transform_location() const { |
| 289 return vertex_tex_transform_location_; |
| 290 } |
| 291 |
| 292 private: |
| 293 int matrix_location_; |
| 294 int quad_location_; |
| 295 int vertex_tex_transform_location_; |
| 296 |
| 297 DISALLOW_COPY_AND_ASSIGN(VertexShaderTile); |
| 298 }; |
| 299 |
| 300 class VertexShaderTileAA { |
| 301 public: |
| 302 VertexShaderTileAA(); |
| 303 |
| 304 void Init(gpu::gles2::GLES2Interface* context, |
| 305 unsigned program, |
| 306 int* base_uniform_index); |
| 307 std::string GetShaderString() const; |
| 308 static std::string GetShaderHead(); |
| 309 static std::string GetShaderBody(); |
| 310 |
| 311 int matrix_location() const { return matrix_location_; } |
| 312 int viewport_location() const { return viewport_location_; } |
| 313 int quad_location() const { return quad_location_; } |
| 314 int edge_location() const { return edge_location_; } |
| 315 int vertex_tex_transform_location() const { |
| 316 return vertex_tex_transform_location_; |
| 317 } |
| 318 |
| 319 private: |
| 320 int matrix_location_; |
| 321 int viewport_location_; |
| 322 int quad_location_; |
| 323 int edge_location_; |
| 324 int vertex_tex_transform_location_; |
| 325 |
| 326 DISALLOW_COPY_AND_ASSIGN(VertexShaderTileAA); |
| 327 }; |
| 328 |
| 329 class VertexShaderVideoTransform { |
| 330 public: |
| 331 VertexShaderVideoTransform(); |
| 332 |
| 333 void Init(gpu::gles2::GLES2Interface* context, |
| 334 unsigned program, |
| 335 int* base_uniform_index); |
| 336 std::string GetShaderString() const; |
| 337 static std::string GetShaderHead(); |
| 338 static std::string GetShaderBody(); |
| 339 |
| 340 int matrix_location() const { return matrix_location_; } |
| 341 int tex_matrix_location() const { return tex_matrix_location_; } |
| 342 |
| 343 private: |
| 344 int matrix_location_; |
| 345 int tex_matrix_location_; |
| 346 |
| 347 DISALLOW_COPY_AND_ASSIGN(VertexShaderVideoTransform); |
| 348 }; |
| 349 |
| 350 class FragmentTexBlendMode { |
| 351 public: |
| 352 int backdrop_location() const { return backdrop_location_; } |
| 353 int original_backdrop_location() const { return original_backdrop_location_; } |
| 354 int backdrop_rect_location() const { return backdrop_rect_location_; } |
| 355 |
| 356 BlendMode blend_mode() const { return blend_mode_; } |
| 357 void set_blend_mode(BlendMode blend_mode) { blend_mode_ = blend_mode; } |
| 358 bool has_blend_mode() const { return blend_mode_ != BLEND_MODE_NONE; } |
| 359 void set_mask_for_background(bool mask_for_background) { |
| 360 mask_for_background_ = mask_for_background; |
| 361 } |
| 362 bool mask_for_background() const { return mask_for_background_; } |
| 363 |
| 364 protected: |
| 365 FragmentTexBlendMode(); |
| 366 |
| 367 std::string SetBlendModeFunctions(std::string shader_string) const; |
| 368 |
| 369 int backdrop_location_; |
| 370 int original_backdrop_location_; |
| 371 int backdrop_rect_location_; |
| 372 |
| 373 private: |
| 374 BlendMode blend_mode_; |
| 375 bool mask_for_background_; |
| 376 |
| 377 std::string GetHelperFunctions() const; |
| 378 std::string GetBlendFunction() const; |
| 379 std::string GetBlendFunctionBodyForRGB() const; |
| 380 }; |
| 381 |
| 382 class FragmentTexAlphaBinding : public FragmentTexBlendMode { |
| 383 public: |
| 384 FragmentTexAlphaBinding(); |
| 385 |
| 386 void Init(gpu::gles2::GLES2Interface* context, |
| 387 unsigned program, |
| 388 int* base_uniform_index); |
| 389 int alpha_location() const { return alpha_location_; } |
| 390 int fragment_tex_transform_location() const { return -1; } |
| 391 int sampler_location() const { return sampler_location_; } |
| 392 |
| 393 private: |
| 394 int sampler_location_; |
| 395 int alpha_location_; |
| 396 |
| 397 DISALLOW_COPY_AND_ASSIGN(FragmentTexAlphaBinding); |
| 398 }; |
| 399 |
| 400 class FragmentTexColorMatrixAlphaBinding : public FragmentTexBlendMode { |
| 401 public: |
| 402 FragmentTexColorMatrixAlphaBinding(); |
| 403 |
| 404 void Init(gpu::gles2::GLES2Interface* context, |
| 405 unsigned program, |
| 406 int* base_uniform_index); |
| 407 int alpha_location() const { return alpha_location_; } |
| 408 int color_matrix_location() const { return color_matrix_location_; } |
| 409 int color_offset_location() const { return color_offset_location_; } |
| 410 int fragment_tex_transform_location() const { return -1; } |
| 411 int sampler_location() const { return sampler_location_; } |
| 412 |
| 413 private: |
| 414 int sampler_location_; |
| 415 int alpha_location_; |
| 416 int color_matrix_location_; |
| 417 int color_offset_location_; |
| 418 }; |
| 419 |
| 420 class FragmentTexOpaqueBinding : public FragmentTexBlendMode { |
| 421 public: |
| 422 FragmentTexOpaqueBinding(); |
| 423 |
| 424 void Init(gpu::gles2::GLES2Interface* context, |
| 425 unsigned program, |
| 426 int* base_uniform_index); |
| 427 int alpha_location() const { return -1; } |
| 428 int fragment_tex_transform_location() const { return -1; } |
| 429 int background_color_location() const { return -1; } |
| 430 int sampler_location() const { return sampler_location_; } |
| 431 |
| 432 private: |
| 433 int sampler_location_; |
| 434 |
| 435 DISALLOW_COPY_AND_ASSIGN(FragmentTexOpaqueBinding); |
| 436 }; |
| 437 |
| 438 class FragmentTexBackgroundBinding : public FragmentTexBlendMode { |
| 439 public: |
| 440 FragmentTexBackgroundBinding(); |
| 441 |
| 442 void Init(gpu::gles2::GLES2Interface* context, |
| 443 unsigned program, |
| 444 int* base_uniform_index); |
| 445 int background_color_location() const { return background_color_location_; } |
| 446 int sampler_location() const { return sampler_location_; } |
| 447 |
| 448 private: |
| 449 int background_color_location_; |
| 450 int sampler_location_; |
| 451 |
| 452 DISALLOW_COPY_AND_ASSIGN(FragmentTexBackgroundBinding); |
| 453 }; |
| 454 |
| 455 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding { |
| 456 public: |
| 457 std::string GetShaderString( |
| 458 TexCoordPrecision precision, SamplerType sampler) const; |
| 459 static std::string GetShaderHead(); |
| 460 static std::string GetShaderBody(); |
| 461 }; |
| 462 |
| 463 class FragmentShaderRGBATexPremultiplyAlpha : public FragmentTexOpaqueBinding { |
| 464 public: |
| 465 std::string GetShaderString( |
| 466 TexCoordPrecision precision, SamplerType sampler) const; |
| 467 static std::string GetShaderHead(); |
| 468 static std::string GetShaderBody(); |
| 469 }; |
| 470 |
| 471 class FragmentShaderTexBackgroundVaryingAlpha |
| 472 : public FragmentTexBackgroundBinding { |
| 473 public: |
| 474 std::string GetShaderString( |
| 475 TexCoordPrecision precision, SamplerType sampler) const; |
| 476 static std::string GetShaderHead(); |
| 477 static std::string GetShaderBody(); |
| 478 }; |
| 479 |
| 480 class FragmentShaderTexBackgroundPremultiplyAlpha |
| 481 : public FragmentTexBackgroundBinding { |
| 482 public: |
| 483 std::string GetShaderString( |
| 484 TexCoordPrecision precision, SamplerType sampler) const; |
| 485 static std::string GetShaderHead(); |
| 486 static std::string GetShaderBody(); |
| 487 }; |
| 488 |
| 489 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { |
| 490 public: |
| 491 std::string GetShaderString( |
| 492 TexCoordPrecision precision, SamplerType sampler) const; |
| 493 static std::string GetShaderHead(); |
| 494 static std::string GetShaderBody(); |
| 495 void FillLocations(ShaderLocations* locations) const; |
| 496 }; |
| 497 |
| 498 class FragmentShaderRGBATexColorMatrixAlpha |
| 499 : public FragmentTexColorMatrixAlphaBinding { |
| 500 public: |
| 501 std::string GetShaderString(TexCoordPrecision precision, |
| 502 SamplerType sampler) const; |
| 503 static std::string GetShaderHead(); |
| 504 static std::string GetShaderBody(); |
| 505 void FillLocations(ShaderLocations* locations) const; |
| 506 }; |
| 507 |
| 508 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { |
| 509 public: |
| 510 std::string GetShaderString( |
| 511 TexCoordPrecision precision, SamplerType sampler) const; |
| 512 static std::string GetShaderHead(); |
| 513 static std::string GetShaderBody(); |
| 514 }; |
| 515 |
| 516 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding { |
| 517 public: |
| 518 std::string GetShaderString( |
| 519 TexCoordPrecision precision, SamplerType sampler) const; |
| 520 static std::string GetShaderHead(); |
| 521 static std::string GetShaderBody(); |
| 522 }; |
| 523 |
| 524 // Swizzles the red and blue component of sampled texel with alpha. |
| 525 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { |
| 526 public: |
| 527 std::string GetShaderString( |
| 528 TexCoordPrecision precision, SamplerType sampler) const; |
| 529 static std::string GetShaderHead(); |
| 530 static std::string GetShaderBody(); |
| 531 }; |
| 532 |
| 533 // Swizzles the red and blue component of sampled texel without alpha. |
| 534 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding { |
| 535 public: |
| 536 std::string GetShaderString( |
| 537 TexCoordPrecision precision, SamplerType sampler) const; |
| 538 static std::string GetShaderHead(); |
| 539 static std::string GetShaderBody(); |
| 540 }; |
| 541 |
| 542 class FragmentShaderRGBATexAlphaAA : public FragmentTexBlendMode { |
| 543 public: |
| 544 FragmentShaderRGBATexAlphaAA(); |
| 545 |
| 546 void Init(gpu::gles2::GLES2Interface* context, |
| 547 unsigned program, |
| 548 int* base_uniform_index); |
| 549 std::string GetShaderString( |
| 550 TexCoordPrecision precision, SamplerType sampler) const; |
| 551 static std::string GetShaderHead(); |
| 552 static std::string GetShaderBody(); |
| 553 void FillLocations(ShaderLocations* locations) const; |
| 554 |
| 555 int alpha_location() const { return alpha_location_; } |
| 556 int sampler_location() const { return sampler_location_; } |
| 557 |
| 558 private: |
| 559 int sampler_location_; |
| 560 int alpha_location_; |
| 561 |
| 562 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaAA); |
| 563 }; |
| 564 |
| 565 class FragmentTexClampAlphaAABinding : public FragmentTexBlendMode { |
| 566 public: |
| 567 FragmentTexClampAlphaAABinding(); |
| 568 |
| 569 void Init(gpu::gles2::GLES2Interface* context, |
| 570 unsigned program, |
| 571 int* base_uniform_index); |
| 572 int alpha_location() const { return alpha_location_; } |
| 573 int sampler_location() const { return sampler_location_; } |
| 574 int fragment_tex_transform_location() const { |
| 575 return fragment_tex_transform_location_; |
| 576 } |
| 577 |
| 578 private: |
| 579 int sampler_location_; |
| 580 int alpha_location_; |
| 581 int fragment_tex_transform_location_; |
| 582 |
| 583 DISALLOW_COPY_AND_ASSIGN(FragmentTexClampAlphaAABinding); |
| 584 }; |
| 585 |
| 586 class FragmentShaderRGBATexClampAlphaAA |
| 587 : public FragmentTexClampAlphaAABinding { |
| 588 public: |
| 589 std::string GetShaderString( |
| 590 TexCoordPrecision precision, SamplerType sampler) const; |
| 591 static std::string GetShaderHead(); |
| 592 static std::string GetShaderBody(); |
| 593 }; |
| 594 |
| 595 // Swizzles the red and blue component of sampled texel. |
| 596 class FragmentShaderRGBATexClampSwizzleAlphaAA |
| 597 : public FragmentTexClampAlphaAABinding { |
| 598 public: |
| 599 std::string GetShaderString( |
| 600 TexCoordPrecision precision, SamplerType sampler) const; |
| 601 static std::string GetShaderHead(); |
| 602 static std::string GetShaderBody(); |
| 603 }; |
| 604 |
| 605 class FragmentShaderRGBATexAlphaMask : public FragmentTexBlendMode { |
| 606 public: |
| 607 FragmentShaderRGBATexAlphaMask(); |
| 608 std::string GetShaderString( |
| 609 TexCoordPrecision precision, SamplerType sampler) const; |
| 610 static std::string GetShaderHead(); |
| 611 static std::string GetShaderBody(); |
| 612 void FillLocations(ShaderLocations* locations) const; |
| 613 void Init(gpu::gles2::GLES2Interface* context, |
| 614 unsigned program, |
| 615 int* base_uniform_index); |
| 616 int alpha_location() const { return alpha_location_; } |
| 617 int sampler_location() const { return sampler_location_; } |
| 618 int mask_sampler_location() const { return mask_sampler_location_; } |
| 619 int mask_tex_coord_scale_location() const { |
| 620 return mask_tex_coord_scale_location_; |
| 621 } |
| 622 int mask_tex_coord_offset_location() const { |
| 623 return mask_tex_coord_offset_location_; |
| 624 } |
| 625 |
| 626 private: |
| 627 int sampler_location_; |
| 628 int mask_sampler_location_; |
| 629 int alpha_location_; |
| 630 int mask_tex_coord_scale_location_; |
| 631 int mask_tex_coord_offset_location_; |
| 632 |
| 633 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMask); |
| 634 }; |
| 635 |
| 636 class FragmentShaderRGBATexAlphaMaskAA : public FragmentTexBlendMode { |
| 637 public: |
| 638 FragmentShaderRGBATexAlphaMaskAA(); |
| 639 std::string GetShaderString( |
| 640 TexCoordPrecision precision, SamplerType sampler) const; |
| 641 static std::string GetShaderHead(); |
| 642 static std::string GetShaderBody(); |
| 643 void FillLocations(ShaderLocations* locations) const; |
| 644 void Init(gpu::gles2::GLES2Interface* context, |
| 645 unsigned program, |
| 646 int* base_uniform_index); |
| 647 int alpha_location() const { return alpha_location_; } |
| 648 int sampler_location() const { return sampler_location_; } |
| 649 int mask_sampler_location() const { return mask_sampler_location_; } |
| 650 int mask_tex_coord_scale_location() const { |
| 651 return mask_tex_coord_scale_location_; |
| 652 } |
| 653 int mask_tex_coord_offset_location() const { |
| 654 return mask_tex_coord_offset_location_; |
| 655 } |
| 656 |
| 657 private: |
| 658 int sampler_location_; |
| 659 int mask_sampler_location_; |
| 660 int alpha_location_; |
| 661 int mask_tex_coord_scale_location_; |
| 662 int mask_tex_coord_offset_location_; |
| 663 |
| 664 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMaskAA); |
| 665 }; |
| 666 |
| 667 class FragmentShaderRGBATexAlphaMaskColorMatrixAA |
| 668 : public FragmentTexBlendMode { |
| 669 public: |
| 670 FragmentShaderRGBATexAlphaMaskColorMatrixAA(); |
| 671 std::string GetShaderString( |
| 672 TexCoordPrecision precision, SamplerType sampler) const; |
| 673 static std::string GetShaderHead(); |
| 674 static std::string GetShaderBody(); |
| 675 void FillLocations(ShaderLocations* locations) const; |
| 676 void Init(gpu::gles2::GLES2Interface* context, |
| 677 unsigned program, |
| 678 int* base_uniform_index); |
| 679 int alpha_location() const { return alpha_location_; } |
| 680 int sampler_location() const { return sampler_location_; } |
| 681 int mask_sampler_location() const { return mask_sampler_location_; } |
| 682 int mask_tex_coord_scale_location() const { |
| 683 return mask_tex_coord_scale_location_; |
| 684 } |
| 685 int mask_tex_coord_offset_location() const { |
| 686 return mask_tex_coord_offset_location_; |
| 687 } |
| 688 int color_matrix_location() const { return color_matrix_location_; } |
| 689 int color_offset_location() const { return color_offset_location_; } |
| 690 |
| 691 private: |
| 692 int sampler_location_; |
| 693 int mask_sampler_location_; |
| 694 int alpha_location_; |
| 695 int mask_tex_coord_scale_location_; |
| 696 int mask_tex_coord_offset_location_; |
| 697 int color_matrix_location_; |
| 698 int color_offset_location_; |
| 699 }; |
| 700 |
| 701 class FragmentShaderRGBATexAlphaColorMatrixAA : public FragmentTexBlendMode { |
| 702 public: |
| 703 FragmentShaderRGBATexAlphaColorMatrixAA(); |
| 704 std::string GetShaderString( |
| 705 TexCoordPrecision precision, SamplerType sampler) const; |
| 706 static std::string GetShaderHead(); |
| 707 static std::string GetShaderBody(); |
| 708 void FillLocations(ShaderLocations* locations) const; |
| 709 void Init(gpu::gles2::GLES2Interface* context, |
| 710 unsigned program, |
| 711 int* base_uniform_index); |
| 712 int alpha_location() const { return alpha_location_; } |
| 713 int sampler_location() const { return sampler_location_; } |
| 714 int color_matrix_location() const { return color_matrix_location_; } |
| 715 int color_offset_location() const { return color_offset_location_; } |
| 716 |
| 717 private: |
| 718 int sampler_location_; |
| 719 int alpha_location_; |
| 720 int color_matrix_location_; |
| 721 int color_offset_location_; |
| 722 }; |
| 723 |
| 724 class FragmentShaderRGBATexAlphaMaskColorMatrix : public FragmentTexBlendMode { |
| 725 public: |
| 726 FragmentShaderRGBATexAlphaMaskColorMatrix(); |
| 727 std::string GetShaderString( |
| 728 TexCoordPrecision precision, SamplerType sampler) const; |
| 729 static std::string GetShaderHead(); |
| 730 static std::string GetShaderBody(); |
| 731 void FillLocations(ShaderLocations* locations) const; |
| 732 void Init(gpu::gles2::GLES2Interface* context, |
| 733 unsigned program, |
| 734 int* base_uniform_index); |
| 735 int alpha_location() const { return alpha_location_; } |
| 736 int sampler_location() const { return sampler_location_; } |
| 737 int mask_sampler_location() const { return mask_sampler_location_; } |
| 738 int mask_tex_coord_scale_location() const { |
| 739 return mask_tex_coord_scale_location_; |
| 740 } |
| 741 int mask_tex_coord_offset_location() const { |
| 742 return mask_tex_coord_offset_location_; |
| 743 } |
| 744 int color_matrix_location() const { return color_matrix_location_; } |
| 745 int color_offset_location() const { return color_offset_location_; } |
| 746 |
| 747 private: |
| 748 int sampler_location_; |
| 749 int mask_sampler_location_; |
| 750 int alpha_location_; |
| 751 int mask_tex_coord_scale_location_; |
| 752 int mask_tex_coord_offset_location_; |
| 753 int color_matrix_location_; |
| 754 int color_offset_location_; |
| 755 }; |
| 756 |
| 757 class FragmentShaderYUVVideo : public FragmentTexBlendMode { |
| 758 public: |
| 759 FragmentShaderYUVVideo(); |
| 760 std::string GetShaderString( |
| 761 TexCoordPrecision precision, SamplerType sampler) const; |
| 762 static std::string GetShaderHead(); |
| 763 static std::string GetShaderBody(); |
| 764 |
| 765 void Init(gpu::gles2::GLES2Interface* context, |
| 766 unsigned program, |
| 767 int* base_uniform_index); |
| 768 int y_texture_location() const { return y_texture_location_; } |
| 769 int u_texture_location() const { return u_texture_location_; } |
| 770 int v_texture_location() const { return v_texture_location_; } |
| 771 int alpha_location() const { return alpha_location_; } |
| 772 int yuv_matrix_location() const { return yuv_matrix_location_; } |
| 773 int yuv_adj_location() const { return yuv_adj_location_; } |
| 774 int clamp_rect_location() const { return clamp_rect_location_; } |
| 775 |
| 776 private: |
| 777 int y_texture_location_; |
| 778 int u_texture_location_; |
| 779 int v_texture_location_; |
| 780 int alpha_location_; |
| 781 int yuv_matrix_location_; |
| 782 int yuv_adj_location_; |
| 783 int clamp_rect_location_; |
| 784 |
| 785 DISALLOW_COPY_AND_ASSIGN(FragmentShaderYUVVideo); |
| 786 }; |
| 787 |
| 788 class FragmentShaderYUVAVideo : public FragmentTexBlendMode { |
| 789 public: |
| 790 FragmentShaderYUVAVideo(); |
| 791 std::string GetShaderString( |
| 792 TexCoordPrecision precision, SamplerType sampler) const; |
| 793 static std::string GetShaderHead(); |
| 794 static std::string GetShaderBody(); |
| 795 |
| 796 void Init(gpu::gles2::GLES2Interface* context, |
| 797 unsigned program, |
| 798 int* base_uniform_index); |
| 799 |
| 800 int y_texture_location() const { return y_texture_location_; } |
| 801 int u_texture_location() const { return u_texture_location_; } |
| 802 int v_texture_location() const { return v_texture_location_; } |
| 803 int a_texture_location() const { return a_texture_location_; } |
| 804 int alpha_location() const { return alpha_location_; } |
| 805 int yuv_matrix_location() const { return yuv_matrix_location_; } |
| 806 int yuv_adj_location() const { return yuv_adj_location_; } |
| 807 int clamp_rect_location() const { return clamp_rect_location_; } |
| 808 |
| 809 private: |
| 810 int y_texture_location_; |
| 811 int u_texture_location_; |
| 812 int v_texture_location_; |
| 813 int a_texture_location_; |
| 814 int alpha_location_; |
| 815 int yuv_matrix_location_; |
| 816 int yuv_adj_location_; |
| 817 int clamp_rect_location_; |
| 818 |
| 819 DISALLOW_COPY_AND_ASSIGN(FragmentShaderYUVAVideo); |
| 820 }; |
| 821 |
| 822 class FragmentShaderColor : public FragmentTexBlendMode { |
| 823 public: |
| 824 FragmentShaderColor(); |
| 825 std::string GetShaderString( |
| 826 TexCoordPrecision precision, SamplerType sampler) const; |
| 827 static std::string GetShaderHead(); |
| 828 static std::string GetShaderBody(); |
| 829 |
| 830 void Init(gpu::gles2::GLES2Interface* context, |
| 831 unsigned program, |
| 832 int* base_uniform_index); |
| 833 int color_location() const { return color_location_; } |
| 834 |
| 835 private: |
| 836 int color_location_; |
| 837 |
| 838 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColor); |
| 839 }; |
| 840 |
| 841 class FragmentShaderColorAA : public FragmentTexBlendMode { |
| 842 public: |
| 843 FragmentShaderColorAA(); |
| 844 std::string GetShaderString( |
| 845 TexCoordPrecision precision, SamplerType sampler) const; |
| 846 static std::string GetShaderHead(); |
| 847 static std::string GetShaderBody(); |
| 848 |
| 849 void Init(gpu::gles2::GLES2Interface* context, |
| 850 unsigned program, |
| 851 int* base_uniform_index); |
| 852 int color_location() const { return color_location_; } |
| 853 |
| 854 private: |
| 855 int color_location_; |
| 856 |
| 857 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColorAA); |
| 858 }; |
| 859 |
| 860 class FragmentShaderCheckerboard : public FragmentTexBlendMode { |
| 861 public: |
| 862 FragmentShaderCheckerboard(); |
| 863 std::string GetShaderString( |
| 864 TexCoordPrecision precision, SamplerType sampler) const; |
| 865 static std::string GetShaderHead(); |
| 866 static std::string GetShaderBody(); |
| 867 |
| 868 void Init(gpu::gles2::GLES2Interface* context, |
| 869 unsigned program, |
| 870 int* base_uniform_index); |
| 871 int alpha_location() const { return alpha_location_; } |
| 872 int tex_transform_location() const { return tex_transform_location_; } |
| 873 int frequency_location() const { return frequency_location_; } |
| 874 int color_location() const { return color_location_; } |
| 875 |
| 876 private: |
| 877 int alpha_location_; |
| 878 int tex_transform_location_; |
| 879 int frequency_location_; |
| 880 int color_location_; |
| 881 |
| 882 DISALLOW_COPY_AND_ASSIGN(FragmentShaderCheckerboard); |
| 883 }; |
| 884 |
| 885 } // namespace cc |
| 886 |
| 887 #endif // CC_OUTPUT_SHADER_H_ |
OLD | NEW |