aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpuFactory.cpp
blob: bd572e6860ae96948e6a626d06e435d988305c6b (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

/*
 * 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"

static const int kMaxNumBackends = 4;
static CreateGpuProc gGpuFactories[kMaxNumBackends] = {GrGLGpu::Create, NULL, NULL, NULL};

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

GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrContext* context) {
    SkASSERT((int)backend < kMaxNumBackends);
    if (!gGpuFactories[backend]) {
        return NULL;
    }
    return (gGpuFactories[backend])(backendContext, context);
}