Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: cc/shader.cc

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

Powered by Google App Engine
This is Rietveld 408576698