aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/fiddle
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-07-27 11:17:18 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-27 11:17:18 -0700
commit7d10b9f6e61ce8cb5387291580c1c0645f72b167 (patch)
tree10cdd355da6ee075e5ec317c680879eb6177c07a /tools/fiddle
parentac0e00dceca10dc7ce30c5be66001bd6960ebf5c (diff)
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
Diffstat (limited to 'tools/fiddle')
-rw-r--r--tools/fiddle/fiddle_main.cpp58
1 files changed, 25 insertions, 33 deletions
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 <stdio.h>
#include <stdlib.h>
-#include <GL/osmesa.h>
-
#include "fiddle_main.h"
// Globals externed in fiddle_main.h
@@ -63,33 +61,31 @@ static SkData* encode_snapshot(const sk_sp<SkSurface>& 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 <GL/osmesa.h>
+ static 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);
+ }
-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;
+ 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())));
}
- return sk_sp<GrContext>(GrContext::Create(
- kOpenGL_GrBackend,
- reinterpret_cast<intptr_t>(mesa.get())));
-}
+#else
+ static sk_sp<GrContext> 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;