Merge pull request #61121 from akien-mga/nanosvg-20220509
This commit is contained in:
commit
0de455cdf7
4 changed files with 17 additions and 11 deletions
9
thirdparty/README.md
vendored
9
thirdparty/README.md
vendored
|
@ -392,13 +392,16 @@ Collection of single-file libraries used in Godot components.
|
|||
## nanosvg
|
||||
|
||||
- Upstream: https://github.com/memononen/nanosvg
|
||||
- Version: git (ccdb1995134d340a93fb20e3a3d323ccb3838dd0, 2021)
|
||||
- Version: git (4c8f0139b62c6e7faa3b67ce1fbe6e63590ed148, 2022)
|
||||
- License: zlib
|
||||
|
||||
Files extracted from the upstream source:
|
||||
|
||||
- All .h files in `src/`
|
||||
- LICENSE.txt
|
||||
- All `.h` files in `src/`
|
||||
- `LICENSE.txt`
|
||||
|
||||
`nanosvg.cc` is a custom file added to configure the build of the header only
|
||||
library.
|
||||
|
||||
|
||||
## oidn
|
||||
|
|
3
thirdparty/nanosvg/nanosvg.cc
vendored
3
thirdparty/nanosvg/nanosvg.cc
vendored
|
@ -1,6 +1,3 @@
|
|||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
#include "math.h"
|
||||
#define NANOSVG_ALL_COLOR_KEYWORDS
|
||||
#define NANOSVG_IMPLEMENTATION
|
||||
#include "nanosvg.h"
|
||||
|
|
6
thirdparty/nanosvg/nanosvg.h
vendored
6
thirdparty/nanosvg/nanosvg.h
vendored
|
@ -187,6 +187,7 @@ void nsvgDelete(NSVGimage* image);
|
|||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#define NSVG_PI (3.14159265358979323846264338327f)
|
||||
|
@ -1226,10 +1227,11 @@ static unsigned int nsvg__parseColorHex(const char* str)
|
|||
static unsigned int nsvg__parseColorRGB(const char* str)
|
||||
{
|
||||
unsigned int r=0, g=0, b=0;
|
||||
float rf=0, gf=0, bf=0;
|
||||
if (sscanf(str, "rgb(%u, %u, %u)", &r, &g, &b) == 3) // decimal integers
|
||||
return NSVG_RGB(r, g, b);
|
||||
if (sscanf(str, "rgb(%u%%, %u%%, %u%%)", &r, &g, &b) == 3) // decimal integer percentage
|
||||
return NSVG_RGB(r*255/100, g*255/100, b*255/100);
|
||||
if (sscanf(str, "rgb(%f%%, %f%%, %f%%)", &rf, &gf, &bf) == 3) // decimal integer percentage
|
||||
return NSVG_RGB(roundf(rf*2.55f), roundf(gf*2.55f), roundf(bf*2.55f)); // (255 / 100.0f)
|
||||
return NSVG_RGB(128, 128, 128);
|
||||
}
|
||||
|
||||
|
|
10
thirdparty/nanosvg/nanosvgrast.h
vendored
10
thirdparty/nanosvg/nanosvgrast.h
vendored
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue