Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/shader.h" | 5 #include "cc/output/shader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 attribute TexCoordPrecision vec2 a_texCoord; | 178 attribute TexCoordPrecision vec2 a_texCoord; |
| 179 uniform mat4 matrix; | 179 uniform mat4 matrix; |
| 180 varying TexCoordPrecision vec2 v_texCoord; | 180 varying TexCoordPrecision vec2 v_texCoord; |
| 181 void main() { | 181 void main() { |
| 182 gl_Position = matrix * a_position; | 182 gl_Position = matrix * a_position; |
| 183 v_texCoord = a_texCoord; | 183 v_texCoord = a_texCoord; |
| 184 } | 184 } |
| 185 ); // NOLINT(whitespace/parens) | 185 ); // NOLINT(whitespace/parens) |
| 186 } | 186 } |
| 187 | 187 |
| 188 VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() | 188 VertexShaderPosTexYUVStretchOffset::VertexShaderPosTexYUVStretchOffset() |
| 189 : matrix_location_(-1), | 189 : matrix_location_(-1), tex_scale_location_(-1), tex_offset_location_(-1) {} |
| 190 tex_scale_location_(-1) {} | |
| 191 | 190 |
| 192 void VertexShaderPosTexYUVStretch::Init(GLES2Interface* context, | 191 void VertexShaderPosTexYUVStretchOffset::Init(GLES2Interface* context, |
| 193 unsigned program, | 192 unsigned program, |
| 194 int* base_uniform_index) { | 193 int* base_uniform_index) { |
| 195 static const char* uniforms[] = { | 194 static const char* uniforms[] = { |
| 196 "matrix", | 195 "matrix", |
| 197 "texScale", | 196 "texScale", |
| 197 "texOFfset", | |
|
danakj
2014/03/21 18:11:11
"texOffset"
again, is the test broken or not test
sheu
2014/03/21 20:44:50
D'oh. I lucked out since the driver I'm testing o
| |
| 198 }; | 198 }; |
| 199 int locations[arraysize(uniforms)]; | 199 int locations[arraysize(uniforms)]; |
| 200 | 200 |
| 201 GetProgramUniformLocations(context, | 201 GetProgramUniformLocations(context, |
| 202 program, | 202 program, |
| 203 arraysize(uniforms), | 203 arraysize(uniforms), |
| 204 uniforms, | 204 uniforms, |
| 205 locations, | 205 locations, |
| 206 base_uniform_index); | 206 base_uniform_index); |
| 207 matrix_location_ = locations[0]; | 207 matrix_location_ = locations[0]; |
| 208 tex_scale_location_ = locations[1]; | 208 tex_scale_location_ = locations[1]; |
| 209 tex_offset_location_ = locations[2]; | |
| 209 } | 210 } |
| 210 | 211 |
| 211 std::string VertexShaderPosTexYUVStretch::GetShaderString() const { | 212 std::string VertexShaderPosTexYUVStretchOffset::GetShaderString() const { |
| 212 return VERTEX_SHADER( | 213 return VERTEX_SHADER( |
| 213 precision mediump float; | 214 precision mediump float; |
| 214 attribute vec4 a_position; | 215 attribute vec4 a_position; |
| 215 attribute TexCoordPrecision vec2 a_texCoord; | 216 attribute TexCoordPrecision vec2 a_texCoord; |
| 216 uniform mat4 matrix; | 217 uniform mat4 matrix; |
| 217 varying TexCoordPrecision vec2 v_texCoord; | 218 varying TexCoordPrecision vec2 v_texCoord; |
| 218 uniform TexCoordPrecision vec2 texScale; | 219 uniform TexCoordPrecision vec2 texScale; |
| 220 uniform TexCoordPrecision vec2 texOffset; | |
| 219 void main() { | 221 void main() { |
| 220 gl_Position = matrix * a_position; | 222 gl_Position = matrix * a_position; |
| 221 v_texCoord = a_texCoord * texScale; | 223 v_texCoord = a_texCoord * texScale + texOffset; |
| 222 } | 224 } |
| 223 ); // NOLINT(whitespace/parens) | 225 ); // NOLINT(whitespace/parens) |
| 224 } | 226 } |
| 225 | 227 |
| 226 VertexShaderPos::VertexShaderPos() | 228 VertexShaderPos::VertexShaderPos() |
| 227 : matrix_location_(-1) {} | 229 : matrix_location_(-1) {} |
| 228 | 230 |
| 229 void VertexShaderPos::Init(GLES2Interface* context, | 231 void VertexShaderPos::Init(GLES2Interface* context, |
| 230 unsigned program, | 232 unsigned program, |
| 231 int* base_uniform_index) { | 233 int* base_uniform_index) { |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1529 vec2 texCoord = | 1531 vec2 texCoord = |
| 1530 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; | 1532 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; |
| 1531 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); | 1533 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
| 1532 float picker = abs(coord.x - coord.y); // NOLINT | 1534 float picker = abs(coord.x - coord.y); // NOLINT |
| 1533 gl_FragColor = mix(color1, color2, picker) * alpha; | 1535 gl_FragColor = mix(color1, color2, picker) * alpha; |
| 1534 } | 1536 } |
| 1535 ); // NOLINT(whitespace/parens) | 1537 ); // NOLINT(whitespace/parens) |
| 1536 } | 1538 } |
| 1537 | 1539 |
| 1538 } // namespace cc | 1540 } // namespace cc |
| OLD | NEW |