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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI)); | 48 glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI)); |
49 break; | 49 break; |
50 #endif | 50 #endif |
51 case kNull_GLContextType: | 51 case kNull_GLContextType: |
52 glCtx.reset(SkNullGLContext::Create(forcedGpuAPI)); | 52 glCtx.reset(SkNullGLContext::Create(forcedGpuAPI)); |
53 break; | 53 break; |
54 case kDebug_GLContextType: | 54 case kDebug_GLContextType: |
55 glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI)); | 55 glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI)); |
56 break; | 56 break; |
57 } | 57 } |
58 if (NULL == glCtx.get()) { | 58 if (nullptr == glCtx.get()) { |
59 return NULL; | 59 return nullptr; |
60 } | 60 } |
61 | 61 |
62 SkASSERT(glCtx->isValid()); | 62 SkASSERT(glCtx->isValid()); |
63 | 63 |
64 // Block NVPR from non-NVPR types. | 64 // Block NVPR from non-NVPR types. |
65 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); | 65 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); |
66 if (kNVPR_GLContextType != type) { | 66 if (kNVPR_GLContextType != type) { |
67 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); | 67 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); |
68 if (!glInterface) { | 68 if (!glInterface) { |
69 return NULL; | 69 return nullptr; |
70 } | 70 } |
71 } else { | 71 } else { |
72 if (!glInterface->hasExtension("GL_NV_path_rendering")) { | 72 if (!glInterface->hasExtension("GL_NV_path_rendering")) { |
73 return NULL; | 73 return nullptr; |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 glCtx->makeCurrent(); | 77 glCtx->makeCurrent(); |
78 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get
()); | 78 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get
()); |
79 #ifdef SK_VULKAN | 79 #ifdef SK_VULKAN |
80 grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions)); | 80 grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions)); |
81 #else | 81 #else |
82 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions)); | 82 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions)); |
83 #endif | 83 #endif |
84 if (!grCtx.get()) { | 84 if (!grCtx.get()) { |
85 return NULL; | 85 return nullptr; |
86 } | 86 } |
87 // Warn if path rendering support is not available for the NVPR type. | 87 // Warn if path rendering support is not available for the NVPR type. |
88 if (kNVPR_GLContextType == type) { | 88 if (kNVPR_GLContextType == type) { |
89 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { | 89 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { |
90 GrGpu* gpu = grCtx->getGpu(); | 90 GrGpu* gpu = grCtx->getGpu(); |
91 const GrGLContext* ctx = gpu->glContextForTesting(); | 91 const GrGLContext* ctx = gpu->glContextForTesting(); |
92 if (ctx) { | 92 if (ctx) { |
93 const GrGLubyte* verUByte; | 93 const GrGLubyte* verUByte; |
94 GR_GL_CALL_RET(ctx->interface(), verUByte, GetString(GR_GL_VERSI
ON)); | 94 GR_GL_CALL_RET(ctx->interface(), verUByte, GetString(GR_GL_VERSI
ON)); |
95 const char* ver = reinterpret_cast<const char*>(verUByte); | 95 const char* ver = reinterpret_cast<const char*>(verUByte); |
96 SkDebugf("\nWARNING: nvprmsaa config requested, but driver path
rendering " | 96 SkDebugf("\nWARNING: nvprmsaa config requested, but driver path
rendering " |
97 "support not available. Maybe update the driver? Your d
river version " | 97 "support not available. Maybe update the driver? Your d
river version " |
98 "string: \"%s\"\n", ver); | 98 "string: \"%s\"\n", ver); |
99 } else { | 99 } else { |
100 SkDebugf("\nWARNING: nvprmsaa config requested, but driver path
rendering " | 100 SkDebugf("\nWARNING: nvprmsaa config requested, but driver path
rendering " |
101 "support not available.\n"); | 101 "support not available.\n"); |
102 } | 102 } |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 GPUContext& ctx = fContexts.push_back(); | 106 GPUContext& ctx = fContexts.push_back(); |
107 ctx.fGLContext = glCtx.get(); | 107 ctx.fGLContext = glCtx.get(); |
108 ctx.fGLContext->ref(); | 108 ctx.fGLContext->ref(); |
109 ctx.fGrContext = grCtx.get(); | 109 ctx.fGrContext = grCtx.get(); |
110 ctx.fGrContext->ref(); | 110 ctx.fGrContext->ref(); |
111 ctx.fType = type; | 111 ctx.fType = type; |
112 return ctx.fGrContext; | 112 return ctx.fGrContext; |
113 } | 113 } |
OLD | NEW |