summaryrefslogtreecommitdiff
path: root/nanosvg/nanosvgrast.h
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2022-07-09 14:37:46 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2022-07-09 14:37:46 +0200
commitd9d3406be8640e30108dcef6d8b1111635fa189a (patch)
tree82a2cd33f1dc890741e51ad5827b147a723f9e93 /nanosvg/nanosvgrast.h
parentf0971416626f5b2b1e64a8c9bc86734e81a193e8 (diff)
Upgrade the bundled nanosvg library to current version
For details see README.bundled-libs.txt.
Diffstat (limited to 'nanosvg/nanosvgrast.h')
-rw-r--r--nanosvg/nanosvgrast.h16
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