Commit b024e4fb authored by Blackbeard (alberto flores)'s avatar Blackbeard (alberto flores) 🚢

Render QImages only once

parent 4d3fbd9b
......@@ -137,8 +137,25 @@ void KisVectorAnimatedBrush::prepareForSeqNo(const KisPaintInformation &info, in
Q_UNUSED(info)
Q_UNUSED(seqNo)
m_parasite.nextIndex();
KisVectorAnimatedBrush::newbrushTip();
}
/*
void KisVectorAnimatedBrush::notifyCachedDabPainted(const KisPaintInformation &info)
{
Q_UNUSED(info)
Q_UNUSED(seqNo)
qDebug() << "painted";
m_parasite.nextIndex();
newbrushTip();
}
*/
void KisVectorAnimatedBrush::notifyStrokeStarted()
{
qDebug() << "started";
}
void KisVectorAnimatedBrush::newbrushTip()
......@@ -157,29 +174,27 @@ void KisVectorAnimatedBrush::newbrushTip()
}
/*
KisFixedPaintDeviceSP KisVectorAnimatedBrush::paintDevice(const KoColorSpace *colorSpace,
const KisDabShape &,
const KisPaintInformation &info,
double subPixelX, double subPixelY) const
{
Q_ASSERT(valid());
Q_UNUSED(info)
// Q_UNUSED(info)
Q_UNUSED(subPixelX)
Q_UNUSED(subPixelY)
qDebug() << m_imageNumber;
nextIndex();
m_imageNumber++;
QImage outputImage = m_brushTip;
QImage outputImage = m_parasite.nextBrushTip();
KisFixedPaintDeviceSP dab = new KisFixedPaintDevice(colorSpace);
Q_CHECK_PTR(dab);
dab->convertFromQImage(outputImage, "");
// KisVectorAnimatedBrush::notifyCachedDabPainted(info)
return dab;
}
}
*/
......@@ -49,11 +49,15 @@ public:
void newbrushTip();
// void notifyStrokeStarted() override;
void notifyStrokeStarted() override;
// void notifyCachedDabPainted(const KisPaintInformation& info) override;
void prepareForSeqNo(const KisPaintInformation& info, int seqNo) override;
/*
// Asks for the new image
/*
KisFixedPaintDeviceSP paintDevice(const KoColorSpace * colorSpace,
KisDabShape const&,
const KisPaintInformation& info,
......
......@@ -33,10 +33,11 @@ KisVectorBrushParasite::KisVectorBrushParasite()
void KisVectorBrushParasite::parseSvg(QByteArray svg)
{
m_shapes= svgToKoShapes(svg);
m_maxIndex = m_shapes.size();
//minus one because count starts from zero
m_maxIndex--;
m_shapes= KisVectorBrushParasite::svgToKoShapes(svg);
m_images = KisVectorBrushParasite::shapesToImages(m_shapes);
m_maxIndex = m_images.size();
m_maxIndex--; //minus one because count starts from zero
}
......@@ -94,10 +95,25 @@ QImage KisVectorBrushParasite::shapeToQImage(QList<KoShape *> shapes, int index)
return theImage;
}
QList<QImage> KisVectorBrushParasite::shapesToImages(QList<KoShape *> shapes)
{
QList<QImage> images;
QListIterator<KoShape*> iter(shapes);
int index = 0;
while(iter.hasNext())
{
images.append(KisVectorBrushParasite::shapeToQImage(shapes, index));
index++;
}
return images;
}
QImage KisVectorBrushParasite::nextBrushTip()
{
return shapeToQImage(m_shapes, m_index);
return m_images.at(m_index);
// return shapeToQImage(m_shapes, m_index);
}
......@@ -123,3 +139,25 @@ void KisVectorBrushParasite::setIndex(int index)
m_index = index;
}
......@@ -22,7 +22,6 @@
#include <SvgParser.h>
#include <KoXmlReader.h>
class KisVectorBrushParasite
{
public:
......@@ -36,6 +35,8 @@ public:
QList<KoShape*> svgToKoShapes(QByteArray svg);
QImage shapeToQImage(QList<KoShape*> shapes, int index);
QList<QImage> shapesToImages(QList<KoShape*> shapes);
QImage nextBrushTip();
......@@ -49,6 +50,7 @@ public:
private:
QList<KoShape*> m_shapes;
QList<QImage> m_images;
QImage m_brushTip;
int m_maxIndex;
int m_index;
......
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