Reorganize nanosvg bundled library.

Rename altsvgrast.h to its original name nanosvg.h and use a new
GitHub fork of nanosvg to maintain FLTK specific patches.

https://github.com/fltk/nanosvg

The diff files (altsvgrast.diff and nanosvg.diff) are no longer necessary
and have been removed. For more information see README.bundled-libs.txt.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12646 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2018-02-04 21:39:50 +00:00
parent c97fe2e58f
commit 4ebaee0f40
8 changed files with 240 additions and 218 deletions

201
README.bundled-libs.txt Normal file
View File

@ -0,0 +1,201 @@
README.bundled-libs.txt - Developer information for bundled libraries
---------------------------------------------------------------------
******************************************************
*** NOTICE *** This file is still work in progress ***
******************************************************
This file is mainly intended for FLTK developers and contains information
about the current versions of all bundled libraries and about how to
upgrade these bundled libraries.
Current versions of bundled libraries:
** work in progress -- not yet completely upgraded **
Library Version Release date FLTK Version
------------------------------------------------------------------
jpeg jpeg-9c 2018-01-14 1.4.0
nanosvg [2017-07-09] n.a. 1.4.0
png libpng-1.6.34 2017-09-29 1.4.0
zlib zlib-1.2.11 2017-01-15 1.4.0
Previous versions of bundled libraries:
Library Version Release date FLTK Version
------------------------------------------------------------------
jpeg jpeg-9a 2014-01-19 1.3.4
png libpng-1.6.16 2014-12-22 1.3.4
zlib zlib-1.2.8 2013-04-28 1.3.4
General information:
FLTK does not include the entire library distributions. We only provide
the source files necessary to build the library itself. There are no
test programs or other contributed files.
We use our own build files, hence a few files MUST NOT be upgraded when
the library source files are upgraded. We strive to keep changes to the
library source files as small as possible. Patching library code to
work with FLTK should be a rare exception.
If patches are necessary all changes in the library files should be
marked with "FLTK" in a comment so a developer that upgrades the library
later is aware of changes in the source code for FLTK. Additional comments
should be added to show the rationale, i.e. why a particular change was
necessary. If applicable, add a reference to a Software Trouble Report
like "STR #3456".
How to update the bundled libraries:
It is generally advisable to use a graphical merge program. I'm using
'meld' under Linux, but YMMV.
Do not add any source files unless they are required to build the library.
Some config header files may be pre-generated in the FLTK sources. These
header files should be left untouched, but it may be necessary to update
them if new items were added to the new library version. In this case
the new header should be pre-generated on a Linux system with default
options unless otherwise mentioned below for a specific library.
Currently there are no known exceptions.
Merging source files:
Please check if some source and header files contain "FLTK" comments
to be aware of necessary merges. It is also good to get the distribution
tar ball of the previous version and to run a (graphical) diff or
merge tool on the previous version and the bundled version of FLTK
to see the "previous" differences.
Files that were not patched in previous versions should be copied to
the new version w/o changes. Files that had FLTK specific patches must
be merged manually. FLTK patches should be verified (if still necessary)
and should be kept in the new source files.
Source and header files that have been added in the new library version
should be added in FLTK as well if they are necessary to build the
library. A simple "trial and error" should be sufficient to find files
that need to be added. Added files must be added to FLTK's build files
as well, usually to both the Makefile and the CMakeLists.txt to be
used in configure/make and in CMake based builds.
Upgrade order:
There is only one dependency between all bundled libraries: libpng
depends on zlib. Hence zlib should be upgraded first, then all other
libs can be upgraded in arbitrary order.
Tests after merge:
Tests should be done on as many platforms as possible, both with
autotools (configure/make) and CMake. Windows (Visual Studio) and
macOS (Xcode) build need CMake to generate the IDE files.
Upgrade notes for specific libraries:
The following chapters contain information of specific files and how
they are upgraded. Since the changes in all bundled libraries can't
be known in advance this information can change in the future. Please
very that no other changes are necessary.
zlib:
Website: http://zlib.net/
Download: See website and follow links.
Repository: git clone https://github.com/madler/zlib.git
The following files need special handling:
CMakeLists.txt: Keep FLTK version, update manually if necessary.
Makefile: Same as CMakeLists.txt.
zconf.h: Merge changes.
As of zlib 1.2.11: two small sections marked with "FLTK" comments
that need to be kept.
makedepend: Keep this file. Run `make depend' in the zlib folder
on a Linux system after the upgrade to update this file.
png:
Website: http://libpng.org/pub/png/libpng.html
Download: See website and follow links.
Repository: git clone https://git.code.sf.net/p/libpng/code libpng
libpng should be upgraded after zlib because it depends on zlib.
The following files need special handling:
CMakeLists.txt: Keep FLTK version, update manually if necessary.
Makefile: Same as CMakeLists.txt.
Note: more to come...
makedepend: Keep this file. Run `make depend' in the zlib folder
on a Linux system after the upgrade to update this file.
jpeg:
Website: http://ijg.org/
Download: See website and follow links.
Repository: <unknown>
The following files need special handling:
CMakeLists.txt: Keep FLTK version, update manually if necessary.
Makefile: Same as CMakeLists.txt.
Note: more to come...
makedepend: Keep this file. Run `make depend' in the zlib folder
on a Linux system after the upgrade to update this file.
nanosvg:
Website: https://github.com/memononen/nanosvg
Download: See website and follow links.
Repository: git clone https://github.com/memononen/nanosvg.git
FLTK Clone: git clone https://github.com/fltk/nanosvg.git
FLTK has its own GitHub clone of the original repository (see above).
The intention is to update this clone from time to time so the FLTK
specific patches are up-to-date with the original library. Hopefully
the FLTK patches will be accepted upstream at some time in the future
so we no longer need our own patches.
AlbrechtS, 04 Feb 2018.
Use this clone (branch 'fltk') to get the nanosvg library with FLTK
specific patches:
$ git clone https://github.com/fltk/nanosvg.git nanosvg-fltk
$ cd nanosvg-fltk
$ git checkout fltk
$ cd src
$ cp nanosvg.h nanosvgrast.h /path/to/fltk-1.4/nanosvg/
This library does not have its own build files since it is a
header-only library. The build is included in FLTK where necessary.
The following files need special handling:
nanosvg.h: Merge or download from FLTK's clone (see above).
nanosvgrast.h: Merge or download from FLTK's clone (see above).

19
nanosvg/README.txt Normal file
View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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
@ -1101,7 +1101,7 @@ static double nsvg__atof(const char* s)
intPart = (double)strtoll(cur, &end, 10);
#endif
if (cur != end) {
res = (double)intPart;
res = intPart;
hasIntPart = 1;
cur = end;
}
@ -1118,7 +1118,7 @@ static double nsvg__atof(const char* s)
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) {

View File

@ -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

View File

@ -41,7 +41,7 @@ static double strtoll(const char *str, char **endptr, int base) {
#include "../nanosvg/nanosvg.h"
#define NANOSVGRAST_IMPLEMENTATION // Expands implementation
#include "../nanosvg/altsvgrast.h"
#include "../nanosvg/nanosvgrast.h"
/** The constructor loads the SVG image from the given .svg/.svgz filename or in-memory data.
@ -184,7 +184,7 @@ void Fl_SVG_Image::rasterize_(int W, int H) {
fy = (double)H / counted_svg_image_->svg_image->height;
}
array = new uchar[W*H*4];
nsvgAltRasterize(rasterizer, counted_svg_image_->svg_image, 0, 0, fx, fy, (uchar* )array, W, H, W*4);
nsvgRasterizeXY(rasterizer, counted_svg_image_->svg_image, 0, 0, fx, fy, (uchar* )array, W, H, W*4);
alloc_array = 1;
data((const char * const *)&array, 1);
d(4);

View File

@ -2000,7 +2000,7 @@ Fl_SVG_Image.o: ../FL/Fl_Graphics_Driver.H ../FL/Fl_Bitmap.H ../FL/Fl_Image.H
Fl_SVG_Image.o: ../FL/Fl_Pixmap.H ../FL/Fl_RGB_Image.H ../FL/Fl_Group.H
Fl_SVG_Image.o: ../FL/Fl_Rect.H ../FL/Fl_Widget.H ../FL/Fl_Scrollbar.H
Fl_SVG_Image.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/Fl_Text_Buffer.H
Fl_SVG_Image.o: ../nanosvg/nanosvg.h ../nanosvg/altsvgrast.h
Fl_SVG_Image.o: ../nanosvg/nanosvg.h ../nanosvg/nanosvgrast.h
flstring.o: flstring.h ../FL/Fl_Export.H ../config.h
numericsort.o: ../FL/platform_types.h ../FL/filename.H ../FL/Fl_Export.H
vsnprintf.o: flstring.h ../FL/Fl_Export.H ../config.h