epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
egdaniel | 384181c | 2015-03-26 09:09:41 -0700 | [diff] [blame] | 10 | #include "GrGpuFactory.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 12 | #include "GrGpu.h" |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 13 | #include "gl/GrGLConfig.h" |
jvanverth | 39edf76 | 2014-12-22 11:44:19 -0800 | [diff] [blame] | 14 | #include "gl/GrGLGpu.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 16 | static CreateGpuProc gGpuFactories[kBackendCount] = { GrGLGpu::Create, nullptr }; |
jvanverth | a50e17a | 2015-08-12 12:19:36 -0700 | [diff] [blame] | 17 | |
| 18 | #ifdef SK_VULKAN |
| 19 | extern GrGpu* vk_gpu_create(GrBackendContext backendContext, const GrContextOptions& options, |
| 20 | GrContext* context); |
| 21 | GrGpuFactoryRegistrar gVkGpuFactoryProc(kVulkan_GrBackend, vk_gpu_create); |
| 22 | #endif |
egdaniel | 384181c | 2015-03-26 09:09:41 -0700 | [diff] [blame] | 23 | |
| 24 | GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) { |
| 25 | gGpuFactories[i] = proc; |
| 26 | } |
| 27 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 28 | GrGpu* GrGpu::Create(GrBackend backend, |
| 29 | GrBackendContext backendContext, |
| 30 | const GrContextOptions& options, |
| 31 | GrContext* context) { |
jvanverth | a50e17a | 2015-08-12 12:19:36 -0700 | [diff] [blame] | 32 | SkASSERT((int)backend < kBackendCount); |
egdaniel | 384181c | 2015-03-26 09:09:41 -0700 | [diff] [blame] | 33 | if (!gGpuFactories[backend]) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 34 | return nullptr; |
egdaniel | 384181c | 2015-03-26 09:09:41 -0700 | [diff] [blame] | 35 | } |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 36 | return (gGpuFactories[backend])(backendContext, options, context); |
egdaniel | 384181c | 2015-03-26 09:09:41 -0700 | [diff] [blame] | 37 | } |