Line data Source code
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 :
24 0 : GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) {
25 0 : gGpuFactories[i] = proc;
26 0 : }
27 :
28 0 : GrGpu* GrGpu::Create(GrBackend backend,
29 : GrBackendContext backendContext,
30 : const GrContextOptions& options,
31 : GrContext* context) {
32 0 : SkASSERT((int)backend < kBackendCount);
33 0 : if (!gGpuFactories[backend]) {
34 0 : return nullptr;
35 : }
36 0 : return (gGpuFactories[backend])(backendContext, options, context);
37 : }
|