1 /* 2 * Copyright 2023 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "include/gpu/ganesh/vk/GrVkDirectContext.h" 9 10 #include "include/gpu/ganesh/GrContextOptions.h" 11 #include "include/gpu/ganesh/GrContextThreadSafeProxy.h" 12 #include "include/gpu/ganesh/GrDirectContext.h" 13 #include "include/gpu/ganesh/GrTypes.h" 14 #include "src/gpu/ganesh/GrDirectContextPriv.h" 15 #include "src/gpu/ganesh/vk/GrVkContextThreadSafeProxy.h" 16 #include "src/gpu/ganesh/vk/GrVkGpu.h" 17 18 namespace GrDirectContexts { MakeVulkan(const skgpu::VulkanBackendContext & backendContext)19sk_sp<GrDirectContext> MakeVulkan(const skgpu::VulkanBackendContext& backendContext) { 20 GrContextOptions defaultOptions; 21 return MakeVulkan(backendContext, defaultOptions); 22 } 23 MakeVulkan(const skgpu::VulkanBackendContext & backendContext,const GrContextOptions & options)24sk_sp<GrDirectContext> MakeVulkan(const skgpu::VulkanBackendContext& backendContext, 25 const GrContextOptions& options) { 26 auto direct = GrDirectContextPriv::Make( 27 GrBackendApi::kVulkan, options, sk_make_sp<GrVkContextThreadSafeProxy>(options)); 28 29 GrDirectContextPriv::SetGpu(direct, 30 GrVkGpu::Make(backendContext, options, direct.get())); 31 if (!GrDirectContextPriv::Init(direct)) { 32 return nullptr; 33 } 34 35 return direct; 36 } 37 } // namespace GrDirectContexts 38