Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: src/gpu/GrGpuFactory.cpp

Issue 1038643002: Add support for using alternative backends (like DirectX) when creating a GrGpu. (Closed) Base URL: https://chromium.googlesource.com/skia@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrGpuFactory.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrTypes.h" 10 #include "GrGpuFactory.h"
11 11
12 #include "gl/GrGLConfig.h" 12 #include "gl/GrGLConfig.h"
13 13
14 #include "GrGpu.h" 14 #include "GrGpu.h"
15 #include "gl/GrGLGpu.h" 15 #include "gl/GrGLGpu.h"
16 16
17 GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrConte xt* context) { 17 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.
18
19 const GrGLInterface* glInterface = NULL; 18 const GrGLInterface* glInterface = NULL;
20 SkAutoTUnref<const GrGLInterface> glInterfaceUnref; 19 SkAutoTUnref<const GrGLInterface> glInterfaceUnref;
21 20
22 if (kOpenGL_GrBackend == backend) { 21 glInterface = reinterpret_cast<const GrGLInterface*>(backendContext);
23 glInterface = reinterpret_cast<const GrGLInterface*>(backendContext); 22 if (NULL == glInterface) {
24 if (NULL == glInterface) { 23 glInterface = GrGLDefaultInterface();
25 glInterface = GrGLDefaultInterface(); 24 // By calling GrGLDefaultInterface we've taken a ref on the
26 // By calling GrGLDefaultInterface we've taken a ref on the 25 // returned object. We only want to hold that ref until after
27 // returned object. We only want to hold that ref until after 26 // the GrGpu is constructed and has taken ownership.
28 // the GrGpu is constructed and has taken ownership. 27 glInterfaceUnref.reset(glInterface);
29 glInterfaceUnref.reset(glInterface); 28 }
30 } 29 if (NULL == glInterface) {
31 if (NULL == glInterface) {
32 #ifdef SK_DEBUG 30 #ifdef SK_DEBUG
33 SkDebugf("No GL interface provided!\n"); 31 SkDebugf("No GL interface provided!\n");
34 #endif 32 #endif
35 return NULL; 33 return NULL;
36 } 34 }
37 GrGLContext ctx(glInterface); 35 GrGLContext ctx(glInterface);
38 if (ctx.isInitialized()) { 36 if (ctx.isInitialized()) {
39 return SkNEW_ARGS(GrGLGpu, (ctx, context)); 37 return SkNEW_ARGS(GrGLGpu, (ctx, context));
40 }
41 } 38 }
42 return NULL; 39 return NULL;
43 } 40 }
41
42 static CreateGpuProc gGpuFactories[4] = {GLGpuCreate, NULL, NULL, NULL};
43
44 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
45 gGpuFactories[i] = proc;
46 }
47
48 GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrConte xt* context) {
robertphillips 2015/03/25 13:58:24 SkAssert(backend < kMaxNumBackends); ?
egdaniel 2015/03/25 16:17:17 Done.
49 return (gGpuFactories[backend])(backendContext, context);
50 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpuFactory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698