blob: eb024f7a2ce4ef5c045bc5b01f3a93f94a2c1cbb [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
reed@google.comac10a2d2010-12-22 21:39:39 +000017#include "GrTypes.h"
18
19// must be before GrGLConfig.h
20#if GR_WIN32_BUILD
21// #include "GrGpuD3D9.h"
22#endif
23
24#include "GrGLConfig.h"
25
reed@google.comac10a2d2010-12-22 21:39:39 +000026#include "GrGpu.h"
junov@google.comf93e7172011-03-31 21:26:24 +000027#include "GrGpuGLFixed.h"
28#include "GrGpuGLShaders.h"
29#include "GrGpuGLShaders2.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000030
31GrGpu* GrGpu::Create(Engine engine, Platform3DContext context3D) {
twiz@google.com59a190b2011-03-14 21:23:01 +000032 // If no GL bindings have been installed, fall-back to calling the
33 // GL functions that have been linked with the executable.
34 if (!GrGLGetGLInterface())
35 GrGLSetDefaultGLInterface();
36
reed@google.comac10a2d2010-12-22 21:39:39 +000037 GrGpu* gpu = NULL;
38
39 switch (engine) {
40 case kOpenGL_Shaders_Engine:
41 GrAssert(NULL == context3D);
junov@google.comf93e7172011-03-31 21:26:24 +000042 {
43#if GR_USE_NEW_GLSHADERS
44 gpu = new GrGpuGLShaders;
45#else
46 gpu = new GrGpuGLShaders2;
47#endif
48 }
reed@google.comac10a2d2010-12-22 21:39:39 +000049 break;
50 case kOpenGL_Fixed_Engine:
51 GrAssert(NULL == context3D);
reed@google.comac10a2d2010-12-22 21:39:39 +000052 gpu = new GrGpuGLFixed;
reed@google.comac10a2d2010-12-22 21:39:39 +000053 break;
54 case kDirect3D9_Engine:
55 GrAssert(NULL != context3D);
56#if GR_WIN32_BUILD
57// gpu = new GrGpuD3D9((IDirect3DDevice9*)context3D);
58#endif
59 break;
60 default:
61 GrAssert(!"unknown engine");
62 break;
63 }
64
65 return gpu;
66}