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

Side by Side Diff: src/gpu/gl/GrGLCaps.h

Issue 1580003002: Hide formats in GrGLCaps and use specific getters for different GL functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixes Created 4 years, 11 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
« no previous file with comments | « no previous file | src/gpu/gl/GrGLCaps.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
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
402 ConfigFormats fFormats; 420 ConfigFormats fFormats;
403 421
404 FormatType fFormatType; 422 FormatType fFormatType;
405 423
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).
(...skipping 19 matching lines...) Expand all
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
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLCaps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698