| Index: src/gpu/gl/GrGLTexture.cpp
|
| diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
|
| index aff91ebe223fb113ca5e986f45cb50e96b952494..9580afec6fcaac89281fca32e657e7501d552dbe 100644
|
| --- a/src/gpu/gl/GrGLTexture.cpp
|
| +++ b/src/gpu/gl/GrGLTexture.cpp
|
| @@ -26,65 +26,81 @@ inline static GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrG
|
| }
|
|
|
| // Because this class is virtually derived from GrSurface we must explicitly call its constructor.
|
| -GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc)
|
| - : GrSurface(gpu, idDesc.fLifeCycle, desc)
|
| - , INHERITED(gpu, idDesc.fLifeCycle, desc, sampler_type(idDesc, gpu), false) {
|
| - this->init(desc, idDesc);
|
| +GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
|
| + const IDDesc& idDesc)
|
| + : GrSurface(gpu, budgeted, desc)
|
| + , INHERITED(gpu, budgeted, desc, sampler_type(idDesc, gpu), false)
|
| + , fIDDesc(idDesc) {
|
| + this->init(desc);
|
| + this->initScratchKeyIfNeeded();
|
| this->registerWithCache();
|
| }
|
|
|
| -GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc,
|
| - bool wasMipMapDataProvided)
|
| - : GrSurface(gpu, idDesc.fLifeCycle, desc)
|
| - , INHERITED(gpu, idDesc.fLifeCycle, desc, sampler_type(idDesc, gpu), wasMipMapDataProvided) {
|
| - this->init(desc, idDesc);
|
| +GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
|
| + const IDDesc& idDesc, bool wasMipMapDataProvided)
|
| + : GrSurface(gpu, budgeted, desc)
|
| + , INHERITED(gpu, budgeted, desc, sampler_type(idDesc, gpu), wasMipMapDataProvided)
|
| + , fIDDesc(idDesc) {
|
| + this->init(desc);
|
| + this->initScratchKeyIfNeeded();
|
| this->registerWithCache();
|
| }
|
|
|
| -GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc, Derived)
|
| - : GrSurface(gpu, idDesc.fLifeCycle, desc)
|
| - , INHERITED(gpu, idDesc.fLifeCycle, desc, sampler_type(idDesc, gpu), false) {
|
| - this->init(desc, idDesc);
|
| +GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
|
| + const IDDesc& idDesc, Derived)
|
| + : GrSurface(gpu, budgeted, desc)
|
| + , INHERITED(gpu, budgeted, desc, sampler_type(idDesc, gpu), false)
|
| + , fIDDesc(idDesc) {
|
| + this->init(desc);
|
| + this->initScratchKeyIfNeeded();
|
| }
|
|
|
| -void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
|
| - SkASSERT(0 != idDesc.fInfo.fID);
|
| +void GrGLTexture::init(const GrSurfaceDesc& desc) {
|
| + SkASSERT(0 != fIDDesc.fInfo.fID);
|
| fTexParams.invalidate();
|
| fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
|
| - fInfo = idDesc.fInfo;
|
| - fTextureIDLifecycle = idDesc.fLifeCycle;
|
| }
|
|
|
| void GrGLTexture::onRelease() {
|
| - if (fInfo.fID) {
|
| - if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) {
|
| + if (fIDDesc.fInfo.fID) {
|
| + if (GrBackendObjectLifeCycle::kBorrowed != fIDDesc.fLifeCycle) {
|
| if (this->desc().fTextureStorageAllocator.fDeallocateTextureStorage) {
|
| this->desc().fTextureStorageAllocator.fDeallocateTextureStorage(
|
| this->desc().fTextureStorageAllocator.fCtx,
|
| - reinterpret_cast<GrBackendObject>(&fInfo));
|
| + reinterpret_cast<GrBackendObject>(&fIDDesc.fInfo));
|
| } else {
|
| - GL_CALL(DeleteTextures(1, &fInfo.fID));
|
| + GL_CALL(DeleteTextures(1, &fIDDesc.fInfo.fID));
|
| }
|
| }
|
| - fInfo.fID = 0;
|
| + fIDDesc.fInfo.fID = 0;
|
| }
|
| INHERITED::onRelease();
|
| }
|
|
|
| void GrGLTexture::onAbandon() {
|
| - fInfo.fTarget = 0;
|
| - fInfo.fID = 0;
|
| + fIDDesc.fInfo.fTarget = 0;
|
| + fIDDesc.fInfo.fID = 0;
|
| INHERITED::onAbandon();
|
| }
|
|
|
| +bool GrGLTexture::refsWrappedResources() const {
|
| + return fIDDesc.fLifeCycle != GrBackendObjectLifeCycle::kInternal;
|
| +}
|
| +
|
| GrBackendObject GrGLTexture::getTextureHandle() const {
|
| #ifdef SK_IGNORE_GL_TEXTURE_TARGET
|
| return static_cast<GrBackendObject>(this->textureID());
|
| #else
|
| - return reinterpret_cast<GrBackendObject>(&fInfo);
|
| + return reinterpret_cast<GrBackendObject>(&fIDDesc.fInfo);
|
| #endif
|
| }
|
|
|
| +size_t GrGLTexture::onGpuMemorySize() const {
|
| + if (GrBackendObjectLifeCycle::kBorrowed != fIDDesc.fLifeCycle) {
|
| + return this->INHERITED::onGpuMemorySize();
|
| + }
|
| + return 0;
|
| +}
|
| void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
|
| const SkString& dumpName) const {
|
| SkString texture_id;
|
|
|