diff --git a/engine/src/flutter/vulkan/vulkan_window.cc b/engine/src/flutter/vulkan/vulkan_window.cc index 4b9be79513..e54bb0aa95 100644 --- a/engine/src/flutter/vulkan/vulkan_window.cc +++ b/engine/src/flutter/vulkan/vulkan_window.cc @@ -97,9 +97,9 @@ GrContext* VulkanWindow::GetSkiaGrContext() { } bool VulkanWindow::CreateSkiaGrContext() { - auto backend_context = CreateSkiaBackendContext(); + GrVkBackendContext backend_context; - if (backend_context == nullptr) { + if (!CreateSkiaBackendContext(&backend_context)) { return false; } @@ -111,25 +111,23 @@ bool VulkanWindow::CreateSkiaGrContext() { context->setResourceCacheLimits(kGrCacheMaxCount, kGrCacheMaxByteSize); - skia_vk_backend_context_ = backend_context; skia_gr_context_ = context; return true; } -sk_sp VulkanWindow::CreateSkiaBackendContext() { +bool VulkanWindow::CreateSkiaBackendContext(GrVkBackendContext* context) { auto interface = vk->CreateSkiaInterface(); if (interface == nullptr || !interface->validate(0)) { - return nullptr; + return false; } uint32_t skia_features = 0; if (!logical_device_->GetPhysicalDeviceFeaturesSkia(&skia_features)) { - return nullptr; + return false; } - auto context = sk_make_sp(); context->fInstance = application_->GetInstance(); context->fPhysicalDevice = logical_device_->GetPhysicalDeviceHandle(); context->fDevice = logical_device_->GetHandle(); @@ -142,7 +140,7 @@ sk_sp VulkanWindow::CreateSkiaBackendContext() { context->fFeatures = skia_features; context->fInterface.reset(interface.release()); context->fOwnsInstanceAndDevice = false; - return context; + return true; } sk_sp VulkanWindow::AcquireSurface() { diff --git a/engine/src/flutter/vulkan/vulkan_window.h b/engine/src/flutter/vulkan/vulkan_window.h index 891589e5a4..55de23f2f7 100644 --- a/engine/src/flutter/vulkan/vulkan_window.h +++ b/engine/src/flutter/vulkan/vulkan_window.h @@ -47,9 +47,6 @@ class VulkanWindow { private: bool valid_; fxl::RefPtr vk; - // Note: The order of objects here is important because the - // GrVkBackendContext assumes ownership of the device and instance handles. - sk_sp skia_vk_backend_context_; std::unique_ptr application_; std::unique_ptr logical_device_; std::unique_ptr surface_; @@ -58,7 +55,7 @@ class VulkanWindow { bool CreateSkiaGrContext(); - sk_sp CreateSkiaBackendContext(); + bool CreateSkiaBackendContext(GrVkBackendContext* context); FXL_WARN_UNUSED_RESULT bool RecreateSwapchain();