File indexing completed on 2024-12-22 04:16:03

0001 /*
0002  *  SPDX-FileCopyrightText: 2021 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KRITA_KISCOLORSMUDGESOURCE_H
0008 #define KRITA_KISCOLORSMUDGESOURCE_H
0009 
0010 #include <QtGlobal>
0011 #include <kis_types.h>
0012 
0013 class KoColorSpace;
0014 class QRect;
0015 class KisOverlayPaintDeviceWrapper;
0016 
0017 class KisColorSmudgeSource {
0018 public:
0019     virtual ~KisColorSmudgeSource() = default;
0020     void readRect(const QRect &rect);
0021     virtual void readRects(const QVector<QRect> &rects) = 0;
0022     virtual void readBytes(quint8 *dstPtr, const QRect &rect) = 0;
0023     virtual const KoColorSpace* colorSpace() const = 0;
0024 };
0025 
0026 using KisColorSmudgeSourceSP = QSharedPointer<KisColorSmudgeSource>;
0027 
0028 struct KisColorSmudgeSourcePaintDevice : public KisColorSmudgeSource
0029 {
0030     KisColorSmudgeSourcePaintDevice(KisOverlayPaintDeviceWrapper &overlayDevice, int overlayIndex = 0);
0031 
0032     void readRects(const QVector<QRect> &rects) override;
0033 
0034     void readBytes(quint8 *dstPtr, const QRect &rect) override;
0035     const KoColorSpace* colorSpace() const override;
0036 
0037 private:
0038     KisOverlayPaintDeviceWrapper &m_overlayDevice;
0039     int m_overlayIndex = 0;
0040 };
0041 
0042 struct KisColorSmudgeSourceImage : public KisColorSmudgeSource
0043 {
0044     KisColorSmudgeSourceImage(KisImageSP image,
0045                               KisOverlayPaintDeviceWrapper &overlayDevice);
0046 
0047     void readRects(const QVector<QRect> &rects) override;
0048 
0049     void readBytes(quint8 *dstPtr, const QRect &rect) override;
0050     const KoColorSpace* colorSpace() const override;
0051 
0052 private:
0053     KisImageSP m_image;
0054     KisOverlayPaintDeviceWrapper &m_overlayDevice;
0055 };
0056 
0057 
0058 #endif //KRITA_KISCOLORSMUDGESOURCE_H