OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void main() | 117 void main() |
118 { | 118 { |
119 gl_Position = matrix * a_position; | 119 gl_Position = matrix * a_position; |
120 } | 120 } |
121 ); | 121 ); |
122 } | 122 } |
123 | 123 |
124 VertexShaderPosTexTransform::VertexShaderPosTexTransform() | 124 VertexShaderPosTexTransform::VertexShaderPosTexTransform() |
125 : m_matrixLocation(-1) | 125 : m_matrixLocation(-1) |
126 , m_texTransformLocation(-1) | 126 , m_texTransformLocation(-1) |
127 , m_pointLocation(-1) | |
128 { | 127 { |
129 } | 128 } |
130 | 129 |
131 void VertexShaderPosTexTransform::init(GraphicsContext3D* context, unsigned prog
ram) | 130 void VertexShaderPosTexTransform::init(GraphicsContext3D* context, unsigned prog
ram) |
132 { | 131 { |
133 m_matrixLocation = context->getUniformLocation(program, "matrix"); | 132 m_matrixLocation = context->getUniformLocation(program, "matrix"); |
134 m_texTransformLocation = context->getUniformLocation(program, "texTransform"
); | 133 m_texTransformLocation = context->getUniformLocation(program, "texTransform"
); |
| 134 ASSERT(m_matrixLocation != -1 && m_texTransformLocation != -1); |
| 135 } |
| 136 |
| 137 String VertexShaderPosTexTransform::getShaderString() const |
| 138 { |
| 139 return SHADER( |
| 140 attribute vec4 a_position; |
| 141 attribute vec2 a_texCoord; |
| 142 uniform mat4 matrix; |
| 143 uniform vec4 texTransform; |
| 144 varying vec2 v_texCoord; |
| 145 void main() |
| 146 { |
| 147 gl_Position = matrix * a_position; |
| 148 v_texCoord = a_texCoord * texTransform.zw + texTransform.xy; |
| 149 } |
| 150 ); |
| 151 } |
| 152 |
| 153 VertexShaderQuad::VertexShaderQuad() |
| 154 : m_matrixLocation(-1) |
| 155 , m_texTransformLocation(-1) |
| 156 , m_pointLocation(-1) |
| 157 { |
| 158 } |
| 159 |
| 160 void VertexShaderQuad::init(GraphicsContext3D* context, unsigned program) |
| 161 { |
| 162 m_matrixLocation = context->getUniformLocation(program, "matrix"); |
| 163 m_texTransformLocation = context->getUniformLocation(program, "texTransform"
); |
135 m_pointLocation = context->getUniformLocation(program, "point"); | 164 m_pointLocation = context->getUniformLocation(program, "point"); |
136 ASSERT(m_matrixLocation != -1 && m_texTransformLocation != -1 && m_pointLoca
tion != -1); | 165 ASSERT(m_matrixLocation != -1 && m_texTransformLocation != -1 && m_pointLoca
tion != -1); |
137 } | 166 } |
138 | 167 |
139 String VertexShaderPosTexTransform::getShaderString() const | 168 String VertexShaderQuad::getShaderString() const |
140 { | 169 { |
141 return SHADER( | 170 return SHADER( |
142 attribute vec4 a_position; | 171 attribute vec4 a_position; |
143 attribute vec2 a_texCoord; | 172 attribute vec2 a_texCoord; |
144 uniform mat4 matrix; | 173 uniform mat4 matrix; |
145 uniform vec4 texTransform; | 174 uniform vec4 texTransform; |
146 uniform vec2 point[4]; | 175 uniform vec2 point[4]; |
147 varying vec2 v_texCoord; | 176 varying vec2 v_texCoord; |
148 void main() | 177 void main() |
149 { | 178 { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 void main() | 346 void main() |
318 { | 347 { |
319 gl_FragColor = vec4(color.xyz * color.w, color.w); | 348 gl_FragColor = vec4(color.xyz * color.w, color.w); |
320 } | 349 } |
321 ); | 350 ); |
322 } | 351 } |
323 | 352 |
324 } // namespace WebCore | 353 } // namespace WebCore |
325 | 354 |
326 #endif // USE(ACCELERATED_COMPOSITING) | 355 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |