1 /*
2 * Copyright 2011 Google Inc.
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
9 #include "GrGpuFactory.h"
10
11 #include "GrGpu.h"
12 #include "gl/GrGLConfig.h"
13 #include "gl/GrGLGpu.h"
14 #ifdef SK_VULKAN
15 #include "vk/GrVkGpu.h"
16 #endif
17
18 static CreateGpuProc gGpuFactories[kBackendCount] = { GrGLGpu::Create, nullptr };
19
20 #ifdef SK_VULKAN
21 GrGpuFactoryRegistrar gVkGpuFactoryProc(kVulkan_GrBackend, GrVkGpu::Create);
22 #endif
23
GrGpuFactoryRegistrar(int i,CreateGpuProc proc)24 GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) {
25 gGpuFactories[i] = proc;
26 }
27
Create(GrBackend backend,GrBackendContext backendContext,const GrContextOptions & options,GrContext * context)28 GrGpu* GrGpu::Create(GrBackend backend,
29 GrBackendContext backendContext,
30 const GrContextOptions& options,
31 GrContext* context) {
32 SkASSERT((int)backend < kBackendCount);
33 if (!gGpuFactories[backend]) {
34 return nullptr;
35 }
36 return (gGpuFactories[backend])(backendContext, options, context);
37 }
38