Remove ownership aruments from render target wrap functions
We never adopt render targets (just borrow them). BUG=skia: Change-Id: Ie899b814a7a81339a8735bbd7ad9facc66e580d7 Reviewed-on: https://skia-review.googlesource.com/9525 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
b726d58efc
commit
0b791f57c4
@ -225,13 +225,12 @@ sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc,
|
||||
return tex;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc,
|
||||
GrWrapOwnership ownership) {
|
||||
sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) {
|
||||
if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
|
||||
return nullptr;
|
||||
}
|
||||
this->handleDirtyContext();
|
||||
return this->onWrapBackendRenderTarget(desc, ownership);
|
||||
return this->onWrapBackendRenderTarget(desc);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc) {
|
||||
|
@ -129,7 +129,7 @@ public:
|
||||
/**
|
||||
* Implements GrResourceProvider::wrapBackendRenderTarget
|
||||
*/
|
||||
sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTargetDesc&,GrWrapOwnership);
|
||||
sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTargetDesc&);
|
||||
|
||||
/**
|
||||
* Implements GrResourceProvider::wrapBackendTextureAsRenderTarget
|
||||
@ -542,8 +542,7 @@ private:
|
||||
const SkTArray<GrMipLevel>& texels) = 0;
|
||||
|
||||
virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) = 0;
|
||||
virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
|
||||
GrWrapOwnership) = 0;
|
||||
virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) = 0;
|
||||
virtual sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&)=0;
|
||||
virtual GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrAccessPattern,
|
||||
const void* data) = 0;
|
||||
|
@ -180,8 +180,7 @@ sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendRenderTarget(
|
||||
const GrBackendRenderTargetDesc& desc)
|
||||
{
|
||||
ASSERT_SINGLE_OWNER
|
||||
return this->isAbandoned() ? nullptr
|
||||
: fGpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership);
|
||||
return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(desc);
|
||||
}
|
||||
|
||||
void GrResourceProvider::assignUniqueKeyToResource(const GrUniqueKey& key,
|
||||
|
@ -578,17 +578,12 @@ sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
|
||||
return GrGLTexture::MakeWrapped(this, surfDesc, idDesc);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc,
|
||||
GrWrapOwnership ownership) {
|
||||
sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc){
|
||||
GrGLRenderTarget::IDDesc idDesc;
|
||||
idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle);
|
||||
idDesc.fMSColorRenderbufferID = 0;
|
||||
idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
|
||||
if (kAdopt_GrWrapOwnership == ownership) {
|
||||
idDesc.fRTFBOOwnership = GrBackendObjectOwnership::kOwned;
|
||||
} else {
|
||||
idDesc.fRTFBOOwnership = GrBackendObjectOwnership::kBorrowed;
|
||||
}
|
||||
idDesc.fRTFBOOwnership = GrBackendObjectOwnership::kBorrowed;
|
||||
idDesc.fIsMixedSampled = false;
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
|
@ -171,8 +171,7 @@ private:
|
||||
GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrAccessPattern,
|
||||
const void* data) override;
|
||||
sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override;
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
|
||||
GrWrapOwnership) override;
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) override;
|
||||
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override;
|
||||
|
||||
gr_instanced::InstancedRendering* onCreateInstancedRendering() override;
|
||||
|
@ -789,13 +789,11 @@ sk_sp<GrTexture> GrVkGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
|
||||
return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, ownership, info);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc,
|
||||
GrWrapOwnership ownership) {
|
||||
sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc){
|
||||
|
||||
const GrVkImageInfo* info =
|
||||
reinterpret_cast<const GrVkImageInfo*>(wrapDesc.fRenderTargetHandle);
|
||||
if (VK_NULL_HANDLE == info->fImage ||
|
||||
(VK_NULL_HANDLE == info->fAlloc.fMemory && kAdopt_GrWrapOwnership == ownership)) {
|
||||
if (VK_NULL_HANDLE == info->fImage) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -808,8 +806,7 @@ sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTa
|
||||
|
||||
desc.fOrigin = resolve_origin(wrapDesc.fOrigin);
|
||||
|
||||
sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(this, desc,
|
||||
ownership, info);
|
||||
sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(this, desc, info);
|
||||
if (tgt && wrapDesc.fStencilBits) {
|
||||
if (!createStencilAttachmentForRenderTarget(tgt.get(), desc.fWidth, desc.fHeight)) {
|
||||
return nullptr;
|
||||
|
@ -177,8 +177,7 @@ private:
|
||||
|
||||
sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override;
|
||||
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
|
||||
GrWrapOwnership) override;
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) override;
|
||||
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -198,18 +198,12 @@ GrVkRenderTarget::CreateNewRenderTarget(GrVkGpu* gpu,
|
||||
sk_sp<GrVkRenderTarget>
|
||||
GrVkRenderTarget::MakeWrappedRenderTarget(GrVkGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
GrWrapOwnership ownership,
|
||||
const GrVkImageInfo* info) {
|
||||
SkASSERT(info);
|
||||
// We can wrap a rendertarget without its allocation, as long as we don't take ownership
|
||||
SkASSERT(VK_NULL_HANDLE != info->fImage);
|
||||
SkASSERT(VK_NULL_HANDLE != info->fAlloc.fMemory || kAdopt_GrWrapOwnership != ownership);
|
||||
|
||||
GrVkImage::Wrapped wrapped = kBorrow_GrWrapOwnership == ownership ? GrVkImage::kBorrowed_Wrapped
|
||||
: GrVkImage::kAdopted_Wrapped;
|
||||
|
||||
return sk_sp<GrVkRenderTarget>(
|
||||
GrVkRenderTarget::Create(gpu, SkBudgeted::kNo, desc, *info, wrapped));
|
||||
GrVkRenderTarget::Create(gpu, SkBudgeted::kNo, desc, *info, GrVkImage::kBorrowed_Wrapped));
|
||||
}
|
||||
|
||||
bool GrVkRenderTarget::completeStencilAttachment() {
|
||||
|
@ -35,7 +35,6 @@ public:
|
||||
const GrVkImage::ImageDesc&);
|
||||
|
||||
static sk_sp<GrVkRenderTarget> MakeWrappedRenderTarget(GrVkGpu*, const GrSurfaceDesc&,
|
||||
GrWrapOwnership,
|
||||
const GrVkImageInfo*);
|
||||
|
||||
~GrVkRenderTarget() override;
|
||||
|
@ -83,31 +83,21 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
desc.fSampleCnt = 0;
|
||||
desc.fStencilBits = 0;
|
||||
desc.fRenderTargetHandle = backendObj;
|
||||
sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership);
|
||||
sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(desc);
|
||||
REPORTER_ASSERT(reporter, rt);
|
||||
|
||||
// image is null
|
||||
GrVkImageInfo backendCopy = *backendTex;
|
||||
backendCopy.fImage = VK_NULL_HANDLE;
|
||||
desc.fRenderTargetHandle = (GrBackendObject)&backendCopy;
|
||||
rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership);
|
||||
REPORTER_ASSERT(reporter, !rt);
|
||||
rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership);
|
||||
rt = gpu->wrapBackendRenderTarget(desc);
|
||||
REPORTER_ASSERT(reporter, !rt);
|
||||
|
||||
// alloc is null
|
||||
backendCopy.fImage = backendTex->fImage;
|
||||
backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
|
||||
// can wrap null alloc if borrowing
|
||||
rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership);
|
||||
REPORTER_ASSERT(reporter, rt);
|
||||
// but not if adopting
|
||||
rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership);
|
||||
REPORTER_ASSERT(reporter, !rt);
|
||||
|
||||
// check adopt creation
|
||||
backendCopy.fAlloc = backendTex->fAlloc;
|
||||
rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership);
|
||||
// can wrap null alloc
|
||||
rt = gpu->wrapBackendRenderTarget(desc);
|
||||
REPORTER_ASSERT(reporter, rt);
|
||||
|
||||
gpu->deleteTestingOnlyBackendTexture(backendObj, true);
|
||||
|
@ -340,8 +340,7 @@ private:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
|
||||
GrWrapOwnership) override {
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user