Plumb the use of GrBackendRenderTarget throughout Skia
Bug: skia:
Change-Id: Ib99a58d9552f5c7b8d77c09dcc72fa88326c26aa
Reviewed-on: https://skia-review.googlesource.com/14148
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index be5b0c7..1eec506 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -815,32 +815,36 @@
return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, ownership, info);
}
-sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc){
+sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
+ GrSurfaceOrigin origin){
// Currently the Vulkan backend does not support wrapping of msaa render targets directly. In
// general this is not an issue since swapchain images in vulkan are never multisampled. Thus if
// you want a multisampled RT it is best to wrap the swapchain images and then let Skia handle
// creating and owning the MSAA images.
- if (wrapDesc.fSampleCnt) {
+ if (backendRT.sampleCnt()) {
return nullptr;
}
- const GrVkImageInfo* info =
- reinterpret_cast<const GrVkImageInfo*>(wrapDesc.fRenderTargetHandle);
+ const GrVkImageInfo* info = backendRT.getVkImageInfo();
+ if (!info) {
+ return nullptr;
+ }
if (VK_NULL_HANDLE == info->fImage) {
return nullptr;
}
GrSurfaceDesc desc;
- desc.fConfig = wrapDesc.fConfig;
+ desc.fConfig = backendRT.config();
desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag;
- desc.fWidth = wrapDesc.fWidth;
- desc.fHeight = wrapDesc.fHeight;
+ desc.fWidth = backendRT.width();
+ desc.fHeight = backendRT.height();
desc.fSampleCnt = 0;
- desc.fOrigin = resolve_origin(wrapDesc.fOrigin);
+ SkASSERT(kDefault_GrSurfaceOrigin != origin);
+ desc.fOrigin = origin;
sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(this, desc, info);
- if (tgt && wrapDesc.fStencilBits) {
+ if (tgt && backendRT.stencilBits()) {
if (!createStencilAttachmentForRenderTarget(tgt.get(), desc.fWidth, desc.fHeight)) {
return nullptr;
}
@@ -853,6 +857,9 @@
int sampleCnt) {
const GrVkImageInfo* info = tex.getVkImageInfo();
+ if (!info) {
+ return nullptr;
+ }
if (VK_NULL_HANDLE == info->fImage) {
return nullptr;
}