From 31ce11c5931305c6a75a3cf126cd8d64871b014a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 4 Oct 2019 18:18:53 -0700 Subject: [PATCH] Make sure nanosvg functions are static so they aren't exported through the SDL_image static library --- IMG_svg.c | 1 + nanosvg.h | 18 +++++++++++------- nanosvgrast.h | 23 +++++++++++++++-------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/IMG_svg.c b/IMG_svg.c index 7f08f5a9..9edd3b9f 100644 --- a/IMG_svg.c +++ b/IMG_svg.c @@ -67,6 +67,7 @@ #endif #undef HAVE_STDIO_H +#define NSVG_EXPORT static #define NANOSVG_IMPLEMENTATION #include "nanosvg.h" #define NANOSVGRAST_IMPLEMENTATION diff --git a/nanosvg.h b/nanosvg.h index 8b2154be..be35c54d 100644 --- a/nanosvg.h +++ b/nanosvg.h @@ -29,6 +29,10 @@ #ifndef NANOSVG_H #define NANOSVG_H +#ifndef NSVG_EXPORT +#define NSVG_EXPORT +#endif + #ifdef __cplusplus extern "C" { #endif @@ -161,14 +165,14 @@ typedef struct NSVGimage } NSVGimage; // Parses SVG file from a file, returns SVG image as paths. -NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi); +NSVG_EXPORT NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi); // Parses SVG file from a null terminated string, returns SVG image as paths. // Important note: changes the string. -NSVGimage* nsvgParse(char* input, const char* units, float dpi); +NSVG_EXPORT NSVGimage* nsvgParse(char* input, const char* units, float dpi); // Deletes list of paths. -void nsvgDelete(NSVGimage* image); +NSVG_EXPORT void nsvgDelete(NSVGimage* image); #ifdef __cplusplus } @@ -1257,7 +1261,7 @@ typedef struct NSVGNamedColor { unsigned int color; } NSVGNamedColor; -NSVGNamedColor nsvg__colors[] = { +static NSVGNamedColor nsvg__colors[] = { { "red", NSVG_RGB(255, 0, 0) }, { "green", NSVG_RGB( 0, 128, 0) }, @@ -2961,7 +2965,7 @@ static void nsvg__scaleToViewbox(NSVGparser* p, const char* units) } } -NSVGimage* nsvgParse(char* input, const char* units, float dpi) +NSVG_EXPORT NSVGimage* nsvgParse(char* input, const char* units, float dpi) { NSVGparser* p; NSVGimage* ret = 0; @@ -2986,7 +2990,7 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi) } #ifdef HAVE_STDIO_H -NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi) +NSVG_EXPORT NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi) { FILE* fp = NULL; size_t size; @@ -3016,7 +3020,7 @@ NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi) } #endif /* HAVE_STDIO_H */ -void nsvgDelete(NSVGimage* image) +NSVG_EXPORT void nsvgDelete(NSVGimage* image) { NSVGshape *snext, *shape; if (image == NULL) return; diff --git a/nanosvgrast.h b/nanosvgrast.h index c5059841..fbd1d861 100644 --- a/nanosvgrast.h +++ b/nanosvgrast.h @@ -25,6 +25,10 @@ #ifndef NANOSVGRAST_H #define NANOSVGRAST_H +#ifndef NSVG_EXPORT +#define NSVG_EXPORT +#endif + #ifdef __cplusplus extern "C" { #endif @@ -44,7 +48,7 @@ typedef struct NSVGrasterizer NSVGrasterizer; */ // Allocated rasterizer context. -NSVGrasterizer* nsvgCreateRasterizer(void); +NSVG_EXPORT NSVGrasterizer* nsvgCreateRasterizer(void); // Rasterizes SVG image, returns RGBA image (non-premultiplied alpha) // r - pointer to rasterizer context @@ -55,12 +59,12 @@ NSVGrasterizer* nsvgCreateRasterizer(void); // w - width of the image to render // h - height of the image to render // stride - number of bytes per scaleline in the destination buffer -void nsvgRasterize(NSVGrasterizer* r, - NSVGimage* image, float tx, float ty, float scale, - unsigned char* dst, int w, int h, int stride); +NSVG_EXPORT void nsvgRasterize(NSVGrasterizer* r, + NSVGimage* image, float tx, float ty, float scale, + unsigned char* dst, int w, int h, int stride); // Deletes rasterizer context. -void nsvgDeleteRasterizer(NSVGrasterizer*); +NSVG_EXPORT void nsvgDeleteRasterizer(NSVGrasterizer*); #ifdef __cplusplus @@ -70,6 +74,9 @@ void nsvgDeleteRasterizer(NSVGrasterizer*); #endif // NANOSVGRAST_H #ifdef NANOSVGRAST_IMPLEMENTATION +#ifndef NSVG_EXPORT +#define NSVG_EXPORT +#endif /* #include @@ -145,7 +152,7 @@ struct NSVGrasterizer int width, height, stride; }; -NSVGrasterizer* nsvgCreateRasterizer() +NSVG_EXPORT NSVGrasterizer* nsvgCreateRasterizer() { NSVGrasterizer* r = (NSVGrasterizer*)malloc(sizeof(NSVGrasterizer)); if (r == NULL) goto error; @@ -161,7 +168,7 @@ NSVGrasterizer* nsvgCreateRasterizer() return NULL; } -void nsvgDeleteRasterizer(NSVGrasterizer* r) +NSVG_EXPORT void nsvgDeleteRasterizer(NSVGrasterizer* r) { NSVGmemPage* p; @@ -1360,7 +1367,7 @@ static void dumpEdges(NSVGrasterizer* r, const char* name) } */ -void nsvgRasterize(NSVGrasterizer* r, +NSVG_EXPORT void nsvgRasterize(NSVGrasterizer* r, NSVGimage* image, float tx, float ty, float scale, unsigned char* dst, int w, int h, int stride) {