• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
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.
7  */
8 
9 
10 #include "GrTypes.h"
11 
12 #include "gl/GrGLConfig.h"
13 
14 #include "GrGpu.h"
15 #include "gl/GrGpuGL.h"
16 
Create(GrBackend backend,GrBackendContext context)17 GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext context) {
18 
19     const GrGLInterface* glInterface = NULL;
20     SkAutoTUnref<const GrGLInterface> glInterfaceUnref;
21 
22     if (kOpenGL_GrBackend == backend) {
23         glInterface = reinterpret_cast<const GrGLInterface*>(context);
24         if (NULL == glInterface) {
25             glInterface = GrGLDefaultInterface();
26             // By calling GrGLDefaultInterface we've taken a ref on the
27             // returned object. We only want to hold that ref until after
28             // the GrGpu is constructed and has taken ownership.
29             glInterfaceUnref.reset(glInterface);
30         }
31         if (NULL == glInterface) {
32 #if GR_DEBUG
33             GrPrintf("No GL interface provided!\n");
34 #endif
35             return NULL;
36         }
37         GrGLContextInfo ctxInfo(glInterface);
38         if (ctxInfo.isInitialized()) {
39             return SkNEW_ARGS(GrGpuGL, (ctxInfo));
40         }
41     }
42     return NULL;
43 }
44