use a qregion instead of a qbitmap for the frame

resizing is same speed, still pixmap->bitmap->region
just repainting should be quite faster
one of the last bic changes

svn path=/trunk/KDE/kdelibs/; revision=897385
This commit is contained in:
Marco Martin 2008-12-15 22:17:59 +00:00
parent 9c25aa59a5
commit 450e4a88a3
2 changed files with 11 additions and 10 deletions

View File

@ -23,6 +23,7 @@
#include <QPainter> #include <QPainter>
#include <QSize> #include <QSize>
#include <QBitmap> #include <QBitmap>
#include <QRegion>
#include <QTimer> #include <QTimer>
#include <kdebug.h> #include <kdebug.h>
@ -53,7 +54,7 @@ public:
FrameSvg::EnabledBorders enabledBorders; FrameSvg::EnabledBorders enabledBorders;
QPixmap cachedBackground; QPixmap cachedBackground;
QBitmap cachedMask; QRegion cachedMask;
QSizeF frameSize; QSizeF frameSize;
//measures //measures
@ -337,11 +338,11 @@ QRectF FrameSvg::contentsRect() const
} }
} }
QBitmap FrameSvg::mask() const QRegion FrameSvg::mask() const
{ {
FrameData *frame = d->frames[d->prefix]; FrameData *frame = d->frames[d->prefix];
if (!frame->cachedMask) { if (frame->cachedMask.isEmpty()) {
// ivan: we are testing whether we have the mask prefixed // ivan: we are testing whether we have the mask prefixed
// elements to use for creating the mask. // elements to use for creating the mask.
if (hasElement("mask-" + d->prefix + "center")) { if (hasElement("mask-" + d->prefix + "center")) {
@ -360,7 +361,7 @@ QBitmap FrameSvg::mask() const
if (maskFrame->cachedBackground.isNull()) { if (maskFrame->cachedBackground.isNull()) {
d->generateBackground(maskFrame); d->generateBackground(maskFrame);
if (maskFrame->cachedBackground.isNull()) { if (maskFrame->cachedBackground.isNull()) {
return QBitmap(); return QRegion();
} }
} }
@ -370,10 +371,10 @@ QBitmap FrameSvg::mask() const
if (frame->cachedBackground.isNull()) { if (frame->cachedBackground.isNull()) {
d->generateBackground(frame); d->generateBackground(frame);
if (frame->cachedBackground.isNull()) { if (frame->cachedBackground.isNull()) {
return QBitmap(); return QRegion();
} }
} }
frame->cachedMask = QBitmap(frame->cachedBackground.alphaChannel().createMaskFromColor(Qt::black)); frame->cachedMask = QRegion(QBitmap(frame->cachedBackground.alphaChannel().createMaskFromColor(Qt::black)));
} }
} }
return frame->cachedMask; return frame->cachedMask;
@ -656,7 +657,7 @@ void FrameSvgPrivate::updateSizes()
Q_ASSERT(frame); Q_ASSERT(frame);
frame->cachedBackground = QPixmap(); frame->cachedBackground = QPixmap();
frame->cachedMask = QPixmap(); frame->cachedMask = QRegion();
if (frame->enabledBorders & FrameSvg::TopBorder) { if (frame->enabledBorders & FrameSvg::TopBorder) {
frame->topHeight = q->elementSize(prefix + "top").height(); frame->topHeight = q->elementSize(prefix + "top").height();

View File

@ -200,10 +200,10 @@ class PLASMA_EXPORT FrameSvg : public Svg
QString prefix(); QString prefix();
/** /**
* Returns a monochrome mask that tightly contains the fully opaque areas of the svg * Returns a mask that tightly contains the fully opaque areas of the svg
* @return a monochrome bitmap of opaque areas * @return a region of opaque areas
*/ */
QBitmap mask() const; QRegion mask() const;
/** /**
* Sets whether saving all the rendered prefixes in a cache or not * Sets whether saving all the rendered prefixes in a cache or not