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

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: Dynamically set highp threshold based on actual mediump precision 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*, unsigned program, bool usingBindUni form, int* baseUniformIndex); 37 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex);
22 std::string getShaderString() const; 38 std::string getShaderString() const;
23 39
24 int matrixLocation() const { return m_matrixLocation; } 40 int matrixLocation() const { return m_matrixLocation; }
25 41
26 private: 42 private:
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 int edgeLocation() const { return -1; } 172 int edgeLocation() const { return -1; }
157 int fragmentTexTransformLocation() const { return -1; } 173 int fragmentTexTransformLocation() const { return -1; }
158 int samplerLocation() const { return m_samplerLocation; } 174 int samplerLocation() const { return m_samplerLocation; }
159 175
160 private: 176 private:
161 int m_samplerLocation; 177 int m_samplerLocation;
162 }; 178 };
163 179
164 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding { 180 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding {
165 public: 181 public:
166 std::string getShaderString() const; 182 std::string getShaderString(TexCoordPrecision precision) const;
167 }; 183 };
168 184
169 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { 185 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding {
170 public: 186 public:
171 std::string getShaderString() const; 187 std::string getShaderString(TexCoordPrecision precision) const;
172 }; 188 };
173 189
174 class FragmentShaderRGBATexRectVaryingAlpha : public FragmentTexAlphaBinding { 190 class FragmentShaderRGBATexRectVaryingAlpha : public FragmentTexAlphaBinding {
175 public: 191 public:
176 std::string getShaderString() const; 192 std::string getShaderString(TexCoordPrecision precision) const;
177 }; 193 };
178 194
179 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { 195 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding {
180 public: 196 public:
181 std::string getShaderString() const; 197 std::string getShaderString(TexCoordPrecision precision) const;
182 }; 198 };
183 199
184 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding { 200 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding {
185 public: 201 public:
186 std::string getShaderString() const; 202 std::string getShaderString(TexCoordPrecision precision) const;
187 }; 203 };
188 204
189 // Swizzles the red and blue component of sampled texel with alpha. 205 // Swizzles the red and blue component of sampled texel with alpha.
190 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { 206 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding {
191 public: 207 public:
192 std::string getShaderString() const; 208 std::string getShaderString(TexCoordPrecision precision) const;
193 }; 209 };
194 210
195 // Swizzles the red and blue component of sampled texel without alpha. 211 // Swizzles the red and blue component of sampled texel without alpha.
196 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding { 212 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding {
197 public: 213 public:
198 std::string getShaderString() const; 214 std::string getShaderString(TexCoordPrecision precision) const;
199 }; 215 };
200 216
201 // Fragment shader for external textures. 217 // Fragment shader for external textures.
202 class FragmentShaderOESImageExternal : public FragmentTexAlphaBinding { 218 class FragmentShaderOESImageExternal : public FragmentTexAlphaBinding {
203 public: 219 public:
204 std::string getShaderString() const; 220 std::string getShaderString(TexCoordPrecision precision) const;
205 bool init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex); 221 bool init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex);
206 private: 222 private:
207 int m_samplerLocation; 223 int m_samplerLocation;
208 }; 224 };
209 225
210 class FragmentShaderRGBATexAlphaAA { 226 class FragmentShaderRGBATexAlphaAA {
211 public: 227 public:
212 FragmentShaderRGBATexAlphaAA(); 228 FragmentShaderRGBATexAlphaAA();
213 229
214 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex); 230 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex);
215 std::string getShaderString() const; 231 std::string getShaderString(TexCoordPrecision precision) const;
216 232
217 int alphaLocation() const { return m_alphaLocation; } 233 int alphaLocation() const { return m_alphaLocation; }
218 int samplerLocation() const { return m_samplerLocation; } 234 int samplerLocation() const { return m_samplerLocation; }
219 int edgeLocation() const { return m_edgeLocation; } 235 int edgeLocation() const { return m_edgeLocation; }
220 236
221 private: 237 private:
222 int m_samplerLocation; 238 int m_samplerLocation;
223 int m_alphaLocation; 239 int m_alphaLocation;
224 int m_edgeLocation; 240 int m_edgeLocation;
225 }; 241 };
(...skipping 10 matching lines...) Expand all
236 252
237 private: 253 private:
238 int m_samplerLocation; 254 int m_samplerLocation;
239 int m_alphaLocation; 255 int m_alphaLocation;
240 int m_fragmentTexTransformLocation; 256 int m_fragmentTexTransformLocation;
241 int m_edgeLocation; 257 int m_edgeLocation;
242 }; 258 };
243 259
244 class FragmentShaderRGBATexClampAlphaAA : public FragmentTexClampAlphaAABinding { 260 class FragmentShaderRGBATexClampAlphaAA : public FragmentTexClampAlphaAABinding {
245 public: 261 public:
246 std::string getShaderString() const; 262 std::string getShaderString(TexCoordPrecision precision) const;
247 }; 263 };
248 264
249 // Swizzles the red and blue component of sampled texel. 265 // Swizzles the red and blue component of sampled texel.
250 class FragmentShaderRGBATexClampSwizzleAlphaAA : public FragmentTexClampAlphaAAB inding { 266 class FragmentShaderRGBATexClampSwizzleAlphaAA : public FragmentTexClampAlphaAAB inding {
251 public: 267 public:
252 std::string getShaderString() const; 268 std::string getShaderString(TexCoordPrecision precision) const;
253 }; 269 };
254 270
255 class FragmentShaderRGBATexAlphaMask { 271 class FragmentShaderRGBATexAlphaMask {
256 public: 272 public:
257 FragmentShaderRGBATexAlphaMask(); 273 FragmentShaderRGBATexAlphaMask();
258 std::string getShaderString() const; 274 std::string getShaderString(TexCoordPrecision precision) const;
259 275
260 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex); 276 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex);
261 int alphaLocation() const { return m_alphaLocation; } 277 int alphaLocation() const { return m_alphaLocation; }
262 int samplerLocation() const { return m_samplerLocation; } 278 int samplerLocation() const { return m_samplerLocation; }
263 int maskSamplerLocation() const { return m_maskSamplerLocation; } 279 int maskSamplerLocation() const { return m_maskSamplerLocation; }
264 int maskTexCoordScaleLocation() const { return m_maskTexCoordScaleLocation; } 280 int maskTexCoordScaleLocation() const { return m_maskTexCoordScaleLocation; }
265 int maskTexCoordOffsetLocation() const { return m_maskTexCoordOffsetLocation ; } 281 int maskTexCoordOffsetLocation() const { return m_maskTexCoordOffsetLocation ; }
266 282
267 private: 283 private:
268 int m_samplerLocation; 284 int m_samplerLocation;
269 int m_maskSamplerLocation; 285 int m_maskSamplerLocation;
270 int m_alphaLocation; 286 int m_alphaLocation;
271 int m_maskTexCoordScaleLocation; 287 int m_maskTexCoordScaleLocation;
272 int m_maskTexCoordOffsetLocation; 288 int m_maskTexCoordOffsetLocation;
273 }; 289 };
274 290
275 class FragmentShaderRGBATexAlphaMaskAA { 291 class FragmentShaderRGBATexAlphaMaskAA {
276 public: 292 public:
277 FragmentShaderRGBATexAlphaMaskAA(); 293 FragmentShaderRGBATexAlphaMaskAA();
278 std::string getShaderString() const; 294 std::string getShaderString(TexCoordPrecision precision) const;
279 295
280 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex); 296 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex);
281 int alphaLocation() const { return m_alphaLocation; } 297 int alphaLocation() const { return m_alphaLocation; }
282 int samplerLocation() const { return m_samplerLocation; } 298 int samplerLocation() const { return m_samplerLocation; }
283 int maskSamplerLocation() const { return m_maskSamplerLocation; } 299 int maskSamplerLocation() const { return m_maskSamplerLocation; }
284 int edgeLocation() const { return m_edgeLocation; } 300 int edgeLocation() const { return m_edgeLocation; }
285 int maskTexCoordScaleLocation() const { return m_maskTexCoordScaleLocation; } 301 int maskTexCoordScaleLocation() const { return m_maskTexCoordScaleLocation; }
286 int maskTexCoordOffsetLocation() const { return m_maskTexCoordOffsetLocation ; } 302 int maskTexCoordOffsetLocation() const { return m_maskTexCoordOffsetLocation ; }
287 303
288 private: 304 private:
289 int m_samplerLocation; 305 int m_samplerLocation;
290 int m_maskSamplerLocation; 306 int m_maskSamplerLocation;
291 int m_alphaLocation; 307 int m_alphaLocation;
292 int m_edgeLocation; 308 int m_edgeLocation;
293 int m_maskTexCoordScaleLocation; 309 int m_maskTexCoordScaleLocation;
294 int m_maskTexCoordOffsetLocation; 310 int m_maskTexCoordOffsetLocation;
295 }; 311 };
296 312
297 class FragmentShaderYUVVideo { 313 class FragmentShaderYUVVideo {
298 public: 314 public:
299 FragmentShaderYUVVideo(); 315 FragmentShaderYUVVideo();
300 std::string getShaderString() const; 316 std::string getShaderString(TexCoordPrecision precision) const;
301 317
302 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex); 318 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex);
303 319
304 int yTextureLocation() const { return m_yTextureLocation; } 320 int yTextureLocation() const { return m_yTextureLocation; }
305 int uTextureLocation() const { return m_uTextureLocation; } 321 int uTextureLocation() const { return m_uTextureLocation; }
306 int vTextureLocation() const { return m_vTextureLocation; } 322 int vTextureLocation() const { return m_vTextureLocation; }
307 int alphaLocation() const { return m_alphaLocation; } 323 int alphaLocation() const { return m_alphaLocation; }
308 int yuvMatrixLocation() const { return m_yuvMatrixLocation; } 324 int yuvMatrixLocation() const { return m_yuvMatrixLocation; }
309 int yuvAdjLocation() const { return m_yuvAdjLocation; } 325 int yuvAdjLocation() const { return m_yuvAdjLocation; }
310 326
311 private: 327 private:
312 int m_yTextureLocation; 328 int m_yTextureLocation;
313 int m_uTextureLocation; 329 int m_uTextureLocation;
314 int m_vTextureLocation; 330 int m_vTextureLocation;
315 int m_alphaLocation; 331 int m_alphaLocation;
316 int m_yuvMatrixLocation; 332 int m_yuvMatrixLocation;
317 int m_yuvAdjLocation; 333 int m_yuvAdjLocation;
318 }; 334 };
319 335
320 class FragmentShaderColor { 336 class FragmentShaderColor {
321 public: 337 public:
322 FragmentShaderColor(); 338 FragmentShaderColor();
323 std::string getShaderString() const; 339 std::string getShaderString(TexCoordPrecision precision) const;
324 340
325 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex); 341 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex);
326 int edgeLocation() const { return -1; } 342 int edgeLocation() const { return -1; }
327 int colorLocation() const { return m_colorLocation; } 343 int colorLocation() const { return m_colorLocation; }
328 344
329 private: 345 private:
330 int m_colorLocation; 346 int m_colorLocation;
331 }; 347 };
332 348
333 class FragmentShaderColorAA { 349 class FragmentShaderColorAA {
334 public: 350 public:
335 FragmentShaderColorAA(); 351 FragmentShaderColorAA();
336 std::string getShaderString() const; 352 std::string getShaderString(TexCoordPrecision precision) const;
337 353
338 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex); 354 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex);
339 int edgeLocation() const { return m_edgeLocation; } 355 int edgeLocation() const { return m_edgeLocation; }
340 int colorLocation() const { return m_colorLocation; } 356 int colorLocation() const { return m_colorLocation; }
341 357
342 private: 358 private:
343 int m_edgeLocation; 359 int m_edgeLocation;
344 int m_colorLocation; 360 int m_colorLocation;
345 }; 361 };
346 362
347 class FragmentShaderCheckerboard { 363 class FragmentShaderCheckerboard {
348 public: 364 public:
349 FragmentShaderCheckerboard(); 365 FragmentShaderCheckerboard();
350 std::string getShaderString() const; 366 std::string getShaderString(TexCoordPrecision precision) const;
351 367
352 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex); 368 void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUni form, int* baseUniformIndex);
353 int alphaLocation() const { return m_alphaLocation; } 369 int alphaLocation() const { return m_alphaLocation; }
354 int texTransformLocation() const { return m_texTransformLocation; } 370 int texTransformLocation() const { return m_texTransformLocation; }
355 int frequencyLocation() const { return m_frequencyLocation; } 371 int frequencyLocation() const { return m_frequencyLocation; }
356 int colorLocation() const { return m_colorLocation; } 372 int colorLocation() const { return m_colorLocation; }
357 private: 373 private:
358 int m_alphaLocation; 374 int m_alphaLocation;
359 int m_texTransformLocation; 375 int m_texTransformLocation;
360 int m_frequencyLocation; 376 int m_frequencyLocation;
361 int m_colorLocation; 377 int m_colorLocation;
362 }; 378 };
363 379
364 } // namespace cc 380 } // namespace cc
365 381
366 #endif // CC_OUTPUT_SHADER_H_ 382 #endif // CC_OUTPUT_SHADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698