Index: tools/viewer/sk_app/VulkanWindowContext.cpp |
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp |
index 2570e826a387c873afa3529bc95bb968814a4173..cee9ec73a6d6087c597de57c68ebcd0c515fcd9b 100644 |
--- a/tools/viewer/sk_app/VulkanWindowContext.cpp |
+++ b/tools/viewer/sk_app/VulkanWindowContext.cpp |
@@ -25,8 +25,12 @@ |
namespace sk_app { |
VulkanWindowContext::VulkanWindowContext(void* platformData, const DisplayParams& params) |
- : fSurface(VK_NULL_HANDLE) |
+ : WindowContext() |
+ , fSurface(VK_NULL_HANDLE) |
, fSwapchain(VK_NULL_HANDLE) |
+ , fImages(nullptr) |
+ , fImageLayouts(nullptr) |
+ , fSurfaces(nullptr) |
, fCommandPool(VK_NULL_HANDLE) |
, fBackbuffers(nullptr) { |
@@ -269,6 +273,7 @@ void VulkanWindowContext::createBuffers(VkFormat format) { |
desc.fSampleCnt = 0; |
desc.fStencilBits = 0; |
desc.fRenderTargetHandle = (GrBackendObject) &info; |
+ // TODO: base this on fSurfaceProps |
SkSurfaceProps props(GrPixelConfigIsSRGB(fPixelConfig) |
? SkSurfaceProps::kGammaCorrect_Flag : 0, |
kUnknown_SkPixelGeometry); |
@@ -398,7 +403,8 @@ void VulkanWindowContext::destroyContext() { |
fSurface = VK_NULL_HANDLE; |
} |
- delete fContext; |
+ fContext->abandonContext(); |
+ fContext->unref(); |
fBackendContext.reset(nullptr); |
} |
@@ -419,7 +425,7 @@ VulkanWindowContext::BackbufferInfo* VulkanWindowContext::getAvailableBackbuffer |
return backbuffer; |
} |
-SkSurface* VulkanWindowContext::getBackbufferSurface() { |
+sk_sp<SkSurface> VulkanWindowContext::getBackbufferSurface() { |
BackbufferInfo* backbuffer = this->getAvailableBackbuffer(); |
SkASSERT(backbuffer); |
@@ -510,10 +516,9 @@ SkSurface* VulkanWindowContext::getBackbufferSurface() { |
QueueSubmit(fBackendContext->fQueue, 1, &submitInfo, |
backbuffer->fUsageFences[0])); |
- return fSurfaces[backbuffer->fImageIndex].get(); |
+ return sk_ref_sp(fSurfaces[backbuffer->fImageIndex].get()); |
} |
- |
void VulkanWindowContext::swapBuffers() { |
BackbufferInfo* backbuffer = fBackbuffers + fCurrentBackbufferIndex; |