blob: 7c2db2b0b116d75ae8f0521343bf1f9130c41f13 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
twiz@google.com59a190b2011-03-14 21:23:01 +00002 Copyright 2011 Google Inc.
reed@google.comac10a2d2010-12-22 21:39:39 +00003
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#include "GrTypes.h"
19
20// must be before GrGLConfig.h
21#if GR_WIN32_BUILD
22// #include "GrGpuD3D9.h"
23#endif
24
25#include "GrGLConfig.h"
26
reed@google.comac10a2d2010-12-22 21:39:39 +000027
28#if GR_SUPPORT_GLES1 || GR_SUPPORT_GLDESKTOP
29 #include "GrGpuGLFixed.h"
30#endif
31
32#if GR_SUPPORT_GLES2 || GR_SUPPORT_GLDESKTOP
bsalomon@google.comc6cf7232011-02-17 16:43:10 +000033 #include "GrGpuGLShaders2.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000034#endif
35
36#include "GrGpu.h"
37
38GrGpu* GrGpu::Create(Engine engine, Platform3DContext context3D) {
twiz@google.com59a190b2011-03-14 21:23:01 +000039 // If no GL bindings have been installed, fall-back to calling the
40 // GL functions that have been linked with the executable.
41 if (!GrGLGetGLInterface())
42 GrGLSetDefaultGLInterface();
43
reed@google.comac10a2d2010-12-22 21:39:39 +000044 GrGpu* gpu = NULL;
45
46 switch (engine) {
47 case kOpenGL_Shaders_Engine:
48 GrAssert(NULL == context3D);
49#if GR_SUPPORT_GLES2 || GR_SUPPORT_GLDESKTOP
reed@google.comac10a2d2010-12-22 21:39:39 +000050 gpu = new GrGpuGLShaders2;
reed@google.comac10a2d2010-12-22 21:39:39 +000051#endif
52 break;
53 case kOpenGL_Fixed_Engine:
54 GrAssert(NULL == context3D);
55#if GR_SUPPORT_GLES1 || GR_SUPPORT_GLDESKTOP
56 gpu = new GrGpuGLFixed;
57#endif
58 break;
59 case kDirect3D9_Engine:
60 GrAssert(NULL != context3D);
61#if GR_WIN32_BUILD
62// gpu = new GrGpuD3D9((IDirect3DDevice9*)context3D);
63#endif
64 break;
65 default:
66 GrAssert(!"unknown engine");
67 break;
68 }
69
70 return gpu;
71}
72
73
74