nanosvg: Sync with upstream 4c8f013

This commit is contained in:
Rémi Verschelde 2022-05-17 16:32:20 +02:00 committed by Relintai
parent e060783202
commit 93739df7cf
4 changed files with 17 additions and 11 deletions

View File

@ -329,13 +329,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

View File

@ -1,6 +1,3 @@
#include "stdio.h"
#include "string.h"
#include "math.h"
#define NANOSVG_ALL_COLOR_KEYWORDS
#define NANOSVG_IMPLEMENTATION
#include "nanosvg.h"

View File

@ -189,6 +189,7 @@ void nsvgDelete(NSVGimage* image);
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define NSVG_PI (3.14159265358979323846264338327f)
@ -1228,10 +1229,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);
}

View File

@ -79,6 +79,8 @@ void nsvgDeleteRasterizer(NSVGrasterizer*);
#ifdef NANOSVGRAST_IMPLEMENTATION
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define NSVG__SUBSAMPLES 5
#define NSVG__FIXSHIFT 10
@ -958,7 +960,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)
@ -1408,6 +1410,7 @@ void nsvgRasterize(NSVGrasterizer* r,
}
// Rasterize edges
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
@ -1434,6 +1437,7 @@ void nsvgRasterize(NSVGrasterizer* r,
}
// Rasterize edges
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