Commit d2180cf4 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Implement external destination device feature for KisOverlayPaintDeviceWrapper

It was not used in the end, but it might be handy in some circumstances
in the future.
parent ef12de13
......@@ -23,6 +23,7 @@ struct KisOverlayPaintDeviceWrapper::Private
KisRectsGrid grid;
bool usePreciseMode = false;
QScopedPointer<KoOptimizedRgbPixelDataScalerU8ToU16Base> scaler;
KisPaintDeviceSP externalDestination;
};
......@@ -69,6 +70,16 @@ KisOverlayPaintDeviceWrapper::~KisOverlayPaintDeviceWrapper()
{
}
void KisOverlayPaintDeviceWrapper::setExternalDestination(KisPaintDeviceSP device)
{
m_d->externalDestination = device;
}
KisPaintDeviceSP KisOverlayPaintDeviceWrapper::externalDestination() const
{
return m_d->externalDestination;
}
KisPaintDeviceSP KisOverlayPaintDeviceWrapper::source() const
{
return m_d->source;
......@@ -162,17 +173,23 @@ void KisOverlayPaintDeviceWrapper::writeRects(const QVector<QRect> &rects, int i
if (rects.isEmpty()) return;
if (m_d->overlays.isEmpty()) return;
if (!m_d->scaler) {
KisPaintDeviceSP destinationDevice =
m_d->externalDestination ? m_d->externalDestination : m_d->source;
if (!m_d->scaler ||
(destinationDevice != m_d->source &&
*destinationDevice->colorSpace() != *m_d->source->colorSpace())) {
Q_FOREACH (const QRect &rc, rects) {
KIS_SAFE_ASSERT_RECOVER_NOOP(m_d->grid.contains(rc));
KisPainter::copyAreaOptimized(rc.topLeft(), m_d->overlays[index], m_d->source, rc);
KisPainter::copyAreaOptimized(rc.topLeft(), m_d->overlays[index], destinationDevice, rc);
}
} else {
KisPaintDeviceSP overlay = m_d->overlays[index];
KisRandomConstAccessorSP srcIt = overlay->createRandomConstAccessorNG();
KisRandomAccessorSP dstIt = m_d->source->createRandomAccessorNG();
KisRandomAccessorSP dstIt = destinationDevice->createRandomAccessorNG();
Q_FOREACH (const QRect &rc, rects) {
KritaUtils::processTwoDevicesWithStrides(rc,
......
......@@ -96,6 +96,9 @@ public:
~KisOverlayPaintDeviceWrapper();
void setExternalDestination(KisPaintDeviceSP device);
KisPaintDeviceSP externalDestination() const;
KisPaintDeviceSP source() const;
KisPaintDeviceSP overlay(int index = 0) const;
......
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