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 "third_party/WebKit/public/platform/WebGraphicsContext3D.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) SetFragTexCoordPrecision(precision, SHADER0(Src)) | 17 #define FRAGMENT_SHADER(Src) SetFragTexCoordPrecision(precision, SHADER0(Src)) |
18 | 18 |
19 using WebKit::WebGraphicsContext3D; | 19 using WebKit::WebGraphicsContext3D; |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 static void GetProgramUniformLocations(WebGraphicsContext3D* context, | 25 static void GetProgramUniformLocations(WebGraphicsContext3D* context, |
26 unsigned program, | 26 unsigned program, |
27 size_t count, | 27 size_t count, |
28 const char** uniforms, | 28 const char** uniforms, |
29 int* locations, | 29 int* locations, |
30 bool using_bind_uniform, | |
31 int* base_uniform_index) { | 30 int* base_uniform_index) { |
32 for (size_t i = 0; i < count; i++) { | 31 for (size_t i = 0; i < count; i++) { |
33 if (using_bind_uniform) { | 32 locations[i] = (*base_uniform_index)++; |
34 locations[i] = (*base_uniform_index)++; | 33 context->bindUniformLocationCHROMIUM(program, locations[i], uniforms[i]); |
35 context->bindUniformLocationCHROMIUM(program, locations[i], uniforms[i]); | |
36 } else { | |
37 locations[i] = context->getUniformLocation(program, uniforms[i]); | |
38 DCHECK_NE(locations[i], -1); | |
39 } | |
40 } | 34 } |
41 } | 35 } |
42 | 36 |
43 static std::string SetFragTexCoordPrecision( | 37 static std::string SetFragTexCoordPrecision( |
44 TexCoordPrecision requested_precision, std::string shader_string) { | 38 TexCoordPrecision requested_precision, std::string shader_string) { |
45 switch (requested_precision) { | 39 switch (requested_precision) { |
46 case TexCoordPrecisionHigh: | 40 case TexCoordPrecisionHigh: |
47 DCHECK_NE(shader_string.find("TexCoordPrecision"), std::string::npos); | 41 DCHECK_NE(shader_string.find("TexCoordPrecision"), std::string::npos); |
48 return | 42 return |
49 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" | 43 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return TexCoordPrecisionRequired(context, | 108 return TexCoordPrecisionRequired(context, |
115 highp_threshold_cache, highp_threshold_min, | 109 highp_threshold_cache, highp_threshold_min, |
116 max_size.width(), max_size.height()); | 110 max_size.width(), max_size.height()); |
117 } | 111 } |
118 | 112 |
119 VertexShaderPosTex::VertexShaderPosTex() | 113 VertexShaderPosTex::VertexShaderPosTex() |
120 : matrix_location_(-1) {} | 114 : matrix_location_(-1) {} |
121 | 115 |
122 void VertexShaderPosTex::Init(WebGraphicsContext3D* context, | 116 void VertexShaderPosTex::Init(WebGraphicsContext3D* context, |
123 unsigned program, | 117 unsigned program, |
124 bool using_bind_uniform, | |
125 int* base_uniform_index) { | 118 int* base_uniform_index) { |
126 static const char* uniforms[] = { | 119 static const char* uniforms[] = { |
127 "matrix", | 120 "matrix", |
128 }; | 121 }; |
129 int locations[arraysize(uniforms)]; | 122 int locations[arraysize(uniforms)]; |
130 | 123 |
131 GetProgramUniformLocations(context, | 124 GetProgramUniformLocations(context, |
132 program, | 125 program, |
133 arraysize(uniforms), | 126 arraysize(uniforms), |
134 uniforms, | 127 uniforms, |
135 locations, | 128 locations, |
136 using_bind_uniform, | |
137 base_uniform_index); | 129 base_uniform_index); |
138 matrix_location_ = locations[0]; | 130 matrix_location_ = locations[0]; |
139 } | 131 } |
140 | 132 |
141 std::string VertexShaderPosTex::GetShaderString() const { | 133 std::string VertexShaderPosTex::GetShaderString() const { |
142 return VERTEX_SHADER( | 134 return VERTEX_SHADER( |
143 attribute vec4 a_position; | 135 attribute vec4 a_position; |
144 attribute TexCoordPrecision vec2 a_texCoord; | 136 attribute TexCoordPrecision vec2 a_texCoord; |
145 uniform mat4 matrix; | 137 uniform mat4 matrix; |
146 varying TexCoordPrecision vec2 v_texCoord; | 138 varying TexCoordPrecision vec2 v_texCoord; |
147 void main() { | 139 void main() { |
148 gl_Position = matrix * a_position; | 140 gl_Position = matrix * a_position; |
149 v_texCoord = a_texCoord; | 141 v_texCoord = a_texCoord; |
150 } | 142 } |
151 ); // NOLINT(whitespace/parens) | 143 ); // NOLINT(whitespace/parens) |
152 } | 144 } |
153 | 145 |
154 VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() | 146 VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() |
155 : matrix_location_(-1), | 147 : matrix_location_(-1), |
156 tex_scale_location_(-1) {} | 148 tex_scale_location_(-1) {} |
157 | 149 |
158 void VertexShaderPosTexYUVStretch::Init(WebGraphicsContext3D* context, | 150 void VertexShaderPosTexYUVStretch::Init(WebGraphicsContext3D* context, |
159 unsigned program, | 151 unsigned program, |
160 bool using_bind_uniform, | |
161 int* base_uniform_index) { | 152 int* base_uniform_index) { |
162 static const char* uniforms[] = { | 153 static const char* uniforms[] = { |
163 "matrix", | 154 "matrix", |
164 "texScale", | 155 "texScale", |
165 }; | 156 }; |
166 int locations[arraysize(uniforms)]; | 157 int locations[arraysize(uniforms)]; |
167 | 158 |
168 GetProgramUniformLocations(context, | 159 GetProgramUniformLocations(context, |
169 program, | 160 program, |
170 arraysize(uniforms), | 161 arraysize(uniforms), |
171 uniforms, | 162 uniforms, |
172 locations, | 163 locations, |
173 using_bind_uniform, | |
174 base_uniform_index); | 164 base_uniform_index); |
175 matrix_location_ = locations[0]; | 165 matrix_location_ = locations[0]; |
176 tex_scale_location_ = locations[1]; | 166 tex_scale_location_ = locations[1]; |
177 } | 167 } |
178 | 168 |
179 std::string VertexShaderPosTexYUVStretch::GetShaderString() const { | 169 std::string VertexShaderPosTexYUVStretch::GetShaderString() const { |
180 return VERTEX_SHADER( | 170 return VERTEX_SHADER( |
181 precision mediump float; | 171 precision mediump float; |
182 attribute vec4 a_position; | 172 attribute vec4 a_position; |
183 attribute TexCoordPrecision vec2 a_texCoord; | 173 attribute TexCoordPrecision vec2 a_texCoord; |
184 uniform mat4 matrix; | 174 uniform mat4 matrix; |
185 varying TexCoordPrecision vec2 v_texCoord; | 175 varying TexCoordPrecision vec2 v_texCoord; |
186 uniform TexCoordPrecision vec2 texScale; | 176 uniform TexCoordPrecision vec2 texScale; |
187 void main() { | 177 void main() { |
188 gl_Position = matrix * a_position; | 178 gl_Position = matrix * a_position; |
189 v_texCoord = a_texCoord * texScale; | 179 v_texCoord = a_texCoord * texScale; |
190 } | 180 } |
191 ); // NOLINT(whitespace/parens) | 181 ); // NOLINT(whitespace/parens) |
192 } | 182 } |
193 | 183 |
194 VertexShaderPos::VertexShaderPos() | 184 VertexShaderPos::VertexShaderPos() |
195 : matrix_location_(-1) {} | 185 : matrix_location_(-1) {} |
196 | 186 |
197 void VertexShaderPos::Init(WebGraphicsContext3D* context, | 187 void VertexShaderPos::Init(WebGraphicsContext3D* context, |
198 unsigned program, | 188 unsigned program, |
199 bool using_bind_uniform, | |
200 int* base_uniform_index) { | 189 int* base_uniform_index) { |
201 static const char* uniforms[] = { | 190 static const char* uniforms[] = { |
202 "matrix", | 191 "matrix", |
203 }; | 192 }; |
204 int locations[arraysize(uniforms)]; | 193 int locations[arraysize(uniforms)]; |
205 | 194 |
206 GetProgramUniformLocations(context, | 195 GetProgramUniformLocations(context, |
207 program, | 196 program, |
208 arraysize(uniforms), | 197 arraysize(uniforms), |
209 uniforms, | 198 uniforms, |
210 locations, | 199 locations, |
211 using_bind_uniform, | |
212 base_uniform_index); | 200 base_uniform_index); |
213 matrix_location_ = locations[0]; | 201 matrix_location_ = locations[0]; |
214 } | 202 } |
215 | 203 |
216 std::string VertexShaderPos::GetShaderString() const { | 204 std::string VertexShaderPos::GetShaderString() const { |
217 return VERTEX_SHADER( | 205 return VERTEX_SHADER( |
218 attribute vec4 a_position; | 206 attribute vec4 a_position; |
219 uniform mat4 matrix; | 207 uniform mat4 matrix; |
220 void main() { | 208 void main() { |
221 gl_Position = matrix * a_position; | 209 gl_Position = matrix * a_position; |
222 } | 210 } |
223 ); // NOLINT(whitespace/parens) | 211 ); // NOLINT(whitespace/parens) |
224 } | 212 } |
225 | 213 |
226 VertexShaderPosTexTransform::VertexShaderPosTexTransform() | 214 VertexShaderPosTexTransform::VertexShaderPosTexTransform() |
227 : matrix_location_(-1), | 215 : matrix_location_(-1), |
228 tex_transform_location_(-1), | 216 tex_transform_location_(-1), |
229 vertex_opacity_location_(-1) {} | 217 vertex_opacity_location_(-1) {} |
230 | 218 |
231 void VertexShaderPosTexTransform::Init(WebGraphicsContext3D* context, | 219 void VertexShaderPosTexTransform::Init(WebGraphicsContext3D* context, |
232 unsigned program, | 220 unsigned program, |
233 bool using_bind_uniform, | |
234 int* base_uniform_index) { | 221 int* base_uniform_index) { |
235 static const char* uniforms[] = { | 222 static const char* uniforms[] = { |
236 "matrix", | 223 "matrix", |
237 "texTransform", | 224 "texTransform", |
238 "opacity", | 225 "opacity", |
239 }; | 226 }; |
240 int locations[arraysize(uniforms)]; | 227 int locations[arraysize(uniforms)]; |
241 | 228 |
242 GetProgramUniformLocations(context, | 229 GetProgramUniformLocations(context, |
243 program, | 230 program, |
244 arraysize(uniforms), | 231 arraysize(uniforms), |
245 uniforms, | 232 uniforms, |
246 locations, | 233 locations, |
247 using_bind_uniform, | |
248 base_uniform_index); | 234 base_uniform_index); |
249 matrix_location_ = locations[0]; | 235 matrix_location_ = locations[0]; |
250 tex_transform_location_ = locations[1]; | 236 tex_transform_location_ = locations[1]; |
251 vertex_opacity_location_ = locations[2]; | 237 vertex_opacity_location_ = locations[2]; |
252 } | 238 } |
253 | 239 |
254 std::string VertexShaderPosTexTransform::GetShaderString() const { | 240 std::string VertexShaderPosTexTransform::GetShaderString() const { |
255 return VERTEX_SHADER( | 241 return VERTEX_SHADER( |
256 attribute vec4 a_position; | 242 attribute vec4 a_position; |
257 attribute TexCoordPrecision vec2 a_texCoord; | 243 attribute TexCoordPrecision vec2 a_texCoord; |
(...skipping 23 matching lines...) Expand all Loading... |
281 } | 267 } |
282 ); // NOLINT(whitespace/parens) | 268 ); // NOLINT(whitespace/parens) |
283 } | 269 } |
284 | 270 |
285 VertexShaderQuad::VertexShaderQuad() | 271 VertexShaderQuad::VertexShaderQuad() |
286 : matrix_location_(-1), | 272 : matrix_location_(-1), |
287 quad_location_(-1) {} | 273 quad_location_(-1) {} |
288 | 274 |
289 void VertexShaderQuad::Init(WebGraphicsContext3D* context, | 275 void VertexShaderQuad::Init(WebGraphicsContext3D* context, |
290 unsigned program, | 276 unsigned program, |
291 bool using_bind_uniform, | |
292 int* base_uniform_index) { | 277 int* base_uniform_index) { |
293 static const char* uniforms[] = { | 278 static const char* uniforms[] = { |
294 "matrix", | 279 "matrix", |
295 "quad", | 280 "quad", |
296 }; | 281 }; |
297 int locations[arraysize(uniforms)]; | 282 int locations[arraysize(uniforms)]; |
298 | 283 |
299 GetProgramUniformLocations(context, | 284 GetProgramUniformLocations(context, |
300 program, | 285 program, |
301 arraysize(uniforms), | 286 arraysize(uniforms), |
302 uniforms, | 287 uniforms, |
303 locations, | 288 locations, |
304 using_bind_uniform, | |
305 base_uniform_index); | 289 base_uniform_index); |
306 matrix_location_ = locations[0]; | 290 matrix_location_ = locations[0]; |
307 quad_location_ = locations[1]; | 291 quad_location_ = locations[1]; |
308 } | 292 } |
309 | 293 |
310 std::string VertexShaderQuad::GetShaderString() const { | 294 std::string VertexShaderQuad::GetShaderString() const { |
311 #if defined(OS_ANDROID) | 295 #if defined(OS_ANDROID) |
312 // TODO(epenner): Find the cause of this 'quad' uniform | 296 // TODO(epenner): Find the cause of this 'quad' uniform |
313 // being missing if we don't add dummy variables. | 297 // being missing if we don't add dummy variables. |
314 // http://crbug.com/240602 | 298 // http://crbug.com/240602 |
(...skipping 25 matching lines...) Expand all Loading... |
340 } | 324 } |
341 | 325 |
342 VertexShaderQuadAA::VertexShaderQuadAA() | 326 VertexShaderQuadAA::VertexShaderQuadAA() |
343 : matrix_location_(-1), | 327 : matrix_location_(-1), |
344 viewport_location_(-1), | 328 viewport_location_(-1), |
345 quad_location_(-1), | 329 quad_location_(-1), |
346 edge_location_(-1) {} | 330 edge_location_(-1) {} |
347 | 331 |
348 void VertexShaderQuadAA::Init(WebGraphicsContext3D* context, | 332 void VertexShaderQuadAA::Init(WebGraphicsContext3D* context, |
349 unsigned program, | 333 unsigned program, |
350 bool using_bind_uniform, | |
351 int* base_uniform_index) { | 334 int* base_uniform_index) { |
352 static const char* uniforms[] = { | 335 static const char* uniforms[] = { |
353 "matrix", | 336 "matrix", |
354 "viewport", | 337 "viewport", |
355 "quad", | 338 "quad", |
356 "edge", | 339 "edge", |
357 }; | 340 }; |
358 int locations[arraysize(uniforms)]; | 341 int locations[arraysize(uniforms)]; |
359 | 342 |
360 GetProgramUniformLocations(context, | 343 GetProgramUniformLocations(context, |
361 program, | 344 program, |
362 arraysize(uniforms), | 345 arraysize(uniforms), |
363 uniforms, | 346 uniforms, |
364 locations, | 347 locations, |
365 using_bind_uniform, | |
366 base_uniform_index); | 348 base_uniform_index); |
367 matrix_location_ = locations[0]; | 349 matrix_location_ = locations[0]; |
368 viewport_location_ = locations[1]; | 350 viewport_location_ = locations[1]; |
369 quad_location_ = locations[2]; | 351 quad_location_ = locations[2]; |
370 edge_location_ = locations[3]; | 352 edge_location_ = locations[3]; |
371 } | 353 } |
372 | 354 |
373 std::string VertexShaderQuadAA::GetShaderString() const { | 355 std::string VertexShaderQuadAA::GetShaderString() const { |
374 return VERTEX_SHADER( | 356 return VERTEX_SHADER( |
375 attribute TexCoordPrecision vec4 a_position; | 357 attribute TexCoordPrecision vec4 a_position; |
(...skipping 23 matching lines...) Expand all Loading... |
399 | 381 |
400 VertexShaderQuadTexTransformAA::VertexShaderQuadTexTransformAA() | 382 VertexShaderQuadTexTransformAA::VertexShaderQuadTexTransformAA() |
401 : matrix_location_(-1), | 383 : matrix_location_(-1), |
402 viewport_location_(-1), | 384 viewport_location_(-1), |
403 quad_location_(-1), | 385 quad_location_(-1), |
404 edge_location_(-1), | 386 edge_location_(-1), |
405 tex_transform_location_(-1) {} | 387 tex_transform_location_(-1) {} |
406 | 388 |
407 void VertexShaderQuadTexTransformAA::Init(WebGraphicsContext3D* context, | 389 void VertexShaderQuadTexTransformAA::Init(WebGraphicsContext3D* context, |
408 unsigned program, | 390 unsigned program, |
409 bool using_bind_uniform, | |
410 int* base_uniform_index) { | 391 int* base_uniform_index) { |
411 static const char* uniforms[] = { | 392 static const char* uniforms[] = { |
412 "matrix", | 393 "matrix", |
413 "viewport", | 394 "viewport", |
414 "quad", | 395 "quad", |
415 "edge", | 396 "edge", |
416 "texTrans", | 397 "texTrans", |
417 }; | 398 }; |
418 int locations[arraysize(uniforms)]; | 399 int locations[arraysize(uniforms)]; |
419 | 400 |
420 GetProgramUniformLocations(context, | 401 GetProgramUniformLocations(context, |
421 program, | 402 program, |
422 arraysize(uniforms), | 403 arraysize(uniforms), |
423 uniforms, | 404 uniforms, |
424 locations, | 405 locations, |
425 using_bind_uniform, | |
426 base_uniform_index); | 406 base_uniform_index); |
427 matrix_location_ = locations[0]; | 407 matrix_location_ = locations[0]; |
428 viewport_location_ = locations[1]; | 408 viewport_location_ = locations[1]; |
429 quad_location_ = locations[2]; | 409 quad_location_ = locations[2]; |
430 edge_location_ = locations[3]; | 410 edge_location_ = locations[3]; |
431 tex_transform_location_ = locations[4]; | 411 tex_transform_location_ = locations[4]; |
432 } | 412 } |
433 | 413 |
434 std::string VertexShaderQuadTexTransformAA::GetShaderString() const { | 414 std::string VertexShaderQuadTexTransformAA::GetShaderString() const { |
435 return VERTEX_SHADER( | 415 return VERTEX_SHADER( |
(...skipping 25 matching lines...) Expand all Loading... |
461 ); // NOLINT(whitespace/parens) | 441 ); // NOLINT(whitespace/parens) |
462 } | 442 } |
463 | 443 |
464 VertexShaderTile::VertexShaderTile() | 444 VertexShaderTile::VertexShaderTile() |
465 : matrix_location_(-1), | 445 : matrix_location_(-1), |
466 quad_location_(-1), | 446 quad_location_(-1), |
467 vertex_tex_transform_location_(-1) {} | 447 vertex_tex_transform_location_(-1) {} |
468 | 448 |
469 void VertexShaderTile::Init(WebGraphicsContext3D* context, | 449 void VertexShaderTile::Init(WebGraphicsContext3D* context, |
470 unsigned program, | 450 unsigned program, |
471 bool using_bind_uniform, | |
472 int* base_uniform_index) { | 451 int* base_uniform_index) { |
473 static const char* uniforms[] = { | 452 static const char* uniforms[] = { |
474 "matrix", | 453 "matrix", |
475 "quad", | 454 "quad", |
476 "vertexTexTransform", | 455 "vertexTexTransform", |
477 }; | 456 }; |
478 int locations[arraysize(uniforms)]; | 457 int locations[arraysize(uniforms)]; |
479 | 458 |
480 GetProgramUniformLocations(context, | 459 GetProgramUniformLocations(context, |
481 program, | 460 program, |
482 arraysize(uniforms), | 461 arraysize(uniforms), |
483 uniforms, | 462 uniforms, |
484 locations, | 463 locations, |
485 using_bind_uniform, | |
486 base_uniform_index); | 464 base_uniform_index); |
487 matrix_location_ = locations[0]; | 465 matrix_location_ = locations[0]; |
488 quad_location_ = locations[1]; | 466 quad_location_ = locations[1]; |
489 vertex_tex_transform_location_ = locations[2]; | 467 vertex_tex_transform_location_ = locations[2]; |
490 } | 468 } |
491 | 469 |
492 std::string VertexShaderTile::GetShaderString() const { | 470 std::string VertexShaderTile::GetShaderString() const { |
493 return VERTEX_SHADER( | 471 return VERTEX_SHADER( |
494 attribute TexCoordPrecision vec4 a_position; | 472 attribute TexCoordPrecision vec4 a_position; |
495 attribute float a_index; | 473 attribute float a_index; |
(...skipping 11 matching lines...) Expand all Loading... |
507 | 485 |
508 VertexShaderTileAA::VertexShaderTileAA() | 486 VertexShaderTileAA::VertexShaderTileAA() |
509 : matrix_location_(-1), | 487 : matrix_location_(-1), |
510 viewport_location_(-1), | 488 viewport_location_(-1), |
511 quad_location_(-1), | 489 quad_location_(-1), |
512 edge_location_(-1), | 490 edge_location_(-1), |
513 vertex_tex_transform_location_(-1) {} | 491 vertex_tex_transform_location_(-1) {} |
514 | 492 |
515 void VertexShaderTileAA::Init(WebGraphicsContext3D* context, | 493 void VertexShaderTileAA::Init(WebGraphicsContext3D* context, |
516 unsigned program, | 494 unsigned program, |
517 bool using_bind_uniform, | |
518 int* base_uniform_index) { | 495 int* base_uniform_index) { |
519 static const char* uniforms[] = { | 496 static const char* uniforms[] = { |
520 "matrix", | 497 "matrix", |
521 "viewport", | 498 "viewport", |
522 "quad", | 499 "quad", |
523 "edge", | 500 "edge", |
524 "vertexTexTransform", | 501 "vertexTexTransform", |
525 }; | 502 }; |
526 int locations[arraysize(uniforms)]; | 503 int locations[arraysize(uniforms)]; |
527 | 504 |
528 GetProgramUniformLocations(context, | 505 GetProgramUniformLocations(context, |
529 program, | 506 program, |
530 arraysize(uniforms), | 507 arraysize(uniforms), |
531 uniforms, | 508 uniforms, |
532 locations, | 509 locations, |
533 using_bind_uniform, | |
534 base_uniform_index); | 510 base_uniform_index); |
535 matrix_location_ = locations[0]; | 511 matrix_location_ = locations[0]; |
536 viewport_location_ = locations[1]; | 512 viewport_location_ = locations[1]; |
537 quad_location_ = locations[2]; | 513 quad_location_ = locations[2]; |
538 edge_location_ = locations[3]; | 514 edge_location_ = locations[3]; |
539 vertex_tex_transform_location_ = locations[4]; | 515 vertex_tex_transform_location_ = locations[4]; |
540 } | 516 } |
541 | 517 |
542 std::string VertexShaderTileAA::GetShaderString() const { | 518 std::string VertexShaderTileAA::GetShaderString() const { |
543 return VERTEX_SHADER( | 519 return VERTEX_SHADER( |
(...skipping 24 matching lines...) Expand all Loading... |
568 } | 544 } |
569 ); // NOLINT(whitespace/parens) | 545 ); // NOLINT(whitespace/parens) |
570 } | 546 } |
571 | 547 |
572 VertexShaderVideoTransform::VertexShaderVideoTransform() | 548 VertexShaderVideoTransform::VertexShaderVideoTransform() |
573 : matrix_location_(-1), | 549 : matrix_location_(-1), |
574 tex_matrix_location_(-1) {} | 550 tex_matrix_location_(-1) {} |
575 | 551 |
576 void VertexShaderVideoTransform::Init(WebGraphicsContext3D* context, | 552 void VertexShaderVideoTransform::Init(WebGraphicsContext3D* context, |
577 unsigned program, | 553 unsigned program, |
578 bool using_bind_uniform, | |
579 int* base_uniform_index) { | 554 int* base_uniform_index) { |
580 static const char* uniforms[] = { | 555 static const char* uniforms[] = { |
581 "matrix", | 556 "matrix", |
582 "texMatrix", | 557 "texMatrix", |
583 }; | 558 }; |
584 int locations[arraysize(uniforms)]; | 559 int locations[arraysize(uniforms)]; |
585 | 560 |
586 GetProgramUniformLocations(context, | 561 GetProgramUniformLocations(context, |
587 program, | 562 program, |
588 arraysize(uniforms), | 563 arraysize(uniforms), |
589 uniforms, | 564 uniforms, |
590 locations, | 565 locations, |
591 using_bind_uniform, | |
592 base_uniform_index); | 566 base_uniform_index); |
593 matrix_location_ = locations[0]; | 567 matrix_location_ = locations[0]; |
594 tex_matrix_location_ = locations[1]; | 568 tex_matrix_location_ = locations[1]; |
595 } | 569 } |
596 | 570 |
597 std::string VertexShaderVideoTransform::GetShaderString() const { | 571 std::string VertexShaderVideoTransform::GetShaderString() const { |
598 return VERTEX_SHADER( | 572 return VERTEX_SHADER( |
599 attribute vec4 a_position; | 573 attribute vec4 a_position; |
600 attribute TexCoordPrecision vec2 a_texCoord; | 574 attribute TexCoordPrecision vec2 a_texCoord; |
601 uniform mat4 matrix; | 575 uniform mat4 matrix; |
602 uniform TexCoordPrecision mat4 texMatrix; | 576 uniform TexCoordPrecision mat4 texMatrix; |
603 varying TexCoordPrecision vec2 v_texCoord; | 577 varying TexCoordPrecision vec2 v_texCoord; |
604 void main() { | 578 void main() { |
605 gl_Position = matrix * a_position; | 579 gl_Position = matrix * a_position; |
606 v_texCoord = | 580 v_texCoord = |
607 vec2(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)); | 581 vec2(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)); |
608 } | 582 } |
609 ); // NOLINT(whitespace/parens) | 583 ); // NOLINT(whitespace/parens) |
610 } | 584 } |
611 | 585 |
612 FragmentTexAlphaBinding::FragmentTexAlphaBinding() | 586 FragmentTexAlphaBinding::FragmentTexAlphaBinding() |
613 : sampler_location_(-1), | 587 : sampler_location_(-1), |
614 alpha_location_(-1) {} | 588 alpha_location_(-1) {} |
615 | 589 |
616 void FragmentTexAlphaBinding::Init(WebGraphicsContext3D* context, | 590 void FragmentTexAlphaBinding::Init(WebGraphicsContext3D* context, |
617 unsigned program, | 591 unsigned program, |
618 bool using_bind_uniform, | |
619 int* base_uniform_index) { | 592 int* base_uniform_index) { |
620 static const char* uniforms[] = { | 593 static const char* uniforms[] = { |
621 "s_texture", | 594 "s_texture", |
622 "alpha", | 595 "alpha", |
623 }; | 596 }; |
624 int locations[arraysize(uniforms)]; | 597 int locations[arraysize(uniforms)]; |
625 | 598 |
626 GetProgramUniformLocations(context, | 599 GetProgramUniformLocations(context, |
627 program, | 600 program, |
628 arraysize(uniforms), | 601 arraysize(uniforms), |
629 uniforms, | 602 uniforms, |
630 locations, | 603 locations, |
631 using_bind_uniform, | |
632 base_uniform_index); | 604 base_uniform_index); |
633 sampler_location_ = locations[0]; | 605 sampler_location_ = locations[0]; |
634 alpha_location_ = locations[1]; | 606 alpha_location_ = locations[1]; |
635 } | 607 } |
636 | 608 |
637 FragmentTexColorMatrixAlphaBinding::FragmentTexColorMatrixAlphaBinding() | 609 FragmentTexColorMatrixAlphaBinding::FragmentTexColorMatrixAlphaBinding() |
638 : sampler_location_(-1), | 610 : sampler_location_(-1), |
639 alpha_location_(-1), | 611 alpha_location_(-1), |
640 color_matrix_location_(-1), | 612 color_matrix_location_(-1), |
641 color_offset_location_(-1) {} | 613 color_offset_location_(-1) {} |
642 | 614 |
643 void FragmentTexColorMatrixAlphaBinding::Init(WebGraphicsContext3D* context, | 615 void FragmentTexColorMatrixAlphaBinding::Init(WebGraphicsContext3D* context, |
644 unsigned program, | 616 unsigned program, |
645 bool using_bind_uniform, | |
646 int* base_uniform_index) { | 617 int* base_uniform_index) { |
647 static const char* uniforms[] = { | 618 static const char* uniforms[] = { |
648 "s_texture", | 619 "s_texture", |
649 "alpha", | 620 "alpha", |
650 "colorMatrix", | 621 "colorMatrix", |
651 "colorOffset", | 622 "colorOffset", |
652 }; | 623 }; |
653 int locations[arraysize(uniforms)]; | 624 int locations[arraysize(uniforms)]; |
654 | 625 |
655 GetProgramUniformLocations(context, | 626 GetProgramUniformLocations(context, |
656 program, | 627 program, |
657 arraysize(uniforms), | 628 arraysize(uniforms), |
658 uniforms, | 629 uniforms, |
659 locations, | 630 locations, |
660 using_bind_uniform, | |
661 base_uniform_index); | 631 base_uniform_index); |
662 sampler_location_ = locations[0]; | 632 sampler_location_ = locations[0]; |
663 alpha_location_ = locations[1]; | 633 alpha_location_ = locations[1]; |
664 color_matrix_location_ = locations[2]; | 634 color_matrix_location_ = locations[2]; |
665 color_offset_location_ = locations[3]; | 635 color_offset_location_ = locations[3]; |
666 } | 636 } |
667 | 637 |
668 FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() | 638 FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() |
669 : sampler_location_(-1) {} | 639 : sampler_location_(-1) {} |
670 | 640 |
671 void FragmentTexOpaqueBinding::Init(WebGraphicsContext3D* context, | 641 void FragmentTexOpaqueBinding::Init(WebGraphicsContext3D* context, |
672 unsigned program, | 642 unsigned program, |
673 bool using_bind_uniform, | |
674 int* base_uniform_index) { | 643 int* base_uniform_index) { |
675 static const char* uniforms[] = { | 644 static const char* uniforms[] = { |
676 "s_texture", | 645 "s_texture", |
677 }; | 646 }; |
678 int locations[arraysize(uniforms)]; | 647 int locations[arraysize(uniforms)]; |
679 | 648 |
680 GetProgramUniformLocations(context, | 649 GetProgramUniformLocations(context, |
681 program, | 650 program, |
682 arraysize(uniforms), | 651 arraysize(uniforms), |
683 uniforms, | 652 uniforms, |
684 locations, | 653 locations, |
685 using_bind_uniform, | |
686 base_uniform_index); | 654 base_uniform_index); |
687 sampler_location_ = locations[0]; | 655 sampler_location_ = locations[0]; |
688 } | 656 } |
689 | 657 |
690 FragmentShaderOESImageExternal::FragmentShaderOESImageExternal() | 658 FragmentShaderOESImageExternal::FragmentShaderOESImageExternal() |
691 : sampler_location_(-1) {} | 659 : sampler_location_(-1) {} |
692 | 660 |
693 void FragmentShaderOESImageExternal::Init(WebGraphicsContext3D* context, | 661 void FragmentShaderOESImageExternal::Init(WebGraphicsContext3D* context, |
694 unsigned program, | 662 unsigned program, |
695 bool using_bind_uniform, | |
696 int* base_uniform_index) { | 663 int* base_uniform_index) { |
697 static const char* uniforms[] = { | 664 static const char* uniforms[] = { |
698 "s_texture", | 665 "s_texture", |
699 }; | 666 }; |
700 int locations[arraysize(uniforms)]; | 667 int locations[arraysize(uniforms)]; |
701 | 668 |
702 GetProgramUniformLocations(context, | 669 GetProgramUniformLocations(context, |
703 program, | 670 program, |
704 arraysize(uniforms), | 671 arraysize(uniforms), |
705 uniforms, | 672 uniforms, |
706 locations, | 673 locations, |
707 using_bind_uniform, | |
708 base_uniform_index); | 674 base_uniform_index); |
709 sampler_location_ = locations[0]; | 675 sampler_location_ = locations[0]; |
710 } | 676 } |
711 | 677 |
712 std::string FragmentShaderOESImageExternal::GetShaderString( | 678 std::string FragmentShaderOESImageExternal::GetShaderString( |
713 TexCoordPrecision precision) const { | 679 TexCoordPrecision precision) const { |
714 // Cannot use the SHADER() macro because of the '#' char | 680 // Cannot use the SHADER() macro because of the '#' char |
715 return "#extension GL_OES_EGL_image_external : require\n" + | 681 return "#extension GL_OES_EGL_image_external : require\n" + |
716 FRAGMENT_SHADER( | 682 FRAGMENT_SHADER( |
717 precision mediump float; | 683 precision mediump float; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 ); // NOLINT(whitespace/parens) | 754 ); // NOLINT(whitespace/parens) |
789 } | 755 } |
790 | 756 |
791 FragmentTexBackgroundBinding::FragmentTexBackgroundBinding() | 757 FragmentTexBackgroundBinding::FragmentTexBackgroundBinding() |
792 : background_color_location_(-1), | 758 : background_color_location_(-1), |
793 sampler_location_(-1) { | 759 sampler_location_(-1) { |
794 } | 760 } |
795 | 761 |
796 void FragmentTexBackgroundBinding::Init(WebGraphicsContext3D* context, | 762 void FragmentTexBackgroundBinding::Init(WebGraphicsContext3D* context, |
797 unsigned program, | 763 unsigned program, |
798 bool using_bind_uniform, | |
799 int* base_uniform_index) { | 764 int* base_uniform_index) { |
800 static const char* uniforms[] = { | 765 static const char* uniforms[] = { |
801 "s_texture", | 766 "s_texture", |
802 "background_color", | 767 "background_color", |
803 }; | 768 }; |
804 int locations[arraysize(uniforms)]; | 769 int locations[arraysize(uniforms)]; |
805 | 770 |
806 GetProgramUniformLocations(context, | 771 GetProgramUniformLocations(context, |
807 program, | 772 program, |
808 arraysize(uniforms), | 773 arraysize(uniforms), |
809 uniforms, | 774 uniforms, |
810 locations, | 775 locations, |
811 using_bind_uniform, | |
812 base_uniform_index); | 776 base_uniform_index); |
813 | 777 |
814 sampler_location_ = locations[0]; | 778 sampler_location_ = locations[0]; |
815 DCHECK_NE(sampler_location_, -1); | 779 DCHECK_NE(sampler_location_, -1); |
816 | 780 |
817 background_color_location_ = locations[1]; | 781 background_color_location_ = locations[1]; |
818 DCHECK_NE(background_color_location_, -1); | 782 DCHECK_NE(background_color_location_, -1); |
819 } | 783 } |
820 | 784 |
821 std::string FragmentShaderTexBackgroundVaryingAlpha::GetShaderString( | 785 std::string FragmentShaderTexBackgroundVaryingAlpha::GetShaderString( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 } | 882 } |
919 ); // NOLINT(whitespace/parens) | 883 ); // NOLINT(whitespace/parens) |
920 } | 884 } |
921 | 885 |
922 FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA() | 886 FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA() |
923 : sampler_location_(-1), | 887 : sampler_location_(-1), |
924 alpha_location_(-1) {} | 888 alpha_location_(-1) {} |
925 | 889 |
926 void FragmentShaderRGBATexAlphaAA::Init(WebGraphicsContext3D* context, | 890 void FragmentShaderRGBATexAlphaAA::Init(WebGraphicsContext3D* context, |
927 unsigned program, | 891 unsigned program, |
928 bool using_bind_uniform, | |
929 int* base_uniform_index) { | 892 int* base_uniform_index) { |
930 static const char* uniforms[] = { | 893 static const char* uniforms[] = { |
931 "s_texture", | 894 "s_texture", |
932 "alpha", | 895 "alpha", |
933 }; | 896 }; |
934 int locations[arraysize(uniforms)]; | 897 int locations[arraysize(uniforms)]; |
935 | 898 |
936 GetProgramUniformLocations(context, | 899 GetProgramUniformLocations(context, |
937 program, | 900 program, |
938 arraysize(uniforms), | 901 arraysize(uniforms), |
939 uniforms, | 902 uniforms, |
940 locations, | 903 locations, |
941 using_bind_uniform, | |
942 base_uniform_index); | 904 base_uniform_index); |
943 sampler_location_ = locations[0]; | 905 sampler_location_ = locations[0]; |
944 alpha_location_ = locations[1]; | 906 alpha_location_ = locations[1]; |
945 } | 907 } |
946 | 908 |
947 std::string FragmentShaderRGBATexAlphaAA::GetShaderString( | 909 std::string FragmentShaderRGBATexAlphaAA::GetShaderString( |
948 TexCoordPrecision precision) const { | 910 TexCoordPrecision precision) const { |
949 return FRAGMENT_SHADER( | 911 return FRAGMENT_SHADER( |
950 precision mediump float; | 912 precision mediump float; |
951 uniform sampler2D s_texture; | 913 uniform sampler2D s_texture; |
(...skipping 11 matching lines...) Expand all Loading... |
963 ); // NOLINT(whitespace/parens) | 925 ); // NOLINT(whitespace/parens) |
964 } | 926 } |
965 | 927 |
966 FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding() | 928 FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding() |
967 : sampler_location_(-1), | 929 : sampler_location_(-1), |
968 alpha_location_(-1), | 930 alpha_location_(-1), |
969 fragment_tex_transform_location_(-1) {} | 931 fragment_tex_transform_location_(-1) {} |
970 | 932 |
971 void FragmentTexClampAlphaAABinding::Init(WebGraphicsContext3D* context, | 933 void FragmentTexClampAlphaAABinding::Init(WebGraphicsContext3D* context, |
972 unsigned program, | 934 unsigned program, |
973 bool using_bind_uniform, | |
974 int* base_uniform_index) { | 935 int* base_uniform_index) { |
975 static const char* uniforms[] = { | 936 static const char* uniforms[] = { |
976 "s_texture", | 937 "s_texture", |
977 "alpha", | 938 "alpha", |
978 "fragmentTexTransform", | 939 "fragmentTexTransform", |
979 }; | 940 }; |
980 int locations[arraysize(uniforms)]; | 941 int locations[arraysize(uniforms)]; |
981 | 942 |
982 GetProgramUniformLocations(context, | 943 GetProgramUniformLocations(context, |
983 program, | 944 program, |
984 arraysize(uniforms), | 945 arraysize(uniforms), |
985 uniforms, | 946 uniforms, |
986 locations, | 947 locations, |
987 using_bind_uniform, | |
988 base_uniform_index); | 948 base_uniform_index); |
989 sampler_location_ = locations[0]; | 949 sampler_location_ = locations[0]; |
990 alpha_location_ = locations[1]; | 950 alpha_location_ = locations[1]; |
991 fragment_tex_transform_location_ = locations[2]; | 951 fragment_tex_transform_location_ = locations[2]; |
992 } | 952 } |
993 | 953 |
994 std::string FragmentShaderRGBATexClampAlphaAA::GetShaderString( | 954 std::string FragmentShaderRGBATexClampAlphaAA::GetShaderString( |
995 TexCoordPrecision precision) const { | 955 TexCoordPrecision precision) const { |
996 return FRAGMENT_SHADER( | 956 return FRAGMENT_SHADER( |
997 precision mediump float; | 957 precision mediump float; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 } | 999 } |
1040 | 1000 |
1041 FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask() | 1001 FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask() |
1042 : sampler_location_(-1), | 1002 : sampler_location_(-1), |
1043 mask_sampler_location_(-1), | 1003 mask_sampler_location_(-1), |
1044 alpha_location_(-1), | 1004 alpha_location_(-1), |
1045 mask_tex_coord_scale_location_(-1) {} | 1005 mask_tex_coord_scale_location_(-1) {} |
1046 | 1006 |
1047 void FragmentShaderRGBATexAlphaMask::Init(WebGraphicsContext3D* context, | 1007 void FragmentShaderRGBATexAlphaMask::Init(WebGraphicsContext3D* context, |
1048 unsigned program, | 1008 unsigned program, |
1049 bool using_bind_uniform, | |
1050 int* base_uniform_index) { | 1009 int* base_uniform_index) { |
1051 static const char* uniforms[] = { | 1010 static const char* uniforms[] = { |
1052 "s_texture", | 1011 "s_texture", |
1053 "s_mask", | 1012 "s_mask", |
1054 "alpha", | 1013 "alpha", |
1055 "maskTexCoordScale", | 1014 "maskTexCoordScale", |
1056 "maskTexCoordOffset", | 1015 "maskTexCoordOffset", |
1057 }; | 1016 }; |
1058 int locations[arraysize(uniforms)]; | 1017 int locations[arraysize(uniforms)]; |
1059 | 1018 |
1060 GetProgramUniformLocations(context, | 1019 GetProgramUniformLocations(context, |
1061 program, | 1020 program, |
1062 arraysize(uniforms), | 1021 arraysize(uniforms), |
1063 uniforms, | 1022 uniforms, |
1064 locations, | 1023 locations, |
1065 using_bind_uniform, | |
1066 base_uniform_index); | 1024 base_uniform_index); |
1067 sampler_location_ = locations[0]; | 1025 sampler_location_ = locations[0]; |
1068 mask_sampler_location_ = locations[1]; | 1026 mask_sampler_location_ = locations[1]; |
1069 alpha_location_ = locations[2]; | 1027 alpha_location_ = locations[2]; |
1070 mask_tex_coord_scale_location_ = locations[3]; | 1028 mask_tex_coord_scale_location_ = locations[3]; |
1071 mask_tex_coord_offset_location_ = locations[4]; | 1029 mask_tex_coord_offset_location_ = locations[4]; |
1072 } | 1030 } |
1073 | 1031 |
1074 std::string FragmentShaderRGBATexAlphaMask::GetShaderString( | 1032 std::string FragmentShaderRGBATexAlphaMask::GetShaderString( |
1075 TexCoordPrecision precision) const { | 1033 TexCoordPrecision precision) const { |
(...skipping 18 matching lines...) Expand all Loading... |
1094 | 1052 |
1095 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() | 1053 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() |
1096 : sampler_location_(-1), | 1054 : sampler_location_(-1), |
1097 mask_sampler_location_(-1), | 1055 mask_sampler_location_(-1), |
1098 alpha_location_(-1), | 1056 alpha_location_(-1), |
1099 mask_tex_coord_scale_location_(-1), | 1057 mask_tex_coord_scale_location_(-1), |
1100 mask_tex_coord_offset_location_(-1) {} | 1058 mask_tex_coord_offset_location_(-1) {} |
1101 | 1059 |
1102 void FragmentShaderRGBATexAlphaMaskAA::Init(WebGraphicsContext3D* context, | 1060 void FragmentShaderRGBATexAlphaMaskAA::Init(WebGraphicsContext3D* context, |
1103 unsigned program, | 1061 unsigned program, |
1104 bool using_bind_uniform, | |
1105 int* base_uniform_index) { | 1062 int* base_uniform_index) { |
1106 static const char* uniforms[] = { | 1063 static const char* uniforms[] = { |
1107 "s_texture", | 1064 "s_texture", |
1108 "s_mask", | 1065 "s_mask", |
1109 "alpha", | 1066 "alpha", |
1110 "maskTexCoordScale", | 1067 "maskTexCoordScale", |
1111 "maskTexCoordOffset", | 1068 "maskTexCoordOffset", |
1112 }; | 1069 }; |
1113 int locations[arraysize(uniforms)]; | 1070 int locations[arraysize(uniforms)]; |
1114 | 1071 |
1115 GetProgramUniformLocations(context, | 1072 GetProgramUniformLocations(context, |
1116 program, | 1073 program, |
1117 arraysize(uniforms), | 1074 arraysize(uniforms), |
1118 uniforms, | 1075 uniforms, |
1119 locations, | 1076 locations, |
1120 using_bind_uniform, | |
1121 base_uniform_index); | 1077 base_uniform_index); |
1122 sampler_location_ = locations[0]; | 1078 sampler_location_ = locations[0]; |
1123 mask_sampler_location_ = locations[1]; | 1079 mask_sampler_location_ = locations[1]; |
1124 alpha_location_ = locations[2]; | 1080 alpha_location_ = locations[2]; |
1125 mask_tex_coord_scale_location_ = locations[3]; | 1081 mask_tex_coord_scale_location_ = locations[3]; |
1126 mask_tex_coord_offset_location_ = locations[4]; | 1082 mask_tex_coord_offset_location_ = locations[4]; |
1127 } | 1083 } |
1128 | 1084 |
1129 std::string FragmentShaderRGBATexAlphaMaskAA::GetShaderString( | 1085 std::string FragmentShaderRGBATexAlphaMaskAA::GetShaderString( |
1130 TexCoordPrecision precision) const { | 1086 TexCoordPrecision precision) const { |
(...skipping 26 matching lines...) Expand all Loading... |
1157 : sampler_location_(-1), | 1113 : sampler_location_(-1), |
1158 mask_sampler_location_(-1), | 1114 mask_sampler_location_(-1), |
1159 alpha_location_(-1), | 1115 alpha_location_(-1), |
1160 mask_tex_coord_scale_location_(-1), | 1116 mask_tex_coord_scale_location_(-1), |
1161 color_matrix_location_(-1), | 1117 color_matrix_location_(-1), |
1162 color_offset_location_(-1) {} | 1118 color_offset_location_(-1) {} |
1163 | 1119 |
1164 void FragmentShaderRGBATexAlphaMaskColorMatrixAA::Init( | 1120 void FragmentShaderRGBATexAlphaMaskColorMatrixAA::Init( |
1165 WebGraphicsContext3D* context, | 1121 WebGraphicsContext3D* context, |
1166 unsigned program, | 1122 unsigned program, |
1167 bool using_bind_uniform, | |
1168 int* base_uniform_index) { | 1123 int* base_uniform_index) { |
1169 static const char* uniforms[] = { | 1124 static const char* uniforms[] = { |
1170 "s_texture", | 1125 "s_texture", |
1171 "s_mask", | 1126 "s_mask", |
1172 "alpha", | 1127 "alpha", |
1173 "maskTexCoordScale", | 1128 "maskTexCoordScale", |
1174 "maskTexCoordOffset", | 1129 "maskTexCoordOffset", |
1175 "colorMatrix", | 1130 "colorMatrix", |
1176 "colorOffset", | 1131 "colorOffset", |
1177 }; | 1132 }; |
1178 int locations[arraysize(uniforms)]; | 1133 int locations[arraysize(uniforms)]; |
1179 | 1134 |
1180 GetProgramUniformLocations(context, | 1135 GetProgramUniformLocations(context, |
1181 program, | 1136 program, |
1182 arraysize(uniforms), | 1137 arraysize(uniforms), |
1183 uniforms, | 1138 uniforms, |
1184 locations, | 1139 locations, |
1185 using_bind_uniform, | |
1186 base_uniform_index); | 1140 base_uniform_index); |
1187 sampler_location_ = locations[0]; | 1141 sampler_location_ = locations[0]; |
1188 mask_sampler_location_ = locations[1]; | 1142 mask_sampler_location_ = locations[1]; |
1189 alpha_location_ = locations[2]; | 1143 alpha_location_ = locations[2]; |
1190 mask_tex_coord_scale_location_ = locations[3]; | 1144 mask_tex_coord_scale_location_ = locations[3]; |
1191 mask_tex_coord_offset_location_ = locations[4]; | 1145 mask_tex_coord_offset_location_ = locations[4]; |
1192 color_matrix_location_ = locations[5]; | 1146 color_matrix_location_ = locations[5]; |
1193 color_offset_location_ = locations[6]; | 1147 color_offset_location_ = locations[6]; |
1194 } | 1148 } |
1195 | 1149 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 FragmentShaderRGBATexAlphaColorMatrixAA:: | 1183 FragmentShaderRGBATexAlphaColorMatrixAA:: |
1230 FragmentShaderRGBATexAlphaColorMatrixAA() | 1184 FragmentShaderRGBATexAlphaColorMatrixAA() |
1231 : sampler_location_(-1), | 1185 : sampler_location_(-1), |
1232 alpha_location_(-1), | 1186 alpha_location_(-1), |
1233 color_matrix_location_(-1), | 1187 color_matrix_location_(-1), |
1234 color_offset_location_(-1) {} | 1188 color_offset_location_(-1) {} |
1235 | 1189 |
1236 void FragmentShaderRGBATexAlphaColorMatrixAA::Init( | 1190 void FragmentShaderRGBATexAlphaColorMatrixAA::Init( |
1237 WebGraphicsContext3D* context, | 1191 WebGraphicsContext3D* context, |
1238 unsigned program, | 1192 unsigned program, |
1239 bool using_bind_uniform, | |
1240 int* base_uniform_index) { | 1193 int* base_uniform_index) { |
1241 static const char* uniforms[] = { | 1194 static const char* uniforms[] = { |
1242 "s_texture", | 1195 "s_texture", |
1243 "alpha", | 1196 "alpha", |
1244 "colorMatrix", | 1197 "colorMatrix", |
1245 "colorOffset", | 1198 "colorOffset", |
1246 }; | 1199 }; |
1247 int locations[arraysize(uniforms)]; | 1200 int locations[arraysize(uniforms)]; |
1248 | 1201 |
1249 GetProgramUniformLocations(context, | 1202 GetProgramUniformLocations(context, |
1250 program, | 1203 program, |
1251 arraysize(uniforms), | 1204 arraysize(uniforms), |
1252 uniforms, | 1205 uniforms, |
1253 locations, | 1206 locations, |
1254 using_bind_uniform, | |
1255 base_uniform_index); | 1207 base_uniform_index); |
1256 sampler_location_ = locations[0]; | 1208 sampler_location_ = locations[0]; |
1257 alpha_location_ = locations[1]; | 1209 alpha_location_ = locations[1]; |
1258 color_matrix_location_ = locations[2]; | 1210 color_matrix_location_ = locations[2]; |
1259 color_offset_location_ = locations[3]; | 1211 color_offset_location_ = locations[3]; |
1260 } | 1212 } |
1261 | 1213 |
1262 std::string FragmentShaderRGBATexAlphaColorMatrixAA::GetShaderString( | 1214 std::string FragmentShaderRGBATexAlphaColorMatrixAA::GetShaderString( |
1263 TexCoordPrecision precision) const { | 1215 TexCoordPrecision precision) const { |
1264 return FRAGMENT_SHADER( | 1216 return FRAGMENT_SHADER( |
(...skipping 23 matching lines...) Expand all Loading... |
1288 FragmentShaderRGBATexAlphaMaskColorMatrix:: | 1240 FragmentShaderRGBATexAlphaMaskColorMatrix:: |
1289 FragmentShaderRGBATexAlphaMaskColorMatrix() | 1241 FragmentShaderRGBATexAlphaMaskColorMatrix() |
1290 : sampler_location_(-1), | 1242 : sampler_location_(-1), |
1291 mask_sampler_location_(-1), | 1243 mask_sampler_location_(-1), |
1292 alpha_location_(-1), | 1244 alpha_location_(-1), |
1293 mask_tex_coord_scale_location_(-1) {} | 1245 mask_tex_coord_scale_location_(-1) {} |
1294 | 1246 |
1295 void FragmentShaderRGBATexAlphaMaskColorMatrix::Init( | 1247 void FragmentShaderRGBATexAlphaMaskColorMatrix::Init( |
1296 WebGraphicsContext3D* context, | 1248 WebGraphicsContext3D* context, |
1297 unsigned program, | 1249 unsigned program, |
1298 bool using_bind_uniform, | |
1299 int* base_uniform_index) { | 1250 int* base_uniform_index) { |
1300 static const char* uniforms[] = { | 1251 static const char* uniforms[] = { |
1301 "s_texture", | 1252 "s_texture", |
1302 "s_mask", | 1253 "s_mask", |
1303 "alpha", | 1254 "alpha", |
1304 "maskTexCoordScale", | 1255 "maskTexCoordScale", |
1305 "maskTexCoordOffset", | 1256 "maskTexCoordOffset", |
1306 "colorMatrix", | 1257 "colorMatrix", |
1307 "colorOffset", | 1258 "colorOffset", |
1308 }; | 1259 }; |
1309 int locations[arraysize(uniforms)]; | 1260 int locations[arraysize(uniforms)]; |
1310 | 1261 |
1311 GetProgramUniformLocations(context, | 1262 GetProgramUniformLocations(context, |
1312 program, | 1263 program, |
1313 arraysize(uniforms), | 1264 arraysize(uniforms), |
1314 uniforms, | 1265 uniforms, |
1315 locations, | 1266 locations, |
1316 using_bind_uniform, | |
1317 base_uniform_index); | 1267 base_uniform_index); |
1318 sampler_location_ = locations[0]; | 1268 sampler_location_ = locations[0]; |
1319 mask_sampler_location_ = locations[1]; | 1269 mask_sampler_location_ = locations[1]; |
1320 alpha_location_ = locations[2]; | 1270 alpha_location_ = locations[2]; |
1321 mask_tex_coord_scale_location_ = locations[3]; | 1271 mask_tex_coord_scale_location_ = locations[3]; |
1322 mask_tex_coord_offset_location_ = locations[4]; | 1272 mask_tex_coord_offset_location_ = locations[4]; |
1323 color_matrix_location_ = locations[5]; | 1273 color_matrix_location_ = locations[5]; |
1324 color_offset_location_ = locations[6]; | 1274 color_offset_location_ = locations[6]; |
1325 } | 1275 } |
1326 | 1276 |
(...skipping 28 matching lines...) Expand all Loading... |
1355 FragmentShaderYUVVideo::FragmentShaderYUVVideo() | 1305 FragmentShaderYUVVideo::FragmentShaderYUVVideo() |
1356 : y_texture_location_(-1), | 1306 : y_texture_location_(-1), |
1357 u_texture_location_(-1), | 1307 u_texture_location_(-1), |
1358 v_texture_location_(-1), | 1308 v_texture_location_(-1), |
1359 alpha_location_(-1), | 1309 alpha_location_(-1), |
1360 yuv_matrix_location_(-1), | 1310 yuv_matrix_location_(-1), |
1361 yuv_adj_location_(-1) {} | 1311 yuv_adj_location_(-1) {} |
1362 | 1312 |
1363 void FragmentShaderYUVVideo::Init(WebGraphicsContext3D* context, | 1313 void FragmentShaderYUVVideo::Init(WebGraphicsContext3D* context, |
1364 unsigned program, | 1314 unsigned program, |
1365 bool using_bind_uniform, | |
1366 int* base_uniform_index) { | 1315 int* base_uniform_index) { |
1367 static const char* uniforms[] = { | 1316 static const char* uniforms[] = { |
1368 "y_texture", | 1317 "y_texture", |
1369 "u_texture", | 1318 "u_texture", |
1370 "v_texture", | 1319 "v_texture", |
1371 "alpha", | 1320 "alpha", |
1372 "yuv_matrix", | 1321 "yuv_matrix", |
1373 "yuv_adj", | 1322 "yuv_adj", |
1374 }; | 1323 }; |
1375 int locations[arraysize(uniforms)]; | 1324 int locations[arraysize(uniforms)]; |
1376 | 1325 |
1377 GetProgramUniformLocations(context, | 1326 GetProgramUniformLocations(context, |
1378 program, | 1327 program, |
1379 arraysize(uniforms), | 1328 arraysize(uniforms), |
1380 uniforms, | 1329 uniforms, |
1381 locations, | 1330 locations, |
1382 using_bind_uniform, | |
1383 base_uniform_index); | 1331 base_uniform_index); |
1384 y_texture_location_ = locations[0]; | 1332 y_texture_location_ = locations[0]; |
1385 u_texture_location_ = locations[1]; | 1333 u_texture_location_ = locations[1]; |
1386 v_texture_location_ = locations[2]; | 1334 v_texture_location_ = locations[2]; |
1387 alpha_location_ = locations[3]; | 1335 alpha_location_ = locations[3]; |
1388 yuv_matrix_location_ = locations[4]; | 1336 yuv_matrix_location_ = locations[4]; |
1389 yuv_adj_location_ = locations[5]; | 1337 yuv_adj_location_ = locations[5]; |
1390 } | 1338 } |
1391 | 1339 |
1392 std::string FragmentShaderYUVVideo::GetShaderString( | 1340 std::string FragmentShaderYUVVideo::GetShaderString( |
(...skipping 24 matching lines...) Expand all Loading... |
1417 u_texture_location_(-1), | 1365 u_texture_location_(-1), |
1418 v_texture_location_(-1), | 1366 v_texture_location_(-1), |
1419 a_texture_location_(-1), | 1367 a_texture_location_(-1), |
1420 alpha_location_(-1), | 1368 alpha_location_(-1), |
1421 yuv_matrix_location_(-1), | 1369 yuv_matrix_location_(-1), |
1422 yuv_adj_location_(-1) { | 1370 yuv_adj_location_(-1) { |
1423 } | 1371 } |
1424 | 1372 |
1425 void FragmentShaderYUVAVideo::Init(WebGraphicsContext3D* context, | 1373 void FragmentShaderYUVAVideo::Init(WebGraphicsContext3D* context, |
1426 unsigned program, | 1374 unsigned program, |
1427 bool using_bind_uniform, | |
1428 int* base_uniform_index) { | 1375 int* base_uniform_index) { |
1429 static const char* uniforms[] = { | 1376 static const char* uniforms[] = { |
1430 "y_texture", | 1377 "y_texture", |
1431 "u_texture", | 1378 "u_texture", |
1432 "v_texture", | 1379 "v_texture", |
1433 "a_texture", | 1380 "a_texture", |
1434 "alpha", | 1381 "alpha", |
1435 "cc_matrix", | 1382 "cc_matrix", |
1436 "yuv_adj", | 1383 "yuv_adj", |
1437 }; | 1384 }; |
1438 int locations[arraysize(uniforms)]; | 1385 int locations[arraysize(uniforms)]; |
1439 | 1386 |
1440 GetProgramUniformLocations(context, | 1387 GetProgramUniformLocations(context, |
1441 program, | 1388 program, |
1442 arraysize(uniforms), | 1389 arraysize(uniforms), |
1443 uniforms, | 1390 uniforms, |
1444 locations, | 1391 locations, |
1445 using_bind_uniform, | |
1446 base_uniform_index); | 1392 base_uniform_index); |
1447 y_texture_location_ = locations[0]; | 1393 y_texture_location_ = locations[0]; |
1448 u_texture_location_ = locations[1]; | 1394 u_texture_location_ = locations[1]; |
1449 v_texture_location_ = locations[2]; | 1395 v_texture_location_ = locations[2]; |
1450 a_texture_location_ = locations[3]; | 1396 a_texture_location_ = locations[3]; |
1451 alpha_location_ = locations[4]; | 1397 alpha_location_ = locations[4]; |
1452 yuv_matrix_location_ = locations[5]; | 1398 yuv_matrix_location_ = locations[5]; |
1453 yuv_adj_location_ = locations[6]; | 1399 yuv_adj_location_ = locations[6]; |
1454 } | 1400 } |
1455 | 1401 |
(...skipping 20 matching lines...) Expand all Loading... |
1476 gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw); | 1422 gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw); |
1477 } | 1423 } |
1478 ); // NOLINT(whitespace/parens) | 1424 ); // NOLINT(whitespace/parens) |
1479 } | 1425 } |
1480 | 1426 |
1481 FragmentShaderColor::FragmentShaderColor() | 1427 FragmentShaderColor::FragmentShaderColor() |
1482 : color_location_(-1) {} | 1428 : color_location_(-1) {} |
1483 | 1429 |
1484 void FragmentShaderColor::Init(WebGraphicsContext3D* context, | 1430 void FragmentShaderColor::Init(WebGraphicsContext3D* context, |
1485 unsigned program, | 1431 unsigned program, |
1486 bool using_bind_uniform, | |
1487 int* base_uniform_index) { | 1432 int* base_uniform_index) { |
1488 static const char* uniforms[] = { | 1433 static const char* uniforms[] = { |
1489 "color", | 1434 "color", |
1490 }; | 1435 }; |
1491 int locations[arraysize(uniforms)]; | 1436 int locations[arraysize(uniforms)]; |
1492 | 1437 |
1493 GetProgramUniformLocations(context, | 1438 GetProgramUniformLocations(context, |
1494 program, | 1439 program, |
1495 arraysize(uniforms), | 1440 arraysize(uniforms), |
1496 uniforms, | 1441 uniforms, |
1497 locations, | 1442 locations, |
1498 using_bind_uniform, | |
1499 base_uniform_index); | 1443 base_uniform_index); |
1500 color_location_ = locations[0]; | 1444 color_location_ = locations[0]; |
1501 } | 1445 } |
1502 | 1446 |
1503 std::string FragmentShaderColor::GetShaderString( | 1447 std::string FragmentShaderColor::GetShaderString( |
1504 TexCoordPrecision precision) const { | 1448 TexCoordPrecision precision) const { |
1505 return FRAGMENT_SHADER( | 1449 return FRAGMENT_SHADER( |
1506 precision mediump float; | 1450 precision mediump float; |
1507 uniform vec4 color; | 1451 uniform vec4 color; |
1508 void main() { | 1452 void main() { |
1509 gl_FragColor = color; | 1453 gl_FragColor = color; |
1510 } | 1454 } |
1511 ); // NOLINT(whitespace/parens) | 1455 ); // NOLINT(whitespace/parens) |
1512 } | 1456 } |
1513 | 1457 |
1514 FragmentShaderColorAA::FragmentShaderColorAA() | 1458 FragmentShaderColorAA::FragmentShaderColorAA() |
1515 : color_location_(-1) {} | 1459 : color_location_(-1) {} |
1516 | 1460 |
1517 void FragmentShaderColorAA::Init(WebGraphicsContext3D* context, | 1461 void FragmentShaderColorAA::Init(WebGraphicsContext3D* context, |
1518 unsigned program, | 1462 unsigned program, |
1519 bool using_bind_uniform, | |
1520 int* base_uniform_index) { | 1463 int* base_uniform_index) { |
1521 static const char* uniforms[] = { | 1464 static const char* uniforms[] = { |
1522 "color", | 1465 "color", |
1523 }; | 1466 }; |
1524 int locations[arraysize(uniforms)]; | 1467 int locations[arraysize(uniforms)]; |
1525 | 1468 |
1526 GetProgramUniformLocations(context, | 1469 GetProgramUniformLocations(context, |
1527 program, | 1470 program, |
1528 arraysize(uniforms), | 1471 arraysize(uniforms), |
1529 uniforms, | 1472 uniforms, |
1530 locations, | 1473 locations, |
1531 using_bind_uniform, | |
1532 base_uniform_index); | 1474 base_uniform_index); |
1533 color_location_ = locations[0]; | 1475 color_location_ = locations[0]; |
1534 } | 1476 } |
1535 | 1477 |
1536 std::string FragmentShaderColorAA::GetShaderString( | 1478 std::string FragmentShaderColorAA::GetShaderString( |
1537 TexCoordPrecision precision) const { | 1479 TexCoordPrecision precision) const { |
1538 return FRAGMENT_SHADER( | 1480 return FRAGMENT_SHADER( |
1539 precision mediump float; | 1481 precision mediump float; |
1540 uniform vec4 color; | 1482 uniform vec4 color; |
1541 varying vec4 edge_dist[2]; // 8 edge distances. | 1483 varying vec4 edge_dist[2]; // 8 edge distances. |
1542 | 1484 |
1543 void main() { | 1485 void main() { |
1544 vec4 d4 = min(edge_dist[0], edge_dist[1]); | 1486 vec4 d4 = min(edge_dist[0], edge_dist[1]); |
1545 vec2 d2 = min(d4.xz, d4.yw); | 1487 vec2 d2 = min(d4.xz, d4.yw); |
1546 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); | 1488 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); |
1547 gl_FragColor = color * aa; | 1489 gl_FragColor = color * aa; |
1548 } | 1490 } |
1549 ); // NOLINT(whitespace/parens) | 1491 ); // NOLINT(whitespace/parens) |
1550 } | 1492 } |
1551 | 1493 |
1552 FragmentShaderCheckerboard::FragmentShaderCheckerboard() | 1494 FragmentShaderCheckerboard::FragmentShaderCheckerboard() |
1553 : alpha_location_(-1), | 1495 : alpha_location_(-1), |
1554 tex_transform_location_(-1), | 1496 tex_transform_location_(-1), |
1555 frequency_location_(-1) {} | 1497 frequency_location_(-1) {} |
1556 | 1498 |
1557 void FragmentShaderCheckerboard::Init(WebGraphicsContext3D* context, | 1499 void FragmentShaderCheckerboard::Init(WebGraphicsContext3D* context, |
1558 unsigned program, | 1500 unsigned program, |
1559 bool using_bind_uniform, | |
1560 int* base_uniform_index) { | 1501 int* base_uniform_index) { |
1561 static const char* uniforms[] = { | 1502 static const char* uniforms[] = { |
1562 "alpha", | 1503 "alpha", |
1563 "texTransform", | 1504 "texTransform", |
1564 "frequency", | 1505 "frequency", |
1565 "color", | 1506 "color", |
1566 }; | 1507 }; |
1567 int locations[arraysize(uniforms)]; | 1508 int locations[arraysize(uniforms)]; |
1568 | 1509 |
1569 GetProgramUniformLocations(context, | 1510 GetProgramUniformLocations(context, |
1570 program, | 1511 program, |
1571 arraysize(uniforms), | 1512 arraysize(uniforms), |
1572 uniforms, | 1513 uniforms, |
1573 locations, | 1514 locations, |
1574 using_bind_uniform, | |
1575 base_uniform_index); | 1515 base_uniform_index); |
1576 alpha_location_ = locations[0]; | 1516 alpha_location_ = locations[0]; |
1577 tex_transform_location_ = locations[1]; | 1517 tex_transform_location_ = locations[1]; |
1578 frequency_location_ = locations[2]; | 1518 frequency_location_ = locations[2]; |
1579 color_location_ = locations[3]; | 1519 color_location_ = locations[3]; |
1580 } | 1520 } |
1581 | 1521 |
1582 std::string FragmentShaderCheckerboard::GetShaderString( | 1522 std::string FragmentShaderCheckerboard::GetShaderString( |
1583 TexCoordPrecision precision) const { | 1523 TexCoordPrecision precision) const { |
1584 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" | 1524 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" |
(...skipping 12 matching lines...) Expand all Loading... |
1597 vec2 texCoord = | 1537 vec2 texCoord = |
1598 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; | 1538 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; |
1599 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); | 1539 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
1600 float picker = abs(coord.x - coord.y); // NOLINT | 1540 float picker = abs(coord.x - coord.y); // NOLINT |
1601 gl_FragColor = mix(color1, color2, picker) * alpha; | 1541 gl_FragColor = mix(color1, color2, picker) * alpha; |
1602 } | 1542 } |
1603 ); // NOLINT(whitespace/parens) | 1543 ); // NOLINT(whitespace/parens) |
1604 } | 1544 } |
1605 | 1545 |
1606 } // namespace cc | 1546 } // namespace cc |
OLD | NEW |