17#include <klocalizedstring.h>
47 KisBrushTextureFlags flags)
49 , m_levelOfDetail(levelOfDetail)
50 , m_strengthOption(setting)
53 fillProperties(setting, resourcesInterface, canvasResourcesInterface);
80 bool additionalInvert =
false;
91 if (!
m_maskInfo->fillProperties(setting, resourcesInterface, additionalInvert)) {
92 warnKrita <<
"WARNING: Couldn't load the pattern for a stroke (KisTextureProperties)";
179 const QRect maskBounds =
m_maskInfo->maskBounds();
184 int x = offset.x() % maskBounds.width() -
m_offsetX;
185 int y = offset.y() % maskBounds.height() -
m_offsetY;
187 const QRect maskPatchRect = QRect(x, y,
rect.width(),
rect.height());
192 fillMaskPainter.
end();
195 quint8* dabData = dab->
data();
212 const QRect maskBounds =
m_maskInfo->maskBounds();
218 int x = offset.x() % maskBounds.width() -
m_offsetX;
219 int y = offset.y() % maskBounds.height() -
m_offsetY;
221 const QRect maskPatchRect = QRect(x, y,
rect.width(),
rect.height());
229 quint8* dabData = dab->
data();
233 qint16 colorWeights[2];
234 colorWeights[0] = qRound(pressure * 255);
235 colorWeights[1] = 255 - colorWeights[0];
240 for (
int row = 0; row <
rect.height(); ++row) {
241 for (
int col = 0; col <
rect.width(); ++col) {
243 const QRgb* maskQRgb =
reinterpret_cast<const QRgb*
>(iter->oldRawData());
244 qreal gradientvalue = qreal(qGray(*maskQRgb))/255.0;
247 qreal paintOpacity = paintcolor.
opacityF() * (qreal(qAlpha(*maskQRgb)) / 255.0);
249 colors[0] = paintcolor.
data();
251 colors[1] = dabColor.
data();
252 colorMix->
mixColors(colors, colorWeights, 2, dabData);
277 const QRect maskBounds =
m_maskInfo->maskBounds();
282 int x = offset.x() % maskBounds.width() -
m_offsetX;
283 int y = offset.y() % maskBounds.height() -
m_offsetY;
285 const QRect maskPatchRect = QRect(x, y,
rect.width(),
rect.height());
297 int alphaChannelOffset = -1;
300 for (quint32 i = 0; i < dab->
pixelSize(); i++) {
303 alphaChannelOffset = channels[i]->pos();
304 alphaChannelType = channels[i]->channelValueType();
310 alphaChannelOffset = 0;
313 QScopedPointer<KisMaskingBrushCompositeOpBase> compositeOp;
314 QString compositeOpId;
334 compositeOpId, alphaChannelType, dab->
pixelSize(),
339 quint8 *dabIt =
nullptr;
342 qint32 dabY = dab->
bounds().y();
343 qint32 maskPatchY = maskPatchRect.y();
344 qint32 rowsRemaining = dab->
bounds().height();
347 while (rowsRemaining > 0) {
348 qint32 dabX = dab->
bounds().x();
349 qint32 maskPatchX = maskPatchRect.x();
350 const qint32 numContiguousMaskPatchRows = maskPatchIt->
numContiguousRows(maskPatchY);
351 const qint32 rows = std::min(rowsRemaining, numContiguousMaskPatchRows);
352 qint32 columnsRemaining = dab->
bounds().width();
354 while (columnsRemaining > 0) {
356 const qint32 columns = std::min(columnsRemaining, numContiguousMaskPatchColumns);
358 const qint32 maskPatchRowStride = maskPatchIt->
rowStride(maskPatchX, maskPatchY);
361 maskPatchIt->
moveTo(maskPatchX, maskPatchY);
363 compositeOp->composite(maskPatchIt->
rawDataConst(), maskPatchRowStride,
368 maskPatchX += columns;
369 columnsRemaining -= columns;
375 rowsRemaining -= rows;
const QString COMPOSITE_OVER
const QString COMPOSITE_COPY
const QString COMPOSITE_DARKEN
const QString COMPOSITE_OVERLAY
const QString COMPOSITE_DODGE
const QString COMPOSITE_LINEAR_BURN
const QString COMPOSITE_MULT
const QString COMPOSITE_ERASE
const QString COMPOSITE_SUBTRACT
const QString COMPOSITE_BURN
const QString COMPOSITE_LINEAR_DODGE
const QString COMPOSITE_HARD_MIX_SOFTER_PHOTOSHOP
const QString COMPOSITE_HARD_MIX_PHOTOSHOP
virtual const quint8 * rawDataConst() const =0
KoResourceLoadResult loadLinkedPattern(KisResourcesInterfaceSP resourcesInterface) const
void fillRect(qint32 x, qint32 y, qint32 w, qint32 h, const KoColor &c, quint8 opacity)
quint32 pixelSize() const
const KoColorSpace * colorSpace() const
static KisMaskingBrushCompositeOpBase * createForAlphaSrc(const QString &id, KoChannelInfo::enumChannelValueType channelType, int pixelSize, int alphaOffset)
KisRandomConstAccessorSP createRandomConstAccessorNG() const
KisHLineIteratorSP createHLineIteratorNG(qint32 x, qint32 y, qint32 w)
void setCompositeOpId(const KoCompositeOp *op)
virtual qint32 rowStride(qint32 x, qint32 y) const =0
virtual qint32 numContiguousRows(qint32 y) const =0
virtual void moveTo(qint32 x, qint32 y)=0
virtual qint32 numContiguousColumns(qint32 x) const =0
ALWAYS_INLINE const quint8 * oldRawData() const
qreal apply(const KisPaintInformation &info) const
static bool requiresEffectiveCompositeOp(const KisPropertiesConfiguration *settings)
void fillProperties(const KisPropertiesConfiguration *setting, KisResourcesInterfaceSP resourcesInterface, KoCanvasResourcesInterfaceSP canvasResourcesInterface)
KisTextureMaskInfoSP m_maskInfo
static QList< KoResourceLoadResult > prepareEmbeddedResources(const KisPropertiesConfigurationSP setting, KisResourcesInterfaceSP resourcesInterface)
KisBrushTextureFlags m_flags
KisCachedPaintDevice m_cachedPaintDevice
KisStrengthOption m_strengthOption
KoAbstractGradientSP m_gradient
void applyGradient(KisFixedPaintDeviceSP dab, const QPoint &offset, const KisPaintInformation &info)
bool applyingGradient() const
KoCachedGradient m_cachedGradient
void apply(KisFixedPaintDeviceSP dab, const QPoint &offset, const KisPaintInformation &info)
apply combine the texture map with the dab
KisTextureOption(const KisPropertiesConfiguration *setting, KisResourcesInterfaceSP resourcesInterface, KoCanvasResourcesInterfaceSP canvasResourcesInterface, int levelOfDetail, KisBrushTextureFlags flags=None)
void applyLightness(KisFixedPaintDeviceSP dab, const QPoint &offset, const KisPaintInformation &info)
KisTextureOptionData::TexturingMode m_texturingMode
static QList< KoResourceLoadResult > prepareLinkedResources(const KisPropertiesConfigurationSP setting, KisResourcesInterfaceSP resourcesInterface)
void setGradient(const KoAbstractGradientSP gradient, qint32 steps, const KoColorSpace *cs)
void setColorSpace(const KoColorSpace *colorSpace)
const quint8 * cachedAt(qreal t) const
gets the color data at position 0 <= t <= 1
@ ALPHA
The channel represents the opacity of a pixel.
enumChannelValueType
enum to define the value of the channel
@ UINT8
use this for an unsigned integer 8bits channel
virtual qreal opacityF(const quint8 *pixel) const =0
QList< KoChannelInfo * > channels
virtual void fillGrayBrushWithColorAndLightnessWithStrength(quint8 *dst, const QRgb *brush, quint8 *brushColor, qreal strength, qint32 nPixels) const
KoMixColorsOp * mixColorsOp
void setColor(const quint8 *data, const KoColorSpace *colorSpace=0)
void setOpacity(quint8 alpha)
virtual void mixColors(const quint8 *const *colors, const qint16 *weights, int nColors, quint8 *dst, int weightSum=255) const =0
#define KIS_SAFE_ASSERT_RECOVER(cond)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
T kisGrowRect(const T &rect, U offset)
QSharedPointer< T > toQShared(T *ptr)
@ CurrentEffectiveCompositeOp
KisPaintDeviceSP device() const
KisTextureMaskInfoSP fetchCachedTextureInfo(KisTextureMaskInfoSP info)
static KisTextureMaskInfoCache * instance()
bool read(const KisPropertiesConfiguration *setting)
TexturingMode texturingMode
@ HARD_MIX_SOFTER_PHOTOSHOP
@ LINEAR_HEIGHT_PHOTOSHOP
KisEmbeddedTextureData textureData
static KoColorSpaceRegistry * instance()