Drop support for native graphics system

Qt 5 only supports raster which means our pixmaps are always non native,
so we don't need the Extension information any more and can drop all
special code handling for mapping a native QPixmap to an X11 pixmap.
This commit is contained in:
Martin Gräßlin 2013-07-22 15:51:56 +02:00
parent e479cfb156
commit 2f9ff5591c
9 changed files with 3 additions and 141 deletions

View file

@ -381,15 +381,9 @@ void Compositor::fallbackToXRenderCompositing()
finish();
KConfigGroup config(KGlobal::config(), "Compositing");
config.writeEntry("Backend", "XRender");
config.writeEntry("GraphicsSystem", "native");
config.sync();
if (Extensions::nonNativePixmaps()) { // must restart to change the graphicssystem
restartKWin("automatic graphicssystem change for XRender backend");
return;
} else {
options->setCompositingMode(XRenderCompositing);
setup();
}
options->setCompositingMode(XRenderCompositing);
setup();
}
void Compositor::slotConfigChanged()
@ -407,12 +401,6 @@ void Compositor::slotReinitialize()
{
// Reparse config. Config options will be reloaded by setup()
KGlobal::config()->reparseConfiguration();
const QString graphicsSystem = KConfigGroup(KGlobal::config(), "Compositing").readEntry("GraphicsSystem", "");
if ((Extensions::nonNativePixmaps() && graphicsSystem == "native") ||
(!Extensions::nonNativePixmaps() && (graphicsSystem == "raster" || graphicsSystem == "opengl")) ) {
restartKWin("explicitly reconfigured graphicsSystem change");
return;
}
// Restart compositing
finish();

View file

@ -20,10 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "kwinglobals.h"
#include <QPainter>
#include <QPaintEngine>
#include <QPixmap>
#include <config-X11.h>
#include <assert.h>
@ -42,8 +38,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin
{
bool Extensions::non_native_pixmaps = false;
void Extensions::init()
{
static bool initPerformed = false;
@ -58,12 +52,6 @@ void Extensions::init()
#ifdef HAVE_XSYNC
XSyncQueryExtension(display(), &event_base, &error_base);
#endif
QPixmap pix(1,1);
QPainter p(&pix);
non_native_pixmaps = p.paintEngine()->type() != QPaintEngine::X11;
p.end();
kDebug(1212) << " non_native_pixmaps: " << non_native_pixmaps << endl;
initPerformed = true;
}

View file

@ -189,11 +189,6 @@ class KWIN_EXPORT Extensions
{
public:
static void init();
static bool nonNativePixmaps() {
return non_native_pixmaps;
}
private:
static bool non_native_pixmaps;
};
} // namespace

View file

@ -109,10 +109,6 @@ static xcb_render_picture_t createPicture(xcb_pixmap_t pix, int depth)
XRenderPicture::XRenderPicture(const QPixmap &pix)
{
if (!Extensions::nonNativePixmaps()) {
d = new XRenderPictureData(createPicture(pix.handle(), pix.depth()));
return;
}
QImage img(pix.toImage());
const int depth = img.depth();
xcb_pixmap_t xpix = xcb_generate_id(connection());

View file

@ -469,22 +469,6 @@ KDE_EXPORT int kdemain(int argc, char * argv[])
mallopt(M_TRIM_THRESHOLD, 5*pagesize);
#endif // M_TRIM_THRESHOLD
// the raster graphicssystem has a quite terrible performance on the XRender backend or when not
// compositing at all while some to many decorations suffer from bad performance of the native
// graphicssystem (lack of implementation, QGradient internally uses the raster system and
// XPutImage's the result because some graphics drivers have insufficient or bad performing
// implementations of XRenderCreate*Gradient)
//
// Therefore we allow configurationa and do some automagic selection to discourage
// ""known to be stupid" ideas ;-P
// The invalid system parameter "" will use the systems default graphicssystem
// "!= XRender" is intended since eg. pot. SW backends likely would profit from raster as well
KConfigGroup config(KSharedConfig::openConfig(KWIN_CONFIG), "Compositing");
QString preferredSystem("native");
if (config.readEntry("Enabled", true) && config.readEntry("Backend", "OpenGL") != "XRender")
preferredSystem = "";
QApplication::setGraphicsSystem(config.readEntry("GraphicsSystem", preferredSystem));
Display* dpy = XOpenDisplay(NULL);
if (!dpy) {
fprintf(stderr, "%s: FATAL ERROR while trying to open display %s\n",

View file

@ -44,9 +44,6 @@ PaintRedirector *PaintRedirector::create(Client *c, QWidget *widget)
if (effects->isOpenGLCompositing()) {
return new OpenGLPaintRedirector(c, widget);
} else {
if (!Extensions::nonNativePixmaps()) {
return new NativeXRenderPaintRedirector(c, widget);
}
return new RasterXRenderPaintRedirector(c, widget);
}
}
@ -483,60 +480,6 @@ void RasterXRenderPaintRedirector::paint(PaintRedirector::DecorationPixmap borde
img.width(), img.height(), offset.x(), offset.y(), 0, 32, img.byteCount(), img.constBits());
}
NativeXRenderPaintRedirector::NativeXRenderPaintRedirector(Client *c, QWidget *widget)
: PaintRedirector(c, widget)
{
resizePixmaps();
}
NativeXRenderPaintRedirector::~NativeXRenderPaintRedirector()
{
}
xcb_render_picture_t NativeXRenderPaintRedirector::picture(PaintRedirector::DecorationPixmap border) const
{
return m_pixmaps[border].x11PictureHandle();
}
void NativeXRenderPaintRedirector::resize(PaintRedirector::DecorationPixmap border, const QSize &size)
{
if (m_pixmaps[border].size() != size) {
m_pixmaps[border] = QPixmap(size);
}
m_pixmaps[border].fill(Qt::transparent);
}
void NativeXRenderPaintRedirector::paint(PaintRedirector::DecorationPixmap border, const QRect &r, const QRect &b, const QRegion &reg)
{
QPainter pt(&m_pixmaps[border]);
pt.translate(-r.topLeft());
pt.setCompositionMode(QPainter::CompositionMode_Source);
pt.setClipRegion(reg);
pt.drawPixmap(b.topLeft(), m_scratch);
pt.end();
}
void NativeXRenderPaintRedirector::fillScratch(Qt::GlobalColor color)
{
m_scratch.fill(color);
}
QPaintDevice *NativeXRenderPaintRedirector::recreateScratch(const QSize &size)
{
m_scratch = QPixmap(size);
return &m_scratch;
}
QPaintDevice *NativeXRenderPaintRedirector::scratch()
{
return &m_scratch;
}
void NativeXRenderPaintRedirector::discardScratch()
{
m_scratch = QPixmap();
}
} // namespace
#include "paintredirector.moc"

View file

@ -162,26 +162,6 @@ private:
static unsigned int s_count;
};
class NativeXRenderPaintRedirector : public PaintRedirector
{
Q_OBJECT
public:
NativeXRenderPaintRedirector(Client *c, QWidget *widget);
virtual ~NativeXRenderPaintRedirector();
protected:
virtual xcb_render_picture_t picture(DecorationPixmap border) const;
virtual void resize(DecorationPixmap border, const QSize &size);
virtual void paint(DecorationPixmap border, const QRect &r, const QRect &b, const QRegion &reg);
virtual void fillScratch(Qt::GlobalColor color);
virtual QPaintDevice *recreateScratch(const QSize &size);
virtual QPaintDevice *scratch();
virtual void discardScratch();
private:
QPixmap m_pixmaps[PixmapCount];
QPixmap m_scratch;
};
class RasterXRenderPaintRedirector : public ImageBasedPaintRedirector
{
Q_OBJECT

View file

@ -926,13 +926,7 @@ bool SceneOpenGL::Texture::load(const QPixmap& pixmap, GLenum target)
if (pixmap.isNull())
return false;
// Checking whether QPixmap comes with its own X11 Pixmap
if (Extensions::nonNativePixmaps()) {
return GLTexture::load(pixmap.toImage(), target);
}
// use the X11 pixmap provided by Qt
return load(pixmap.handle(), pixmap.size(), pixmap.depth());
return GLTexture::load(pixmap.toImage(), target);
}
void SceneOpenGL::Texture::findTarget()

View file

@ -1470,12 +1470,6 @@ QString Workspace::supportInformation() const
support.append(decorationPlugin()->supportInformation());
support.append("\nCompositing\n");
support.append( "===========\n");
support.append("Qt Graphics System: ");
if (Extensions::nonNativePixmaps()) {
support.append("raster\n");
} else {
support.append("native\n");
}
if (effects) {
support.append("Compositing is active\n");
switch (effects->compositingType()) {