[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: [plasma-framework/native_rendering] src: Use QImage internally in Plasma over QPixmap
From: Aleix Pol <aleixpol () kde ! org>
Date: 2014-02-20 0:56:16
Message-ID: CACcA1Ro1_mGihA6KHDqSmBsg_V+g34U6gpuy+nEgLkFsMJUsFg () mail ! gmail ! com
[Download RAW message or body]
what's the reason?
On Wed, Feb 19, 2014 at 7:23 PM, David Edmundson
<kde@davidedmundson.co.uk>wrote:
> Git commit b19df4a80f674166f1d18cbdc8e45c8151ce4ddf by David Edmundson.
> Committed on 19/02/2014 at 18:16.
> Pushed by davidedmundson into branch 'native_rendering'.
>
> Use QImage internally in Plasma over QPixmap
>
> M +3 -3 src/declarativeimports/core/svgitem.cpp
> M +20 -19 src/plasma/framesvg.cpp
> M +2 -2 src/plasma/framesvg.h
> M +3 -3 src/plasma/private/framesvg_p.h
> M +1 -1 src/plasma/private/svg_p.h
> M +2 -2 src/plasma/private/theme_p.cpp
> M +1 -1 src/plasma/private/theme_p.h
> M +23 -13 src/plasma/svg.cpp
> M +19 -1 src/plasma/svg.h
> M +6 -6 src/plasma/theme.cpp
> M +6 -6 src/plasma/theme.h
>
>
> http://commits.kde.org/plasma-framework/b19df4a80f674166f1d18cbdc8e45c8151ce4ddf
>
> diff --git a/src/declarativeimports/core/svgitem.cpp
> b/src/declarativeimports/core/svgitem.cpp
> index 3f9c399..9dc19b0 100644
> --- a/src/declarativeimports/core/svgitem.cpp
> +++ b/src/declarativeimports/core/svgitem.cpp
> @@ -138,9 +138,9 @@ QSGNode* SvgItem::updatePaintNode(QSGNode* oldNode,
> UpdatePaintNodeData* updateP
> m_svg.data()->resize(width(), height());
> qDebug() << "called";
> //TODO make m_svg return a QImage so that we can avoid the deep
> copy in toImage();
> - const QPixmap pixmap = m_svg.data()->pixmap();
> - textureNode->setRect(0,0, pixmap.width(), pixmap.height());
> -
> textureNode->setTexture(window()->createTextureFromImage(pixmap.toImage()));
> + const QImage image = m_svg.data()->image();
> + textureNode->setRect(0,0, image.width(), image.height());
> + textureNode->setTexture(window()->createTextureFromImage(image));
> m_dirty = false;
> }
> return textureNode;
> diff --git a/src/plasma/framesvg.cpp b/src/plasma/framesvg.cpp
> index 9e1a53e..3c4826a 100644
> --- a/src/plasma/framesvg.cpp
> +++ b/src/plasma/framesvg.cpp
> @@ -442,7 +442,7 @@ QRectF FrameSvg::contentsRect() const
> }
> }
>
> -QPixmap FrameSvg::alphaMask() const
> +QImage FrameSvg::alphaMask() const
> {
> //FIXME: the distinction between overlay and
> return d->alphaMask();
> @@ -457,7 +457,7 @@ QRegion FrameSvg::mask() const
> if (frame->cachedMasks.count() > frame->MAX_CACHED_MASKS) {
> frame->cachedMasks.clear();
> }
> - frame->cachedMasks.insert(id,
> QRegion(QBitmap(d->alphaMask().alphaChannel().createMaskFromColor(Qt::black))));
> + frame->cachedMasks.insert(id,
> QRegion(QBitmap::fromImage(d->alphaMask().alphaChannel().createMaskFromColor(Qt::black))));
> }
> return frame->cachedMasks[id];
> }
> @@ -489,7 +489,7 @@ void FrameSvg::clearCache()
> if (p->deref(this)) {
> const QString key = d->cacheId(p, it.key());
> FrameSvgPrivate::s_sharedFrames.remove(key);
> - p->cachedBackground = QPixmap();
> + p->cachedBackground = QImage();
> }
>
> it.remove();
> @@ -497,13 +497,13 @@ void FrameSvg::clearCache()
> }
> }
>
> -QPixmap FrameSvg::framePixmap()
> +QImage FrameSvg::framePixmap()
> {
> FrameData *frame = d->frames[d->prefix];
> if (frame->cachedBackground.isNull()) {
> d->generateBackground(frame);
> if (frame->cachedBackground.isNull()) {
> - return QPixmap();
> + return QImage();
> }
> }
>
> @@ -520,7 +520,7 @@ void FrameSvg::paintFrame(QPainter *painter, const
> QRectF &target, const QRectF
> }
> }
>
> - painter->drawPixmap(target, frame->cachedBackground, source.isValid()
> ? source : target);
> + painter->drawImage(target, frame->cachedBackground, source.isValid()
> ? source : target);
> }
>
> void FrameSvg::paintFrame(QPainter *painter, const QPointF &pos)
> @@ -533,7 +533,7 @@ void FrameSvg::paintFrame(QPainter *painter, const
> QPointF &pos)
> }
> }
>
> - painter->drawPixmap(pos, frame->cachedBackground);
> + painter->drawImage(pos, frame->cachedBackground);
> }
>
> //#define DEBUG_FRAMESVG_CACHE
> @@ -605,7 +605,7 @@ FrameSvgPrivate::~FrameSvgPrivate()
> frames.clear();
> }
>
> -QPixmap FrameSvgPrivate::alphaMask()
> +QImage FrameSvgPrivate::alphaMask()
> {
> FrameData *frame = frames[prefix];
> QString maskPrefix;
> @@ -618,7 +618,7 @@ QPixmap FrameSvgPrivate::alphaMask()
> if (frame->cachedBackground.isNull()) {
> generateBackground(frame);
> if (frame->cachedBackground.isNull()) {
> - return QPixmap();
> + return QImage();
> }
> }
>
> @@ -658,11 +658,11 @@ QPixmap FrameSvgPrivate::alphaMask()
> s_sharedFrames.insert(newKey, maskFrame);
> }
>
> - maskFrame->cachedBackground = QPixmap();
> + maskFrame->cachedBackground = QImage();
>
> generateBackground(maskFrame);
> if (maskFrame->cachedBackground.isNull()) {
> - return QPixmap();
> + return QImage();
> }
> }
>
> @@ -682,7 +682,7 @@ void FrameSvgPrivate::generateBackground(FrameData
> *frame)
> bool frameCached = !frame->cachedBackground.isNull();
> bool overlayCached = false;
> const bool overlayAvailable =
> !prefix.startsWith(QLatin1String("mask-")) && q->hasElement(prefix %
> "overlay");
> - QPixmap overlay;
> + QImage overlay;
> if (q->isUsingRenderingCache()) {
> frameCached = theme->findInCache(id, frame->cachedBackground) &&
> !frame->cachedBackground.isNull();
>
> @@ -737,13 +737,13 @@ void FrameSvgPrivate::generateBackground(FrameData
> *frame)
> }
>
> if (!frameCached) {
> - cacheFrame(prefix, frame->cachedBackground, overlayCached ?
> overlay : QPixmap());
> + cacheFrame(prefix, frame->cachedBackground, overlayCached ?
> overlay : QImage());
> }
>
> if (!overlay.isNull()) {
> QPainter p(&frame->cachedBackground);
> p.setCompositionMode(QPainter::CompositionMode_SourceOver);
> - p.drawPixmap(actualOverlayPos, overlay, QRect(actualOverlayPos,
> overlaySize));
> + p.drawImage(actualOverlayPos, overlay, QRect(actualOverlayPos,
> overlaySize));
> }
> }
>
> @@ -775,8 +775,9 @@ void
> FrameSvgPrivate::generateFrameBackground(FrameData *frame)
> int rightOffset = contentWidth;
> int bottomOffset = contentHeight;
>
> - frame->cachedBackground = QPixmap(frame->leftWidth + contentWidth +
> frame->rightWidth,
> - frame->topHeight + contentHeight +
> frame->bottomHeight);
> + frame->cachedBackground = QImage(frame->leftWidth + contentWidth +
> frame->rightWidth,
> + frame->topHeight + contentHeight +
> frame->bottomHeight,
> +
> QImage::Format_ARGB32_Premultiplied);
> frame->cachedBackground.fill(Qt::transparent);
> QPainter p(&frame->cachedBackground);
> p.setCompositionMode(QPainter::CompositionMode_Source);
> @@ -818,7 +819,7 @@ void
> FrameSvgPrivate::generateFrameBackground(FrameData *frame)
>
> if (frame->composeOverBorder) {
> p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
> - p.drawPixmap(QRect(QPoint(0, 0), size.toSize()), alphaMask());
> + p.drawImage(QRect(QPoint(0, 0), size.toSize()), alphaMask());
> p.setCompositionMode(QPainter::CompositionMode_SourceOver);
> }
>
> @@ -940,7 +941,7 @@ QString FrameSvgPrivate::cacheId(FrameData *frame,
> const QString &prefixToSave)
> return QString::number(frame->enabledBorders) % s %
> QString::number(size.width()) % s % QString::number(size.height()) % s %
> prefixToSave % s % q->imagePath();
> }
>
> -void FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const
> QPixmap &background, const QPixmap &overlay)
> +void FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const
> QImage &background, const QImage &overlay)
> {
> if (!q->isUsingRenderingCache()) {
> return;
> @@ -973,7 +974,7 @@ void FrameSvgPrivate::updateSizes() const
>
> QSize s = q->size();
> q->resize();
> - frame->cachedBackground = QPixmap();
> + frame->cachedBackground = QImage();
>
> if (frame->enabledBorders & FrameSvg::TopBorder) {
> frame->topHeight = q->elementSize(prefix % "top").height();
> diff --git a/src/plasma/framesvg.h b/src/plasma/framesvg.h
> index 482956d..19bbee3 100644
> --- a/src/plasma/framesvg.h
> +++ b/src/plasma/framesvg.h
> @@ -218,7 +218,7 @@ class PLASMA_EXPORT FrameSvg : public Svg
> /**
> * @return a pixmap whose alpha channel is the opacity of the
> frame. It may be the frame itself or a special frame with the mask- prefix
> */
> - QPixmap alphaMask() const;
> + QImage alphaMask() const;
>
> /**
> * Sets whether saving all the rendered prefixes in a cache or not
> @@ -245,7 +245,7 @@ class PLASMA_EXPORT FrameSvg : public Svg
> * string for the whole SVG (the default)
> * @return a QPixmap of the rendered SVG
> */
> - Q_INVOKABLE QPixmap framePixmap();
> + QImage framePixmap();
>
> /**
> * Paints the loaded SVG with the elements that represents the
> border
> diff --git a/src/plasma/private/framesvg_p.h
> b/src/plasma/private/framesvg_p.h
> index 1bbc744..9cecd6b 100644
> --- a/src/plasma/private/framesvg_p.h
> +++ b/src/plasma/private/framesvg_p.h
> @@ -82,7 +82,7 @@ public:
> int refcount() const;
>
> FrameSvg::EnabledBorders enabledBorders;
> - QPixmap cachedBackground;
> + QImage cachedBackground;
> QHash<QString, QRegion> cachedMasks;
> static const int MAX_CACHED_MASKS = 10;
>
> @@ -123,12 +123,12 @@ public:
>
> ~FrameSvgPrivate();
>
> - QPixmap alphaMask();
> + QImage alphaMask();
>
> void generateBackground(FrameData *frame);
> void generateFrameBackground(FrameData *frame);
> QString cacheId(FrameData *frame, const QString &prefixToUse) const;
> - void cacheFrame(const QString &prefixToSave, const QPixmap
> &background, const QPixmap &overlay);
> + void cacheFrame(const QString &prefixToSave, const QImage
> &background, const QImage &overlay);
> void updateSizes() const;
> void updateNeeded();
> void updateAndSignalSizes();
> diff --git a/src/plasma/private/svg_p.h b/src/plasma/private/svg_p.h
> index 332efda..c1a5acf 100644
> --- a/src/plasma/private/svg_p.h
> +++ b/src/plasma/private/svg_p.h
> @@ -72,7 +72,7 @@ public:
> Theme *actualTheme();
> Theme *cacheAndColorsTheme();
>
> - QPixmap findInCache(const QString &elementId, const QSizeF &s =
> QSizeF());
> + QImage findInCache(const QString &elementId, const QSizeF &s =
> QSizeF());
>
> void createRenderer();
> void eraseRenderer();
> diff --git a/src/plasma/private/theme_p.cpp
> b/src/plasma/private/theme_p.cpp
> index 9b8b7df..b8e98b5 100644
> --- a/src/plasma/private/theme_p.cpp
> +++ b/src/plasma/private/theme_p.cpp
> @@ -307,10 +307,10 @@ void ThemePrivate::discardCache(CacheTypes caches)
> void ThemePrivate::scheduledCacheUpdate()
> {
> if (useCache()) {
> - QHashIterator<QString, QPixmap> it(pixmapsToCache);
> + QHashIterator<QString, QImage> it(pixmapsToCache);
> while (it.hasNext()) {
> it.next();
> - pixmapCache->insertPixmap(idsToCache[it.key()], it.value());
> + pixmapCache->insertImage(idsToCache[it.key()], it.value());
> }
> }
>
> diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h
> index 291ce33..3c95478 100644
> --- a/src/plasma/private/theme_p.h
> +++ b/src/plasma/private/theme_p.h
> @@ -128,7 +128,7 @@ public:
> KImageCache *pixmapCache;
> KSharedConfigPtr svgElementsCache;
> QHash<QString, QSet<QString> > invalidElements;
> - QHash<QString, QPixmap> pixmapsToCache;
> + QHash<QString, QImage> pixmapsToCache;
> QHash<QString, QString> keysToCache;
> QHash<QString, QString> idsToCache;
> QHash<styles, QString> cachedStyleSheets;
> diff --git a/src/plasma/svg.cpp b/src/plasma/svg.cpp
> index 9ec2aa5..38c0624 100644
> --- a/src/plasma/svg.cpp
> +++ b/src/plasma/svg.cpp
> @@ -263,7 +263,7 @@ Theme *SvgPrivate::cacheAndColorsTheme()
> }
> }
>
> -QPixmap SvgPrivate::findInCache(const QString &elementId, const QSizeF &s)
> +QImage SvgPrivate::findInCache(const QString &elementId, const QSizeF &s)
> {
> QSize size;
> QString actualElementId;
> @@ -326,7 +326,7 @@ QPixmap SvgPrivate::findInCache(const QString
> &elementId, const QSizeF &s)
> }
>
> if (size.isEmpty()) {
> - return QPixmap();
> + return QImage();
> }
>
> QString id = cachePath(path, size);
> @@ -337,7 +337,7 @@ QPixmap SvgPrivate::findInCache(const QString
> &elementId, const QSizeF &s)
>
> //qDebug() << "id is " << id;
>
> - QPixmap p;
> + QImage p;
> if (cacheRendering && cacheAndColorsTheme()->findInCache(id, p,
> lastModified)) {
> //qDebug() << "found cached version of " << id << p.size();
> return p;
> @@ -354,9 +354,11 @@ QPixmap SvgPrivate::findInCache(const QString
> &elementId, const QSizeF &s)
>
> //don't alter the pixmap size or it won't match up properly to, e.g.,
> FrameSvg elements
> //makeUniform should never change the size so much that it gains or
> loses a whole pixel
> - p = QPixmap(size);
> + p = QImage(size, QImage::Format_ARGB32_Premultiplied);
>
> + //FIXME DAVE - do we need this?
> p.fill(Qt::transparent);
> +
> QPainter renderPainter(&p);
>
> if (actualElementId.isEmpty()) {
> @@ -369,9 +371,7 @@ QPixmap SvgPrivate::findInCache(const QString
> &elementId, const QSizeF &s)
>
> // Apply current color scheme if the svg asks for it
> if (applyColors) {
> - QImage itmp = p.toImage();
> - KIconEffect::colorize(itmp,
> cacheAndColorsTheme()->color(Theme::BackgroundColor), 1.0);
> - p = p.fromImage(itmp);
> + KIconEffect::colorize(p,
> cacheAndColorsTheme()->color(Theme::BackgroundColor), 1.0);
> }
>
> if (cacheRendering) {
> @@ -662,22 +662,32 @@ Svg::~Svg()
> QPixmap Svg::pixmap(const QString &elementID)
> {
> if (elementID.isNull() || d->multipleImages) {
> + return QPixmap::fromImage((d->findInCache(elementID, size())));
> + } else {
> + return QPixmap::fromImage(d->findInCache(elementID));
> + }
> +}
> +
> +QImage Svg::image(const QString& elementID)
> +{
> + if (elementID.isNull() || d->multipleImages) {
> return d->findInCache(elementID, size());
> } else {
> return d->findInCache(elementID);
> }
> }
>
> +
> void Svg::paint(QPainter *painter, const QPointF &point, const QString
> &elementID)
> {
> - QPixmap pix((elementID.isNull() || d->multipleImages) ?
> d->findInCache(elementID, size()) :
> + QImage pix((elementID.isNull() || d->multipleImages) ?
> d->findInCache(elementID, size()) :
>
> d->findInCache(elementID));
>
> if (pix.isNull()) {
> return;
> }
>
> - painter->drawPixmap(QRectF(point, pix.size()), pix, QRectF(QPointF(0,
> 0), pix.size()));
> + painter->drawImage(QRectF(point, pix.size()), pix, QRectF(QPointF(0,
> 0), pix.size()));
> }
>
> void Svg::paint(QPainter *painter, int x, int y, const QString &elementID)
> @@ -687,14 +697,14 @@ void Svg::paint(QPainter *painter, int x, int y,
> const QString &elementID)
>
> void Svg::paint(QPainter *painter, const QRectF &rect, const QString
> &elementID)
> {
> - QPixmap pix(d->findInCache(elementID, rect.size()));
> - painter->drawPixmap(QRectF(rect.topLeft(), pix.size()), pix,
> QRectF(QPointF(0, 0), pix.size()));
> + QImage pix(d->findInCache(elementID, rect.size()));
> + painter->drawImage(QRectF(rect.topLeft(), pix.size()), pix,
> QRectF(QPointF(0, 0), pix.size()));
> }
>
> void Svg::paint(QPainter *painter, int x, int y, int width, int height,
> const QString &elementID)
> {
> - QPixmap pix(d->findInCache(elementID, QSizeF(width, height)));
> - painter->drawPixmap(x, y, pix, 0, 0, pix.size().width(),
> pix.size().height());
> + QImage pix(d->findInCache(elementID, QSizeF(width, height)));
> + painter->drawImage(x, y, pix, 0, 0, pix.size().width(),
> pix.size().height());
> }
>
> QSize Svg::size() const
> diff --git a/src/plasma/svg.h b/src/plasma/svg.h
> index 01d98f8..20c327a 100644
> --- a/src/plasma/svg.h
> +++ b/src/plasma/svg.h
> @@ -81,7 +81,10 @@ class PLASMA_EXPORT Svg : public QObject
> ~Svg();
>
> /**
> - * Returns a pixmap of the SVG represented by this object.
> + * DEPRECATED Returns a pixmap of the SVG represented by this
> object.
> + *
> + * image() is significantly faster as it avoids a conversion
> + * Update your code
> *
> * The size of the pixmap will be the size of this Svg object
> (size())
> * if containsMultipleImages is @c true; otherwise, it will be the
> @@ -95,6 +98,21 @@ class PLASMA_EXPORT Svg : public QObject
> Q_INVOKABLE QPixmap pixmap(const QString &elementID = QString());
>
> /**
> + * Returns a pixmap of the SVG represented by this object.
> + *
> + * The size of the pixmap will be the size of this Svg object
> (size())
> + * if containsMultipleImages is @c true; otherwise, it will be the
> + * size of the requested element after the whole SVG has been
> scaled
> + * to size().
> + *
> + * @param elementId the ID string of the element to render, or
> an empty
> + * string for the whole SVG (the default)
> + * @return a QPixmap of the rendered SVG
> + */
> + Q_INVOKABLE QImage image(const QString &elementID = QString());
> +
> +
> + /**
> * Paints all or part of the SVG represented by this object
> *
> * The size of the painted area will be the size of this Svg
> object
> diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp
> index aba84d5..bf599f6 100644
> --- a/src/plasma/theme.cpp
> +++ b/src/plasma/theme.cpp
> @@ -299,7 +299,7 @@ bool Theme::useGlobalSettings() const
> return d->useGlobal;
> }
>
> -bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int
> lastModified)
> +bool Theme::findInCache(const QString &key, QImage &pix, unsigned int
> lastModified)
> {
> if (lastModified != 0 && d->useCache() && lastModified >
> uint(d->pixmapCache->lastModifiedTime().toTime_t())) {
> return false;
> @@ -312,8 +312,8 @@ bool Theme::findInCache(const QString &key, QPixmap
> &pix, unsigned int lastModif
> return !pix.isNull();
> }
>
> - QPixmap temp;
> - if (d->pixmapCache->findPixmap(key, &temp) && !temp.isNull()) {
> + QImage temp;
> + if (d->pixmapCache->findImage(key, &temp) && !temp.isNull()) {
> pix = temp;
> return true;
> }
> @@ -322,14 +322,14 @@ bool Theme::findInCache(const QString &key, QPixmap
> &pix, unsigned int lastModif
> return false;
> }
>
> -void Theme::insertIntoCache(const QString& key, const QPixmap& pix)
> +void Theme::insertIntoCache(const QString& key, const QImage& pix)
> {
> if (d->useCache()) {
> - d->pixmapCache->insertPixmap(key, pix);
> + d->pixmapCache->insertImage(key, pix);
> }
> }
>
> -void Theme::insertIntoCache(const QString& key, const QPixmap& pix, const
> QString& id)
> +void Theme::insertIntoCache(const QString& key, const QImage& pix, const
> QString& id)
> {
> if (d->useCache()) {
> d->pixmapsToCache.insert(id, pix);
> diff --git a/src/plasma/theme.h b/src/plasma/theme.h
> index 42677fb..a5cd4f7 100644
> --- a/src/plasma/theme.h
> +++ b/src/plasma/theme.h
> @@ -227,14 +227,14 @@ class PLASMA_EXPORT Theme : public QObject
> * where cache is still valid.
> *
> * @param key the name to use in the cache for this image
> - * @param pix the pixmap object to populate with the resulting
> data if found
> + * @param pix the image object to populate with the resulting
> data if found
> * @param lastModified if non-zero, the time stamp is also
> checked on the file,
> * and must be newer than the timestamp to be
> loaded
> *
> * @return true when pixmap was found and loaded from cache,
> false otherwise
> * @since 4.3
> **/
> - bool findInCache(const QString &key, QPixmap &pix, unsigned int
> lastModified = 0);
> + bool findInCache(const QString& key, QImage& pix, unsigned int
> lastModified = 0);
>
> /**
> * Insert specified pixmap into the cache.
> @@ -242,9 +242,9 @@ class PLASMA_EXPORT Theme : public QObject
> * overwritten.
> *
> * @param key the name to use in the cache for this pixmap
> - * @param pix the pixmap data to store in the cache
> + * @param pix the image data to store in the cache
> **/
> - void insertIntoCache(const QString& key, const QPixmap& pix);
> + void insertIntoCache(const QString& key, const QImage& pix);
>
> /**
> * Insert specified pixmap into the cache.
> @@ -257,14 +257,14 @@ class PLASMA_EXPORT Theme : public QObject
> * useful in the cache and just cause overhead.
> *
> * @param key the name to use in the cache for this pixmap
> - * @param pix the pixmap data to store in the cache
> + * @param pix the image data to store in the cache
> * @param id a name that identifies the caller class of this
> function in an unique fashion.
> * This is needed to limit disk writes of the cache.
> * If an image with the same id changes quickly,
> * only the last size where insertIntoCache was called
> is actually stored on disk
> * @since 4.3
> **/
> - void insertIntoCache(const QString& key, const QPixmap& pix,
> const QString& id);
> + void insertIntoCache(const QString& key, const QImage& pix, const
> QString& id);
>
> /**
> * Sets the maximum size of the cache (in kilobytes). If cache
> gets bigger
>
>
[Attachment #3 (text/html)]
<div dir="ltr">what's the reason?</div><div class="gmail_extra"><br><br><div \
class="gmail_quote">On Wed, Feb 19, 2014 at 7:23 PM, David Edmundson <span \
dir="ltr"><<a href="mailto:kde@davidedmundson.co.uk" \
target="_blank">kde@davidedmundson.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Git commit b19df4a80f674166f1d18cbdc8e45c8151ce4ddf by David \
Edmundson.<br> Committed on 19/02/2014 at 18:16.<br>
Pushed by davidedmundson into branch 'native_rendering'.<br>
<br>
Use QImage internally in Plasma over QPixmap<br>
<br>
M +3 -3 src/declarativeimports/core/svgitem.cpp<br>
M +20 -19 src/plasma/framesvg.cpp<br>
M +2 -2 src/plasma/framesvg.h<br>
M +3 -3 src/plasma/private/framesvg_p.h<br>
M +1 -1 src/plasma/private/svg_p.h<br>
M +2 -2 src/plasma/private/theme_p.cpp<br>
M +1 -1 src/plasma/private/theme_p.h<br>
M +23 -13 src/plasma/svg.cpp<br>
M +19 -1 src/plasma/svg.h<br>
M +6 -6 src/plasma/theme.cpp<br>
M +6 -6 src/plasma/theme.h<br>
<br>
<a href="http://commits.kde.org/plasma-framework/b19df4a80f674166f1d18cbdc8e45c8151ce4ddf" \
target="_blank">http://commits.kde.org/plasma-framework/b19df4a80f674166f1d18cbdc8e45c8151ce4ddf</a><br>
<br>
diff --git a/src/declarativeimports/core/svgitem.cpp \
b/src/declarativeimports/core/svgitem.cpp<br> index 3f9c399..9dc19b0 100644<br>
--- a/src/declarativeimports/core/svgitem.cpp<br>
+++ b/src/declarativeimports/core/svgitem.cpp<br>
@@ -138,9 +138,9 @@ QSGNode* SvgItem::updatePaintNode(QSGNode* oldNode, \
UpdatePaintNodeData* updateP<br> m_svg.data()->resize(width(), height());<br>
qDebug() << "called";<br>
//TODO make m_svg return a QImage so that we can avoid the deep copy in \
toImage();<br>
- const QPixmap pixmap = m_svg.data()->pixmap();<br>
- textureNode->setRect(0,0, pixmap.width(), pixmap.height());<br>
- textureNode->setTexture(window()->createTextureFromImage(pixmap.toImage()));<br>
+ const QImage image = m_svg.data()->image();<br>
+ textureNode->setRect(0,0, image.width(), image.height());<br>
+ textureNode->setTexture(window()->createTextureFromImage(image));<br>
m_dirty = false;<br>
}<br>
return textureNode;<br>
diff --git a/src/plasma/framesvg.cpp b/src/plasma/framesvg.cpp<br>
index 9e1a53e..3c4826a 100644<br>
--- a/src/plasma/framesvg.cpp<br>
+++ b/src/plasma/framesvg.cpp<br>
@@ -442,7 +442,7 @@ QRectF FrameSvg::contentsRect() const<br>
}<br>
}<br>
<br>
-QPixmap FrameSvg::alphaMask() const<br>
+QImage FrameSvg::alphaMask() const<br>
{<br>
//FIXME: the distinction between overlay and<br>
return d->alphaMask();<br>
@@ -457,7 +457,7 @@ QRegion FrameSvg::mask() const<br>
if (frame->cachedMasks.count() > frame->MAX_CACHED_MASKS) \
{<br> frame->cachedMasks.clear();<br>
}<br>
- frame->cachedMasks.insert(id, \
QRegion(QBitmap(d->alphaMask().alphaChannel().createMaskFromColor(Qt::black))));<br>
+ frame->cachedMasks.insert(id, \
QRegion(QBitmap::fromImage(d->alphaMask().alphaChannel().createMaskFromColor(Qt::black))));<br>
}<br>
return frame->cachedMasks[id];<br>
}<br>
@@ -489,7 +489,7 @@ void FrameSvg::clearCache()<br>
if (p->deref(this)) {<br>
const QString key = d->cacheId(p, it.key());<br>
FrameSvgPrivate::s_sharedFrames.remove(key);<br>
- p->cachedBackground = QPixmap();<br>
+ p->cachedBackground = QImage();<br>
}<br>
<br>
it.remove();<br>
@@ -497,13 +497,13 @@ void FrameSvg::clearCache()<br>
}<br>
}<br>
<br>
-QPixmap FrameSvg::framePixmap()<br>
+QImage FrameSvg::framePixmap()<br>
{<br>
FrameData *frame = d->frames[d->prefix];<br>
if (frame->cachedBackground.isNull()) {<br>
d->generateBackground(frame);<br>
if (frame->cachedBackground.isNull()) {<br>
- return QPixmap();<br>
+ return QImage();<br>
}<br>
}<br>
<br>
@@ -520,7 +520,7 @@ void FrameSvg::paintFrame(QPainter *painter, const QRectF \
&target, const QRectF<br> }<br>
}<br>
<br>
- painter->drawPixmap(target, frame->cachedBackground, source.isValid() ? \
source : target);<br> + painter->drawImage(target, \
frame->cachedBackground, source.isValid() ? source : target);<br> }<br>
<br>
void FrameSvg::paintFrame(QPainter *painter, const QPointF &pos)<br>
@@ -533,7 +533,7 @@ void FrameSvg::paintFrame(QPainter *painter, const QPointF \
&pos)<br> }<br>
}<br>
<br>
- painter->drawPixmap(pos, frame->cachedBackground);<br>
+ painter->drawImage(pos, frame->cachedBackground);<br>
}<br>
<br>
//#define DEBUG_FRAMESVG_CACHE<br>
@@ -605,7 +605,7 @@ FrameSvgPrivate::~FrameSvgPrivate()<br>
frames.clear();<br>
}<br>
<br>
-QPixmap FrameSvgPrivate::alphaMask()<br>
+QImage FrameSvgPrivate::alphaMask()<br>
{<br>
FrameData *frame = frames[prefix];<br>
QString maskPrefix;<br>
@@ -618,7 +618,7 @@ QPixmap FrameSvgPrivate::alphaMask()<br>
if (frame->cachedBackground.isNull()) {<br>
generateBackground(frame);<br>
if (frame->cachedBackground.isNull()) {<br>
- return QPixmap();<br>
+ return QImage();<br>
}<br>
}<br>
<br>
@@ -658,11 +658,11 @@ QPixmap FrameSvgPrivate::alphaMask()<br>
s_sharedFrames.insert(newKey, maskFrame);<br>
}<br>
<br>
- maskFrame->cachedBackground = QPixmap();<br>
+ maskFrame->cachedBackground = QImage();<br>
<br>
generateBackground(maskFrame);<br>
if (maskFrame->cachedBackground.isNull()) {<br>
- return QPixmap();<br>
+ return QImage();<br>
}<br>
}<br>
<br>
@@ -682,7 +682,7 @@ void FrameSvgPrivate::generateBackground(FrameData *frame)<br>
bool frameCached = !frame->cachedBackground.isNull();<br>
bool overlayCached = false;<br>
const bool overlayAvailable = \
!prefix.startsWith(QLatin1String("mask-")) && \
q->hasElement(prefix % "overlay");<br>
- QPixmap overlay;<br>
+ QImage overlay;<br>
if (q->isUsingRenderingCache()) {<br>
frameCached = theme->findInCache(id, frame->cachedBackground) \
&& !frame->cachedBackground.isNull();<br> <br>
@@ -737,13 +737,13 @@ void FrameSvgPrivate::generateBackground(FrameData *frame)<br>
}<br>
<br>
if (!frameCached) {<br>
- cacheFrame(prefix, frame->cachedBackground, overlayCached ? overlay : \
QPixmap());<br> + cacheFrame(prefix, frame->cachedBackground, \
overlayCached ? overlay : QImage());<br> }<br>
<br>
if (!overlay.isNull()) {<br>
QPainter p(&frame->cachedBackground);<br>
p.setCompositionMode(QPainter::CompositionMode_SourceOver);<br>
- p.drawPixmap(actualOverlayPos, overlay, QRect(actualOverlayPos, \
overlaySize));<br> + p.drawImage(actualOverlayPos, overlay, \
QRect(actualOverlayPos, overlaySize));<br> }<br>
}<br>
<br>
@@ -775,8 +775,9 @@ void FrameSvgPrivate::generateFrameBackground(FrameData \
*frame)<br> int rightOffset = contentWidth;<br>
int bottomOffset = contentHeight;<br>
<br>
- frame->cachedBackground = QPixmap(frame->leftWidth + contentWidth + \
frame->rightWidth,<br>
- frame->topHeight + \
contentHeight + frame->bottomHeight);<br> + frame->cachedBackground = \
QImage(frame->leftWidth + contentWidth + frame->rightWidth,<br> + \
frame->topHeight + contentHeight + frame->bottomHeight,<br> + \
QImage::Format_ARGB32_Premultiplied);<br> \
frame->cachedBackground.fill(Qt::transparent);<br> QPainter \
p(&frame->cachedBackground);<br> \
p.setCompositionMode(QPainter::CompositionMode_Source);<br> @@ -818,7 +819,7 @@ void \
FrameSvgPrivate::generateFrameBackground(FrameData *frame)<br> <br>
if (frame->composeOverBorder) {<br>
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);<br>
- p.drawPixmap(QRect(QPoint(0, 0), size.toSize()), alphaMask());<br>
+ p.drawImage(QRect(QPoint(0, 0), size.toSize()), alphaMask());<br>
p.setCompositionMode(QPainter::CompositionMode_SourceOver);<br>
}<br>
<br>
@@ -940,7 +941,7 @@ QString FrameSvgPrivate::cacheId(FrameData *frame, const QString \
&prefixToSave)<br> return QString::number(frame->enabledBorders) % s % \
QString::number(size.width()) % s % QString::number(size.height()) % s % prefixToSave \
% s % q->imagePath();<br> }<br>
<br>
-void FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const QPixmap \
&background, const QPixmap &overlay)<br> +void \
FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const QImage \
&background, const QImage &overlay)<br> {<br>
if (!q->isUsingRenderingCache()) {<br>
return;<br>
@@ -973,7 +974,7 @@ void FrameSvgPrivate::updateSizes() const<br>
<br>
QSize s = q->size();<br>
q->resize();<br>
- frame->cachedBackground = QPixmap();<br>
+ frame->cachedBackground = QImage();<br>
<br>
if (frame->enabledBorders & FrameSvg::TopBorder) {<br>
frame->topHeight = q->elementSize(prefix % \
"top").height();<br>
diff --git a/src/plasma/framesvg.h b/src/plasma/framesvg.h<br>
index 482956d..19bbee3 100644<br>
--- a/src/plasma/framesvg.h<br>
+++ b/src/plasma/framesvg.h<br>
@@ -218,7 +218,7 @@ class PLASMA_EXPORT FrameSvg : public Svg<br>
/**<br>
* @return a pixmap whose alpha channel is the opacity of the frame. It \
may be the frame itself or a special frame with the mask- prefix<br>
*/<br>
- QPixmap alphaMask() const;<br>
+ QImage alphaMask() const;<br>
<br>
/**<br>
* Sets whether saving all the rendered prefixes in a cache or not<br>
@@ -245,7 +245,7 @@ class PLASMA_EXPORT FrameSvg : public Svg<br>
* string for the whole SVG (the default)<br>
* @return a QPixmap of the rendered SVG<br>
*/<br>
- Q_INVOKABLE QPixmap framePixmap();<br>
+ QImage framePixmap();<br>
<br>
/**<br>
* Paints the loaded SVG with the elements that represents the \
border<br>
diff --git a/src/plasma/private/framesvg_p.h b/src/plasma/private/framesvg_p.h<br>
index 1bbc744..9cecd6b 100644<br>
--- a/src/plasma/private/framesvg_p.h<br>
+++ b/src/plasma/private/framesvg_p.h<br>
@@ -82,7 +82,7 @@ public:<br>
int refcount() const;<br>
<br>
FrameSvg::EnabledBorders enabledBorders;<br>
- QPixmap cachedBackground;<br>
+ QImage cachedBackground;<br>
QHash<QString, QRegion> cachedMasks;<br>
static const int MAX_CACHED_MASKS = 10;<br>
<br>
@@ -123,12 +123,12 @@ public:<br>
<br>
~FrameSvgPrivate();<br>
<br>
- QPixmap alphaMask();<br>
+ QImage alphaMask();<br>
<br>
void generateBackground(FrameData *frame);<br>
void generateFrameBackground(FrameData *frame);<br>
QString cacheId(FrameData *frame, const QString &prefixToUse) const;<br>
- void cacheFrame(const QString &prefixToSave, const QPixmap \
&background, const QPixmap &overlay);<br> + void cacheFrame(const \
QString &prefixToSave, const QImage &background, const QImage \
&overlay);<br> void updateSizes() const;<br>
void updateNeeded();<br>
void updateAndSignalSizes();<br>
diff --git a/src/plasma/private/svg_p.h b/src/plasma/private/svg_p.h<br>
index 332efda..c1a5acf 100644<br>
--- a/src/plasma/private/svg_p.h<br>
+++ b/src/plasma/private/svg_p.h<br>
@@ -72,7 +72,7 @@ public:<br>
Theme *actualTheme();<br>
Theme *cacheAndColorsTheme();<br>
<br>
- QPixmap findInCache(const QString &elementId, const QSizeF &s = \
QSizeF());<br> + QImage findInCache(const QString &elementId, const QSizeF \
&s = QSizeF());<br> <br>
void createRenderer();<br>
void eraseRenderer();<br>
diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp<br>
index 9b8b7df..b8e98b5 100644<br>
--- a/src/plasma/private/theme_p.cpp<br>
+++ b/src/plasma/private/theme_p.cpp<br>
@@ -307,10 +307,10 @@ void ThemePrivate::discardCache(CacheTypes caches)<br>
void ThemePrivate::scheduledCacheUpdate()<br>
{<br>
if (useCache()) {<br>
- QHashIterator<QString, QPixmap> it(pixmapsToCache);<br>
+ QHashIterator<QString, QImage> it(pixmapsToCache);<br>
while (it.hasNext()) {<br>
it.next();<br>
- pixmapCache->insertPixmap(idsToCache[it.key()], \
it.value());<br> + pixmapCache->insertImage(idsToCache[it.key()], \
it.value());<br> }<br>
}<br>
<br>
diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h<br>
index 291ce33..3c95478 100644<br>
--- a/src/plasma/private/theme_p.h<br>
+++ b/src/plasma/private/theme_p.h<br>
@@ -128,7 +128,7 @@ public:<br>
KImageCache *pixmapCache;<br>
KSharedConfigPtr svgElementsCache;<br>
QHash<QString, QSet<QString> > invalidElements;<br>
- QHash<QString, QPixmap> pixmapsToCache;<br>
+ QHash<QString, QImage> pixmapsToCache;<br>
QHash<QString, QString> keysToCache;<br>
QHash<QString, QString> idsToCache;<br>
QHash<styles, QString> cachedStyleSheets;<br>
diff --git a/src/plasma/svg.cpp b/src/plasma/svg.cpp<br>
index 9ec2aa5..38c0624 100644<br>
--- a/src/plasma/svg.cpp<br>
+++ b/src/plasma/svg.cpp<br>
@@ -263,7 +263,7 @@ Theme *SvgPrivate::cacheAndColorsTheme()<br>
}<br>
}<br>
<br>
-QPixmap SvgPrivate::findInCache(const QString &elementId, const QSizeF \
&s)<br> +QImage SvgPrivate::findInCache(const QString &elementId, const \
QSizeF &s)<br> {<br>
QSize size;<br>
QString actualElementId;<br>
@@ -326,7 +326,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, \
const QSizeF &s)<br> }<br>
<br>
if (size.isEmpty()) {<br>
- return QPixmap();<br>
+ return QImage();<br>
}<br>
<br>
QString id = cachePath(path, size);<br>
@@ -337,7 +337,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, \
const QSizeF &s)<br> <br>
//qDebug() << "id is " << id;<br>
<br>
- QPixmap p;<br>
+ QImage p;<br>
if (cacheRendering && cacheAndColorsTheme()->findInCache(id, p, \
lastModified)) {<br>
//qDebug() << "found cached version of " << id \
<< p.size();<br> return p;<br>
@@ -354,9 +354,11 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, \
const QSizeF &s)<br> <br>
//don't alter the pixmap size or it won't match up properly to, e.g., \
FrameSvg elements<br>
//makeUniform should never change the size so much that it gains or loses a \
whole pixel<br>
- p = QPixmap(size);<br>
+ p = QImage(size, QImage::Format_ARGB32_Premultiplied);<br>
<br>
+ //FIXME DAVE - do we need this?<br>
p.fill(Qt::transparent);<br>
+<br>
QPainter renderPainter(&p);<br>
<br>
if (actualElementId.isEmpty()) {<br>
@@ -369,9 +371,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, \
const QSizeF &s)<br> <br>
// Apply current color scheme if the svg asks for it<br>
if (applyColors) {<br>
- QImage itmp = p.toImage();<br>
- KIconEffect::colorize(itmp, \
cacheAndColorsTheme()->color(Theme::BackgroundColor), 1.0);<br>
- p = p.fromImage(itmp);<br>
+ KIconEffect::colorize(p, \
cacheAndColorsTheme()->color(Theme::BackgroundColor), 1.0);<br> }<br>
<br>
if (cacheRendering) {<br>
@@ -662,22 +662,32 @@ Svg::~Svg()<br>
QPixmap Svg::pixmap(const QString &elementID)<br>
{<br>
if (elementID.isNull() || d->multipleImages) {<br>
+ return QPixmap::fromImage((d->findInCache(elementID, size())));<br>
+ } else {<br>
+ return QPixmap::fromImage(d->findInCache(elementID));<br>
+ }<br>
+}<br>
+<br>
+QImage Svg::image(const QString& elementID)<br>
+{<br>
+ if (elementID.isNull() || d->multipleImages) {<br>
return d->findInCache(elementID, size());<br>
} else {<br>
return d->findInCache(elementID);<br>
}<br>
}<br>
<br>
+<br>
void Svg::paint(QPainter *painter, const QPointF &point, const QString \
&elementID)<br> {<br>
- QPixmap pix((elementID.isNull() || d->multipleImages) ? \
d->findInCache(elementID, size()) :<br> + QImage pix((elementID.isNull() || \
d->multipleImages) ? d->findInCache(elementID, size()) :<br>
\
d->findInCache(elementID));<br> <br>
if (pix.isNull()) {<br>
return;<br>
}<br>
<br>
- painter->drawPixmap(QRectF(point, pix.size()), pix, QRectF(QPointF(0, 0), \
pix.size()));<br> + painter->drawImage(QRectF(point, pix.size()), pix, \
QRectF(QPointF(0, 0), pix.size()));<br> }<br>
<br>
void Svg::paint(QPainter *painter, int x, int y, const QString &elementID)<br>
@@ -687,14 +697,14 @@ void Svg::paint(QPainter *painter, int x, int y, const QString \
&elementID)<br> <br>
void Svg::paint(QPainter *painter, const QRectF &rect, const QString \
&elementID)<br> {<br>
- QPixmap pix(d->findInCache(elementID, rect.size()));<br>
- painter->drawPixmap(QRectF(rect.topLeft(), pix.size()), pix, \
QRectF(QPointF(0, 0), pix.size()));<br> + QImage \
pix(d->findInCache(elementID, rect.size()));<br> + \
painter->drawImage(QRectF(rect.topLeft(), pix.size()), pix, QRectF(QPointF(0, 0), \
pix.size()));<br> }<br>
<br>
void Svg::paint(QPainter *painter, int x, int y, int width, int height, const \
QString &elementID)<br> {<br>
- QPixmap pix(d->findInCache(elementID, QSizeF(width, height)));<br>
- painter->drawPixmap(x, y, pix, 0, 0, pix.size().width(), \
pix.size().height());<br> + QImage pix(d->findInCache(elementID, \
QSizeF(width, height)));<br> + painter->drawImage(x, y, pix, 0, 0, \
pix.size().width(), pix.size().height());<br> }<br>
<br>
QSize Svg::size() const<br>
diff --git a/src/plasma/svg.h b/src/plasma/svg.h<br>
index 01d98f8..20c327a 100644<br>
--- a/src/plasma/svg.h<br>
+++ b/src/plasma/svg.h<br>
@@ -81,7 +81,10 @@ class PLASMA_EXPORT Svg : public QObject<br>
~Svg();<br>
<br>
/**<br>
- * Returns a pixmap of the SVG represented by this object.<br>
+ * DEPRECATED Returns a pixmap of the SVG represented by this \
object.<br> + *<br>
+ * image() is significantly faster as it avoids a conversion<br>
+ * Update your code<br>
*<br>
* The size of the pixmap will be the size of this Svg object \
(size())<br>
* if containsMultipleImages is @c true; otherwise, it will be the<br>
@@ -95,6 +98,21 @@ class PLASMA_EXPORT Svg : public QObject<br>
Q_INVOKABLE QPixmap pixmap(const QString &elementID = \
QString());<br> <br>
/**<br>
+ * Returns a pixmap of the SVG represented by this object.<br>
+ *<br>
+ * The size of the pixmap will be the size of this Svg object \
(size())<br> + * if containsMultipleImages is @c true; otherwise, it will \
be the<br> + * size of the requested element after the whole SVG has been \
scaled<br> + * to size().<br>
+ *<br>
+ * @param elementId the ID string of the element to render, or an \
empty<br> + * string for the whole SVG (the \
default)<br> + * @return a QPixmap of the rendered SVG<br>
+ */<br>
+ Q_INVOKABLE QImage image(const QString &elementID = QString());<br>
+<br>
+<br>
+ /**<br>
* Paints all or part of the SVG represented by this object<br>
*<br>
* The size of the painted area will be the size of this Svg object<br>
diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp<br>
index aba84d5..bf599f6 100644<br>
--- a/src/plasma/theme.cpp<br>
+++ b/src/plasma/theme.cpp<br>
@@ -299,7 +299,7 @@ bool Theme::useGlobalSettings() const<br>
return d->useGlobal;<br>
}<br>
<br>
-bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int \
lastModified)<br> +bool Theme::findInCache(const QString &key, QImage &pix, \
unsigned int lastModified)<br> {<br>
if (lastModified != 0 && d->useCache() && lastModified \
> uint(d->pixmapCache->lastModifiedTime().toTime_t())) {<br> return \
false;<br> @@ -312,8 +312,8 @@ bool Theme::findInCache(const QString &key, \
QPixmap &pix, unsigned int lastModif<br> return !pix.isNull();<br>
}<br>
<br>
- QPixmap temp;<br>
- if (d->pixmapCache->findPixmap(key, &temp) && \
!temp.isNull()) {<br> + QImage temp;<br>
+ if (d->pixmapCache->findImage(key, &temp) && \
!temp.isNull()) {<br> pix = temp;<br>
return true;<br>
}<br>
@@ -322,14 +322,14 @@ bool Theme::findInCache(const QString &key, QPixmap \
&pix, unsigned int lastModif<br> return false;<br>
}<br>
<br>
-void Theme::insertIntoCache(const QString& key, const QPixmap& pix)<br>
+void Theme::insertIntoCache(const QString& key, const QImage& pix)<br>
{<br>
if (d->useCache()) {<br>
- d->pixmapCache->insertPixmap(key, pix);<br>
+ d->pixmapCache->insertImage(key, pix);<br>
}<br>
}<br>
<br>
-void Theme::insertIntoCache(const QString& key, const QPixmap& pix, const \
QString& id)<br> +void Theme::insertIntoCache(const QString& key, const \
QImage& pix, const QString& id)<br> {<br>
if (d->useCache()) {<br>
d->pixmapsToCache.insert(id, pix);<br>
diff --git a/src/plasma/theme.h b/src/plasma/theme.h<br>
index 42677fb..a5cd4f7 100644<br>
--- a/src/plasma/theme.h<br>
+++ b/src/plasma/theme.h<br>
@@ -227,14 +227,14 @@ class PLASMA_EXPORT Theme : public QObject<br>
* where cache is still valid.<br>
*<br>
* @param key the name to use in the cache for this image<br>
- * @param pix the pixmap object to populate with the resulting data if \
found<br> + * @param pix the image object to populate with the resulting \
data if found<br>
* @param lastModified if non-zero, the time stamp is also checked on \
the file,<br>
* and must be newer than the timestamp \
to be loaded<br>
*<br>
* @return true when pixmap was found and loaded from cache, false \
otherwise<br>
* @since 4.3<br>
**/<br>
- bool findInCache(const QString &key, QPixmap &pix, unsigned int \
lastModified = 0);<br> + bool findInCache(const QString& key, \
QImage& pix, unsigned int lastModified = 0);<br> <br>
/**<br>
* Insert specified pixmap into the cache.<br>
@@ -242,9 +242,9 @@ class PLASMA_EXPORT Theme : public QObject<br>
* overwritten.<br>
*<br>
* @param key the name to use in the cache for this pixmap<br>
- * @param pix the pixmap data to store in the cache<br>
+ * @param pix the image data to store in the cache<br>
**/<br>
- void insertIntoCache(const QString& key, const QPixmap& \
pix);<br> + void insertIntoCache(const QString& key, const QImage& \
pix);<br> <br>
/**<br>
* Insert specified pixmap into the cache.<br>
@@ -257,14 +257,14 @@ class PLASMA_EXPORT Theme : public QObject<br>
* useful in the cache and just cause overhead.<br>
*<br>
* @param key the name to use in the cache for this pixmap<br>
- * @param pix the pixmap data to store in the cache<br>
+ * @param pix the image data to store in the cache<br>
* @param id a name that identifies the caller class of this function \
in an unique fashion.<br>
* This is needed to limit disk writes of the cache.<br>
* If an image with the same id changes quickly,<br>
* only the last size where insertIntoCache was called \
is actually stored on disk<br>
* @since 4.3<br>
**/<br>
- void insertIntoCache(const QString& key, const QPixmap& pix, \
const QString& id);<br> + void insertIntoCache(const QString& key, \
const QImage& pix, const QString& id);<br> <br>
/**<br>
* Sets the maximum size of the cache (in kilobytes). If cache gets \
bigger<br> <br>
</blockquote></div><br></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic