From 7d10b9f6e61ce8cb5387291580c1c0645f72b167 Mon Sep 17 00:00:00 2001 From: mtklein Date: Wed, 27 Jul 2016 11:17:18 -0700 Subject: GN: fixes for Mac - Make fiddle build on Mac (skipping GL). - Now that we're building in SkCodec, we depend on libpng and libjpeg-turbo unconditionally, not just on Linux. - Re-arrange third_party a bit so that our targets are Fuchsia/Chrome compatible. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2184133002 NOTREECHECKS=true This doesn't affect Chrome/Blink, so landing through the closed tree. Review-Url: https://codereview.chromium.org/2184133002 --- tools/fiddle/fiddle_main.cpp | 58 +++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) (limited to 'tools/fiddle') diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp index f6270daaa5..1c80c4416c 100644 --- a/tools/fiddle/fiddle_main.cpp +++ b/tools/fiddle/fiddle_main.cpp @@ -8,8 +8,6 @@ #include #include -#include - #include "fiddle_main.h" // Globals externed in fiddle_main.h @@ -63,33 +61,31 @@ static SkData* encode_snapshot(const sk_sp& surface) { return img ? img->encode() : nullptr; } -static OSMesaContext create_osmesa_context() { - OSMesaContext osMesaContext = - OSMesaCreateContextExt(OSMESA_BGRA, 0, 0, 0, nullptr); - if (osMesaContext != nullptr) { - static uint32_t buffer[16 * 16]; - OSMesaMakeCurrent(osMesaContext, &buffer, GL_UNSIGNED_BYTE, 16, 16); - } - return osMesaContext; -} +#if defined(__linux) + #include + static sk_sp 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); + } -static sk_sp 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 mesa(GrGLAssembleInterface(nullptr, osmesa_get)); - if (!mesa) { - return nullptr; + auto osmesa_get = [](void* ctx, const char name[]) { + SkASSERT(nullptr == ctx); + SkASSERT(OSMesaGetCurrentContext()); + return OSMesaGetProcAddress(name); + }; + sk_sp mesa(GrGLAssembleInterface(nullptr, osmesa_get)); + if (!mesa) { + return nullptr; + } + return sk_sp(GrContext::Create( + kOpenGL_GrBackend, + reinterpret_cast(mesa.get()))); } - return sk_sp(GrContext::Create( - kOpenGL_GrBackend, - reinterpret_cast(mesa.get()))); -} +#else + static sk_sp create_grcontext() { return nullptr; } +#endif int main() { const DrawOptions options = GetDrawOptions(); @@ -117,10 +113,9 @@ int main() { rasterData.reset(encode_snapshot(rasterSurface)); } if (options.gpu) { - OSMesaContext osMesaContext = create_osmesa_context(); - auto grContext = create_mesa_grcontext(); + auto grContext = create_grcontext(); if (!grContext) { - fputs("Unable to get Mesa GrContext.\n", stderr); + fputs("Unable to get GrContext.\n", stderr); } else { auto surface = SkSurface::MakeRenderTarget( grContext.get(), @@ -134,9 +129,6 @@ int main() { draw(surface->getCanvas()); gpuData.reset(encode_snapshot(surface)); } - if (osMesaContext) { - OSMesaDestroyContext(osMesaContext); - } } if (options.pdf) { SkDynamicMemoryWStream pdfStream; -- cgit v1.2.3