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 #ifndef CC_OUTPUT_SHADER_H_ | 5 #ifndef CC_OUTPUT_SHADER_H_ |
6 #define CC_OUTPUT_SHADER_H_ | 6 #define CC_OUTPUT_SHADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 int* highp_threshold_cache, | 106 int* highp_threshold_cache, |
107 int highp_threshold_min, | 107 int highp_threshold_min, |
108 const gfx::Point& max_coordinate); | 108 const gfx::Point& max_coordinate); |
109 | 109 |
110 CC_EXPORT TexCoordPrecision TexCoordPrecisionRequired( | 110 CC_EXPORT TexCoordPrecision TexCoordPrecisionRequired( |
111 gpu::gles2::GLES2Interface* context, | 111 gpu::gles2::GLES2Interface* context, |
112 int *highp_threshold_cache, | 112 int *highp_threshold_cache, |
113 int highp_threshold_min, | 113 int highp_threshold_min, |
114 const gfx::Size& max_size); | 114 const gfx::Size& max_size); |
115 | 115 |
116 class VertexShaderPosTex { | 116 class VertexShaderBase { |
117 public: | 117 public: |
118 VertexShaderPosTex(); | 118 VertexShaderBase(); |
119 | |
120 void Init(gpu::gles2::GLES2Interface* context, | 119 void Init(gpu::gles2::GLES2Interface* context, |
121 unsigned program, | 120 unsigned program, |
122 int* base_uniform_index); | 121 int* base_uniform_index); |
123 std::string GetShaderString() const; | 122 std::string GetShaderString() const; |
124 static std::string GetShaderHead(); | 123 void FillLocations(ShaderLocations* locations) const; |
125 static std::string GetShaderBody(); | |
126 | 124 |
127 int matrix_location() const { return matrix_location_; } | 125 int tex_transform_location() const { return tex_transform_location_; } |
128 | 126 |
129 private: | 127 int vertex_tex_transform_location() const { |
130 int matrix_location_; | 128 return vertex_tex_transform_location_; |
129 } | |
131 | 130 |
132 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTex); | 131 int tex_matrix_location() const { return tex_matrix_location_; } |
133 }; | |
134 | 132 |
135 class VertexShaderPosTexYUVStretchOffset { | |
136 public: | |
137 VertexShaderPosTexYUVStretchOffset(); | |
138 | |
139 void Init(gpu::gles2::GLES2Interface* context, | |
140 unsigned program, | |
141 int* base_uniform_index); | |
142 std::string GetShaderString() const; | |
143 static std::string GetShaderHead(); | |
144 static std::string GetShaderBody(); | |
145 | |
146 int matrix_location() const { return matrix_location_; } | |
147 int ya_tex_scale_location() const { return ya_tex_scale_location_; } | 133 int ya_tex_scale_location() const { return ya_tex_scale_location_; } |
148 int ya_tex_offset_location() const { return ya_tex_offset_location_; } | 134 int ya_tex_offset_location() const { return ya_tex_offset_location_; } |
149 int uv_tex_scale_location() const { return uv_tex_scale_location_; } | 135 int uv_tex_scale_location() const { return uv_tex_scale_location_; } |
150 int uv_tex_offset_location() const { return uv_tex_offset_location_; } | 136 int uv_tex_offset_location() const { return uv_tex_offset_location_; } |
151 | 137 |
152 private: | 138 int matrix_location() const { return matrix_location_; } |
153 int matrix_location_; | |
154 int ya_tex_scale_location_; | |
155 int ya_tex_offset_location_; | |
156 int uv_tex_scale_location_; | |
157 int uv_tex_offset_location_; | |
158 | 139 |
159 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexYUVStretchOffset); | 140 int vertex_opacity_location() const { return vertex_opacity_location_; } |
141 | |
142 int viewport_location() const { return viewport_location_; } | |
143 int edge_location() const { return edge_location_; } | |
144 | |
145 int quad_location() const { return quad_location_; } | |
146 | |
147 protected: | |
148 virtual std::string GetShaderSource() const = 0; | |
149 | |
ccameron
2017/01/04 09:06:12
has_tex_transform_, has_vertex_tex_transform, has_
| |
150 bool has_tex_transform_ = false; | |
151 int tex_transform_location_ = -1; | |
152 | |
153 bool has_vertex_tex_transform_ = false; | |
154 int vertex_tex_transform_location_ = -1; | |
155 | |
156 bool has_tex_matrix_ = false; | |
157 int tex_matrix_location_ = -1; | |
158 | |
159 bool has_ya_uv_tex_scale_offset_ = false; | |
160 int ya_tex_scale_location_ = -1; | |
161 int ya_tex_offset_location_ = -1; | |
162 int uv_tex_scale_location_ = -1; | |
163 int uv_tex_offset_location_ = -1; | |
164 | |
165 bool has_matrix_ = false; | |
166 int matrix_location_ = -1; | |
167 | |
168 bool has_vertex_opacity_ = false; | |
169 int vertex_opacity_location_ = -1; | |
170 | |
171 bool has_aa_ = false; | |
172 int viewport_location_ = -1; | |
173 int edge_location_ = -1; | |
174 | |
175 bool has_quad_ = false; | |
176 int quad_location_ = -1; | |
160 }; | 177 }; |
161 | 178 |
162 class VertexShaderPos { | 179 class VertexShaderPosTex : public VertexShaderBase { |
163 public: | 180 public: |
164 VertexShaderPos(); | 181 VertexShaderPosTex() { has_matrix_ = true; } |
165 | 182 std::string GetShaderSource() const override; |
166 void Init(gpu::gles2::GLES2Interface* context, | |
167 unsigned program, | |
168 int* base_uniform_index); | |
169 std::string GetShaderString() const; | |
170 static std::string GetShaderHead(); | |
171 static std::string GetShaderBody(); | |
172 | |
173 int matrix_location() const { return matrix_location_; } | |
174 | |
175 private: | |
176 int matrix_location_; | |
177 | |
178 DISALLOW_COPY_AND_ASSIGN(VertexShaderPos); | |
179 }; | 183 }; |
180 | 184 |
181 class VertexShaderPosTexIdentity { | 185 class VertexShaderPosTexYUVStretchOffset : public VertexShaderBase { |
182 public: | 186 public: |
183 void Init(gpu::gles2::GLES2Interface* context, | 187 VertexShaderPosTexYUVStretchOffset() { |
184 unsigned program, | 188 has_matrix_ = true; |
185 int* base_uniform_index) {} | 189 has_ya_uv_tex_scale_offset_ = true; |
186 std::string GetShaderString() const; | 190 } |
187 static std::string GetShaderHead(); | 191 std::string GetShaderSource() const override; |
188 static std::string GetShaderBody(); | |
189 }; | 192 }; |
190 | 193 |
191 class VertexShaderPosTexTransform { | 194 class VertexShaderPos : public VertexShaderBase { |
192 public: | 195 public: |
193 VertexShaderPosTexTransform(); | 196 VertexShaderPos() { has_matrix_ = true; } |
194 | 197 std::string GetShaderSource() const override; |
195 void Init(gpu::gles2::GLES2Interface* context, | |
196 unsigned program, | |
197 int* base_uniform_index); | |
198 std::string GetShaderString() const; | |
199 static std::string GetShaderHead(); | |
200 static std::string GetShaderBody(); | |
201 void FillLocations(ShaderLocations* locations) const; | |
202 | |
203 int matrix_location() const { return matrix_location_; } | |
204 int tex_transform_location() const { return tex_transform_location_; } | |
205 int vertex_opacity_location() const { return vertex_opacity_location_; } | |
206 | |
207 private: | |
208 int matrix_location_; | |
209 int tex_transform_location_; | |
210 int vertex_opacity_location_; | |
211 | |
212 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexTransform); | |
213 }; | 198 }; |
214 | 199 |
215 class VertexShaderQuad { | 200 class VertexShaderPosTexIdentity : public VertexShaderBase { |
216 public: | 201 public: |
217 VertexShaderQuad(); | 202 std::string GetShaderSource() const override; |
218 | |
219 void Init(gpu::gles2::GLES2Interface* context, | |
220 unsigned program, | |
221 int* base_uniform_index); | |
222 std::string GetShaderString() const; | |
223 static std::string GetShaderHead(); | |
224 static std::string GetShaderBody(); | |
225 | |
226 int matrix_location() const { return matrix_location_; } | |
227 int viewport_location() const { return -1; } | |
228 int quad_location() const { return quad_location_; } | |
229 int edge_location() const { return -1; } | |
230 | |
231 private: | |
232 int matrix_location_; | |
233 int quad_location_; | |
234 | |
235 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuad); | |
236 }; | 203 }; |
237 | 204 |
238 class VertexShaderQuadAA { | 205 class VertexShaderPosTexTransform : public VertexShaderBase { |
239 public: | 206 public: |
240 VertexShaderQuadAA(); | 207 VertexShaderPosTexTransform() { |
241 | 208 has_matrix_ = true; |
242 void Init(gpu::gles2::GLES2Interface* context, | 209 has_tex_transform_ = true; |
243 unsigned program, | 210 has_vertex_opacity_ = true; |
244 int* base_uniform_index); | 211 } |
245 std::string GetShaderString() const; | 212 std::string GetShaderSource() const override; |
246 static std::string GetShaderHead(); | |
247 static std::string GetShaderBody(); | |
248 | |
249 int matrix_location() const { return matrix_location_; } | |
250 int viewport_location() const { return viewport_location_; } | |
251 int quad_location() const { return quad_location_; } | |
252 int edge_location() const { return edge_location_; } | |
253 | |
254 private: | |
255 int matrix_location_; | |
256 int viewport_location_; | |
257 int quad_location_; | |
258 int edge_location_; | |
259 | |
260 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadAA); | |
261 }; | 213 }; |
262 | 214 |
263 | 215 class VertexShaderQuad : public VertexShaderBase { |
264 class VertexShaderQuadTexTransformAA { | |
265 public: | 216 public: |
266 VertexShaderQuadTexTransformAA(); | 217 VertexShaderQuad() { |
267 | 218 has_matrix_ = true; |
268 void Init(gpu::gles2::GLES2Interface* context, | 219 has_quad_ = true; |
269 unsigned program, | 220 } |
270 int* base_uniform_index); | 221 std::string GetShaderSource() const override; |
271 std::string GetShaderString() const; | |
272 static std::string GetShaderHead(); | |
273 static std::string GetShaderBody(); | |
274 void FillLocations(ShaderLocations* locations) const; | |
275 | |
276 int matrix_location() const { return matrix_location_; } | |
277 int viewport_location() const { return viewport_location_; } | |
278 int quad_location() const { return quad_location_; } | |
279 int edge_location() const { return edge_location_; } | |
280 int tex_transform_location() const { return tex_transform_location_; } | |
281 | |
282 private: | |
283 int matrix_location_; | |
284 int viewport_location_; | |
285 int quad_location_; | |
286 int edge_location_; | |
287 int tex_transform_location_; | |
288 | |
289 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadTexTransformAA); | |
290 }; | 222 }; |
291 | 223 |
292 class VertexShaderTile { | 224 class VertexShaderQuadAA : public VertexShaderBase { |
293 public: | 225 public: |
294 VertexShaderTile(); | 226 VertexShaderQuadAA() { |
295 | 227 has_matrix_ = true; |
296 void Init(gpu::gles2::GLES2Interface* context, | 228 has_aa_ = true; |
297 unsigned program, | 229 has_quad_ = true; |
298 int* base_uniform_index); | |
299 std::string GetShaderString() const; | |
300 static std::string GetShaderHead(); | |
301 static std::string GetShaderBody(); | |
302 | |
303 int matrix_location() const { return matrix_location_; } | |
304 int viewport_location() const { return -1; } | |
305 int quad_location() const { return quad_location_; } | |
306 int edge_location() const { return -1; } | |
307 int vertex_tex_transform_location() const { | |
308 return vertex_tex_transform_location_; | |
309 } | 230 } |
310 | 231 std::string GetShaderSource() const override; |
311 private: | |
312 int matrix_location_; | |
313 int quad_location_; | |
314 int vertex_tex_transform_location_; | |
315 | |
316 DISALLOW_COPY_AND_ASSIGN(VertexShaderTile); | |
317 }; | 232 }; |
318 | 233 |
319 class VertexShaderTileAA { | 234 class VertexShaderQuadTexTransformAA : public VertexShaderBase { |
320 public: | 235 public: |
321 VertexShaderTileAA(); | 236 VertexShaderQuadTexTransformAA() { |
322 | 237 has_matrix_ = true; |
323 void Init(gpu::gles2::GLES2Interface* context, | 238 has_aa_ = true; |
324 unsigned program, | 239 has_quad_ = true; |
325 int* base_uniform_index); | 240 has_tex_transform_ = true; |
326 std::string GetShaderString() const; | |
327 static std::string GetShaderHead(); | |
328 static std::string GetShaderBody(); | |
329 | |
330 int matrix_location() const { return matrix_location_; } | |
331 int viewport_location() const { return viewport_location_; } | |
332 int quad_location() const { return quad_location_; } | |
333 int edge_location() const { return edge_location_; } | |
334 int vertex_tex_transform_location() const { | |
335 return vertex_tex_transform_location_; | |
336 } | 241 } |
337 | 242 std::string GetShaderSource() const override; |
338 private: | |
339 int matrix_location_; | |
340 int viewport_location_; | |
341 int quad_location_; | |
342 int edge_location_; | |
343 int vertex_tex_transform_location_; | |
344 | |
345 DISALLOW_COPY_AND_ASSIGN(VertexShaderTileAA); | |
346 }; | 243 }; |
347 | 244 |
348 class VertexShaderVideoTransform { | 245 class VertexShaderTile : public VertexShaderBase { |
349 public: | 246 public: |
350 VertexShaderVideoTransform(); | 247 VertexShaderTile() { |
248 has_matrix_ = true; | |
249 has_quad_ = true; | |
250 has_vertex_tex_transform_ = true; | |
251 } | |
252 std::string GetShaderSource() const override; | |
253 }; | |
351 | 254 |
352 void Init(gpu::gles2::GLES2Interface* context, | 255 class VertexShaderTileAA : public VertexShaderBase { |
353 unsigned program, | 256 public: |
354 int* base_uniform_index); | 257 VertexShaderTileAA() { |
355 std::string GetShaderString() const; | 258 has_matrix_ = true; |
356 static std::string GetShaderHead(); | 259 has_quad_ = true; |
357 static std::string GetShaderBody(); | 260 has_vertex_tex_transform_ = true; |
261 has_aa_ = true; | |
262 } | |
263 std::string GetShaderSource() const override; | |
264 }; | |
358 | 265 |
359 int matrix_location() const { return matrix_location_; } | 266 class VertexShaderVideoTransform : public VertexShaderBase { |
360 int tex_matrix_location() const { return tex_matrix_location_; } | 267 public: |
361 | 268 VertexShaderVideoTransform() { |
362 private: | 269 has_matrix_ = true; |
363 int matrix_location_; | 270 has_tex_matrix_ = true; |
364 int tex_matrix_location_; | 271 } |
365 | 272 std::string GetShaderSource() const override; |
366 DISALLOW_COPY_AND_ASSIGN(VertexShaderVideoTransform); | |
367 }; | 273 }; |
368 | 274 |
369 class FragmentShaderBase { | 275 class FragmentShaderBase { |
370 public: | 276 public: |
371 virtual void Init(gpu::gles2::GLES2Interface* context, | 277 virtual void Init(gpu::gles2::GLES2Interface* context, |
372 unsigned program, | 278 unsigned program, |
373 int* base_uniform_index); | 279 int* base_uniform_index); |
374 std::string GetShaderString(TexCoordPrecision precision, | 280 std::string GetShaderString(TexCoordPrecision precision, |
375 SamplerType sampler) const; | 281 SamplerType sampler) const; |
376 void FillLocations(ShaderLocations* locations) const; | 282 void FillLocations(ShaderLocations* locations) const; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 FragmentShaderColorAA() { | 582 FragmentShaderColorAA() { |
677 input_color_type_ = INPUT_COLOR_SOURCE_UNIFORM; | 583 input_color_type_ = INPUT_COLOR_SOURCE_UNIFORM; |
678 has_aa_ = true; | 584 has_aa_ = true; |
679 frag_color_mode_ = FRAG_COLOR_MODE_DEFAULT; | 585 frag_color_mode_ = FRAG_COLOR_MODE_DEFAULT; |
680 } | 586 } |
681 }; | 587 }; |
682 | 588 |
683 } // namespace cc | 589 } // namespace cc |
684 | 590 |
685 #endif // CC_OUTPUT_SHADER_H_ | 591 #endif // CC_OUTPUT_SHADER_H_ |
OLD | NEW |