blob: 3001a0d41aa001df664adc4174477a5be6da546f [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
egdaniel384181c2015-03-26 09:09:41 -070016static const int kMaxNumBackends = 4;
bsalomon424cc262015-05-22 10:37:30 -070017static CreateGpuProc gGpuFactories[kMaxNumBackends] = {GrGLGpu::Create, NULL, NULL, NULL};
egdaniel384181c2015-03-26 09:09:41 -070018
19GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) {
20 gGpuFactories[i] = proc;
21}
22
bsalomonf28cff72015-05-22 12:25:41 -070023GrGpu* GrGpu::Create(GrBackend backend,
24 GrBackendContext backendContext,
25 const GrContextOptions& options,
26 GrContext* context) {
egdaniel384181c2015-03-26 09:09:41 -070027 SkASSERT((int)backend < kMaxNumBackends);
28 if (!gGpuFactories[backend]) {
29 return NULL;
30 }
bsalomonf28cff72015-05-22 12:25:41 -070031 return (gGpuFactories[backend])(backendContext, options, context);
egdaniel384181c2015-03-26 09:09:41 -070032}