kwin: Refactor some code in the PaintRedirector

Add virtual resizePixmaps() and updatePixmaps() methods that resizes and
updates all the pixmaps. Make resize() and paint() regular virtuals
with stub implementations.

The new methods will be used by OpenGLPaintRedirector in the next commit.
This commit is contained in:
Fredrik Höglund 2013-03-16 14:45:14 +01:00
parent 1fd779695f
commit e862bfe569
2 changed files with 52 additions and 19 deletions

View file

@ -187,9 +187,7 @@ void PaintRedirector::ensurePixmapsPainted()
QRect rects[PixmapCount];
m_client->layoutDecorationRects(rects[LeftPixmap], rects[TopPixmap], rects[RightPixmap], rects[BottomPixmap], Client::DecorationRelative);
for (int i=0; i<PixmapCount; ++i) {
repaintPixmap(DecorationPixmap(i), rects[i], pending);
}
updatePixmaps(rects, pending);
pending = QRegion();
scheduled = QRegion();
@ -197,30 +195,33 @@ void PaintRedirector::ensurePixmapsPainted()
xcb_flush(connection());
}
void PaintRedirector::updatePixmaps(const QRect *rects, const QRegion &region)
{
for (int i = 0; i < PixmapCount; ++i) {
if (!rects[i].isValid())
continue;
const QRect bounding = region.boundingRect();
const QRegion reg = region & rects[i];
if (reg.isEmpty())
continue;
paint(DecorationPixmap(i), rects[i], bounding, reg);
}
}
void PaintRedirector::preparePaint(const QPixmap &pending)
{
Q_UNUSED(pending)
}
void PaintRedirector::repaintPixmap(DecorationPixmap border, const QRect &r, QRegion reg)
{
if (!r.isValid())
return;
const QRect b = reg.boundingRect();
reg &= r;
if (reg.isEmpty())
return;
paint(border, r, b, reg);
}
void PaintRedirector::resizePixmaps()
{
QRect rects[PixmapCount];
m_client->layoutDecorationRects(rects[LeftPixmap], rects[TopPixmap], rects[RightPixmap], rects[BottomPixmap], Client::DecorationRelative);
for (int i=0; i<PixmapCount; ++i) {
resize(DecorationPixmap(i), rects[i].size());
}
resizePixmaps(rects);
// repaint
if (widget) {
@ -228,6 +229,13 @@ void PaintRedirector::resizePixmaps()
}
}
void PaintRedirector::resizePixmaps(const QRect *rects)
{
for (int i = 0; i < PixmapCount; ++i) {
resize(DecorationPixmap(i), rects[i].size());
}
}
GLTexture *PaintRedirector::texture(PaintRedirector::DecorationPixmap border) const
{
Q_UNUSED(border)
@ -240,6 +248,28 @@ xcb_render_picture_t PaintRedirector::picture(PaintRedirector::DecorationPixmap
return XCB_RENDER_PICTURE_NONE;
}
void PaintRedirector::resize(DecorationPixmap border, const QSize &size)
{
Q_UNUSED(border)
Q_UNUSED(size)
}
void PaintRedirector::paint(DecorationPixmap border, const QRect& r, const QRect &b, const QRegion &reg)
{
Q_UNUSED(border)
Q_UNUSED(r)
Q_UNUSED(b)
Q_UNUSED(reg)
}
// ------------------------------------------------------------------
ImageBasedPaintRedirector::ImageBasedPaintRedirector(Client *c, QWidget *widget)
: PaintRedirector(c, widget)
{

View file

@ -92,13 +92,16 @@ protected:
PaintRedirector(Client *c, QWidget* widget);
virtual xcb_render_picture_t picture(DecorationPixmap border) const;
virtual GLTexture *texture(DecorationPixmap border) const;
virtual void resize(DecorationPixmap border, const QSize &size) = 0;
virtual void resizePixmaps(const QRect *rects);
virtual void resize(DecorationPixmap border, const QSize &size);
virtual void preparePaint(const QPixmap &pending);
virtual void paint(DecorationPixmap border, const QRect& r, const QRect &b, const QRegion &reg) = 0;
virtual void updatePixmaps(const QRect *rects, const QRegion &region);
virtual void paint(DecorationPixmap border, const QRect& r, const QRect &b, const QRegion &reg);
virtual QPaintDevice *scratch() = 0;
virtual QPaintDevice *recreateScratch(const QSize &size) = 0;
virtual void fillScratch(Qt::GlobalColor color) = 0;
virtual void discardScratch() = 0;
private:
void added(QWidget* widget);
void removed(QWidget* widget);