#pragma once #include #include #include #include #include #include #include "stroke.hpp" namespace ZShell::internal { struct BrushEntry { QCanvasCustomBrush brush; qint64 holeToken = -1; // hole generation this brush was built with }; class StrokeCanvasRenderer final : public QCanvasPainterItemRenderer { public: void synchronizeData(QCanvasPainterItem* item) override; void paint(QCanvasPainter* painter) override; private: QCanvasCustomBrush& brushFor(const QColor& color); void updateBrushHole(); void drawStroke( QCanvasPainter* painter, const QVector& points, const QColor& color, qreal width, bool polyline); void drawHoverCursor( QCanvasPainter* painter, const QPointF& point, qreal penWidth, QColor penColor, bool isDrawing); QColor m_penColor; qreal m_penWidth = 4.0; bool m_hoverVisible = false; QPointF m_hoverPoint; bool m_isDrawing = false; QRectF m_hole; qreal m_holeRadius = 0.0; qreal m_devicePixelRatio = 1.0; QVector4D m_lastHoleData1; QVector4D m_lastHoleData3; QVector4D m_lastHoleData4; qint64 m_holeToken = 0; QVector m_strokes; Stroke m_currentStroke; QVector m_pendingGroupRemovals; QHash m_brushes; }; }; // namespace ZShell::internal