/* * InfiniPaint * Copyright (C) 2025-2026 Yousef Khadadeh * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include "BrushComponentCode.hpp" #include "CanvasComponent.hpp" #include "Helpers/SCollision.hpp" #include #include #include class MeshCanvasComponent : public CanvasComponent { public: virtual CanvasComponentType get_type() const override; virtual void save(cereal::PortableBinaryOutputArchive& a) const override; virtual void load(cereal::PortableBinaryInputArchive& a) override; virtual void save_file(cereal::PortableBinaryOutputArchive& a) const override; virtual void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) override; virtual std::unique_ptr get_data_copy() const override; virtual void change_stroke_color(const Vector4f& newStrokeColor) override; virtual std::vector attempt_split(DrawingProgram& drawP) const override; virtual std::optional get_stroke_color() const override; virtual void set_data_from(const CanvasComponent& other) override; virtual void simplify_paths() override; struct Data { SkPath meshPath; Vector4f color; } d; private: virtual void draw(SkCanvas* canvas, const DrawData& drawData, const std::shared_ptr& predrawData) const override; virtual bool accurate_draw(SkCanvas* canvas, const DrawData& drawData, const CoordSpaceHelper& coords, const std::shared_ptr& predrawData) const override; virtual std::shared_ptr get_predraw_data_accurate(const DrawData& drawData, const CoordSpaceHelper& coords) const override; virtual void initialize_draw_data(DrawingProgram& drawP) override; virtual bool collides_within_coords_point(const Vector2f& checkAgainst) const override; virtual bool collides_within_coords_skpath(const SkPath& checkAgainst) const override; virtual bool can_erase_detail() const override; virtual CanvasComponentEraseDetailResult erase_detail(const SkPath& eraseAgainst) override; bool should_draw_extra(const DrawData& drawData, const CoordSpaceHelper& coords) const override; virtual SCollision::AABB get_obj_coord_bounds() const override; SCollision::BVHContainer collisionTree; };