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

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

Issue 12665005: cc: Use highp precision for texture coords if available and needed (Closed) Base URL: http://git.chromium.org/chromium/src.git@highp2
Patch Set: Rebase on pending Chromification https://codereview.chromium.org/13004003 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
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 #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 #include "third_party/skia/include/core/SkColorPriv.h" 9 #include "third_party/skia/include/core/SkColorPriv.h"
10 10
11 namespace gfx {
12 class Point;
13 }
14
11 namespace WebKit { 15 namespace WebKit {
12 class WebGraphicsContext3D; 16 class WebGraphicsContext3D;
13 } 17 }
14 18
15 namespace cc { 19 namespace cc {
16 20
21 enum TexCoordPrecision {
22 TexCoordPrecisionNA,
23 TexCoordPrecisionMedium,
24 TexCoordPrecisionHigh,
25 };
26
27 int TexCoordHighpThreshold(WebKit::WebGraphicsContext3D* context);
28
29 TexCoordPrecision TexCoordPrecisionRequired(
30 WebKit::WebGraphicsContext3D* context,
31 const gfx::Point& max_coordinate);
32
17 class VertexShaderPosTex { 33 class VertexShaderPosTex {
18 public: 34 public:
19 VertexShaderPosTex(); 35 VertexShaderPosTex();
20 36
21 void Init(WebKit::WebGraphicsContext3D*, 37 void Init(WebKit::WebGraphicsContext3D*,
22 unsigned program, 38 unsigned program,
23 bool using_bind_uniform, 39 bool using_bind_uniform,
24 int* base_uniform_index); 40 int* base_uniform_index);
25 std::string GetShaderString() const; 41 std::string GetShaderString() const;
26 42
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 int edge_location() const { return -1; } 204 int edge_location() const { return -1; }
189 int fragment_tex_transform_location() const { return -1; } 205 int fragment_tex_transform_location() const { return -1; }
190 int sampler_location() const { return sampler_location_; } 206 int sampler_location() const { return sampler_location_; }
191 207
192 private: 208 private:
193 int sampler_location_; 209 int sampler_location_;
194 }; 210 };
195 211
196 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding { 212 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding {
197 public: 213 public:
198 std::string GetShaderString() const; 214 std::string GetShaderString(TexCoordPrecision precision) const;
199 }; 215 };
200 216
201 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { 217 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding {
202 public: 218 public:
203 std::string GetShaderString() const; 219 std::string GetShaderString(TexCoordPrecision precision) const;
204 }; 220 };
205 221
206 class FragmentShaderRGBATexRectVaryingAlpha : public FragmentTexAlphaBinding { 222 class FragmentShaderRGBATexRectVaryingAlpha : public FragmentTexAlphaBinding {
207 public: 223 public:
208 std::string GetShaderString() const; 224 std::string GetShaderString(TexCoordPrecision precision) const;
209 }; 225 };
210 226
211 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { 227 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding {
212 public: 228 public:
213 std::string GetShaderString() const; 229 std::string GetShaderString(TexCoordPrecision precision) const;
214 }; 230 };
215 231
216 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding { 232 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding {
217 public: 233 public:
218 std::string GetShaderString() const; 234 std::string GetShaderString(TexCoordPrecision precision) const;
219 }; 235 };
220 236
221 // Swizzles the red and blue component of sampled texel with alpha. 237 // Swizzles the red and blue component of sampled texel with alpha.
222 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { 238 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding {
223 public: 239 public:
224 std::string GetShaderString() const; 240 std::string GetShaderString(TexCoordPrecision precision) const;
225 }; 241 };
226 242
227 // Swizzles the red and blue component of sampled texel without alpha. 243 // Swizzles the red and blue component of sampled texel without alpha.
228 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding { 244 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding {
229 public: 245 public:
230 std::string GetShaderString() const; 246 std::string GetShaderString(TexCoordPrecision precision) const;
231 }; 247 };
232 248
233 // Fragment shader for external textures. 249 // Fragment shader for external textures.
234 class FragmentShaderOESImageExternal : public FragmentTexAlphaBinding { 250 class FragmentShaderOESImageExternal : public FragmentTexAlphaBinding {
235 public: 251 public:
236 std::string GetShaderString() const; 252 std::string GetShaderString(TexCoordPrecision precision) const;
237 bool Init(WebKit::WebGraphicsContext3D*, 253 bool Init(WebKit::WebGraphicsContext3D*,
238 unsigned program, 254 unsigned program,
239 bool using_bind_uniform, 255 bool using_bind_uniform,
240 int* base_uniform_index); 256 int* base_uniform_index);
241 private: 257 private:
242 int sampler_location_; 258 int sampler_location_;
243 }; 259 };
244 260
245 class FragmentShaderRGBATexAlphaAA { 261 class FragmentShaderRGBATexAlphaAA {
246 public: 262 public:
247 FragmentShaderRGBATexAlphaAA(); 263 FragmentShaderRGBATexAlphaAA();
248 264
249 void Init(WebKit::WebGraphicsContext3D*, 265 void Init(WebKit::WebGraphicsContext3D*,
250 unsigned program, 266 unsigned program,
251 bool using_bind_uniform, 267 bool using_bind_uniform,
252 int* base_uniform_index); 268 int* base_uniform_index);
253 std::string GetShaderString() const; 269 std::string GetShaderString(TexCoordPrecision precision) const;
254 270
255 int alpha_location() const { return alpha_location_; } 271 int alpha_location() const { return alpha_location_; }
256 int sampler_location() const { return sampler_location_; } 272 int sampler_location() const { return sampler_location_; }
257 int edge_location() const { return edge_location_; } 273 int edge_location() const { return edge_location_; }
258 274
259 private: 275 private:
260 int sampler_location_; 276 int sampler_location_;
261 int alpha_location_; 277 int alpha_location_;
262 int edge_location_; 278 int edge_location_;
263 }; 279 };
(...skipping 16 matching lines...) Expand all
280 private: 296 private:
281 int sampler_location_; 297 int sampler_location_;
282 int alpha_location_; 298 int alpha_location_;
283 int fragment_tex_transform_location_; 299 int fragment_tex_transform_location_;
284 int edge_location_; 300 int edge_location_;
285 }; 301 };
286 302
287 class FragmentShaderRGBATexClampAlphaAA : 303 class FragmentShaderRGBATexClampAlphaAA :
288 public FragmentTexClampAlphaAABinding { 304 public FragmentTexClampAlphaAABinding {
289 public: 305 public:
290 std::string GetShaderString() const; 306 std::string GetShaderString(TexCoordPrecision precision) const;
291 }; 307 };
292 308
293 // Swizzles the red and blue component of sampled texel. 309 // Swizzles the red and blue component of sampled texel.
294 class FragmentShaderRGBATexClampSwizzleAlphaAA : 310 class FragmentShaderRGBATexClampSwizzleAlphaAA :
295 public FragmentTexClampAlphaAABinding { 311 public FragmentTexClampAlphaAABinding {
296 public: 312 public:
297 std::string GetShaderString() const; 313 std::string GetShaderString(TexCoordPrecision precision) const;
298 }; 314 };
299 315
300 class FragmentShaderRGBATexAlphaMask { 316 class FragmentShaderRGBATexAlphaMask {
301 public: 317 public:
302 FragmentShaderRGBATexAlphaMask(); 318 FragmentShaderRGBATexAlphaMask();
303 std::string GetShaderString() const; 319 std::string GetShaderString(TexCoordPrecision precision) const;
304 320
305 void Init(WebKit::WebGraphicsContext3D*, 321 void Init(WebKit::WebGraphicsContext3D*,
306 unsigned program, 322 unsigned program,
307 bool using_bind_uniform, 323 bool using_bind_uniform,
308 int* base_uniform_index); 324 int* base_uniform_index);
309 int alpha_location() const { return alpha_location_; } 325 int alpha_location() const { return alpha_location_; }
310 int sampler_location() const { return sampler_location_; } 326 int sampler_location() const { return sampler_location_; }
311 int mask_sampler_location() const { return mask_sampler_location_; } 327 int mask_sampler_location() const { return mask_sampler_location_; }
312 int mask_tex_coord_scale_location() const { 328 int mask_tex_coord_scale_location() const {
313 return mask_tex_coord_scale_location_; 329 return mask_tex_coord_scale_location_;
314 } 330 }
315 int mask_tex_coord_offset_location() const { 331 int mask_tex_coord_offset_location() const {
316 return mask_tex_coord_offset_location_; 332 return mask_tex_coord_offset_location_;
317 } 333 }
318 334
319 private: 335 private:
320 int sampler_location_; 336 int sampler_location_;
321 int mask_sampler_location_; 337 int mask_sampler_location_;
322 int alpha_location_; 338 int alpha_location_;
323 int mask_tex_coord_scale_location_; 339 int mask_tex_coord_scale_location_;
324 int mask_tex_coord_offset_location_; 340 int mask_tex_coord_offset_location_;
325 }; 341 };
326 342
327 class FragmentShaderRGBATexAlphaMaskAA { 343 class FragmentShaderRGBATexAlphaMaskAA {
328 public: 344 public:
329 FragmentShaderRGBATexAlphaMaskAA(); 345 FragmentShaderRGBATexAlphaMaskAA();
330 std::string GetShaderString() const; 346 std::string GetShaderString(TexCoordPrecision precision) const;
331 347
332 void Init(WebKit::WebGraphicsContext3D*, 348 void Init(WebKit::WebGraphicsContext3D*,
333 unsigned program, 349 unsigned program,
334 bool using_bind_uniform, 350 bool using_bind_uniform,
335 int* base_uniform_index); 351 int* base_uniform_index);
336 int alpha_location() const { return alpha_location_; } 352 int alpha_location() const { return alpha_location_; }
337 int sampler_location() const { return sampler_location_; } 353 int sampler_location() const { return sampler_location_; }
338 int mask_sampler_location() const { return mask_sampler_location_; } 354 int mask_sampler_location() const { return mask_sampler_location_; }
339 int edge_location() const { return edge_location_; } 355 int edge_location() const { return edge_location_; }
340 int mask_tex_coord_scale_location() const { 356 int mask_tex_coord_scale_location() const {
341 return mask_tex_coord_scale_location_; 357 return mask_tex_coord_scale_location_;
342 } 358 }
343 int mask_tex_coord_offset_location() const { 359 int mask_tex_coord_offset_location() const {
344 return mask_tex_coord_offset_location_; 360 return mask_tex_coord_offset_location_;
345 } 361 }
346 362
347 private: 363 private:
348 int sampler_location_; 364 int sampler_location_;
349 int mask_sampler_location_; 365 int mask_sampler_location_;
350 int alpha_location_; 366 int alpha_location_;
351 int edge_location_; 367 int edge_location_;
352 int mask_tex_coord_scale_location_; 368 int mask_tex_coord_scale_location_;
353 int mask_tex_coord_offset_location_; 369 int mask_tex_coord_offset_location_;
354 }; 370 };
355 371
356 class FragmentShaderYUVVideo { 372 class FragmentShaderYUVVideo {
357 public: 373 public:
358 FragmentShaderYUVVideo(); 374 FragmentShaderYUVVideo();
359 std::string GetShaderString() const; 375 std::string GetShaderString(TexCoordPrecision precision) const;
360 376
361 void Init(WebKit::WebGraphicsContext3D*, 377 void Init(WebKit::WebGraphicsContext3D*,
362 unsigned program, 378 unsigned program,
363 bool using_bind_uniform, 379 bool using_bind_uniform,
364 int* base_uniform_index); 380 int* base_uniform_index);
365 int y_texture_location() const { return y_texture_location_; } 381 int y_texture_location() const { return y_texture_location_; }
366 int u_texture_location() const { return u_texture_location_; } 382 int u_texture_location() const { return u_texture_location_; }
367 int v_texture_location() const { return v_texture_location_; } 383 int v_texture_location() const { return v_texture_location_; }
368 int alpha_location() const { return alpha_location_; } 384 int alpha_location() const { return alpha_location_; }
369 int yuv_matrix_location() const { return yuv_matrix_location_; } 385 int yuv_matrix_location() const { return yuv_matrix_location_; }
370 int yuv_adj_location() const { return yuv_adj_location_; } 386 int yuv_adj_location() const { return yuv_adj_location_; }
371 387
372 private: 388 private:
373 int y_texture_location_; 389 int y_texture_location_;
374 int u_texture_location_; 390 int u_texture_location_;
375 int v_texture_location_; 391 int v_texture_location_;
376 int alpha_location_; 392 int alpha_location_;
377 int yuv_matrix_location_; 393 int yuv_matrix_location_;
378 int yuv_adj_location_; 394 int yuv_adj_location_;
379 }; 395 };
380 396
381 class FragmentShaderColor { 397 class FragmentShaderColor {
382 public: 398 public:
383 FragmentShaderColor(); 399 FragmentShaderColor();
384 std::string GetShaderString() const; 400 std::string GetShaderString(TexCoordPrecision precision) const;
385 401
386 void Init(WebKit::WebGraphicsContext3D*, 402 void Init(WebKit::WebGraphicsContext3D*,
387 unsigned program, 403 unsigned program,
388 bool using_bind_uniform, 404 bool using_bind_uniform,
389 int* base_uniform_index); 405 int* base_uniform_index);
390 int edge_location() const { return -1; } 406 int edge_location() const { return -1; }
391 int color_location() const { return color_location_; } 407 int color_location() const { return color_location_; }
392 408
393 private: 409 private:
394 int color_location_; 410 int color_location_;
395 }; 411 };
396 412
397 class FragmentShaderColorAA { 413 class FragmentShaderColorAA {
398 public: 414 public:
399 FragmentShaderColorAA(); 415 FragmentShaderColorAA();
400 std::string GetShaderString() const; 416 std::string GetShaderString(TexCoordPrecision precision) const;
401 417
402 void Init(WebKit::WebGraphicsContext3D*, 418 void Init(WebKit::WebGraphicsContext3D*,
403 unsigned program, 419 unsigned program,
404 bool using_bind_uniform, 420 bool using_bind_uniform,
405 int* base_uniform_index); 421 int* base_uniform_index);
406 int edge_location() const { return edge_location_; } 422 int edge_location() const { return edge_location_; }
407 int color_location() const { return color_location_; } 423 int color_location() const { return color_location_; }
408 424
409 private: 425 private:
410 int edge_location_; 426 int edge_location_;
411 int color_location_; 427 int color_location_;
412 }; 428 };
413 429
414 class FragmentShaderCheckerboard { 430 class FragmentShaderCheckerboard {
415 public: 431 public:
416 FragmentShaderCheckerboard(); 432 FragmentShaderCheckerboard();
417 std::string GetShaderString() const; 433 std::string GetShaderString(TexCoordPrecision precision) const;
418 434
419 void Init(WebKit::WebGraphicsContext3D*, 435 void Init(WebKit::WebGraphicsContext3D*,
420 unsigned program, 436 unsigned program,
421 bool using_bind_uniform, 437 bool using_bind_uniform,
422 int* base_uniform_index); 438 int* base_uniform_index);
423 int alpha_location() const { return alpha_location_; } 439 int alpha_location() const { return alpha_location_; }
424 int tex_transform_location() const { return tex_transform_location_; } 440 int tex_transform_location() const { return tex_transform_location_; }
425 int frequency_location() const { return frequency_location_; } 441 int frequency_location() const { return frequency_location_; }
426 int color_location() const { return color_location_; } 442 int color_location() const { return color_location_; }
427 443
428 private: 444 private:
429 int alpha_location_; 445 int alpha_location_;
430 int tex_transform_location_; 446 int tex_transform_location_;
431 int frequency_location_; 447 int frequency_location_;
432 int color_location_; 448 int color_location_;
433 }; 449 };
434 450
435 } // namespace cc 451 } // namespace cc
436 452
437 #endif // CC_OUTPUT_SHADER_H_ 453 #endif // CC_OUTPUT_SHADER_H_
OLDNEW
« no previous file with comments | « cc/output/program_binding.h ('k') | cc/output/shader.cc » ('j') | cc/output/shader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698