aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-12-17 09:50:47 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-17 09:50:47 -0800
commit62a627be6a7e3fdb4fe1c67de0c371a276c761f6 (patch)
treec7cb2a96c819644bb7127849c098b5a1a64b8a1f
parent3922cef8057e19b64a95496d11103ba3bbcdceed (diff)
Move the GrGLGpu config stencil format index into ConfigTable
-rw-r--r--src/gpu/gl/GrGLGpu.cpp29
-rw-r--r--src/gpu/gl/GrGLGpu.h23
2 files changed, 24 insertions, 28 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 7be4d32b88..42c92687f7 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -160,14 +160,6 @@ bool GrGLGpu::BlendCoeffReferencesConstant(GrBlendCoeff coeff) {
///////////////////////////////////////////////////////////////////////////////
-// Used in the map of pixel configs to stencil format indices. This value is used to
-// indicate that a stencil format has not yet been set for the given config.
-static const int kUnknownStencilIndex = -1;
-// This value is used as the stencil index when no stencil configs are supported with the
-// given pixel config.
-static const int kUnsupportedStencilIndex = -2;
-
-///////////////////////////////////////////////////////////////////////////////
GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options,
GrContext* context) {
@@ -222,9 +214,6 @@ GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context)
SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVertexAttribs);
- for (int i = 0; i < kGrPixelConfigCnt; ++i) {
- fPixelConfigToStencilIndex[i] = kUnknownStencilIndex;
- }
fHWProgramID = 0;
fTempSrcFBOID = 0;
fTempDstFBOID = 0;
@@ -1279,9 +1268,9 @@ void inline get_stencil_rb_sizes(const GrGLInterface* gl,
int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
static const int kSize = 16;
- if (kUnknownStencilIndex == fPixelConfigToStencilIndex[config]) {
+ if (ConfigEntry::kUnknown_StencilIndex == fConfigTable[config].fStencilFormatIndex) {
// Default to unsupported
- fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
+ fConfigTable[config].fStencilFormatIndex = ConfigEntry::kUnsupported_StencilFormatIndex;
// Create color texture
GrGLuint colorID = 0;
GL_CALL(GenTextures(1, &colorID));
@@ -1307,8 +1296,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
if (!this->configToGLFormats(config, useSizedFormat, &internalFormat,
&externalFormat, &externalType)) {
GL_CALL(DeleteTextures(1, &colorID));
- fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
- return kUnsupportedStencilIndex;
+ return ConfigEntry::kUnsupported_StencilFormatIndex;
}
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
@@ -1322,8 +1310,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
NULL));
if (GR_GL_NO_ERROR != GR_GL_GET_ERROR(this->glInterface())) {
GL_CALL(DeleteTextures(1, &colorID));
- fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
- return kUnsupportedStencilIndex;
+ return ConfigEntry::kUnsupported_StencilFormatIndex;
}
// unbind the texture from the texture unit before binding it to the frame buffer
@@ -1380,7 +1367,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
GR_GL_RENDERBUFFER, 0));
}
} else {
- fPixelConfigToStencilIndex[config] = i;
+ fConfigTable[config].fStencilFormatIndex = i;
break;
}
}
@@ -1391,8 +1378,8 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, 0));
GL_CALL(DeleteFramebuffers(1, &fb));
}
- SkASSERT(kUnknownStencilIndex != fPixelConfigToStencilIndex[config]);
- return fPixelConfigToStencilIndex[config];
+ SkASSERT(ConfigEntry::kUnknown_StencilIndex != fConfigTable[config].fStencilFormatIndex);
+ return fConfigTable[config].fStencilFormatIndex;
}
GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRenderTarget* rt,
@@ -1408,7 +1395,7 @@ GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRen
GrGLStencilAttachment::IDDesc sbDesc;
int sIdx = this->getCompatibleStencilIndex(rt->config());
- if (sIdx == kUnsupportedStencilIndex) {
+ if (sIdx < 0) {
return nullptr;
}
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 409aae8f43..4f3b37ee9d 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -153,7 +153,7 @@ private:
GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
GrWrapOwnership) override;
// Given a GrPixelConfig return the index into the stencil format array on GrGLCaps to a
- // compatible stencil format.
+ // compatible stencil format, or negative if there is no compatible stencil format.
int getCompatibleStencilIndex(GrPixelConfig config);
void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override;
@@ -541,18 +541,27 @@ private:
struct ConfigEntry {
// Default constructor inits to known bad GL enum values.
- ConfigEntry() { memset(this, 0xAB, sizeof(ConfigEntry)); }
+ ConfigEntry() {
+ memset(this, 0xAB, sizeof(ConfigEntry));
+ fStencilFormatIndex = kUnknown_StencilIndex;
+ }
GrGLenum fBaseInternalFormat;
GrGLenum fSizedInternalFormat;
GrGLenum fExternalFormat;
GrGLenum fExternalType;
- };
- ConfigEntry fConfigTable[kLast_GrPixelConfig + 1];
+ // Index into GrGLCaps's list of stencil formats. Support is determined experimentally and
+ // lazily.
+ int fStencilFormatIndex;
+ enum {
+ // This indicates that a stencil format has not yet been determined for the config.
+ kUnknown_StencilIndex = -1,
+ // This indicates that there is no supported stencil format for the config.
+ kUnsupported_StencilFormatIndex = -2
+ };
+ };
- // Mapping of pixel configs to known supported stencil formats to be used
- // when adding a stencil buffer to a framebuffer.
- int fPixelConfigToStencilIndex[kGrPixelConfigCnt];
+ ConfigEntry fConfigTable[kGrPixelConfigCnt];
typedef GrGpu INHERITED;
friend class GrGLPathRendering; // For accessing setTextureUnit.