diff --git a/effects/magnifier/magnifier.cpp b/effects/magnifier/magnifier.cpp
index abb12e703f..d84a09ed37 100644
--- a/effects/magnifier/magnifier.cpp
+++ b/effects/magnifier/magnifier.cpp
@@ -225,10 +225,8 @@ void MagnifierEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat
{ int16_t(area.x()), int16_t(area.bottom()-FRAME_WIDTH), uint16_t(area.width()-FRAME_WIDTH), uint16_t(FRAME_WIDTH)},
{ int16_t(area.x()), int16_t(area.y()), uint16_t(FRAME_WIDTH), uint16_t(area.height()-FRAME_WIDTH)}
};
- // TODO: remove XRenderColor
- const XRenderColor xc = preMultiply(QColor(0,0,0,255));
- const xcb_render_color_t c = {xc.red, xc.green, xc.blue, xc.alpha};
- xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), c, 4, rects);
+ xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(),
+ preMultiply(QColor(0,0,0,255)), 4, rects);
#endif
}
}
diff --git a/effects/mousemark/mousemark.cpp b/effects/mousemark/mousemark.cpp
index dc53015a30..53679ff865 100644
--- a/effects/mousemark/mousemark.cpp
+++ b/effects/mousemark/mousemark.cpp
@@ -148,8 +148,7 @@ void MouseMarkEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat
}
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if ( effects->compositingType() == XRenderCompositing) {
- XRenderColor xc = preMultiply(color);
- xcb_render_color_t c = {xc.red, xc.green, xc.blue, xc.alpha};
+ xcb_render_color_t c = preMultiply(color);
for (int i = 0; i < marks.count(); ++i) {
const int n = marks[i].count() - 1;
if (n > 0) {
diff --git a/effects/snaphelper/snaphelper.cpp b/effects/snaphelper/snaphelper.cpp
index 7ceaa4193c..0b083cda08 100644
--- a/effects/snaphelper/snaphelper.cpp
+++ b/effects/snaphelper/snaphelper.cpp
@@ -155,9 +155,8 @@ void SnapHelperEffect::postPaintScreen()
rects[5].width = 4;
rects[5].height = 2*halfHeight - 4;
- XRenderColor xc = preMultiply(QColor(128, 128, 128, m_timeline.currentValue()*128));
- xcb_render_color_t c = {xc.red, xc.green, xc.blue, xc.alpha};
- xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_OVER, effects->xrenderBufferPicture(), c, 6, rects);
+ xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_OVER, effects->xrenderBufferPicture(),
+ preMultiply(QColor(128, 128, 128, m_timeline.currentValue()*128)), 6, rects);
}
#endif
}
diff --git a/libkwineffects/CMakeLists.txt b/libkwineffects/CMakeLists.txt
index e31b62ffaa..009d7bc21f 100644
--- a/libkwineffects/CMakeLists.txt
+++ b/libkwineffects/CMakeLists.txt
@@ -12,10 +12,8 @@ set(kwin_EFFECTSLIB_SRCS
kde4_add_library(kwineffects SHARED ${kwin_EFFECTSLIB_SRCS})
target_link_libraries(kwineffects ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY}
${X11_LIBRARIES}
- ${X11_Xrender_LIB}
${X11_Xrandr_LIB}
${X11_Xdamage_LIB}
- ${X11_Xfixes_LIB}
${XCB_XCB_LIBRARIES}
${X11_XCB_LIBRARIES}
${XCB_XFIXES_LIBRARIES}
diff --git a/libkwineffects/kwinxrenderutils.cpp b/libkwineffects/kwinxrenderutils.cpp
index 9ac5094f25..1cbef472f2 100644
--- a/libkwineffects/kwinxrenderutils.cpp
+++ b/libkwineffects/kwinxrenderutils.cpp
@@ -29,9 +29,9 @@ namespace KWin
{
// adapted from Qt, because this really sucks ;)
-XRenderColor preMultiply(const QColor &c, float opacity)
+xcb_render_color_t preMultiply(const QColor &c, float opacity)
{
- XRenderColor color;
+ xcb_render_color_t color;
const uint A = c.alpha() * opacity,
R = c.red(),
G = c.green(),
@@ -43,33 +43,38 @@ XRenderColor preMultiply(const QColor &c, float opacity)
return color;
}
-XRenderPicture xRenderFill(const XRenderColor *xc)
+XRenderPicture xRenderFill(const xcb_render_color_t &c)
{
- Pixmap pixmap = XCreatePixmap(display(), rootWindow(), 1, 1, 32);
- XRenderPictureAttributes pa; pa.repeat = True;
+ xcb_pixmap_t pixmap = xcb_generate_id(connection());
+ xcb_create_pixmap(connection(), 32, pixmap, rootWindow(), 1, 1);
XRenderPicture fill(pixmap, 32);
- XFreePixmap(display(), pixmap);
- XRenderChangePicture(display(), fill, CPRepeat, &pa);
- XRenderFillRectangle(display(), PictOpSrc, fill, xc, 0, 0, 1, 1);
+ xcb_free_pixmap(connection(), pixmap);
+
+ uint32_t values[] = {true};
+ xcb_render_change_picture(connection(), fill, XCB_RENDER_CP_REPEAT, values);
+
+ xcb_rectangle_t rect = {0, 0, 1, 1};
+ xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, fill, c, 1, &rect);
return fill;
}
XRenderPicture xRenderFill(const QColor &c)
{
- XRenderColor xc = preMultiply(c);
- return xRenderFill(&xc);
+ return xRenderFill(preMultiply(c));
}
-static XRenderPicture _blendPicture(X::None);
-static XRenderColor _blendColor;
XRenderPicture xRenderBlendPicture(double opacity)
{
- _blendColor.alpha = ushort(opacity * 0xffff);
- if (_blendPicture == X::None)
- _blendPicture = xRenderFill(&_blendColor);
- else
- XRenderFillRectangle(display(), PictOpSrc, _blendPicture, &_blendColor, 0, 0, 1, 1);
- return _blendPicture;
+ static XRenderPicture s_blendPicture(XCB_RENDER_PICTURE_NONE);
+ static xcb_render_color_t s_blendColor = {0, 0, 0, 0};
+ s_blendColor.alpha = uint16_t(opacity * 0xffff);
+ if (s_blendPicture == XCB_RENDER_PICTURE_NONE) {
+ s_blendPicture = xRenderFill(s_blendColor);
+ } else {
+ xcb_rectangle_t rect = {0, 0, 1, 1};
+ xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, s_blendPicture, s_blendColor, 1, &rect);
+ }
+ return s_blendPicture;
}
static xcb_render_picture_t createPicture(xcb_pixmap_t pix, int depth)
diff --git a/libkwineffects/kwinxrenderutils.h b/libkwineffects/kwinxrenderutils.h
index b8c47818c5..2d2ff7323c 100644
--- a/libkwineffects/kwinxrenderutils.h
+++ b/libkwineffects/kwinxrenderutils.h
@@ -24,25 +24,26 @@ along with this program. If not, see .
#include
#include
-#include
#include
#include
#include
-#include
+// TODO: remove, currently only included to not break builds of effects
#include
#include
+class QColor;
+
/** @addtogroup kwineffects */
/** @{ */
namespace KWin
{
/**
- * dumps a QColor into a XRenderColor
+ * dumps a QColor into a xcb_render_color_t
*/
-KWIN_EXPORT XRenderColor preMultiply(const QColor &c, float opacity = 1.0);
+KWIN_EXPORT xcb_render_color_t preMultiply(const QColor &c, float opacity = 1.0);
/** @internal */
class KWIN_EXPORT XRenderPictureData
@@ -158,7 +159,7 @@ KWIN_EXPORT XRenderPicture xRenderBlendPicture(double opacity);
/**
* Creates a 1x1 Picture filled with c
*/
-KWIN_EXPORT XRenderPicture xRenderFill(const XRenderColor *c);
+KWIN_EXPORT XRenderPicture xRenderFill(const xcb_render_color_t &c);
KWIN_EXPORT XRenderPicture xRenderFill(const QColor &c);
/**
diff --git a/scene_xrender.cpp b/scene_xrender.cpp
index c8cb09b5e0..019e6cd0ec 100644
--- a/scene_xrender.cpp
+++ b/scene_xrender.cpp
@@ -697,13 +697,21 @@ XRenderComposite(display(), PictOpOver, _PART_->x11PictureHandle(), decorationAl
if (data.brightness() != 1.0) {
// fake brightness change by overlaying black
const float alpha = (1 - data.brightness()) * data.opacity();
- XRenderColor col = preMultiply(data.brightness() < 1.0 ? QColor(0,0,0,255*alpha) : QColor(255,255,255,-alpha*255));
+ xcb_rectangle_t rect;
if (blitInTempPixmap) {
- XRenderFillRectangle(display(), PictOpOver, renderTarget, &col,
- -temp_visibleRect.left(), -temp_visibleRect.top(), width(), height());
+ rect.x = -temp_visibleRect.left();
+ rect.y = -temp_visibleRect.top();
+ rect.width = width();
+ rect.height = height();
} else {
- XRenderFillRectangle(display(), PictOpOver, renderTarget, &col, wr.x(), wr.y(), wr.width(), wr.height());
+ rect.x = wr.x();
+ rect.y = wr.y();
+ rect.width = wr.width();
+ rect.height = wr.height();
}
+ xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_OVER, renderTarget,
+ preMultiply(data.brightness() < 1.0 ? QColor(0,0,0,255*alpha) : QColor(255,255,255,-alpha*255)),
+ 1, &rect);
}
if (blitInTempPixmap) {
const QRect r = mapToScreen(mask, data, temp_visibleRect);