File indexing completed on 2025-01-26 04:11:17
0001 /* 0002 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org> 0003 * SPDX-FileCopyrightText: 2004-2008 Boudewijn Rempt <boud@valdyas.org> 0004 * SPDX-FileCopyrightText: 2004 Clarence Dang <dang@kde.org> 0005 * SPDX-FileCopyrightText: 2004 Adrian Page <adrian@pagenet.plus.com> 0006 * SPDX-FileCopyrightText: 2004 Cyrille Berger <cberger@cberger.net> 0007 * 0008 * SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #ifndef KIS_BRUSHOP_H_ 0012 #define KIS_BRUSHOP_H_ 0013 0014 #include "kis_brush_based_paintop.h" 0015 #include <kis_brush_based_paintop_settings.h> 0016 #include <KisStandardOptions.h> 0017 #include <KisAirbrushOptionData.h> 0018 #include <KisSpacingOption.h> 0019 #include <KisScatterOption.h> 0020 #include <KisSharpnessOption.h> 0021 #include <KisRotationOption.h> 0022 #include <KisFlowOpacityOption.h> 0023 0024 #include <KisRollingMeanAccumulatorWrapper.h> 0025 0026 #include <QElapsedTimer> 0027 0028 class KisPainter; 0029 class KisColorSource; 0030 class KisDabRenderingExecutor; 0031 struct KisRenderedDab; 0032 class KisRunnableStrokeJobData; 0033 0034 class KisBrushOp : public KisBrushBasedPaintOp 0035 { 0036 0037 public: 0038 0039 KisBrushOp(const KisPaintOpSettingsSP settings, KisPainter * painter, KisNodeSP node, KisImageSP image); 0040 ~KisBrushOp() override; 0041 0042 void paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance) override; 0043 0044 std::pair<int, bool> doAsynchronousUpdate(QVector<KisRunnableStrokeJobData *> &jobs) override; 0045 0046 protected: 0047 KisSpacingInformation paintAt(const KisPaintInformation& info) override; 0048 0049 KisSpacingInformation updateSpacingImpl(const KisPaintInformation &info) const override; 0050 0051 KisTimingInformation updateTimingImpl(const KisPaintInformation &info) const override; 0052 0053 struct UpdateSharedState; 0054 typedef QSharedPointer<UpdateSharedState> UpdateSharedStateSP; 0055 0056 void addMirroringJobs(Qt::Orientation direction, 0057 QVector<QRect> &rects, 0058 UpdateSharedStateSP state, 0059 QVector<KisRunnableStrokeJobData*> &jobs); 0060 0061 UpdateSharedStateSP m_updateSharedState; 0062 0063 0064 private: 0065 KisAirbrushOptionData m_airbrushData; 0066 0067 KisSizeOption m_sizeOption; 0068 KisRatioOption m_ratioOption; 0069 KisRateOption m_rateOption; 0070 KisSoftnessOption m_softnessOption; 0071 KisLightnessStrengthOption m_lightnessStrengthOption; 0072 KisSpacingOption m_spacingOption; 0073 KisScatterOption m_scatterOption; 0074 KisSharpnessOption m_sharpnessOption; 0075 KisRotationOption m_rotationOption; 0076 KisFlowOpacityOption2 m_opacityOption; 0077 0078 0079 KisPaintDeviceSP m_lineCacheDevice; 0080 0081 QScopedPointer<KisDabRenderingExecutor> m_dabExecutor; 0082 qreal m_currentUpdatePeriod = 20.0; 0083 KisRollingMeanAccumulatorWrapper m_avgSpacing; 0084 KisRollingMeanAccumulatorWrapper m_avgNumDabs; 0085 KisRollingMeanAccumulatorWrapper m_avgUpdateTimePerDab; 0086 0087 const int m_idealNumRects; 0088 0089 const int m_minUpdatePeriod; 0090 const int m_maxUpdatePeriod; 0091 }; 0092 0093 #endif // KIS_BRUSHOP_H_