Skip to content

Commit

Permalink
Nosksp backend context (flutter#5544)
Browse files Browse the repository at this point in the history
* Use new vulkan factory of GrContext which doens't take an sk_sp.

* remove unneeded member.
  • Loading branch information
egdaniel authored and brianosman committed Jun 15, 2018
1 parent 6afe4c8 commit 0ecd42a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
14 changes: 6 additions & 8 deletions vulkan/vulkan_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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<GrVkBackendContext> 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<GrVkBackendContext>();
context->fInstance = application_->GetInstance();
context->fPhysicalDevice = logical_device_->GetPhysicalDeviceHandle();
context->fDevice = logical_device_->GetHandle();
Expand All @@ -142,7 +140,7 @@ sk_sp<GrVkBackendContext> VulkanWindow::CreateSkiaBackendContext() {
context->fFeatures = skia_features;
context->fInterface.reset(interface.release());
context->fOwnsInstanceAndDevice = false;
return context;
return true;
}

sk_sp<SkSurface> VulkanWindow::AcquireSurface() {
Expand Down
5 changes: 1 addition & 4 deletions vulkan/vulkan_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class VulkanWindow {
private:
bool valid_;
fxl::RefPtr<VulkanProcTable> vk;
// Note: The order of objects here is important because the
// GrVkBackendContext assumes ownership of the device and instance handles.
sk_sp<GrVkBackendContext> skia_vk_backend_context_;
std::unique_ptr<VulkanApplication> application_;
std::unique_ptr<VulkanDevice> logical_device_;
std::unique_ptr<VulkanSurface> surface_;
Expand All @@ -58,7 +55,7 @@ class VulkanWindow {

bool CreateSkiaGrContext();

sk_sp<GrVkBackendContext> CreateSkiaBackendContext();
bool CreateSkiaBackendContext(GrVkBackendContext* context);

FXL_WARN_UNUSED_RESULT
bool RecreateSwapchain();
Expand Down

0 comments on commit 0ecd42a

Please sign in to comment.