diff --git a/conan/conan-skia/recipes/skia/all/conandata.yml b/conan/conan-skia/recipes/skia/all/conandata.yml index 83a7d37..63ed90e 100644 --- a/conan/conan-skia/recipes/skia/all/conandata.yml +++ b/conan/conan-skia/recipes/skia/all/conandata.yml @@ -55,3 +55,7 @@ sources: url: - "https://github.com/google/skia/archive/f4ed99d2443962782cf5f8b4dd27179f131e7cbe.zip" sha256: "2e00dcdb54942c1da7b2f6cfd9fef8c4899115206d940931f6c040bac08b6b79" + "143.20251028.0": + url: + - "https://github.com/google/skia/archive/da51f0d60ea2b14e845a823dc11b405dbeef42d8.zip" + sha256: "1f5140d5908031d8cdd06429a633a1583b12fc43dc1c768374ed1e91ab9fa596" diff --git a/conan/conan-skia/recipes/skia/config.yml b/conan/conan-skia/recipes/skia/config.yml index ddc7bec..8051146 100644 --- a/conan/conan-skia/recipes/skia/config.yml +++ b/conan/conan-skia/recipes/skia/config.yml @@ -27,3 +27,5 @@ versions: folder: all "142.20250802.0": folder: all + "143.20251028.0": + folder: all diff --git a/conan/export_libs.bat b/conan/export_libs.bat index 4605021..c89d030 100755 --- a/conan/export_libs.bat +++ b/conan/export_libs.bat @@ -1,4 +1,4 @@ conan export %0/../libjuice/all/conanfile.py --version=1.6.1 conan export %0/../libdatachannel/all/conanfile.py --version=0.23.1 -conan export %0/../conan-skia/recipes/skia/all/conanfile.py --version=142.20250802.0 +conan export %0/../conan-skia/recipes/skia/all/conanfile.py --version=143.20251028.0 conan export %0/../sdl3/3.x/conanfile.py --version=3.2.26 diff --git a/conan/export_libs.sh b/conan/export_libs.sh index 556d6db..94df4db 100755 --- a/conan/export_libs.sh +++ b/conan/export_libs.sh @@ -5,7 +5,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) conan export "$(dirname "$0")/libjuice/all/conanfile.py" --version=1.6.1 conan export "$(dirname "$0")/libdatachannel/all/conanfile.py" --version=0.23.1 conan export "$(dirname "$0")/mpg123/all/conanfile.py" --version=1.32.10 -conan export "$(dirname "$0")/conan-skia/recipes/skia/all/conanfile.py" --version=142.20250802.0 +conan export "$(dirname "$0")/conan-skia/recipes/skia/all/conanfile.py" --version=143.20251028.0 conan export "$(dirname "$0")/sdl3/3.x/conanfile.py" --version=3.2.26 #conan create . -o use_system_expat=False -o use_system_freetype=False -o use_system_harfbuzz=False -o use_system_icu=False -o use_system_libjpeg_turbo=False -o use_system_libpng=False -o use_system_libwebp=False -o use_system_zlib=False --build=missing --version=134.20250327.0 #cd ../../../.. diff --git a/conanfile.py b/conanfile.py index 6bef3ae..10e1bfa 100644 --- a/conanfile.py +++ b/conanfile.py @@ -7,7 +7,7 @@ class CompressorRecipe(ConanFile): def requirements(self): if self.settings.os == "Emscripten": - self.requires("skia/142.20250802.0", options = { + self.requires("skia/143.20251028.0", options = { "enable_svg": True, "use_freetype": True, "use_system_freetype": True, @@ -34,7 +34,7 @@ class CompressorRecipe(ConanFile): "use_conan_libwebp": False }) else: - self.requires("skia/142.20250802.0", options = { + self.requires("skia/143.20251028.0", options = { "use_system_expat": False, "use_freetype": True, "use_system_freetype": True, diff --git a/src/DrawCollision.cpp b/src/DrawCollision.cpp index 321c555..ecf34a4 100644 --- a/src/DrawCollision.cpp +++ b/src/DrawCollision.cpp @@ -1,6 +1,7 @@ #include "DrawCollision.hpp" #include #include +#include void draw_collider(SkCanvas* canvas, const DrawData& drawData, const SCollision::AABB& aabb, const SkPaint& p) { SkRect r = SkRect::MakeLTRB(aabb.min.x(), aabb.min.y(), aabb.max.x(), aabb.max.y()); @@ -12,12 +13,12 @@ void draw_collider(SkCanvas* canvas, const DrawData& drawData, const SCollision: } void draw_collider(SkCanvas* canvas, const DrawData& drawData, const SCollision::Triangle& triangle, const SkPaint& p) { - SkPath path; + SkPathBuilder path; path.moveTo(convert_vec2(triangle.p[0])); path.lineTo(convert_vec2(triangle.p[1])); path.lineTo(convert_vec2(triangle.p[2])); path.close(); - canvas->drawPath(path, p); + canvas->drawPath(path.detach(), p); } void draw_collider(SkCanvas* canvas, const DrawData& drawData, const SCollision::ColliderCollection& collection, const SkPaint& p) { diff --git a/src/DrawComponents/DrawBrushStroke.cpp b/src/DrawComponents/DrawBrushStroke.cpp index 3d1b74b..031f743 100644 --- a/src/DrawComponents/DrawBrushStroke.cpp +++ b/src/DrawComponents/DrawBrushStroke.cpp @@ -113,13 +113,17 @@ void DrawBrushStroke::initialize_draw_data(DrawingProgram& drawP) { return false; }; - brushPath = std::make_shared(); - brushPathLOD[0] = std::make_shared(); - brushPathLOD[1] = std::make_shared(); + auto brushPathBuilder = std::make_shared(); + auto brushPathLOD0Builder = std::make_shared(); + auto brushPathLOD1Builder = std::make_shared(); - create_triangles(triangleFunc, points, 0, brushPath); - create_triangles(triangleFunc, points, 4, brushPathLOD[0]); - create_triangles(triangleFunc, points, 30, brushPathLOD[1]); + create_triangles(triangleFunc, points, 0, brushPathBuilder); + create_triangles(triangleFunc, points, 4, brushPathLOD0Builder); + create_triangles(triangleFunc, points, 30, brushPathLOD1Builder); + + brushPath = std::make_shared(brushPathBuilder->detach()); + brushPathLOD[0] = std::make_shared(brushPathLOD0Builder->detach()); + brushPathLOD[1] = std::make_shared(brushPathLOD1Builder->detach()); } create_collider(); } @@ -223,7 +227,7 @@ std::vector DrawBrushStroke::every_nth_point_include_front return toRet; } -void DrawBrushStroke::create_triangles(const std::function& passTriangleFunc, const std::vector& smoothedPoints, size_t skipVertexCount, std::shared_ptr bPath) { +void DrawBrushStroke::create_triangles(const std::function& passTriangleFunc, const std::vector& smoothedPoints, size_t skipVertexCount, std::shared_ptr bPathBuilder) { const int ARC_SMOOTHNESS = 10; const int CIRCLE_SMOOTHNESS = 20; const std::vector& pointsN = d->points; @@ -239,8 +243,8 @@ void DrawBrushStroke::create_triangles(const std::functionaddPoly({topPoints.data(), topPoints.size()}, false); + if(bPathBuilder && !topPoints.empty()) + bPathBuilder->addPolygon({topPoints.data(), topPoints.size()}, false); return; } @@ -387,9 +391,9 @@ void DrawBrushStroke::create_triangles(const std::functionaddPoly({topPoints.data(), topPoints.size()}, false); + bPathBuilder->addPolygon({topPoints.data(), topPoints.size()}, false); } } diff --git a/src/DrawComponents/DrawBrushStroke.hpp b/src/DrawComponents/DrawBrushStroke.hpp index 910888c..3a1c369 100644 --- a/src/DrawComponents/DrawBrushStroke.hpp +++ b/src/DrawComponents/DrawBrushStroke.hpp @@ -6,6 +6,7 @@ #ifndef IS_SERVER #include +#include #endif #define DRAW_MINIMUM_LIMIT 0.3 @@ -57,7 +58,7 @@ class DrawBrushStroke : public DrawComponent { void add_precheck_aabb_level(size_t level, const std::vector>& levelArray); std::vector> precheckAABBLevels; - void create_triangles(const std::function& passTriangleFunc, const std::vector& smoothedPoints, size_t skipVertexCount, std::shared_ptr bPath); + void create_triangles(const std::function& passTriangleFunc, const std::vector& smoothedPoints, size_t skipVertexCount, std::shared_ptr bPath); std::vector get_wedge_indices(const std::vector& points); std::vector smooth_points(size_t beginIndex, size_t endIndex, unsigned numOfDivisions); std::vector smooth_points_avg(size_t beginIndex, size_t endIndex, unsigned numOfDivisions); diff --git a/src/DrawComponents/DrawEllipse.cpp b/src/DrawComponents/DrawEllipse.cpp index 00709a0..19f793c 100644 --- a/src/DrawComponents/DrawEllipse.cpp +++ b/src/DrawComponents/DrawEllipse.cpp @@ -1,6 +1,7 @@ #include "DrawEllipse.hpp" #include "Helpers/ConvertVec.hpp" #include "Helpers/SCollision.hpp" +#include #ifndef IS_SERVER #include "../DrawCollision.hpp" @@ -70,9 +71,10 @@ void DrawEllipse::draw(SkCanvas* canvas, const DrawData& drawData) { } void DrawEllipse::create_draw_data() { - ellipsePath = SkPath(); + SkPathBuilder ellipsePathBuilder; SkRect newRect = SkRect::MakeLTRB(d.p1.x(), d.p1.y(), d.p2.x(), d.p2.y()); - ellipsePath.addOval(newRect); + ellipsePathBuilder.addOval(newRect); + ellipsePath = ellipsePathBuilder.detach(); } void DrawEllipse::initialize_draw_data(DrawingProgram& drawP) { diff --git a/src/DrawComponents/DrawRectangle.cpp b/src/DrawComponents/DrawRectangle.cpp index bde543e..b0ec6e7 100644 --- a/src/DrawComponents/DrawRectangle.cpp +++ b/src/DrawComponents/DrawRectangle.cpp @@ -3,6 +3,7 @@ #include "Helpers/MathExtras.hpp" #include "Helpers/SCollision.hpp" #include +#include #include "../SharedTypes.hpp" #ifndef IS_SERVER @@ -87,14 +88,16 @@ bool DrawRectangle::collides_within_coords(const SCollision::ColliderCollection< } void DrawRectangle::create_draw_data() { - rectPath = SkPath(); + SkPathBuilder rectPathBuilder; if(d.p1.x() == d.p2.x() || d.p1.y() == d.p2.y()) { - rectPath.moveTo(convert_vec2(d.p1)); - rectPath.lineTo(convert_vec2(d.p2)); + rectPathBuilder.moveTo(convert_vec2(d.p1)); + rectPathBuilder.lineTo(convert_vec2(d.p2)); + rectPath = rectPathBuilder.detach(); } else { - SkRect newRect = SkRect::MakeLTRB(d.p1.x(), d.p1.y(), d.p2.x(), d.p2.y()); - rectPath.addRoundRect(newRect, d.cornerRadius, d.cornerRadius); + SkRRect newRect = SkRRect::MakeRectXY(SkRect::MakeLTRB(d.p1.x(), d.p1.y(), d.p2.x(), d.p2.y()), d.cornerRadius, d.cornerRadius); + rectPathBuilder.addRRect(newRect); + rectPath = rectPathBuilder.detach(); } } diff --git a/src/DrawingProgram/DrawingProgramSelection.cpp b/src/DrawingProgram/DrawingProgramSelection.cpp index a468161..94f2c2b 100644 --- a/src/DrawingProgram/DrawingProgramSelection.cpp +++ b/src/DrawingProgram/DrawingProgramSelection.cpp @@ -17,6 +17,7 @@ #endif #include +#include #define ROTATION_POINT_RADIUS_MULTIPLIER 0.7f #define ROTATION_POINTS_DISTANCE 20.0f @@ -515,14 +516,14 @@ void DrawingProgramSelection::draw_components(SkCanvas* canvas, const DrawData& void DrawingProgramSelection::draw_gui(SkCanvas* canvas, const DrawData& drawData) { if(is_something_selected() && !camSpaceSelection.triangle.empty()) { - SkPath selectionRectPath; + SkPathBuilder selectionRectPath; selectionRectPath.moveTo(convert_vec2(camSpaceSelection.triangle[0].p[0])); selectionRectPath.lineTo(convert_vec2(camSpaceSelection.triangle[0].p[1])); selectionRectPath.lineTo(convert_vec2(camSpaceSelection.triangle[0].p[2])); selectionRectPath.lineTo(convert_vec2(camSpaceSelection.triangle[1].p[2])); selectionRectPath.close(); SkPaint p{SkColor4f{0.3f, 0.6f, 0.9f, 0.4f}}; - canvas->drawPath(selectionRectPath, p); + canvas->drawPath(selectionRectPath.detach(), p); if(drawP.is_actual_selection_tool(drawP.drawTool->get_type())) { if(transformOpHappening == TransformOperation::NONE || transformOpHappening == TransformOperation::ROTATE || transformOpHappening == TransformOperation::ROTATE_RELOCATE_CENTER) diff --git a/src/DrawingProgram/EraserTool.cpp b/src/DrawingProgram/EraserTool.cpp index 8f17e98..0130239 100644 --- a/src/DrawingProgram/EraserTool.cpp +++ b/src/DrawingProgram/EraserTool.cpp @@ -2,6 +2,7 @@ #include "DrawingProgram.hpp" #include "../MainProgram.hpp" #include "../DrawData.hpp" +#include EraserTool::EraserTool(DrawingProgram& initDrawP): DrawingProgramToolBase(initDrawP) @@ -81,9 +82,9 @@ void EraserTool::draw(SkCanvas* canvas, const DrawData& drawData) { linePaint.setStyle(SkPaint::kStroke_Style); linePaint.setStrokeCap(SkPaint::kRound_Cap); linePaint.setStrokeWidth(drawP.controls.relativeWidth * 2.0f); - SkPath erasePath; + SkPathBuilder erasePath; erasePath.moveTo(convert_vec2(drawData.main->input.mouse.lastPos)); erasePath.lineTo(convert_vec2(drawData.main->input.mouse.pos)); - canvas->drawPath(erasePath, linePaint); + canvas->drawPath(erasePath.detach(), linePaint); } } diff --git a/src/DrawingProgram/LassoSelectTool.cpp b/src/DrawingProgram/LassoSelectTool.cpp index 2cadaff..034d36b 100644 --- a/src/DrawingProgram/LassoSelectTool.cpp +++ b/src/DrawingProgram/LassoSelectTool.cpp @@ -9,6 +9,7 @@ #include #include "../DrawCollision.hpp" #include +#include namespace mapbox { namespace util { @@ -111,12 +112,12 @@ void LassoSelectTool::draw(SkCanvas* canvas, const DrawData& drawData) { canvas->save(); controls.coords.transform_sk_canvas(canvas, drawData); - SkPath lassoPath; + SkPathBuilder lassoPath; lassoPath.moveTo(convert_vec2(controls.lassoPoints.front())); for(Vector2f& p : controls.lassoPoints | std::views::drop(1)) lassoPath.lineTo(convert_vec2(p)); - canvas->drawPath(lassoPath, drawP.select_tool_line_paint()); + canvas->drawPath(lassoPath.detach(), drawP.select_tool_line_paint()); canvas->restore(); } diff --git a/src/DrawingProgram/ScreenshotTool.cpp b/src/DrawingProgram/ScreenshotTool.cpp index c8f5138..832cb1d 100644 --- a/src/DrawingProgram/ScreenshotTool.cpp +++ b/src/DrawingProgram/ScreenshotTool.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -491,9 +492,10 @@ void ScreenshotTool::draw(SkCanvas* canvas, const DrawData& drawData) { float y2 = std::max(controls.rectY1, controls.rectY2); SkPoint p1{x1, y1}; SkPoint p2{x2, y2}; - SkPath path1; - path1.addRect(p1.x(), p1.y(), p2.x(), p2.y()); - path1.setFillType(SkPathFillType::kInverseWinding); + SkPathBuilder path1B; + path1B.addRect(SkRect::MakeLTRB(p1.x(), p1.y(), p2.x(), p2.y())); + path1B.setFillType(SkPathFillType::kInverseWinding); + SkPath path1 = path1B.detach(); SkPaint paint1; paint1.setColor4f({0.0f, 0.0f, 0.0f, 0.3f}); canvas->drawPath(path1, paint1); diff --git a/src/FontData.cpp b/src/FontData.cpp index bd73ce5..047dc82 100644 --- a/src/FontData.cpp +++ b/src/FontData.cpp @@ -5,12 +5,7 @@ #include #include -#ifdef __EMSCRIPTEN__ -#elif _WIN32 - #include -#elif __APPLE__ - #include -#elif __linux__ +#ifndef __EMSCRIPTEN__ #include #include #endif @@ -21,14 +16,8 @@ FontData::FontData() { #ifdef __EMSCRIPTEN__ localFontMgr = SkFontMgr_New_Custom_Empty(); -#elif _WIN32 - localFontMgr = SkFontMgr_New_GDI(); -#elif __APPLE__ - localFontMgr = SkFontMgr_New_Custom_Empty(); -#elif __linux__ - localFontMgr = SkFontMgr_New_FontConfig(nullptr, SkFontScanner_Make_FreeType()); #else - localFontMgr = SkFontMgr_New_Custom_Empty(); + localFontMgr = SkFontMgr_New_FontConfig(nullptr, SkFontScanner_Make_FreeType()); #endif defaultFontMgr = SkFontMgr_New_Custom_Directory("data/fonts"); diff --git a/src/GUIStuff/Elements/CheckBox.cpp b/src/GUIStuff/Elements/CheckBox.cpp index 2abd592..1a256ab 100644 --- a/src/GUIStuff/Elements/CheckBox.cpp +++ b/src/GUIStuff/Elements/CheckBox.cpp @@ -1,5 +1,6 @@ #include "CheckBox.hpp" #include +#include #include namespace GUIStuff { @@ -53,7 +54,7 @@ void CheckBox::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderComma checkP.setStrokeCap(SkPaint::kRound_Cap); checkP.setStrokeJoin(SkPaint::kRound_Join); - SkPath checkPath; + SkPathBuilder checkPathB; Vector2f checkP1{(4.5/17.0) - 0.5, (8.5/17.0) - 0.5}; Vector2f checkP2{(7.5/17.0) - 0.5, (12.0/17.0) - 0.5}; Vector2f checkP3{(12.5/17.0) - 0.5, (6.0/17.0) - 0.5}; @@ -75,11 +76,12 @@ void CheckBox::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderComma points[3] = lerp_vec(checkP2, rectP4, lerpTime2); points[4] = points[0]; - checkPath.moveTo(points[0].x(), points[0].y()); + checkPathB.moveTo(points[0].x(), points[0].y()); for(unsigned i = 1; i < 5; i++) - checkPath.lineTo(points[i].x(), points[i].y()); - checkPath.close(); + checkPathB.lineTo(points[i].x(), points[i].y()); + checkPathB.close(); + SkPath checkPath = checkPathB.detach(); canvas->drawPath(checkPath, checkP); checkP.setStyle(SkPaint::kStroke_Style); canvas->drawPath(checkPath, checkP); diff --git a/src/GUIStuff/Elements/PaintCircleMenu.cpp b/src/GUIStuff/Elements/PaintCircleMenu.cpp index fed062f..130aa2a 100644 --- a/src/GUIStuff/Elements/PaintCircleMenu.cpp +++ b/src/GUIStuff/Elements/PaintCircleMenu.cpp @@ -1,5 +1,6 @@ #include "PaintCircleMenu.hpp" #include "Helpers/ConvertVec.hpp" +#include namespace GUIStuff { @@ -150,7 +151,7 @@ void PaintCircleMenu::draw_palette_bar(SkCanvas* canvas, UpdateInputData& io) { SkRect startOval = SkRect::MakeLTRB(-PALETTE_START, -PALETTE_START, PALETTE_START, PALETTE_START); SkRect endOval = SkRect::MakeLTRB(-ROTATE_START, -ROTATE_START, ROTATE_START, ROTATE_START); if(colorBarSelect.hovered) { - SkPath selectionPath; + SkPathBuilder selectionPathBuilder; double angleStart = colorSelectionIndex * colorDistribution; double angleEnd = (colorSelectionIndex + 1) * colorDistribution; Vector2f lineDir1{std::cos(angleStart), std::sin(angleStart)}; @@ -159,17 +160,17 @@ void PaintCircleMenu::draw_palette_bar(SkCanvas* canvas, UpdateInputData& io) { lineP.setStrokeWidth(5.0f); lineP.setStroke(true); lineP.setStrokeJoin(SkPaint::kRound_Join); - selectionPath.moveTo(lineDir1.x() * PALETTE_START, lineDir1.y() * PALETTE_START); - selectionPath.lineTo(lineDir1.x() * ROTATE_START, lineDir1.y() * ROTATE_START); - selectionPath.arcTo(endOval, angleStart * 180.0 / std::numbers::pi, (angleEnd - angleStart) * 180.0 / std::numbers::pi, false); - selectionPath.lineTo(lineDir2.x() * PALETTE_START, lineDir2.y() * PALETTE_START); - selectionPath.arcTo(startOval, angleEnd * 180.0 / std::numbers::pi, (angleStart - angleEnd) * 180.0 / std::numbers::pi, false); - selectionPath.close(); - canvas->drawPath(selectionPath, lineP); + selectionPathBuilder.moveTo(lineDir1.x() * PALETTE_START, lineDir1.y() * PALETTE_START); + selectionPathBuilder.lineTo(lineDir1.x() * ROTATE_START, lineDir1.y() * ROTATE_START); + selectionPathBuilder.arcTo(endOval, angleStart * 180.0 / std::numbers::pi, (angleEnd - angleStart) * 180.0 / std::numbers::pi, false); + selectionPathBuilder.lineTo(lineDir2.x() * PALETTE_START, lineDir2.y() * PALETTE_START); + selectionPathBuilder.arcTo(startOval, angleEnd * 180.0 / std::numbers::pi, (angleStart - angleEnd) * 180.0 / std::numbers::pi, false); + selectionPathBuilder.close(); + canvas->drawPath(selectionPathBuilder.detach(), lineP); } for(unsigned i = 0; i < d.palette.size(); i++) { if(d.palette[i].x() == d.selectedColor->x() && d.palette[i].y() == d.selectedColor->y() && d.palette[i].z() == d.selectedColor->z()) { - SkPath selectionPath; + SkPathBuilder selectionPathBuilder; double angleStart = i * colorDistribution; double angleEnd = (i + 1) * colorDistribution; Vector2f lineDir1{std::cos(angleStart), std::sin(angleStart)}; @@ -178,13 +179,13 @@ void PaintCircleMenu::draw_palette_bar(SkCanvas* canvas, UpdateInputData& io) { lineP.setStrokeWidth(5.0f); lineP.setStroke(true); lineP.setStrokeJoin(SkPaint::kRound_Join); - selectionPath.moveTo(lineDir1.x() * PALETTE_START, lineDir1.y() * PALETTE_START); - selectionPath.lineTo(lineDir1.x() * ROTATE_START, lineDir1.y() * ROTATE_START); - selectionPath.arcTo(endOval, angleStart * 180.0 / std::numbers::pi, (angleEnd - angleStart) * 180.0 / std::numbers::pi, false); - selectionPath.lineTo(lineDir2.x() * PALETTE_START, lineDir2.y() * PALETTE_START); - selectionPath.arcTo(startOval, angleEnd * 180.0 / std::numbers::pi, (angleStart - angleEnd) * 180.0 / std::numbers::pi, false); - selectionPath.close(); - canvas->drawPath(selectionPath, lineP); + selectionPathBuilder.moveTo(lineDir1.x() * PALETTE_START, lineDir1.y() * PALETTE_START); + selectionPathBuilder.lineTo(lineDir1.x() * ROTATE_START, lineDir1.y() * ROTATE_START); + selectionPathBuilder.arcTo(endOval, angleStart * 180.0 / std::numbers::pi, (angleEnd - angleStart) * 180.0 / std::numbers::pi, false); + selectionPathBuilder.lineTo(lineDir2.x() * PALETTE_START, lineDir2.y() * PALETTE_START); + selectionPathBuilder.arcTo(startOval, angleEnd * 180.0 / std::numbers::pi, (angleStart - angleEnd) * 180.0 / std::numbers::pi, false); + selectionPathBuilder.close(); + canvas->drawPath(selectionPathBuilder.detach(), lineP); break; } } diff --git a/src/GUIStuff/GUIManager.cpp b/src/GUIStuff/GUIManager.cpp index 3ebbd9e..e83f6a3 100644 --- a/src/GUIStuff/GUIManager.cpp +++ b/src/GUIStuff/GUIManager.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "Elements/SVGIcon.hpp" #include "Elements/FontPicker.hpp" #include "Elements/SelectableButton.hpp" @@ -139,75 +140,75 @@ void GUIManager::draw(SkCanvas* canvas) { float halfLineWidth = 0.0f; // Top Left corner if (config->cornerRadius.topLeft > 0.0f) { - SkPath path; + SkPathBuilder path; float lineWidth = config->width.top; p.setStrokeWidth(lineWidth); path.moveTo(bb.x + halfLineWidth, bb.y + config->cornerRadius.topLeft + halfLineWidth); - path.arcTo((bb.x + halfLineWidth), (bb.y + halfLineWidth), (bb.x + config->cornerRadius.topLeft + halfLineWidth), (bb.y + halfLineWidth), config->cornerRadius.topLeft); - canvas->drawPath(path, p); + path.arcTo(SkPoint{(bb.x + halfLineWidth), (bb.y + halfLineWidth)}, SkPoint{(bb.x + config->cornerRadius.topLeft + halfLineWidth), (bb.y + halfLineWidth)}, config->cornerRadius.topLeft); + canvas->drawPath(path.detach(), p); } // Top border if (config->width.top > 0.0f) { - SkPath path; + SkPathBuilder path; float lineWidth = config->width.top; p.setStrokeWidth(lineWidth); path.moveTo((bb.x + config->cornerRadius.topLeft + halfLineWidth), (bb.y + halfLineWidth)); path.lineTo((bb.x + bb.width - config->cornerRadius.topRight - halfLineWidth), (bb.y + halfLineWidth)); - canvas->drawPath(path, p); + canvas->drawPath(path.detach(), p); } // Top Right Corner if (config->cornerRadius.topRight > 0.0f) { - SkPath path; + SkPathBuilder path; float lineWidth = config->width.top; p.setStrokeWidth(lineWidth); path.moveTo((bb.x + bb.width - config->cornerRadius.topRight - halfLineWidth), (bb.y + halfLineWidth)); - path.arcTo((bb.x + bb.width - halfLineWidth), (bb.y + halfLineWidth), (bb.x + bb.width - halfLineWidth), (bb.y + config->cornerRadius.topRight + halfLineWidth), config->cornerRadius.topRight); - canvas->drawPath(path, p); + path.arcTo(SkPoint{(bb.x + bb.width - halfLineWidth), (bb.y + halfLineWidth)}, SkPoint{(bb.x + bb.width - halfLineWidth), (bb.y + config->cornerRadius.topRight + halfLineWidth)}, config->cornerRadius.topRight); + canvas->drawPath(path.detach(), p); } // Right border if (config->width.right > 0.0f) { - SkPath path; + SkPathBuilder path; float lineWidth = config->width.right; p.setStrokeWidth(lineWidth); path.moveTo((bb.x + bb.width - halfLineWidth), (bb.y + config->cornerRadius.topRight + halfLineWidth)); path.lineTo((bb.x + bb.width - halfLineWidth), (bb.y + bb.height - config->cornerRadius.bottomRight - halfLineWidth)); - canvas->drawPath(path, p); + canvas->drawPath(path.detach(), p); } // Bottom Right Corner if (config->cornerRadius.bottomRight > 0.0f) { - SkPath path; + SkPathBuilder path; float lineWidth = config->width.bottom; p.setStrokeWidth(lineWidth); path.moveTo((bb.x + bb.width - halfLineWidth), (bb.y + bb.height - config->cornerRadius.bottomRight - halfLineWidth)); - path.arcTo((bb.x + bb.width - halfLineWidth), (bb.y + bb.height - halfLineWidth), (bb.x + bb.width - config->cornerRadius.bottomRight - halfLineWidth), (bb.y + bb.height - halfLineWidth), config->cornerRadius.bottomRight); - canvas->drawPath(path, p); + path.arcTo(SkPoint{(bb.x + bb.width - halfLineWidth), (bb.y + bb.height - halfLineWidth)}, SkPoint{(bb.x + bb.width - config->cornerRadius.bottomRight - halfLineWidth), (bb.y + bb.height - halfLineWidth)}, config->cornerRadius.bottomRight); + canvas->drawPath(path.detach(), p); } // Bottom Border if (config->width.bottom > 0.0f) { - SkPath path; + SkPathBuilder path; float lineWidth = config->width.bottom; p.setStrokeWidth(lineWidth); path.moveTo((bb.x + config->cornerRadius.bottomLeft + halfLineWidth), (bb.y + bb.height - halfLineWidth)); path.lineTo((bb.x + bb.width - config->cornerRadius.bottomRight - halfLineWidth), (bb.y + bb.height - halfLineWidth)); - canvas->drawPath(path, p); + canvas->drawPath(path.detach(), p); } // Bottom Left Corner if (config->cornerRadius.bottomLeft > 0.0f) { - SkPath path; + SkPathBuilder path; float lineWidth = config->width.bottom; p.setStrokeWidth(lineWidth); path.moveTo((bb.x + config->cornerRadius.bottomLeft + halfLineWidth), (bb.y + bb.height - halfLineWidth)); - path.arcTo((bb.x + halfLineWidth), (bb.y + bb.height - halfLineWidth), (bb.x + halfLineWidth), (bb.y + bb.height - config->cornerRadius.bottomLeft - halfLineWidth), config->cornerRadius.bottomLeft); - canvas->drawPath(path, p); + path.arcTo(SkPoint{(bb.x + halfLineWidth), (bb.y + bb.height - halfLineWidth)}, SkPoint{(bb.x + halfLineWidth), (bb.y + bb.height - config->cornerRadius.bottomLeft - halfLineWidth)}, config->cornerRadius.bottomLeft); + canvas->drawPath(path.detach(), p); } // Left Border if (config->width.left > 0.0f) { - SkPath path; + SkPathBuilder path; float lineWidth = config->width.left; p.setStrokeWidth(lineWidth); path.moveTo((bb.x + halfLineWidth), (bb.y + bb.height - config->cornerRadius.bottomLeft - halfLineWidth)); path.lineTo((bb.x + halfLineWidth), (bb.y + config->cornerRadius.topRight + halfLineWidth)); - canvas->drawPath(path, p); + canvas->drawPath(path.detach(), p); } break; } diff --git a/src/WorldGrid.cpp b/src/WorldGrid.cpp index 474b049..9eb17ca 100644 --- a/src/WorldGrid.cpp +++ b/src/WorldGrid.cpp @@ -3,6 +3,7 @@ #include "Helpers/MathExtras.hpp" #include "MainProgram.hpp" #include +#include sk_sp WorldGrid::circlePointEffect; sk_sp WorldGrid::squarePointEffect; @@ -313,13 +314,13 @@ void WorldGrid::draw(GridManager& gMan, SkCanvas* canvas, const DrawData& drawDa Vector2f b2 = drawData.cam.c.to_space(b.top_right()); Vector2f b3 = drawData.cam.c.to_space(b.max); Vector2f b4 = drawData.cam.c.to_space(b.bottom_left()); - SkPath clipPath; + SkPathBuilder clipPath; clipPath.moveTo(b1.x(), b1.y()); clipPath.lineTo(b2.x(), b2.y()); clipPath.lineTo(b3.x(), b3.y()); clipPath.lineTo(b4.x(), b4.y()); clipPath.close(); - canvas->clipPath(clipPath); + canvas->clipPath(clipPath.detach()); } canvas->rotate(-drawData.cam.c.rotation * 180.0 / std::numbers::pi); canvas->drawPaint(linePaint);