mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-26 21:57:16 +01:00
nanosvg: Sync with upstream 4c8f013
This commit is contained in:
parent
e060783202
commit
93739df7cf
9
thirdparty/README.md
vendored
9
thirdparty/README.md
vendored
@ -329,13 +329,16 @@ Collection of single-file libraries used in Godot components.
|
|||||||
## nanosvg
|
## nanosvg
|
||||||
|
|
||||||
- Upstream: https://github.com/memononen/nanosvg
|
- Upstream: https://github.com/memononen/nanosvg
|
||||||
- Version: git (ccdb1995134d340a93fb20e3a3d323ccb3838dd0, 2021)
|
- Version: git (4c8f0139b62c6e7faa3b67ce1fbe6e63590ed148, 2022)
|
||||||
- License: zlib
|
- License: zlib
|
||||||
|
|
||||||
Files extracted from the upstream source:
|
Files extracted from the upstream source:
|
||||||
|
|
||||||
- All .h files in `src/`
|
- All `.h` files in `src/`
|
||||||
- LICENSE.txt
|
- `LICENSE.txt`
|
||||||
|
|
||||||
|
`nanosvg.cc` is a custom file added to configure the build of the header only
|
||||||
|
library.
|
||||||
|
|
||||||
|
|
||||||
## oidn
|
## 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_ALL_COLOR_KEYWORDS
|
||||||
#define NANOSVG_IMPLEMENTATION
|
#define NANOSVG_IMPLEMENTATION
|
||||||
#include "nanosvg.h"
|
#include "nanosvg.h"
|
||||||
|
6
thirdparty/nanosvg/nanosvg.h
vendored
6
thirdparty/nanosvg/nanosvg.h
vendored
@ -189,6 +189,7 @@ void nsvgDelete(NSVGimage* image);
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define NSVG_PI (3.14159265358979323846264338327f)
|
#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)
|
static unsigned int nsvg__parseColorRGB(const char* str)
|
||||||
{
|
{
|
||||||
unsigned int r=0, g=0, b=0;
|
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
|
if (sscanf(str, "rgb(%u, %u, %u)", &r, &g, &b) == 3) // decimal integers
|
||||||
return NSVG_RGB(r, g, b);
|
return NSVG_RGB(r, g, b);
|
||||||
if (sscanf(str, "rgb(%u%%, %u%%, %u%%)", &r, &g, &b) == 3) // decimal integer percentage
|
if (sscanf(str, "rgb(%f%%, %f%%, %f%%)", &rf, &gf, &bf) == 3) // decimal integer percentage
|
||||||
return NSVG_RGB(r*255/100, g*255/100, b*255/100);
|
return NSVG_RGB(roundf(rf*2.55f), roundf(gf*2.55f), roundf(bf*2.55f)); // (255 / 100.0f)
|
||||||
return NSVG_RGB(128, 128, 128);
|
return NSVG_RGB(128, 128, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
thirdparty/nanosvg/nanosvgrast.h
vendored
10
thirdparty/nanosvg/nanosvgrast.h
vendored
@ -79,6 +79,8 @@ void nsvgDeleteRasterizer(NSVGrasterizer*);
|
|||||||
#ifdef NANOSVGRAST_IMPLEMENTATION
|
#ifdef NANOSVGRAST_IMPLEMENTATION
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define NSVG__SUBSAMPLES 5
|
#define NSVG__SUBSAMPLES 5
|
||||||
#define NSVG__FIXSHIFT 10
|
#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)
|
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)
|
static unsigned int nsvg__lerpRGBA(unsigned int c0, unsigned int c1, float u)
|
||||||
@ -1408,7 +1410,8 @@ void nsvgRasterize(NSVGrasterizer* r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rasterize edges
|
// 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
|
// now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
|
||||||
nsvg__initPaint(&cache, &shape->fill, shape->opacity);
|
nsvg__initPaint(&cache, &shape->fill, shape->opacity);
|
||||||
@ -1434,7 +1437,8 @@ void nsvgRasterize(NSVGrasterizer* r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rasterize edges
|
// 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
|
// now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
|
||||||
nsvg__initPaint(&cache, &shape->stroke, shape->opacity);
|
nsvg__initPaint(&cache, &shape->stroke, shape->opacity);
|
||||||
|
Loading…
Reference in New Issue
Block a user