blob: f769ce4c578c187cb6ad94c436218a1470f58327 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
egdaniel384181c2015-03-26 09:09:41 -070010#include "GrGpuFactory.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000011
reed@google.comac10a2d2010-12-22 21:39:39 +000012#include "GrGpu.h"
bsalomon424cc262015-05-22 10:37:30 -070013#include "gl/GrGLConfig.h"
jvanverth39edf762014-12-22 11:44:19 -080014#include "gl/GrGLGpu.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015
halcanary96fcdcc2015-08-27 07:41:13 -070016static CreateGpuProc gGpuFactories[kBackendCount] = { GrGLGpu::Create, nullptr };
jvanvertha50e17a2015-08-12 12:19:36 -070017
18#ifdef SK_VULKAN
19extern GrGpu* vk_gpu_create(GrBackendContext backendContext, const GrContextOptions& options,
20 GrContext* context);
21GrGpuFactoryRegistrar gVkGpuFactoryProc(kVulkan_GrBackend, vk_gpu_create);
22#endif
egdaniel384181c2015-03-26 09:09:41 -070023
24GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) {
25 gGpuFactories[i] = proc;
26}
27
bsalomon682c2692015-05-22 14:01:46 -070028GrGpu* GrGpu::Create(GrBackend backend,
29 GrBackendContext backendContext,
30 const GrContextOptions& options,
31 GrContext* context) {
jvanvertha50e17a2015-08-12 12:19:36 -070032 SkASSERT((int)backend < kBackendCount);
egdaniel384181c2015-03-26 09:09:41 -070033 if (!gGpuFactories[backend]) {
halcanary96fcdcc2015-08-27 07:41:13 -070034 return nullptr;
egdaniel384181c2015-03-26 09:09:41 -070035 }
bsalomon682c2692015-05-22 14:01:46 -070036 return (gGpuFactories[backend])(backendContext, options, context);
egdaniel384181c2015-03-26 09:09:41 -070037}