Port of mousemark effect to XCB

remotes/origin/Plasma/5.0
Martin Gräßlin 13 years ago
parent c5bebcd809
commit 5dc4b1d85d
  1. 21
      effects/mousemark/mousemark.cpp
  2. 4
      effects/mousemark/mousemark.h

@ -35,6 +35,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kdebug.h>
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
#include <xcb/render.h>
#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, <strike>tess...</strike> 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;
}
}

@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kwinglutils.h>
#include <kwinxrenderutils.h>
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;

Loading…
Cancel
Save