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 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 SkASSERT(glCtx->isValid()); | 74 SkASSERT(glCtx->isValid()); |
75 | 75 |
76 // Block NVPR from non-NVPR types. | 76 // Block NVPR from non-NVPR types. |
77 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); | 77 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); |
78 if (kNVPR_GLContextType != type) { | 78 if (kNVPR_GLContextType != type) { |
79 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); | 79 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); |
80 if (!glInterface) { | 80 if (!glInterface) { |
81 return nullptr; | 81 return nullptr; |
82 } | 82 } |
83 } else { | |
84 if (!glInterface->hasExtension("GL_NV_path_rendering")) { | |
85 return nullptr; | |
86 } | |
87 } | 83 } |
88 | 84 |
89 glCtx->makeCurrent(); | 85 glCtx->makeCurrent(); |
90 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get
()); | 86 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get
()); |
91 #ifdef SK_VULKAN | 87 #ifdef SK_VULKAN |
92 grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions)); | 88 grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions)); |
93 #else | 89 #else |
94 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions)); | 90 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions)); |
95 #endif | 91 #endif |
96 if (!grCtx.get()) { | 92 if (!grCtx.get()) { |
97 return nullptr; | 93 return nullptr; |
98 } | 94 } |
99 // Warn if path rendering support is not available for the NVPR type. | |
100 if (kNVPR_GLContextType == type) { | 95 if (kNVPR_GLContextType == type) { |
101 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { | 96 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { |
102 GrGpu* gpu = grCtx->getGpu(); | 97 return nullptr; |
103 const GrGLContext* ctx = gpu->glContextForTesting(); | |
104 if (ctx) { | |
105 const GrGLubyte* verUByte; | |
106 GR_GL_CALL_RET(ctx->interface(), verUByte, GetString(GR_GL_VERSI
ON)); | |
107 const char* ver = reinterpret_cast<const char*>(verUByte); | |
108 SkDebugf("\nWARNING: nvprmsaa config requested, but driver path
rendering " | |
109 "support not available. Maybe update the driver? Your d
river version " | |
110 "string: \"%s\"\n", ver); | |
111 } else { | |
112 SkDebugf("\nWARNING: nvprmsaa config requested, but driver path
rendering " | |
113 "support not available.\n"); | |
114 } | |
115 } | 98 } |
116 } | 99 } |
117 | 100 |
118 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); | 101 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); |
119 ctx->fGLContext = SkRef(glCtx.get()); | 102 ctx->fGLContext = SkRef(glCtx.get()); |
120 ctx->fGrContext = SkRef(grCtx.get()); | 103 ctx->fGrContext = SkRef(grCtx.get()); |
121 ctx->fType = type; | 104 ctx->fType = type; |
122 return ctx; | 105 return ctx; |
123 } | 106 } |
OLD | NEW |