| OLD | NEW |
| 1 // Copyright 2011 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 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/shader.h" | 7 #include "cc/shader.h" |
| 8 | 8 |
| 9 #include "base/logging.h" |
| 9 #include <public/WebGraphicsContext3D.h> | 10 #include <public/WebGraphicsContext3D.h> |
| 10 #include <wtf/StdLibExtras.h> | 11 #include <wtf/StdLibExtras.h> |
| 11 | 12 |
| 12 #define SHADER0(Src) #Src | 13 #define SHADER0(Src) #Src |
| 13 #define SHADER(Src) SHADER0(Src) | 14 #define SHADER(Src) SHADER0(Src) |
| 14 | 15 |
| 15 using WebKit::WebGraphicsContext3D; | 16 using WebKit::WebGraphicsContext3D; |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 static void getProgramUniformLocations(WebGraphicsContext3D* context, unsigned p
rogram, const char** shaderUniforms, size_t count, size_t maxLocations, int* loc
ations, bool usingBindUniform, int* baseUniformIndex) | 22 static void getProgramUniformLocations(WebGraphicsContext3D* context, unsigned p
rogram, const char** shaderUniforms, size_t count, size_t maxLocations, int* loc
ations, bool usingBindUniform, int* baseUniformIndex) |
| 22 { | 23 { |
| 23 for (size_t uniformIndex = 0; uniformIndex < count; uniformIndex ++) { | 24 for (size_t uniformIndex = 0; uniformIndex < count; uniformIndex ++) { |
| 24 ASSERT(uniformIndex < maxLocations); | 25 DCHECK(uniformIndex < maxLocations); |
| 25 | 26 |
| 26 if (usingBindUniform) { | 27 if (usingBindUniform) { |
| 27 locations[uniformIndex] = (*baseUniformIndex)++; | 28 locations[uniformIndex] = (*baseUniformIndex)++; |
| 28 context->bindUniformLocationCHROMIUM(program, locations[uniformIndex
], shaderUniforms[uniformIndex]); | 29 context->bindUniformLocationCHROMIUM(program, locations[uniformIndex
], shaderUniforms[uniformIndex]); |
| 29 } else | 30 } else |
| 30 locations[uniformIndex] = context->getUniformLocation(program, shade
rUniforms[uniformIndex]); | 31 locations[uniformIndex] = context->getUniformLocation(program, shade
rUniforms[uniformIndex]); |
| 31 } | 32 } |
| 32 } | 33 } |
| 33 | 34 |
| 34 } | 35 } |
| 35 | 36 |
| 36 VertexShaderPosTex::VertexShaderPosTex() | 37 VertexShaderPosTex::VertexShaderPosTex() |
| 37 : m_matrixLocation(-1) | 38 : m_matrixLocation(-1) |
| 38 { | 39 { |
| 39 } | 40 } |
| 40 | 41 |
| 41 void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program, b
ool usingBindUniform, int* baseUniformIndex) | 42 void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program, b
ool usingBindUniform, int* baseUniformIndex) |
| 42 { | 43 { |
| 43 static const char* shaderUniforms[] = { | 44 static const char* shaderUniforms[] = { |
| 44 "matrix", | 45 "matrix", |
| 45 }; | 46 }; |
| 46 int locations[1]; | 47 int locations[1]; |
| 47 | 48 |
| 48 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 49 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 49 | 50 |
| 50 m_matrixLocation = locations[0]; | 51 m_matrixLocation = locations[0]; |
| 51 ASSERT(m_matrixLocation != -1); | 52 DCHECK(m_matrixLocation != -1); |
| 52 } | 53 } |
| 53 | 54 |
| 54 std::string VertexShaderPosTex::getShaderString() const | 55 std::string VertexShaderPosTex::getShaderString() const |
| 55 { | 56 { |
| 56 return SHADER( | 57 return SHADER( |
| 57 attribute vec4 a_position; | 58 attribute vec4 a_position; |
| 58 attribute vec2 a_texCoord; | 59 attribute vec2 a_texCoord; |
| 59 uniform mat4 matrix; | 60 uniform mat4 matrix; |
| 60 varying vec2 v_texCoord; | 61 varying vec2 v_texCoord; |
| 61 void main() | 62 void main() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 80 "y_widthScaleFactor", | 81 "y_widthScaleFactor", |
| 81 "uv_widthScaleFactor", | 82 "uv_widthScaleFactor", |
| 82 }; | 83 }; |
| 83 int locations[3]; | 84 int locations[3]; |
| 84 | 85 |
| 85 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 86 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 86 | 87 |
| 87 m_matrixLocation = locations[0]; | 88 m_matrixLocation = locations[0]; |
| 88 m_yWidthScaleFactorLocation = locations[1]; | 89 m_yWidthScaleFactorLocation = locations[1]; |
| 89 m_uvWidthScaleFactorLocation = locations[2]; | 90 m_uvWidthScaleFactorLocation = locations[2]; |
| 90 ASSERT(m_matrixLocation != -1 && m_yWidthScaleFactorLocation != -1 && m_uvWi
dthScaleFactorLocation != -1); | 91 DCHECK(m_matrixLocation != -1 && m_yWidthScaleFactorLocation != -1 && m_uvWi
dthScaleFactorLocation != -1); |
| 91 } | 92 } |
| 92 | 93 |
| 93 std::string VertexShaderPosTexYUVStretch::getShaderString() const | 94 std::string VertexShaderPosTexYUVStretch::getShaderString() const |
| 94 { | 95 { |
| 95 return SHADER( | 96 return SHADER( |
| 96 precision mediump float; | 97 precision mediump float; |
| 97 attribute vec4 a_position; | 98 attribute vec4 a_position; |
| 98 attribute vec2 a_texCoord; | 99 attribute vec2 a_texCoord; |
| 99 uniform mat4 matrix; | 100 uniform mat4 matrix; |
| 100 varying vec2 y_texCoord; | 101 varying vec2 y_texCoord; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 118 void VertexShaderPos::init(WebGraphicsContext3D* context, unsigned program, bool
usingBindUniform, int* baseUniformIndex) | 119 void VertexShaderPos::init(WebGraphicsContext3D* context, unsigned program, bool
usingBindUniform, int* baseUniformIndex) |
| 119 { | 120 { |
| 120 static const char* shaderUniforms[] = { | 121 static const char* shaderUniforms[] = { |
| 121 "matrix", | 122 "matrix", |
| 122 }; | 123 }; |
| 123 int locations[1]; | 124 int locations[1]; |
| 124 | 125 |
| 125 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 126 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 126 | 127 |
| 127 m_matrixLocation = locations[0]; | 128 m_matrixLocation = locations[0]; |
| 128 ASSERT(m_matrixLocation != -1); | 129 DCHECK(m_matrixLocation != -1); |
| 129 } | 130 } |
| 130 | 131 |
| 131 std::string VertexShaderPos::getShaderString() const | 132 std::string VertexShaderPos::getShaderString() const |
| 132 { | 133 { |
| 133 return SHADER( | 134 return SHADER( |
| 134 attribute vec4 a_position; | 135 attribute vec4 a_position; |
| 135 uniform mat4 matrix; | 136 uniform mat4 matrix; |
| 136 void main() | 137 void main() |
| 137 { | 138 { |
| 138 gl_Position = matrix * a_position; | 139 gl_Position = matrix * a_position; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 151 static const char* shaderUniforms[] = { | 152 static const char* shaderUniforms[] = { |
| 152 "matrix", | 153 "matrix", |
| 153 "texTransform", | 154 "texTransform", |
| 154 }; | 155 }; |
| 155 int locations[2]; | 156 int locations[2]; |
| 156 | 157 |
| 157 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 158 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 158 | 159 |
| 159 m_matrixLocation = locations[0]; | 160 m_matrixLocation = locations[0]; |
| 160 m_texTransformLocation = locations[1]; | 161 m_texTransformLocation = locations[1]; |
| 161 ASSERT(m_matrixLocation != -1 && m_texTransformLocation != -1); | 162 DCHECK(m_matrixLocation != -1 && m_texTransformLocation != -1); |
| 162 } | 163 } |
| 163 | 164 |
| 164 std::string VertexShaderPosTexTransform::getShaderString() const | 165 std::string VertexShaderPosTexTransform::getShaderString() const |
| 165 { | 166 { |
| 166 return SHADER( | 167 return SHADER( |
| 167 attribute vec4 a_position; | 168 attribute vec4 a_position; |
| 168 attribute vec2 a_texCoord; | 169 attribute vec2 a_texCoord; |
| 169 uniform mat4 matrix; | 170 uniform mat4 matrix; |
| 170 uniform vec4 texTransform; | 171 uniform vec4 texTransform; |
| 171 varying vec2 v_texCoord; | 172 varying vec2 v_texCoord; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 201 static const char* shaderUniforms[] = { | 202 static const char* shaderUniforms[] = { |
| 202 "matrix", | 203 "matrix", |
| 203 "point", | 204 "point", |
| 204 }; | 205 }; |
| 205 int locations[2]; | 206 int locations[2]; |
| 206 | 207 |
| 207 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 208 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 208 | 209 |
| 209 m_matrixLocation = locations[0]; | 210 m_matrixLocation = locations[0]; |
| 210 m_pointLocation = locations[1]; | 211 m_pointLocation = locations[1]; |
| 211 ASSERT(m_matrixLocation != -1 && m_pointLocation != -1); | 212 DCHECK(m_matrixLocation != -1 && m_pointLocation != -1); |
| 212 } | 213 } |
| 213 | 214 |
| 214 std::string VertexShaderQuad::getShaderString() const | 215 std::string VertexShaderQuad::getShaderString() const |
| 215 { | 216 { |
| 216 return SHADER( | 217 return SHADER( |
| 217 attribute vec4 a_position; | 218 attribute vec4 a_position; |
| 218 attribute vec2 a_texCoord; | 219 attribute vec2 a_texCoord; |
| 219 uniform mat4 matrix; | 220 uniform mat4 matrix; |
| 220 uniform vec2 point[4]; | 221 uniform vec2 point[4]; |
| 221 varying vec2 v_texCoord; | 222 varying vec2 v_texCoord; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 247 "point", | 248 "point", |
| 248 "vertexTexTransform", | 249 "vertexTexTransform", |
| 249 }; | 250 }; |
| 250 int locations[3]; | 251 int locations[3]; |
| 251 | 252 |
| 252 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 253 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 253 | 254 |
| 254 m_matrixLocation = locations[0]; | 255 m_matrixLocation = locations[0]; |
| 255 m_pointLocation = locations[1]; | 256 m_pointLocation = locations[1]; |
| 256 m_vertexTexTransformLocation = locations[2]; | 257 m_vertexTexTransformLocation = locations[2]; |
| 257 ASSERT(m_matrixLocation != -1 && m_pointLocation != -1 && m_vertexTexTransfo
rmLocation != -1); | 258 DCHECK(m_matrixLocation != -1 && m_pointLocation != -1 && m_vertexTexTransfo
rmLocation != -1); |
| 258 } | 259 } |
| 259 | 260 |
| 260 std::string VertexShaderTile::getShaderString() const | 261 std::string VertexShaderTile::getShaderString() const |
| 261 { | 262 { |
| 262 return SHADER( | 263 return SHADER( |
| 263 attribute vec4 a_position; | 264 attribute vec4 a_position; |
| 264 attribute vec2 a_texCoord; | 265 attribute vec2 a_texCoord; |
| 265 uniform mat4 matrix; | 266 uniform mat4 matrix; |
| 266 uniform vec2 point[4]; | 267 uniform vec2 point[4]; |
| 267 uniform vec4 vertexTexTransform; | 268 uniform vec4 vertexTexTransform; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 static const char* shaderUniforms[] = { | 329 static const char* shaderUniforms[] = { |
| 329 "s_texture", | 330 "s_texture", |
| 330 "alpha", | 331 "alpha", |
| 331 }; | 332 }; |
| 332 int locations[2]; | 333 int locations[2]; |
| 333 | 334 |
| 334 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 335 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 335 | 336 |
| 336 m_samplerLocation = locations[0]; | 337 m_samplerLocation = locations[0]; |
| 337 m_alphaLocation = locations[1]; | 338 m_alphaLocation = locations[1]; |
| 338 ASSERT(m_samplerLocation != -1 && m_alphaLocation != -1); | 339 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1); |
| 339 } | 340 } |
| 340 | 341 |
| 341 FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() | 342 FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() |
| 342 : m_samplerLocation(-1) | 343 : m_samplerLocation(-1) |
| 343 { | 344 { |
| 344 } | 345 } |
| 345 | 346 |
| 346 void FragmentTexOpaqueBinding::init(WebGraphicsContext3D* context, unsigned prog
ram, bool usingBindUniform, int* baseUniformIndex) | 347 void FragmentTexOpaqueBinding::init(WebGraphicsContext3D* context, unsigned prog
ram, bool usingBindUniform, int* baseUniformIndex) |
| 347 { | 348 { |
| 348 static const char* shaderUniforms[] = { | 349 static const char* shaderUniforms[] = { |
| 349 "s_texture", | 350 "s_texture", |
| 350 }; | 351 }; |
| 351 int locations[1]; | 352 int locations[1]; |
| 352 | 353 |
| 353 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 354 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 354 | 355 |
| 355 m_samplerLocation = locations[0]; | 356 m_samplerLocation = locations[0]; |
| 356 ASSERT(m_samplerLocation != -1); | 357 DCHECK(m_samplerLocation != -1); |
| 357 } | 358 } |
| 358 | 359 |
| 359 std::string FragmentShaderRGBATexFlipAlpha::getShaderString() const | 360 std::string FragmentShaderRGBATexFlipAlpha::getShaderString() const |
| 360 { | 361 { |
| 361 return SHADER( | 362 return SHADER( |
| 362 precision mediump float; | 363 precision mediump float; |
| 363 varying vec2 v_texCoord; | 364 varying vec2 v_texCoord; |
| 364 uniform sampler2D s_texture; | 365 uniform sampler2D s_texture; |
| 365 uniform float alpha; | 366 uniform float alpha; |
| 366 void main() | 367 void main() |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 "alpha", | 515 "alpha", |
| 515 "edge", | 516 "edge", |
| 516 }; | 517 }; |
| 517 int locations[3]; | 518 int locations[3]; |
| 518 | 519 |
| 519 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 520 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 520 | 521 |
| 521 m_samplerLocation = locations[0]; | 522 m_samplerLocation = locations[0]; |
| 522 m_alphaLocation = locations[1]; | 523 m_alphaLocation = locations[1]; |
| 523 m_edgeLocation = locations[2]; | 524 m_edgeLocation = locations[2]; |
| 524 ASSERT(m_samplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation !=
-1); | 525 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation !=
-1); |
| 525 } | 526 } |
| 526 | 527 |
| 527 std::string FragmentShaderRGBATexAlphaAA::getShaderString() const | 528 std::string FragmentShaderRGBATexAlphaAA::getShaderString() const |
| 528 { | 529 { |
| 529 return SHADER( | 530 return SHADER( |
| 530 precision mediump float; | 531 precision mediump float; |
| 531 varying vec2 v_texCoord; | 532 varying vec2 v_texCoord; |
| 532 uniform sampler2D s_texture; | 533 uniform sampler2D s_texture; |
| 533 uniform float alpha; | 534 uniform float alpha; |
| 534 uniform vec3 edge[8]; | 535 uniform vec3 edge[8]; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 "edge", | 567 "edge", |
| 567 }; | 568 }; |
| 568 int locations[4]; | 569 int locations[4]; |
| 569 | 570 |
| 570 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 571 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 571 | 572 |
| 572 m_samplerLocation = locations[0]; | 573 m_samplerLocation = locations[0]; |
| 573 m_alphaLocation = locations[1]; | 574 m_alphaLocation = locations[1]; |
| 574 m_fragmentTexTransformLocation = locations[2]; | 575 m_fragmentTexTransformLocation = locations[2]; |
| 575 m_edgeLocation = locations[3]; | 576 m_edgeLocation = locations[3]; |
| 576 ASSERT(m_samplerLocation != -1 && m_alphaLocation != -1 && m_fragmentTexTran
sformLocation != -1 && m_edgeLocation != -1); | 577 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_fragmentTexTran
sformLocation != -1 && m_edgeLocation != -1); |
| 577 } | 578 } |
| 578 | 579 |
| 579 std::string FragmentShaderRGBATexClampAlphaAA::getShaderString() const | 580 std::string FragmentShaderRGBATexClampAlphaAA::getShaderString() const |
| 580 { | 581 { |
| 581 return SHADER( | 582 return SHADER( |
| 582 precision mediump float; | 583 precision mediump float; |
| 583 varying vec2 v_texCoord; | 584 varying vec2 v_texCoord; |
| 584 uniform sampler2D s_texture; | 585 uniform sampler2D s_texture; |
| 585 uniform float alpha; | 586 uniform float alpha; |
| 586 uniform vec4 fragmentTexTransform; | 587 uniform vec4 fragmentTexTransform; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 }; | 650 }; |
| 650 int locations[5]; | 651 int locations[5]; |
| 651 | 652 |
| 652 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 653 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 653 | 654 |
| 654 m_samplerLocation = locations[0]; | 655 m_samplerLocation = locations[0]; |
| 655 m_maskSamplerLocation = locations[1]; | 656 m_maskSamplerLocation = locations[1]; |
| 656 m_alphaLocation = locations[2]; | 657 m_alphaLocation = locations[2]; |
| 657 m_maskTexCoordScaleLocation = locations[3]; | 658 m_maskTexCoordScaleLocation = locations[3]; |
| 658 m_maskTexCoordOffsetLocation = locations[4]; | 659 m_maskTexCoordOffsetLocation = locations[4]; |
| 659 ASSERT(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca
tion != -1); | 660 DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca
tion != -1); |
| 660 } | 661 } |
| 661 | 662 |
| 662 std::string FragmentShaderRGBATexAlphaMask::getShaderString() const | 663 std::string FragmentShaderRGBATexAlphaMask::getShaderString() const |
| 663 { | 664 { |
| 664 return SHADER( | 665 return SHADER( |
| 665 precision mediump float; | 666 precision mediump float; |
| 666 varying vec2 v_texCoord; | 667 varying vec2 v_texCoord; |
| 667 uniform sampler2D s_texture; | 668 uniform sampler2D s_texture; |
| 668 uniform sampler2D s_mask; | 669 uniform sampler2D s_mask; |
| 669 uniform vec2 maskTexCoordScale; | 670 uniform vec2 maskTexCoordScale; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 int locations[6]; | 702 int locations[6]; |
| 702 | 703 |
| 703 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 704 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 704 | 705 |
| 705 m_samplerLocation = locations[0]; | 706 m_samplerLocation = locations[0]; |
| 706 m_maskSamplerLocation = locations[1]; | 707 m_maskSamplerLocation = locations[1]; |
| 707 m_alphaLocation = locations[2]; | 708 m_alphaLocation = locations[2]; |
| 708 m_edgeLocation = locations[3]; | 709 m_edgeLocation = locations[3]; |
| 709 m_maskTexCoordScaleLocation = locations[4]; | 710 m_maskTexCoordScaleLocation = locations[4]; |
| 710 m_maskTexCoordOffsetLocation = locations[5]; | 711 m_maskTexCoordOffsetLocation = locations[5]; |
| 711 ASSERT(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca
tion != -1 && m_edgeLocation != -1); | 712 DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca
tion != -1 && m_edgeLocation != -1); |
| 712 } | 713 } |
| 713 | 714 |
| 714 std::string FragmentShaderRGBATexAlphaMaskAA::getShaderString() const | 715 std::string FragmentShaderRGBATexAlphaMaskAA::getShaderString() const |
| 715 { | 716 { |
| 716 return SHADER( | 717 return SHADER( |
| 717 precision mediump float; | 718 precision mediump float; |
| 718 varying vec2 v_texCoord; | 719 varying vec2 v_texCoord; |
| 719 uniform sampler2D s_texture; | 720 uniform sampler2D s_texture; |
| 720 uniform sampler2D s_mask; | 721 uniform sampler2D s_mask; |
| 721 uniform vec2 maskTexCoordScale; | 722 uniform vec2 maskTexCoordScale; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 | 766 |
| 766 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 767 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 767 | 768 |
| 768 m_yTextureLocation = locations[0]; | 769 m_yTextureLocation = locations[0]; |
| 769 m_uTextureLocation = locations[1]; | 770 m_uTextureLocation = locations[1]; |
| 770 m_vTextureLocation = locations[2]; | 771 m_vTextureLocation = locations[2]; |
| 771 m_alphaLocation = locations[3]; | 772 m_alphaLocation = locations[3]; |
| 772 m_ccMatrixLocation = locations[4]; | 773 m_ccMatrixLocation = locations[4]; |
| 773 m_yuvAdjLocation = locations[5]; | 774 m_yuvAdjLocation = locations[5]; |
| 774 | 775 |
| 775 ASSERT(m_yTextureLocation != -1 && m_uTextureLocation != -1 && m_vTextureLoc
ation != -1 | 776 DCHECK(m_yTextureLocation != -1 && m_uTextureLocation != -1 && m_vTextureLoc
ation != -1 |
| 776 && m_alphaLocation != -1 && m_ccMatrixLocation != -1 && m_yuvAdjLocat
ion != -1); | 777 && m_alphaLocation != -1 && m_ccMatrixLocation != -1 && m_yuvAdjLocat
ion != -1); |
| 777 } | 778 } |
| 778 | 779 |
| 779 std::string FragmentShaderYUVVideo::getShaderString() const | 780 std::string FragmentShaderYUVVideo::getShaderString() const |
| 780 { | 781 { |
| 781 return SHADER( | 782 return SHADER( |
| 782 precision mediump float; | 783 precision mediump float; |
| 783 precision mediump int; | 784 precision mediump int; |
| 784 varying vec2 y_texCoord; | 785 varying vec2 y_texCoord; |
| 785 varying vec2 uv_texCoord; | 786 varying vec2 uv_texCoord; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 809 void FragmentShaderColor::init(WebGraphicsContext3D* context, unsigned program,
bool usingBindUniform, int* baseUniformIndex) | 810 void FragmentShaderColor::init(WebGraphicsContext3D* context, unsigned program,
bool usingBindUniform, int* baseUniformIndex) |
| 810 { | 811 { |
| 811 static const char* shaderUniforms[] = { | 812 static const char* shaderUniforms[] = { |
| 812 "color", | 813 "color", |
| 813 }; | 814 }; |
| 814 int locations[1]; | 815 int locations[1]; |
| 815 | 816 |
| 816 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 817 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 817 | 818 |
| 818 m_colorLocation = locations[0]; | 819 m_colorLocation = locations[0]; |
| 819 ASSERT(m_colorLocation != -1); | 820 DCHECK(m_colorLocation != -1); |
| 820 } | 821 } |
| 821 | 822 |
| 822 std::string FragmentShaderColor::getShaderString() const | 823 std::string FragmentShaderColor::getShaderString() const |
| 823 { | 824 { |
| 824 return SHADER( | 825 return SHADER( |
| 825 precision mediump float; | 826 precision mediump float; |
| 826 uniform vec4 color; | 827 uniform vec4 color; |
| 827 void main() | 828 void main() |
| 828 { | 829 { |
| 829 gl_FragColor = color; | 830 gl_FragColor = color; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 847 "color", | 848 "color", |
| 848 }; | 849 }; |
| 849 int locations[4]; | 850 int locations[4]; |
| 850 | 851 |
| 851 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 852 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
| 852 | 853 |
| 853 m_alphaLocation = locations[0]; | 854 m_alphaLocation = locations[0]; |
| 854 m_texTransformLocation = locations[1]; | 855 m_texTransformLocation = locations[1]; |
| 855 m_frequencyLocation = locations[2]; | 856 m_frequencyLocation = locations[2]; |
| 856 m_colorLocation = locations[3]; | 857 m_colorLocation = locations[3]; |
| 857 ASSERT(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyL
ocation != -1 && m_colorLocation != -1); | 858 DCHECK(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyL
ocation != -1 && m_colorLocation != -1); |
| 858 } | 859 } |
| 859 | 860 |
| 860 std::string FragmentShaderCheckerboard::getShaderString() const | 861 std::string FragmentShaderCheckerboard::getShaderString() const |
| 861 { | 862 { |
| 862 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" | 863 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" |
| 863 // by Munshi, Ginsburg, Shreiner. | 864 // by Munshi, Ginsburg, Shreiner. |
| 864 return SHADER( | 865 return SHADER( |
| 865 precision mediump float; | 866 precision mediump float; |
| 866 precision mediump int; | 867 precision mediump int; |
| 867 varying vec2 v_texCoord; | 868 varying vec2 v_texCoord; |
| 868 uniform float alpha; | 869 uniform float alpha; |
| 869 uniform float frequency; | 870 uniform float frequency; |
| 870 uniform vec4 texTransform; | 871 uniform vec4 texTransform; |
| 871 uniform vec4 color; | 872 uniform vec4 color; |
| 872 void main() | 873 void main() |
| 873 { | 874 { |
| 874 vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0); | 875 vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0); |
| 875 vec4 color2 = color; | 876 vec4 color2 = color; |
| 876 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT
ransform.xy; | 877 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT
ransform.xy; |
| 877 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); | 878 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
| 878 float picker = abs(coord.x - coord.y); | 879 float picker = abs(coord.x - coord.y); |
| 879 gl_FragColor = mix(color1, color2, picker) * alpha; | 880 gl_FragColor = mix(color1, color2, picker) * alpha; |
| 880 } | 881 } |
| 881 ); | 882 ); |
| 882 } | 883 } |
| 883 | 884 |
| 884 } // namespace cc | 885 } // namespace cc |
| OLD | NEW |