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, |
27 GLContextOptions
options) { | 28 GLContextOptions
options) { |
28 for (int i = 0; i < fContexts.count(); ++i) { | 29 for (int i = 0; i < fContexts.count(); ++i) { |
29 if (fContexts[i]->fType == type && | 30 if (fContexts[i]->fType == type && |
30 fContexts[i]->fOptions == options) { | 31 fContexts[i]->fOptions == options && |
| 32 (forcedGpuAPI == kNone_GrGLStandard || |
| 33 forcedGpuAPI == fContexts[i]->fGLContext->gl()->fStandard)) { |
31 fContexts[i]->fGLContext->makeCurrent(); | 34 fContexts[i]->fGLContext->makeCurrent(); |
32 return fContexts[i]; | 35 return fContexts[i]; |
33 } | 36 } |
34 } | 37 } |
35 SkAutoTUnref<SkGLContext> glCtx; | 38 SkAutoTUnref<SkGLContext> glCtx; |
36 SkAutoTUnref<GrContext> grCtx; | 39 SkAutoTUnref<GrContext> grCtx; |
37 switch (type) { | 40 switch (type) { |
38 case kNative_GLContextType: | 41 case kNative_GLContextType: |
39 glCtx.reset(SkCreatePlatformGLContext(kNone_GrGLStandard)); | 42 glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI)); |
40 break; | 43 break; |
41 case kGL_GLContextType: | 44 #ifdef SK_ANGLE |
42 glCtx.reset(SkCreatePlatformGLContext(kGL_GrGLStandard)); | 45 case kANGLE_GLContextType: |
| 46 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, false)); |
43 break; | 47 break; |
44 case kGLES_GLContextType: | 48 case kANGLE_GL_GLContextType: |
45 glCtx.reset(SkCreatePlatformGLContext(kGLES_GrGLStandard)); | 49 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, true)); |
46 break; | |
47 #if SK_ANGLE | |
48 #ifdef SK_BUILD_FOR_WIN | |
49 case kANGLE_GLContextType: | |
50 glCtx.reset(SkANGLEGLContext::CreateDirectX()); | |
51 break; | 50 break; |
52 #endif | 51 #endif |
53 case kANGLE_GL_GLContextType: | 52 #ifdef SK_COMMAND_BUFFER |
54 glCtx.reset(SkANGLEGLContext::CreateOpenGL()); | 53 case kCommandBuffer_GLContextType: |
| 54 glCtx.reset(SkCommandBufferGLContext::Create(forcedGpuAPI)); |
55 break; | 55 break; |
56 #endif | 56 #endif |
57 #if SK_COMMAND_BUFFER | 57 #ifdef SK_MESA |
58 case kCommandBuffer_GLContextType: | |
59 glCtx.reset(SkCommandBufferGLContext::Create()); | |
60 break; | |
61 #endif | |
62 #if SK_MESA | |
63 case kMESA_GLContextType: | 58 case kMESA_GLContextType: |
64 glCtx.reset(SkMesaGLContext::Create()); | 59 glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI)); |
65 break; | 60 break; |
66 #endif | 61 #endif |
67 case kNull_GLContextType: | 62 case kNull_GLContextType: |
68 glCtx.reset(SkNullGLContext::Create()); | 63 glCtx.reset(SkNullGLContext::Create(forcedGpuAPI)); |
69 break; | 64 break; |
70 case kDebug_GLContextType: | 65 case kDebug_GLContextType: |
71 glCtx.reset(SkDebugGLContext::Create()); | 66 glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI)); |
72 break; | 67 break; |
73 } | 68 } |
74 if (nullptr == glCtx.get()) { | 69 if (nullptr == glCtx.get()) { |
75 return nullptr; | 70 return nullptr; |
76 } | 71 } |
77 | 72 |
78 SkASSERT(glCtx->isValid()); | 73 SkASSERT(glCtx->isValid()); |
79 | 74 |
80 // Block NVPR from non-NVPR types. | 75 // Block NVPR from non-NVPR types. |
81 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); | 76 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); |
(...skipping 20 matching lines...) Expand all Loading... |
102 } | 97 } |
103 } | 98 } |
104 | 99 |
105 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); | 100 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); |
106 ctx->fGLContext = SkRef(glCtx.get()); | 101 ctx->fGLContext = SkRef(glCtx.get()); |
107 ctx->fGrContext = SkRef(grCtx.get()); | 102 ctx->fGrContext = SkRef(grCtx.get()); |
108 ctx->fType = type; | 103 ctx->fType = type; |
109 ctx->fOptions = options; | 104 ctx->fOptions = options; |
110 return ctx; | 105 return ctx; |
111 } | 106 } |
OLD | NEW |