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 #include "gl/GLTestContext.h" | 10 #include "gl/GLTestContext.h" |
11 | 11 |
12 #if SK_ANGLE | 12 #if SK_ANGLE |
13 #include "gl/angle/GLTestContext_angle.h" | 13 #include "gl/angle/GLTestContext_angle.h" |
14 #endif | 14 #endif |
15 #if SK_COMMAND_BUFFER | 15 #if SK_COMMAND_BUFFER |
16 #include "gl/command_buffer/GLTestContext_command_buffer.h" | 16 #include "gl/command_buffer/GLTestContext_command_buffer.h" |
17 #endif | 17 #endif |
18 #include "gl/debug/DebugGLTestContext.h" | 18 #include "gl/debug/DebugGLTestContext.h" |
19 #if SK_MESA | 19 #if SK_MESA |
20 #include "gl/mesa/GLTestContext_mesa.h" | 20 #include "gl/mesa/GLTestContext_mesa.h" |
21 #endif | 21 #endif |
| 22 #if SK_VULKAN |
| 23 #include "vk/GrVkBackendContext.h" |
| 24 #endif |
22 #include "gl/null/NullGLTestContext.h" | 25 #include "gl/null/NullGLTestContext.h" |
23 #include "gl/GrGLGpu.h" | 26 #include "gl/GrGLGpu.h" |
24 #include "GrCaps.h" | 27 #include "GrCaps.h" |
25 | 28 |
26 namespace sk_gpu_test { | 29 namespace sk_gpu_test { |
27 GrContextFactory::GrContextFactory() { } | 30 GrContextFactory::GrContextFactory() { } |
28 | 31 |
29 GrContextFactory::GrContextFactory(const GrContextOptions& opts) | 32 GrContextFactory::GrContextFactory(const GrContextOptions& opts) |
30 : fGlobalOptions(opts) { | 33 : fGlobalOptions(opts) { |
31 } | 34 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Block NVPR from non-NVPR types. | 124 // Block NVPR from non-NVPR types. |
122 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); | 125 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); |
123 if (!(kEnableNVPR_GLContextOptions & options)) { | 126 if (!(kEnableNVPR_GLContextOptions & options)) { |
124 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); | 127 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); |
125 if (!glInterface) { | 128 if (!glInterface) { |
126 return ContextInfo(); | 129 return ContextInfo(); |
127 } | 130 } |
128 } | 131 } |
129 | 132 |
130 glCtx->makeCurrent(); | 133 glCtx->makeCurrent(); |
131 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get
()); | |
132 #ifdef SK_VULKAN | 134 #ifdef SK_VULKAN |
133 if (kEnableNVPR_GLContextOptions & options) { | 135 if (kEnableNVPR_GLContextOptions & options) { |
134 return ContextInfo(); | 136 return ContextInfo(); |
135 } else { | 137 } else { |
| 138 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(GrVkBackend
Context::Create()); |
136 grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions)
); | 139 grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions)
); |
137 } | 140 } |
138 #else | 141 #else |
| 142 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get
()); |
139 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions)); | 143 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions)); |
140 #endif | 144 #endif |
141 if (!grCtx.get()) { | 145 if (!grCtx.get()) { |
142 return ContextInfo(); | 146 return ContextInfo(); |
143 } | 147 } |
144 if (kEnableNVPR_GLContextOptions & options) { | 148 if (kEnableNVPR_GLContextOptions & options) { |
145 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { | 149 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { |
146 return ContextInfo(); | 150 return ContextInfo(); |
147 } | 151 } |
148 } | 152 } |
149 if (kRequireSRGBSupport_GLContextOptions & options) { | 153 if (kRequireSRGBSupport_GLContextOptions & options) { |
150 if (!grCtx->caps()->srgbSupport()) { | 154 if (!grCtx->caps()->srgbSupport()) { |
151 return ContextInfo(); | 155 return ContextInfo(); |
152 } | 156 } |
153 } | 157 } |
154 | 158 |
155 Context& context = fContexts.push_back(); | 159 Context& context = fContexts.push_back(); |
156 context.fGLContext = glCtx.release(); | 160 context.fGLContext = glCtx.release(); |
157 context.fGrContext = SkRef(grCtx.get()); | 161 context.fGrContext = SkRef(grCtx.get()); |
158 context.fType = type; | 162 context.fType = type; |
159 context.fOptions = options; | 163 context.fOptions = options; |
160 return ContextInfo(context.fGrContext, context.fGLContext); | 164 return ContextInfo(context.fGrContext, context.fGLContext); |
161 } | 165 } |
162 } // namespace sk_gpu_test | 166 } // namespace sk_gpu_test |
OLD | NEW |