Index: src/gpu/vk/GrVkRenderTarget.cpp |
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp |
index ee45aa30e87cf44fe4a918cca779f83ef3c94de8..7ff7f26d42e929afd1911c3dd96a17b739f08ef0 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,29 @@ GrVkRenderTarget* |
GrVkRenderTarget::CreateWrappedRenderTarget(GrVkGpu* gpu, |
const GrSurfaceDesc& desc, |
GrGpuResource::LifeCycle lifeCycle, |
- const GrVkImage::Resource* imageResource) { |
- SkASSERT(imageResource); |
+ const GrVkTextureInfo* 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 || kAdopted_LifeCycle != lifeCycle); |
+ |
+ 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); |
+ if (rt) { |
+ rt->fCurrentLayout = info->fImageLayout; |
+ } |
+ // Create() will increment the refCount of the image resource if it succeeds |
+ imageResource->unref(gpu); |
+ return rt; |
} |
bool GrVkRenderTarget::completeStencilAttachment() { |