aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpuFactory.cpp
blob: c6134b65a2e383a84c44ee1a3ba1cac771ea1160 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#include "GrGpuFactory.h"

#include "GrGpu.h"
#include "gl/GrGLConfig.h"
#include "gl/GrGLGpu.h"
#ifdef SK_VULKAN
#include "vk/GrVkGpu.h"
#endif

static CreateGpuProc gGpuFactories[kBackendCount] = { GrGLGpu::Create, nullptr };

#ifdef SK_VULKAN
GrGpuFactoryRegistrar gVkGpuFactoryProc(kVulkan_GrBackend, GrVkGpu::Create);
#endif

GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) {
    gGpuFactories[i] = proc;
}

GrGpu* GrGpu::Create(GrBackend backend,
                     GrBackendContext backendContext,
                     const GrContextOptions& options,
                     GrContext* context) {
    SkASSERT((int)backend < kBackendCount);
    if (!gGpuFactories[backend]) {
        return nullptr;
    }
    return (gGpuFactories[backend])(backendContext, options, context);
}