reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 8 | |
egdaniel | 384181c | 2015-03-26 09:09:41 -0700 | [diff] [blame] | 9 | #include "GrGpuFactory.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #include "GrGpu.h" |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 12 | #include "gl/GrGLConfig.h" |
jvanverth | 39edf76 | 2014-12-22 11:44:19 -0800 | [diff] [blame] | 13 | #include "gl/GrGLGpu.h" |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 14 | #ifdef SK_VULKAN |
| 15 | #include "vk/GrVkGpu.h" |
| 16 | #endif |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 17 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 18 | static CreateGpuProc gGpuFactories[kBackendCount] = { GrGLGpu::Create, nullptr }; |
jvanverth | a50e17a | 2015-08-12 12:19:36 -0700 | [diff] [blame] | 19 | |
| 20 | #ifdef SK_VULKAN |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 21 | GrGpuFactoryRegistrar gVkGpuFactoryProc(kVulkan_GrBackend, GrVkGpu::Create); |
jvanverth | a50e17a | 2015-08-12 12:19:36 -0700 | [diff] [blame] | 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 | } |