File indexing completed on 2024-06-16 04:17:25
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef __KIS_DAB_CACHE_H 0008 #define __KIS_DAB_CACHE_H 0009 0010 #include "kritapaintop_export.h" 0011 0012 #include "kis_dab_cache_base.h" 0013 0014 #include "kis_brush.h" 0015 0016 class KisColorSource; 0017 class KisTextureOption; 0018 class KisPrecisionOption; 0019 struct MirrorProperties; 0020 0021 0022 /** 0023 * @brief The KisDabCache class provides caching for dabs into the brush paintop 0024 * 0025 * This class adds caching of the dabs to the paintop system of Krita. 0026 * Such cache makes the execution of the benchmarks up to 2 times faster. 0027 * Subjectively, the real painting becomes much faster, especially with 0028 * huge brushes. Artists report up to 20% speed gain while painting. 0029 * 0030 * Of course, such caching makes the painting a bit less precise: we need 0031 * to tolerate subpixel differences to allow the cache to work. Sometimes 0032 * small difference in the size of a dab can also be acceptable. That is 0033 * why I introduced levels of precision. They are graded from 1 to 5: from 0034 * the fastest and less precise to the slowest, but with the best quality. 0035 * You can see the slider in the paintop settings dialog. The ToolTip text 0036 * explains which features of the brush are sacrificed on each precision 0037 * level. 0038 * 0039 * The texturing and mirroring problems are solved. 0040 */ 0041 class PAINTOP_EXPORT KisDabCache : public KisDabCacheBase 0042 { 0043 public: 0044 KisDabCache(KisBrushSP brush); 0045 ~KisDabCache(); 0046 0047 KisFixedPaintDeviceSP fetchDab(const KoColorSpace *cs, 0048 KisColorSource *colorSource, 0049 const QPointF &cursorPoint, 0050 KisDabShape const&, 0051 const KisPaintInformation& info, 0052 qreal softnessFactor, 0053 QRect *dstDabRect, 0054 qreal lightnessStrength = 1.0); 0055 0056 KisFixedPaintDeviceSP fetchDab(const KoColorSpace *cs, 0057 const KoColor& color, 0058 const QPointF &cursorPoint, 0059 KisDabShape const&, 0060 const KisPaintInformation& info, 0061 qreal softnessFactor, 0062 QRect *dstDabRect, 0063 qreal lightnessStrength = 1.0); 0064 0065 KisFixedPaintDeviceSP fetchNormalizedImageDab(const KoColorSpace *cs, 0066 const QPointF &cursorPoint, 0067 KisDabShape const& shape, 0068 const KisPaintInformation& info, 0069 qreal softnessFactor, 0070 QRect *dstDabRect); 0071 0072 0073 void setSharpnessPostprocessing(KisSharpnessOption *option); 0074 void setTexturePostprocessing(KisTextureOption *option); 0075 0076 bool needSeparateOriginal() const; 0077 0078 private: 0079 0080 inline KisFixedPaintDeviceSP fetchFromCache(KisDabCacheUtils::DabRenderingResources *resources, const KisPaintInformation& info, 0081 QRect *dstDabRect); 0082 0083 inline KisFixedPaintDeviceSP fetchDabCommon(const KoColorSpace *cs, 0084 KisColorSource *colorSource, 0085 const KoColor& color, 0086 const QPointF &cursorPoint, 0087 KisDabShape, 0088 const KisPaintInformation& info, 0089 qreal softnessFactor, 0090 QRect *dstDabRect, 0091 qreal lightnessStrength = 1.0, 0092 bool forceNormalizedRGBAImageStamp = false); 0093 0094 private: 0095 0096 struct Private; 0097 Private * const m_d; 0098 0099 }; 0100 0101 #endif /* __KIS_DAB_CACHE_H */