OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef GrGLCaps_DEFINED | 9 #ifndef GrGLCaps_DEFINED |
10 #define GrGLCaps_DEFINED | 10 #define GrGLCaps_DEFINED |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 /** | 23 /** |
24 * Stores some capabilities of a GL context. Most are determined by the GL | 24 * Stores some capabilities of a GL context. Most are determined by the GL |
25 * version and the extensions string. It also tracks formats that have passed | 25 * version and the extensions string. It also tracks formats that have passed |
26 * the FBO completeness test. | 26 * the FBO completeness test. |
27 */ | 27 */ |
28 class GrGLCaps : public GrCaps { | 28 class GrGLCaps : public GrCaps { |
29 public: | 29 public: |
30 typedef GrGLStencilAttachment::Format StencilFormat; | 30 typedef GrGLStencilAttachment::Format StencilFormat; |
31 | 31 |
32 /** Provides information about the mappiing from GrPixelConfig to GL formats
. */ | |
33 struct ConfigFormats { | |
34 ConfigFormats() { | |
35 // Inits to known bad GL enum values. | |
36 memset(this, 0xAB, sizeof(ConfigFormats)); | |
37 } | |
38 GrGLenum fBaseInternalFormat; | |
39 GrGLenum fSizedInternalFormat; | |
40 GrGLenum fExternalFormat; | |
41 GrGLenum fExternalType; | |
42 | |
43 // The <format> parameter to use for glTexImage and glTexSubImage. | |
44 // This is usually the same as fExternalFormat except for kSRGBA on some
GL contexts. | |
45 GrGLenum fExternalFormatForTexImage; | |
46 // Either the base or sized internal format depending on the GL and conf
ig. | |
47 GrGLenum fInternalFormatTexImage; | |
48 }; | |
49 | |
50 /** | 32 /** |
51 * The type of MSAA for FBOs supported. Different extensions have different | 33 * The type of MSAA for FBOs supported. Different extensions have different |
52 * semantics of how / when a resolve is performed. | 34 * semantics of how / when a resolve is performed. |
53 */ | 35 */ |
54 enum MSFBOType { | 36 enum MSFBOType { |
55 /** | 37 /** |
56 * no support for MSAA FBOs | 38 * no support for MSAA FBOs |
57 */ | 39 */ |
58 kNone_MSFBOType = 0, | 40 kNone_MSFBOType = 0, |
59 /** | 41 /** |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 113 |
132 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override
{ | 114 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override
{ |
133 SkASSERT(kGrPixelConfigCnt > config); | 115 SkASSERT(kGrPixelConfigCnt > config); |
134 if (withMSAA) { | 116 if (withMSAA) { |
135 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderabl
eWithMSAA_Flag); | 117 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderabl
eWithMSAA_Flag); |
136 } else { | 118 } else { |
137 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderabl
e_Flag); | 119 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderabl
e_Flag); |
138 } | 120 } |
139 } | 121 } |
140 | 122 |
141 /** Returns conversions to various GL format parameters for a GrPixelCfonig.
*/ | |
142 const ConfigFormats& configGLFormats(GrPixelConfig config) const { | |
143 return fConfigTable[config].fFormats; | |
144 } | |
145 | |
146 /** Returns the mapping between GrPixelConfig components and GL internal for
mat components. */ | 123 /** Returns the mapping between GrPixelConfig components and GL internal for
mat components. */ |
147 const GrSwizzle& configSwizzle(GrPixelConfig config) const { | 124 const GrSwizzle& configSwizzle(GrPixelConfig config) const { |
148 return fConfigTable[config].fSwizzle; | 125 return fConfigTable[config].fSwizzle; |
149 } | 126 } |
150 | 127 |
| 128 bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalC
onfig, |
| 129 GrGLenum* internalFormat, GrGLenum* externalFormat, |
| 130 GrGLenum* externalType) const; |
| 131 |
| 132 bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* int
ernalFormat) const; |
| 133 |
| 134 bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig external
Config, |
| 135 GrGLenum* externalFormat, GrGLenum* externalType) c
onst; |
| 136 |
| 137 bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) c
onst; |
| 138 |
151 /** | 139 /** |
152 * Gets an array of legal stencil formats. These formats are not guaranteed | 140 * Gets an array of legal stencil formats. These formats are not guaranteed |
153 * to be supported by the driver but are legal GLenum names given the GL | 141 * to be supported by the driver but are legal GLenum names given the GL |
154 * version and extensions supported. | 142 * version and extensions supported. |
155 */ | 143 */ |
156 const SkTArray<StencilFormat, true>& stencilFormats() const { | 144 const SkTArray<StencilFormat, true>& stencilFormats() const { |
157 return fStencilFormats; | 145 return fStencilFormats; |
158 } | 146 } |
159 | 147 |
160 /** | 148 /** |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 /// Is there support for GL_EXT_direct_state_access? | 271 /// Is there support for GL_EXT_direct_state_access? |
284 bool directStateAccessSupport() const { return fDirectStateAccessSupport; } | 272 bool directStateAccessSupport() const { return fDirectStateAccessSupport; } |
285 | 273 |
286 /// Is there support for GL_KHR_debug? | 274 /// Is there support for GL_KHR_debug? |
287 bool debugSupport() const { return fDebugSupport; } | 275 bool debugSupport() const { return fDebugSupport; } |
288 | 276 |
289 /// Is there support for ES2 compatability? | 277 /// Is there support for ES2 compatability? |
290 bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } | 278 bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } |
291 | 279 |
292 /// Can we call glDisable(GL_MULTISAMPLE)? | 280 /// Can we call glDisable(GL_MULTISAMPLE)? |
293 bool multisampleDisableSupport() const { | 281 bool multisampleDisableSupport() const { return fMultisampleDisableSupport;
} |
294 return fMultisampleDisableSupport; | |
295 } | |
296 | 282 |
297 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic conte
nt. | 283 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic conte
nt. |
298 bool useNonVBOVertexAndIndexDynamicData() const { | 284 bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAnd
IndexDynamicData; } |
299 return fUseNonVBOVertexAndIndexDynamicData; | |
300 } | |
301 | 285 |
302 /// Does ReadPixels support the provided format/type combo? | 286 /// Does ReadPixels support the provided format/type combo? |
303 bool readPixelsSupported(const GrGLInterface* intf, | 287 bool readPixelsSupported(const GrGLInterface* intf, |
304 GrPixelConfig readConfig, | 288 GrPixelConfig readConfig, |
305 GrPixelConfig currFBOConfig) const; | 289 GrPixelConfig currFBOConfig) const; |
306 | 290 |
307 bool isCoreProfile() const { return fIsCoreProfile; } | 291 bool isCoreProfile() const { return fIsCoreProfile; } |
308 | 292 |
309 bool bindFragDataLocationSupport() const { return fBindFragDataLocationSuppo
rt; } | 293 bool bindFragDataLocationSupport() const { return fBindFragDataLocationSuppo
rt; } |
310 | 294 |
(...skipping 16 matching lines...) Expand all Loading... |
327 * Returns a string containing the caps info. | 311 * Returns a string containing the caps info. |
328 */ | 312 */ |
329 SkString dump() const override; | 313 SkString dump() const override; |
330 | 314 |
331 bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; } | 315 bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; } |
332 bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; } | 316 bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; } |
333 | 317 |
334 const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fS
haderCaps.get()); } | 318 const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fS
haderCaps.get()); } |
335 | 319 |
336 private: | 320 private: |
| 321 enum ExternalFormatUsage { |
| 322 kTexImage_ExternalFormatUsage, |
| 323 kOther_ExternalFormatUsage, |
| 324 |
| 325 kLast_ExternalFormatUsage = kOther_ExternalFormatUsage |
| 326 }; |
| 327 static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1; |
| 328 bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConf
ig, |
| 329 ExternalFormatUsage usage, GrGLenum* externalFormat, |
| 330 GrGLenum* externalType) const; |
| 331 |
337 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterfa
ce*); | 332 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterfa
ce*); |
338 void initGLSL(const GrGLContextInfo&); | 333 void initGLSL(const GrGLContextInfo&); |
339 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*); | 334 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*); |
340 | 335 |
341 void onApplyOptionsOverrides(const GrContextOptions& options) override; | 336 void onApplyOptionsOverrides(const GrContextOptions& options) override; |
342 | 337 |
343 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); | 338 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); |
344 void initBlendEqationSupport(const GrGLContextInfo&); | 339 void initBlendEqationSupport(const GrGLContextInfo&); |
345 void initStencilFormats(const GrGLContextInfo&); | 340 void initStencilFormats(const GrGLContextInfo&); |
346 // This must be called after initFSAASupport(). | 341 // This must be called after initFSAASupport(). |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 kNormalizedFixedPoint_FormatType, | 384 kNormalizedFixedPoint_FormatType, |
390 kFloat_FormatType, | 385 kFloat_FormatType, |
391 }; | 386 }; |
392 | 387 |
393 struct ReadPixelsFormat { | 388 struct ReadPixelsFormat { |
394 ReadPixelsFormat() : fFormat(0), fType(0) {} | 389 ReadPixelsFormat() : fFormat(0), fType(0) {} |
395 GrGLenum fFormat; | 390 GrGLenum fFormat; |
396 GrGLenum fType; | 391 GrGLenum fType; |
397 }; | 392 }; |
398 | 393 |
| 394 struct ConfigFormats { |
| 395 ConfigFormats() { |
| 396 // Inits to known bad GL enum values. |
| 397 memset(this, 0xAB, sizeof(ConfigFormats)); |
| 398 } |
| 399 GrGLenum fBaseInternalFormat; |
| 400 GrGLenum fSizedInternalFormat; |
| 401 |
| 402 /** The external format and type are to be used when uploading/downloadi
ng data using this |
| 403 config where both the CPU data and GrSurface are the same config. To
get the external |
| 404 format and type when converting between configs while copying to/fro
m memory use |
| 405 getExternalFormat(). |
| 406 The kTexImage external format is usually the same as kOther except f
or kSRGBA on some |
| 407 GL contexts. */ |
| 408 GrGLenum fExternalFormat[kExternalFormatUsageCnt]; |
| 409 GrGLenum fExternalType; |
| 410 |
| 411 |
| 412 // Either the base or sized internal format depending on the GL and conf
ig. |
| 413 GrGLenum fInternalFormatTexImage; |
| 414 GrGLenum fInternalFormatRenderbuffer; |
| 415 }; |
| 416 |
399 struct ConfigInfo { | 417 struct ConfigInfo { |
400 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {} | 418 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {} |
401 | 419 |
| 420 FormatType fFormatType; |
| 421 |
402 ConfigFormats fFormats; | 422 ConfigFormats fFormats; |
403 | 423 |
404 FormatType fFormatType; | |
405 | |
406 // On ES contexts there are restrictions on type type/format that may be
used for | 424 // On ES contexts there are restrictions on type type/format that may be
used for |
407 // ReadPixels. One is implicitly specified by the current FBO's format.
The other is | 425 // ReadPixels. One is implicitly specified by the current FBO's format.
The other is |
408 // queryable. This stores the queried option (lazily). | 426 // queryable. This stores the queried option (lazily). |
409 ReadPixelsFormat fSecondReadPixelsFormat; | 427 ReadPixelsFormat fSecondReadPixelsFormat; |
410 | 428 |
411 enum { | 429 enum { |
412 // This indicates that a stencil format has not yet been determined
for the config. | 430 // This indicates that a stencil format has not yet been determined
for the config. |
413 kUnknown_StencilIndex = -1, | 431 kUnknown_StencilIndex = -1, |
414 // This indicates that there is no supported stencil format for the
config. | 432 // This indicates that there is no supported stencil format for the
config. |
415 kUnsupported_StencilFormatIndex = -2 | 433 kUnsupported_StencilFormatIndex = -2 |
(...skipping 12 matching lines...) Expand all Loading... |
428 | 446 |
429 GrSwizzle fSwizzle; | 447 GrSwizzle fSwizzle; |
430 }; | 448 }; |
431 | 449 |
432 ConfigInfo fConfigTable[kGrPixelConfigCnt]; | 450 ConfigInfo fConfigTable[kGrPixelConfigCnt]; |
433 | 451 |
434 typedef GrCaps INHERITED; | 452 typedef GrCaps INHERITED; |
435 }; | 453 }; |
436 | 454 |
437 #endif | 455 #endif |
OLD | NEW |