Chromium Code Reviews| Index: src/gpu/GrGpuFactory.cpp |
| diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp |
| index 4b09c14e5182ae9e299c073403f5835b3537cec1..9dd9e5eb4244c9a69eee0403a1ca0d99b2e5624f 100644 |
| --- a/src/gpu/GrGpuFactory.cpp |
| +++ b/src/gpu/GrGpuFactory.cpp |
| @@ -7,37 +7,44 @@ |
| */ |
| -#include "GrTypes.h" |
| +#include "GrGpuFactory.h" |
| #include "gl/GrGLConfig.h" |
| #include "GrGpu.h" |
| #include "gl/GrGLGpu.h" |
| -GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrContext* context) { |
| - |
| +static GrGpu* GLGpuCreate(GrBackendContext backendContext, GrContext* context) { |
|
bsalomon
2015/03/25 14:11:54
gl_cpu_create (static_functions_use_hacker_naming)
egdaniel
2015/03/25 16:17:17
Done.
|
| const GrGLInterface* glInterface = NULL; |
| SkAutoTUnref<const GrGLInterface> glInterfaceUnref; |
| - if (kOpenGL_GrBackend == backend) { |
| - glInterface = reinterpret_cast<const GrGLInterface*>(backendContext); |
| - if (NULL == glInterface) { |
| - glInterface = GrGLDefaultInterface(); |
| - // By calling GrGLDefaultInterface we've taken a ref on the |
| - // returned object. We only want to hold that ref until after |
| - // the GrGpu is constructed and has taken ownership. |
| - glInterfaceUnref.reset(glInterface); |
| - } |
| - if (NULL == glInterface) { |
| + glInterface = reinterpret_cast<const GrGLInterface*>(backendContext); |
| + if (NULL == glInterface) { |
| + glInterface = GrGLDefaultInterface(); |
| + // By calling GrGLDefaultInterface we've taken a ref on the |
| + // returned object. We only want to hold that ref until after |
| + // the GrGpu is constructed and has taken ownership. |
| + glInterfaceUnref.reset(glInterface); |
| + } |
| + if (NULL == glInterface) { |
| #ifdef SK_DEBUG |
| - SkDebugf("No GL interface provided!\n"); |
| + SkDebugf("No GL interface provided!\n"); |
| #endif |
| - return NULL; |
| - } |
| - GrGLContext ctx(glInterface); |
| - if (ctx.isInitialized()) { |
| - return SkNEW_ARGS(GrGLGpu, (ctx, context)); |
| - } |
| + return NULL; |
| + } |
| + GrGLContext ctx(glInterface); |
| + if (ctx.isInitialized()) { |
| + return SkNEW_ARGS(GrGLGpu, (ctx, context)); |
| } |
| return NULL; |
| } |
| + |
| +static CreateGpuProc gGpuFactories[4] = {GLGpuCreate, NULL, NULL, NULL}; |
| + |
| +GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) { |
|
bsalomon
2015/03/25 14:11:54
Seems a bit weird to have a fixed sized array. Why
robertphillips
2015/03/25 16:01:02
I suggest we keep it simple for this go round and
egdaniel
2015/03/25 16:17:17
Agree with Rob on the simple approach for now. Als
|
| + gGpuFactories[i] = proc; |
| +} |
| + |
| +GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrContext* context) { |
|
robertphillips
2015/03/25 13:58:24
SkAssert(backend < kMaxNumBackends); ?
egdaniel
2015/03/25 16:17:17
Done.
|
| + return (gGpuFactories[backend])(backendContext, context); |
| +} |