////////////////////////////////////////////////////////////////////////////////
bool GrContext::isConfigRenderable(GrPixelConfig config) const {
- return fGpu->isConfigRenderable(config);
+ return fGpu->caps()->isConfigRenderable(config);
}
static inline intptr_t setOrClear(intptr_t bits, int shift, intptr_t pred) {
fMaxRenderTargetSize = 0;
fMaxTextureSize = 0;
fMaxSampleCount = 0;
+
+ memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport));
}
GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) {
fMaxTextureSize = other.fMaxTextureSize;
fMaxSampleCount = other.fMaxSampleCount;
+ memcpy(fConfigRenderSupport, other.fConfigRenderSupport, sizeof(fConfigRenderSupport));
+
return *this;
}
GrPrintf("Max Texture Size : %d\n", fMaxTextureSize);
GrPrintf("Max Render Target Size : %d\n", fMaxRenderTargetSize);
GrPrintf("Max Sample Count : %d\n", fMaxSampleCount);
+
+ static const char* kConfigNames[] = {
+ "Unknown", // kUnknown_GrPixelConfig
+ "Alpha8", // kAlpha_8_GrPixelConfig,
+ "Index8", // kIndex_8_GrPixelConfig,
+ "RGB565", // kRGB_565_GrPixelConfig,
+ "RGBA444", // kRGBA_4444_GrPixelConfig,
+ "RGBA8888", // kRGBA_8888_GrPixelConfig,
+ "BGRA8888", // kBGRA_8888_GrPixelConfig,
+ };
+ GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
+ GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
+ GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig);
+ GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
+ GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
+ GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
+ GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
+ GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt);
+
+ SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig]);
+ for (size_t i = 0; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
+ if (i != kUnknown_GrPixelConfig) {
+ GrPrintf("%s is renderable: %s\n", kConfigNames[i], gNY[fConfigRenderSupport[i]]);
+ }
+ }
}
*/
#include "SkRefCnt.h"
+#include "GrTypes.h"
#ifndef GrDrawTargetCaps_DEFINED
#define GrDrawTargetCaps_DEFINED
// Will be 0 if MSAA is not supported
int maxSampleCount() const { return fMaxSampleCount; }
+ /**
+ * Can the provided configuration act as a render target?
+ */
+ bool isConfigRenderable(GrPixelConfig config) const {
+ SkASSERT(kGrPixelConfigCnt > config);
+ return fConfigRenderSupport[config];
+ }
+
protected:
bool f8BitPaletteSupport : 1;
bool fNPOTTextureTileSupport : 1;
int fMaxTextureSize;
int fMaxSampleCount;
+ bool fConfigRenderSupport[kGrPixelConfigCnt];
+
typedef SkRefCnt INHERITED;
};
poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX;
#endif
-
- for (int i = 0; i < kGrPixelConfigCnt; ++i) {
- fConfigRenderSupport[i] = false;
- };
}
GrGpu::~GrGpu() {
return fResetTimestamp;
}
- /**
- * Can the provided configuration act as a color render target?
- */
- bool isConfigRenderable(GrPixelConfig config) const {
- SkASSERT(kGrPixelConfigCnt > config);
- return fConfigRenderSupport[config];
- }
-
/**
* These methods are called by the clip manager's setupClipping function
* which (called as part of GrGpu's implementation of onDraw and
// The final stencil settings to use as determined by the clip manager.
GrStencilSettings fStencilSettings;
- // Derived classes need access to this so they can fill it out in their
- // constructors
- bool fConfigRenderSupport[kGrPixelConfigCnt];
-
// Helpers for setting up geometry state
void finalizeReservedVertices();
void finalizeReservedIndices();
} else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) {
GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
}
+
+ this->initConfigRenderableTable(ctxInfo);
+}
+
+void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
+
+ // OpenGL < 3.0
+ // no support for render targets unless the GL_ARB_framebuffer_object
+ // extension is supported (in which case we get ALPHA, RED, RG, RGB,
+ // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
+ // probably don't get R8 in this case.
+
+ // OpenGL 3.0
+ // base color renderable: ALPHA, RED, RG, RGB, and RGBA
+ // sized derivatives: ALPHA8, R8, RGBA4, RGBA8
+
+ // >= OpenGL 3.1
+ // base color renderable: RED, RG, RGB, and RGBA
+ // sized derivatives: R8, RGBA4, RGBA8
+ // if the GL_ARB_compatibility extension is supported then we get back
+ // support for GL_ALPHA and ALPHA8
+
+ // GL_EXT_bgra adds BGRA render targets to any version
+
+ // ES 2.0
+ // color renderable: RGBA4, RGB5_A1, RGB565
+ // GL_EXT_texture_rg adds support for R8 as a color render target
+ // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8
+ // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support
+
+ // ES 3.0
+ // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
+ // below already account for this).
+
+ if (kDesktop_GrGLBinding == ctxInfo.binding()) {
+ // Post 3.0 we will get R8
+ // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object)
+ if (ctxInfo.version() >= GR_GL_VER(3,0) ||
+ ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
+ fConfigRenderSupport[kAlpha_8_GrPixelConfig] = true;
+ }
+ } else {
+ // On ES we can only hope for R8
+ fConfigRenderSupport[kAlpha_8_GrPixelConfig] = fTextureRedSupport;
+ }
+
+ if (kDesktop_GrGLBinding != ctxInfo.binding()) {
+ // only available in ES
+ fConfigRenderSupport[kRGB_565_GrPixelConfig] = true;
+ }
+
+ // we no longer support 444 as a render target
+ fConfigRenderSupport[kRGBA_4444_GrPixelConfig] = false;
+
+ if (this->fRGBA8RenderbufferSupport) {
+ fConfigRenderSupport[kRGBA_8888_GrPixelConfig] = true;
+ }
+
+ if (this->fBGRAFormatSupport) {
+ fConfigRenderSupport[kBGRA_8888_GrPixelConfig] = true;
+ }
}
bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
}
};
- void initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli);
- void initStencilFormats(const GrGLContextInfo& ctxInfo);
+ void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
+ void initStencilFormats(const GrGLContextInfo&);
+ void initConfigRenderableTable(const GrGLContextInfo&);
// tracks configs that have been verified to pass the FBO completeness when
// used as a color attachment
fHWBoundTextures.reset(ctx.info().caps()->maxFragmentTextureUnits());
fHWTexGenSettings.reset(ctx.info().caps()->maxFixedFunctionTextureCoords());
- fillInConfigRenderableTable();
-
-
GrGLClearErr(fGLContext.interface());
if (gPrintStartupSpew) {
///////////////////////////////////////////////////////////////////////////////
-void GrGpuGL::fillInConfigRenderableTable() {
-
- // OpenGL < 3.0
- // no support for render targets unless the GL_ARB_framebuffer_object
- // extension is supported (in which case we get ALPHA, RED, RG, RGB,
- // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
- // probably don't get R8 in this case.
-
- // OpenGL 3.0
- // base color renderable: ALPHA, RED, RG, RGB, and RGBA
- // sized derivatives: ALPHA8, R8, RGBA4, RGBA8
-
- // >= OpenGL 3.1
- // base color renderable: RED, RG, RGB, and RGBA
- // sized derivatives: R8, RGBA4, RGBA8
- // if the GL_ARB_compatibility extension is supported then we get back
- // support for GL_ALPHA and ALPHA8
-
- // GL_EXT_bgra adds BGRA render targets to any version
-
- // ES 2.0
- // color renderable: RGBA4, RGB5_A1, RGB565
- // GL_EXT_texture_rg adds support for R8 as a color render target
- // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8
- // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support
-
- // ES 3.0
- // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
- // below already account for this).
-
- if (kDesktop_GrGLBinding == this->glBinding()) {
- // Post 3.0 we will get R8
- // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object)
- if (this->glVersion() >= GR_GL_VER(3,0) ||
- this->hasExtension("GL_ARB_framebuffer_object")) {
- fConfigRenderSupport[kAlpha_8_GrPixelConfig] = true;
- }
- } else {
- // On ES we can only hope for R8
- fConfigRenderSupport[kAlpha_8_GrPixelConfig] =
- this->glCaps().textureRedSupport();
- }
-
- if (kDesktop_GrGLBinding != this->glBinding()) {
- // only available in ES
- fConfigRenderSupport[kRGB_565_GrPixelConfig] = true;
- }
-
- // we no longer support 444 as a render target
- fConfigRenderSupport[kRGBA_4444_GrPixelConfig] = false;
-
- if (this->glCaps().rgba8RenderbufferSupport()) {
- fConfigRenderSupport[kRGBA_8888_GrPixelConfig] = true;
- }
-
- if (this->glCaps().bgraFormatSupport()) {
- fConfigRenderSupport[kBGRA_8888_GrPixelConfig] = true;
- }
-}
GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig,
GrPixelConfig surfaceConfig) const {
const GrSurface* src,
const GrGpuGL* gpu,
bool* wouldNeedTempFBO = NULL) {
- if (gpu->isConfigRenderable(dst->config()) &&
- gpu->isConfigRenderable(src->config()) &&
+ if (gpu->glCaps().isConfigRenderable(dst->config()) &&
+ gpu->glCaps().isConfigRenderable(src->config()) &&
gpu->glCaps().usesMSAARenderBuffers()) {
// ES3 doesn't allow framebuffer blits when the src has MSAA and the configs don't match
// or the rects are not the same (not just the same size but have the same edges).
if (NULL != srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) {
return false;
}
- if (gpu->isConfigRenderable(src->config()) && NULL != dst->asTexture() &&
+ if (gpu->glCaps().isConfigRenderable(src->config()) && NULL != dst->asTexture() &&
dst->origin() == src->origin() && kIndex_8_GrPixelConfig != src->config()) {
if (NULL != wouldNeedTempFBO) {
*wouldNeedTempFBO = NULL == src->asRenderTarget();
GrGLuint texID,
GrGLRenderTarget::Desc* desc);
- void fillInConfigRenderableTable();
-
GrGLContext fGLContext;
// GL program-related state