Fiddle can use EGL if available.
To test this turn on egl, e.g. --args='skia_use_egl=true', and run by altering the
library path to point to the right directory of the EGL driver you want to use, for example:
LD_LIBRARY_PATH=/usr/lib/nvidia-367/ ./out/Release/fiddle | ./tools/fiddle/parse-fiddle-output
Bug: skia:
Change-Id: I2cce80318925fe88f9407646acb67628a8e48810
Reviewed-on: https://skia-review.googlesource.com/18137
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/tools/fiddle/mesa_context.cpp b/tools/fiddle/mesa_context.cpp
new file mode 100644
index 0000000..70ee62b
--- /dev/null
+++ b/tools/fiddle/mesa_context.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "fiddle_main.h"
+
+#include <GL/osmesa.h>
+
+// create_grcontext implementation for Mesa.
+sk_sp<GrContext> create_grcontext() {
+ // We just leak the OSMesaContext... the process will die soon anyway.
+ if (OSMesaContext osMesaContext = OSMesaCreateContextExt(OSMESA_BGRA, 0, 0, 0, nullptr)) {
+ static uint32_t buffer[16 * 16];
+ OSMesaMakeCurrent(osMesaContext, &buffer, GL_UNSIGNED_BYTE, 16, 16);
+ }
+
+ 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())));
+}