From bcce8926524827775539874346dd424a9510dbc9 Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Mon, 25 Mar 2013 15:38:39 +0000 Subject: Make GrDrawTarget::Caps ref counted and GrGLCaps derive from it. Also rename GrDrawTarget::getCaps() -> GrDrawTarget::caps(). Review URL: https://codereview.chromium.org/12843026 git-svn-id: http://skia.googlecode.com/svn/trunk@8364 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/gl/GrGLBufferImpl.cpp | 4 +- src/gpu/gl/GrGLCaps.cpp | 131 ++++++++++++++++++++++++++++++++++----- src/gpu/gl/GrGLCaps.h | 11 +++- src/gpu/gl/GrGLContext.cpp | 6 +- src/gpu/gl/GrGLContext.h | 21 ++++--- src/gpu/gl/GrGLProgram.cpp | 4 +- src/gpu/gl/GrGLShaderBuilder.cpp | 4 +- src/gpu/gl/GrGpuGL.cpp | 129 ++++++-------------------------------- src/gpu/gl/GrGpuGL.h | 7 +-- 9 files changed, 164 insertions(+), 153 deletions(-) (limited to 'src/gpu/gl') diff --git a/src/gpu/gl/GrGLBufferImpl.cpp b/src/gpu/gl/GrGLBufferImpl.cpp index 6867e1383d..0723bd25a6 100644 --- a/src/gpu/gl/GrGLBufferImpl.cpp +++ b/src/gpu/gl/GrGLBufferImpl.cpp @@ -74,7 +74,7 @@ void* GrGLBufferImpl::lock(GrGpuGL* gpu) { GrAssert(!this->isLocked()); if (0 == fDesc.fID) { fLockPtr = fCPUData; - } else if (gpu->getCaps().bufferLockSupport()) { + } else if (gpu->caps()->bufferLockSupport()) { this->bind(gpu); // Let driver know it can discard the old data GL_CALL(gpu, BufferData(fBufferType, @@ -92,7 +92,7 @@ void GrGLBufferImpl::unlock(GrGpuGL* gpu) { VALIDATE(); GrAssert(this->isLocked()); if (0 != fDesc.fID) { - GrAssert(gpu->getCaps().bufferLockSupport()); + GrAssert(gpu->caps()->bufferLockSupport()); this->bind(gpu); GL_CALL(gpu, UnmapBuffer(fBufferType)); } diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index a115b5d12e..cf09506c05 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -10,11 +10,15 @@ #include "GrGLContext.h" #include "SkTSearch.h" +SK_DEFINE_INST_COUNT(GrGLCaps) + GrGLCaps::GrGLCaps() { this->reset(); } void GrGLCaps::reset() { + INHERITED::reset(); + fVerifiedColorConfigs.reset(); fStencilFormats.reset(); fStencilVerifiedColorConfigs.reset(); @@ -46,6 +50,7 @@ GrGLCaps::GrGLCaps(const GrGLCaps& caps) { } GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) { + INHERITED::operator=(caps); fVerifiedColorConfigs = caps.fVerifiedColorConfigs; fStencilFormats = caps.fStencilFormats; fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs; @@ -85,6 +90,10 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { GrGLBinding binding = ctxInfo.binding(); GrGLVersion version = ctxInfo.version(); + /************************************************************************** + * Caps specific to GrGLCaps + **************************************************************************/ + if (kES2_GrGLBinding == binding) { GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, &fMaxFragmentUniformVectors); @@ -194,6 +203,89 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { this->initFSAASupport(ctxInfo, gli); this->initStencilFormats(ctxInfo); + + /************************************************************************** + * GrDrawTarget::Caps fields + **************************************************************************/ + GrGLint maxTextureUnits; + // check FS and fixed-function texture unit limits + // we only use textures in the fragment stage currently. + // checks are > to make sure we have a spare unit. + GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); + GrAssert(maxTextureUnits > GrDrawState::kNumStages); + + GrGLint numFormats; + GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats); + SkAutoSTMalloc<10, GrGLint> formats(numFormats); + GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); + for (int i = 0; i < numFormats; ++i) { + if (formats[i] == GR_GL_PALETTE8_RGBA8) { + f8BitPaletteSupport = true; + break; + } + } + + if (kDesktop_GrGLBinding == binding) { + // we could also look for GL_ATI_separate_stencil extension or + // GL_EXT_stencil_two_side but they use different function signatures + // than GL2.0+ (and than each other). + fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0)); + // supported on GL 1.4 and higher or by extension + fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) || + ctxInfo.hasExtension("GL_EXT_stencil_wrap"); + } else { + // ES 2 has two sided stencil and stencil wrap + fTwoSidedStencilSupport = true; + fStencilWrapOpsSupport = true; + } + + if (kDesktop_GrGLBinding == binding) { + fBufferLockSupport = true; // we require VBO support and the desktop VBO extension includes + // glMapBuffer. + } else { + fBufferLockSupport = ctxInfo.hasExtension("GL_OES_mapbuffer"); + } + + if (kDesktop_GrGLBinding == binding) { + if (ctxInfo.version() >= GR_GL_VER(2,0) || + ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")) { + fNPOTTextureTileSupport = true; + } else { + fNPOTTextureTileSupport = false; + } + } else { + // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only + fNPOTTextureTileSupport = ctxInfo.hasExtension("GL_OES_texture_npot"); + } + + fHWAALineSupport = (kDesktop_GrGLBinding == binding); + + GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_SIZE, &fMaxTextureSize); + GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize); + // Our render targets are always created with textures as the color + // attachment, hence this min: + fMaxRenderTargetSize = GrMin(fMaxTextureSize, fMaxRenderTargetSize); + + fPathStencilingSupport = GR_GL_USE_NV_PATH_RENDERING && + ctxInfo.hasExtension("GL_NV_path_rendering"); + + // Enable supported shader-related caps + if (kDesktop_GrGLBinding == binding) { + fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) || + ctxInfo.hasExtension("GL_ARB_blend_func_extended"); + fShaderDerivativeSupport = true; + // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS + fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3,2) && + ctxInfo.glslGeneration() >= k150_GrGLSLGeneration; + } else { + fShaderDerivativeSupport = ctxInfo.hasExtension("GL_OES_standard_derivatives"); + } + + if (GrGLCaps::kImaginationES_MSFBOType == fMSFBOType) { + GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount); + } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) { + GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount); + } } bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, @@ -411,6 +503,10 @@ bool GrGLCaps::isColorConfigAndStencilFormatVerified( } void GrGLCaps::print() const { + + INHERITED::print(); + + GrPrintf("--- GL-Specific ---\n"); for (int i = 0; i < fStencilFormats.count(); ++i) { GrPrintf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n", i, @@ -432,20 +528,25 @@ void GrGLCaps::print() const { }; GrPrintf("MSAA Type: %s\n", gMSFBOExtStr[fMSFBOType]); GrPrintf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); - GrPrintf("Support RGBA8 Render Buffer: %s\n", - (fRGBA8RenderbufferSupport ? "YES": "NO")); - GrPrintf("BGRA is an internal format: %s\n", - (fBGRAIsInternalFormat ? "YES": "NO")); - GrPrintf("Support texture swizzle: %s\n", - (fTextureSwizzleSupport ? "YES": "NO")); - GrPrintf("Unpack Row length support: %s\n", - (fUnpackRowLengthSupport ? "YES": "NO")); - GrPrintf("Unpack Flip Y support: %s\n", - (fUnpackFlipYSupport ? "YES": "NO")); - GrPrintf("Pack Row length support: %s\n", - (fPackRowLengthSupport ? "YES": "NO")); - GrPrintf("Pack Flip Y support: %s\n", - (fPackFlipYSupport ? "YES": "NO")); + GrPrintf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); + GrPrintf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO")); + GrPrintf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO")); + GrPrintf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO")); + GrPrintf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO")); + GrPrintf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO")); + GrPrintf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")); + GrPrintf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO")); + GrPrintf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); + + GrPrintf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO")); + GrPrintf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO")); + GrPrintf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); + GrPrintf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); - GrPrintf("Fragment coord conventions support: %s\n", (fFragCoordsConventionSupport ? "YES": "NO")); + GrPrintf("Fragment coord conventions support: %s\n", + (fFragCoordsConventionSupport ? "YES": "NO")); + GrPrintf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); + GrPrintf("Use non-VBO for dynamic data: %s\n", + (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); + GrPrintf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); } diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 83f4650c97..d19c98978d 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -12,6 +12,7 @@ #include "SkTArray.h" #include "SkTDArray.h" #include "GrGLStencilBuffer.h" +#include "GrDrawTarget.h" class GrGLContextInfo; @@ -20,8 +21,10 @@ class GrGLContextInfo; * version and the extensions string. It also tracks formats that have passed * the FBO completeness test. */ -class GrGLCaps { +class GrGLCaps : public GrDrawTarget::Caps { public: + SK_DECLARE_INST_COUNT(GrGLCaps) + typedef GrGLStencilBuffer::Format StencilFormat; /** @@ -93,7 +96,7 @@ public: /** * Resets the caps such that nothing is supported. */ - void reset(); + virtual void reset() SK_OVERRIDE; /** * Initializes the GrGLCaps to the set of features supported in the current @@ -158,7 +161,7 @@ public: /** * Prints the caps info using GrPrintf. */ - void print() const; + virtual void print() const SK_OVERRIDE; /** * Gets an array of legal stencil formats. These formats are not guaranteed @@ -308,6 +311,8 @@ private: bool fVertexArrayObjectSupport : 1; bool fUseNonVBOVertexAndIndexDynamicData : 1; bool fIsCoreProfile : 1; + + typedef GrDrawTarget::Caps INHERITED; }; #endif diff --git a/src/gpu/gl/GrGLContext.cpp b/src/gpu/gl/GrGLContext.cpp index 0c3f0eb67a..d384b4ee6f 100644 --- a/src/gpu/gl/GrGLContext.cpp +++ b/src/gpu/gl/GrGLContext.cpp @@ -14,7 +14,7 @@ GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& ctxInfo) { fGLSLGeneration = ctxInfo.fGLSLGeneration; fVendor = ctxInfo.fVendor; fExtensions = ctxInfo.fExtensions; - fGLCaps = ctxInfo.fGLCaps; + *fGLCaps = *ctxInfo.fGLCaps.get(); return *this; } @@ -36,7 +36,7 @@ bool GrGLContextInfo::initialize(const GrGLInterface* interface) { fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface); fVendor = GrGLGetVendor(interface); - fGLCaps.init(*this, interface); + fGLCaps->init(*this, interface); return true; } } @@ -53,7 +53,7 @@ void GrGLContextInfo::reset() { fGLSLGeneration = static_cast(0); fVendor = kOther_GrGLVendor; fExtensions.reset(); - fGLCaps.reset(); + fGLCaps->reset(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/gl/GrGLContext.h b/src/gpu/gl/GrGLContext.h index 1091ab9906..71b3861a94 100644 --- a/src/gpu/gl/GrGLContext.h +++ b/src/gpu/gl/GrGLContext.h @@ -26,7 +26,10 @@ public: /** * Default constructor */ - GrGLContextInfo() { this->reset(); } + GrGLContextInfo() { + fGLCaps.reset(SkNEW(GrGLCaps)); + this->reset(); + } /** * Copies a GrGLContextInfo @@ -44,8 +47,8 @@ public: GrGLVersion version() const { return fGLVersion; } GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } GrGLVendor vendor() const { return fVendor; } - const GrGLCaps& caps() const { return fGLCaps; } - GrGLCaps& caps() { return fGLCaps; } + const GrGLCaps* caps() const { return fGLCaps.get(); } + GrGLCaps* caps() { return fGLCaps; } /** * Checks for extension support using a cached copy of the GL_EXTENSIONS @@ -65,12 +68,12 @@ public: private: - GrGLBinding fBindingInUse; - GrGLVersion fGLVersion; - GrGLSLGeneration fGLSLGeneration; - GrGLVendor fVendor; - GrGLExtensions fExtensions; - GrGLCaps fGLCaps; + GrGLBinding fBindingInUse; + GrGLVersion fGLVersion; + GrGLSLGeneration fGLSLGeneration; + GrGLVendor fVendor; + GrGLExtensions fExtensions; + SkAutoTUnref fGLCaps; }; /** diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 21729cd33b..333146868b 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -149,7 +149,7 @@ void GrGLProgram::BuildDesc(const GrDrawState& drawState, // other than pass through values from the VS to the FS anyway). #if GR_GL_EXPERIMENTAL_GS #if 0 - desc->fExperimentalGS = gpu->getCaps().geometryShaderSupport(); + desc->fExperimentalGS = gpu->caps().geometryShaderSupport(); #else desc->fExperimentalGS = false; #endif @@ -177,7 +177,7 @@ void GrGLProgram::BuildDesc(const GrDrawState& drawState, desc->fFirstCoverageStage = firstCoverageStage; } - if (gpu->getCaps().dualSourceBlendingSupport() && + if (gpu->caps()->dualSourceBlendingSupport() && !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | GrDrawState::kCoverageAsAlpha_BlendOptFlag))) { if (kZero_GrBlendCoeff == dstCoeff) { diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp index 117962633f..3808402ab4 100644 --- a/src/gpu/gl/GrGLShaderBuilder.cpp +++ b/src/gpu/gl/GrGLShaderBuilder.cpp @@ -158,7 +158,7 @@ void GrGLShaderBuilder::appendTextureLookup(SkString* out, sample_function_name(varyingType, fCtxInfo.glslGeneration()), this->getUniformCStr(sampler.fSamplerUniform), coordName); - append_swizzle(out, *sampler.textureAccess(), fCtxInfo.caps()); + append_swizzle(out, *sampler.textureAccess(), *fCtxInfo.caps()); } void GrGLShaderBuilder::appendTextureLookup(ShaderType type, @@ -332,7 +332,7 @@ void GrGLShaderBuilder::addVarying(GrSLType type, const char* GrGLShaderBuilder::fragmentPosition() { #if 1 - if (fCtxInfo.caps().fragCoordConventionsSupport()) { + if (fCtxInfo.caps()->fragCoordConventionsSupport()) { if (!fSetupFragPosition) { if (fCtxInfo.glslGeneration() < k150_GrGLSLGeneration) { fFSHeader.append("#extension GL_ARB_fragment_coord_conventions: require\n"); diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index e7d3a946a4..cf4acd5f0c 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -153,9 +153,10 @@ GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) GrAssert(ctx.isInitialized()); + fCaps.reset(SkRef(ctx.info().caps())); + fillInConfigRenderableTable(); - fPrintedCaps = false; GrGLClearErr(fGLContext.interface()); @@ -174,10 +175,9 @@ GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) GrPrintf("------ RENDERER %s\n", renderer); GrPrintf("------ VERSION %s\n", version); GrPrintf("------ EXTENSIONS\n %s \n", ext); + ctx.info().caps()->print(); } - this->initCaps(); - fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext())); GrAssert(this->glCaps().maxVertexAttributes() >= GrDrawState::kVertexAttribCnt); @@ -209,92 +209,6 @@ GrGpuGL::~GrGpuGL() { /////////////////////////////////////////////////////////////////////////////// -void GrGpuGL::initCaps() { - GrGLint maxTextureUnits; - // check FS and fixed-function texture unit limits - // we only use textures in the fragment stage currently. - // checks are > to make sure we have a spare unit. - const GrGLInterface* gl = this->glInterface(); - GR_GL_GetIntegerv(gl, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); - GrAssert(maxTextureUnits > GrDrawState::kNumStages); - - CapsInternals* caps = this->capsInternals(); - - GrGLint numFormats; - GR_GL_GetIntegerv(gl, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats); - SkAutoSTMalloc<10, GrGLint> formats(numFormats); - GR_GL_GetIntegerv(gl, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); - for (int i = 0; i < numFormats; ++i) { - if (formats[i] == GR_GL_PALETTE8_RGBA8) { - caps->f8BitPaletteSupport = true; - break; - } - } - - if (kDesktop_GrGLBinding == this->glBinding()) { - // we could also look for GL_ATI_separate_stencil extension or - // GL_EXT_stencil_two_side but they use different function signatures - // than GL2.0+ (and than each other). - caps->fTwoSidedStencilSupport = (this->glVersion() >= GR_GL_VER(2,0)); - // supported on GL 1.4 and higher or by extension - caps->fStencilWrapOpsSupport = (this->glVersion() >= GR_GL_VER(1,4)) || - this->hasExtension("GL_EXT_stencil_wrap"); - } else { - // ES 2 has two sided stencil and stencil wrap - caps->fTwoSidedStencilSupport = true; - caps->fStencilWrapOpsSupport = true; - } - - if (kDesktop_GrGLBinding == this->glBinding()) { - caps->fBufferLockSupport = true; // we require VBO support and the desktop VBO - // extension includes glMapBuffer. - } else { - caps->fBufferLockSupport = this->hasExtension("GL_OES_mapbuffer"); - } - - if (kDesktop_GrGLBinding == this->glBinding()) { - if (this->glVersion() >= GR_GL_VER(2,0) || - this->hasExtension("GL_ARB_texture_non_power_of_two")) { - caps->fNPOTTextureTileSupport = true; - } else { - caps->fNPOTTextureTileSupport = false; - } - } else { - // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only - caps->fNPOTTextureTileSupport = this->hasExtension("GL_OES_texture_npot"); - } - - caps->fHWAALineSupport = (kDesktop_GrGLBinding == this->glBinding()); - - GR_GL_GetIntegerv(gl, GR_GL_MAX_TEXTURE_SIZE, &caps->fMaxTextureSize); - GR_GL_GetIntegerv(gl, GR_GL_MAX_RENDERBUFFER_SIZE, &caps->fMaxRenderTargetSize); - // Our render targets are always created with textures as the color - // attachment, hence this min: - caps->fMaxRenderTargetSize = GrMin(caps->fMaxTextureSize, caps->fMaxRenderTargetSize); - - caps->fFSAASupport = GrGLCaps::kNone_MSFBOType != this->glCaps().msFBOType(); - caps->fPathStencilingSupport = GR_GL_USE_NV_PATH_RENDERING && - this->hasExtension("GL_NV_path_rendering"); - - // Enable supported shader-related caps - if (kDesktop_GrGLBinding == this->glBinding()) { - caps->fDualSourceBlendingSupport = this->glVersion() >= GR_GL_VER(3,3) || - this->hasExtension("GL_ARB_blend_func_extended"); - caps->fShaderDerivativeSupport = true; - // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS - caps->fGeometryShaderSupport = this->glVersion() >= GR_GL_VER(3,2) && - this->glslGeneration() >= k150_GrGLSLGeneration; - } else { - caps->fShaderDerivativeSupport = this->hasExtension("GL_OES_standard_derivatives"); - } - - if (GrGLCaps::kImaginationES_MSFBOType == this->glCaps().msFBOType()) { - GR_GL_GetIntegerv(this->glInterface(), GR_GL_MAX_SAMPLES_IMG, &caps->fMaxSampleCount); - } else if (GrGLCaps::kNone_MSFBOType != this->glCaps().msFBOType()) { - GR_GL_GetIntegerv(this->glInterface(), GR_GL_MAX_SAMPLES, &caps->fMaxSampleCount); - } -} - void GrGpuGL::fillInConfigRenderableTable() { // OpenGL < 3.0 @@ -399,11 +313,6 @@ bool GrGpuGL::fullReadPixelsIsFasterThanPartial() const { } void GrGpuGL::onResetContext() { - if (gPrintStartupSpew && !fPrintedCaps) { - fPrintedCaps = true; - this->getCaps().print(); - this->glCaps().print(); - } // we don't use the zb at all GL_CALL(Disable(GR_GL_DEPTH_TEST)); @@ -463,7 +372,7 @@ void GrGpuGL::onResetContext() { fHWBoundRenderTarget = NULL; fHWPathStencilMatrixState.invalidate(); - if (fCaps.pathStencilingSupport()) { + if (this->caps()->pathStencilingSupport()) { // we don't use the model view matrix. GL_CALL(MatrixMode(GR_GL_MODELVIEW)); GL_CALL(LoadIdentity()); @@ -511,7 +420,7 @@ GrTexture* GrGpuGL::onWrapBackendTexture(const GrBackendTextureDesc& desc) { return NULL; } - int maxSize = this->getCaps().maxTextureSize(); + int maxSize = this->caps()->maxTextureSize(); if (desc.fWidth > maxSize || desc.fHeight > maxSize) { return NULL; } @@ -836,12 +745,12 @@ bool renderbuffer_storage_msaa(GrGLContext& ctx, GrGLenum format, int width, int height) { CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); - GrAssert(GrGLCaps::kNone_MSFBOType != ctx.info().caps().msFBOType()); + GrAssert(GrGLCaps::kNone_MSFBOType != ctx.info().caps()->msFBOType()); bool created = false; if (GrGLCaps::kNVDesktop_CoverageAAType == - ctx.info().caps().coverageAAType()) { + ctx.info().caps()->coverageAAType()) { const GrGLCaps::MSAACoverageMode& mode = - ctx.info().caps().getMSAACoverageMode(sampleCount); + ctx.info().caps()->getMSAACoverageMode(sampleCount); GL_ALLOC_CALL(ctx.interface(), RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER, mode.fCoverageSampleCnt, @@ -924,7 +833,7 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height, if (status != GR_GL_FRAMEBUFFER_COMPLETE) { goto FAILED; } - fGLContext.info().caps().markConfigAsValidColorAttachment(desc->fConfig); + fGLContext.info().caps()->markConfigAsValidColorAttachment(desc->fConfig); } } GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID)); @@ -945,7 +854,7 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height, if (status != GR_GL_FRAMEBUFFER_COMPLETE) { goto FAILED; } - fGLContext.info().caps().markConfigAsValidColorAttachment(desc->fConfig); + fGLContext.info().caps()->markConfigAsValidColorAttachment(desc->fConfig); } return true; @@ -990,7 +899,7 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, return return_null_texture(); } // If the sample count exceeds the max then we clamp it. - glTexDesc.fSampleCnt = GrMin(desc.fSampleCnt, this->getCaps().maxSampleCount()); + glTexDesc.fSampleCnt = GrMin(desc.fSampleCnt, this->caps()->maxSampleCount()); glTexDesc.fFlags = desc.fFlags; glTexDesc.fWidth = desc.fWidth; @@ -1006,8 +915,6 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, bool renderTarget = 0 != (desc.fFlags & kRenderTarget_GrTextureFlagBit); - const Caps& caps = this->getCaps(); - glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); glRTDesc.fOrigin = glTexDesc.fOrigin; @@ -1019,8 +926,8 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, } if (renderTarget) { - if (glTexDesc.fWidth > caps.maxRenderTargetSize() || - glTexDesc.fHeight > caps.maxRenderTargetSize()) { + int maxRTSize = this->caps()->maxRenderTargetSize(); + if (glTexDesc.fWidth > maxRTSize || glTexDesc.fHeight > maxRTSize) { return return_null_texture(); } } @@ -1234,7 +1141,7 @@ bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTar } return false; } else { - fGLContext.info().caps().markColorConfigAndStencilFormatAsVerified( + fGLContext.info().caps()->markColorConfigAndStencilFormatAsVerified( rt->config(), glsb->format()); } @@ -1312,7 +1219,7 @@ GrIndexBuffer* GrGpuGL::onCreateIndexBuffer(uint32_t size, bool dynamic) { } GrPath* GrGpuGL::onCreatePath(const SkPath& inPath) { - GrAssert(fCaps.pathStencilingSupport()); + GrAssert(this->caps()->pathStencilingSupport()); return SkNEW_ARGS(GrGLPath, (this, inPath)); } @@ -1735,7 +1642,7 @@ void GrGpuGL::setStencilPathSettings(const GrPath&, } void GrGpuGL::onGpuStencilPath(const GrPath* path, SkPath::FillType fill) { - GrAssert(fCaps.pathStencilingSupport()); + GrAssert(this->caps()->pathStencilingSupport()); GrGLuint id = static_cast(path)->pathID(); GrDrawState* drawState = this->drawState(); @@ -1918,7 +1825,7 @@ void GrGpuGL::flushStencil(DrawType type) { } } if (!fStencilSettings.isDisabled()) { - if (this->getCaps().twoSidedStencilSupport()) { + if (this->caps()->twoSidedStencilSupport()) { set_gl_stencil(this->glInterface(), fStencilSettings, GR_GL_FRONT, @@ -2268,7 +2175,7 @@ bool GrGpuGL::configToGLFormats(GrPixelConfig config, *externalType = GR_GL_UNSIGNED_SHORT_4_4_4_4; break; case kIndex_8_GrPixelConfig: - if (this->getCaps().eightBitPaletteSupport()) { + if (this->caps()->eightBitPaletteSupport()) { *internalFormat = GR_GL_PALETTE8_RGBA8; // glCompressedTexImage doesn't take external params *externalFormat = GR_GL_PALETTE8_RGBA8; diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index e871f220d5..423d87fe16 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -57,7 +57,7 @@ public: virtual void abandonResources() SK_OVERRIDE; - const GrGLCaps& glCaps() const { return fGLContext.info().caps(); } + const GrGLCaps& glCaps() const { return *fGLContext.info().caps(); } // These functions should be used to bind GL objects. They track the GL state and skip redundant // bindings. Making the equivalent glBind calls directly will confuse the state tracking. @@ -218,9 +218,6 @@ private: // flushing the scissor after that function is called. void flushScissor(); - // Inits GrDrawTarget::Caps, subclass may enable additional caps. - void initCaps(); - void initFSAASupport(); // determines valid stencil formats @@ -431,8 +428,6 @@ private: // from our loop that tries stencil formats and calls check fb status. int fLastSuccessfulStencilFmtIdx; - bool fPrintedCaps; - typedef GrGpu INHERITED; }; -- cgit v1.2.3