| 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/output/shader.h" | 5 #include "cc/output/shader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "cc/output/gl_renderer.h" // For the GLC() macro. | 11 #include "cc/output/gl_renderer.h" // For the GLC() macro. |
| 12 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 12 #include "gpu/command_buffer/client/gles2_interface.h" |
| 13 #include "third_party/khronos/GLES2/gl2.h" | 13 #include "third_party/khronos/GLES2/gl2.h" |
| 14 | 14 |
| 15 #define SHADER0(Src) #Src | 15 #define SHADER0(Src) #Src |
| 16 #define VERTEX_SHADER(Src) SetVertexTexCoordPrecision(SHADER0(Src)) | 16 #define VERTEX_SHADER(Src) SetVertexTexCoordPrecision(SHADER0(Src)) |
| 17 #define FRAGMENT_SHADER(Src) SetFragmentTexCoordPrecision( \ | 17 #define FRAGMENT_SHADER(Src) SetFragmentTexCoordPrecision( \ |
| 18 precision, SetFragmentSamplerType(sampler, SHADER0(Src))) | 18 precision, SetFragmentSamplerType(sampler, SHADER0(Src))) |
| 19 | 19 |
| 20 using blink::WebGraphicsContext3D; | 20 using gpu::gles2::GLES2Interface; |
| 21 | 21 |
| 22 namespace cc { | 22 namespace cc { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 static void GetProgramUniformLocations(WebGraphicsContext3D* context, | 26 static void GetProgramUniformLocations(GLES2Interface* context, |
| 27 unsigned program, | 27 unsigned program, |
| 28 size_t count, | 28 size_t count, |
| 29 const char** uniforms, | 29 const char** uniforms, |
| 30 int* locations, | 30 int* locations, |
| 31 int* base_uniform_index) { | 31 int* base_uniform_index) { |
| 32 for (size_t i = 0; i < count; i++) { | 32 for (size_t i = 0; i < count; i++) { |
| 33 locations[i] = (*base_uniform_index)++; | 33 locations[i] = (*base_uniform_index)++; |
| 34 context->bindUniformLocationCHROMIUM(program, locations[i], uniforms[i]); | 34 context->BindUniformLocationCHROMIUM(program, locations[i], uniforms[i]); |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 static std::string SetFragmentTexCoordPrecision( | 38 static std::string SetFragmentTexCoordPrecision( |
| 39 TexCoordPrecision requested_precision, std::string shader_string) { | 39 TexCoordPrecision requested_precision, std::string shader_string) { |
| 40 switch (requested_precision) { | 40 switch (requested_precision) { |
| 41 case TexCoordPrecisionHigh: | 41 case TexCoordPrecisionHigh: |
| 42 DCHECK_NE(shader_string.find("TexCoordPrecision"), std::string::npos); | 42 DCHECK_NE(shader_string.find("TexCoordPrecision"), std::string::npos); |
| 43 return | 43 return |
| 44 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" | 44 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 65 | 65 |
| 66 static std::string SetVertexTexCoordPrecision(const char* shader_string) { | 66 static std::string SetVertexTexCoordPrecision(const char* shader_string) { |
| 67 // We unconditionally use highp in the vertex shader since | 67 // We unconditionally use highp in the vertex shader since |
| 68 // we are unlikely to be vertex shader bound when drawing large quads. | 68 // we are unlikely to be vertex shader bound when drawing large quads. |
| 69 // Also, some vertex shaders mutate the texture coordinate in such a | 69 // Also, some vertex shaders mutate the texture coordinate in such a |
| 70 // way that the effective precision might be lower than expected. | 70 // way that the effective precision might be lower than expected. |
| 71 return "#define TexCoordPrecision highp\n" + | 71 return "#define TexCoordPrecision highp\n" + |
| 72 std::string(shader_string); | 72 std::string(shader_string); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context, | 75 TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context, |
| 76 int *highp_threshold_cache, | 76 int *highp_threshold_cache, |
| 77 int highp_threshold_min, | 77 int highp_threshold_min, |
| 78 int x, int y) { | 78 int x, int y) { |
| 79 if (*highp_threshold_cache == 0) { | 79 if (*highp_threshold_cache == 0) { |
| 80 // Initialize range and precision with minimum spec values for when | 80 // Initialize range and precision with minimum spec values for when |
| 81 // GetShaderPrecisionFormat is a test stub. | 81 // GetShaderPrecisionFormat is a test stub. |
| 82 // TODO(brianderson): Implement better stubs of GetShaderPrecisionFormat | 82 // TODO(brianderson): Implement better stubs of GetShaderPrecisionFormat |
| 83 // everywhere. | 83 // everywhere. |
| 84 GLint range[2] = { 14, 14 }; | 84 GLint range[2] = { 14, 14 }; |
| 85 GLint precision = 10; | 85 GLint precision = 10; |
| 86 GLC(context, context->getShaderPrecisionFormat(GL_FRAGMENT_SHADER, | 86 GLC(context, context->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, |
| 87 GL_MEDIUM_FLOAT, | 87 GL_MEDIUM_FLOAT, |
| 88 range, &precision)); | 88 range, &precision)); |
| 89 *highp_threshold_cache = 1 << precision; | 89 *highp_threshold_cache = 1 << precision; |
| 90 } | 90 } |
| 91 | 91 |
| 92 int highp_threshold = std::max(*highp_threshold_cache, highp_threshold_min); | 92 int highp_threshold = std::max(*highp_threshold_cache, highp_threshold_min); |
| 93 if (x > highp_threshold || y > highp_threshold) | 93 if (x > highp_threshold || y > highp_threshold) |
| 94 return TexCoordPrecisionHigh; | 94 return TexCoordPrecisionHigh; |
| 95 return TexCoordPrecisionMedium; | 95 return TexCoordPrecisionMedium; |
| 96 } | 96 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 127 return shader_string; | 127 return shader_string; |
| 128 default: | 128 default: |
| 129 NOTREACHED(); | 129 NOTREACHED(); |
| 130 break; | 130 break; |
| 131 } | 131 } |
| 132 return shader_string; | 132 return shader_string; |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace | 135 } // namespace |
| 136 | 136 |
| 137 TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context, | 137 TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context, |
| 138 int *highp_threshold_cache, | 138 int *highp_threshold_cache, |
| 139 int highp_threshold_min, | 139 int highp_threshold_min, |
| 140 gfx::Point max_coordinate) { | 140 gfx::Point max_coordinate) { |
| 141 return TexCoordPrecisionRequired(context, | 141 return TexCoordPrecisionRequired(context, |
| 142 highp_threshold_cache, highp_threshold_min, | 142 highp_threshold_cache, highp_threshold_min, |
| 143 max_coordinate.x(), max_coordinate.y()); | 143 max_coordinate.x(), max_coordinate.y()); |
| 144 } | 144 } |
| 145 | 145 |
| 146 TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context, | 146 TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context, |
| 147 int *highp_threshold_cache, | 147 int *highp_threshold_cache, |
| 148 int highp_threshold_min, | 148 int highp_threshold_min, |
| 149 gfx::Size max_size) { | 149 gfx::Size max_size) { |
| 150 return TexCoordPrecisionRequired(context, | 150 return TexCoordPrecisionRequired(context, |
| 151 highp_threshold_cache, highp_threshold_min, | 151 highp_threshold_cache, highp_threshold_min, |
| 152 max_size.width(), max_size.height()); | 152 max_size.width(), max_size.height()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 VertexShaderPosTex::VertexShaderPosTex() | 155 VertexShaderPosTex::VertexShaderPosTex() |
| 156 : matrix_location_(-1) {} | 156 : matrix_location_(-1) {} |
| 157 | 157 |
| 158 void VertexShaderPosTex::Init(WebGraphicsContext3D* context, | 158 void VertexShaderPosTex::Init(GLES2Interface* context, |
| 159 unsigned program, | 159 unsigned program, |
| 160 int* base_uniform_index) { | 160 int* base_uniform_index) { |
| 161 static const char* uniforms[] = { | 161 static const char* uniforms[] = { |
| 162 "matrix", | 162 "matrix", |
| 163 }; | 163 }; |
| 164 int locations[arraysize(uniforms)]; | 164 int locations[arraysize(uniforms)]; |
| 165 | 165 |
| 166 GetProgramUniformLocations(context, | 166 GetProgramUniformLocations(context, |
| 167 program, | 167 program, |
| 168 arraysize(uniforms), | 168 arraysize(uniforms), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 182 gl_Position = matrix * a_position; | 182 gl_Position = matrix * a_position; |
| 183 v_texCoord = a_texCoord; | 183 v_texCoord = a_texCoord; |
| 184 } | 184 } |
| 185 ); // NOLINT(whitespace/parens) | 185 ); // NOLINT(whitespace/parens) |
| 186 } | 186 } |
| 187 | 187 |
| 188 VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() | 188 VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() |
| 189 : matrix_location_(-1), | 189 : matrix_location_(-1), |
| 190 tex_scale_location_(-1) {} | 190 tex_scale_location_(-1) {} |
| 191 | 191 |
| 192 void VertexShaderPosTexYUVStretch::Init(WebGraphicsContext3D* context, | 192 void VertexShaderPosTexYUVStretch::Init(GLES2Interface* context, |
| 193 unsigned program, | 193 unsigned program, |
| 194 int* base_uniform_index) { | 194 int* base_uniform_index) { |
| 195 static const char* uniforms[] = { | 195 static const char* uniforms[] = { |
| 196 "matrix", | 196 "matrix", |
| 197 "texScale", | 197 "texScale", |
| 198 }; | 198 }; |
| 199 int locations[arraysize(uniforms)]; | 199 int locations[arraysize(uniforms)]; |
| 200 | 200 |
| 201 GetProgramUniformLocations(context, | 201 GetProgramUniformLocations(context, |
| 202 program, | 202 program, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 219 void main() { | 219 void main() { |
| 220 gl_Position = matrix * a_position; | 220 gl_Position = matrix * a_position; |
| 221 v_texCoord = a_texCoord * texScale; | 221 v_texCoord = a_texCoord * texScale; |
| 222 } | 222 } |
| 223 ); // NOLINT(whitespace/parens) | 223 ); // NOLINT(whitespace/parens) |
| 224 } | 224 } |
| 225 | 225 |
| 226 VertexShaderPos::VertexShaderPos() | 226 VertexShaderPos::VertexShaderPos() |
| 227 : matrix_location_(-1) {} | 227 : matrix_location_(-1) {} |
| 228 | 228 |
| 229 void VertexShaderPos::Init(WebGraphicsContext3D* context, | 229 void VertexShaderPos::Init(GLES2Interface* context, |
| 230 unsigned program, | 230 unsigned program, |
| 231 int* base_uniform_index) { | 231 int* base_uniform_index) { |
| 232 static const char* uniforms[] = { | 232 static const char* uniforms[] = { |
| 233 "matrix", | 233 "matrix", |
| 234 }; | 234 }; |
| 235 int locations[arraysize(uniforms)]; | 235 int locations[arraysize(uniforms)]; |
| 236 | 236 |
| 237 GetProgramUniformLocations(context, | 237 GetProgramUniformLocations(context, |
| 238 program, | 238 program, |
| 239 arraysize(uniforms), | 239 arraysize(uniforms), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 251 gl_Position = matrix * a_position; | 251 gl_Position = matrix * a_position; |
| 252 } | 252 } |
| 253 ); // NOLINT(whitespace/parens) | 253 ); // NOLINT(whitespace/parens) |
| 254 } | 254 } |
| 255 | 255 |
| 256 VertexShaderPosTexTransform::VertexShaderPosTexTransform() | 256 VertexShaderPosTexTransform::VertexShaderPosTexTransform() |
| 257 : matrix_location_(-1), | 257 : matrix_location_(-1), |
| 258 tex_transform_location_(-1), | 258 tex_transform_location_(-1), |
| 259 vertex_opacity_location_(-1) {} | 259 vertex_opacity_location_(-1) {} |
| 260 | 260 |
| 261 void VertexShaderPosTexTransform::Init(WebGraphicsContext3D* context, | 261 void VertexShaderPosTexTransform::Init(GLES2Interface* context, |
| 262 unsigned program, | 262 unsigned program, |
| 263 int* base_uniform_index) { | 263 int* base_uniform_index) { |
| 264 static const char* uniforms[] = { | 264 static const char* uniforms[] = { |
| 265 "matrix", | 265 "matrix", |
| 266 "texTransform", | 266 "texTransform", |
| 267 "opacity", | 267 "opacity", |
| 268 }; | 268 }; |
| 269 int locations[arraysize(uniforms)]; | 269 int locations[arraysize(uniforms)]; |
| 270 | 270 |
| 271 GetProgramUniformLocations(context, | 271 GetProgramUniformLocations(context, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 gl_Position = a_position; | 307 gl_Position = a_position; |
| 308 v_texCoord = (a_position.xy + vec2(1.0)) * 0.5; | 308 v_texCoord = (a_position.xy + vec2(1.0)) * 0.5; |
| 309 } | 309 } |
| 310 ); // NOLINT(whitespace/parens) | 310 ); // NOLINT(whitespace/parens) |
| 311 } | 311 } |
| 312 | 312 |
| 313 VertexShaderQuad::VertexShaderQuad() | 313 VertexShaderQuad::VertexShaderQuad() |
| 314 : matrix_location_(-1), | 314 : matrix_location_(-1), |
| 315 quad_location_(-1) {} | 315 quad_location_(-1) {} |
| 316 | 316 |
| 317 void VertexShaderQuad::Init(WebGraphicsContext3D* context, | 317 void VertexShaderQuad::Init(GLES2Interface* context, |
| 318 unsigned program, | 318 unsigned program, |
| 319 int* base_uniform_index) { | 319 int* base_uniform_index) { |
| 320 static const char* uniforms[] = { | 320 static const char* uniforms[] = { |
| 321 "matrix", | 321 "matrix", |
| 322 "quad", | 322 "quad", |
| 323 }; | 323 }; |
| 324 int locations[arraysize(uniforms)]; | 324 int locations[arraysize(uniforms)]; |
| 325 | 325 |
| 326 GetProgramUniformLocations(context, | 326 GetProgramUniformLocations(context, |
| 327 program, | 327 program, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 ); // NOLINT(whitespace/parens) | 364 ); // NOLINT(whitespace/parens) |
| 365 #endif | 365 #endif |
| 366 } | 366 } |
| 367 | 367 |
| 368 VertexShaderQuadAA::VertexShaderQuadAA() | 368 VertexShaderQuadAA::VertexShaderQuadAA() |
| 369 : matrix_location_(-1), | 369 : matrix_location_(-1), |
| 370 viewport_location_(-1), | 370 viewport_location_(-1), |
| 371 quad_location_(-1), | 371 quad_location_(-1), |
| 372 edge_location_(-1) {} | 372 edge_location_(-1) {} |
| 373 | 373 |
| 374 void VertexShaderQuadAA::Init(WebGraphicsContext3D* context, | 374 void VertexShaderQuadAA::Init(GLES2Interface* context, |
| 375 unsigned program, | 375 unsigned program, |
| 376 int* base_uniform_index) { | 376 int* base_uniform_index) { |
| 377 static const char* uniforms[] = { | 377 static const char* uniforms[] = { |
| 378 "matrix", | 378 "matrix", |
| 379 "viewport", | 379 "viewport", |
| 380 "quad", | 380 "quad", |
| 381 "edge", | 381 "edge", |
| 382 }; | 382 }; |
| 383 int locations[arraysize(uniforms)]; | 383 int locations[arraysize(uniforms)]; |
| 384 | 384 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 ); // NOLINT(whitespace/parens) | 421 ); // NOLINT(whitespace/parens) |
| 422 } | 422 } |
| 423 | 423 |
| 424 VertexShaderQuadTexTransformAA::VertexShaderQuadTexTransformAA() | 424 VertexShaderQuadTexTransformAA::VertexShaderQuadTexTransformAA() |
| 425 : matrix_location_(-1), | 425 : matrix_location_(-1), |
| 426 viewport_location_(-1), | 426 viewport_location_(-1), |
| 427 quad_location_(-1), | 427 quad_location_(-1), |
| 428 edge_location_(-1), | 428 edge_location_(-1), |
| 429 tex_transform_location_(-1) {} | 429 tex_transform_location_(-1) {} |
| 430 | 430 |
| 431 void VertexShaderQuadTexTransformAA::Init(WebGraphicsContext3D* context, | 431 void VertexShaderQuadTexTransformAA::Init(GLES2Interface* context, |
| 432 unsigned program, | 432 unsigned program, |
| 433 int* base_uniform_index) { | 433 int* base_uniform_index) { |
| 434 static const char* uniforms[] = { | 434 static const char* uniforms[] = { |
| 435 "matrix", | 435 "matrix", |
| 436 "viewport", | 436 "viewport", |
| 437 "quad", | 437 "quad", |
| 438 "edge", | 438 "edge", |
| 439 "texTrans", | 439 "texTrans", |
| 440 }; | 440 }; |
| 441 int locations[arraysize(uniforms)]; | 441 int locations[arraysize(uniforms)]; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 v_texCoord = (pos.xy + vec2(0.5)) * texTrans.zw + texTrans.xy; | 481 v_texCoord = (pos.xy + vec2(0.5)) * texTrans.zw + texTrans.xy; |
| 482 } | 482 } |
| 483 ); // NOLINT(whitespace/parens) | 483 ); // NOLINT(whitespace/parens) |
| 484 } | 484 } |
| 485 | 485 |
| 486 VertexShaderTile::VertexShaderTile() | 486 VertexShaderTile::VertexShaderTile() |
| 487 : matrix_location_(-1), | 487 : matrix_location_(-1), |
| 488 quad_location_(-1), | 488 quad_location_(-1), |
| 489 vertex_tex_transform_location_(-1) {} | 489 vertex_tex_transform_location_(-1) {} |
| 490 | 490 |
| 491 void VertexShaderTile::Init(WebGraphicsContext3D* context, | 491 void VertexShaderTile::Init(GLES2Interface* context, |
| 492 unsigned program, | 492 unsigned program, |
| 493 int* base_uniform_index) { | 493 int* base_uniform_index) { |
| 494 static const char* uniforms[] = { | 494 static const char* uniforms[] = { |
| 495 "matrix", | 495 "matrix", |
| 496 "quad", | 496 "quad", |
| 497 "vertexTexTransform", | 497 "vertexTexTransform", |
| 498 }; | 498 }; |
| 499 int locations[arraysize(uniforms)]; | 499 int locations[arraysize(uniforms)]; |
| 500 | 500 |
| 501 GetProgramUniformLocations(context, | 501 GetProgramUniformLocations(context, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 525 ); // NOLINT(whitespace/parens) | 525 ); // NOLINT(whitespace/parens) |
| 526 } | 526 } |
| 527 | 527 |
| 528 VertexShaderTileAA::VertexShaderTileAA() | 528 VertexShaderTileAA::VertexShaderTileAA() |
| 529 : matrix_location_(-1), | 529 : matrix_location_(-1), |
| 530 viewport_location_(-1), | 530 viewport_location_(-1), |
| 531 quad_location_(-1), | 531 quad_location_(-1), |
| 532 edge_location_(-1), | 532 edge_location_(-1), |
| 533 vertex_tex_transform_location_(-1) {} | 533 vertex_tex_transform_location_(-1) {} |
| 534 | 534 |
| 535 void VertexShaderTileAA::Init(WebGraphicsContext3D* context, | 535 void VertexShaderTileAA::Init(GLES2Interface* context, |
| 536 unsigned program, | 536 unsigned program, |
| 537 int* base_uniform_index) { | 537 int* base_uniform_index) { |
| 538 static const char* uniforms[] = { | 538 static const char* uniforms[] = { |
| 539 "matrix", | 539 "matrix", |
| 540 "viewport", | 540 "viewport", |
| 541 "quad", | 541 "quad", |
| 542 "edge", | 542 "edge", |
| 543 "vertexTexTransform", | 543 "vertexTexTransform", |
| 544 }; | 544 }; |
| 545 int locations[arraysize(uniforms)]; | 545 int locations[arraysize(uniforms)]; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 dot(edge[7], screen_pos)) * gl_Position.w; | 584 dot(edge[7], screen_pos)) * gl_Position.w; |
| 585 v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy; | 585 v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy; |
| 586 } | 586 } |
| 587 ); // NOLINT(whitespace/parens) | 587 ); // NOLINT(whitespace/parens) |
| 588 } | 588 } |
| 589 | 589 |
| 590 VertexShaderVideoTransform::VertexShaderVideoTransform() | 590 VertexShaderVideoTransform::VertexShaderVideoTransform() |
| 591 : matrix_location_(-1), | 591 : matrix_location_(-1), |
| 592 tex_matrix_location_(-1) {} | 592 tex_matrix_location_(-1) {} |
| 593 | 593 |
| 594 void VertexShaderVideoTransform::Init(WebGraphicsContext3D* context, | 594 void VertexShaderVideoTransform::Init(GLES2Interface* context, |
| 595 unsigned program, | 595 unsigned program, |
| 596 int* base_uniform_index) { | 596 int* base_uniform_index) { |
| 597 static const char* uniforms[] = { | 597 static const char* uniforms[] = { |
| 598 "matrix", | 598 "matrix", |
| 599 "texMatrix", | 599 "texMatrix", |
| 600 }; | 600 }; |
| 601 int locations[arraysize(uniforms)]; | 601 int locations[arraysize(uniforms)]; |
| 602 | 602 |
| 603 GetProgramUniformLocations(context, | 603 GetProgramUniformLocations(context, |
| 604 program, | 604 program, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 622 v_texCoord = | 622 v_texCoord = |
| 623 vec2(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)); | 623 vec2(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)); |
| 624 } | 624 } |
| 625 ); // NOLINT(whitespace/parens) | 625 ); // NOLINT(whitespace/parens) |
| 626 } | 626 } |
| 627 | 627 |
| 628 FragmentTexAlphaBinding::FragmentTexAlphaBinding() | 628 FragmentTexAlphaBinding::FragmentTexAlphaBinding() |
| 629 : sampler_location_(-1), | 629 : sampler_location_(-1), |
| 630 alpha_location_(-1) {} | 630 alpha_location_(-1) {} |
| 631 | 631 |
| 632 void FragmentTexAlphaBinding::Init(WebGraphicsContext3D* context, | 632 void FragmentTexAlphaBinding::Init(GLES2Interface* context, |
| 633 unsigned program, | 633 unsigned program, |
| 634 int* base_uniform_index) { | 634 int* base_uniform_index) { |
| 635 static const char* uniforms[] = { | 635 static const char* uniforms[] = { |
| 636 "s_texture", | 636 "s_texture", |
| 637 "alpha", | 637 "alpha", |
| 638 }; | 638 }; |
| 639 int locations[arraysize(uniforms)]; | 639 int locations[arraysize(uniforms)]; |
| 640 | 640 |
| 641 GetProgramUniformLocations(context, | 641 GetProgramUniformLocations(context, |
| 642 program, | 642 program, |
| 643 arraysize(uniforms), | 643 arraysize(uniforms), |
| 644 uniforms, | 644 uniforms, |
| 645 locations, | 645 locations, |
| 646 base_uniform_index); | 646 base_uniform_index); |
| 647 sampler_location_ = locations[0]; | 647 sampler_location_ = locations[0]; |
| 648 alpha_location_ = locations[1]; | 648 alpha_location_ = locations[1]; |
| 649 } | 649 } |
| 650 | 650 |
| 651 FragmentTexColorMatrixAlphaBinding::FragmentTexColorMatrixAlphaBinding() | 651 FragmentTexColorMatrixAlphaBinding::FragmentTexColorMatrixAlphaBinding() |
| 652 : sampler_location_(-1), | 652 : sampler_location_(-1), |
| 653 alpha_location_(-1), | 653 alpha_location_(-1), |
| 654 color_matrix_location_(-1), | 654 color_matrix_location_(-1), |
| 655 color_offset_location_(-1) {} | 655 color_offset_location_(-1) {} |
| 656 | 656 |
| 657 void FragmentTexColorMatrixAlphaBinding::Init(WebGraphicsContext3D* context, | 657 void FragmentTexColorMatrixAlphaBinding::Init(GLES2Interface* context, |
| 658 unsigned program, | 658 unsigned program, |
| 659 int* base_uniform_index) { | 659 int* base_uniform_index) { |
| 660 static const char* uniforms[] = { | 660 static const char* uniforms[] = { |
| 661 "s_texture", | 661 "s_texture", |
| 662 "alpha", | 662 "alpha", |
| 663 "colorMatrix", | 663 "colorMatrix", |
| 664 "colorOffset", | 664 "colorOffset", |
| 665 }; | 665 }; |
| 666 int locations[arraysize(uniforms)]; | 666 int locations[arraysize(uniforms)]; |
| 667 | 667 |
| 668 GetProgramUniformLocations(context, | 668 GetProgramUniformLocations(context, |
| 669 program, | 669 program, |
| 670 arraysize(uniforms), | 670 arraysize(uniforms), |
| 671 uniforms, | 671 uniforms, |
| 672 locations, | 672 locations, |
| 673 base_uniform_index); | 673 base_uniform_index); |
| 674 sampler_location_ = locations[0]; | 674 sampler_location_ = locations[0]; |
| 675 alpha_location_ = locations[1]; | 675 alpha_location_ = locations[1]; |
| 676 color_matrix_location_ = locations[2]; | 676 color_matrix_location_ = locations[2]; |
| 677 color_offset_location_ = locations[3]; | 677 color_offset_location_ = locations[3]; |
| 678 } | 678 } |
| 679 | 679 |
| 680 FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() | 680 FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() |
| 681 : sampler_location_(-1) {} | 681 : sampler_location_(-1) {} |
| 682 | 682 |
| 683 void FragmentTexOpaqueBinding::Init(WebGraphicsContext3D* context, | 683 void FragmentTexOpaqueBinding::Init(GLES2Interface* context, |
| 684 unsigned program, | 684 unsigned program, |
| 685 int* base_uniform_index) { | 685 int* base_uniform_index) { |
| 686 static const char* uniforms[] = { | 686 static const char* uniforms[] = { |
| 687 "s_texture", | 687 "s_texture", |
| 688 }; | 688 }; |
| 689 int locations[arraysize(uniforms)]; | 689 int locations[arraysize(uniforms)]; |
| 690 | 690 |
| 691 GetProgramUniformLocations(context, | 691 GetProgramUniformLocations(context, |
| 692 program, | 692 program, |
| 693 arraysize(uniforms), | 693 arraysize(uniforms), |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 gl_FragColor = texColor * v_alpha; | 759 gl_FragColor = texColor * v_alpha; |
| 760 } | 760 } |
| 761 ); // NOLINT(whitespace/parens) | 761 ); // NOLINT(whitespace/parens) |
| 762 } | 762 } |
| 763 | 763 |
| 764 FragmentTexBackgroundBinding::FragmentTexBackgroundBinding() | 764 FragmentTexBackgroundBinding::FragmentTexBackgroundBinding() |
| 765 : background_color_location_(-1), | 765 : background_color_location_(-1), |
| 766 sampler_location_(-1) { | 766 sampler_location_(-1) { |
| 767 } | 767 } |
| 768 | 768 |
| 769 void FragmentTexBackgroundBinding::Init(WebGraphicsContext3D* context, | 769 void FragmentTexBackgroundBinding::Init(GLES2Interface* context, |
| 770 unsigned program, | 770 unsigned program, |
| 771 int* base_uniform_index) { | 771 int* base_uniform_index) { |
| 772 static const char* uniforms[] = { | 772 static const char* uniforms[] = { |
| 773 "s_texture", | 773 "s_texture", |
| 774 "background_color", | 774 "background_color", |
| 775 }; | 775 }; |
| 776 int locations[arraysize(uniforms)]; | 776 int locations[arraysize(uniforms)]; |
| 777 | 777 |
| 778 GetProgramUniformLocations(context, | 778 GetProgramUniformLocations(context, |
| 779 program, | 779 program, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 vec4 texColor = TextureLookup(s_texture, v_texCoord); | 872 vec4 texColor = TextureLookup(s_texture, v_texCoord); |
| 873 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, 1.0); | 873 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, 1.0); |
| 874 } | 874 } |
| 875 ); // NOLINT(whitespace/parens) | 875 ); // NOLINT(whitespace/parens) |
| 876 } | 876 } |
| 877 | 877 |
| 878 FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA() | 878 FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA() |
| 879 : sampler_location_(-1), | 879 : sampler_location_(-1), |
| 880 alpha_location_(-1) {} | 880 alpha_location_(-1) {} |
| 881 | 881 |
| 882 void FragmentShaderRGBATexAlphaAA::Init(WebGraphicsContext3D* context, | 882 void FragmentShaderRGBATexAlphaAA::Init(GLES2Interface* context, |
| 883 unsigned program, | 883 unsigned program, |
| 884 int* base_uniform_index) { | 884 int* base_uniform_index) { |
| 885 static const char* uniforms[] = { | 885 static const char* uniforms[] = { |
| 886 "s_texture", | 886 "s_texture", |
| 887 "alpha", | 887 "alpha", |
| 888 }; | 888 }; |
| 889 int locations[arraysize(uniforms)]; | 889 int locations[arraysize(uniforms)]; |
| 890 | 890 |
| 891 GetProgramUniformLocations(context, | 891 GetProgramUniformLocations(context, |
| 892 program, | 892 program, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 915 gl_FragColor = texColor * alpha * aa; | 915 gl_FragColor = texColor * alpha * aa; |
| 916 } | 916 } |
| 917 ); // NOLINT(whitespace/parens) | 917 ); // NOLINT(whitespace/parens) |
| 918 } | 918 } |
| 919 | 919 |
| 920 FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding() | 920 FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding() |
| 921 : sampler_location_(-1), | 921 : sampler_location_(-1), |
| 922 alpha_location_(-1), | 922 alpha_location_(-1), |
| 923 fragment_tex_transform_location_(-1) {} | 923 fragment_tex_transform_location_(-1) {} |
| 924 | 924 |
| 925 void FragmentTexClampAlphaAABinding::Init(WebGraphicsContext3D* context, | 925 void FragmentTexClampAlphaAABinding::Init(GLES2Interface* context, |
| 926 unsigned program, | 926 unsigned program, |
| 927 int* base_uniform_index) { | 927 int* base_uniform_index) { |
| 928 static const char* uniforms[] = { | 928 static const char* uniforms[] = { |
| 929 "s_texture", | 929 "s_texture", |
| 930 "alpha", | 930 "alpha", |
| 931 "fragmentTexTransform", | 931 "fragmentTexTransform", |
| 932 }; | 932 }; |
| 933 int locations[arraysize(uniforms)]; | 933 int locations[arraysize(uniforms)]; |
| 934 | 934 |
| 935 GetProgramUniformLocations(context, | 935 GetProgramUniformLocations(context, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 } | 989 } |
| 990 ); // NOLINT(whitespace/parens) | 990 ); // NOLINT(whitespace/parens) |
| 991 } | 991 } |
| 992 | 992 |
| 993 FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask() | 993 FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask() |
| 994 : sampler_location_(-1), | 994 : sampler_location_(-1), |
| 995 mask_sampler_location_(-1), | 995 mask_sampler_location_(-1), |
| 996 alpha_location_(-1), | 996 alpha_location_(-1), |
| 997 mask_tex_coord_scale_location_(-1) {} | 997 mask_tex_coord_scale_location_(-1) {} |
| 998 | 998 |
| 999 void FragmentShaderRGBATexAlphaMask::Init(WebGraphicsContext3D* context, | 999 void FragmentShaderRGBATexAlphaMask::Init(GLES2Interface* context, |
| 1000 unsigned program, | 1000 unsigned program, |
| 1001 int* base_uniform_index) { | 1001 int* base_uniform_index) { |
| 1002 static const char* uniforms[] = { | 1002 static const char* uniforms[] = { |
| 1003 "s_texture", | 1003 "s_texture", |
| 1004 "s_mask", | 1004 "s_mask", |
| 1005 "alpha", | 1005 "alpha", |
| 1006 "maskTexCoordScale", | 1006 "maskTexCoordScale", |
| 1007 "maskTexCoordOffset", | 1007 "maskTexCoordOffset", |
| 1008 }; | 1008 }; |
| 1009 int locations[arraysize(uniforms)]; | 1009 int locations[arraysize(uniforms)]; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 ); // NOLINT(whitespace/parens) | 1042 ); // NOLINT(whitespace/parens) |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() | 1045 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() |
| 1046 : sampler_location_(-1), | 1046 : sampler_location_(-1), |
| 1047 mask_sampler_location_(-1), | 1047 mask_sampler_location_(-1), |
| 1048 alpha_location_(-1), | 1048 alpha_location_(-1), |
| 1049 mask_tex_coord_scale_location_(-1), | 1049 mask_tex_coord_scale_location_(-1), |
| 1050 mask_tex_coord_offset_location_(-1) {} | 1050 mask_tex_coord_offset_location_(-1) {} |
| 1051 | 1051 |
| 1052 void FragmentShaderRGBATexAlphaMaskAA::Init(WebGraphicsContext3D* context, | 1052 void FragmentShaderRGBATexAlphaMaskAA::Init(GLES2Interface* context, |
| 1053 unsigned program, | 1053 unsigned program, |
| 1054 int* base_uniform_index) { | 1054 int* base_uniform_index) { |
| 1055 static const char* uniforms[] = { | 1055 static const char* uniforms[] = { |
| 1056 "s_texture", | 1056 "s_texture", |
| 1057 "s_mask", | 1057 "s_mask", |
| 1058 "alpha", | 1058 "alpha", |
| 1059 "maskTexCoordScale", | 1059 "maskTexCoordScale", |
| 1060 "maskTexCoordOffset", | 1060 "maskTexCoordOffset", |
| 1061 }; | 1061 }; |
| 1062 int locations[arraysize(uniforms)]; | 1062 int locations[arraysize(uniforms)]; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 FragmentShaderRGBATexAlphaMaskColorMatrixAA:: | 1103 FragmentShaderRGBATexAlphaMaskColorMatrixAA:: |
| 1104 FragmentShaderRGBATexAlphaMaskColorMatrixAA() | 1104 FragmentShaderRGBATexAlphaMaskColorMatrixAA() |
| 1105 : sampler_location_(-1), | 1105 : sampler_location_(-1), |
| 1106 mask_sampler_location_(-1), | 1106 mask_sampler_location_(-1), |
| 1107 alpha_location_(-1), | 1107 alpha_location_(-1), |
| 1108 mask_tex_coord_scale_location_(-1), | 1108 mask_tex_coord_scale_location_(-1), |
| 1109 color_matrix_location_(-1), | 1109 color_matrix_location_(-1), |
| 1110 color_offset_location_(-1) {} | 1110 color_offset_location_(-1) {} |
| 1111 | 1111 |
| 1112 void FragmentShaderRGBATexAlphaMaskColorMatrixAA::Init( | 1112 void FragmentShaderRGBATexAlphaMaskColorMatrixAA::Init( |
| 1113 WebGraphicsContext3D* context, | 1113 GLES2Interface* context, |
| 1114 unsigned program, | 1114 unsigned program, |
| 1115 int* base_uniform_index) { | 1115 int* base_uniform_index) { |
| 1116 static const char* uniforms[] = { | 1116 static const char* uniforms[] = { |
| 1117 "s_texture", | 1117 "s_texture", |
| 1118 "s_mask", | 1118 "s_mask", |
| 1119 "alpha", | 1119 "alpha", |
| 1120 "maskTexCoordScale", | 1120 "maskTexCoordScale", |
| 1121 "maskTexCoordOffset", | 1121 "maskTexCoordOffset", |
| 1122 "colorMatrix", | 1122 "colorMatrix", |
| 1123 "colorOffset", | 1123 "colorOffset", |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 FragmentShaderRGBATexAlphaColorMatrixAA:: | 1175 FragmentShaderRGBATexAlphaColorMatrixAA:: |
| 1176 FragmentShaderRGBATexAlphaColorMatrixAA() | 1176 FragmentShaderRGBATexAlphaColorMatrixAA() |
| 1177 : sampler_location_(-1), | 1177 : sampler_location_(-1), |
| 1178 alpha_location_(-1), | 1178 alpha_location_(-1), |
| 1179 color_matrix_location_(-1), | 1179 color_matrix_location_(-1), |
| 1180 color_offset_location_(-1) {} | 1180 color_offset_location_(-1) {} |
| 1181 | 1181 |
| 1182 void FragmentShaderRGBATexAlphaColorMatrixAA::Init( | 1182 void FragmentShaderRGBATexAlphaColorMatrixAA::Init( |
| 1183 WebGraphicsContext3D* context, | 1183 GLES2Interface* context, |
| 1184 unsigned program, | 1184 unsigned program, |
| 1185 int* base_uniform_index) { | 1185 int* base_uniform_index) { |
| 1186 static const char* uniforms[] = { | 1186 static const char* uniforms[] = { |
| 1187 "s_texture", | 1187 "s_texture", |
| 1188 "alpha", | 1188 "alpha", |
| 1189 "colorMatrix", | 1189 "colorMatrix", |
| 1190 "colorOffset", | 1190 "colorOffset", |
| 1191 }; | 1191 }; |
| 1192 int locations[arraysize(uniforms)]; | 1192 int locations[arraysize(uniforms)]; |
| 1193 | 1193 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 FragmentShaderRGBATexAlphaMaskColorMatrix:: | 1232 FragmentShaderRGBATexAlphaMaskColorMatrix:: |
| 1233 FragmentShaderRGBATexAlphaMaskColorMatrix() | 1233 FragmentShaderRGBATexAlphaMaskColorMatrix() |
| 1234 : sampler_location_(-1), | 1234 : sampler_location_(-1), |
| 1235 mask_sampler_location_(-1), | 1235 mask_sampler_location_(-1), |
| 1236 alpha_location_(-1), | 1236 alpha_location_(-1), |
| 1237 mask_tex_coord_scale_location_(-1) {} | 1237 mask_tex_coord_scale_location_(-1) {} |
| 1238 | 1238 |
| 1239 void FragmentShaderRGBATexAlphaMaskColorMatrix::Init( | 1239 void FragmentShaderRGBATexAlphaMaskColorMatrix::Init( |
| 1240 WebGraphicsContext3D* context, | 1240 GLES2Interface* context, |
| 1241 unsigned program, | 1241 unsigned program, |
| 1242 int* base_uniform_index) { | 1242 int* base_uniform_index) { |
| 1243 static const char* uniforms[] = { | 1243 static const char* uniforms[] = { |
| 1244 "s_texture", | 1244 "s_texture", |
| 1245 "s_mask", | 1245 "s_mask", |
| 1246 "alpha", | 1246 "alpha", |
| 1247 "maskTexCoordScale", | 1247 "maskTexCoordScale", |
| 1248 "maskTexCoordOffset", | 1248 "maskTexCoordOffset", |
| 1249 "colorMatrix", | 1249 "colorMatrix", |
| 1250 "colorOffset", | 1250 "colorOffset", |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 } | 1295 } |
| 1296 | 1296 |
| 1297 FragmentShaderYUVVideo::FragmentShaderYUVVideo() | 1297 FragmentShaderYUVVideo::FragmentShaderYUVVideo() |
| 1298 : y_texture_location_(-1), | 1298 : y_texture_location_(-1), |
| 1299 u_texture_location_(-1), | 1299 u_texture_location_(-1), |
| 1300 v_texture_location_(-1), | 1300 v_texture_location_(-1), |
| 1301 alpha_location_(-1), | 1301 alpha_location_(-1), |
| 1302 yuv_matrix_location_(-1), | 1302 yuv_matrix_location_(-1), |
| 1303 yuv_adj_location_(-1) {} | 1303 yuv_adj_location_(-1) {} |
| 1304 | 1304 |
| 1305 void FragmentShaderYUVVideo::Init(WebGraphicsContext3D* context, | 1305 void FragmentShaderYUVVideo::Init(GLES2Interface* context, |
| 1306 unsigned program, | 1306 unsigned program, |
| 1307 int* base_uniform_index) { | 1307 int* base_uniform_index) { |
| 1308 static const char* uniforms[] = { | 1308 static const char* uniforms[] = { |
| 1309 "y_texture", | 1309 "y_texture", |
| 1310 "u_texture", | 1310 "u_texture", |
| 1311 "v_texture", | 1311 "v_texture", |
| 1312 "alpha", | 1312 "alpha", |
| 1313 "yuv_matrix", | 1313 "yuv_matrix", |
| 1314 "yuv_adj", | 1314 "yuv_adj", |
| 1315 }; | 1315 }; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 FragmentShaderYUVAVideo::FragmentShaderYUVAVideo() | 1355 FragmentShaderYUVAVideo::FragmentShaderYUVAVideo() |
| 1356 : y_texture_location_(-1), | 1356 : y_texture_location_(-1), |
| 1357 u_texture_location_(-1), | 1357 u_texture_location_(-1), |
| 1358 v_texture_location_(-1), | 1358 v_texture_location_(-1), |
| 1359 a_texture_location_(-1), | 1359 a_texture_location_(-1), |
| 1360 alpha_location_(-1), | 1360 alpha_location_(-1), |
| 1361 yuv_matrix_location_(-1), | 1361 yuv_matrix_location_(-1), |
| 1362 yuv_adj_location_(-1) { | 1362 yuv_adj_location_(-1) { |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 void FragmentShaderYUVAVideo::Init(WebGraphicsContext3D* context, | 1365 void FragmentShaderYUVAVideo::Init(GLES2Interface* context, |
| 1366 unsigned program, | 1366 unsigned program, |
| 1367 int* base_uniform_index) { | 1367 int* base_uniform_index) { |
| 1368 static const char* uniforms[] = { | 1368 static const char* uniforms[] = { |
| 1369 "y_texture", | 1369 "y_texture", |
| 1370 "u_texture", | 1370 "u_texture", |
| 1371 "v_texture", | 1371 "v_texture", |
| 1372 "a_texture", | 1372 "a_texture", |
| 1373 "alpha", | 1373 "alpha", |
| 1374 "cc_matrix", | 1374 "cc_matrix", |
| 1375 "yuv_adj", | 1375 "yuv_adj", |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj; | 1412 vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj; |
| 1413 vec3 rgb = yuv_matrix * yuv; | 1413 vec3 rgb = yuv_matrix * yuv; |
| 1414 gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw); | 1414 gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw); |
| 1415 } | 1415 } |
| 1416 ); // NOLINT(whitespace/parens) | 1416 ); // NOLINT(whitespace/parens) |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 FragmentShaderColor::FragmentShaderColor() | 1419 FragmentShaderColor::FragmentShaderColor() |
| 1420 : color_location_(-1) {} | 1420 : color_location_(-1) {} |
| 1421 | 1421 |
| 1422 void FragmentShaderColor::Init(WebGraphicsContext3D* context, | 1422 void FragmentShaderColor::Init(GLES2Interface* context, |
| 1423 unsigned program, | 1423 unsigned program, |
| 1424 int* base_uniform_index) { | 1424 int* base_uniform_index) { |
| 1425 static const char* uniforms[] = { | 1425 static const char* uniforms[] = { |
| 1426 "color", | 1426 "color", |
| 1427 }; | 1427 }; |
| 1428 int locations[arraysize(uniforms)]; | 1428 int locations[arraysize(uniforms)]; |
| 1429 | 1429 |
| 1430 GetProgramUniformLocations(context, | 1430 GetProgramUniformLocations(context, |
| 1431 program, | 1431 program, |
| 1432 arraysize(uniforms), | 1432 arraysize(uniforms), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1443 uniform vec4 color; | 1443 uniform vec4 color; |
| 1444 void main() { | 1444 void main() { |
| 1445 gl_FragColor = color; | 1445 gl_FragColor = color; |
| 1446 } | 1446 } |
| 1447 ); // NOLINT(whitespace/parens) | 1447 ); // NOLINT(whitespace/parens) |
| 1448 } | 1448 } |
| 1449 | 1449 |
| 1450 FragmentShaderColorAA::FragmentShaderColorAA() | 1450 FragmentShaderColorAA::FragmentShaderColorAA() |
| 1451 : color_location_(-1) {} | 1451 : color_location_(-1) {} |
| 1452 | 1452 |
| 1453 void FragmentShaderColorAA::Init(WebGraphicsContext3D* context, | 1453 void FragmentShaderColorAA::Init(GLES2Interface* context, |
| 1454 unsigned program, | 1454 unsigned program, |
| 1455 int* base_uniform_index) { | 1455 int* base_uniform_index) { |
| 1456 static const char* uniforms[] = { | 1456 static const char* uniforms[] = { |
| 1457 "color", | 1457 "color", |
| 1458 }; | 1458 }; |
| 1459 int locations[arraysize(uniforms)]; | 1459 int locations[arraysize(uniforms)]; |
| 1460 | 1460 |
| 1461 GetProgramUniformLocations(context, | 1461 GetProgramUniformLocations(context, |
| 1462 program, | 1462 program, |
| 1463 arraysize(uniforms), | 1463 arraysize(uniforms), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1481 gl_FragColor = color * aa; | 1481 gl_FragColor = color * aa; |
| 1482 } | 1482 } |
| 1483 ); // NOLINT(whitespace/parens) | 1483 ); // NOLINT(whitespace/parens) |
| 1484 } | 1484 } |
| 1485 | 1485 |
| 1486 FragmentShaderCheckerboard::FragmentShaderCheckerboard() | 1486 FragmentShaderCheckerboard::FragmentShaderCheckerboard() |
| 1487 : alpha_location_(-1), | 1487 : alpha_location_(-1), |
| 1488 tex_transform_location_(-1), | 1488 tex_transform_location_(-1), |
| 1489 frequency_location_(-1) {} | 1489 frequency_location_(-1) {} |
| 1490 | 1490 |
| 1491 void FragmentShaderCheckerboard::Init(WebGraphicsContext3D* context, | 1491 void FragmentShaderCheckerboard::Init(GLES2Interface* context, |
| 1492 unsigned program, | 1492 unsigned program, |
| 1493 int* base_uniform_index) { | 1493 int* base_uniform_index) { |
| 1494 static const char* uniforms[] = { | 1494 static const char* uniforms[] = { |
| 1495 "alpha", | 1495 "alpha", |
| 1496 "texTransform", | 1496 "texTransform", |
| 1497 "frequency", | 1497 "frequency", |
| 1498 "color", | 1498 "color", |
| 1499 }; | 1499 }; |
| 1500 int locations[arraysize(uniforms)]; | 1500 int locations[arraysize(uniforms)]; |
| 1501 | 1501 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1529 vec2 texCoord = | 1529 vec2 texCoord = |
| 1530 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; | 1530 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; |
| 1531 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); | 1531 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
| 1532 float picker = abs(coord.x - coord.y); // NOLINT | 1532 float picker = abs(coord.x - coord.y); // NOLINT |
| 1533 gl_FragColor = mix(color1, color2, picker) * alpha; | 1533 gl_FragColor = mix(color1, color2, picker) * alpha; |
| 1534 } | 1534 } |
| 1535 ); // NOLINT(whitespace/parens) | 1535 ); // NOLINT(whitespace/parens) |
| 1536 } | 1536 } |
| 1537 | 1537 |
| 1538 } // namespace cc | 1538 } // namespace cc |
| OLD | NEW |