| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrContextFactory.h" | 9 #include "GrContextFactory.h" |
| 10 | 10 |
| 11 #if SK_ANGLE | 11 #if SK_ANGLE |
| 12 #include "gl/angle/SkANGLEGLContext.h" | 12 #include "gl/angle/SkANGLEGLContext.h" |
| 13 #endif | 13 #endif |
| 14 #if SK_COMMAND_BUFFER | 14 #if SK_COMMAND_BUFFER |
| 15 #include "gl/command_buffer/SkCommandBufferGLContext.h" | 15 #include "gl/command_buffer/SkCommandBufferGLContext.h" |
| 16 #endif | 16 #endif |
| 17 #include "gl/debug/SkDebugGLContext.h" | 17 #include "gl/debug/SkDebugGLContext.h" |
| 18 #if SK_MESA | 18 #if SK_MESA |
| 19 #include "gl/mesa/SkMesaGLContext.h" | 19 #include "gl/mesa/SkMesaGLContext.h" |
| 20 #endif | 20 #endif |
| 21 #include "gl/SkGLContext.h" | 21 #include "gl/SkGLContext.h" |
| 22 #include "gl/SkNullGLContext.h" | 22 #include "gl/SkNullGLContext.h" |
| 23 #include "gl/GrGLGpu.h" | 23 #include "gl/GrGLGpu.h" |
| 24 #include "GrCaps.h" | 24 #include "GrCaps.h" |
| 25 | 25 |
| 26 GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType ty
pe, | 26 GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType ty
pe, |
| 27 GrGLStandard for
cedGpuAPI, | |
| 28 GLContextOptions
options) { | 27 GLContextOptions
options) { |
| 29 for (int i = 0; i < fContexts.count(); ++i) { | 28 for (int i = 0; i < fContexts.count(); ++i) { |
| 30 if (fContexts[i]->fType == type && | 29 if (fContexts[i]->fType == type && |
| 31 fContexts[i]->fOptions == options && | 30 fContexts[i]->fOptions == options) { |
| 32 (forcedGpuAPI == kNone_GrGLStandard || | |
| 33 forcedGpuAPI == fContexts[i]->fGLContext->gl()->fStandard)) { | |
| 34 fContexts[i]->fGLContext->makeCurrent(); | 31 fContexts[i]->fGLContext->makeCurrent(); |
| 35 return fContexts[i]; | 32 return fContexts[i]; |
| 36 } | 33 } |
| 37 } | 34 } |
| 38 | 35 |
| 39 SkAutoTUnref<SkGLContext> glCtx; | 36 SkAutoTUnref<SkGLContext> glCtx; |
| 40 SkAutoTUnref<GrContext> grCtx; | 37 SkAutoTUnref<GrContext> grCtx; |
| 41 switch (type) { | 38 switch (type) { |
| 42 case kNative_GLContextType: | 39 case kNative_GLContextType: |
| 43 glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI)); | 40 glCtx.reset(SkCreatePlatformGLContext(kNone_GrGLStandard)); |
| 41 break; |
| 42 case kGL_GLContextType: |
| 43 glCtx.reset(SkCreatePlatformGLContext(kGL_GrGLStandard)); |
| 44 break; |
| 45 case kGLES_GLContextType: |
| 46 glCtx.reset(SkCreatePlatformGLContext(kGLES_GrGLStandard)); |
| 44 break; | 47 break; |
| 45 #ifdef SK_ANGLE | 48 #ifdef SK_ANGLE |
| 46 case kANGLE_GLContextType: | 49 case kANGLE_GLContextType: |
| 47 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, false)); | 50 glCtx.reset(SkANGLEGLContext::Create(false)); |
| 48 break; | 51 break; |
| 49 case kANGLE_GL_GLContextType: | 52 case kANGLE_GL_GLContextType: |
| 50 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, true)); | 53 glCtx.reset(SkANGLEGLContext::Create(true)); |
| 51 break; | 54 break; |
| 52 #endif | 55 #endif |
| 53 #ifdef SK_COMMAND_BUFFER | 56 #ifdef SK_COMMAND_BUFFER |
| 54 case kCommandBuffer_GLContextType: | 57 case kCommandBuffer_GLContextType: |
| 55 glCtx.reset(SkCommandBufferGLContext::Create(forcedGpuAPI)); | 58 glCtx.reset(SkCommandBufferGLContext::Create()); |
| 56 break; | 59 break; |
| 57 #endif | 60 #endif |
| 58 #ifdef SK_MESA | 61 #ifdef SK_MESA |
| 59 case kMESA_GLContextType: | 62 case kMESA_GLContextType: |
| 60 glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI)); | 63 glCtx.reset(SkMesaGLContext::Create()); |
| 61 break; | 64 break; |
| 62 #endif | 65 #endif |
| 63 case kNull_GLContextType: | 66 case kNull_GLContextType: |
| 64 glCtx.reset(SkNullGLContext::Create(forcedGpuAPI)); | 67 glCtx.reset(SkNullGLContext::Create()); |
| 65 break; | 68 break; |
| 66 case kDebug_GLContextType: | 69 case kDebug_GLContextType: |
| 67 glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI)); | 70 glCtx.reset(SkDebugGLContext::Create()); |
| 68 break; | 71 break; |
| 69 } | 72 } |
| 70 if (nullptr == glCtx.get()) { | 73 if (nullptr == glCtx.get()) { |
| 71 return nullptr; | 74 return nullptr; |
| 72 } | 75 } |
| 73 | 76 |
| 74 SkASSERT(glCtx->isValid()); | 77 SkASSERT(glCtx->isValid()); |
| 75 | 78 |
| 76 // Block NVPR from non-NVPR types. | 79 // Block NVPR from non-NVPR types. |
| 77 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); | 80 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 99 } | 102 } |
| 100 } | 103 } |
| 101 | 104 |
| 102 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); | 105 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); |
| 103 ctx->fGLContext = SkRef(glCtx.get()); | 106 ctx->fGLContext = SkRef(glCtx.get()); |
| 104 ctx->fGrContext = SkRef(grCtx.get()); | 107 ctx->fGrContext = SkRef(grCtx.get()); |
| 105 ctx->fType = type; | 108 ctx->fType = type; |
| 106 ctx->fOptions = options; | 109 ctx->fOptions = options; |
| 107 return ctx; | 110 return ctx; |
| 108 } | 111 } |
| OLD | NEW |