2017-05-31 13:45:19 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
2017-06-01 17:24:11 +00:00
|
|
|
sk_sp<GrContext> create_grcontext(std::ostringstream &driverinfo) {
|
2017-05-31 13:45:19 +00:00
|
|
|
// 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);
|
|
|
|
}
|
2017-06-01 17:24:11 +00:00
|
|
|
driverinfo << "Mesa";
|
2017-05-31 13:45:19 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2017-07-25 14:05:01 +00:00
|
|
|
return GrContext::MakeGL(mesa.get());
|
2017-05-31 13:45:19 +00:00
|
|
|
}
|