|
@@ -77,6 +77,8 @@ void nsvgDeleteRasterizer(NSVGrasterizer*);
|
|
|
#ifdef NANOSVGRAST_IMPLEMENTATION
|
|
|
|
|
|
#include <math.h>
|
|
|
+#include <stdlib.h>
|
|
|
+#include <string.h>
|
|
|
|
|
|
#define NSVG__SUBSAMPLES 5
|
|
|
#define NSVG__FIXSHIFT 10
|
|
@@ -956,7 +958,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)
|
|
@@ -1406,7 +1408,8 @@ void nsvgRasterize(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);
|
|
@@ -1432,7 +1435,8 @@ void nsvgRasterize(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);
|