From 5dc4b1d85d9ab2e44805c3ef2b277a26419e7465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 29 Jan 2013 08:20:53 +0100 Subject: [PATCH] Port of mousemark effect to XCB --- effects/mousemark/mousemark.cpp | 21 +++++++++++++-------- effects/mousemark/mousemark.h | 4 +++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/effects/mousemark/mousemark.cpp b/effects/mousemark/mousemark.cpp index 23f67a307f..5a0c8351bc 100644 --- a/effects/mousemark/mousemark.cpp +++ b/effects/mousemark/mousemark.cpp @@ -35,6 +35,10 @@ along with this program. If not, see . #include +#ifdef KWIN_HAVE_XRENDER_COMPOSITING +#include +#endif + namespace KWin { @@ -76,7 +80,7 @@ void MouseMarkEffect::reconfigure(ReconfigureFlags) } #ifdef KWIN_HAVE_XRENDER_COMPOSITING -void MouseMarkEffect::addRect(const QPoint &p1, const QPoint &p2, XRectangle *r, XRenderColor *c) +void MouseMarkEffect::addRect(const QPoint &p1, const QPoint &p2, xcb_rectangle_t *r, xcb_render_color_t *c) { r->x = qMin(p1.x(), p2.x()) - width_2; r->y = qMin(p1.y(), p2.y()) - width_2; @@ -85,7 +89,7 @@ void MouseMarkEffect::addRect(const QPoint &p1, const QPoint &p2, XRectangle *r, // fast move -> large rect, tess... interpolate a line if (r->width > 3*width/2 && r->height > 3*width/2) { const int n = sqrt(r->width*r->width + r->height*r->height) / width; - XRectangle *rects = new XRectangle[n-1]; + xcb_rectangle_t *rects = new xcb_rectangle_t[n-1]; const int w = p1.x() < p2.x() ? r->width : -r->width; const int h = p1.y() < p2.y() ? r->height : -r->height; for (int i = 1; i < n; ++i) { @@ -93,7 +97,7 @@ void MouseMarkEffect::addRect(const QPoint &p1, const QPoint &p2, XRectangle *r, rects[i-1].y = p1.y() + i*h/n; rects[i-1].width = rects[i-1].height = width; } - XRenderFillRectangles(display(), PictOpSrc, effects->xrenderBufferPicture(), c, rects, n - 1); + xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), *c, n - 1, rects); delete [] rects; r->x = p1.x(); r->y = p1.y(); @@ -143,24 +147,25 @@ void MouseMarkEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat } #ifdef KWIN_HAVE_XRENDER_COMPOSITING if ( effects->compositingType() == XRenderCompositing) { - XRenderColor c = preMultiply(color); + XRenderColor xc = preMultiply(color); + xcb_render_color_t c = {xc.red, xc.green, xc.blue, xc.alpha}; for (int i = 0; i < marks.count(); ++i) { const int n = marks[i].count() - 1; if (n > 0) { - XRectangle *rects = new XRectangle[n]; + xcb_rectangle_t *rects = new xcb_rectangle_t[n]; for (int j = 0; j < marks[i].count()-1; ++j) { addRect(marks[i][j], marks[i][j+1], &rects[j], &c); } - XRenderFillRectangles(display(), PictOpSrc, effects->xrenderBufferPicture(), &c, rects, n); + xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), c, n, rects); delete [] rects; } } const int n = drawing.count() - 1; if (n > 0) { - XRectangle *rects = new XRectangle[n]; + xcb_rectangle_t *rects = new xcb_rectangle_t[n]; for (int i = 0; i < n; ++i) addRect(drawing[i], drawing[i+1], &rects[i], &c); - XRenderFillRectangles(display(), PictOpSrc, effects->xrenderBufferPicture(), &c, rects, n); + xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), c, n, rects); delete [] rects; } } diff --git a/effects/mousemark/mousemark.h b/effects/mousemark/mousemark.h index 34372cd033..e4bcf13b81 100644 --- a/effects/mousemark/mousemark.h +++ b/effects/mousemark/mousemark.h @@ -25,6 +25,8 @@ along with this program. If not, see . #include #include +struct xcb_render_color_t; + namespace KWin { @@ -58,7 +60,7 @@ private: typedef QVector< QPoint > Mark; static Mark createArrow(QPoint arrow_start, QPoint arrow_end); #ifdef KWIN_HAVE_XRENDER_COMPOSITING - void addRect(const QPoint &p1, const QPoint &p2, XRectangle *r, XRenderColor *c); + void addRect(const QPoint &p1, const QPoint &p2, xcb_rectangle_t *r, xcb_render_color_t *c); #endif QVector< Mark > marks; Mark drawing;