Commit 96b504d6 authored by Sven Langkamp's avatar Sven Langkamp

moved the mask visualisation to KisCanvas2, now it will only be repainted for...

moved the mask visualisation to KisCanvas2, now it will only be repainted for changed area and is cached in the canvas cache

svn path=/trunk/koffice/; revision=697473
parent b417eb27
......@@ -155,17 +155,20 @@ QRect KisSelection::selectedExactRect() const
}
}
void KisSelection::paint(QImage* img)
void KisSelection::paint(QImage* img, const QRect & r)
{
if (img->isNull()) {
return;
}
qint32 width = img->width();
qint32 height = img->height();
qint32 width = r.width();
qint32 height = r.height();
Q_ASSERT(img->width() == width);
Q_ASSERT(img->height() == height);
quint8* buffer = new quint8[width*height];
readBytes(buffer, 0, 0, width, height);
readBytes(buffer, r.x(), r.y(), width, height);
for (qint32 y = 0; y < height; y++) {
......
......@@ -134,7 +134,7 @@ public:
*/
QRect selectedExactRect() const;
void paint(QImage* img);
void paint(QImage* img, const QRect & r);
// if the parent layer is interested in keeping up to date with the dirtyness
// of this layer, set to true
......
......@@ -51,6 +51,7 @@
#include "kis_opengl_image_textures.h"
#include "kis_shape_controller.h"
#include "kis_layer_manager.h"
#include "kis_selection.h"
#ifdef HAVE_OPENGL
#include <QGLFormat>
......@@ -275,11 +276,28 @@ void KisCanvas2::updateCanvasProjection( const QRect & rc )
QPainter p( &m_d->canvasCache );
p.setCompositionMode( QPainter::CompositionMode_Source );
p.drawImage( rc.x(), rc.y(),
image()->convertToQImage(rc.x(), rc.y(), rc.width(), rc.height(),
m_d->monitorProfile,
m_d->view->resourceProvider()->HDRExposure() )
, 0, 0, rc.width(), rc.height() );
QImage updateImage = image()->convertToQImage(rc.x(), rc.y(), rc.width(), rc.height(),
m_d->monitorProfile,
m_d->view->resourceProvider()->HDRExposure());
KisLayerSP layer = resourceProvider()->resource( KisResourceProvider::CurrentKritaLayer ).value<KisLayerSP>();
if (!layer) return;
KisPaintDeviceSP dev = layer->paintDevice();
if (!dev) return;
if (dev->hasSelection()){
KisSelectionSP selection = dev->selection();
QTime t;
t.start();
selection->paint(&updateImage, rc);
kDebug(41010) << "Mask visualisation rendering took: " << t.elapsed();
}
p.drawImage( rc.x(), rc.y(), updateImage, 0, 0, rc.width(), rc.height() );
p.end();
QRect vRect = viewRectFromImagePixels( rc );
......
......@@ -355,22 +355,6 @@ void KisQPainterCanvas::drawScaledImage( const QRect & r, QPainter &gc )
QImage canvasImage = m_d->canvas->canvasCache();
KisLayerSP layer = m_d->canvas->resourceProvider()->resource( KisResourceProvider::CurrentKritaLayer ).value<KisLayerSP>();
if (!layer) return;
KisPaintDeviceSP dev = layer->paintDevice();
if (!dev) return;
if (dev->hasSelection()){
KisSelectionSP selection = dev->selection();
QTime t;
t.start();
selection->paint(&canvasImage);
kDebug(41010) << "Mask visualisation rendering took: " << t.elapsed();
}
double sx, sy;
m_d->viewConverter->zoom(&sx, &sy);
......
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