[wayland] Move X11WindowedQPainterBackend into backends/x11

master
Martin Gräßlin 10 years ago
parent f7bf7cb7ba
commit d80984beab

@ -441,6 +441,7 @@ if(HAVE_WAYLAND)
backends/fbdev/screens_fb.cpp
backends/wayland/scene_qpainter_wayland_backend.cpp
backends/wayland/screens_wayland.cpp
backends/x11/scene_qpainter_x11_backend.cpp
backends/x11/screens_x11windowed.cpp
virtual_terminal.cpp
backends/wayland/wayland_backend.cpp

@ -0,0 +1,83 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2015 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "scene_qpainter_x11_backend.h"
#include "x11windowed_backend.h"
namespace KWin
{
X11WindowedQPainterBackend::X11WindowedQPainterBackend(X11WindowedBackend *backend)
: QPainterBackend()
, m_backBuffer(backend->size(), QImage::Format_RGB32)
, m_backend(backend)
{
}
X11WindowedQPainterBackend::~X11WindowedQPainterBackend()
{
if (m_gc) {
xcb_free_gc(m_backend->connection(), m_gc);
}
}
QImage *X11WindowedQPainterBackend::buffer()
{
return &m_backBuffer;
}
bool X11WindowedQPainterBackend::needsFullRepaint() const
{
return m_needsFullRepaint;
}
void X11WindowedQPainterBackend::prepareRenderingFrame()
{
}
void X11WindowedQPainterBackend::screenGeometryChanged(const QSize &size)
{
if (m_backBuffer.size() != size) {
m_backBuffer = QImage(size, QImage::Format_RGB32);
m_backBuffer.fill(Qt::black);
m_needsFullRepaint = true;
}
}
void X11WindowedQPainterBackend::present(int mask, const QRegion &damage)
{
Q_UNUSED(mask)
Q_UNUSED(damage)
xcb_connection_t *c = m_backend->connection();
const xcb_window_t window = m_backend->window();
if (m_gc == XCB_NONE) {
m_gc = xcb_generate_id(c);
xcb_create_gc(c, m_gc, window, 0, nullptr);
}
// TODO: only update changes?
xcb_put_image(c, XCB_IMAGE_FORMAT_Z_PIXMAP, window, m_gc,
m_backBuffer.width(), m_backBuffer.height(), 0, 0, 0, 24,
m_backBuffer.byteCount(), m_backBuffer.constBits());
}
bool X11WindowedQPainterBackend::usesOverlayWindow() const
{
return false;
}
}

@ -0,0 +1,55 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2015 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_SCENE_QPAINTER_X11_BACKEND_H
#define KWIN_SCENE_QPAINTER_X11_BACKEND_H
#include "scene_qpainter.h"
#include <QObject>
namespace KWin
{
class X11WindowedBackend;
class X11WindowedQPainterBackend : public QObject, public QPainterBackend
{
Q_OBJECT
public:
X11WindowedQPainterBackend(X11WindowedBackend *backend);
virtual ~X11WindowedQPainterBackend();
QImage *buffer() override;
bool needsFullRepaint() const override;
bool usesOverlayWindow() const override;
void prepareRenderingFrame() override;
void present(int mask, const QRegion &damage) override;
void screenGeometryChanged(const QSize &size);
private:
bool m_needsFullRepaint = true;
xcb_gcontext_t m_gc = XCB_NONE;
QImage m_backBuffer;
X11WindowedBackend *m_backend;
};
}
#endif

@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "x11windowed_backend.h"
#include "scene_qpainter.h"
#include "scene_qpainter_x11_backend.h"
#include "screens_x11windowed.h"
#include "utils.h"
#include "wayland_server.h"

@ -28,8 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "screens.h"
#include "toplevel.h"
#if HAVE_WAYLAND
#include "abstract_backend.h"
#include "wayland_server.h"
#include "backends/x11/x11windowed_backend.h"
#include <KWayland/Server/buffer_interface.h>
#include <KWayland/Server/surface_interface.h>
#endif
@ -91,71 +91,6 @@ QImage *QPainterBackend::bufferForScreen(int screenId)
return buffer();
}
#if HAVE_WAYLAND
//****************************************
// X11WindowedBackend
//****************************************
X11WindowedQPainterBackend::X11WindowedQPainterBackend(X11WindowedBackend *backend)
: QPainterBackend()
, m_backBuffer(backend->size(), QImage::Format_RGB32)
, m_backend(backend)
{
}
X11WindowedQPainterBackend::~X11WindowedQPainterBackend()
{
if (m_gc) {
xcb_free_gc(m_backend->connection(), m_gc);
}
}
QImage *X11WindowedQPainterBackend::buffer()
{
return &m_backBuffer;
}
bool X11WindowedQPainterBackend::needsFullRepaint() const
{
return m_needsFullRepaint;
}
void X11WindowedQPainterBackend::prepareRenderingFrame()
{
}
void X11WindowedQPainterBackend::screenGeometryChanged(const QSize &size)
{
if (m_backBuffer.size() != size) {
m_backBuffer = QImage(size, QImage::Format_RGB32);
m_backBuffer.fill(Qt::black);
m_needsFullRepaint = true;
}
}
void X11WindowedQPainterBackend::present(int mask, const QRegion &damage)
{
Q_UNUSED(mask)
Q_UNUSED(damage)
xcb_connection_t *c = m_backend->connection();
const xcb_window_t window = m_backend->window();
if (m_gc == XCB_NONE) {
m_gc = xcb_generate_id(c);
xcb_create_gc(c, m_gc, window, 0, nullptr);
}
// TODO: only update changes?
xcb_put_image(c, XCB_IMAGE_FORMAT_Z_PIXMAP, window, m_gc,
m_backBuffer.width(), m_backBuffer.height(), 0, 0, 0, 24,
m_backBuffer.byteCount(), m_backBuffer.constBits());
}
bool X11WindowedQPainterBackend::usesOverlayWindow() const
{
return false;
}
#endif
//****************************************
// SceneQPainter
//****************************************

@ -31,8 +31,6 @@ namespace Xcb {
class Shm;
}
class X11WindowedBackend;
class QPainterBackend
{
public:
@ -109,30 +107,6 @@ private:
bool m_failed;
};
#if HAVE_WAYLAND
class X11WindowedQPainterBackend : public QObject, public QPainterBackend
{
Q_OBJECT
public:
X11WindowedQPainterBackend(X11WindowedBackend *backend);
virtual ~X11WindowedQPainterBackend();
QImage *buffer() override;
bool needsFullRepaint() const override;
bool usesOverlayWindow() const override;
void prepareRenderingFrame() override;
void present(int mask, const QRegion &damage) override;
void screenGeometryChanged(const QSize &size);
private:
bool m_needsFullRepaint = true;
xcb_gcontext_t m_gc = XCB_NONE;
QImage m_backBuffer;
X11WindowedBackend *m_backend;
};
#endif
class SceneQPainter : public Scene
{
Q_OBJECT

Loading…
Cancel
Save