Add support for a new GPU interface

Review URL: https://codereview.chromium.org/1290813002
This commit is contained in:
jvanverth 2015-08-12 12:19:36 -07:00 committed by Commit bot
parent 082e329887
commit a50e17a391
3 changed files with 16 additions and 3 deletions

View File

@ -126,7 +126,11 @@ static inline int GrNextPow2(int n) {
*/
enum GrBackend {
kOpenGL_GrBackend,
kVulkan_GrBackend,
kLast_GrBackend = kVulkan_GrBackend
};
const int kBackendCount = kLast_GrBackend + 1;
/**
* Backend-specific 3D context handle

View File

@ -76,7 +76,11 @@ GrContext* GrContextFactory::get(GLContextType type, GrGLStandard forcedGpuAPI)
glCtx->makeCurrent();
GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
#ifdef SK_VULKAN
grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions));
#else
grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions));
#endif
if (!grCtx.get()) {
return NULL;
}

View File

@ -13,8 +13,13 @@
#include "gl/GrGLConfig.h"
#include "gl/GrGLGpu.h"
static const int kMaxNumBackends = 4;
static CreateGpuProc gGpuFactories[kMaxNumBackends] = {GrGLGpu::Create, NULL, NULL, NULL};
static CreateGpuProc gGpuFactories[kBackendCount] = { GrGLGpu::Create, NULL };
#ifdef SK_VULKAN
extern GrGpu* vk_gpu_create(GrBackendContext backendContext, const GrContextOptions& options,
GrContext* context);
GrGpuFactoryRegistrar gVkGpuFactoryProc(kVulkan_GrBackend, vk_gpu_create);
#endif
GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) {
gGpuFactories[i] = proc;
@ -24,7 +29,7 @@ GrGpu* GrGpu::Create(GrBackend backend,
GrBackendContext backendContext,
const GrContextOptions& options,
GrContext* context) {
SkASSERT((int)backend < kMaxNumBackends);
SkASSERT((int)backend < kBackendCount);
if (!gGpuFactories[backend]) {
return NULL;
}