Chromium Code Reviews| Index: src/gpu/vk/GrVkRenderTarget.cpp |
| diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp |
| index ee45aa30e87cf44fe4a918cca779f83ef3c94de8..9ea8d346199806a0852b1ef5c7df45a4897be51a 100644 |
| --- a/src/gpu/vk/GrVkRenderTarget.cpp |
| +++ b/src/gpu/vk/GrVkRenderTarget.cpp |
| @@ -15,6 +15,8 @@ |
| #include "GrVkResourceProvider.h" |
| #include "GrVkUtil.h" |
| +#include "vk/GrVkTypes.h" |
| + |
| #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) |
| // We're virtually derived from GrSurface (via GrRenderTarget) so its |
| @@ -203,12 +205,24 @@ GrVkRenderTarget* |
| GrVkRenderTarget::CreateWrappedRenderTarget(GrVkGpu* gpu, |
| const GrSurfaceDesc& desc, |
| GrGpuResource::LifeCycle lifeCycle, |
| - const GrVkImage::Resource* imageResource) { |
| - SkASSERT(imageResource); |
| + const GrVkTextureInfo* info) { |
| + // We can wrap a rendertarget without its allocation, as long as we don't take ownership |
| + SkASSERT(info->fAlloc || kAdopted_LifeCycle != lifeCycle); |
|
bsalomon
2016/03/17 17:19:03
Seems ok to assert here but should the onWrap**()
jvanverth1
2016/03/18 14:30:00
Done.
|
| + |
| + GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTiling) |
| + ? Resource::kLinearTiling_Flag : Resource::kNo_Flags; |
| + |
| + const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fImage, |
| + info->fAlloc, |
| + flags); |
| + if (!imageResource) { |
| + return nullptr; |
| + } |
| - // Note: we assume the caller will unref the imageResource |
| - // Create() will increment the refCount, and we'll unref when we're done with it |
| - return GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageResource); |
| + GrVkRenderTarget* rt = GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageResource); |
| + // Create() will increment the refCount of the image resource if it succeeds |
| + imageResource->unref(gpu); |
| + return rt; |
| } |
| bool GrVkRenderTarget::completeStencilAttachment() { |