Remove ownership parameter from GrResourceProvider::wrapBackendTextureAsRenderTarget

Remove ownership parameter from
GrResourceProvider::wrapBackendTextureAsRenderTarget.
The function leaks the texture id if kAdopt_LifeCycle is passed.

There is no public API to access the parameter.

BUG=594928
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1842313003

Review URL: https://codereview.chromium.org/1842313003
This commit is contained in:
kkinnunen 2016-04-01 04:50:37 -07:00 committed by Commit bot
parent 4d51f64ff1
commit 49c4c22b37
8 changed files with 21 additions and 34 deletions

View File

@ -220,8 +220,7 @@ GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc&
return this->onWrapBackendRenderTarget(desc, ownership);
}
GrRenderTarget* GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc,
GrWrapOwnership ownership) {
GrRenderTarget* GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc) {
this->handleDirtyContext();
if (!(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) {
return nullptr;
@ -233,7 +232,7 @@ GrRenderTarget* GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDe
if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
return nullptr;
}
return this->onWrapBackendTextureAsRenderTarget(desc, ownership);
return this->onWrapBackendTextureAsRenderTarget(desc);
}
GrBuffer* GrGpu::createBuffer(GrBufferType type, size_t size, GrAccessPattern accessPattern) {

View File

@ -124,7 +124,7 @@ public:
/**
* Implements GrTextureProvider::wrapBackendTextureAsRenderTarget
*/
GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&, GrWrapOwnership);
GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&);
/**
* Creates a buffer.
@ -526,8 +526,7 @@ private:
virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) = 0;
virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
GrWrapOwnership) = 0;
virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&,
GrWrapOwnership) = 0;
virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) = 0;
virtual GrBuffer* onCreateBuffer(GrBufferType, size_t size, GrAccessPattern) = 0;
// overridden by backend-specific derived class to perform the clear.

View File

@ -186,9 +186,9 @@ GrStencilAttachment* GrResourceProvider::attachStencilAttachment(GrRenderTarget*
}
GrRenderTarget* GrResourceProvider::wrapBackendTextureAsRenderTarget(
const GrBackendTextureDesc& desc, GrWrapOwnership ownership) {
const GrBackendTextureDesc& desc) {
if (this->isAbandoned()) {
return nullptr;
}
return this->gpu()->wrapBackendTextureAsRenderTarget(desc, ownership);
return this->gpu()->wrapBackendTextureAsRenderTarget(desc);
}

View File

@ -140,10 +140,12 @@ public:
* Wraps an existing texture with a GrRenderTarget object. This is useful when the provided
* texture has a format that cannot be textured from by Skia, but we want to raster to it.
*
* The texture is wrapped as borrowed. The texture object will not be freed once the
* render target is destroyed.
*
* @return GrRenderTarget object or NULL on failure.
*/
GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc,
GrWrapOwnership = kBorrow_GrWrapOwnership);
GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc);
private:
const GrBuffer* createInstancedIndexBuffer(const uint16_t* pattern,

View File

@ -661,8 +661,7 @@ GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencilBits);
}
GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc,
GrWrapOwnership ownership) {
GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc) {
#ifdef SK_IGNORE_GL_TEXTURE_TARGET
if (!desc.fTextureHandle) {
return nullptr;
@ -674,34 +673,25 @@ GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextu
}
#endif
GrGLTexture::IDDesc idDesc;
GrGLTextureInfo texInfo;
GrSurfaceDesc surfDesc;
#ifdef SK_IGNORE_GL_TEXTURE_TARGET
idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle);
texInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle);
// We only support GL_TEXTURE_2D at the moment.
idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
texInfo.fTarget = GR_GL_TEXTURE_2D;
#else
idDesc.fInfo = *info;
texInfo = *info;
#endif
if (GR_GL_TEXTURE_RECTANGLE != idDesc.fInfo.fTarget &&
GR_GL_TEXTURE_2D != idDesc.fInfo.fTarget) {
if (GR_GL_TEXTURE_RECTANGLE != texInfo.fTarget &&
GR_GL_TEXTURE_2D != texInfo.fTarget) {
// Only texture rectangle and texture 2d are supported. We do not check whether texture
// rectangle is supported by Skia - if the caller provided us with a texture rectangle,
// we assume the necessary support exists.
return nullptr;
}
switch (ownership) {
case kAdopt_GrWrapOwnership:
idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle;
break;
case kBorrow_GrWrapOwnership:
idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle;
break;
}
surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags;
surfDesc.fWidth = desc.fWidth;
surfDesc.fHeight = desc.fHeight;
@ -719,7 +709,7 @@ GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextu
GrGLRenderTarget::IDDesc rtIDDesc;
if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_LifeCycle,
idDesc.fInfo, &rtIDDesc)) {
texInfo, &rtIDDesc)) {
return nullptr;
}
return GrGLRenderTarget::CreateWrapped(this, surfDesc, rtIDDesc, 0);

View File

@ -142,8 +142,7 @@ private:
GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override;
GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
GrWrapOwnership) override;
GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&,
GrWrapOwnership) override;
GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override;
// Given a GrPixelConfig return the index into the stencil format array on GrGLCaps to a
// compatible stencil format, or negative if there is no compatible stencil format.
int getCompatibleStencilIndex(GrPixelConfig config);

View File

@ -129,8 +129,7 @@ private:
GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
GrWrapOwnership) override;
GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&,
GrWrapOwnership) override { return NULL; }
GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override { return NULL; }
GrBuffer* onCreateBuffer(GrBufferType, size_t size, GrAccessPattern) override;

View File

@ -340,8 +340,7 @@ private:
return nullptr;
}
GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&,
GrWrapOwnership) override {
GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override {
return nullptr;
}