Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Unified Diff: experimental/fiddle/fiddle_main.cpp

Issue 1849753003: Fiddle: update to new const GrGLAssembleInterface API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/fiddle/fiddle_main.cpp
diff --git a/experimental/fiddle/fiddle_main.cpp b/experimental/fiddle/fiddle_main.cpp
index c5561c0c6fd271ca4f894045183eb0ecc6688571..51c956842b34ab953ded8e0b8cb4ef4476157c0f 100644
--- a/experimental/fiddle/fiddle_main.cpp
+++ b/experimental/fiddle/fiddle_main.cpp
@@ -72,13 +72,24 @@ static OSMesaContext create_osmesa_context() {
return osMesaContext;
}
-static GrContext* create_mesa_grcontext() {
- sk_sp<const GrGLInterface> mesa(GrGLCreateMesaInterface());
- intptr_t backend = reinterpret_cast<intptr_t>(mesa.get());
- return backend ? GrContext::Create(kOpenGL_GrBackend, backend) : nullptr;
+static sk_sp<GrContext> create_mesa_grcontext() {
+ if (nullptr == OSMesaGetCurrentContext()) {
+ return nullptr;
+ }
+ auto osmesa_get = [](void* ctx, const char name[]) {
+ SkASSERT(nullptr == ctx);
+ SkASSERT(OSMesaGetCurrentContext());
+ return OSMesaGetProcAddress(name);
+ };
+ sk_sp<const GrGLInterface> mesa(GrGLAssembleInterface(nullptr, osmesa_get));
+ if (!mesa) {
+ return nullptr;
+ }
+ return sk_sp<GrContext>(GrContext::Create(
+ kOpenGL_GrBackend,
+ reinterpret_cast<intptr_t>(mesa.get())));
}
-
int main() {
const DrawOptions options = GetDrawOptions();
if (options.source) {
@@ -105,7 +116,7 @@ int main() {
}
if (options.gpu) {
OSMesaContext osMesaContext = create_osmesa_context();
- sk_sp<GrContext> grContext(create_mesa_grcontext());
+ auto grContext = create_mesa_grcontext();
if (!grContext) {
fputs("Unable to get Mesa GrContext.\n", stderr);
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698