Commit 548bad28 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Draft implementation of "smeared heightmap" smudging

parent f838c4ae
......@@ -180,12 +180,19 @@ void KisColorSmudgeStrategyBase::sampleDullingColor(const QRect &srcRect, qreal
maskDab, resultColor);
}
void
KisColorSmudgeStrategyBase::blendBrush(const QVector<KisPainter *> dstPainters, KisColorSmudgeSourceSP srcSampleDevice,
KisFixedPaintDeviceSP maskDab, bool preserveMaskDab, const QRect &srcRect,
const QRect &dstRect, const KoColor &currentPaintColor, qreal opacity,
qreal smudgeRateValue, qreal maxPossibleSmudgeRateValue, qreal colorRateValue,
qreal smudgeRadiusValue)
void KisColorSmudgeStrategyBase::blendBrushImpl(KisColorSmudgeStrategyBase::DabColoringStrategy &coloringStrategy,
const QVector<KisPainter *> dstPainters,
KisColorSmudgeSourceSP srcSampleDevice,
KisFixedPaintDeviceSP maskDab,
bool preserveMaskDab,
const QRect &srcRect,
const QRect &dstRect,
const KoColor &currentPaintColor,
qreal opacity,
qreal smudgeRateValue,
qreal maxPossibleSmudgeRateValue,
qreal colorRateValue,
qreal smudgeRadiusValue)
{
const quint8 colorRateOpacity = this->colorRateOpacity(opacity, smudgeRateValue, colorRateValue, maxPossibleSmudgeRateValue);
......@@ -203,8 +210,6 @@ KisColorSmudgeStrategyBase::blendBrush(const QVector<KisPainter *> dstPainters,
m_blendDevice->setRect(dstRect);
m_blendDevice->lazyGrowBufferWithoutInitialization();
DabColoringStrategy &coloringStrategy = this->coloringStrategy();
const quint8 dullingRateOpacity = this->dullingRateOpacity(opacity, smudgeRateValue);
if (colorRateOpacity > 0 &&
......@@ -261,6 +266,23 @@ KisColorSmudgeStrategyBase::blendBrush(const QVector<KisPainter *> dstPainters,
}
void
KisColorSmudgeStrategyBase::blendBrush(const QVector<KisPainter *> dstPainters, KisColorSmudgeSourceSP srcSampleDevice,
KisFixedPaintDeviceSP maskDab, bool preserveMaskDab, const QRect &srcRect,
const QRect &dstRect, const KoColor &currentPaintColor, qreal opacity,
qreal smudgeRateValue, qreal maxPossibleSmudgeRateValue, qreal colorRateValue,
qreal smudgeRadiusValue)
{
DabColoringStrategy &coloringStrategy = this->coloringStrategy();
blendBrushImpl(coloringStrategy, dstPainters, srcSampleDevice,
maskDab, preserveMaskDab,
srcRect, dstRect,
currentPaintColor,
opacity,
smudgeRateValue, maxPossibleSmudgeRateValue,
colorRateValue, smudgeRadiusValue);
}
void KisColorSmudgeStrategyBase::blendInBackgroundWithSmearing(KisFixedPaintDeviceSP dst, KisColorSmudgeSourceSP src,
const QRect &srcRect, const QRect &dstRect,
const quint8 smudgeRateOpacity)
......
......@@ -103,6 +103,12 @@ public:
KisFixedPaintDeviceSP tempFixedDevice, KisFixedPaintDeviceSP maskDab,
KoColor *resultColor);
void blendBrushImpl(DabColoringStrategy &coloringStrategy,
const QVector<KisPainter *> dstPainters, KisColorSmudgeSourceSP srcSampleDevice,
KisFixedPaintDeviceSP maskDab, bool preserveMaskDab, const QRect &srcRect, const QRect &dstRect,
const KoColor &currentPaintColor, qreal opacity, qreal smudgeRateValue,
qreal maxPossibleSmudgeRateValue, qreal colorRateValue, qreal smudgeRadiusValue);
void blendBrush(const QVector<KisPainter *> dstPainters, KisColorSmudgeSourceSP srcSampleDevice,
KisFixedPaintDeviceSP maskDab, bool preserveMaskDab, const QRect &srcRect, const QRect &dstRect,
const KoColor &currentPaintColor, qreal opacity, qreal smudgeRateValue,
......
......@@ -69,6 +69,10 @@ void KisColorSmudgeStrategyLightness::initializePainting()
// we should read data from the color layer, not from the final projection layer
m_sourceWrapperDevice = toQShared(new KisColorSmudgeSourcePaintDevice(*m_layerOverlayDevice, 1));
m_heightmapOverlayDevice.reset(new KisOverlayPaintDeviceWrapper(m_heightmapDevice, 1, KisOverlayPaintDeviceWrapper::LazyPreciseMode));
m_heightmapWrapperDevice.reset(new KisColorSmudgeSourcePaintDevice(*m_heightmapOverlayDevice));
m_origDab->setColorSpace(m_heightmapOverlayDevice->overlayColorSpace());
}
KisColorSmudgeStrategyBase::DabColoringStrategy &KisColorSmudgeStrategyLightness::coloringStrategy()
......@@ -93,6 +97,7 @@ void KisColorSmudgeStrategyLightness::updateMask(KisDabCache *dabCache, const Ki
m_maskDab->setRect(m_origDab->bounds());
m_maskDab->lazyGrowBufferWithoutInitialization();
m_origDab->colorSpace()->copyOpacityU8(m_origDab->data(), m_maskDab->data(), numPixels);
m_heightmapColoringStrategy.setStampDab(m_origDab);
m_shouldPreserveOriginalDab = !dabCache->needSeparateOriginal();
}
......@@ -124,6 +129,18 @@ KisColorSmudgeStrategyLightness::paintDab(const QRect &srcRect, const QRect &dst
smudgeRadiusValue);
blendBrushImpl(m_heightmapColoringStrategy,
{&m_heightmapPainter},
m_heightmapWrapperDevice,
m_maskDab, true,
srcRect, dstRect,
KoColor(Qt::white, m_heightmapWrapperDevice->colorSpace()),
opacity,
smudgeRateValue,
maxPossibleSmudgeRateValue,
lightnessStrengthValue,
smudgeRadiusValue);
#if 0
const quint8 thresholdHeightmapOpacity = qRound(0.2 * 255.0);
quint8 heightmapOpacity = qRound(opacity * lightnessStrengthValue * 255.0);
......@@ -139,7 +156,7 @@ KisColorSmudgeStrategyLightness::paintDab(const QRect &srcRect, const QRect &dst
m_heightmapPainter.setOpacity(heightmapOpacity);
m_heightmapPainter.bltFixed(dstRect.topLeft(), m_origDab, m_origDab->bounds());
m_heightmapPainter.renderMirrorMaskSafe(dstRect, m_origDab, m_shouldPreserveOriginalDab);
#endif
KisFixedPaintDeviceSP tempColorDevice =
new KisFixedPaintDevice(m_colorOnlyDevice->colorSpace(), m_memoryAllocator);
......
......@@ -39,6 +39,9 @@ private:
KisPaintDeviceSP m_projectionDevice;
KisOverlayPaintDeviceWrapper *m_layerOverlayDevice;
KisColorSmudgeSourceSP m_sourceWrapperDevice;
KisColorSmudgeSourceSP m_heightmapWrapperDevice;
QScopedPointer<KisOverlayPaintDeviceWrapper> m_heightmapOverlayDevice;
DabColoringStrategyStamp m_heightmapColoringStrategy;
KisPainter m_finalPainter;
KisPainter m_heightmapPainter;
bool m_shouldPreserveOriginalDab = true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment