diff options
Diffstat (limited to 'nanosvg/nanosvgrast.h')
| -rw-r--r-- | nanosvg/nanosvgrast.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/nanosvg/nanosvgrast.h b/nanosvg/nanosvgrast.h index 84a05a7f8..52986693e 100644 --- a/nanosvg/nanosvgrast.h +++ b/nanosvg/nanosvgrast.h @@ -31,6 +31,8 @@ #ifndef NANOSVGRAST_H #define NANOSVGRAST_H +#include "nanosvg.h" + #ifndef NANOSVGRAST_CPLUSPLUS #ifdef __cplusplus extern "C" { @@ -87,11 +89,11 @@ void nsvgDeleteRasterizer(NSVGrasterizer*); #endif #endif -#endif // NANOSVGRAST_H - #ifdef NANOSVGRAST_IMPLEMENTATION #include <math.h> +#include <stdlib.h> +#include <string.h> #define NSVG__SUBSAMPLES 5 #define NSVG__FIXSHIFT 10 @@ -972,7 +974,7 @@ static float nsvg__clampf(float a, float mn, float mx) { return a < mn ? mn : (a static unsigned int nsvg__RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - return (r) | (g << 8) | (b << 16) | (a << 24); + return ((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16) | ((unsigned int)a << 24); } static unsigned int nsvg__lerpRGBA(unsigned int c0, unsigned int c1, float u) @@ -1423,7 +1425,8 @@ void nsvgRasterizeXY(NSVGrasterizer* r, } // Rasterize edges - qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge); + if (r->nedges != 0) + qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule nsvg__initPaint(&cache, &shape->fill, shape->opacity); @@ -1449,7 +1452,8 @@ void nsvgRasterizeXY(NSVGrasterizer* r, } // Rasterize edges - qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge); + if (r->nedges != 0) + qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule nsvg__initPaint(&cache, &shape->stroke, shape->opacity); @@ -1474,3 +1478,5 @@ void nsvgRasterize(NSVGrasterizer* r, } #endif // NANOSVGRAST_IMPLEMENTATION + +#endif // NANOSVGRAST_H |
