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

Unified Diff: tools/fiddle/fiddle_main.cpp

Issue 2184133002: GN: fixes for Mac (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix linux Created 4 years, 5 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
« BUILD.gn ('K') | « third_party/libpng/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/fiddle/fiddle_main.cpp
diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp
index f6270daaa59ae3935a4e095ed53742ff01a3d854..1c80c4416c64bd69d56e422173c83772724b76d2 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;
« BUILD.gn ('K') | « third_party/libpng/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698