diff options
Diffstat (limited to 'nanosvg')
| -rw-r--r-- | nanosvg/README.txt | 19 | ||||
| -rw-r--r-- | nanosvg/altsvgrast.diff | 136 | ||||
| -rw-r--r-- | nanosvg/nanosvg.diff | 61 | ||||
| -rw-r--r-- | nanosvg/nanosvg.h | 16 | ||||
| -rw-r--r-- | nanosvg/nanosvgrast.h (renamed from nanosvg/altsvgrast.h) | 19 |
5 files changed, 36 insertions, 215 deletions
diff --git a/nanosvg/README.txt b/nanosvg/README.txt new file mode 100644 index 000000000..2cb5de3f4 --- /dev/null +++ b/nanosvg/README.txt @@ -0,0 +1,19 @@ +README for the nanosvg library bundled with FLTK +------------------------------------------------ + +This is a header-only library to display SVG images. + +This bundled library was modified for optimal use in the FLTK library. + + +The original library can be found here: + + https://github.com/memononen/nanosvg + + +The modified library was cloned and can be found here: + + https://github.com/fltk/nanosvg + + +For more information see README.bundled-libs.txt in FLTK's root directory. diff --git a/nanosvg/altsvgrast.diff b/nanosvg/altsvgrast.diff deleted file mode 100644 index 83cdc6d06..000000000 --- a/nanosvg/altsvgrast.diff +++ /dev/null @@ -1,136 +0,0 @@ -1,6d0 -< // -< // "$Id$" -< // -< -< /* Modified by FLTK from original sources to support non-square X,Y axes scaling */ -< -31d24 -< -51,53d43 -< -< // For non-square X,Y scaling, use -< nsvgAltRasterize(rast, image, 0,0,1,1, img, w, h, w*4); -63c53 -< // scale - image scale (assumes square aspect ratio) ---- -> // scale - image scale -72,77d61 -< // As above, but allow X and Y axes to scale independently for non-square aspects -< void nsvgAltRasterize(NSVGrasterizer* r, -< NSVGimage* image, float tx, float ty, -< float sx, float sy, -< unsigned char* dst, int w, int h, int stride); -< -382c366 -< static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float sx, float sy) ---- -> static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale) -390c374 -< nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, 0); ---- -> nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0); -393c377 -< nsvg__flattenCubicBez(r, p[0]*sx,p[1]*sy, p[2]*sx,p[3]*sy, p[4]*sx,p[5]*sy, p[6]*sx,p[7]*sy, 0, 0); ---- -> nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0); -396c380 -< nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, 0); ---- -> nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0); -746c730 -< static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float sx, float sy) ---- -> static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float scale) -754,755c738 -< const float sw = (sx + sy) / 2; // average scaling factor -< const float lineWidth = shape->strokeWidth * sw; // FIXME (?) ---- -> float lineWidth = shape->strokeWidth * scale; -760c743 -< nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, NSVG_PT_CORNER); ---- -> nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER); -763c746 -< nsvg__flattenCubicBez(r, p[0]*sx,p[1]*sy, p[2]*sx,p[3]*sy, p[4]*sx,p[5]*sy, p[6]*sx,p[7]*sy, 0, NSVG_PT_CORNER); ---- -> nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER); -809c792 -< dashLen = (shape->strokeDashArray[idash] - dashOffset) * sw; ---- -> dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale; -831c814 -< dashLen = shape->strokeDashArray[idash] * sw; ---- -> dashLen = shape->strokeDashArray[idash] * scale; -1000c983 -< float tx, float ty, float sx, float sy, NSVGcachedPaint* cache) ---- -> float tx, float ty, float scale, NSVGcachedPaint* cache) -1041,1043c1024,1026 -< fx = ((float)x - tx) / sx; -< fy = ((float)y - ty) / sy; -< dx = 1.0f / sx; ---- -> fx = ((float)x - tx) / scale; -> fy = ((float)y - ty) / scale; -> dx = 1.0f / scale; -1086,1088c1069,1071 -< fx = ((float)x - tx) / sx; -< fy = ((float)y - ty) / sy; -< dx = 1.0f / sx; ---- -> fx = ((float)x - tx) / scale; -> fy = ((float)y - ty) / scale; -> dx = 1.0f / scale; -1127c1110 -< static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float sx, float sy, NSVGcachedPaint* cache, char fillRule) ---- -> static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule) -1209c1192 -< nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, sx, sy, cache); ---- -> nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache); -1377,1379c1360,1361 -< void nsvgAltRasterize(NSVGrasterizer* r, -< NSVGimage* image, float tx, float ty, -< float sx, float sy, ---- -> void nsvgRasterize(NSVGrasterizer* r, -> NSVGimage* image, float tx, float ty, float scale, -1410c1392 -< nsvg__flattenShape(r, shape, sx, sy); ---- -> nsvg__flattenShape(r, shape, scale); -1427c1409 -< nsvg__rasterizeSortedEdges(r, tx,ty, sx, sy, &cache, shape->fillRule); ---- -> nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule); -1429c1411 -< if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * sx) > 0.01f) { ---- -> if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) { -1434c1416 -< nsvg__flattenShapeStroke(r, shape, sx, sy); ---- -> nsvg__flattenShapeStroke(r, shape, scale); -1453c1435 -< nsvg__rasterizeSortedEdges(r, tx,ty,sx, sy, &cache, NSVG_FILLRULE_NONZERO); ---- -> nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO); -1465,1477c1447 -< void nsvgRasterize(NSVGrasterizer* r, -< NSVGimage* image, float tx, float ty, float scale, -< unsigned char* dst, int w, int h, int stride) -< { -< nsvgAltRasterize(r,image, tx, ty, scale, scale, dst, w, h, stride); -< } -< -< #endif // NANOSVGRAST_IMPLEMENTATION -< -< -< // -< // End of "$Id$". -< // ---- -> #endif diff --git a/nanosvg/nanosvg.diff b/nanosvg/nanosvg.diff deleted file mode 100644 index 0f0db20f5..000000000 --- a/nanosvg/nanosvg.diff +++ /dev/null @@ -1,61 +0,0 @@ -Index: nanosvg.h -=================================================================== ---- nanosvg.h (revision 12413) -+++ nanosvg.h (working copy) -@@ -1081,7 +1081,7 @@ - char* cur = (char*)s; - char* end = NULL; - double res = 0.0, sign = 1.0; -- long long intPart = 0, fracPart = 0; -+ double intPart = 0, fracPart = 0; - char hasIntPart = 0, hasFracPart = 0; - - // Parse optional sign -@@ -1095,7 +1095,11 @@ - // Parse integer part - if (nsvg__isdigit(*cur)) { - // Parse digit sequence -- intPart = (double)strtoll(cur, &end, 10); -+#ifdef _MSC_VER -+ intPart = (double)_strtoi64(cur, &end, 10); -+#else -+ intPart = (double)strtoll(cur, &end, 10); -+#endif - if (cur != end) { - res = (double)intPart; - hasIntPart = 1; -@@ -1108,7 +1112,11 @@ - cur++; // Skip '.' - if (nsvg__isdigit(*cur)) { - // Parse digit sequence -- fracPart = strtoll(cur, &end, 10); -+#ifdef _MSC_VER -+ fracPart = (double)_strtoi64(cur, &end, 10); -+#else -+ fracPart = (double)strtoll(cur, &end, 10); -+#endif - if (cur != end) { - res += (double)fracPart / pow(10.0, (double)(end - cur)); - hasFracPart = 1; -@@ -1123,11 +1131,11 @@ - - // Parse optional exponent - if (*cur == 'e' || *cur == 'E') { -- int expPart = 0; -+ double expPart = 0; - cur++; // skip 'E' -- expPart = strtol(cur, &end, 10); // Parse digit sequence with sign -+ expPart = (double)strtol(cur, &end, 10); // Parse digit sequence with sign - if (cur != end) { -- res *= pow(10.0, (double)expPart); -+ res *= pow(10.0, expPart); - } - } - - -Property changes on: nanosvg.h -___________________________________________________________________ -Added: eol-style -## -0,0 +1 ## -+native -\ No newline at end of property diff --git a/nanosvg/nanosvg.h b/nanosvg/nanosvg.h index bd5b722f4..0426b0c3f 100644 --- a/nanosvg/nanosvg.h +++ b/nanosvg/nanosvg.h @@ -1081,7 +1081,7 @@ static double nsvg__atof(const char* s) char* cur = (char*)s; char* end = NULL; double res = 0.0, sign = 1.0; - double intPart = 0, fracPart = 0; + double intPart = 0.0, fracPart = 0.0; char hasIntPart = 0, hasFracPart = 0; // Parse optional sign @@ -1096,12 +1096,12 @@ static double nsvg__atof(const char* s) if (nsvg__isdigit(*cur)) { // Parse digit sequence #ifdef _MSC_VER - intPart = (double)_strtoi64(cur, &end, 10); + intPart = (double)_strtoi64(cur, &end, 10); #else - intPart = (double)strtoll(cur, &end, 10); + intPart = (double)strtoll(cur, &end, 10); #endif if (cur != end) { - res = (double)intPart; + res = intPart; hasIntPart = 1; cur = end; } @@ -1113,12 +1113,12 @@ static double nsvg__atof(const char* s) if (nsvg__isdigit(*cur)) { // Parse digit sequence #ifdef _MSC_VER - fracPart = (double)_strtoi64(cur, &end, 10); + fracPart = (double)_strtoi64(cur, &end, 10); #else - fracPart = (double)strtoll(cur, &end, 10); + fracPart = (double)strtoll(cur, &end, 10); #endif if (cur != end) { - res += (double)fracPart / pow(10.0, (double)(end - cur)); + res += fracPart / pow(10.0, (double)(end - cur)); hasFracPart = 1; cur = end; } @@ -1131,7 +1131,7 @@ static double nsvg__atof(const char* s) // Parse optional exponent if (*cur == 'e' || *cur == 'E') { - double expPart = 0; + double expPart = 0.0; cur++; // skip 'E' expPart = (double)strtol(cur, &end, 10); // Parse digit sequence with sign if (cur != end) { diff --git a/nanosvg/altsvgrast.h b/nanosvg/nanosvgrast.h index 5a4e43a35..63506e5cd 100644 --- a/nanosvg/altsvgrast.h +++ b/nanosvg/nanosvgrast.h @@ -1,9 +1,3 @@ -// -// "$Id$" -// - -/* Modified by FLTK from original sources to support non-square X,Y axes scaling */ - /* * Copyright (c) 2013-14 Mikko Mononen memon@inside.org * @@ -28,6 +22,11 @@ * */ +/* Modified by FLTK to support non-square X,Y axes scaling. + * + * Added: nsvgRasterizeXY() +*/ + #ifndef NANOSVGRAST_H #define NANOSVGRAST_H @@ -50,7 +49,7 @@ typedef struct NSVGrasterizer NSVGrasterizer; nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4); // For non-square X,Y scaling, use - nsvgAltRasterize(rast, image, 0,0,1,1, img, w, h, w*4); + nsvgRasterizeXY(rast, image, 0,0,1,1, img, w, h, w*4); */ // Allocated rasterizer context. @@ -70,7 +69,7 @@ void nsvgRasterize(NSVGrasterizer* r, unsigned char* dst, int w, int h, int stride); // As above, but allow X and Y axes to scale independently for non-square aspects -void nsvgAltRasterize(NSVGrasterizer* r, +void nsvgRasterizeXY(NSVGrasterizer* r, NSVGimage* image, float tx, float ty, float sx, float sy, unsigned char* dst, int w, int h, int stride); @@ -1374,7 +1373,7 @@ static void dumpEdges(NSVGrasterizer* r, const char* name) } */ -void nsvgAltRasterize(NSVGrasterizer* r, +void nsvgRasterizeXY(NSVGrasterizer* r, NSVGimage* image, float tx, float ty, float sx, float sy, unsigned char* dst, int w, int h, int stride) @@ -1466,7 +1465,7 @@ void nsvgRasterize(NSVGrasterizer* r, NSVGimage* image, float tx, float ty, float scale, unsigned char* dst, int w, int h, int stride) { - nsvgAltRasterize(r,image, tx, ty, scale, scale, dst, w, h, stride); + nsvgRasterizeXY(r,image, tx, ty, scale, scale, dst, w, h, stride); } #endif // NANOSVGRAST_IMPLEMENTATION |
