diff options
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 40 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.cpp | 23 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.h | 7 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTextureRenderTarget.cpp | 7 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTextureRenderTarget.h | 3 |
6 files changed, 29 insertions, 55 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index bef1f1919f..86aa76f981 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1010,7 +1010,7 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight GrSurfaceOrigin texOrigin, GrGLenum target, UploadType uploadType, int left, int top, int width, int height, GrPixelConfig dataConfig, const GrMipLevel texels[], int mipLevelCount, - bool* wasFullMipMapDataProvided) { + GrMipMapsStatus* mipMapsStatus) { SkASSERT(this->caps()->isConfigTexturable(texConfig)); SkDEBUGCODE( SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height); @@ -1076,9 +1076,8 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight // in case we need a temporary, trimmed copy of the src pixels SkAutoSMalloc<128 * 128> tempStorage; - if (wasFullMipMapDataProvided) { - // Make sure this is initialized to true - *wasFullMipMapDataProvided = true; + if (mipMapsStatus) { + *mipMapsStatus = GrMipMapsStatus::kValid; } // find the combined size of all the mip levels and the relative offset of @@ -1094,12 +1093,14 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight individualMipOffsets.push_back(combinedBufferSize); combinedBufferSize += trimmedSize; } else { - if (wasFullMipMapDataProvided) { - *wasFullMipMapDataProvided = false; + if (mipMapsStatus) { + *mipMapsStatus = GrMipMapsStatus::kDirty; } individualMipOffsets.push_back(0); } - + } + if (mipMapsStatus && mipLevelCount <= 1) { + *mipMapsStatus = GrMipMapsStatus::kNotAllocated; } char* buffer = (char*)tempStorage.reset(combinedBufferSize); @@ -1416,18 +1417,13 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, GrGLTexture::IDDesc idDesc; idDesc.fOwnership = GrBackendObjectOwnership::kOwned; - bool wasFullMipMapDataProvided = true; + GrMipMapsStatus mipMapsStatus; GrGLTexture::TexParams initialTexParams; if (!this->createTextureImpl(desc, &idDesc.fInfo, isRenderTarget, &initialTexParams, - texels, mipLevelCount, &wasFullMipMapDataProvided)) { + texels, mipLevelCount, &mipMapsStatus)) { return return_null_texture(); } - bool mipsAllocated = false; - if (mipLevelCount > 1) { - mipsAllocated = true; - } - sk_sp<GrGLTexture> tex; if (isRenderTarget) { // unbind the texture from the texture unit before binding it to the frame buffer @@ -1439,11 +1435,10 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, return return_null_texture(); } tex = sk_make_sp<GrGLTextureRenderTarget>(this, budgeted, desc, idDesc, rtIDDesc, - mipsAllocated, wasFullMipMapDataProvided); + mipMapsStatus); tex->baseLevelWasBoundToFBO(); } else { - tex = sk_make_sp<GrGLTexture>(this, budgeted, desc, idDesc, - mipsAllocated, wasFullMipMapDataProvided); + tex = sk_make_sp<GrGLTexture>(this, budgeted, desc, idDesc, mipMapsStatus); } tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); #ifdef TRACE_TEXTURE_CREATION @@ -1615,7 +1610,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) { bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info, bool renderTarget, GrGLTexture::TexParams* initialTexParams, const GrMipLevel texels[], int mipLevelCount, - bool* wasFullMipMapDataProvided) { + GrMipMapsStatus* mipMapsStatus) { info->fID = 0; info->fTarget = GR_GL_TEXTURE_2D; GL_CALL(GenTextures(1, &(info->fID))); @@ -1639,7 +1634,7 @@ bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info } if (!this->uploadTexData(desc.fConfig, desc.fWidth, desc.fHeight, desc.fOrigin, info->fTarget, kNewTexture_UploadType, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig, - texels, mipLevelCount)) { + texels, mipLevelCount, mipMapsStatus)) { GL_CALL(DeleteTextures(1, &(info->fID))); return false; } @@ -3169,7 +3164,7 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, bool allowSRGBInputs : SkDestinationSurfaceColorMode::kLegacy; if (GrPixelConfigIsSRGB(texture->config()) && colorMode != texture->texturePriv().mipColorMode()) { - texture->texturePriv().dirtyMipMaps(true); + texture->texturePriv().markMipMapsDirty(); } // If the mips aren't dirty, we're done: @@ -3177,9 +3172,6 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, bool allowSRGBInputs return; } - // Make sure we at least have some base layer to make mips from - SkASSERT(texture->texturePriv().mipMapsAreValid()); - // If we created a rt/tex and rendered to it without using a texture and now we're texturing // from the rt it will still be the last bound texture, but it needs resolving. GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderTarget()); @@ -3211,7 +3203,7 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, bool allowSRGBInputs GL_CALL(GenerateMipmap(target)); } - texture->texturePriv().dirtyMipMaps(false); + texture->texturePriv().markMipMapsClean(); texture->texturePriv().setMaxMipMapLevel(SkMipMap::ComputeLevelCount( texture->width(), texture->height())); texture->texturePriv().setMipColorMode(colorMode); diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 20758c382c..a3af0ae8db 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -225,7 +225,7 @@ private: bool createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info, bool renderTarget, GrGLTexture::TexParams* initialTexParams, const GrMipLevel texels[], int mipLevelCount, - bool* wasFullMipMapDataProvided); + GrMipMapsStatus* mipMapsStatus); bool onIsACopyNeededForTextureParams(GrTextureProxy*, const GrSamplerState&, GrTextureProducer::CopyParams*, @@ -393,7 +393,7 @@ private: GrSurfaceOrigin texOrigin, GrGLenum target, UploadType uploadType, int left, int top, int width, int height, GrPixelConfig dataConfig, const GrMipLevel texels[], int mipLevelCount, - bool* wasFullMipMapDataProvided = nullptr); + GrMipMapsStatus* mipMapsStatus = nullptr); bool createRenderTargetObjects(const GrSurfaceDesc&, const GrGLTextureInfo& texInfo, GrGLRenderTarget::IDDesc*); diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp index 789c0b756e..aa918d5ed7 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -49,22 +49,10 @@ 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) + const IDDesc& idDesc, GrMipMapsStatus mipMapsStatus) : GrSurface(gpu, desc) , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu), - highest_filter_mode(idDesc, desc.fConfig), false, false) { - this->init(desc, idDesc); - this->registerWithCache(budgeted); -} - -GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc, - const IDDesc& idDesc, - bool mipsAllocated, - bool wasFullMipMapDataProvided) - : GrSurface(gpu, desc) - , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu), - highest_filter_mode(idDesc, desc.fConfig), - mipsAllocated, wasFullMipMapDataProvided) { + highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) { this->init(desc, idDesc); this->registerWithCache(budgeted); } @@ -72,17 +60,16 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc, const IDDesc& idDesc) : GrSurface(gpu, desc) , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu), - highest_filter_mode(idDesc, desc.fConfig), false, false) { + highest_filter_mode(idDesc, desc.fConfig), GrMipMapsStatus::kNotAllocated) { this->init(desc, idDesc); this->registerWithCacheWrapped(); } GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc, - bool mipsAllocated, bool wasFullMipMapDataProvided) + GrMipMapsStatus mipMapsStatus) : GrSurface(gpu, desc) , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu), - highest_filter_mode(idDesc, desc.fConfig), - mipsAllocated, wasFullMipMapDataProvided) { + highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) { this->init(desc, idDesc); } diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h index f2dc739f2d..8ab6805738 100644 --- a/src/gpu/gl/GrGLTexture.h +++ b/src/gpu/gl/GrGLTexture.h @@ -32,9 +32,7 @@ public: GrGLTextureInfo fInfo; GrBackendObjectOwnership fOwnership; }; - GrGLTexture(GrGLGpu*, SkBudgeted, const GrSurfaceDesc&, const IDDesc&); - GrGLTexture(GrGLGpu*, SkBudgeted, const GrSurfaceDesc&, const IDDesc&, - bool mipsAllocated, bool wasFullMipMapDataProvided); + GrGLTexture(GrGLGpu*, SkBudgeted, const GrSurfaceDesc&, const IDDesc&, GrMipMapsStatus); ~GrGLTexture() override { // check that invokeReleaseProc has been called (if needed) @@ -73,8 +71,7 @@ public: protected: // Constructor for subclasses. - GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, - bool mipsAllocated, bool wasMipMapDataProvided); + GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, GrMipMapsStatus); enum Wrapped { kWrapped }; // Constructor for instances wrapping backend objects. diff --git a/src/gpu/gl/GrGLTextureRenderTarget.cpp b/src/gpu/gl/GrGLTextureRenderTarget.cpp index b60d3c94ef..c5a75be872 100644 --- a/src/gpu/gl/GrGLTextureRenderTarget.cpp +++ b/src/gpu/gl/GrGLTextureRenderTarget.cpp @@ -17,10 +17,9 @@ GrGLTextureRenderTarget::GrGLTextureRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, const GrGLTexture::IDDesc& texIDDesc, const GrGLRenderTarget::IDDesc& rtIDDesc, - bool mipsAllocated, - bool wasFullMipMapDataProvided) + GrMipMapsStatus mipMapsStatus) : GrSurface(gpu, desc) - , GrGLTexture(gpu, desc, texIDDesc, mipsAllocated, wasFullMipMapDataProvided) + , GrGLTexture(gpu, desc, texIDDesc, mipMapsStatus) , GrGLRenderTarget(gpu, desc, rtIDDesc) { this->registerWithCache(budgeted); } @@ -30,7 +29,7 @@ GrGLTextureRenderTarget::GrGLTextureRenderTarget(GrGLGpu* gpu, const GrGLTexture::IDDesc& texIDDesc, const GrGLRenderTarget::IDDesc& rtIDDesc) : GrSurface(gpu, desc) - , GrGLTexture(gpu, desc, texIDDesc, false, false) + , GrGLTexture(gpu, desc, texIDDesc, GrMipMapsStatus::kNotAllocated) , GrGLRenderTarget(gpu, desc, rtIDDesc) { this->registerWithCacheWrapped(); } diff --git a/src/gpu/gl/GrGLTextureRenderTarget.h b/src/gpu/gl/GrGLTextureRenderTarget.h index 2242933e0c..6621f9c004 100644 --- a/src/gpu/gl/GrGLTextureRenderTarget.h +++ b/src/gpu/gl/GrGLTextureRenderTarget.h @@ -29,8 +29,7 @@ public: const GrSurfaceDesc& desc, const GrGLTexture::IDDesc& texIDDesc, const GrGLRenderTarget::IDDesc& rtIDDesc, - bool mipsAllocated, - bool wasFullMipMapDataProvided); + GrMipMapsStatus); bool canAttemptStencilAttachment() const override; |