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/shader.h" | 5 #include "cc/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 <public/WebGraphicsContext3D.h> | 9 #include <public/WebGraphicsContext3D.h> |
| 10 | 10 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 m_matrixLocation = locations[0]; | 152 m_matrixLocation = locations[0]; |
| 153 m_texTransformLocation = locations[1]; | 153 m_texTransformLocation = locations[1]; |
| 154 DCHECK(m_matrixLocation != -1 && m_texTransformLocation != -1); | 154 DCHECK(m_matrixLocation != -1 && m_texTransformLocation != -1); |
| 155 } | 155 } |
| 156 | 156 |
| 157 std::string VertexShaderPosTexTransform::getShaderString() const | 157 std::string VertexShaderPosTexTransform::getShaderString() const |
| 158 { | 158 { |
| 159 return SHADER( | 159 return SHADER( |
| 160 attribute vec4 a_position; | 160 attribute vec4 a_position; |
| 161 attribute vec2 a_texCoord; | 161 attribute vec2 a_texCoord; |
| 162 uniform mat4 matrix; | 162 attribute float a_index; |
|
shawnsingh
2012/11/28 19:44:16
If my prior comment about using the array of struc
| |
| 163 uniform vec4 texTransform; | 163 uniform mat4 matrix[8]; |
| 164 uniform vec4 texTransform[8]; | |
| 164 varying vec2 v_texCoord; | 165 varying vec2 v_texCoord; |
| 165 void main() | 166 void main() |
| 166 { | 167 { |
| 167 gl_Position = matrix * a_position; | 168 gl_Position = matrix[int(a_index)] * a_position; |
| 168 v_texCoord = a_texCoord * texTransform.zw + texTransform.xy; | 169 v_texCoord = a_texCoord * texTransform[int(a_index)].zw + texTransfo rm[int(a_index)].xy; |
| 169 } | 170 } |
| 170 ); | 171 ); |
| 171 } | 172 } |
| 172 | 173 |
| 173 VertexShaderQuad::VertexShaderQuad() | 174 VertexShaderQuad::VertexShaderQuad() |
| 174 : m_matrixLocation(-1) | 175 : m_matrixLocation(-1) |
| 175 , m_pointLocation(-1) | 176 , m_pointLocation(-1) |
| 176 { | 177 { |
| 177 } | 178 } |
| 178 | 179 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 vec4 color2 = color; | 868 vec4 color2 = color; |
| 868 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT ransform.xy; | 869 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT ransform.xy; |
| 869 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); | 870 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
| 870 float picker = abs(coord.x - coord.y); | 871 float picker = abs(coord.x - coord.y); |
| 871 gl_FragColor = mix(color1, color2, picker) * alpha; | 872 gl_FragColor = mix(color1, color2, picker) * alpha; |
| 872 } | 873 } |
| 873 ); | 874 ); |
| 874 } | 875 } |
| 875 | 876 |
| 876 } // namespace cc | 877 } // namespace cc |
| OLD | NEW |