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

Side by Side Diff: cc/output/shader.cc

Issue 12764030: cc: Chromify shader.cc and shader.h (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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
« no previous file with comments | « cc/output/shader.h ('k') | no next file » | 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 "cc/output/shader.h" 5 #include "cc/output/shader.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
10 10
11 #define SHADER0(Src) #Src 11 #define SHADER0(Src) #Src
12 #define SHADER(Src) SHADER0(Src) 12 #define SHADER(Src) SHADER0(Src)
13 13
14 using WebKit::WebGraphicsContext3D; 14 using WebKit::WebGraphicsContext3D;
15 15
16 namespace cc { 16 namespace cc {
17 17
18 namespace { 18 namespace {
19 19
20 static void getProgramUniformLocations(WebGraphicsContext3D* context, unsigned p rogram, const char** shaderUniforms, size_t count, size_t maxLocations, int* loc ations, bool usingBindUniform, int* baseUniformIndex) 20 static void GetProgramUniformLocations(WebGraphicsContext3D* context,
21 { 21 unsigned program,
22 for (size_t uniformIndex = 0; uniformIndex < count; uniformIndex ++) { 22 const char** shader_uniforms,
23 DCHECK(uniformIndex < maxLocations); 23 size_t count,
24 24 size_t max_locations,
25 if (usingBindUniform) { 25 int* locations,
26 locations[uniformIndex] = (*baseUniformIndex)++; 26 bool using_bind_uniform,
27 context->bindUniformLocationCHROMIUM(program, locations[uniformIndex ], shaderUniforms[uniformIndex]); 27 int* base_uniform_index) {
28 } else 28 for (size_t uniform_index = 0; uniform_index < count; uniform_index ++) {
29 locations[uniformIndex] = context->getUniformLocation(program, shade rUniforms[uniformIndex]); 29 DCHECK(uniform_index < max_locations);
30 } 30
31 if (using_bind_uniform) {
32 locations[uniform_index] = (*base_uniform_index)++;
33 context->bindUniformLocationCHROMIUM(program,
34 locations[uniform_index],
35 shader_uniforms[uniform_index]);
36 } else {
37 locations[uniform_index] =
38 context->getUniformLocation(program, shader_uniforms[uniform_index]);
39 }
40 }
31 } 41 }
32 42
33 } 43 }
34 44
35 VertexShaderPosTex::VertexShaderPosTex() 45 VertexShaderPosTex::VertexShaderPosTex()
36 : m_matrixLocation(-1) 46 : matrix_location_(-1) { }
37 { 47
38 } 48 void VertexShaderPosTex::Init(WebGraphicsContext3D* context,
39 49 unsigned program,
40 void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program, b ool usingBindUniform, int* baseUniformIndex) 50 bool using_bind_uniform,
41 { 51 int* base_uniform_index) {
42 static const char* shaderUniforms[] = { 52 static const char* shader_uniforms[] = {
43 "matrix", 53 "matrix",
44 }; 54 };
45 int locations[1]; 55 int locations[1];
46 56
47 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 57 GetProgramUniformLocations(context,
48 58 program,
49 m_matrixLocation = locations[0]; 59 shader_uniforms,
50 DCHECK(m_matrixLocation != -1); 60 arraysize(shader_uniforms),
51 } 61 arraysize(locations),
52 62 locations,
53 std::string VertexShaderPosTex::getShaderString() const 63 using_bind_uniform,
54 { 64 base_uniform_index);
55 return SHADER( 65
56 attribute vec4 a_position; 66 matrix_location_ = locations[0];
57 attribute vec2 a_texCoord; 67 DCHECK(matrix_location_ != -1);
58 uniform mat4 matrix; 68 }
59 varying vec2 v_texCoord; 69
60 void main() 70 std::string VertexShaderPosTex::GetShaderString() const {
61 { 71 return SHADER(
62 gl_Position = matrix * a_position; 72 attribute vec4 a_position;
63 v_texCoord = a_texCoord; 73 attribute vec2 a_texCoord;
64 } 74 uniform mat4 matrix;
65 ); 75 varying vec2 v_texCoord;
76 void main() {
77 gl_Position = matrix * a_position;
78 v_texCoord = a_texCoord;
79 }
80 );
66 } 81 }
67 82
68 VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() 83 VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch()
69 : m_matrixLocation(-1) 84 : matrix_location_(-1),
70 , m_texScaleLocation(-1) 85 tex_scale_location_(-1) { }
71 { 86
72 } 87 void VertexShaderPosTexYUVStretch::Init(WebGraphicsContext3D* context,
73 88 unsigned program,
74 void VertexShaderPosTexYUVStretch::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex) 89 bool using_bind_uniform,
75 { 90 int* base_uniform_index) {
76 static const char* shaderUniforms[] = { 91 static const char* shader_uniforms[] = {
77 "matrix", 92 "matrix",
78 "texScale", 93 "texScale",
79 }; 94 };
80 int locations[2]; 95 int locations[2];
81 96
82 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 97 GetProgramUniformLocations(context,
83 98 program,
84 m_matrixLocation = locations[0]; 99 shader_uniforms,
85 m_texScaleLocation = locations[1]; 100 arraysize(shader_uniforms),
86 DCHECK(m_matrixLocation != -1 && m_texScaleLocation != -1); 101 arraysize(locations),
87 } 102 locations,
88 103 using_bind_uniform,
89 std::string VertexShaderPosTexYUVStretch::getShaderString() const 104 base_uniform_index);
90 { 105
91 return SHADER( 106 matrix_location_ = locations[0];
92 precision mediump float; 107 tex_scale_location_ = locations[1];
93 attribute vec4 a_position; 108 DCHECK(matrix_location_ != -1 && tex_scale_location_ != -1);
94 attribute vec2 a_texCoord; 109 }
95 uniform mat4 matrix; 110
96 varying vec2 v_texCoord; 111 std::string VertexShaderPosTexYUVStretch::GetShaderString() const {
97 uniform vec2 texScale; 112 return SHADER(
98 void main() 113 precision mediump float;
99 { 114 attribute vec4 a_position;
100 gl_Position = matrix * a_position; 115 attribute vec2 a_texCoord;
101 v_texCoord = a_texCoord * texScale; 116 uniform mat4 matrix;
102 } 117 varying vec2 v_texCoord;
103 ); 118 uniform vec2 texScale;
119 void main() {
120 gl_Position = matrix * a_position;
121 v_texCoord = a_texCoord * texScale;
122 }
123 );
104 } 124 }
105 125
106 VertexShaderPos::VertexShaderPos() 126 VertexShaderPos::VertexShaderPos()
107 : m_matrixLocation(-1) 127 : matrix_location_(-1) { }
108 { 128
109 } 129 void VertexShaderPos::Init(WebGraphicsContext3D* context,
110 130 unsigned program,
111 void VertexShaderPos::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex) 131 bool using_bind_uniform,
112 { 132 int* base_uniform_index) {
113 static const char* shaderUniforms[] = { 133 static const char* shader_uniforms[] = {
114 "matrix", 134 "matrix",
115 }; 135 };
116 int locations[1]; 136 int locations[1];
117 137
118 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 138 GetProgramUniformLocations(context,
119 139 program,
120 m_matrixLocation = locations[0]; 140 shader_uniforms,
121 DCHECK(m_matrixLocation != -1); 141 arraysize(shader_uniforms),
122 } 142 arraysize(locations),
123 143 locations,
124 std::string VertexShaderPos::getShaderString() const 144 using_bind_uniform,
125 { 145 base_uniform_index);
126 return SHADER( 146
127 attribute vec4 a_position; 147 matrix_location_ = locations[0];
128 uniform mat4 matrix; 148 DCHECK(matrix_location_ != -1);
129 void main() 149 }
130 { 150
131 gl_Position = matrix * a_position; 151 std::string VertexShaderPos::GetShaderString() const {
132 } 152 return SHADER(
133 ); 153 attribute vec4 a_position;
154 uniform mat4 matrix;
155 void main() {
156 gl_Position = matrix * a_position;
157 }
158 );
134 } 159 }
135 160
136 VertexShaderPosTexTransform::VertexShaderPosTexTransform() 161 VertexShaderPosTexTransform::VertexShaderPosTexTransform()
137 : m_matrixLocation(-1) 162 : matrix_location_(-1),
138 , m_texTransformLocation(-1) 163 tex_transform_location_(-1),
139 , m_vertexOpacityLocation(-1) 164 vertex_opacity_location_(-1) { }
140 { 165
141 } 166 void VertexShaderPosTexTransform::Init(WebGraphicsContext3D* context,
142 167 unsigned program,
143 void VertexShaderPosTexTransform::init(WebGraphicsContext3D* context, unsigned p rogram, bool usingBindUniform, int* baseUniformIndex) 168 bool using_bind_uniform,
144 { 169 int* base_uniform_index) {
145 static const char* shaderUniforms[] = { 170 static const char* shader_uniforms[] = {
146 "matrix", 171 "matrix",
147 "texTransform", 172 "texTransform",
148 "opacity", 173 "opacity",
149 }; 174 };
150 int locations[3]; 175 int locations[3];
151 176
152 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 177 GetProgramUniformLocations(context,
153 178 program,
154 m_matrixLocation = locations[0]; 179 shader_uniforms,
155 m_texTransformLocation = locations[1]; 180 arraysize(shader_uniforms),
156 m_vertexOpacityLocation = locations[2]; 181 arraysize(locations),
157 DCHECK(m_matrixLocation != -1 && m_texTransformLocation != -1 && m_vertexOpa cityLocation != -1); 182 locations,
158 } 183 using_bind_uniform,
159 184 base_uniform_index);
160 std::string VertexShaderPosTexTransform::getShaderString() const 185
161 { 186 matrix_location_ = locations[0];
162 return SHADER( 187 tex_transform_location_ = locations[1];
163 attribute vec4 a_position; 188 vertex_opacity_location_ = locations[2];
164 attribute vec2 a_texCoord; 189 DCHECK(matrix_location_ != -1 && tex_transform_location_ != -1 &&
165 attribute float a_index; 190 vertex_opacity_location_ != -1);
166 uniform mat4 matrix[8]; 191 }
167 uniform vec4 texTransform[8]; 192
168 uniform float opacity[32]; 193 std::string VertexShaderPosTexTransform::GetShaderString() const {
169 varying vec2 v_texCoord; 194 return SHADER(
170 varying float v_alpha; 195 attribute vec4 a_position;
171 void main() 196 attribute vec2 a_texCoord;
172 { 197 attribute float a_index;
173 gl_Position = matrix[int(a_index * 0.25)] * a_position; 198 uniform mat4 matrix[8];
174 vec4 texTrans = texTransform[int(a_index * 0.25)]; 199 uniform vec4 texTransform[8];
175 v_texCoord = a_texCoord * texTrans.zw + texTrans.xy; 200 uniform float opacity[32];
176 v_alpha = opacity[int(a_index)]; 201 varying vec2 v_texCoord;
177 } 202 varying float v_alpha;
178 ); 203 void main() {
179 } 204 gl_Position = matrix[int(a_index * 0.25)] * a_position;
180 205 vec4 texTrans = texTransform[int(a_index * 0.25)];
181 std::string VertexShaderPosTexTransformFlip::getShaderString() const 206 v_texCoord = a_texCoord * texTrans.zw + texTrans.xy;
182 { 207 v_alpha = opacity[int(a_index)];
183 return SHADER( 208 }
184 attribute vec4 a_position; 209 );
185 attribute vec2 a_texCoord; 210 }
186 attribute float a_index; 211
187 uniform mat4 matrix[8]; 212 std::string VertexShaderPosTexTransformFlip::GetShaderString() const {
188 uniform vec4 texTransform[8]; 213 return SHADER(
189 uniform float opacity[32]; 214 attribute vec4 a_position;
190 varying vec2 v_texCoord; 215 attribute vec2 a_texCoord;
191 varying float v_alpha; 216 attribute float a_index;
192 void main() 217 uniform mat4 matrix[8];
193 { 218 uniform vec4 texTransform[8];
194 gl_Position = matrix[int(a_index * 0.25)] * a_position; 219 uniform float opacity[32];
195 vec4 texTrans = texTransform[int(a_index * 0.25)]; 220 varying vec2 v_texCoord;
196 v_texCoord = a_texCoord * texTrans.zw + texTrans.xy; 221 varying float v_alpha;
197 v_texCoord.y = 1.0 - v_texCoord.y; 222 void main() {
198 v_alpha = opacity[int(a_index)]; 223 gl_Position = matrix[int(a_index * 0.25)] * a_position;
199 } 224 vec4 texTrans = texTransform[int(a_index * 0.25)];
200 ); 225 v_texCoord = a_texCoord * texTrans.zw + texTrans.xy;
201 } 226 v_texCoord.y = 1.0 - v_texCoord.y;
202 227 v_alpha = opacity[int(a_index)];
203 std::string VertexShaderPosTexIdentity::getShaderString() const 228 }
204 { 229 );
205 return SHADER( 230 }
206 attribute vec4 a_position; 231
207 varying vec2 v_texCoord; 232 std::string VertexShaderPosTexIdentity::GetShaderString() const {
208 void main() 233 return SHADER(
209 { 234 attribute vec4 a_position;
210 gl_Position = a_position; 235 varying vec2 v_texCoord;
211 v_texCoord = (a_position.xy + vec2(1.0)) * 0.5; 236 void main() {
212 } 237 gl_Position = a_position;
213 ); 238 v_texCoord = (a_position.xy + vec2(1.0)) * 0.5;
239 }
240 );
214 } 241 }
215 242
216 VertexShaderQuad::VertexShaderQuad() 243 VertexShaderQuad::VertexShaderQuad()
217 : m_matrixLocation(-1) 244 : matrix_location_(-1),
218 , m_pointLocation(-1) 245 point_location_(-1),
219 , m_texScaleLocation(-1) 246 tex_scale_location_(-1) { }
220 { 247
221 } 248 void VertexShaderQuad::Init(WebGraphicsContext3D* context,
222 249 unsigned program,
223 void VertexShaderQuad::init(WebGraphicsContext3D* context, unsigned program, boo l usingBindUniform, int* baseUniformIndex) 250 bool using_bind_uniform,
224 { 251 int* base_uniform_index) {
225 // TODO(reveman): Some uniform names are causing drawing artifact. 252 // TODO(reveman): Some uniform names are causing drawing artifact.
226 // crbug.com/223014 253 // crbug.com/223014
227 static const char* shaderUniforms[] = { 254 static const char* shader_uniforms[] = {
228 "matrix", 255 "matrix",
229 "point_bug223014", 256 "point_bug223014",
230 "texScale", 257 "texScale",
231 }; 258 };
232 int locations[3]; 259 int locations[3];
233 260
234 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 261 GetProgramUniformLocations(context,
235 262 program,
236 m_matrixLocation = locations[0]; 263 shader_uniforms,
237 m_pointLocation = locations[1]; 264 arraysize(shader_uniforms),
238 m_texScaleLocation = locations[2]; 265 arraysize(locations),
239 DCHECK_NE(m_matrixLocation, -1); 266 locations,
240 DCHECK_NE(m_pointLocation, -1); 267 using_bind_uniform,
241 DCHECK_NE(m_texScaleLocation, -1); 268 base_uniform_index);
242 } 269
243 270 matrix_location_ = locations[0];
244 std::string VertexShaderQuad::getShaderString() const 271 point_location_ = locations[1];
245 { 272 tex_scale_location_ = locations[2];
246 return SHADER( 273 DCHECK_NE(matrix_location_, -1);
247 attribute vec4 a_position; 274 DCHECK_NE(point_location_, -1);
248 attribute vec2 a_texCoord; 275 DCHECK_NE(tex_scale_location_, -1);
249 uniform mat4 matrix; 276 }
250 uniform vec2 point_bug223014[4]; 277
251 uniform vec2 texScale; 278 std::string VertexShaderQuad::GetShaderString() const {
252 varying vec2 v_texCoord; 279 return SHADER(
253 void main() 280 attribute vec4 a_position;
254 { 281 attribute vec2 a_texCoord;
255 vec2 complement = abs(a_texCoord - 1.0); 282 uniform mat4 matrix;
256 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w); 283 uniform vec2 point_bug223014[4];
257 pos.xy += (complement.x * complement.y) * point_bug223014[0]; 284 uniform vec2 texScale;
258 pos.xy += (a_texCoord.x * complement.y) * point_bug223014[1]; 285 varying vec2 v_texCoord;
259 pos.xy += (a_texCoord.x * a_texCoord.y) * point_bug223014[2]; 286 void main() {
260 pos.xy += (complement.x * a_texCoord.y) * point_bug223014[3]; 287 vec2 complement = abs(a_texCoord - 1.0);
261 gl_Position = matrix * pos; 288 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w);
262 v_texCoord = (pos.xy + vec2(0.5)) * texScale; 289 pos.xy += (complement.x * complement.y) * point_bug223014[0];
263 } 290 pos.xy += (a_texCoord.x * complement.y) * point_bug223014[1];
264 ); 291 pos.xy += (a_texCoord.x * a_texCoord.y) * point_bug223014[2];
292 pos.xy += (complement.x * a_texCoord.y) * point_bug223014[3];
293 gl_Position = matrix * pos;
294 v_texCoord = (pos.xy + vec2(0.5)) * texScale;
295 }
296 );
265 } 297 }
266 298
267 VertexShaderTile::VertexShaderTile() 299 VertexShaderTile::VertexShaderTile()
268 : m_matrixLocation(-1) 300 : matrix_location_(-1),
269 , m_pointLocation(-1) 301 point_location_(-1),
270 , m_vertexTexTransformLocation(-1) 302 vertex_tex_transform_location_(-1) { }
271 { 303
272 } 304 void VertexShaderTile::Init(WebGraphicsContext3D* context,
273 305 unsigned program,
274 void VertexShaderTile::init(WebGraphicsContext3D* context, unsigned program, boo l usingBindUniform, int* baseUniformIndex) 306 bool using_bind_uniform,
275 { 307 int* base_uniform_index) {
276 static const char* shaderUniforms[] = { 308 static const char* shader_uniforms[] = {
277 "matrix", 309 "matrix",
278 "point_bug223014", 310 "point_bug223014",
279 "vertexTexTransform", 311 "vertexTexTransform",
280 }; 312 };
281 int locations[3]; 313 int locations[3];
282 314
283 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 315 GetProgramUniformLocations(context,
284 316 program,
285 m_matrixLocation = locations[0]; 317 shader_uniforms,
286 m_pointLocation = locations[1]; 318 arraysize(shader_uniforms),
287 m_vertexTexTransformLocation = locations[2]; 319 arraysize(locations),
288 DCHECK(m_matrixLocation != -1 && m_pointLocation != -1 && m_vertexTexTransfo rmLocation != -1); 320 locations,
289 } 321 using_bind_uniform,
290 322 base_uniform_index);
291 std::string VertexShaderTile::getShaderString() const 323
292 { 324 matrix_location_ = locations[0];
293 return SHADER( 325 point_location_ = locations[1];
294 attribute vec4 a_position; 326 vertex_tex_transform_location_ = locations[2];
295 attribute vec2 a_texCoord; 327 DCHECK(matrix_location_ != -1 && point_location_ != -1 &&
296 uniform mat4 matrix; 328 vertex_tex_transform_location_ != -1);
297 uniform vec2 point_bug223014[4]; 329 }
298 uniform vec4 vertexTexTransform; 330
299 varying vec2 v_texCoord; 331 std::string VertexShaderTile::GetShaderString() const {
300 void main() 332 return SHADER(
301 { 333 attribute vec4 a_position;
302 vec2 complement = abs(a_texCoord - 1.0); 334 attribute vec2 a_texCoord;
303 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w); 335 uniform mat4 matrix;
304 pos.xy += (complement.x * complement.y) * point_bug223014[0]; 336 uniform vec2 point_bug223014[4];
305 pos.xy += (a_texCoord.x * complement.y) * point_bug223014[1]; 337 uniform vec4 vertexTexTransform;
306 pos.xy += (a_texCoord.x * a_texCoord.y) * point_bug223014[2]; 338 varying vec2 v_texCoord;
307 pos.xy += (complement.x * a_texCoord.y) * point_bug223014[3]; 339 void main() {
308 gl_Position = matrix * pos; 340 vec2 complement = abs(a_texCoord - 1.0);
309 v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy; 341 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w);
310 } 342 pos.xy += (complement.x * complement.y) * point_bug223014[0];
311 ); 343 pos.xy += (a_texCoord.x * complement.y) * point_bug223014[1];
344 pos.xy += (a_texCoord.x * a_texCoord.y) * point_bug223014[2];
345 pos.xy += (complement.x * a_texCoord.y) * point_bug223014[3];
346 gl_Position = matrix * pos;
347 v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy;
348 }
349 );
312 } 350 }
313 351
314 VertexShaderVideoTransform::VertexShaderVideoTransform() 352 VertexShaderVideoTransform::VertexShaderVideoTransform()
315 : m_matrixLocation(-1) 353 : matrix_location_(-1),
316 , m_texMatrixLocation(-1) 354 tex_matrix_location_(-1) { }
317 { 355
318 } 356 bool VertexShaderVideoTransform::Init(WebGraphicsContext3D* context,
319 357 unsigned program,
320 bool VertexShaderVideoTransform::init(WebGraphicsContext3D* context, unsigned pr ogram, bool usingBindUniform, int* baseUniformIndex) 358 bool using_bind_uniform,
321 { 359 int* base_uniform_index) {
322 static const char* shaderUniforms[] = { 360 static const char* shader_uniforms[] = {
323 "matrix", 361 "matrix",
324 "texMatrix", 362 "texMatrix",
325 }; 363 };
326 int locations[2]; 364 int locations[2];
327 365
328 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 366 GetProgramUniformLocations(context,
329 367 program,
330 m_matrixLocation = locations[0]; 368 shader_uniforms,
331 m_texMatrixLocation = locations[1]; 369 arraysize(shader_uniforms),
332 return m_matrixLocation != -1 && m_texMatrixLocation != -1; 370 arraysize(locations),
333 } 371 locations,
334 372 using_bind_uniform,
335 std::string VertexShaderVideoTransform::getShaderString() const 373 base_uniform_index);
336 { 374
337 return SHADER( 375 matrix_location_ = locations[0];
338 attribute vec4 a_position; 376 tex_matrix_location_ = locations[1];
339 attribute vec2 a_texCoord; 377 return matrix_location_ != -1 && tex_matrix_location_ != -1;
340 uniform mat4 matrix; 378 }
341 uniform mat4 texMatrix; 379
342 varying vec2 v_texCoord; 380 std::string VertexShaderVideoTransform::GetShaderString() const {
343 void main() 381 return SHADER(
344 { 382 attribute vec4 a_position;
345 gl_Position = matrix * a_position; 383 attribute vec2 a_texCoord;
346 v_texCoord = vec2(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)); 384 uniform mat4 matrix;
347 } 385 uniform mat4 texMatrix;
348 ); 386 varying vec2 v_texCoord;
387 void main() {
388 gl_Position = matrix * a_position;
389 v_texCoord =
390 vec2(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0));
391 }
392 );
349 } 393 }
350 394
351 FragmentTexAlphaBinding::FragmentTexAlphaBinding() 395 FragmentTexAlphaBinding::FragmentTexAlphaBinding()
352 : m_samplerLocation(-1) 396 : sampler_location_(-1),
353 , m_alphaLocation(-1) 397 alpha_location_(-1) { }
354 { 398
355 } 399 void FragmentTexAlphaBinding::Init(WebGraphicsContext3D* context,
356 400 unsigned program,
357 void FragmentTexAlphaBinding::init(WebGraphicsContext3D* context, unsigned progr am, bool usingBindUniform, int* baseUniformIndex) 401 bool using_bind_uniform,
358 { 402 int* base_uniform_index) {
359 static const char* shaderUniforms[] = { 403 static const char* shader_uniforms[] = {
360 "s_texture", 404 "s_texture",
361 "alpha", 405 "alpha",
362 }; 406 };
363 int locations[2]; 407 int locations[2];
364 408
365 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 409 GetProgramUniformLocations(context,
366 410 program,
367 m_samplerLocation = locations[0]; 411 shader_uniforms,
368 m_alphaLocation = locations[1]; 412 arraysize(shader_uniforms),
369 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1); 413 arraysize(locations),
414 locations,
415 using_bind_uniform,
416 base_uniform_index);
417
418 sampler_location_ = locations[0];
419 alpha_location_ = locations[1];
420 DCHECK(sampler_location_ != -1 && alpha_location_ != -1);
370 } 421 }
371 422
372 FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() 423 FragmentTexOpaqueBinding::FragmentTexOpaqueBinding()
373 : m_samplerLocation(-1) 424 : sampler_location_(-1) { }
374 { 425
375 } 426 void FragmentTexOpaqueBinding::Init(WebGraphicsContext3D* context,
376 427 unsigned program,
377 void FragmentTexOpaqueBinding::init(WebGraphicsContext3D* context, unsigned prog ram, bool usingBindUniform, int* baseUniformIndex) 428 bool using_bind_uniform,
378 { 429 int* base_uniform_index) {
379 static const char* shaderUniforms[] = { 430 static const char* shader_uniforms[] = {
380 "s_texture", 431 "s_texture",
381 }; 432 };
382 int locations[1]; 433 int locations[1];
383 434
384 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 435 GetProgramUniformLocations(context,
385 436 program,
386 m_samplerLocation = locations[0]; 437 shader_uniforms,
387 DCHECK(m_samplerLocation != -1); 438 arraysize(shader_uniforms),
388 } 439 arraysize(locations),
389 440 locations,
390 bool FragmentShaderOESImageExternal::init(WebGraphicsContext3D* context, unsigne d program, bool usingBindUniform, int* baseUniformIndex) 441 using_bind_uniform,
391 { 442 base_uniform_index);
392 static const char* shaderUniforms[] = { 443
393 "s_texture", 444 sampler_location_ = locations[0];
394 }; 445 DCHECK(sampler_location_ != -1);
395 int locations[1]; 446 }
396 447
397 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 448 bool FragmentShaderOESImageExternal::Init(WebGraphicsContext3D* context,
398 449 unsigned program,
399 m_samplerLocation = locations[0]; 450 bool using_bind_uniform,
400 return m_samplerLocation != -1; 451 int* base_uniform_index) {
401 } 452 static const char* shader_uniforms[] = {
402 453 "s_texture",
403 std::string FragmentShaderOESImageExternal::getShaderString() const 454 };
404 { 455 int locations[1];
405 // Cannot use the SHADER() macro because of the '#' char 456
406 return "#extension GL_OES_EGL_image_external : require \n" 457 GetProgramUniformLocations(context,
407 "precision mediump float;\n" 458 program,
408 "varying vec2 v_texCoord;\n" 459 shader_uniforms,
409 "uniform samplerExternalOES s_texture;\n" 460 arraysize(shader_uniforms),
410 "void main()\n" 461 arraysize(locations),
411 "{\n" 462 locations,
412 " vec4 texColor = texture2D(s_texture, v_texCoord);\n" 463 using_bind_uniform,
413 " gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor .w);\n" 464 base_uniform_index);
414 "}\n"; 465
415 } 466 sampler_location_ = locations[0];
416 467 return sampler_location_ != -1;
417 std::string FragmentShaderRGBATexAlpha::getShaderString() const 468 }
418 { 469
419 return SHADER( 470 std::string FragmentShaderOESImageExternal::GetShaderString() const {
420 precision mediump float; 471 // Cannot use the SHADER() macro because of the '#' char
421 varying vec2 v_texCoord; 472 return "#extension GL_OES_EGL_image_external : require\n"
422 uniform sampler2D s_texture; 473 SHADER(
423 uniform float alpha; 474 precision mediump float;
424 void main() 475 varying vec2 v_texCoord;
425 { 476 uniform samplerExternalOES s_texture;
426 vec4 texColor = texture2D(s_texture, v_texCoord); 477 void main() {
427 gl_FragColor = texColor * alpha; 478 vec4 texColor = texture2D(s_texture, v_texCoord);
428 } 479 gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w);
429 ); 480 }
430 } 481 );
431 482 }
432 std::string FragmentShaderRGBATexVaryingAlpha::getShaderString() const 483
433 { 484 std::string FragmentShaderRGBATexAlpha::GetShaderString() const {
434 return SHADER( 485 return SHADER(
486 precision mediump float;
487 varying vec2 v_texCoord;
488 uniform sampler2D s_texture;
489 uniform float alpha;
490 void main() {
491 vec4 texColor = texture2D(s_texture, v_texCoord);
492 gl_FragColor = texColor * alpha;
493 }
494 );
495 }
496
497 std::string FragmentShaderRGBATexVaryingAlpha::GetShaderString() const {
498 return SHADER(
499 precision mediump float;
500 varying vec2 v_texCoord;
501 varying float v_alpha;
502 uniform sampler2D s_texture;
503 void main() {
504 vec4 texColor = texture2D(s_texture, v_texCoord);
505 gl_FragColor = texColor * v_alpha;
506 }
507 );
508 }
509
510 std::string FragmentShaderRGBATexRectVaryingAlpha::GetShaderString() const {
511 return "#extension GL_ARB_texture_rectangle : require\n"
512 SHADER(
435 precision mediump float; 513 precision mediump float;
436 varying vec2 v_texCoord; 514 varying vec2 v_texCoord;
437 varying float v_alpha; 515 varying float v_alpha;
438 uniform sampler2D s_texture; 516 uniform sampler2DRect s_texture;
439 void main() 517 void main() {
440 { 518 vec4 texColor = texture2DRect(s_texture, v_texCoord);
441 vec4 texColor = texture2D(s_texture, v_texCoord); 519 gl_FragColor = texColor * v_alpha;
442 gl_FragColor = texColor * v_alpha;
443 } 520 }
444 ); 521 );
445 } 522 }
446 523
447 std::string FragmentShaderRGBATexRectVaryingAlpha::getShaderString() const 524 std::string FragmentShaderRGBATexOpaque::GetShaderString() const {
448 { 525 return SHADER(
449 return "#extension GL_ARB_texture_rectangle : require\n" 526 precision mediump float;
450 "precision mediump float;\n" 527 varying vec2 v_texCoord;
451 "varying vec2 v_texCoord;\n" 528 uniform sampler2D s_texture;
452 "varying float v_alpha;\n" 529 void main() {
453 "uniform sampler2DRect s_texture;\n" 530 vec4 texColor = texture2D(s_texture, v_texCoord);
454 "void main()\n" 531 gl_FragColor = vec4(texColor.rgb, 1.0);
455 "{\n" 532 }
456 " vec4 texColor = texture2DRect(s_texture, v_texCoord);\n" 533 );
457 " gl_FragColor = texColor * v_alpha;\n" 534 }
458 "}\n"; 535
459 } 536 std::string FragmentShaderRGBATex::GetShaderString() const {
460 537 return SHADER(
461 std::string FragmentShaderRGBATexOpaque::getShaderString() const 538 precision mediump float;
462 { 539 varying vec2 v_texCoord;
463 return SHADER( 540 uniform sampler2D s_texture;
464 precision mediump float; 541 void main() {
465 varying vec2 v_texCoord; 542 gl_FragColor = texture2D(s_texture, v_texCoord);
466 uniform sampler2D s_texture; 543 }
467 void main() 544 );
468 { 545 }
469 vec4 texColor = texture2D(s_texture, v_texCoord); 546
470 gl_FragColor = vec4(texColor.rgb, 1.0); 547 std::string FragmentShaderRGBATexSwizzleAlpha::GetShaderString() const {
471 } 548 return SHADER(
472 ); 549 precision mediump float;
473 } 550 varying vec2 v_texCoord;
474 551 uniform sampler2D s_texture;
475 std::string FragmentShaderRGBATex::getShaderString() const 552 uniform float alpha;
476 { 553 void main() {
477 return SHADER( 554 vec4 texColor = texture2D(s_texture, v_texCoord);
478 precision mediump float; 555 gl_FragColor =
479 varying vec2 v_texCoord; 556 vec4(texColor.z, texColor.y, texColor.x, texColor.w) * alpha;
480 uniform sampler2D s_texture; 557 }
481 void main() 558 );
482 { 559 }
483 gl_FragColor = texture2D(s_texture, v_texCoord); 560
484 } 561 std::string FragmentShaderRGBATexSwizzleOpaque::GetShaderString() const {
485 ); 562 return SHADER(
486 } 563 precision mediump float;
487 564 varying vec2 v_texCoord;
488 std::string FragmentShaderRGBATexSwizzleAlpha::getShaderString() const 565 uniform sampler2D s_texture;
489 { 566 void main() {
490 return SHADER( 567 vec4 texColor = texture2D(s_texture, v_texCoord);
491 precision mediump float; 568 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, 1.0);
492 varying vec2 v_texCoord; 569 }
493 uniform sampler2D s_texture; 570 );
494 uniform float alpha;
495 void main()
496 {
497 vec4 texColor = texture2D(s_texture, v_texCoord);
498 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, texColor.w) * alpha;
499 }
500 );
501 }
502
503 std::string FragmentShaderRGBATexSwizzleOpaque::getShaderString() const
504 {
505 return SHADER(
506 precision mediump float;
507 varying vec2 v_texCoord;
508 uniform sampler2D s_texture;
509 void main()
510 {
511 vec4 texColor = texture2D(s_texture, v_texCoord);
512 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, 1.0);
513 }
514 );
515 } 571 }
516 572
517 FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA() 573 FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA()
518 : m_samplerLocation(-1) 574 : sampler_location_(-1),
519 , m_alphaLocation(-1) 575 alpha_location_(-1),
520 , m_edgeLocation(-1) 576 edge_location_(-1) { }
521 { 577
522 } 578 void FragmentShaderRGBATexAlphaAA::Init(WebGraphicsContext3D* context,
523 579 unsigned program,
524 void FragmentShaderRGBATexAlphaAA::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex) 580 bool using_bind_uniform,
525 { 581 int* base_uniform_index) {
526 static const char* shaderUniforms[] = { 582 static const char* shader_uniforms[] = {
527 "s_texture", 583 "s_texture",
528 "alpha", 584 "alpha",
529 "edge", 585 "edge",
530 }; 586 };
531 int locations[3]; 587 int locations[3];
532 588
533 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 589 GetProgramUniformLocations(context,
534 590 program,
535 m_samplerLocation = locations[0]; 591 shader_uniforms,
536 m_alphaLocation = locations[1]; 592 arraysize(shader_uniforms),
537 m_edgeLocation = locations[2]; 593 arraysize(locations),
538 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation != -1); 594 locations,
539 } 595 using_bind_uniform,
540 596 base_uniform_index);
541 std::string FragmentShaderRGBATexAlphaAA::getShaderString() const 597
542 { 598 sampler_location_ = locations[0];
543 return SHADER( 599 alpha_location_ = locations[1];
544 precision mediump float; 600 edge_location_ = locations[2];
545 varying vec2 v_texCoord; 601 DCHECK(sampler_location_ != -1 && alpha_location_ != -1 &&
546 uniform sampler2D s_texture; 602 edge_location_ != -1);
547 uniform float alpha; 603 }
548 uniform vec3 edge[8]; 604
549 void main() 605 std::string FragmentShaderRGBATexAlphaAA::GetShaderString() const {
550 { 606 return SHADER(
551 vec4 texColor = texture2D(s_texture, v_texCoord); 607 precision mediump float;
552 vec3 pos = vec3(gl_FragCoord.xy, 1); 608 varying vec2 v_texCoord;
553 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); 609 uniform sampler2D s_texture;
554 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); 610 uniform float alpha;
555 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); 611 uniform vec3 edge[8];
556 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); 612 void main() {
557 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); 613 vec4 texColor = texture2D(s_texture, v_texCoord);
558 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); 614 vec3 pos = vec3(gl_FragCoord.xy, 1);
559 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); 615 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0);
560 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); 616 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0);
561 gl_FragColor = texColor * alpha * min(min(a0, a2) * min(a1, a3), min (a4, a6) * min(a5, a7)); 617 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0);
562 } 618 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0);
563 ); 619 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0);
620 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0);
621 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0);
622 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0);
623 gl_FragColor = texColor * alpha * min(min(a0, a2) * min(a1, a3),
624 min(a4, a6) * min(a5, a7));
625 }
626 );
564 } 627 }
565 628
566 FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding() 629 FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding()
567 : m_samplerLocation(-1) 630 : sampler_location_(-1),
568 , m_alphaLocation(-1) 631 alpha_location_(-1),
569 , m_fragmentTexTransformLocation(-1) 632 fragment_tex_transform_location_(-1),
570 , m_edgeLocation(-1) 633 edge_location_(-1) { }
571 { 634
572 } 635 void FragmentTexClampAlphaAABinding::Init(WebGraphicsContext3D* context,
573 636 unsigned program,
574 void FragmentTexClampAlphaAABinding::init(WebGraphicsContext3D* context, unsigne d program, bool usingBindUniform, int* baseUniformIndex) 637 bool using_bind_uniform,
575 { 638 int* base_uniform_index) {
576 static const char* shaderUniforms[] = { 639 static const char* shader_uniforms[] = {
577 "s_texture", 640 "s_texture",
578 "alpha", 641 "alpha",
579 "fragmentTexTransform", 642 "fragmentTexTransform",
580 "edge", 643 "edge",
581 }; 644 };
582 int locations[4]; 645 int locations[4];
583 646
584 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 647 GetProgramUniformLocations(context,
585 648 program,
586 m_samplerLocation = locations[0]; 649 shader_uniforms,
587 m_alphaLocation = locations[1]; 650 arraysize(shader_uniforms),
588 m_fragmentTexTransformLocation = locations[2]; 651 arraysize(locations),
589 m_edgeLocation = locations[3]; 652 locations,
590 DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_fragmentTexTran sformLocation != -1 && m_edgeLocation != -1); 653 using_bind_uniform,
591 } 654 base_uniform_index);
592 655
593 std::string FragmentShaderRGBATexClampAlphaAA::getShaderString() const 656 sampler_location_ = locations[0];
594 { 657 alpha_location_ = locations[1];
595 return SHADER( 658 fragment_tex_transform_location_ = locations[2];
596 precision mediump float; 659 edge_location_ = locations[3];
597 varying vec2 v_texCoord; 660 DCHECK(sampler_location_ != -1 && alpha_location_ != -1 &&
598 uniform sampler2D s_texture; 661 fragment_tex_transform_location_ != -1 && edge_location_ != -1);
599 uniform float alpha; 662 }
600 uniform vec4 fragmentTexTransform; 663
601 uniform vec3 edge[8]; 664 std::string FragmentShaderRGBATexClampAlphaAA::GetShaderString() const {
602 void main() 665 return SHADER(
603 { 666 precision mediump float;
604 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.z w + fragmentTexTransform.xy; 667 varying vec2 v_texCoord;
605 vec4 texColor = texture2D(s_texture, texCoord); 668 uniform sampler2D s_texture;
606 vec3 pos = vec3(gl_FragCoord.xy, 1); 669 uniform float alpha;
607 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); 670 uniform vec4 fragmentTexTransform;
608 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); 671 uniform vec3 edge[8];
609 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); 672 void main() {
610 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); 673 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw +
611 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); 674 fragmentTexTransform.xy;
612 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); 675 vec4 texColor = texture2D(s_texture, texCoord);
613 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); 676 vec3 pos = vec3(gl_FragCoord.xy, 1);
614 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); 677 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0);
615 gl_FragColor = texColor * alpha * min(min(a0, a2) * min(a1, a3), min (a4, a6) * min(a5, a7)); 678 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0);
616 } 679 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0);
617 ); 680 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0);
618 } 681 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0);
619 682 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0);
620 std::string FragmentShaderRGBATexClampSwizzleAlphaAA::getShaderString() const 683 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0);
621 { 684 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0);
622 return SHADER( 685 gl_FragColor = texColor * alpha * min(min(a0, a2) * min(a1, a3),
623 precision mediump float; 686 min(a4, a6) * min(a5, a7));
624 varying vec2 v_texCoord; 687 }
625 uniform sampler2D s_texture; 688 );
626 uniform float alpha; 689 }
627 uniform vec4 fragmentTexTransform; 690
628 uniform vec3 edge[8]; 691 std::string FragmentShaderRGBATexClampSwizzleAlphaAA::GetShaderString() const {
629 void main() 692 return SHADER(
630 { 693 precision mediump float;
631 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.z w + fragmentTexTransform.xy; 694 varying vec2 v_texCoord;
632 vec4 texColor = texture2D(s_texture, texCoord); 695 uniform sampler2D s_texture;
633 vec3 pos = vec3(gl_FragCoord.xy, 1); 696 uniform float alpha;
634 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); 697 uniform vec4 fragmentTexTransform;
635 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); 698 uniform vec3 edge[8];
636 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); 699 void main() {
637 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); 700 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw +
638 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); 701 fragmentTexTransform.xy;
639 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); 702 vec4 texColor = texture2D(s_texture, texCoord);
640 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); 703 vec3 pos = vec3(gl_FragCoord.xy, 1);
641 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); 704 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0);
642 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, texColor.w) * alpha * min(min(a0, a2) * min(a1, a3), min(a4, a6) * min(a5, a7)); 705 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0);
643 } 706 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0);
644 ); 707 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0);
708 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0);
709 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0);
710 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0);
711 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0);
712 gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, texColor.w) *
713 alpha * min(min(a0, a2) * min(a1, a3), min(a4, a6) * min(a5, a7));
714 }
715 );
645 } 716 }
646 717
647 FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask() 718 FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask()
648 : m_samplerLocation(-1) 719 : sampler_location_(-1),
649 , m_maskSamplerLocation(-1) 720 mask_sampler_location_(-1),
650 , m_alphaLocation(-1) 721 alpha_location_(-1),
651 , m_maskTexCoordScaleLocation(-1) 722 mask_tex_coord_scale_location_(-1) { }
652 { 723
653 } 724 void FragmentShaderRGBATexAlphaMask::Init(WebGraphicsContext3D* context,
654 725 unsigned program,
655 void FragmentShaderRGBATexAlphaMask::init(WebGraphicsContext3D* context, unsigne d program, bool usingBindUniform, int* baseUniformIndex) 726 bool using_bind_uniform,
656 { 727 int* base_uniform_index) {
657 static const char* shaderUniforms[] = { 728 static const char* shader_uniforms[] = {
658 "s_texture", 729 "s_texture",
659 "s_mask", 730 "s_mask",
660 "alpha", 731 "alpha",
661 "maskTexCoordScale", 732 "maskTexCoordScale",
662 "maskTexCoordOffset", 733 "maskTexCoordOffset",
663 }; 734 };
664 int locations[5]; 735 int locations[5];
665 736
666 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 737 GetProgramUniformLocations(context,
667 738 program,
668 m_samplerLocation = locations[0]; 739 shader_uniforms,
669 m_maskSamplerLocation = locations[1]; 740 arraysize(shader_uniforms),
670 m_alphaLocation = locations[2]; 741 arraysize(locations),
671 m_maskTexCoordScaleLocation = locations[3]; 742 locations,
672 m_maskTexCoordOffsetLocation = locations[4]; 743 using_bind_uniform,
673 DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca tion != -1); 744 base_uniform_index);
674 } 745
675 746 sampler_location_ = locations[0];
676 std::string FragmentShaderRGBATexAlphaMask::getShaderString() const 747 mask_sampler_location_ = locations[1];
677 { 748 alpha_location_ = locations[2];
678 return SHADER( 749 mask_tex_coord_scale_location_ = locations[3];
679 precision mediump float; 750 mask_tex_coord_offset_location_ = locations[4];
680 varying vec2 v_texCoord; 751 DCHECK(sampler_location_ != -1 && mask_sampler_location_ != -1 &&
681 uniform sampler2D s_texture; 752 alpha_location_ != -1);
682 uniform sampler2D s_mask; 753 }
683 uniform vec2 maskTexCoordScale; 754
684 uniform vec2 maskTexCoordOffset; 755 std::string FragmentShaderRGBATexAlphaMask::GetShaderString() const {
685 uniform float alpha; 756 return SHADER(
686 void main() 757 precision mediump float;
687 { 758 varying vec2 v_texCoord;
688 vec4 texColor = texture2D(s_texture, v_texCoord); 759 uniform sampler2D s_texture;
689 vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskT exCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); 760 uniform sampler2D s_mask;
690 vec4 maskColor = texture2D(s_mask, maskTexCoord); 761 uniform vec2 maskTexCoordScale;
691 gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha * maskColor.w; 762 uniform vec2 maskTexCoordOffset;
692 } 763 uniform float alpha;
693 ); 764 void main() {
765 vec4 texColor = texture2D(s_texture, v_texCoord);
766 vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x *
767 maskTexCoordScale.x,
768 maskTexCoordOffset.y + v_texCoord.y *
769 maskTexCoordScale.y);
770 vec4 maskColor = texture2D(s_mask, maskTexCoord);
771 gl_FragColor = vec4(texColor.x, texColor.y,
772 texColor.z, texColor.w) * alpha * maskColor.w;
773 }
774 );
694 } 775 }
695 776
696 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() 777 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA()
697 : m_samplerLocation(-1) 778 : sampler_location_(-1),
698 , m_maskSamplerLocation(-1) 779 mask_sampler_location_(-1),
699 , m_alphaLocation(-1) 780 alpha_location_(-1),
700 , m_edgeLocation(-1) 781 edge_location_(-1),
701 , m_maskTexCoordScaleLocation(-1) 782 mask_tex_coord_scale_location_(-1) { }
702 { 783
703 } 784 void FragmentShaderRGBATexAlphaMaskAA::Init(WebGraphicsContext3D* context,
704 785 unsigned program,
705 void FragmentShaderRGBATexAlphaMaskAA::init(WebGraphicsContext3D* context, unsig ned program, bool usingBindUniform, int* baseUniformIndex) 786 bool using_bind_uniform,
706 { 787 int* base_uniform_index) {
707 static const char* shaderUniforms[] = { 788 static const char* shader_uniforms[] = {
708 "s_texture", 789 "s_texture",
709 "s_mask", 790 "s_mask",
710 "alpha", 791 "alpha",
711 "edge", 792 "edge",
712 "maskTexCoordScale", 793 "maskTexCoordScale",
713 "maskTexCoordOffset", 794 "maskTexCoordOffset",
714 }; 795 };
715 int locations[6]; 796 int locations[6];
716 797
717 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 798 GetProgramUniformLocations(context,
718 799 program,
719 m_samplerLocation = locations[0]; 800 shader_uniforms,
720 m_maskSamplerLocation = locations[1]; 801 arraysize(shader_uniforms),
721 m_alphaLocation = locations[2]; 802 arraysize(locations),
722 m_edgeLocation = locations[3]; 803 locations,
723 m_maskTexCoordScaleLocation = locations[4]; 804 using_bind_uniform,
724 m_maskTexCoordOffsetLocation = locations[5]; 805 base_uniform_index);
725 DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLoca tion != -1 && m_edgeLocation != -1); 806
726 } 807 sampler_location_ = locations[0];
727 808 mask_sampler_location_ = locations[1];
728 std::string FragmentShaderRGBATexAlphaMaskAA::getShaderString() const 809 alpha_location_ = locations[2];
729 { 810 edge_location_ = locations[3];
730 return SHADER( 811 mask_tex_coord_scale_location_ = locations[4];
731 precision mediump float; 812 mask_tex_coord_offset_location_ = locations[5];
732 varying vec2 v_texCoord; 813 DCHECK(sampler_location_ != -1 && mask_sampler_location_ != -1 &&
733 uniform sampler2D s_texture; 814 alpha_location_ != -1 && edge_location_ != -1);
734 uniform sampler2D s_mask; 815 }
735 uniform vec2 maskTexCoordScale; 816
736 uniform vec2 maskTexCoordOffset; 817 std::string FragmentShaderRGBATexAlphaMaskAA::GetShaderString() const {
737 uniform float alpha; 818 return SHADER(
738 uniform vec3 edge[8]; 819 precision mediump float;
739 void main() 820 varying vec2 v_texCoord;
740 { 821 uniform sampler2D s_texture;
741 vec4 texColor = texture2D(s_texture, v_texCoord); 822 uniform sampler2D s_mask;
742 vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskT exCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); 823 uniform vec2 maskTexCoordScale;
743 vec4 maskColor = texture2D(s_mask, maskTexCoord); 824 uniform vec2 maskTexCoordOffset;
744 vec3 pos = vec3(gl_FragCoord.xy, 1); 825 uniform float alpha;
745 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); 826 uniform vec3 edge[8];
746 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); 827 void main() {
747 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); 828 vec4 texColor = texture2D(s_texture, v_texCoord);
748 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); 829 vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x *
749 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); 830 maskTexCoordScale.x,
750 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); 831 maskTexCoordOffset.y + v_texCoord.y *
751 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); 832 maskTexCoordScale.y);
752 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); 833 vec4 maskColor = texture2D(s_mask, maskTexCoord);
753 gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha * maskColor.w * min(min(a0, a2) * min(a1, a3), min(a4, a6) * min(a5, a7) ); 834 vec3 pos = vec3(gl_FragCoord.xy, 1);
754 } 835 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0);
755 ); 836 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0);
837 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0);
838 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0);
839 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0);
840 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0);
841 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0);
842 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0);
843 gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) *
844 alpha * maskColor.w * min(min(a0, a2) * min(a1, a3),
845 min(a4, a6) * min(a5, a7));
846 }
847 );
756 } 848 }
757 849
758 FragmentShaderYUVVideo::FragmentShaderYUVVideo() 850 FragmentShaderYUVVideo::FragmentShaderYUVVideo()
759 : m_yTextureLocation(-1) 851 : y_texture_location_(-1),
760 , m_uTextureLocation(-1) 852 u_texture_location_(-1),
761 , m_vTextureLocation(-1) 853 v_texture_location_(-1),
762 , m_alphaLocation(-1) 854 alpha_location_(-1),
763 , m_yuvMatrixLocation(-1) 855 yuv_matrix_location_(-1),
764 , m_yuvAdjLocation(-1) 856 yuv_adj_location_(-1) { }
765 { 857
766 } 858 void FragmentShaderYUVVideo::Init(WebGraphicsContext3D* context,
767 859 unsigned program,
768 void FragmentShaderYUVVideo::init(WebGraphicsContext3D* context, unsigned progra m, bool usingBindUniform, int* baseUniformIndex) 860 bool using_bind_uniform,
769 { 861 int* base_uniform_index) {
770 static const char* shaderUniforms[] = { 862 static const char* shader_uniforms[] = {
771 "y_texture", 863 "y_texture",
772 "u_texture", 864 "u_texture",
773 "v_texture", 865 "v_texture",
774 "alpha", 866 "alpha",
775 "yuv_matrix", 867 "yuv_matrix",
776 "yuv_adj", 868 "yuv_adj",
777 }; 869 };
778 int locations[6]; 870 int locations[6];
779 871
780 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 872 GetProgramUniformLocations(context,
781 873 program,
782 m_yTextureLocation = locations[0]; 874 shader_uniforms,
783 m_uTextureLocation = locations[1]; 875 arraysize(shader_uniforms),
784 m_vTextureLocation = locations[2]; 876 arraysize(locations),
785 m_alphaLocation = locations[3]; 877 locations,
786 m_yuvMatrixLocation = locations[4]; 878 using_bind_uniform,
787 m_yuvAdjLocation = locations[5]; 879 base_uniform_index);
788 880
789 DCHECK(m_yTextureLocation != -1 && m_uTextureLocation != -1 && m_vTextureLoc ation != -1 881 y_texture_location_ = locations[0];
790 && m_alphaLocation != -1 && m_yuvMatrixLocation != -1 && m_yuvAdjLoca tion != -1); 882 u_texture_location_ = locations[1];
791 } 883 v_texture_location_ = locations[2];
792 884 alpha_location_ = locations[3];
793 std::string FragmentShaderYUVVideo::getShaderString() const 885 yuv_matrix_location_ = locations[4];
794 { 886 yuv_adj_location_ = locations[5];
795 return SHADER( 887
796 precision mediump float; 888 DCHECK(y_texture_location_ != -1 && u_texture_location_ != -1 &&
797 precision mediump int; 889 v_texture_location_ != -1 && alpha_location_ != -1 &&
798 varying vec2 v_texCoord; 890 yuv_matrix_location_ != -1 && yuv_adj_location_ != -1);
799 uniform sampler2D y_texture; 891 }
800 uniform sampler2D u_texture; 892
801 uniform sampler2D v_texture; 893 std::string FragmentShaderYUVVideo::GetShaderString() const {
802 uniform float alpha; 894 return SHADER(
803 uniform vec3 yuv_adj; 895 precision mediump float;
804 uniform mat3 yuv_matrix; 896 precision mediump int;
805 void main() 897 varying vec2 v_texCoord;
806 { 898 uniform sampler2D y_texture;
807 float y_raw = texture2D(y_texture, v_texCoord).x; 899 uniform sampler2D u_texture;
808 float u_unsigned = texture2D(u_texture, v_texCoord).x; 900 uniform sampler2D v_texture;
809 float v_unsigned = texture2D(v_texture, v_texCoord).x; 901 uniform float alpha;
810 vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj; 902 uniform vec3 yuv_adj;
811 vec3 rgb = yuv_matrix * yuv; 903 uniform mat3 yuv_matrix;
812 gl_FragColor = vec4(rgb, float(1)) * alpha; 904 void main() {
813 } 905 float y_raw = texture2D(y_texture, v_texCoord).x;
814 ); 906 float u_unsigned = texture2D(u_texture, v_texCoord).x;
907 float v_unsigned = texture2D(v_texture, v_texCoord).x;
908 vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj;
909 vec3 rgb = yuv_matrix * yuv;
910 gl_FragColor = vec4(rgb, float(1)) * alpha;
911 }
912 );
815 } 913 }
816 914
817 FragmentShaderColor::FragmentShaderColor() 915 FragmentShaderColor::FragmentShaderColor()
818 : m_colorLocation(-1) 916 : color_location_(-1) { }
819 { 917
820 } 918 void FragmentShaderColor::Init(WebGraphicsContext3D* context,
821 919 unsigned program,
822 void FragmentShaderColor::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex) 920 bool using_bind_uniform,
823 { 921 int* base_uniform_index) {
824 static const char* shaderUniforms[] = { 922 static const char* shader_uniforms[] = {
825 "color", 923 "color",
826 }; 924 };
827 int locations[1]; 925 int locations[1];
828 926
829 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 927 GetProgramUniformLocations(context,
830 928 program,
831 m_colorLocation = locations[0]; 929 shader_uniforms,
832 DCHECK(m_colorLocation != -1); 930 arraysize(shader_uniforms),
833 } 931 arraysize(locations),
834 932 locations,
835 std::string FragmentShaderColor::getShaderString() const 933 using_bind_uniform,
836 { 934 base_uniform_index);
837 return SHADER( 935
838 precision mediump float; 936 color_location_ = locations[0];
839 uniform vec4 color; 937 DCHECK(color_location_ != -1);
840 void main() 938 }
841 { 939
842 gl_FragColor = color; 940 std::string FragmentShaderColor::GetShaderString() const {
843 } 941 return SHADER(
844 ); 942 precision mediump float;
943 uniform vec4 color;
944 void main() {
945 gl_FragColor = color;
946 }
947 );
845 } 948 }
846 949
847 FragmentShaderColorAA::FragmentShaderColorAA() 950 FragmentShaderColorAA::FragmentShaderColorAA()
848 : m_edgeLocation(-1) 951 : edge_location_(-1),
849 , m_colorLocation(-1) 952 color_location_(-1) { }
850 { 953
851 } 954 void FragmentShaderColorAA::Init(WebGraphicsContext3D* context,
852 955 unsigned program,
853 void FragmentShaderColorAA::init(WebGraphicsContext3D* context, unsigned program , bool usingBindUniform, int* baseUniformIndex) 956 bool using_bind_uniform,
854 { 957 int* base_uniform_index) {
855 static const char* shaderUniforms[] = { 958 static const char* shader_uniforms[] = {
856 "edge", 959 "edge",
857 "color", 960 "color",
858 }; 961 };
859 int locations[2]; 962 int locations[2];
860 963
861 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 964 GetProgramUniformLocations(context,
862 965 program,
863 m_edgeLocation = locations[0]; 966 shader_uniforms,
864 m_colorLocation = locations[1]; 967 arraysize(shader_uniforms),
865 DCHECK(m_edgeLocation != -1 && m_colorLocation != -1); 968 arraysize(locations),
866 } 969 locations,
867 970 using_bind_uniform,
868 std::string FragmentShaderColorAA::getShaderString() const 971 base_uniform_index);
869 { 972
870 return SHADER( 973 edge_location_ = locations[0];
871 precision mediump float; 974 color_location_ = locations[1];
872 uniform vec4 color; 975 DCHECK(edge_location_ != -1 && color_location_ != -1);
873 uniform vec3 edge[8]; 976 }
874 void main() 977
875 { 978 std::string FragmentShaderColorAA::GetShaderString() const {
876 vec3 pos = vec3(gl_FragCoord.xy, 1); 979 return SHADER(
877 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); 980 precision mediump float;
878 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); 981 uniform vec4 color;
879 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); 982 uniform vec3 edge[8];
880 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); 983 void main() {
881 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); 984 vec3 pos = vec3(gl_FragCoord.xy, 1);
882 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); 985 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0);
883 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); 986 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0);
884 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); 987 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0);
885 gl_FragColor = color * min(min(a0, a2) * min(a1, a3), min(a4, a6) * min(a5, a7)); 988 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0);
886 } 989 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0);
887 ); 990 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0);
991 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0);
992 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0);
993 gl_FragColor = color * min(min(a0, a2) * min(a1, a3),
994 min(a4, a6) * min(a5, a7));
995 }
996 );
888 } 997 }
889 998
890 FragmentShaderCheckerboard::FragmentShaderCheckerboard() 999 FragmentShaderCheckerboard::FragmentShaderCheckerboard()
891 : m_alphaLocation(-1) 1000 : alpha_location_(-1),
892 , m_texTransformLocation(-1) 1001 tex_transform_location_(-1),
893 , m_frequencyLocation(-1) 1002 frequency_location_(-1) { }
894 { 1003
895 } 1004 void FragmentShaderCheckerboard::Init(WebGraphicsContext3D* context,
896 1005 unsigned program,
897 void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned pr ogram, bool usingBindUniform, int* baseUniformIndex) 1006 bool using_bind_uniform,
898 { 1007 int* base_uniform_index) {
899 static const char* shaderUniforms[] = { 1008 static const char* shader_uniforms[] = {
900 "alpha", 1009 "alpha",
901 "texTransform", 1010 "texTransform",
902 "frequency", 1011 "frequency",
903 "color", 1012 "color",
904 }; 1013 };
905 int locations[4]; 1014 int locations[4];
906 1015
907 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 1016 GetProgramUniformLocations(context,
908 1017 program,
909 m_alphaLocation = locations[0]; 1018 shader_uniforms,
910 m_texTransformLocation = locations[1]; 1019 arraysize(shader_uniforms),
911 m_frequencyLocation = locations[2]; 1020 arraysize(locations),
912 m_colorLocation = locations[3]; 1021 locations,
913 DCHECK(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyL ocation != -1 && m_colorLocation != -1); 1022 using_bind_uniform,
914 } 1023 base_uniform_index);
915 1024
916 std::string FragmentShaderCheckerboard::getShaderString() const 1025 alpha_location_ = locations[0];
917 { 1026 tex_transform_location_ = locations[1];
918 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" 1027 frequency_location_ = locations[2];
919 // by Munshi, Ginsburg, Shreiner. 1028 color_location_ = locations[3];
920 return SHADER( 1029 DCHECK(alpha_location_ != -1 && tex_transform_location_ != -1 &&
921 precision mediump float; 1030 frequency_location_ != -1 && color_location_ != -1);
922 precision mediump int; 1031 }
923 varying vec2 v_texCoord; 1032
924 uniform float alpha; 1033 std::string FragmentShaderCheckerboard::GetShaderString() const {
925 uniform float frequency; 1034 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide"
926 uniform vec4 texTransform; 1035 // by Munshi, Ginsburg, Shreiner.
927 uniform vec4 color; 1036 return SHADER(
928 void main() 1037 precision mediump float;
929 { 1038 precision mediump int;
930 vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0); 1039 varying vec2 v_texCoord;
931 vec4 color2 = color; 1040 uniform float alpha;
932 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT ransform.xy; 1041 uniform float frequency;
933 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); 1042 uniform vec4 texTransform;
934 float picker = abs(coord.x - coord.y); 1043 uniform vec4 color;
935 gl_FragColor = mix(color1, color2, picker) * alpha; 1044 void main() {
936 } 1045 vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0);
937 ); 1046 vec4 color2 = color;
1047 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw +
1048 texTransform.xy;
1049 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0);
1050 float picker = abs(coord.x - coord.y);
1051 gl_FragColor = mix(color1, color2, picker) * alpha;
1052 }
1053 );
938 } 1054 }
939 1055
940 } // namespace cc 1056 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/shader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698