OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrContextFactory_DEFINED | 8 #ifndef GrContextFactory_DEFINED |
9 #define GrContextFactory_DEFINED | 9 #define GrContextFactory_DEFINED |
10 | 10 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if (fContexts[i].fType == type) { | 128 if (fContexts[i].fType == type) { |
129 fContexts[i].fGLContext->makeCurrent(); | 129 fContexts[i].fGLContext->makeCurrent(); |
130 return fContexts[i].fGrContext; | 130 return fContexts[i].fGrContext; |
131 } | 131 } |
132 } | 132 } |
133 SkAutoTUnref<SkGLContext> glCtx; | 133 SkAutoTUnref<SkGLContext> glCtx; |
134 SkAutoTUnref<GrContext> grCtx; | 134 SkAutoTUnref<GrContext> grCtx; |
135 switch (type) { | 135 switch (type) { |
136 case kNVPR_GLContextType: // fallthru | 136 case kNVPR_GLContextType: // fallthru |
137 case kNative_GLContextType: | 137 case kNative_GLContextType: |
138 glCtx.reset(SkCreatePlatformGLContext()); | 138 glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI)); |
139 break; | 139 break; |
140 #ifdef SK_ANGLE | 140 #ifdef SK_ANGLE |
141 case kANGLE_GLContextType: | 141 case kANGLE_GLContextType: |
142 glCtx.reset(SkNEW(SkANGLEGLContext)); | 142 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI)); |
143 break; | 143 break; |
144 #endif | 144 #endif |
145 #ifdef SK_MESA | 145 #ifdef SK_MESA |
146 case kMESA_GLContextType: | 146 case kMESA_GLContextType: |
147 glCtx.reset(SkNEW(SkMesaGLContext)); | 147 glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI)); |
148 break; | 148 break; |
149 #endif | 149 #endif |
150 case kNull_GLContextType: | 150 case kNull_GLContextType: |
151 glCtx.reset(SkNEW(SkNullGLContext)); | 151 glCtx.reset(SkNullGLContext::Create(forcedGpuAPI)); |
152 break; | 152 break; |
153 case kDebug_GLContextType: | 153 case kDebug_GLContextType: |
154 glCtx.reset(SkNEW(SkDebugGLContext)); | 154 glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI)); |
155 break; | 155 break; |
156 } | 156 } |
157 static const int kBogusSize = 1; | 157 if (NULL == glCtx.get()) { |
158 if (!glCtx.get()) { | |
159 return NULL; | |
160 } | |
161 if (!glCtx.get()->init(forcedGpuAPI, kBogusSize, kBogusSize)) { | |
162 return NULL; | 158 return NULL; |
163 } | 159 } |
164 | 160 |
| 161 SkASSERT(glCtx->isValid()); |
| 162 |
165 // Ensure NVPR is available for the NVPR type and block it from other ty
pes. | 163 // Ensure NVPR is available for the NVPR type and block it from other ty
pes. |
166 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx.get()->gl())); | 164 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); |
167 if (kNVPR_GLContextType == type) { | 165 if (kNVPR_GLContextType == type) { |
168 if (!glInterface->hasExtension("GL_NV_path_rendering")) { | 166 if (!glInterface->hasExtension("GL_NV_path_rendering")) { |
169 return NULL; | 167 return NULL; |
170 } | 168 } |
171 } else { | 169 } else { |
172 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); | 170 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); |
173 if (!glInterface) { | 171 if (!glInterface) { |
174 return NULL; | 172 return NULL; |
175 } | 173 } |
176 } | 174 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 struct GPUContext { | 206 struct GPUContext { |
209 GLContextType fType; | 207 GLContextType fType; |
210 SkGLContext* fGLContext; | 208 SkGLContext* fGLContext; |
211 GrContext* fGrContext; | 209 GrContext* fGrContext; |
212 }; | 210 }; |
213 SkTArray<GPUContext, true> fContexts; | 211 SkTArray<GPUContext, true> fContexts; |
214 const GrContext::Options fGlobalOptions; | 212 const GrContext::Options fGlobalOptions; |
215 }; | 213 }; |
216 | 214 |
217 #endif | 215 #endif |
OLD | NEW |