~ubuntu-branches/ubuntu/wily/kwin/wily-proposed

« back to all changes in this revision

Viewing changes to scene_qpainter.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-08-10 23:16:37 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20150810231637-5zb2tstjkez93hml
Tags: 4:5.3.95-0ubuntu1
new upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "shadow.h"
25
25
 
26
26
#include "decorations/decorationrenderer.h"
27
 
#if HAVE_WAYLAND
28
 
namespace KWayland
29
 
{
30
 
namespace Client
31
 
{
32
 
class Buffer;
33
 
}
34
 
}
35
 
#endif
36
27
 
37
28
namespace KWin {
38
29
 
40
31
    class Shm;
41
32
}
42
33
 
43
 
namespace Wayland
44
 
{
45
 
class WaylandBackend;
46
 
}
47
 
class FramebufferBackend;
48
 
class X11WindowedBackend;
49
 
 
50
 
class QPainterBackend
 
34
class KWIN_EXPORT QPainterBackend
51
35
{
52
36
public:
53
37
    virtual ~QPainterBackend();
92
76
    }
93
77
 
94
78
    virtual QImage *buffer() = 0;
 
79
    /**
 
80
     * Overload for the case that there is a different buffer per screen.
 
81
     * Default implementation just calls buffer.
 
82
     * @param screenId The id of the screen as used in Screens
 
83
     * @todo Get a better identifier for screen then a counter variable
 
84
     **/
 
85
    virtual QImage *bufferForScreen(int screenId);
95
86
    virtual bool needsFullRepaint() const = 0;
96
87
    virtual void renderCursor(QPainter *painter);
 
88
    /**
 
89
     * Whether the rendering needs to be split per screen.
 
90
     * Default implementation returns @c false.
 
91
     **/
 
92
    virtual bool perScreenRendering() const;
97
93
 
98
94
protected:
99
95
    QPainterBackend();
111
107
    bool m_failed;
112
108
};
113
109
 
114
 
#if HAVE_WAYLAND
115
 
class WaylandQPainterBackend : public QObject, public QPainterBackend
116
 
{
117
 
    Q_OBJECT
118
 
public:
119
 
    explicit WaylandQPainterBackend(Wayland::WaylandBackend *b);
120
 
    virtual ~WaylandQPainterBackend();
121
 
 
122
 
    virtual void present(int mask, const QRegion& damage) override;
123
 
    virtual bool usesOverlayWindow() const override;
124
 
    virtual void screenGeometryChanged(const QSize &size) override;
125
 
    virtual QImage *buffer() override;
126
 
    virtual void prepareRenderingFrame() override;
127
 
    virtual bool needsFullRepaint() const override;
128
 
private Q_SLOTS:
129
 
    void remapBuffer();
130
 
private:
131
 
    Wayland::WaylandBackend *m_backend;
132
 
    bool m_needsFullRepaint;
133
 
    QImage m_backBuffer;
134
 
    QWeakPointer<KWayland::Client::Buffer> m_buffer;
135
 
};
136
 
 
137
 
class X11WindowedQPainterBackend : public QObject, public QPainterBackend
138
 
{
139
 
    Q_OBJECT
140
 
public:
141
 
    X11WindowedQPainterBackend(X11WindowedBackend *backend);
142
 
    virtual ~X11WindowedQPainterBackend();
143
 
 
144
 
    QImage *buffer() override;
145
 
    bool needsFullRepaint() const override;
146
 
    bool usesOverlayWindow() const override;
147
 
    void prepareRenderingFrame() override;
148
 
    void present(int mask, const QRegion &damage) override;
149
 
    void screenGeometryChanged(const QSize &size);
150
 
 
151
 
private:
152
 
    bool m_needsFullRepaint = true;
153
 
    xcb_gcontext_t m_gc = XCB_NONE;
154
 
    QImage m_backBuffer;
155
 
    X11WindowedBackend *m_backend;
156
 
};
157
 
 
158
 
class FramebufferQPainterBackend : public QObject, public QPainterBackend
159
 
{
160
 
    Q_OBJECT
161
 
public:
162
 
    FramebufferQPainterBackend(FramebufferBackend *backend);
163
 
    virtual ~FramebufferQPainterBackend();
164
 
 
165
 
    QImage *buffer() override;
166
 
    bool needsFullRepaint() const override;
167
 
    bool usesOverlayWindow() const override;
168
 
    void prepareRenderingFrame() override;
169
 
    void present(int mask, const QRegion &damage) override;
170
 
    void renderCursor(QPainter *painter) override;
171
 
 
172
 
private:
173
 
    QImage m_renderBuffer;
174
 
    QImage m_backBuffer;
175
 
    FramebufferBackend *m_backend;
176
 
};
177
 
#endif
178
 
 
179
110
class SceneQPainter : public Scene
180
111
{
181
112
    Q_OBJECT