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 |
| 49 #if SK_BUILD_FOR_WIN |
46 case kANGLE_GLContextType: | 50 case kANGLE_GLContextType: |
47 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, false)); | 51 glCtx.reset(SkANGLEGLContext::CreateDirectX()); |
48 break; | 52 break; |
| 53 #endif |
49 case kANGLE_GL_GLContextType: | 54 case kANGLE_GL_GLContextType: |
50 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, true)); | 55 glCtx.reset(SkANGLEGLContext::CreateOpenGL()); |
51 break; | 56 break; |
52 #endif | 57 #endif |
53 #ifdef SK_COMMAND_BUFFER | 58 #ifdef SK_COMMAND_BUFFER |
54 case kCommandBuffer_GLContextType: | 59 case kCommandBuffer_GLContextType: |
55 glCtx.reset(SkCommandBufferGLContext::Create(forcedGpuAPI)); | 60 glCtx.reset(SkCommandBufferGLContext::Create()); |
56 break; | 61 break; |
57 #endif | 62 #endif |
58 #ifdef SK_MESA | 63 #ifdef SK_MESA |
59 case kMESA_GLContextType: | 64 case kMESA_GLContextType: |
60 glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI)); | 65 glCtx.reset(SkMesaGLContext::Create()); |
61 break; | 66 break; |
62 #endif | 67 #endif |
63 case kNull_GLContextType: | 68 case kNull_GLContextType: |
64 glCtx.reset(SkNullGLContext::Create(forcedGpuAPI)); | 69 glCtx.reset(SkNullGLContext::Create()); |
65 break; | 70 break; |
66 case kDebug_GLContextType: | 71 case kDebug_GLContextType: |
67 glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI)); | 72 glCtx.reset(SkDebugGLContext::Create()); |
68 break; | 73 break; |
69 } | 74 } |
70 if (nullptr == glCtx.get()) { | 75 if (nullptr == glCtx.get()) { |
71 return nullptr; | 76 return nullptr; |
72 } | 77 } |
73 | 78 |
74 SkASSERT(glCtx->isValid()); | 79 SkASSERT(glCtx->isValid()); |
75 | 80 |
76 // Block NVPR from non-NVPR types. | 81 // Block NVPR from non-NVPR types. |
77 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); | 82 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); |
(...skipping 21 matching lines...) Expand all Loading... |
99 } | 104 } |
100 } | 105 } |
101 | 106 |
102 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); | 107 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); |
103 ctx->fGLContext = SkRef(glCtx.get()); | 108 ctx->fGLContext = SkRef(glCtx.get()); |
104 ctx->fGrContext = SkRef(grCtx.get()); | 109 ctx->fGrContext = SkRef(grCtx.get()); |
105 ctx->fType = type; | 110 ctx->fType = type; |
106 ctx->fOptions = options; | 111 ctx->fOptions = options; |
107 return ctx; | 112 return ctx; |
108 } | 113 } |
OLD | NEW |