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

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

Issue 13008010: cc: Use different name for "point" uniform until crbug.com/223014 has been resolved. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 VertexShaderQuad::VertexShaderQuad() 216 VertexShaderQuad::VertexShaderQuad()
217 : m_matrixLocation(-1) 217 : m_matrixLocation(-1)
218 , m_pointLocation(-1) 218 , m_pointLocation(-1)
219 , m_texScaleLocation(-1) 219 , m_texScaleLocation(-1)
220 { 220 {
221 } 221 }
222 222
223 void VertexShaderQuad::init(WebGraphicsContext3D* context, unsigned program, boo l usingBindUniform, int* baseUniformIndex) 223 void VertexShaderQuad::init(WebGraphicsContext3D* context, unsigned program, boo l usingBindUniform, int* baseUniformIndex)
224 { 224 {
225 // TODO(reveman): Some uniform names are causing drawing artifact.
226 // crbug.com/223014
225 static const char* shaderUniforms[] = { 227 static const char* shaderUniforms[] = {
226 "matrix", 228 "matrix",
227 "point", 229 "point_bug223014",
228 "texScale", 230 "texScale",
229 }; 231 };
230 int locations[3]; 232 int locations[3];
231 233
232 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 234 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ;
233 235
234 m_matrixLocation = locations[0]; 236 m_matrixLocation = locations[0];
235 m_pointLocation = locations[1]; 237 m_pointLocation = locations[1];
236 m_texScaleLocation = locations[2]; 238 m_texScaleLocation = locations[2];
237 DCHECK_NE(m_matrixLocation, -1); 239 DCHECK_NE(m_matrixLocation, -1);
238 DCHECK_NE(m_pointLocation, -1); 240 DCHECK_NE(m_pointLocation, -1);
239 DCHECK_NE(m_texScaleLocation, -1); 241 DCHECK_NE(m_texScaleLocation, -1);
240 } 242 }
241 243
242 std::string VertexShaderQuad::getShaderString() const 244 std::string VertexShaderQuad::getShaderString() const
243 { 245 {
244 return SHADER( 246 return SHADER(
245 attribute vec4 a_position; 247 attribute vec4 a_position;
246 attribute vec2 a_texCoord; 248 attribute vec2 a_texCoord;
247 uniform mat4 matrix; 249 uniform mat4 matrix;
248 uniform vec2 point[4]; 250 uniform vec2 point_bug223014[4];
249 uniform vec2 texScale; 251 uniform vec2 texScale;
250 varying vec2 v_texCoord; 252 varying vec2 v_texCoord;
251 void main() 253 void main()
252 { 254 {
253 vec2 complement = abs(a_texCoord - 1.0); 255 vec2 complement = abs(a_texCoord - 1.0);
254 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w); 256 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w);
255 pos.xy += (complement.x * complement.y) * point[0]; 257 pos.xy += (complement.x * complement.y) * point_bug223014[0];
256 pos.xy += (a_texCoord.x * complement.y) * point[1]; 258 pos.xy += (a_texCoord.x * complement.y) * point_bug223014[1];
257 pos.xy += (a_texCoord.x * a_texCoord.y) * point[2]; 259 pos.xy += (a_texCoord.x * a_texCoord.y) * point_bug223014[2];
258 pos.xy += (complement.x * a_texCoord.y) * point[3]; 260 pos.xy += (complement.x * a_texCoord.y) * point_bug223014[3];
259 gl_Position = matrix * pos; 261 gl_Position = matrix * pos;
260 v_texCoord = (pos.xy + vec2(0.5)) * texScale; 262 v_texCoord = (pos.xy + vec2(0.5)) * texScale;
261 } 263 }
262 ); 264 );
263 } 265 }
264 266
265 VertexShaderTile::VertexShaderTile() 267 VertexShaderTile::VertexShaderTile()
266 : m_matrixLocation(-1) 268 : m_matrixLocation(-1)
267 , m_pointLocation(-1) 269 , m_pointLocation(-1)
268 , m_vertexTexTransformLocation(-1) 270 , m_vertexTexTransformLocation(-1)
269 { 271 {
270 } 272 }
271 273
272 void VertexShaderTile::init(WebGraphicsContext3D* context, unsigned program, boo l usingBindUniform, int* baseUniformIndex) 274 void VertexShaderTile::init(WebGraphicsContext3D* context, unsigned program, boo l usingBindUniform, int* baseUniformIndex)
273 { 275 {
274 static const char* shaderUniforms[] = { 276 static const char* shaderUniforms[] = {
275 "matrix", 277 "matrix",
276 "point", 278 "point_bug223014",
277 "vertexTexTransform", 279 "vertexTexTransform",
278 }; 280 };
279 int locations[3]; 281 int locations[3];
280 282
281 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ; 283 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex) ;
282 284
283 m_matrixLocation = locations[0]; 285 m_matrixLocation = locations[0];
284 m_pointLocation = locations[1]; 286 m_pointLocation = locations[1];
285 m_vertexTexTransformLocation = locations[2]; 287 m_vertexTexTransformLocation = locations[2];
286 DCHECK(m_matrixLocation != -1 && m_pointLocation != -1 && m_vertexTexTransfo rmLocation != -1); 288 DCHECK(m_matrixLocation != -1 && m_pointLocation != -1 && m_vertexTexTransfo rmLocation != -1);
287 } 289 }
288 290
289 std::string VertexShaderTile::getShaderString() const 291 std::string VertexShaderTile::getShaderString() const
290 { 292 {
291 return SHADER( 293 return SHADER(
292 attribute vec4 a_position; 294 attribute vec4 a_position;
293 attribute vec2 a_texCoord; 295 attribute vec2 a_texCoord;
294 uniform mat4 matrix; 296 uniform mat4 matrix;
295 uniform vec2 point[4]; 297 uniform vec2 point_bug223014[4];
296 uniform vec4 vertexTexTransform; 298 uniform vec4 vertexTexTransform;
297 varying vec2 v_texCoord; 299 varying vec2 v_texCoord;
298 void main() 300 void main()
299 { 301 {
300 vec2 complement = abs(a_texCoord - 1.0); 302 vec2 complement = abs(a_texCoord - 1.0);
301 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w); 303 vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w);
302 pos.xy += (complement.x * complement.y) * point[0]; 304 pos.xy += (complement.x * complement.y) * point_bug223014[0];
303 pos.xy += (a_texCoord.x * complement.y) * point[1]; 305 pos.xy += (a_texCoord.x * complement.y) * point_bug223014[1];
304 pos.xy += (a_texCoord.x * a_texCoord.y) * point[2]; 306 pos.xy += (a_texCoord.x * a_texCoord.y) * point_bug223014[2];
305 pos.xy += (complement.x * a_texCoord.y) * point[3]; 307 pos.xy += (complement.x * a_texCoord.y) * point_bug223014[3];
306 gl_Position = matrix * pos; 308 gl_Position = matrix * pos;
307 v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy; 309 v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy;
308 } 310 }
309 ); 311 );
310 } 312 }
311 313
312 VertexShaderVideoTransform::VertexShaderVideoTransform() 314 VertexShaderVideoTransform::VertexShaderVideoTransform()
313 : m_matrixLocation(-1) 315 : m_matrixLocation(-1)
314 , m_texMatrixLocation(-1) 316 , m_texMatrixLocation(-1)
315 { 317 {
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 vec4 color2 = color; 931 vec4 color2 = color;
930 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT ransform.xy; 932 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT ransform.xy;
931 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); 933 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0);
932 float picker = abs(coord.x - coord.y); 934 float picker = abs(coord.x - coord.y);
933 gl_FragColor = mix(color1, color2, picker) * alpha; 935 gl_FragColor = mix(color1, color2, picker) * alpha;
934 } 936 }
935 ); 937 );
936 } 938 }
937 939
938 } // namespace cc 940 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698