File indexing completed on 2024-12-22 04:12:56

0001 /*
0002  *  SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KISMASKEDPAINTINGSTROKEDATA_H
0008 #define KISMASKEDPAINTINGSTROKEDATA_H
0009 
0010 #include "kritaui_export.h"
0011 
0012 #include <QVector>
0013 #include <QSharedPointer>
0014 
0015 class KisFreehandStrokeInfo;
0016 class KisPaintInformation;
0017 class KisDistanceInformation;
0018 class QPointF;
0019 class QRectF;
0020 class QRect;
0021 class QPainterPath;
0022 class QPen;
0023 class KoColor;
0024 class KisRunnableStrokeJobData;
0025 
0026 class KisPaintOpPreset;
0027 typedef QSharedPointer<KisPaintOpPreset> KisPaintOpPresetSP;
0028 
0029 
0030 class KRITAUI_EXPORT KisMaskedFreehandStrokePainter
0031 {
0032 public:
0033     KisMaskedFreehandStrokePainter(KisFreehandStrokeInfo *strokeData, KisFreehandStrokeInfo *maskData);
0034 
0035     // painter overrides
0036 
0037     KisPaintOpPresetSP preset() const;
0038 
0039     void paintAt(const KisPaintInformation& pi);
0040 
0041     void paintLine(const KisPaintInformation &pi1,
0042                    const KisPaintInformation &pi2);
0043 
0044     void paintBezierCurve(const KisPaintInformation &pi1,
0045                           const QPointF &control1,
0046                           const QPointF &control2,
0047                           const KisPaintInformation &pi2);
0048 
0049     void paintPolyline(const QVector<QPointF> &points,
0050                        int index = 0, int numPoints = -1);
0051 
0052     void paintPolygon(const QVector<QPointF> &points);
0053     void paintRect(const QRectF &rect);
0054     void paintEllipse(const QRectF &rect);
0055     void paintPainterPath(const QPainterPath& path);
0056 
0057     void drawPainterPath(const QPainterPath& path, const QPen& pen);
0058     void drawAndFillPainterPath(const QPainterPath& path, const QPen& pen, const KoColor &customColor);
0059 
0060     // paintop overrides
0061 
0062     std::pair<int, bool> doAsynchronousUpdate(QVector<KisRunnableStrokeJobData*> &jobs);
0063     bool hasDirtyRegion() const;
0064     QVector<QRect> takeDirtyRegion();
0065 
0066     bool hasMasking() const;
0067 
0068 private:
0069     template <class Func>
0070     inline void applyToAllPainters(Func func);
0071 
0072 private:
0073     KisFreehandStrokeInfo *m_stroke = 0;
0074     KisFreehandStrokeInfo *m_mask = 0;
0075 };
0076 
0077 #endif // KISMASKEDPAINTINGSTROKEDATA_H