| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 #endif | 81 #endif |
| 82 case kNVPR_GLContextType: | 82 case kNVPR_GLContextType: |
| 83 return "nvpr"; | 83 return "nvpr"; |
| 84 case kDebug_GLContextType: | 84 case kDebug_GLContextType: |
| 85 return "debug"; | 85 return "debug"; |
| 86 default: | 86 default: |
| 87 SkFAIL("Unknown GL Context type."); | 87 SkFAIL("Unknown GL Context type."); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 explicit GrContextFactory(const GrContext::Options& opts) : fGlobalOptions(o
pts) { } |
| 91 GrContextFactory() { } | 92 GrContextFactory() { } |
| 92 | 93 |
| 93 ~GrContextFactory() { this->destroyContexts(); } | 94 ~GrContextFactory() { this->destroyContexts(); } |
| 94 | 95 |
| 95 void destroyContexts() { | 96 void destroyContexts() { |
| 96 for (int i = 0; i < fContexts.count(); ++i) { | 97 for (int i = 0; i < fContexts.count(); ++i) { |
| 97 if (NULL != fContexts[i].fGLContext) { // could be abandoned. | 98 if (NULL != fContexts[i].fGLContext) { // could be abandoned. |
| 98 fContexts[i].fGLContext->makeCurrent(); | 99 fContexts[i].fGLContext->makeCurrent(); |
| 99 } | 100 } |
| 100 fContexts[i].fGrContext->unref(); | 101 fContexts[i].fGrContext->unref(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 170 } |
| 170 } else { | 171 } else { |
| 171 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); | 172 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); |
| 172 if (!glInterface) { | 173 if (!glInterface) { |
| 173 return NULL; | 174 return NULL; |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 | 177 |
| 177 glCtx->makeCurrent(); | 178 glCtx->makeCurrent(); |
| 178 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface
.get()); | 179 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface
.get()); |
| 179 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx)); | 180 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, &fGlobalOptions
)); |
| 180 if (!grCtx.get()) { | 181 if (!grCtx.get()) { |
| 181 return NULL; | 182 return NULL; |
| 182 } | 183 } |
| 183 GPUContext& ctx = fContexts.push_back(); | 184 GPUContext& ctx = fContexts.push_back(); |
| 184 ctx.fGLContext = glCtx.get(); | 185 ctx.fGLContext = glCtx.get(); |
| 185 ctx.fGLContext->ref(); | 186 ctx.fGLContext->ref(); |
| 186 ctx.fGrContext = grCtx.get(); | 187 ctx.fGrContext = grCtx.get(); |
| 187 ctx.fGrContext->ref(); | 188 ctx.fGrContext->ref(); |
| 188 ctx.fType = type; | 189 ctx.fType = type; |
| 189 return ctx.fGrContext; | 190 return ctx.fGrContext; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 200 | 201 |
| 201 return NULL; | 202 return NULL; |
| 202 } | 203 } |
| 203 | 204 |
| 204 private: | 205 private: |
| 205 struct GPUContext { | 206 struct GPUContext { |
| 206 GLContextType fType; | 207 GLContextType fType; |
| 207 SkGLContextHelper* fGLContext; | 208 SkGLContextHelper* fGLContext; |
| 208 GrContext* fGrContext; | 209 GrContext* fGrContext; |
| 209 }; | 210 }; |
| 210 SkTArray<GPUContext, true> fContexts; | 211 SkTArray<GPUContext, true> fContexts; |
| 212 const GrContext::Options fGlobalOptions; |
| 211 }; | 213 }; |
| 212 | 214 |
| 213 #endif | 215 #endif |
| OLD | NEW |