• 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 // must be before GrGLConfig.h
13 #if GR_WIN32_BUILD
14 //    #include "GrGpuD3D9.h"
15 #endif
16 
17 #include "gl/GrGLConfig.h"
18 
19 #include "GrGpu.h"
20 #include "gl/GrGpuGLShaders.h"
21 
Create(GrEngine engine,GrPlatform3DContext context3D)22 GrGpu* GrGpu::Create(GrEngine engine, GrPlatform3DContext context3D) {
23 
24     const GrGLInterface* glInterface = NULL;
25     SkAutoTUnref<const GrGLInterface> glInterfaceUnref;
26 
27     if (kOpenGL_Shaders_GrEngine == engine) {
28         glInterface = reinterpret_cast<const GrGLInterface*>(context3D);
29         if (NULL == glInterface) {
30             glInterface = GrGLDefaultInterface();
31             // By calling GrGLDefaultInterface we've taken a ref on the
32             // returned object. We only want to hold that ref until after
33             // the GrGpu is constructed and has taken ownership.
34             glInterfaceUnref.reset(glInterface);
35         }
36         if (NULL == glInterface) {
37 #if GR_DEBUG
38             GrPrintf("No GL interface provided!\n");
39 #endif
40             return NULL;
41         }
42         GrGLContextInfo ctxInfo(glInterface);
43         if (ctxInfo.isInitialized()) {
44             return new GrGpuGLShaders(ctxInfo);
45         }
46     }
47     return NULL;
48 }
49