Skip to content

Commit 929b3ee

Browse files
committed
Update lunasvg to 2.3.8
1 parent b603ce1 commit 929b3ee

36 files changed

+819
-1135
lines changed

vendor/lunasvg/3rdparty/plutovg/plutovg-blend.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <limits.h>
44
#include <math.h>
5+
#include <float.h>
56

67
#define COLOR_TABLE_SIZE 1024
78
typedef struct {
@@ -243,6 +244,7 @@ static void fetch_radial_gradient(uint32_t* buffer, const radial_gradient_values
243244
while(buffer < end)
244245
{
245246
uint32_t result = 0;
247+
det = fabs(det) < DBL_EPSILON ? 0.0 : det;
246248
if(det >= 0)
247249
{
248250
double w = sqrt(det) - b;
@@ -261,7 +263,11 @@ static void fetch_radial_gradient(uint32_t* buffer, const radial_gradient_values
261263
{
262264
while(buffer < end)
263265
{
264-
*buffer++ = gradient_pixel(gradient, sqrt(det) - b);
266+
det = fabs(det) < DBL_EPSILON ? 0.0 : det;
267+
uint32_t result = 0;
268+
if (det >= 0)
269+
result = gradient_pixel(gradient, sqrt(det) - b);
270+
*buffer++ = result;
265271
det += delta_det;
266272
delta_det += delta_delta_det;
267273
b += delta_b;

vendor/lunasvg/3rdparty/plutovg/plutovg-ft-stroker.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,12 @@ static void ft_stroke_border_export(PVG_FT_StrokeBorder border,
629629
PVG_FT_Outline* outline)
630630
{
631631
/* copy point locations */
632-
memcpy(outline->points + outline->n_points, border->points,
633-
border->num_points * sizeof(PVG_FT_Vector));
632+
if (outline->points != NULL && border->points != NULL)
633+
memcpy(outline->points + outline->n_points, border->points,
634+
border->num_points * sizeof(PVG_FT_Vector));
634635

635636
/* copy tags */
637+
if (outline->tags)
636638
{
637639
PVG_FT_UInt count = border->num_points;
638640
PVG_FT_Byte* read = border->tags;
@@ -649,6 +651,7 @@ static void ft_stroke_border_export(PVG_FT_StrokeBorder border,
649651
}
650652

651653
/* copy contours */
654+
if (outline->contours)
652655
{
653656
PVG_FT_UInt count = border->num_points;
654657
PVG_FT_Byte* tags = border->tags;

vendor/lunasvg/3rdparty/plutovg/plutovg-rle.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
#include <math.h>
77
#include <limits.h>
88

9+
#define ALIGN_SIZE(size) (((size) + 7ul) & ~7ul)
910
static void ft_outline_init(PVG_FT_Outline* outline, plutovg_t* pluto, int points, int contours)
1011
{
11-
size_t size_a = (points + contours) * sizeof(PVG_FT_Vector);
12-
size_t size_b = (points + contours) * sizeof(char);
13-
size_t size_c = contours * sizeof(int);
14-
size_t size_d = contours * sizeof(char);
12+
size_t size_a = ALIGN_SIZE((points + contours) * sizeof(PVG_FT_Vector));
13+
size_t size_b = ALIGN_SIZE((points + contours) * sizeof(char));
14+
size_t size_c = ALIGN_SIZE(contours * sizeof(int));
15+
size_t size_d = ALIGN_SIZE(contours * sizeof(char));
1516
size_t size_n = size_a + size_b + size_c + size_d;
1617
if(size_n > pluto->outline_size) {
1718
pluto->outline_data = realloc(pluto->outline_data, size_n);
@@ -20,9 +21,13 @@ static void ft_outline_init(PVG_FT_Outline* outline, plutovg_t* pluto, int point
2021

2122
PVG_FT_Byte* data = pluto->outline_data;
2223
outline->points = (PVG_FT_Vector*)(data);
23-
outline->tags = (char*)(data + size_a);
24-
outline->contours = (int*)(data + size_a + size_b);
25-
outline->contours_flag = (char*)(data + size_a + size_b + size_c);
24+
outline->tags = outline->contours_flag = NULL;
25+
outline->contours = NULL;
26+
if(data){
27+
outline->tags = (char*)(data + size_a);
28+
outline->contours = (int*)(data + size_a + size_b);
29+
outline->contours_flag = (char*)(data + size_a + size_b + size_c);
30+
}
2631
outline->n_points = 0;
2732
outline->n_contours = 0;
2833
outline->flags = 0x0;

vendor/lunasvg/3rdparty/plutovg/plutovg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ plutovg_texture_t* plutovg_set_texture(plutovg_t* pluto, plutovg_surface_t* surf
223223
{
224224
plutovg_paint_t* paint = &pluto->state->paint;
225225
paint->type = plutovg_paint_type_texture;
226-
plutovg_texture_init(&paint->texture, surface, plutovg_texture_type_plain);
226+
plutovg_texture_init(&paint->texture, surface, type);
227227
return &paint->texture;
228228
}
229229

vendor/lunasvg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Releases](https://img.shields.io/badge/Version-2.3.5-orange.svg)](https://github.com/sammycage/lunasvg/releases)
1+
[![Releases](https://img.shields.io/badge/Version-2.3.8-orange.svg)](https://github.com/sammycage/lunasvg/releases)
22
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/sammycage/lunasvg/blob/master/LICENSE)
33
[![Build Status](https://github.com/sammycage/lunasvg/actions/workflows/ci.yml/badge.svg)](https://github.com/sammycage/lunasvg/actions)
44

vendor/lunasvg/include/lunasvg.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <memory>
2727
#include <string>
28+
#include <cstdint>
2829

2930
#if defined(_MSC_VER) && defined(LUNASVG_SHARED)
3031
#ifdef LUNASVG_EXPORT
@@ -41,8 +42,7 @@ namespace lunasvg {
4142
class Rect;
4243
class Matrix;
4344

44-
class LUNASVG_API Box
45-
{
45+
class LUNASVG_API Box {
4646
public:
4747
Box() = default;
4848
Box(double x, double y, double w, double h);
@@ -60,8 +60,7 @@ class LUNASVG_API Box
6060

6161
class Transform;
6262

63-
class LUNASVG_API Matrix
64-
{
63+
class LUNASVG_API Matrix {
6564
public:
6665
Matrix() = default;
6766
Matrix(double a, double b, double c, double d, double e, double f);
@@ -98,8 +97,7 @@ class LUNASVG_API Matrix
9897
double f{0};
9998
};
10099

101-
class LUNASVG_API Bitmap
102-
{
100+
class LUNASVG_API Bitmap {
103101
public:
104102
/**
105103
* @note Bitmap format is ARGB Premultiplied.
@@ -129,8 +127,7 @@ class LUNASVG_API Bitmap
129127

130128
class LayoutSymbol;
131129

132-
class LUNASVG_API Document
133-
{
130+
class LUNASVG_API Document {
134131
public:
135132
/**
136133
* @brief Creates a document from a file
@@ -208,6 +205,7 @@ class LUNASVG_API Document
208205
Bitmap renderToBitmap(std::uint32_t width = 0, std::uint32_t height = 0, std::uint32_t backgroundColor = 0x00000000) const;
209206

210207
~Document();
208+
211209
private:
212210
Document();
213211

vendor/lunasvg/source/canvas.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,9 @@ void Canvas::luminance()
149149
auto height = plutovg_surface_get_height(surface);
150150
auto stride = plutovg_surface_get_stride(surface);
151151
auto data = plutovg_surface_get_data(surface);
152-
for(int y = 0;y < height;y++)
153-
{
152+
for(int y = 0; y < height; y++) {
154153
auto pixels = reinterpret_cast<uint32_t*>(data + stride * y);
155-
for(int x = 0;x < width;x++)
156-
{
154+
for(int x = 0; x < width; x++) {
157155
auto pixel = pixels[x];
158156
auto r = (pixel >> 16) & 0xFF;
159157
auto g = (pixel >> 8) & 0xFF;
@@ -229,8 +227,7 @@ static plutovg_texture_type_t to_plutovg_texture_type(TextureType type)
229227

230228
static void to_plutovg_stops(plutovg_gradient_t* gradient, const GradientStops& stops)
231229
{
232-
for(const auto& stop : stops)
233-
{
230+
for(const auto& stop : stops) {
234231
auto offset = std::get<0>(stop);
235232
auto& color = std::get<1>(stop);
236233
plutovg_gradient_add_stop_rgba(gradient, offset, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0);
@@ -241,8 +238,7 @@ void to_plutovg_path(plutovg_t* pluto, const Path& path)
241238
{
242239
PathIterator it(path);
243240
std::array<Point, 3> p;
244-
while(!it.isDone())
245-
{
241+
while(!it.isDone()) {
246242
switch(it.currentSegment(p)) {
247243
case PathCommand::MoveTo:
248244
plutovg_move_to(pluto, p[0].x, p[0].y);

vendor/lunasvg/source/canvas.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@ using GradientStops = std::vector<GradientStop>;
1313

1414
using DashArray = std::vector<double>;
1515

16-
struct DashData
17-
{
16+
struct DashData {
1817
DashArray array;
1918
double offset{0.0};
2019
};
2120

22-
enum class TextureType
23-
{
21+
enum class TextureType {
2422
Plain,
2523
Tiled
2624
};
2725

28-
enum class BlendMode
29-
{
26+
enum class BlendMode {
3027
Src,
3128
Src_Over,
3229
Dst_In,
@@ -35,8 +32,7 @@ enum class BlendMode
3532

3633
class CanvasImpl;
3734

38-
class Canvas
39-
{
35+
class Canvas {
4036
public:
4137
static std::shared_ptr<Canvas> create(unsigned char* data, unsigned int width, unsigned int height, unsigned int stride);
4238
static std::shared_ptr<Canvas> create(double x, double y, double width, double height);
@@ -61,6 +57,7 @@ class Canvas
6157
Rect box() const;
6258

6359
~Canvas();
60+
6461
private:
6562
Canvas(unsigned char* data, int width, int height, int stride);
6663
Canvas(int x, int y, int width, int height);

vendor/lunasvg/source/clippathelement.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ namespace lunasvg {
77

88
class LayoutClipPath;
99

10-
class ClipPathElement : public GraphicsElement
11-
{
10+
class ClipPathElement : public GraphicsElement {
1211
public:
1312
ClipPathElement();
1413

vendor/lunasvg/source/defselement.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
namespace lunasvg {
77

8-
class DefsElement : public GraphicsElement
9-
{
8+
class DefsElement : public GraphicsElement {
109
public:
1110
DefsElement();
1211

0 commit comments

Comments
 (0)