SVN commit 728961 by rempt: Add KisSelectionSP as an argument to the constructors of the painters & use it whereever the painters used to use a selection from the paint device (just ported, not tested yet) M +10 -4 kis_convolution_painter.cc M +2 -1 kis_convolution_painter.h M +19 -11 kis_fill_painter.cc M +9 -1 kis_fill_painter.h M +25 -6 kis_painter.cc M +6 -2 kis_painter.h --- trunk/koffice/krita/image/kis_convolution_painter.cc #728960:728961 @@ -79,22 +79,28 @@ { } -KisConvolutionPainter::KisConvolutionPainter(KisPaintDeviceSP device) : KisPainter(device) +KisConvolutionPainter::KisConvolutionPainter(KisPaintDeviceSP device) + : KisPainter(device) { } +KisConvolutionPainter::KisConvolutionPainter(KisPaintDeviceSP device, KisSelectionSP selection) +: KisPainter(device, selection) +{ +} + + void KisConvolutionPainter::applyMatrix(KisKernelSP kernel, qint32 x, qint32 y, qint32 w, qint32 h, KisConvolutionBorderOp borderOp ) { // Make the area we cover as small as possible - if (m_device->hasSelection()) { + if ( m_selection ) { - QRect r = m_device->selection()->selectedRect().intersect(QRect(x, y, w, h)); + QRect r = m_selection->selectedRect().intersect(QRect(x, y, w, h)); x = r.x(); y = r.y(); w = r.width(); h = r.height(); - } if ( w == 0 && h == 0 ) return; --- trunk/koffice/krita/image/kis_convolution_painter.h #728960:728961 @@ -63,7 +63,8 @@ public: KisConvolutionPainter(); - KisConvolutionPainter(KisPaintDeviceSP device); + KisConvolutionPainter(KisPaintDeviceSP device ); + KisConvolutionPainter(KisPaintDeviceSP device, KisSelectionSP selection); /** * Convolve all channels in src using the specified kernel; there is only one kernel for all --- trunk/koffice/krita/image/kis_fill_painter.cc #728960:728961 @@ -62,15 +62,23 @@ KisFillPainter::KisFillPainter() : KisPainter() { - m_width = m_height = -1; - m_sampleMerged = false; - m_careForSelection = false; - m_fuzzy = false; + initFillPainter(); } KisFillPainter::KisFillPainter(KisPaintDeviceSP device) : KisPainter(device) { + initFillPainter(); +} + +KisFillPainter::KisFillPainter(KisPaintDeviceSP device, KisSelectionSP selection) + : KisPainter( device, selection ) +{ + initFillPainter(); +} + +void KisFillPainter::initFillPainter() +{ m_width = m_height = -1; m_sampleMerged = false; m_careForSelection = false; @@ -182,7 +190,7 @@ m_size = m_width * m_height; // Create a selection from the surrounding area - m_selection = createFloodSelection(startX, startY, projection); + m_fillSelection = createFloodSelection(startX, startY, projection); } void KisFillPainter::genericFillEnd(KisPaintDeviceSP filled) { @@ -191,10 +199,10 @@ return; } - QRect rc = m_selection->selectedExactRect(); + QRect rc = m_fillSelection->selectedExactRect(); // Sets dirty! - bltMask(rc.x(), rc.y(), m_compositeOp, filled, m_selection, m_opacity, + bltMask(rc.x(), rc.y(), m_compositeOp, filled, m_fillSelection, m_opacity, rc.x(), rc.y(), rc.width(), rc.height()); emit notifyProgressDone(); @@ -217,8 +225,8 @@ // correct! (BSAR) if (m_width < 0 || m_height < 0) { - if (m_device->hasSelection() && m_careForSelection) { - QRect rc = m_device->selection()->selectedExactRect(); + if (m_selection && m_careForSelection) { + QRect rc = m_selection->selectedExactRect(); m_width = rc.width() - (startX - rc.x()); m_height = rc.height() - (startY - rc.y()); } @@ -271,10 +279,10 @@ int progressPercent = 0; int pixelsDone = 0; int currentPercent = 0; emit notifyProgressStage(i18n("Making fill outline..."), 0); - bool hasSelection = m_careForSelection && sourceDevice->hasSelection(); + bool hasSelection = m_careForSelection && m_selection; KisSelectionSP srcSel = KisSelectionSP(0); if (hasSelection) { - srcSel = sourceDevice->selection(); + srcSel = m_selection; if(!srcSel->hasPixelSelection()) srcSel->setPixelSelection(KisPixelSelectionSP(new KisPixelSelection(sourceDevice))); } --- trunk/koffice/krita/image/kis_fill_painter.h #728960:728961 @@ -52,6 +52,14 @@ */ KisFillPainter(KisPaintDeviceSP device); + KisFillPainter(KisPaintDeviceSP device, KisSelectionSP selection); + +private: + + void initFillPainter(); + +public: + /** * Fill a rectangle with black transparent pixels (0, 0, 0, 0 for RGBA). */ @@ -177,7 +185,7 @@ void genericFillStart(int startX, int startY, KisPaintDeviceSP projection); void genericFillEnd(KisPaintDeviceSP filled); - KisPixelSelectionSP m_selection; + KisPixelSelectionSP m_fillSelection; int m_threshold; int m_size; --- trunk/koffice/krita/image/kis_painter.cc #728960:728961 @@ -64,17 +64,27 @@ #define BEZIER_FLATNESS_THRESHOLD 0.5 KisPainter::KisPainter() + : m_selection( 0 ) { init(); } -KisPainter::KisPainter(KisPaintDeviceSP device) +KisPainter::KisPainter( KisPaintDeviceSP device ) + : m_selection( 0 ) { init(); Q_ASSERT(device); begin(device); } +KisPainter::KisPainter(KisPaintDeviceSP device, KisSelectionSP selection) + : m_selection(selection) +{ + init(); + Q_ASSERT(device); + begin(device); +} + void KisPainter::init() { m_transaction = 0; @@ -102,10 +112,15 @@ end(); } -void KisPainter::begin(KisPaintDeviceSP device) +void KisPainter::begin( KisPaintDeviceSP device ) { + begin( device, 0 ); +} + +void KisPainter::begin( KisPaintDeviceSP device, KisSelectionSP selection ) +{ if (!device) return; - + m_selection = selection; Q_ASSERT( device->colorSpace() ); if (m_transaction) { @@ -118,6 +133,9 @@ m_pixelSize = device->pixelSize(); } + + + QUndoCommand *KisPainter::end() { return endTransaction(); @@ -496,11 +514,12 @@ qint32 sw, qint32 sh) { if (m_device.isNull()) return; - if (!m_device->hasSelection()) { + if ( !m_selection ) { bitBlt(dx, dy, op, srcdev, opacity, sx, sy, sw, sh); } - else - bltSelection(dx,dy,op,srcdev, m_device->selection(),opacity,sx,sy,sw,sh); + else { + bltSelection(dx, dy, op, srcdev, m_selection, opacity, sx, sy, sw, sh ); + } } double KisPainter::paintLine(const KisPaintInformation &pi1, --- trunk/koffice/krita/image/kis_painter.h #728960:728961 @@ -63,8 +63,10 @@ public: /// Construct painter without a device KisPainter(); + /// Construct a painter, and begin painting on the device - KisPainter(KisPaintDeviceSP device); + KisPainter( KisPaintDeviceSP device ); + KisPainter(KisPaintDeviceSP device, KisSelectionSP selection); virtual ~KisPainter(); private: @@ -75,7 +77,8 @@ /** * Start painting on the specified device. Not undoable. */ - void begin(KisPaintDeviceSP device); + void begin( KisPaintDeviceSP device ); + void begin( KisPaintDeviceSP device, KisSelectionSP selection ); /** * Finish painting on the current device @@ -606,6 +609,7 @@ protected: KisPaintDeviceSP m_device; + KisSelectionSP m_selection; KisTransaction *m_transaction; QRegion m_dirtyRegion;