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