Skip to content

Commit d42838b

Browse files
committed
update
1 parent 77a07fb commit d42838b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+5689
-5907
lines changed

Linux/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1110,9 +1110,9 @@ set(SIV3D_INTERNAL_SOURCES
11101110
../Siv3D/src/ThirdParty/plutovg/plutovg-paint.c
11111111
../Siv3D/src/ThirdParty/plutovg/plutovg-rle.c
11121112
../Siv3D/src/ThirdParty/plutovg/plutovg.c
1113-
../Siv3D/src/ThirdParty/plutovg/sw_ft_math.c
1114-
../Siv3D/src/ThirdParty/plutovg/sw_ft_raster.c
1115-
../Siv3D/src/ThirdParty/plutovg/sw_ft_stroker.c
1113+
../Siv3D/src/ThirdParty/plutovg/plutovg-ft-math.c
1114+
../Siv3D/src/ThirdParty/plutovg/plutovg-ft-raster.c
1115+
../Siv3D/src/ThirdParty/plutovg/plutovg-ft-stroker.c
11161116

11171117
../Siv3D/src/ThirdParty/qr-code-generator-library/qrcodegen.cpp
11181118

Siv3D/src/Siv3D/ImageFormat/SVG/SVGDecoder.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ namespace s3d
102102

103103
const int32 width = static_cast<int32>(std::ceil(document->width()));
104104
const int32 height = static_cast<int32>(std::ceil(document->height()));
105-
const lunasvg::Bitmap bitmap = document->renderToBitmap(width, height, 0x00000000);
105+
lunasvg::Bitmap bitmap = document->renderToBitmap(width, height, 0x00000000);
106+
bitmap.convert(0, 1, 2, 3, true);
106107

107108
Image image(bitmap.width(), bitmap.height());
108109
assert(image.size_bytes() == (bitmap.stride() * bitmap.height()));

Siv3D/src/Siv3D/SVG/SVGDetail.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ namespace s3d
9696
const int32 imageHeight = maxHeight.value_or_eval([&] { return static_cast<int32>(std::ceil(m_document->height())); });
9797
const uint32 color = Color{ background.a, background.b, background.g, background.r }.asUint32();
9898

99-
const lunasvg::Bitmap bitmap = m_document->renderToBitmap(imageWidth, imageHeight, color);
99+
lunasvg::Bitmap bitmap = m_document->renderToBitmap(imageWidth, imageHeight, color);
100+
bitmap.convert(0, 1, 2, 3, true);
100101

101102
Image image{ bitmap.width(), bitmap.height() };
102103
assert(image.size_bytes() == (bitmap.stride() * bitmap.height()));

Siv3D/src/ThirdParty/lunasvg/canvas.cpp

+21-74
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ static plutovg_fill_rule_t to_plutovg_fill_rule(WindRule winding);
99
static plutovg_operator_t to_plutovg_operator(BlendMode mode);
1010
static plutovg_line_cap_t to_plutovg_line_cap(LineCap cap);
1111
static plutovg_line_join_t to_plutovg_line_join(LineJoin join);
12-
static plutovg_spread_method_t to_plutovg_spread_methood(SpreadMethod spread);
12+
static plutovg_spread_method_t to_plutovg_spread_method(SpreadMethod spread);
13+
static plutovg_texture_type_t to_plutovg_texture_type(TextureType type);
1314
static void to_plutovg_stops(plutovg_gradient_t* gradient, const GradientStops& stops);
1415
static void to_plutovg_path(plutovg_t* pluto, const Path& path);
1516

@@ -59,43 +60,32 @@ Canvas::~Canvas()
5960

6061
void Canvas::setColor(const Color& color)
6162
{
62-
plutovg_set_source_rgba(pluto, color.r, color.g, color.b, color.a);
63+
plutovg_set_rgba(pluto, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0);
6364
}
6465

6566
void Canvas::setLinearGradient(double x1, double y1, double x2, double y2, const GradientStops& stops, SpreadMethod spread, const Transform& transform)
6667
{
67-
auto gradient = plutovg_gradient_create_linear(x1, y1, x2, y2);
68+
auto gradient = plutovg_set_linear_gradient(pluto, x1, y1, x2, y2);
6869
auto matrix = to_plutovg_matrix(transform);
6970
to_plutovg_stops(gradient, stops);
70-
plutovg_gradient_set_spread(gradient, to_plutovg_spread_methood(spread));
71+
plutovg_gradient_set_spread(gradient, to_plutovg_spread_method(spread));
7172
plutovg_gradient_set_matrix(gradient, &matrix);
72-
plutovg_set_source_gradient(pluto, gradient);
73-
plutovg_gradient_destroy(gradient);
7473
}
7574

7675
void Canvas::setRadialGradient(double cx, double cy, double r, double fx, double fy, const GradientStops& stops, SpreadMethod spread, const Transform& transform)
7776
{
78-
auto gradient = plutovg_gradient_create_radial(cx, cy, r, fx, fy, 0);
77+
auto gradient = plutovg_set_radial_gradient(pluto, cx, cy, r, fx, fy, 0);
7978
auto matrix = to_plutovg_matrix(transform);
8079
to_plutovg_stops(gradient, stops);
81-
plutovg_gradient_set_spread(gradient, to_plutovg_spread_methood(spread));
80+
plutovg_gradient_set_spread(gradient, to_plutovg_spread_method(spread));
8281
plutovg_gradient_set_matrix(gradient, &matrix);
83-
plutovg_set_source_gradient(pluto, gradient);
84-
plutovg_gradient_destroy(gradient);
8582
}
8683

8784
void Canvas::setTexture(const Canvas* source, TextureType type, const Transform& transform)
8885
{
89-
auto texture = plutovg_texture_create(source->surface);
86+
auto texture = plutovg_set_texture(pluto, source->surface, to_plutovg_texture_type(type));
9087
auto matrix = to_plutovg_matrix(transform);
91-
if(type == TextureType::Plain)
92-
plutovg_texture_set_type(texture, plutovg_texture_type_plain);
93-
else
94-
plutovg_texture_set_type(texture, plutovg_texture_type_tiled);
95-
9688
plutovg_texture_set_matrix(texture, &matrix);
97-
plutovg_set_source_texture(pluto, texture);
98-
plutovg_texture_destroy(texture);
9989
}
10090

10191
void Canvas::fill(const Path& path, const Transform& transform, WindRule winding, BlendMode mode, double opacity)
@@ -128,7 +118,7 @@ void Canvas::stroke(const Path& path, const Transform& transform, double width,
128118

129119
void Canvas::blend(const Canvas* source, BlendMode mode, double opacity)
130120
{
131-
plutovg_set_source_surface(pluto, source->surface, source->rect.x, source->rect.y);
121+
plutovg_set_texture_surface(pluto, source->surface, source->rect.x, source->rect.y);
132122
plutovg_set_operator(pluto, to_plutovg_operator(mode));
133123
plutovg_set_opacity(pluto, opacity);
134124
plutovg_set_matrix(pluto, &translation);
@@ -145,69 +135,23 @@ void Canvas::mask(const Rect& clip, const Transform& transform)
145135
plutovg_add_path(pluto, path);
146136
plutovg_path_destroy(path);
147137

148-
plutovg_set_source_rgba(pluto, 0, 0, 0, 0);
138+
plutovg_set_rgba(pluto, 0, 0, 0, 0);
149139
plutovg_set_fill_rule(pluto, plutovg_fill_rule_even_odd);
150140
plutovg_set_operator(pluto, plutovg_operator_src);
151141
plutovg_set_opacity(pluto, 0.0);
152142
plutovg_set_matrix(pluto, &translation);
153143
plutovg_fill(pluto);
154144
}
155145

156-
void Canvas::clear(unsigned int value)
157-
{
158-
auto r = (value >> 24) & 0xFF;
159-
auto g = (value >> 16) & 0xFF;
160-
auto b = (value >> 8) & 0xFF;
161-
auto a = (value >> 0) & 0xFF;
162-
163-
plutovg_set_source_rgba(pluto, r / 255.0, g / 255.0, b / 255.0, a / 255.0);
164-
plutovg_set_opacity(pluto, 1.0);
165-
plutovg_set_operator(pluto, plutovg_operator_src);
166-
plutovg_paint(pluto);
167-
}
168-
169-
void Canvas::rgba()
170-
{
171-
auto width = plutovg_surface_get_width(surface);
172-
auto height = plutovg_surface_get_height(surface);
173-
auto stride = plutovg_surface_get_stride(surface);
174-
auto data = plutovg_surface_get_data(surface);
175-
for(int y = 0;y < height;y++)
176-
{
177-
auto pixels = reinterpret_cast<uint32_t*>(data + stride * y);
178-
for(int x = 0;x < width;x++)
179-
{
180-
auto pixel = pixels[x];
181-
auto a = (pixel >> 24) & 0xFF;
182-
if(a == 0)
183-
continue;
184-
185-
auto r = (pixel >> 16) & 0xFF;
186-
auto g = (pixel >> 8) & 0xFF;
187-
auto b = (pixel >> 0) & 0xFF;
188-
if(a != 255)
189-
{
190-
r = (r * 255) / a;
191-
g = (g * 255) / a;
192-
b = (b * 255) / a;
193-
}
194-
195-
pixels[x] = (a << 24) | (b << 16) | (g << 8) | r;
196-
}
197-
}
198-
}
199-
200146
void Canvas::luminance()
201147
{
202148
auto width = plutovg_surface_get_width(surface);
203149
auto height = plutovg_surface_get_height(surface);
204150
auto stride = plutovg_surface_get_stride(surface);
205151
auto data = plutovg_surface_get_data(surface);
206-
for(int y = 0;y < height;y++)
207-
{
152+
for(int y = 0; y < height; y++) {
208153
auto pixels = reinterpret_cast<uint32_t*>(data + stride * y);
209-
for(int x = 0;x < width;x++)
210-
{
154+
for(int x = 0; x < width; x++) {
211155
auto pixel = pixels[x];
212156
auto r = (pixel >> 16) & 0xFF;
213157
auto g = (pixel >> 8) & 0xFF;
@@ -271,27 +215,30 @@ plutovg_line_join_t to_plutovg_line_join(LineJoin join)
271215
return join == LineJoin::Miter ? plutovg_line_join_miter : join == LineJoin::Round ? plutovg_line_join_round : plutovg_line_join_bevel;
272216
}
273217

274-
static plutovg_spread_method_t to_plutovg_spread_methood(SpreadMethod spread)
218+
static plutovg_spread_method_t to_plutovg_spread_method(SpreadMethod spread)
275219
{
276220
return spread == SpreadMethod::Pad ? plutovg_spread_method_pad : spread == SpreadMethod::Reflect ? plutovg_spread_method_reflect : plutovg_spread_method_repeat;
277221
}
278222

223+
static plutovg_texture_type_t to_plutovg_texture_type(TextureType type)
224+
{
225+
return type == TextureType::Plain ? plutovg_texture_type_plain : plutovg_texture_type_tiled;
226+
}
227+
279228
static void to_plutovg_stops(plutovg_gradient_t* gradient, const GradientStops& stops)
280229
{
281-
for(const auto& stop : stops)
282-
{
230+
for(const auto& stop : stops) {
283231
auto offset = std::get<0>(stop);
284232
auto& color = std::get<1>(stop);
285-
plutovg_gradient_add_stop_rgba(gradient, offset, color.r, color.g, color.b, color.a);
233+
plutovg_gradient_add_stop_rgba(gradient, offset, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0);
286234
}
287235
}
288236

289237
void to_plutovg_path(plutovg_t* pluto, const Path& path)
290238
{
291239
PathIterator it(path);
292240
std::array<Point, 3> p;
293-
while(!it.isDone())
294-
{
241+
while(!it.isDone()) {
295242
switch(it.currentSegment(p)) {
296243
case PathCommand::MoveTo:
297244
plutovg_move_to(pluto, p[0].x, p[0].y);

Siv3D/src/ThirdParty/lunasvg/canvas.h

+5-10
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);
@@ -52,8 +48,6 @@ class Canvas
5248
void blend(const Canvas* source, BlendMode mode, double opacity);
5349
void mask(const Rect& clip, const Transform& transform);
5450

55-
void clear(unsigned int value);
56-
void rgba();
5751
void luminance();
5852

5953
unsigned int width() const;
@@ -63,6 +57,7 @@ class Canvas
6357
Rect box() const;
6458

6559
~Canvas();
60+
6661
private:
6762
Canvas(unsigned char* data, int width, int height, int stride);
6863
Canvas(int x, int y, int width, int height);

Siv3D/src/ThirdParty/lunasvg/clippathelement.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
namespace lunasvg {
66

77
ClipPathElement::ClipPathElement()
8-
: GraphicsElement(ElementId::ClipPath)
8+
: GraphicsElement(ElementID::ClipPath)
99
{
1010
}
1111

1212
Units ClipPathElement::clipPathUnits() const
1313
{
14-
auto& value = get(PropertyId::ClipPathUnits);
14+
auto& value = get(PropertyID::ClipPathUnits);
1515
return Parser::parseUnits(value, Units::UserSpaceOnUse);
1616
}
1717

@@ -21,7 +21,7 @@ std::unique_ptr<LayoutClipPath> ClipPathElement::getClipper(LayoutContext* conte
2121
return nullptr;
2222

2323
LayoutBreaker layoutBreaker(context, this);
24-
auto clipper = std::make_unique<LayoutClipPath>();
24+
auto clipper = makeUnique<LayoutClipPath>();
2525
clipper->units = clipPathUnits();
2626
clipper->transform = transform();
2727
clipper->clipper = context->getClipper(clip_path());

Siv3D/src/ThirdParty/lunasvg/clippathelement.h

+1-2
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

Siv3D/src/ThirdParty/lunasvg/defselement.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace lunasvg {
44

55
DefsElement::DefsElement()
6-
: GraphicsElement(ElementId::Defs)
6+
: GraphicsElement(ElementID::Defs)
77
{
88
}
99

Siv3D/src/ThirdParty/lunasvg/defselement.h

+1-2
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)