diff options
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.cpp | 77 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.h | 9 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUniformHandler.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUniformHandler.h | 2 |
5 files changed, 58 insertions, 40 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index e04a40d8ab..ea1bfcd726 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -3008,7 +3008,8 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) { int progIdx = TextureToCopyProgramIdx(srcTex); const GrShaderCaps* shaderCaps = this->caps()->shaderCaps(); - GrSLType samplerType = srcTex->texturePriv().samplerType(); + GrSLType samplerType = + GrSLCombinedSamplerTypeForTextureType(srcTex->texturePriv().textureType()); if (!fCopyProgramArrayBuffer) { static const GrGLfloat vdata[] = { @@ -4126,7 +4127,7 @@ sk_sp<GrSemaphore> GrGLGpu::prepareTextureForCrossContextUsage(GrTexture* textur } int GrGLGpu::TextureToCopyProgramIdx(GrTexture* texture) { - switch (texture->texturePriv().samplerType()) { + switch (GrSLCombinedSamplerTypeForTextureType(texture->texturePriv().textureType())) { case kTexture2DSampler_GrSLType: return 0; case kTexture2DRectSampler_GrSLType: diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp index 2d674f4756..f0fafabcba 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -15,18 +15,30 @@ #define GPUGL static_cast<GrGLGpu*>(this->getGpu()) #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) -static inline GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, GrPixelConfig config, - const GrGLGpu* gpu) { - if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) { - SkASSERT(gpu->caps()->shaderCaps()->externalTextureSupport()); - return kTextureExternalSampler_GrSLType; - } else if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE) { - SkASSERT(gpu->glCaps().rectangleTextureSupport()); - return kTexture2DRectSampler_GrSLType; - } else { - SkASSERT(idDesc.fInfo.fTarget == GR_GL_TEXTURE_2D); - return kTexture2DSampler_GrSLType; +static inline GrTextureType texture_type_from_target(GrGLenum target) { + switch (target) { + case GR_GL_TEXTURE_2D: + return GrTextureType::k2D; + case GR_GL_TEXTURE_RECTANGLE: + return GrTextureType::kRectangle; + case GR_GL_TEXTURE_EXTERNAL: + return GrTextureType::kExternal; } + SK_ABORT("Unexpected texture target"); + return GrTextureType::k2D; +} + +static inline GrGLenum target_from_texture_type(GrTextureType type) { + switch (type) { + case GrTextureType::k2D: + return GR_GL_TEXTURE_2D; + case GrTextureType::kRectangle: + return GR_GL_TEXTURE_RECTANGLE; + case GrTextureType::kExternal: + return GR_GL_TEXTURE_EXTERNAL; + } + SK_ABORT("Unexpected texture type"); + return GR_GL_TEXTURE_2D; } // This method parallels GrTextureProxy::highestFilterMode @@ -42,27 +54,27 @@ static inline GrSamplerState::Filter highest_filter_mode(const GrGLTexture::IDDe // Because this class is virtually derived from GrSurface we must explicitly call its constructor. GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc, const IDDesc& idDesc, GrMipMapsStatus mipMapsStatus) - : GrSurface(gpu, desc) - , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu), - highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) { + : GrSurface(gpu, desc) + , INHERITED(gpu, desc, texture_type_from_target(idDesc.fInfo.fTarget), + highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) { this->init(desc, idDesc); this->registerWithCache(budgeted); } GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc, GrMipMapsStatus mipMapsStatus, const IDDesc& idDesc) - : GrSurface(gpu, desc) - , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu), - highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) { + : GrSurface(gpu, desc) + , INHERITED(gpu, desc, texture_type_from_target(idDesc.fInfo.fTarget), + highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) { this->init(desc, idDesc); this->registerWithCacheWrapped(); } GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc, GrMipMapsStatus mipMapsStatus) - : GrSurface(gpu, desc) - , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu), - highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) { + : GrSurface(gpu, desc) + , INHERITED(gpu, desc, texture_type_from_target(idDesc.fInfo.fTarget), + highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) { this->init(desc, idDesc); } @@ -75,30 +87,38 @@ void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { } fTexParams.invalidate(); fTexParamsTimestamp = GrGpu::kExpiredTimestamp; - fInfo = idDesc.fInfo; + fID = idDesc.fInfo.fID; + fFormat = idDesc.fInfo.fFormat; fTextureIDOwnership = idDesc.fOwnership; } +GrGLenum GrGLTexture::target() const { + return target_from_texture_type(this->texturePriv().textureType()); +} + void GrGLTexture::onRelease() { - if (fInfo.fID) { + if (fID) { if (GrBackendObjectOwnership::kBorrowed != fTextureIDOwnership) { - GL_CALL(DeleteTextures(1, &fInfo.fID)); + GL_CALL(DeleteTextures(1, &fID)); } - fInfo.fID = 0; + fID = 0; } this->invokeReleaseProc(); INHERITED::onRelease(); } void GrGLTexture::onAbandon() { - fInfo.fTarget = 0; - fInfo.fID = 0; + fID = 0; this->invokeReleaseProc(); INHERITED::onAbandon(); } GrBackendTexture GrGLTexture::getBackendTexture() const { - return GrBackendTexture(this->width(), this->height(), this->texturePriv().mipMapped(), fInfo); + GrGLTextureInfo info; + info.fTarget = target_from_texture_type(this->texturePriv().textureType()); + info.fID = fID; + info.fFormat = fFormat; + return GrBackendTexture(this->width(), this->height(), this->texturePriv().mipMapped(), info); } sk_sp<GrGLTexture> GrGLTexture::MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc, @@ -108,8 +128,7 @@ sk_sp<GrGLTexture> GrGLTexture::MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& d bool GrGLTexture::onStealBackendTexture(GrBackendTexture* backendTexture, SkImage::BackendTextureReleaseProc* releaseProc) { - *backendTexture = GrBackendTexture(this->width(), this->height(), - this->texturePriv().mipMapped(), fInfo); + *backendTexture = this->getBackendTexture(); // Set the release proc to a no-op function. GL doesn't require any special cleanup. *releaseProc = [](GrBackendTexture){}; diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h index 10b8e26e78..298f1faf11 100644 --- a/src/gpu/gl/GrGLTexture.h +++ b/src/gpu/gl/GrGLTexture.h @@ -58,9 +58,9 @@ public: fTexParamsTimestamp = timestamp; } - GrGLuint textureID() const { return fInfo.fID; } + GrGLuint textureID() const { return fID; } - GrGLenum target() const { return fInfo.fTarget; } + GrGLenum target() const; bool hasBaseLevelBeenBoundToFBO() const { return fBaseLevelHasBeenBoundToFBO; } void baseLevelWasBoundToFBO() { fBaseLevelHasBeenBoundToFBO = true; } @@ -96,9 +96,8 @@ private: TexParams fTexParams; GrGpu::ResetTimestamp fTexParamsTimestamp; - // Holds the texture target and ID. A pointer to this may be shared to external clients for - // direct interaction with the GL object. - GrGLTextureInfo fInfo; + GrGLuint fID; + GrGLenum fFormat; GrBackendObjectOwnership fTextureIDOwnership; bool fBaseLevelHasBeenBoundToFBO = false; diff --git a/src/gpu/gl/GrGLUniformHandler.cpp b/src/gpu/gl/GrGLUniformHandler.cpp index 81b1ee69ac..0d57a1422c 100644 --- a/src/gpu/gl/GrGLUniformHandler.cpp +++ b/src/gpu/gl/GrGLUniformHandler.cpp @@ -63,7 +63,7 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray( GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::addSampler(uint32_t visibility, GrSwizzle swizzle, - GrSLType type, + GrTextureType type, GrSLPrecision precision, const char* name) { SkASSERT(name && strlen(name)); @@ -74,8 +74,7 @@ GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::addSampler(uint32_t visi fProgramBuilder->nameVariable(&mangleName, prefix, name, true); UniformInfo& sampler = fSamplers.push_back(); - SkASSERT(GrSLTypeIsCombinedSamplerType(type)); - sampler.fVariable.setType(type); + sampler.fVariable.setType(GrSLCombinedSamplerTypeForTextureType(type)); sampler.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier); sampler.fVariable.setPrecision(precision); sampler.fVariable.setName(mangleName); diff --git a/src/gpu/gl/GrGLUniformHandler.h b/src/gpu/gl/GrGLUniformHandler.h index d3aa2f8358..1bf8553e73 100644 --- a/src/gpu/gl/GrGLUniformHandler.h +++ b/src/gpu/gl/GrGLUniformHandler.h @@ -39,7 +39,7 @@ private: int arrayCount, const char** outName) override; - SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision, + SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrTextureType, GrSLPrecision, const char* name) override; const GrShaderVar& samplerVariable(SamplerHandle handle) const override { |