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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #endif | 24 #endif |
25 #include "gl/null/NullGLTestContext.h" | 25 #include "gl/null/NullGLTestContext.h" |
26 #include "gl/GrGLGpu.h" | 26 #include "gl/GrGLGpu.h" |
27 #include "GrCaps.h" | 27 #include "GrCaps.h" |
28 | 28 |
29 namespace sk_gpu_test { | 29 namespace sk_gpu_test { |
30 GrContextFactory::GrContextFactory() { } | 30 GrContextFactory::GrContextFactory() { } |
31 | 31 |
32 GrContextFactory::GrContextFactory(const GrContextOptions& opts) | 32 GrContextFactory::GrContextFactory(const GrContextOptions& opts) |
33 : fGlobalOptions(opts) { | 33 : fGlobalOptions(opts) { |
| 34 // In this factory, instanced rendering is specified with kUseInstanced_Cont
extOptions. |
| 35 SkASSERT(!fGlobalOptions.fEnableInstancedRendering); |
34 } | 36 } |
35 | 37 |
36 GrContextFactory::~GrContextFactory() { | 38 GrContextFactory::~GrContextFactory() { |
37 this->destroyContexts(); | 39 this->destroyContexts(); |
38 } | 40 } |
39 | 41 |
40 void GrContextFactory::destroyContexts() { | 42 void GrContextFactory::destroyContexts() { |
41 for (Context& context : fContexts) { | 43 for (Context& context : fContexts) { |
42 if (context.fTestContext) { | 44 if (context.fTestContext) { |
43 context.fTestContext->makeCurrent(); | 45 context.fTestContext->makeCurrent(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 glCtx = CreateDebugGLTestContext(); | 145 glCtx = CreateDebugGLTestContext(); |
144 break; | 146 break; |
145 default: | 147 default: |
146 return ContextInfo(); | 148 return ContextInfo(); |
147 } | 149 } |
148 if (!glCtx) { | 150 if (!glCtx) { |
149 return ContextInfo(); | 151 return ContextInfo(); |
150 } | 152 } |
151 testCtx.reset(glCtx); | 153 testCtx.reset(glCtx); |
152 glInterface.reset(SkRef(glCtx->gl())); | 154 glInterface.reset(SkRef(glCtx->gl())); |
153 // Block NVPR from non-NVPR types. | 155 // Block NVPR from non-NVPR types. We don't block NVPR from contexts
that will use |
154 if (!(kEnableNVPR_ContextOptions & options)) { | 156 // instanced rendering because that would prevent us from testing mi
xed samples. |
| 157 if (!((kEnableNVPR_ContextOptions | kUseInstanced_ContextOptions) &
options)) { |
155 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface.get())); | 158 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface.get())); |
156 if (!glInterface) { | 159 if (!glInterface) { |
157 return ContextInfo(); | 160 return ContextInfo(); |
158 } | 161 } |
159 } | 162 } |
160 backendContext = reinterpret_cast<GrBackendContext>(glInterface.get(
)); | 163 backendContext = reinterpret_cast<GrBackendContext>(glInterface.get(
)); |
161 break; | 164 break; |
162 } | 165 } |
163 #ifdef SK_VULKAN | 166 #ifdef SK_VULKAN |
164 case kVulkan_GrBackend: | 167 case kVulkan_GrBackend: |
(...skipping 16 matching lines...) Expand all Loading... |
181 } | 184 } |
182 } | 185 } |
183 backendContext = testCtx->backendContext(); | 186 backendContext = testCtx->backendContext(); |
184 break; | 187 break; |
185 #endif | 188 #endif |
186 default: | 189 default: |
187 return ContextInfo(); | 190 return ContextInfo(); |
188 } | 191 } |
189 testCtx->makeCurrent(); | 192 testCtx->makeCurrent(); |
190 SkASSERT(testCtx && testCtx->backend() == backend); | 193 SkASSERT(testCtx && testCtx->backend() == backend); |
191 grCtx.reset(GrContext::Create(backend, backendContext, fGlobalOptions)); | 194 GrContextOptions grOptions = fGlobalOptions; |
| 195 if (kUseInstanced_ContextOptions & options) { |
| 196 grOptions.fEnableInstancedRendering = true; |
| 197 } |
| 198 grCtx.reset(GrContext::Create(backend, backendContext, grOptions)); |
192 if (!grCtx.get()) { | 199 if (!grCtx.get()) { |
193 return ContextInfo(); | 200 return ContextInfo(); |
194 } | 201 } |
195 if (kEnableNVPR_ContextOptions & options) { | 202 if (kEnableNVPR_ContextOptions & options) { |
196 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { | 203 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { |
197 return ContextInfo(); | 204 return ContextInfo(); |
198 } | 205 } |
199 } | 206 } |
| 207 if (kUseInstanced_ContextOptions & options) { |
| 208 if (GrCaps::InstancedSupport::kNone == grCtx->caps()->instancedSupport()
) { |
| 209 return ContextInfo(); |
| 210 } |
| 211 } |
200 if (kRequireSRGBSupport_ContextOptions & options) { | 212 if (kRequireSRGBSupport_ContextOptions & options) { |
201 if (!grCtx->caps()->srgbSupport()) { | 213 if (!grCtx->caps()->srgbSupport()) { |
202 return ContextInfo(); | 214 return ContextInfo(); |
203 } | 215 } |
204 } | 216 } |
205 | 217 |
206 Context& context = fContexts.push_back(); | 218 Context& context = fContexts.push_back(); |
207 context.fBackend = backend; | 219 context.fBackend = backend; |
208 context.fTestContext = testCtx.release(); | 220 context.fTestContext = testCtx.release(); |
209 context.fGrContext = SkRef(grCtx.get()); | 221 context.fGrContext = SkRef(grCtx.get()); |
210 context.fType = type; | 222 context.fType = type; |
211 context.fOptions = options; | 223 context.fOptions = options; |
212 context.fAbandoned = false; | 224 context.fAbandoned = false; |
213 return ContextInfo(context.fBackend, context.fTestContext, context.fGrContex
t); | 225 return ContextInfo(context.fBackend, context.fTestContext, context.fGrContex
t); |
214 } | 226 } |
215 } // namespace sk_gpu_test | 227 } // namespace sk_gpu_test |
OLD | NEW |