File indexing completed on 2024-05-12 15:58:35

0001 /*
0002  *  SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KISPAINTERPRIVATE_H
0008 #define KISPAINTERPRIVATE_H
0009 
0010 #include <KoColorSpace.h>
0011 #include <KoColor.h>
0012 #include <KoCompositeOpRegistry.h>
0013 #include <KoUpdater.h>
0014 #include "kis_paintop.h"
0015 #include "kis_selection.h"
0016 #include "kis_fill_painter.h"
0017 #include "kis_painter.h"
0018 #include "kis_paintop_preset.h"
0019 #include <KisFakeRunnableStrokeJobsExecutor.h>
0020 
0021 struct Q_DECL_HIDDEN KisPainter::Private {
0022     Private(KisPainter *_q) : q(_q) {}
0023     Private(KisPainter *_q, const KoColorSpace *cs)
0024         : q(_q), paintColor(cs), backgroundColor(cs) {}
0025 
0026     KisPainter *q {nullptr};
0027 
0028     KisPaintDeviceSP            device;
0029     KisSelectionSP              selection;
0030     KisTransaction*             transaction {nullptr};
0031     KoUpdater*                  progressUpdater {nullptr};
0032 
0033     QVector<QRect>              dirtyRects;
0034     KisPaintOp*                 paintOp {nullptr};
0035     KoColor                     paintColor;
0036     KoColor                     backgroundColor;
0037     KoColor                     customColor;
0038     KisFilterConfigurationSP    generator;
0039     KisPaintLayer*              sourceLayer {nullptr};
0040     FillStyle                   fillStyle {FillStyleNone};
0041     StrokeStyle                 strokeStyle {StrokeStyleBrush};
0042     bool                        antiAliasPolygonFill {true};
0043     KoPatternSP                 pattern;
0044     QPointF                     duplicateOffset;
0045     quint32                     pixelSize {0};
0046     const KoColorSpace*         colorSpace {nullptr};
0047     KoColorProfile*             profile {nullptr};
0048     const KoColorSpace*         cachedSourceColorSpace {nullptr};
0049     const KoCompositeOp*        cachedCompositeOp {nullptr};
0050     QString                     compositeOpId;
0051     KoAbstractGradientSP        gradient;
0052     KisPaintOpPresetSP          paintOpPreset;
0053     QImage                      polygonMaskImage;
0054     QPainter*                   maskPainter {nullptr};
0055     KisFillPainter*             fillPainter {nullptr};
0056     KisPaintDeviceSP            polygon;
0057     qint32                      maskImageWidth {255};
0058     qint32                      maskImageHeight {255};
0059     QPointF                     axesCenter;
0060     bool                        mirrorHorizontally {false};
0061     bool                        mirrorVertically {false};
0062     bool                        isOpacityUnit {true}; // TODO: move into ParameterInfo
0063     KoCompositeOp::ParameterInfo paramInfo;
0064     KoColorConversionTransformation::Intent renderingIntent;
0065     KoColorConversionTransformation::ConversionFlags conversionFlags;
0066     KisRunnableStrokeJobsInterface *runnableStrokeJobsInterface {nullptr};
0067     QScopedPointer<KisRunnableStrokeJobsInterface> fakeRunnableStrokeJobsInterface;
0068     QTransform                  patternTransform;
0069 
0070     const KoCompositeOp*        compositeOp(const KoColorSpace *srcCS);
0071 
0072     bool tryReduceSourceRect(const KisPaintDevice *srcDev,
0073                              QRect *srcRect,
0074                              qint32 *srcX,
0075                              qint32 *srcY,
0076                              qint32 *srcWidth,
0077                              qint32 *srcHeight,
0078                              qint32 *dstX,
0079                              qint32 *dstY);
0080 
0081     void fillPainterPathImpl(const QPainterPath& path, const QRect &requestedRect);
0082 
0083     void applyDevice(const QRect &applyRect,
0084                      const KisRenderedDab &dab,
0085                      KisRandomAccessorSP dstIt,
0086                      const KoColorSpace *srcColorSpace,
0087                      KoCompositeOp::ParameterInfo &localParamInfo);
0088 
0089     void applyDeviceWithSelection(const QRect &applyRect,
0090                                   const KisRenderedDab &dab,
0091                                   KisRandomAccessorSP dstIt,
0092                                   KisRandomConstAccessorSP maskIt,
0093                                   const KoColorSpace *srcColorSpace,
0094                                   KoCompositeOp::ParameterInfo &localParamInfo);
0095 
0096     template<class T> QVector<T> calculateMirroredObjects(const T &object);
0097 
0098 };
0099 
0100 #endif // KISPAINTERPRIVATE_H