blob: c6134b65a2e383a84c44ee1a3ba1cac771ea1160 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * 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.
reed@google.comac10a2d2010-12-22 21:39:39 +00006 */
7
epoger@google.comec3ed6a2011-07-28 14:26:00 +00008
egdaniel384181c2015-03-26 09:09:41 -07009#include "GrGpuFactory.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#include "GrGpu.h"
bsalomon424cc262015-05-22 10:37:30 -070012#include "gl/GrGLConfig.h"
jvanverth39edf762014-12-22 11:44:19 -080013#include "gl/GrGLGpu.h"
jvanverth633b3562016-03-23 11:01:22 -070014#ifdef SK_VULKAN
15#include "vk/GrVkGpu.h"
16#endif
reed@google.comac10a2d2010-12-22 21:39:39 +000017
halcanary96fcdcc2015-08-27 07:41:13 -070018static CreateGpuProc gGpuFactories[kBackendCount] = { GrGLGpu::Create, nullptr };
jvanvertha50e17a2015-08-12 12:19:36 -070019
20#ifdef SK_VULKAN
jvanverth633b3562016-03-23 11:01:22 -070021GrGpuFactoryRegistrar gVkGpuFactoryProc(kVulkan_GrBackend, GrVkGpu::Create);
jvanvertha50e17a2015-08-12 12:19:36 -070022#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}