Chromium Code Reviews| 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 "cc/shader.h" | 5 #include "cc/shader.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" | 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" |
| 10 | 10 |
| 11 #define SHADER0(Src) #Src | 11 #define SHADER0(Src) #Src |
| 12 #define SHADER(Src) SHADER0(Src) | 12 #define SHADER(Src) fixShader(SHADER0(Src)) |
| 13 | 13 |
| 14 using WebKit::WebGraphicsContext3D; | 14 using WebKit::WebGraphicsContext3D; |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 static void getProgramUniformLocations(WebGraphicsContext3D* context, unsigned p rogram, const char** shaderUniforms, size_t count, size_t maxLocations, int* loc ations, bool usingBindUniform, int* baseUniformIndex) | 20 static void getProgramUniformLocations(WebGraphicsContext3D* context, unsigned p rogram, const char** shaderUniforms, size_t count, size_t maxLocations, int* loc ations, bool usingBindUniform, int* baseUniformIndex) |
| 21 { | 21 { |
| 22 for (size_t uniformIndex = 0; uniformIndex < count; uniformIndex ++) { | 22 for (size_t uniformIndex = 0; uniformIndex < count; uniformIndex ++) { |
| 23 DCHECK(uniformIndex < maxLocations); | 23 DCHECK(uniformIndex < maxLocations); |
| 24 | 24 |
| 25 if (usingBindUniform) { | 25 if (usingBindUniform) { |
| 26 locations[uniformIndex] = (*baseUniformIndex)++; | 26 locations[uniformIndex] = (*baseUniformIndex)++; |
| 27 context->bindUniformLocationCHROMIUM(program, locations[uniformIndex ], shaderUniforms[uniformIndex]); | 27 context->bindUniformLocationCHROMIUM(program, locations[uniformIndex ], shaderUniforms[uniformIndex]); |
| 28 } else | 28 } else |
| 29 locations[uniformIndex] = context->getUniformLocation(program, shade rUniforms[uniformIndex]); | 29 locations[uniformIndex] = context->getUniformLocation(program, shade rUniforms[uniformIndex]); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 static std::string fixShader(const char* shaderString) { | |
|
Vangelis Kokkevis
2013/02/21 07:47:35
nit: please use a more descriptive name for this f
| |
| 34 return "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" | |
| 35 "#define TexCoordPrecision highp\n" | |
| 36 "#else\n" | |
| 37 "#define TexCoordPrecision mediump\n" | |
| 38 "#endif\n" + | |
| 39 std::string(shaderString); | |
| 40 } | |
| 41 | |
| 33 } | 42 } |
| 34 | 43 |
| 35 VertexShaderPosTex::VertexShaderPosTex() | 44 VertexShaderPosTex::VertexShaderPosTex() |
| 36 : m_matrixLocation(-1) | 45 : m_matrixLocation(-1) |
| 37 { | 46 { |
| 38 } | 47 } |
| 39 | 48 |
| 40 void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program, b ool usingBindUniform, int* baseUniformIndex) | 49 void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program, b ool usingBindUniform, int* baseUniformIndex) |
| 41 { | 50 { |
| 42 static const char* shaderUniforms[] = { | 51 static const char* shaderUniforms[] = { |
| 43 "matrix", | 52 "matrix", |
| 44 }; | 53 }; |
| 45 int locations[1]; | 54 int locations[1]; |
| 46 | 55 |
| 47 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; | 56 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; |
| 48 | 57 |
| 49 m_matrixLocation = locations[0]; | 58 m_matrixLocation = locations[0]; |
| 50 DCHECK(m_matrixLocation != -1); | 59 DCHECK(m_matrixLocation != -1); |
| 51 } | 60 } |
| 52 | 61 |
| 53 std::string VertexShaderPosTex::getShaderString() const | 62 std::string VertexShaderPosTex::getShaderString() const |
| 54 { | 63 { |
| 55 return SHADER( | 64 return SHADER( |
| 56 attribute vec4 a_position; | 65 attribute vec4 a_position; |
| 57 attribute vec2 a_texCoord; | 66 attribute TexCoordPrecision vec2 a_texCoord; |
|
Vangelis Kokkevis
2013/02/21 07:47:35
I wonder if we should leave the vertex shaders alo
Sami
2013/02/21 11:47:38
Right. We could add a VERTEX_SHADER and FRAGMENT_S
brianderson
2013/02/21 23:05:55
Hmm, I had VERTEX_SHADER and FRAGMENT_SHADER macro
| |
| 58 uniform mat4 matrix; | 67 uniform mat4 matrix; |
| 59 varying vec2 v_texCoord; | 68 varying TexCoordPrecision vec2 v_texCoord; |
| 60 void main() | 69 void main() |
| 61 { | 70 { |
| 62 gl_Position = matrix * a_position; | 71 gl_Position = matrix * a_position; |
| 63 v_texCoord = a_texCoord; | 72 v_texCoord = a_texCoord; |
| 64 } | 73 } |
| 65 ); | 74 ); |
| 66 } | 75 } |
| 67 | 76 |
| 68 VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() | 77 VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() |
| 69 : m_matrixLocation(-1) | 78 : m_matrixLocation(-1) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 84 m_matrixLocation = locations[0]; | 93 m_matrixLocation = locations[0]; |
| 85 m_texScaleLocation = locations[1]; | 94 m_texScaleLocation = locations[1]; |
| 86 DCHECK(m_matrixLocation != -1 && m_texScaleLocation != -1); | 95 DCHECK(m_matrixLocation != -1 && m_texScaleLocation != -1); |
| 87 } | 96 } |
| 88 | 97 |
| 89 std::string VertexShaderPosTexYUVStretch::getShaderString() const | 98 std::string VertexShaderPosTexYUVStretch::getShaderString() const |
| 90 { | 99 { |
| 91 return SHADER( | 100 return SHADER( |
| 92 precision mediump float; | 101 precision mediump float; |
| 93 attribute vec4 a_position; | 102 attribute vec4 a_position; |
| 94 attribute vec2 a_texCoord; | 103 attribute TexCoordPrecision vec2 a_texCoord; |
| 95 uniform mat4 matrix; | 104 uniform mat4 matrix; |
| 96 varying vec2 v_texCoord; | 105 varying TexCoordPrecision vec2 v_texCoord; |
| 97 uniform vec2 texScale; | 106 uniform TexCoordPrecision vec2 texScale; |
| 98 void main() | 107 void main() |
| 99 { | 108 { |
| 100 gl_Position = matrix * a_position; | 109 gl_Position = matrix * a_position; |
| 101 v_texCoord = a_texCoord * texScale; | 110 v_texCoord = a_texCoord * texScale; |
| 102 } | 111 } |
| 103 ); | 112 ); |
| 104 } | 113 } |
| 105 | 114 |
| 106 VertexShaderPos::VertexShaderPos() | 115 VertexShaderPos::VertexShaderPos() |
| 107 : m_matrixLocation(-1) | 116 : m_matrixLocation(-1) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 m_matrixLocation = locations[0]; | 163 m_matrixLocation = locations[0]; |
| 155 m_texTransformLocation = locations[1]; | 164 m_texTransformLocation = locations[1]; |
| 156 m_vertexOpacityLocation = locations[2]; | 165 m_vertexOpacityLocation = locations[2]; |
| 157 DCHECK(m_matrixLocation != -1 && m_texTransformLocation != -1 && m_vertexOpa cityLocation != -1); | 166 DCHECK(m_matrixLocation != -1 && m_texTransformLocation != -1 && m_vertexOpa cityLocation != -1); |
| 158 } | 167 } |
| 159 | 168 |
| 160 std::string VertexShaderPosTexTransform::getShaderString() const | 169 std::string VertexShaderPosTexTransform::getShaderString() const |
| 161 { | 170 { |
| 162 return SHADER( | 171 return SHADER( |
| 163 attribute vec4 a_position; | 172 attribute vec4 a_position; |
| 164 attribute vec2 a_texCoord; | 173 attribute TexCoordPrecision vec2 a_texCoord; |
| 165 attribute float a_index; | 174 attribute float a_index; |
| 166 uniform mat4 matrix[8]; | 175 uniform mat4 matrix[8]; |
| 167 uniform vec4 texTransform[8]; | 176 uniform TexCoordPrecision vec4 texTransform[8]; |
| 168 uniform float opacity[32]; | 177 uniform float opacity[32]; |
| 169 varying vec2 v_texCoord; | 178 varying TexCoordPrecision vec2 v_texCoord; |
| 170 varying float v_alpha; | 179 varying float v_alpha; |
| 171 void main() | 180 void main() |
| 172 { | 181 { |
| 173 gl_Position = matrix[int(a_index * 0.25)] * a_position; | 182 gl_Position = matrix[int(a_index * 0.25)] * a_position; |
| 174 vec4 texTrans = texTransform[int(a_index * 0.25)]; | 183 TexCoordPrecision vec4 texTrans = texTransform[int(a_index * 0.25)]; |
| 175 v_texCoord = a_texCoord * texTrans.zw + texTrans.xy; | 184 v_texCoord = a_texCoord * texTrans.zw + texTrans.xy; |
| 176 v_alpha = opacity[int(a_index)]; | 185 v_alpha = opacity[int(a_index)]; |
| 177 } | 186 } |
| 178 ); | 187 ); |
| 179 } | 188 } |
| 180 | 189 |
| 181 std::string VertexShaderPosTexIdentity::getShaderString() const | 190 std::string VertexShaderPosTexIdentity::getShaderString() const |
| 182 { | 191 { |
| 183 return SHADER( | 192 return SHADER( |
| 184 attribute vec4 a_position; | 193 attribute vec4 a_position; |
| 185 varying vec2 v_texCoord; | 194 varying TexCoordPrecision vec2 v_texCoord; |
| 186 void main() | 195 void main() |
| 187 { | 196 { |
| 188 gl_Position = a_position; | 197 gl_Position = a_position; |
| 189 v_texCoord = (a_position.xy + vec2(1.0)) * 0.5; | 198 v_texCoord = (a_position.xy + vec2(1.0)) * 0.5; |
| 190 } | 199 } |
| 191 ); | 200 ); |
| 192 } | 201 } |
| 193 | 202 |
| 194 VertexShaderQuad::VertexShaderQuad() | 203 VertexShaderQuad::VertexShaderQuad() |
| 195 : m_matrixLocation(-1) | 204 : m_matrixLocation(-1) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 213 m_pointLocation = locations[1]; | 222 m_pointLocation = locations[1]; |
| 214 m_texScaleLocation = locations[2]; | 223 m_texScaleLocation = locations[2]; |
| 215 DCHECK_NE(m_matrixLocation, -1); | 224 DCHECK_NE(m_matrixLocation, -1); |
| 216 DCHECK_NE(m_pointLocation, -1); | 225 DCHECK_NE(m_pointLocation, -1); |
| 217 DCHECK_NE(m_texScaleLocation, -1); | 226 DCHECK_NE(m_texScaleLocation, -1); |
| 218 } | 227 } |
| 219 | 228 |
| 220 std::string VertexShaderQuad::getShaderString() const | 229 std::string VertexShaderQuad::getShaderString() const |
| 221 { | 230 { |
| 222 return SHADER( | 231 return SHADER( |
| 223 attribute vec4 a_position; | 232 attribute TexCoordPrecision vec4 a_position; |
| 224 attribute vec2 a_texCoord; | 233 attribute TexCoordPrecision vec2 a_texCoord; |
| 225 uniform mat4 matrix; | 234 uniform mat4 matrix; |
| 226 uniform vec2 point[4]; | 235 uniform TexCoordPrecision vec2 point[4]; |
| 227 uniform vec2 texScale; | 236 uniform TexCoordPrecision vec2 texScale; |
| 228 varying vec2 v_texCoord; | 237 varying TexCoordPrecision vec2 v_texCoord; |
| 229 void main() | 238 void main() |
| 230 { | 239 { |
| 231 vec2 complement = abs(a_texCoord - 1.0); | 240 TexCoordPrecision vec2 complement = abs(a_texCoord - 1.0); |
| 232 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w); | 241 TexCoordPrecision vec4 pos = vec4(0.0, 0.0, a_position.z, a_position .w); |
| 233 pos.xy += (complement.x * complement.y) * point[0]; | 242 pos.xy += (complement.x * complement.y) * point[0]; |
| 234 pos.xy += (a_texCoord.x * complement.y) * point[1]; | 243 pos.xy += (a_texCoord.x * complement.y) * point[1]; |
| 235 pos.xy += (a_texCoord.x * a_texCoord.y) * point[2]; | 244 pos.xy += (a_texCoord.x * a_texCoord.y) * point[2]; |
| 236 pos.xy += (complement.x * a_texCoord.y) * point[3]; | 245 pos.xy += (complement.x * a_texCoord.y) * point[3]; |
| 237 gl_Position = matrix * pos; | 246 gl_Position = matrix * pos; |
| 238 v_texCoord = (pos.xy + vec2(0.5)) * texScale; | 247 v_texCoord = (pos.xy + vec2(0.5)) * texScale; |
| 239 } | 248 } |
| 240 ); | 249 ); |
| 241 } | 250 } |
| 242 | 251 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 260 | 269 |
| 261 m_matrixLocation = locations[0]; | 270 m_matrixLocation = locations[0]; |
| 262 m_pointLocation = locations[1]; | 271 m_pointLocation = locations[1]; |
| 263 m_vertexTexTransformLocation = locations[2]; | 272 m_vertexTexTransformLocation = locations[2]; |
| 264 DCHECK(m_matrixLocation != -1 && m_pointLocation != -1 && m_vertexTexTransfo rmLocation != -1); | 273 DCHECK(m_matrixLocation != -1 && m_pointLocation != -1 && m_vertexTexTransfo rmLocation != -1); |
| 265 } | 274 } |
| 266 | 275 |
| 267 std::string VertexShaderTile::getShaderString() const | 276 std::string VertexShaderTile::getShaderString() const |
| 268 { | 277 { |
| 269 return SHADER( | 278 return SHADER( |
| 270 attribute vec4 a_position; | 279 attribute TexCoordPrecision vec4 a_position; |
| 271 attribute vec2 a_texCoord; | 280 attribute TexCoordPrecision vec2 a_texCoord; |
| 272 uniform mat4 matrix; | 281 uniform mat4 matrix; |
| 273 uniform vec2 point[4]; | 282 uniform TexCoordPrecision vec2 point[4]; |
| 274 uniform vec4 vertexTexTransform; | 283 uniform TexCoordPrecision vec4 vertexTexTransform; |
| 275 varying vec2 v_texCoord; | 284 varying TexCoordPrecision vec2 v_texCoord; |
| 276 void main() | 285 void main() |
| 277 { | 286 { |
| 278 vec2 complement = abs(a_texCoord - 1.0); | 287 vec2 complement = abs(a_texCoord - 1.0); |
| 279 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w); | 288 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w); |
| 280 pos.xy += (complement.x * complement.y) * point[0]; | 289 pos.xy += (complement.x * complement.y) * point[0]; |
| 281 pos.xy += (a_texCoord.x * complement.y) * point[1]; | 290 pos.xy += (a_texCoord.x * complement.y) * point[1]; |
| 282 pos.xy += (a_texCoord.x * a_texCoord.y) * point[2]; | 291 pos.xy += (a_texCoord.x * a_texCoord.y) * point[2]; |
| 283 pos.xy += (complement.x * a_texCoord.y) * point[3]; | 292 pos.xy += (complement.x * a_texCoord.y) * point[3]; |
| 284 gl_Position = matrix * pos; | 293 gl_Position = matrix * pos; |
| 285 v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy; | 294 v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 305 | 314 |
| 306 m_matrixLocation = locations[0]; | 315 m_matrixLocation = locations[0]; |
| 307 m_texMatrixLocation = locations[1]; | 316 m_texMatrixLocation = locations[1]; |
| 308 return m_matrixLocation != -1 && m_texMatrixLocation != -1; | 317 return m_matrixLocation != -1 && m_texMatrixLocation != -1; |
| 309 } | 318 } |
| 310 | 319 |
| 311 std::string VertexShaderVideoTransform::getShaderString() const | 320 std::string VertexShaderVideoTransform::getShaderString() const |
| 312 { | 321 { |
| 313 return SHADER( | 322 return SHADER( |
| 314 attribute vec4 a_position; | 323 attribute vec4 a_position; |
| 315 attribute vec2 a_texCoord; | 324 attribute TexCoordPrecision vec2 a_texCoord; |
| 316 uniform mat4 matrix; | 325 uniform mat4 matrix; |
| 317 uniform mat4 texMatrix; | 326 uniform TexCoordPrecision mat4 texMatrix; |
| 318 varying vec2 v_texCoord; | 327 varying TexCoordPrecision vec2 v_texCoord; |
| 319 void main() | 328 void main() |
| 320 { | 329 { |
| 321 gl_Position = matrix * a_position; | 330 gl_Position = matrix * a_position; |
| 322 v_texCoord = vec2(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)); | 331 v_texCoord = vec2(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)); |
| 323 } | 332 } |
| 324 ); | 333 ); |
| 325 } | 334 } |
| 326 | 335 |
| 327 FragmentTexAlphaBinding::FragmentTexAlphaBinding() | 336 FragmentTexAlphaBinding::FragmentTexAlphaBinding() |
| 328 : m_samplerLocation(-1) | 337 : m_samplerLocation(-1) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; | 369 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; |
| 361 | 370 |
| 362 m_samplerLocation = locations[0]; | 371 m_samplerLocation = locations[0]; |
| 363 DCHECK(m_samplerLocation != -1); | 372 DCHECK(m_samplerLocation != -1); |
| 364 } | 373 } |
| 365 | 374 |
| 366 std::string FragmentShaderRGBATexFlipVaryingAlpha::getShaderString() const | 375 std::string FragmentShaderRGBATexFlipVaryingAlpha::getShaderString() const |
| 367 { | 376 { |
| 368 return SHADER( | 377 return SHADER( |
| 369 precision mediump float; | 378 precision mediump float; |
| 370 varying vec2 v_texCoord; | 379 varying TexCoordPrecision vec2 v_texCoord; |
| 371 varying float v_alpha; | 380 varying float v_alpha; |
| 372 uniform sampler2D s_texture; | 381 uniform sampler2D s_texture; |
| 373 void main() | 382 void main() |
| 374 { | 383 { |
| 375 vec4 texColor = texture2D(s_texture, vec2(v_texCoord.x, 1.0 - v_texC oord.y)); | 384 vec4 texColor = texture2D(s_texture, vec2(v_texCoord.x, 1.0 - v_texC oord.y)); |
| 376 gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * v_alpha; | 385 gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * v_alpha; |
| 377 } | 386 } |
| 378 ); | 387 ); |
| 379 } | 388 } |
| 380 | 389 |
| 381 bool FragmentShaderOESImageExternal::init(WebGraphicsContext3D* context, unsigne d program, bool usingBindUniform, int* baseUniformIndex) | 390 bool FragmentShaderOESImageExternal::init(WebGraphicsContext3D* context, unsigne d program, bool usingBindUniform, int* baseUniformIndex) |
| 382 { | 391 { |
| 383 static const char* shaderUniforms[] = { | 392 static const char* shaderUniforms[] = { |
| 384 "s_texture", | 393 "s_texture", |
| 385 }; | 394 }; |
| 386 int locations[1]; | 395 int locations[1]; |
| 387 | 396 |
| 388 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; | 397 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; |
| 389 | 398 |
| 390 m_samplerLocation = locations[0]; | 399 m_samplerLocation = locations[0]; |
| 391 return m_samplerLocation != -1; | 400 return m_samplerLocation != -1; |
| 392 } | 401 } |
| 393 | 402 |
| 394 std::string FragmentShaderOESImageExternal::getShaderString() const | 403 std::string FragmentShaderOESImageExternal::getShaderString() const |
| 395 { | 404 { |
| 396 // Cannot use the SHADER() macro because of the '#' char | 405 // Cannot use the SHADER() macro because of the '#' char |
| 397 return "#extension GL_OES_EGL_image_external : require \n" | 406 return fixShader( |
| 407 "#extension GL_OES_EGL_image_external : require \n" | |
| 398 "precision mediump float;\n" | 408 "precision mediump float;\n" |
| 399 "varying vec2 v_texCoord;\n" | 409 "varying TexCoordPrecision vec2 v_texCoord;\n" |
| 400 "uniform samplerExternalOES s_texture;\n" | 410 "uniform samplerExternalOES s_texture;\n" |
| 401 "void main()\n" | 411 "void main()\n" |
| 402 "{\n" | 412 "{\n" |
| 403 " vec4 texColor = texture2D(s_texture, v_texCoord);\n" | 413 " vec4 texColor = texture2D(s_texture, v_texCoord);\n" |
| 404 " gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor .w);\n" | 414 " gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor .w);\n" |
| 405 "}\n"; | 415 "}\n"); |
| 406 } | 416 } |
| 407 | 417 |
| 408 std::string FragmentShaderRGBATexAlpha::getShaderString() const | 418 std::string FragmentShaderRGBATexAlpha::getShaderString() const |
| 409 { | 419 { |
| 410 return SHADER( | 420 return SHADER( |
| 411 precision mediump float; | 421 precision mediump float; |
| 412 varying vec2 v_texCoord; | 422 varying TexCoordPrecision vec2 v_texCoord; |
| 413 uniform sampler2D s_texture; | 423 uniform sampler2D s_texture; |
| 414 uniform float alpha; | 424 uniform float alpha; |
| 415 void main() | 425 void main() |
| 416 { | 426 { |
| 417 vec4 texColor = texture2D(s_texture, v_texCoord); | 427 vec4 texColor = texture2D(s_texture, v_texCoord); |
| 418 gl_FragColor = texColor * alpha; | 428 gl_FragColor = texColor * alpha; |
| 419 } | 429 } |
| 420 ); | 430 ); |
| 421 } | 431 } |
| 422 | 432 |
| 423 std::string FragmentShaderRGBATexVaryingAlpha::getShaderString() const | 433 std::string FragmentShaderRGBATexVaryingAlpha::getShaderString() const |
| 424 { | 434 { |
| 425 return SHADER( | 435 return SHADER( |
| 426 precision mediump float; | 436 precision mediump float; |
| 427 varying vec2 v_texCoord; | 437 varying TexCoordPrecision vec2 v_texCoord; |
| 428 varying float v_alpha; | 438 varying float v_alpha; |
| 429 uniform sampler2D s_texture; | 439 uniform sampler2D s_texture; |
| 430 void main() | 440 void main() |
| 431 { | 441 { |
| 432 vec4 texColor = texture2D(s_texture, v_texCoord); | 442 vec4 texColor = texture2D(s_texture, v_texCoord); |
| 433 gl_FragColor = texColor * v_alpha; | 443 gl_FragColor = texColor * v_alpha; |
| 434 } | 444 } |
| 435 ); | 445 ); |
| 436 } | 446 } |
| 437 | 447 |
| 438 std::string FragmentShaderRGBATexRectFlipVaryingAlpha::getShaderString() const | 448 std::string FragmentShaderRGBATexRectFlipVaryingAlpha::getShaderString() const |
| 439 { | 449 { |
| 440 // This must be paired with VertexShaderPosTexTransform to pick up the texTr ansform uniform. | 450 // This must be paired with VertexShaderPosTexTransform to pick up the texTr ansform uniform. |
| 441 // The necessary #extension preprocessing directive breaks the SHADER and SH ADER0 macros. | 451 // The necessary #extension preprocessing directive breaks the SHADER and SH ADER0 macros. |
| 442 return "#extension GL_ARB_texture_rectangle : require\n" | 452 return fixShader( |
| 453 "#extension GL_ARB_texture_rectangle : require\n" | |
| 443 "precision mediump float;\n" | 454 "precision mediump float;\n" |
| 444 "varying vec2 v_texCoord;\n" | 455 "varying TexCoordPrecision vec2 v_texCoord;\n" |
| 445 "varying float v_alpha;\n" | 456 "varying float v_alpha;\n" |
| 446 "uniform vec4 texTransform;\n" | 457 "uniform TexCoordPrecision vec4 texTransform;\n" |
| 447 "uniform sampler2DRect s_texture;\n" | 458 "uniform sampler2DRect s_texture;\n" |
| 448 "void main()\n" | 459 "void main()\n" |
| 449 "{\n" | 460 "{\n" |
| 450 " vec4 texColor = texture2DRect(s_texture, vec2(v_texCoord.x, tex Transform.w - v_texCoord.y));\n" | 461 " vec4 texColor = texture2DRect(s_texture, vec2(v_texCoord.x, tex Transform.w - v_texCoord.y));\n" |
| 451 " gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColo r.w) * v_alpha;\n" | 462 " gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColo r.w) * v_alpha;\n" |
| 452 "}\n"; | 463 "}\n"); |
| 453 } | 464 } |
| 454 | 465 |
| 455 std::string FragmentShaderRGBATexRectVaryingAlpha::getShaderString() const | 466 std::string FragmentShaderRGBATexRectVaryingAlpha::getShaderString() const |
| 456 { | 467 { |
| 457 return "#extension GL_ARB_texture_rectangle : require\n" | 468 return fixShader( |
| 469 "#extension GL_ARB_texture_rectangle : require\n" | |
| 458 "precision mediump float;\n" | 470 "precision mediump float;\n" |
| 459 "varying vec2 v_texCoord;\n" | 471 "varying TexCoordPrecision vec2 v_texCoord;\n" |
| 460 "varying float v_alpha;\n" | 472 "varying float v_alpha;\n" |
| 461 "uniform sampler2DRect s_texture;\n" | 473 "uniform sampler2DRect s_texture;\n" |
| 462 "void main()\n" | 474 "void main()\n" |
| 463 "{\n" | 475 "{\n" |
| 464 " vec4 texColor = texture2DRect(s_texture, v_texCoord);\n" | 476 " vec4 texColor = texture2DRect(s_texture, v_texCoord);\n" |
| 465 " gl_FragColor = texColor * v_alpha;\n" | 477 " gl_FragColor = texColor * v_alpha;\n" |
| 466 "}\n"; | 478 "}\n"); |
| 467 } | 479 } |
| 468 | 480 |
| 469 std::string FragmentShaderRGBATexOpaque::getShaderString() const | 481 std::string FragmentShaderRGBATexOpaque::getShaderString() const |
| 470 { | 482 { |
| 471 return SHADER( | 483 return SHADER( |
| 472 precision mediump float; | 484 precision mediump float; |
| 473 varying vec2 v_texCoord; | 485 varying TexCoordPrecision vec2 v_texCoord; |
| 474 uniform sampler2D s_texture; | 486 uniform sampler2D s_texture; |
| 475 void main() | 487 void main() |
| 476 { | 488 { |
| 477 vec4 texColor = texture2D(s_texture, v_texCoord); | 489 vec4 texColor = texture2D(s_texture, v_texCoord); |
| 478 gl_FragColor = vec4(texColor.rgb, 1.0); | 490 gl_FragColor = vec4(texColor.rgb, 1.0); |
| 479 } | 491 } |
| 480 ); | 492 ); |
| 481 } | 493 } |
| 482 | 494 |
| 483 std::string FragmentShaderRGBATex::getShaderString() const | 495 std::string FragmentShaderRGBATex::getShaderString() const |
| 484 { | 496 { |
| 485 return SHADER( | 497 return SHADER( |
| 486 precision mediump float; | 498 precision mediump float; |
| 487 varying vec2 v_texCoord; | 499 varying TexCoordPrecision vec2 v_texCoord; |
| 488 uniform sampler2D s_texture; | 500 uniform sampler2D s_texture; |
| 489 void main() | 501 void main() |
| 490 { | 502 { |
| 491 gl_FragColor = texture2D(s_texture, v_texCoord); | 503 gl_FragColor = texture2D(s_texture, v_texCoord); |
| 492 } | 504 } |
| 493 ); | 505 ); |
| 494 } | 506 } |
| 495 | 507 |
| 496 std::string FragmentShaderRGBATexSwizzleAlpha::getShaderString() const | 508 std::string FragmentShaderRGBATexSwizzleAlpha::getShaderString() const |
| 497 { | 509 { |
| 498 return SHADER( | 510 return SHADER( |
| 499 precision mediump float; | 511 precision mediump float; |
| 500 varying vec2 v_texCoord; | 512 varying TexCoordPrecision vec2 v_texCoord; |
| 501 uniform sampler2D s_texture; | 513 uniform sampler2D s_texture; |
| 502 uniform float alpha; | 514 uniform float alpha; |
| 503 void main() | 515 void main() |
| 504 { | 516 { |
| 505 vec4 texColor = texture2D(s_texture, v_texCoord); | 517 vec4 texColor = texture2D(s_texture, v_texCoord); |
| 506 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, texColor.w) * alpha; | 518 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, texColor.w) * alpha; |
| 507 } | 519 } |
| 508 ); | 520 ); |
| 509 } | 521 } |
| 510 | 522 |
| 511 std::string FragmentShaderRGBATexSwizzleOpaque::getShaderString() const | 523 std::string FragmentShaderRGBATexSwizzleOpaque::getShaderString() const |
| 512 { | 524 { |
| 513 return SHADER( | 525 return SHADER( |
| 514 precision mediump float; | 526 precision mediump float; |
| 515 varying vec2 v_texCoord; | 527 varying TexCoordPrecision vec2 v_texCoord; |
| 516 uniform sampler2D s_texture; | 528 uniform sampler2D s_texture; |
| 517 void main() | 529 void main() |
| 518 { | 530 { |
| 519 vec4 texColor = texture2D(s_texture, v_texCoord); | 531 vec4 texColor = texture2D(s_texture, v_texCoord); |
| 520 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, 1.0); | 532 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, 1.0); |
| 521 } | 533 } |
| 522 ); | 534 ); |
| 523 } | 535 } |
| 524 | 536 |
| 525 FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA() | 537 FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA() |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 543 m_samplerLocation = locations[0]; | 555 m_samplerLocation = locations[0]; |
| 544 m_alphaLocation = locations[1]; | 556 m_alphaLocation = locations[1]; |
| 545 m_edgeLocation = locations[2]; | 557 m_edgeLocation = locations[2]; |
| 546 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation != -1); | 558 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation != -1); |
| 547 } | 559 } |
| 548 | 560 |
| 549 std::string FragmentShaderRGBATexAlphaAA::getShaderString() const | 561 std::string FragmentShaderRGBATexAlphaAA::getShaderString() const |
| 550 { | 562 { |
| 551 return SHADER( | 563 return SHADER( |
| 552 precision mediump float; | 564 precision mediump float; |
| 553 varying vec2 v_texCoord; | 565 varying TexCoordPrecision vec2 v_texCoord; |
| 554 uniform sampler2D s_texture; | 566 uniform sampler2D s_texture; |
| 555 uniform float alpha; | 567 uniform float alpha; |
| 556 uniform vec3 edge[8]; | 568 uniform vec3 edge[8]; |
| 557 void main() | 569 void main() |
| 558 { | 570 { |
| 559 vec4 texColor = texture2D(s_texture, v_texCoord); | 571 vec4 texColor = texture2D(s_texture, v_texCoord); |
| 560 vec3 pos = vec3(gl_FragCoord.xy, 1); | 572 vec3 pos = vec3(gl_FragCoord.xy, 1); |
| 561 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); | 573 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); |
| 562 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); | 574 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); |
| 563 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); | 575 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 m_alphaLocation = locations[1]; | 607 m_alphaLocation = locations[1]; |
| 596 m_fragmentTexTransformLocation = locations[2]; | 608 m_fragmentTexTransformLocation = locations[2]; |
| 597 m_edgeLocation = locations[3]; | 609 m_edgeLocation = locations[3]; |
| 598 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_fragmentTexTran sformLocation != -1 && m_edgeLocation != -1); | 610 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_fragmentTexTran sformLocation != -1 && m_edgeLocation != -1); |
| 599 } | 611 } |
| 600 | 612 |
| 601 std::string FragmentShaderRGBATexClampAlphaAA::getShaderString() const | 613 std::string FragmentShaderRGBATexClampAlphaAA::getShaderString() const |
| 602 { | 614 { |
| 603 return SHADER( | 615 return SHADER( |
| 604 precision mediump float; | 616 precision mediump float; |
| 605 varying vec2 v_texCoord; | 617 varying TexCoordPrecision vec2 v_texCoord; |
| 606 uniform sampler2D s_texture; | 618 uniform sampler2D s_texture; |
| 607 uniform float alpha; | 619 uniform float alpha; |
| 608 uniform vec4 fragmentTexTransform; | 620 uniform TexCoordPrecision vec4 fragmentTexTransform; |
| 609 uniform vec3 edge[8]; | 621 uniform vec3 edge[8]; |
| 610 void main() | 622 void main() |
| 611 { | 623 { |
| 612 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.z w + fragmentTexTransform.xy; | 624 TexCoordPrecision vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * frag mentTexTransform.zw + fragmentTexTransform.xy; |
| 613 vec4 texColor = texture2D(s_texture, texCoord); | 625 vec4 texColor = texture2D(s_texture, texCoord); |
| 614 vec3 pos = vec3(gl_FragCoord.xy, 1); | 626 vec3 pos = vec3(gl_FragCoord.xy, 1); |
| 615 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); | 627 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); |
| 616 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); | 628 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); |
| 617 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); | 629 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); |
| 618 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); | 630 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); |
| 619 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); | 631 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); |
| 620 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); | 632 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); |
| 621 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); | 633 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); |
| 622 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); | 634 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); |
| 623 gl_FragColor = texColor * alpha * min(min(a0, a2) * min(a1, a3), min (a4, a6) * min(a5, a7)); | 635 gl_FragColor = texColor * alpha * min(min(a0, a2) * min(a1, a3), min (a4, a6) * min(a5, a7)); |
| 624 } | 636 } |
| 625 ); | 637 ); |
| 626 } | 638 } |
| 627 | 639 |
| 628 std::string FragmentShaderRGBATexClampSwizzleAlphaAA::getShaderString() const | 640 std::string FragmentShaderRGBATexClampSwizzleAlphaAA::getShaderString() const |
| 629 { | 641 { |
| 630 return SHADER( | 642 return SHADER( |
| 631 precision mediump float; | 643 precision mediump float; |
| 632 varying vec2 v_texCoord; | 644 varying TexCoordPrecision vec2 v_texCoord; |
| 633 uniform sampler2D s_texture; | 645 uniform sampler2D s_texture; |
| 634 uniform float alpha; | 646 uniform float alpha; |
| 635 uniform vec4 fragmentTexTransform; | 647 uniform TexCoordPrecision vec4 fragmentTexTransform; |
| 636 uniform vec3 edge[8]; | 648 uniform vec3 edge[8]; |
| 637 void main() | 649 void main() |
| 638 { | 650 { |
| 639 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.z w + fragmentTexTransform.xy; | 651 TexCoordPrecision vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * frag mentTexTransform.zw + fragmentTexTransform.xy; |
| 640 vec4 texColor = texture2D(s_texture, texCoord); | 652 vec4 texColor = texture2D(s_texture, texCoord); |
| 641 vec3 pos = vec3(gl_FragCoord.xy, 1); | 653 vec3 pos = vec3(gl_FragCoord.xy, 1); |
| 642 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); | 654 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); |
| 643 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); | 655 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); |
| 644 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); | 656 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); |
| 645 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); | 657 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); |
| 646 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); | 658 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); |
| 647 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); | 659 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); |
| 648 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); | 660 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); |
| 649 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); | 661 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 678 m_alphaLocation = locations[2]; | 690 m_alphaLocation = locations[2]; |
| 679 m_maskTexCoordScaleLocation = locations[3]; | 691 m_maskTexCoordScaleLocation = locations[3]; |
| 680 m_maskTexCoordOffsetLocation = locations[4]; | 692 m_maskTexCoordOffsetLocation = locations[4]; |
| 681 DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca tion != -1); | 693 DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca tion != -1); |
| 682 } | 694 } |
| 683 | 695 |
| 684 std::string FragmentShaderRGBATexAlphaMask::getShaderString() const | 696 std::string FragmentShaderRGBATexAlphaMask::getShaderString() const |
| 685 { | 697 { |
| 686 return SHADER( | 698 return SHADER( |
| 687 precision mediump float; | 699 precision mediump float; |
| 688 varying vec2 v_texCoord; | 700 varying TexCoordPrecision vec2 v_texCoord; |
| 689 uniform sampler2D s_texture; | 701 uniform sampler2D s_texture; |
| 690 uniform sampler2D s_mask; | 702 uniform sampler2D s_mask; |
| 691 uniform vec2 maskTexCoordScale; | 703 uniform TexCoordPrecision vec2 maskTexCoordScale; |
| 692 uniform vec2 maskTexCoordOffset; | 704 uniform TexCoordPrecision vec2 maskTexCoordOffset; |
| 693 uniform float alpha; | 705 uniform float alpha; |
| 694 void main() | 706 void main() |
| 695 { | 707 { |
| 696 vec4 texColor = texture2D(s_texture, v_texCoord); | 708 vec4 texColor = texture2D(s_texture, v_texCoord); |
| 697 vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskT exCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); | 709 TexCoordPrecision vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_ texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexC oordScale.y); |
| 698 vec4 maskColor = texture2D(s_mask, maskTexCoord); | 710 vec4 maskColor = texture2D(s_mask, maskTexCoord); |
| 699 gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha * maskColor.w; | 711 gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha * maskColor.w; |
| 700 } | 712 } |
| 701 ); | 713 ); |
| 702 } | 714 } |
| 703 | 715 |
| 704 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() | 716 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() |
| 705 : m_samplerLocation(-1) | 717 : m_samplerLocation(-1) |
| 706 , m_maskSamplerLocation(-1) | 718 , m_maskSamplerLocation(-1) |
| 707 , m_alphaLocation(-1) | 719 , m_alphaLocation(-1) |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 730 m_edgeLocation = locations[3]; | 742 m_edgeLocation = locations[3]; |
| 731 m_maskTexCoordScaleLocation = locations[4]; | 743 m_maskTexCoordScaleLocation = locations[4]; |
| 732 m_maskTexCoordOffsetLocation = locations[5]; | 744 m_maskTexCoordOffsetLocation = locations[5]; |
| 733 DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca tion != -1 && m_edgeLocation != -1); | 745 DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca tion != -1 && m_edgeLocation != -1); |
| 734 } | 746 } |
| 735 | 747 |
| 736 std::string FragmentShaderRGBATexAlphaMaskAA::getShaderString() const | 748 std::string FragmentShaderRGBATexAlphaMaskAA::getShaderString() const |
| 737 { | 749 { |
| 738 return SHADER( | 750 return SHADER( |
| 739 precision mediump float; | 751 precision mediump float; |
| 740 varying vec2 v_texCoord; | 752 varying TexCoordPrecision vec2 v_texCoord; |
| 741 uniform sampler2D s_texture; | 753 uniform sampler2D s_texture; |
| 742 uniform sampler2D s_mask; | 754 uniform sampler2D s_mask; |
| 743 uniform vec2 maskTexCoordScale; | 755 uniform TexCoordPrecision vec2 maskTexCoordScale; |
| 744 uniform vec2 maskTexCoordOffset; | 756 uniform TexCoordPrecision vec2 maskTexCoordOffset; |
| 745 uniform float alpha; | 757 uniform float alpha; |
| 746 uniform vec3 edge[8]; | 758 uniform vec3 edge[8]; |
| 747 void main() | 759 void main() |
| 748 { | 760 { |
| 749 vec4 texColor = texture2D(s_texture, v_texCoord); | 761 vec4 texColor = texture2D(s_texture, v_texCoord); |
| 750 vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskT exCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); | 762 TexCoordPrecision vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_ texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexC oordScale.y); |
| 751 vec4 maskColor = texture2D(s_mask, maskTexCoord); | 763 vec4 maskColor = texture2D(s_mask, maskTexCoord); |
| 752 vec3 pos = vec3(gl_FragCoord.xy, 1); | 764 vec3 pos = vec3(gl_FragCoord.xy, 1); |
| 753 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); | 765 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); |
| 754 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); | 766 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); |
| 755 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); | 767 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); |
| 756 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); | 768 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); |
| 757 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); | 769 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); |
| 758 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); | 770 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); |
| 759 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); | 771 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); |
| 760 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); | 772 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 | 808 |
| 797 DCHECK(m_yTextureLocation != -1 && m_uTextureLocation != -1 && m_vTextureLoc ation != -1 | 809 DCHECK(m_yTextureLocation != -1 && m_uTextureLocation != -1 && m_vTextureLoc ation != -1 |
| 798 && m_alphaLocation != -1 && m_yuvMatrixLocation != -1 && m_yuvAdjLoca tion != -1); | 810 && m_alphaLocation != -1 && m_yuvMatrixLocation != -1 && m_yuvAdjLoca tion != -1); |
| 799 } | 811 } |
| 800 | 812 |
| 801 std::string FragmentShaderYUVVideo::getShaderString() const | 813 std::string FragmentShaderYUVVideo::getShaderString() const |
| 802 { | 814 { |
| 803 return SHADER( | 815 return SHADER( |
| 804 precision mediump float; | 816 precision mediump float; |
| 805 precision mediump int; | 817 precision mediump int; |
| 806 varying vec2 v_texCoord; | 818 varying TexCoordPrecision vec2 v_texCoord; |
| 807 uniform sampler2D y_texture; | 819 uniform sampler2D y_texture; |
| 808 uniform sampler2D u_texture; | 820 uniform sampler2D u_texture; |
| 809 uniform sampler2D v_texture; | 821 uniform sampler2D v_texture; |
| 810 uniform float alpha; | 822 uniform float alpha; |
| 811 uniform vec3 yuv_adj; | 823 uniform vec3 yuv_adj; |
| 812 uniform mat3 yuv_matrix; | 824 uniform mat3 yuv_matrix; |
| 813 void main() | 825 void main() |
| 814 { | 826 { |
| 815 float y_raw = texture2D(y_texture, v_texCoord).x; | 827 float y_raw = texture2D(y_texture, v_texCoord).x; |
| 816 float u_unsigned = texture2D(u_texture, v_texCoord).x; | 828 float u_unsigned = texture2D(u_texture, v_texCoord).x; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 DCHECK(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyL ocation != -1 && m_colorLocation != -1); | 890 DCHECK(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyL ocation != -1 && m_colorLocation != -1); |
| 879 } | 891 } |
| 880 | 892 |
| 881 std::string FragmentShaderCheckerboard::getShaderString() const | 893 std::string FragmentShaderCheckerboard::getShaderString() const |
| 882 { | 894 { |
| 883 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" | 895 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" |
| 884 // by Munshi, Ginsburg, Shreiner. | 896 // by Munshi, Ginsburg, Shreiner. |
| 885 return SHADER( | 897 return SHADER( |
| 886 precision mediump float; | 898 precision mediump float; |
| 887 precision mediump int; | 899 precision mediump int; |
| 888 varying vec2 v_texCoord; | 900 varying TexCoordPrecision vec2 v_texCoord; |
| 889 uniform float alpha; | 901 uniform float alpha; |
| 890 uniform float frequency; | 902 uniform float frequency; |
| 891 uniform vec4 texTransform; | 903 uniform vec4 texTransform; |
| 892 uniform vec4 color; | 904 uniform vec4 color; |
| 893 void main() | 905 void main() |
| 894 { | 906 { |
| 895 vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0); | 907 vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0); |
| 896 vec4 color2 = color; | 908 vec4 color2 = color; |
| 897 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT ransform.xy; | 909 TexCoordPrecision vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texT ransform.zw + texTransform.xy; |
| 898 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); | 910 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
| 899 float picker = abs(coord.x - coord.y); | 911 float picker = abs(coord.x - coord.y); |
| 900 gl_FragColor = mix(color1, color2, picker) * alpha; | 912 gl_FragColor = mix(color1, color2, picker) * alpha; |
| 901 } | 913 } |
| 902 ); | 914 ); |
| 903 } | 915 } |
| 904 | 916 |
| 905 } // namespace cc | 917 } // namespace cc |
| OLD | NEW |