|
Krita Source Code Documentation
|
The KisDabCacheBase class provides caching for dabs into the brush paintop. More...
#include <kis_dab_cache_base.h>
Inheritance diagram for KisDabCacheBase:Classes | |
| struct | DabPosition |
| struct | Private |
| struct | SavedDabParameters |
Public Member Functions | |
| void | disableSubpixelPrecision () |
| KisDabCacheBase () | |
| bool | needSeparateOriginal (KisTextureOption *textureOption, KisSharpnessOption *sharpnessOption) const |
| void | setMirrorPostprocessing (KisMirrorOption *option) |
| void | setPrecisionOption (KisPrecisionOption *option) |
| ~KisDabCacheBase () | |
Protected Member Functions | |
| void | fetchDabGenerationInfo (bool hasDabInCache, KisDabCacheUtils::DabRenderingResources *resources, const KisDabCacheUtils::DabRequestInfo &request, KisDabCacheUtils::DabGenerationInfo *di, bool *shouldUseCache) |
Private Member Functions | |
| KisDabCacheBase::DabPosition | calculateDabRect (KisBrushSP brush, const QPointF &cursorPoint, KisDabShape, const KisPaintInformation &info, const MirrorProperties &mirrorProperties, KisSharpnessOption *sharpnessOption) |
| SavedDabParameters | getDabParameters (KisBrushSP brush, const KoColor &color, KisDabShape const &, const KisPaintInformation &info, double subPixelX, double subPixelY, qreal softnessFactor, qreal lightnessStrength, MirrorProperties mirrorProperties) |
Private Attributes | |
| Private *const | m_d |
The KisDabCacheBase class provides caching for dabs into the brush paintop.
This class adds caching of the dabs to the paintop system of Krita. Such cache makes the execution of the benchmarks up to 2 times faster. Subjectively, the real painting becomes much faster, especially with huge brushes. Artists report up to 20% speed gain while painting.
Of course, such caching makes the painting a bit less precise: we need to tolerate subpixel differences to allow the cache to work. Sometimes small difference in the size of a dab can also be acceptable. That is why I introduced levels of precision. They are graded from 1 to 5: from the fastest and less precise to the slowest, but with the best quality. You can see the slider in the paintop settings dialog. The ToolTip text explains which features of the brush are sacrificed on each precision level.
The texturing and mirroring problems are solved.
Definition at line 42 of file kis_dab_cache_base.h.
| KisDabCacheBase::KisDabCacheBase | ( | ) |
Definition at line 90 of file kis_dab_cache_base.cpp.
| KisDabCacheBase::~KisDabCacheBase | ( | ) |
|
inlineprivate |
Definition at line 173 of file kis_dab_cache_base.cpp.
References KisSharpnessOption::apply(), MirrorProperties::coordinateSystemFlipped, MirrorProperties::horizontalMirror, m_d, M_PI, KisDabCacheBase::Private::positiveFraction(), KisDabShape::ratio(), KisDabShape::rotation(), KisDabShape::scale(), KisPaintOp::splitCoordinate(), KisDabCacheBase::Private::subPixelPrecisionDisabled, and MirrorProperties::verticalMirror.
| void KisDabCacheBase::disableSubpixelPrecision | ( | ) |
Disables handling of the subPixelX and subPixelY values, this is needed at least for the Color Smudge paint op, which reads aligned areas from image, so additional offsets generated by the subpixel precision should be avoided
Definition at line 110 of file kis_dab_cache_base.cpp.
References m_d, and KisDabCacheBase::Private::subPixelPrecisionDisabled.
|
protected |
Fetches all the necessary information for dab generation and tells if the caller must should reuse the preciously returned dab. * Please note that KisDabCacheBase has an internal state, that keeps the parameters of the previously generated (on a cache-miss) dab. This function automatically updates this state when 'shouldUseCache == false'. Therefore, the caller must generate the dab if and only if when 'shouldUseCache == false'. Otherwise the internal state will become inconsistent.
| hasDabInCache | shows if the caller has something in its cache |
| resources | rendering resources available for this dab |
| request | the request information |
| di | (OUT) calculated dab generation information |
| shouldUseCache | (OUT) shows whether the caller must use cache or not |
Definition at line 231 of file kis_dab_cache_base.cpp.
References KisMirrorOption::apply(), KisDabCacheUtils::DabRenderingResources::brush, calculateDabRect(), KisDabCacheUtils::DabRenderingResources::colorSource, KisDabCacheBase::SavedDabParameters::compare(), KisDabCacheUtils::DabGenerationInfo::dstDabRect, KisPrecisionOption::effectivePrecisionLevel(), getDabParameters(), KisDabCacheBase::SavedDabParameters::height, KisDabCacheUtils::DabGenerationInfo::info, KisDabCacheBase::Private::lastSavedDabParameters, KisDabCacheUtils::DabGenerationInfo::lightnessStrength, m_d, KisDabCacheBase::Private::mirrorOption, KisDabCacheUtils::DabGenerationInfo::mirrorProperties, needSeparateOriginal(), KisDabCacheUtils::DabGenerationInfo::needsPostprocessing, KisDabCacheUtils::DabGenerationInfo::paintColor, KisDabCacheBase::Private::precisionOption, KisDabCacheBase::DabPosition::realAngle, KisDabCacheBase::DabPosition::rect, KisDabCacheUtils::DabGenerationInfo::shape, KisDabCacheUtils::DabRenderingResources::sharpnessOption, KisDabCacheUtils::DabGenerationInfo::softnessFactor, KisDabCacheUtils::DabGenerationInfo::solidColorFill, KisDabCacheBase::DabPosition::subPixel, KisDabCacheUtils::DabGenerationInfo::subPixel, KisDabCacheUtils::DabRenderingResources::textureOption, KisUniformColorSource::uniformColor(), and KisDabCacheBase::SavedDabParameters::width.
|
inlineprivate |
Definition at line 116 of file kis_dab_cache_base.cpp.
References KisDabCacheBase::SavedDabParameters::angle, KisDabCacheBase::SavedDabParameters::color, KisDabCacheBase::SavedDabParameters::height, KisDabCacheBase::SavedDabParameters::index, KisDabCacheBase::SavedDabParameters::lightnessStrength, KisDabCacheBase::SavedDabParameters::mirrorProperties, KisDabShape::ratio(), KisDabCacheBase::SavedDabParameters::ratio, KisDabShape::rotation(), KisDabCacheBase::SavedDabParameters::softnessFactor, KisDabCacheBase::SavedDabParameters::subPixelX, KisDabCacheBase::SavedDabParameters::subPixelY, and KisDabCacheBase::SavedDabParameters::width.
| bool KisDabCacheBase::needSeparateOriginal | ( | KisTextureOption * | textureOption, |
| KisSharpnessOption * | sharpnessOption ) const |
Return true if the dab needs postprocessing by special options like 'texture' or 'sharpness'
Definition at line 142 of file kis_dab_cache_base.cpp.
References KisCurveOption::isChecked(), and KisTextureOption::m_enabled.
| void KisDabCacheBase::setMirrorPostprocessing | ( | KisMirrorOption * | option | ) |
Definition at line 100 of file kis_dab_cache_base.cpp.
References m_d, and KisDabCacheBase::Private::mirrorOption.
| void KisDabCacheBase::setPrecisionOption | ( | KisPrecisionOption * | option | ) |
Definition at line 105 of file kis_dab_cache_base.cpp.
References m_d, and KisDabCacheBase::Private::precisionOption.
|
private |
Definition at line 109 of file kis_dab_cache_base.h.