1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*********************************************************************/
28
#include "kwineffects.h"
35
class EffectFrameImpl;
36
class EffectWindowImpl;
40
// The base class for compositing backends.
49
// Returns true if the ctor failed to properly initialize.
50
virtual bool initFailed() const = 0;
51
virtual CompositingType compositingType() const = 0;
52
// Repaints the given screen areas, windows provides the stacking order.
53
// The entry point for the main part of the painting pass.
54
virtual void paint(QRegion damage, ToplevelList windows) = 0;
56
// Notification function - KWin core informs about changes.
57
// Used to mainly discard cached data.
59
// shape/size of a window changed
60
virtual void windowGeometryShapeChanged(Toplevel*) = 0;
61
// opacity of a window changed
62
virtual void windowOpacityChanged(Toplevel*) = 0;
63
// a new window has been created
64
virtual void windowAdded(Toplevel*) = 0;
65
// a window has been closed
66
virtual void windowClosed(Toplevel*, Deleted*) = 0;
67
// a window has been destroyed
68
virtual void windowDeleted(Deleted*) = 0;
69
// Flags controlling how painting is done.
71
// Window (or at least part of it) will be painted opaque.
72
PAINT_WINDOW_OPAQUE = 1 << 0,
73
// Window (or at least part of it) will be painted translucent.
74
PAINT_WINDOW_TRANSLUCENT = 1 << 1,
75
// Window will be painted with transformed geometry.
76
PAINT_WINDOW_TRANSFORMED = 1 << 2,
77
// Paint only a region of the screen (can be optimized, cannot
78
// be used together with TRANSFORMED flags).
79
PAINT_SCREEN_REGION = 1 << 3,
80
// Whole screen will be painted with transformed geometry.
81
PAINT_SCREEN_TRANSFORMED = 1 << 4,
82
// At least one window will be painted with transformed geometry.
83
PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS = 1 << 5,
84
// Clear whole background as the very first step, without optimizing it
85
PAINT_SCREEN_BACKGROUND_FIRST = 1 << 6,
86
// Temporary solution since (_OPAQUE | _TRANSLUCENT) is not working currently.
87
PAINT_DECORATION_ONLY = 1 << 7,
88
// Window will be painted with a lanczos filter.
89
PAINT_WINDOW_LANCZOS = 1 << 8,
90
// same as PAINT_SCREEN_TRANSFORMED without full repainting
91
PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS = 1 << 9
93
// types of filtering available
94
enum ImageFilterType { ImageFilterFast, ImageFilterGood };
95
inline uint estimatedRenderTime() {
96
return lastRenderTime;
98
// there's nothing to paint (adjust time_diff later)
100
bool waitSyncAvailable() {
104
// shared implementation, starts painting the screen
105
void paintScreen(int* mask, QRegion* region);
106
friend class EffectsHandlerImpl;
107
// called after all effects had their paintScreen() called
108
void finalPaintScreen(int mask, QRegion region, ScreenPaintData& data);
109
// shared implementation of painting the screen in the generic
111
virtual void paintGenericScreen(int mask, ScreenPaintData data);
112
// shared implementation of painting the screen in an optimized way
113
virtual void paintSimpleScreen(int mask, QRegion region);
114
// paint the background (not the desktop background - the whole background)
115
virtual void paintBackground(QRegion region) = 0;
116
// called after all effects had their paintWindow() called
117
void finalPaintWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data);
118
// shared implementation, starts painting the window
119
virtual void paintWindow(Window* w, int mask, QRegion region, WindowQuadList quads);
120
// called after all effects had their drawWindow() called
121
void finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data);
122
// compute time since the last repaint
123
void updateTimeDiff();
124
QList< QPoint > selfCheckPoints() const;
125
QRegion selfCheckRegion() const;
126
// dimensions of the test pixmap for selfcheck
127
int selfCheckWidth() const;
128
int selfCheckHeight() const;
129
// saved data for 2nd pass of optimized screen painting
131
Phase2Data(Window* w, QRegion r, QRegion c, int m, const WindowQuadList& q)
132
: window(w), region(r), clip(c), mask(m), quads(q) {}
141
WindowQuadList quads;
143
// windows in their stacking order
144
QVector< Window* > stacking_order;
145
// The region which actually has been painted by paintScreen() and should be
146
// copied from the buffer to the screen. I.e. the region returned from Scene::paintScreen().
147
// Since prePaintWindow() can extend areas to paint, these changes would have to propagate
148
// up all the way from paintSimpleScreen() up to paintScreen(), so save them here rather
149
// than propagate them up in arguments.
150
QRegion painted_region;
151
// time since last repaint
158
LanczosFilter* lanczos_filter;
161
// The base class for windows representations in composite backends
167
// perform the actual painting of the window
168
virtual void performPaint(int mask, QRegion region, WindowPaintData data) = 0;
169
// do any cleanup needed when the window's composite pixmap is discarded
170
virtual void pixmapDiscarded() {}
175
QRect geometry() const;
179
// access to the internal window class
180
// TODO eventually get rid of this
182
// should the window be painted
183
bool isPaintingEnabled() const;
184
void resetPaintingEnabled();
185
// Flags explaining why painting should be disabled
187
// Window will not be painted
188
PAINT_DISABLED = 1 << 0,
189
// Window will not be painted because it is deleted
190
PAINT_DISABLED_BY_DELETE = 1 << 1,
191
// Window will not be painted because of which desktop it's on
192
PAINT_DISABLED_BY_DESKTOP = 1 << 2,
193
// Window will not be painted because it is minimized
194
PAINT_DISABLED_BY_MINIMIZE = 1 << 3,
195
// Window will not be painted because it is not the active window in a client group
196
PAINT_DISABLED_BY_CLIENT_GROUP = 1 << 4,
197
// Window will not be painted because it's not on the current activity
198
PAINT_DISABLED_BY_ACTIVITY = 1 << 5
200
void enablePainting(int reason);
201
void disablePainting(int reason);
202
// is the window visible at all
203
bool isVisible() const;
204
// is the window fully opaque
205
bool isOpaque() const;
206
// shape of the window
207
QRegion shape() const;
208
QRegion clientShape() const;
210
void updateToplevel(Toplevel* c);
211
// creates initial quad list for the window
212
virtual WindowQuadList buildQuads(bool force = false) const;
213
void suspendUnredirect(bool suspend);
214
void updateShadow(Shadow* shadow);
215
const Shadow* shadow() const;
218
WindowQuadList makeQuads(WindowQuadType type, const QRegion& reg) const;
220
ImageFilterType filter;
223
int disable_painting;
224
mutable QRegion shape_region;
225
mutable bool shape_valid;
226
mutable WindowQuadList* cached_quad_list;
227
Q_DISABLE_COPY(Window)
230
class Scene::EffectFrame
233
EffectFrame(EffectFrameImpl* frame);
234
virtual ~EffectFrame();
235
virtual void render(QRegion region, double opacity, double frameOpacity) = 0;
236
virtual void free() = 0;
237
virtual void freeIconFrame() = 0;
238
virtual void freeTextFrame() = 0;
239
virtual void freeSelection() = 0;
240
virtual void crossFadeIcon() = 0;
241
virtual void crossFadeText() = 0;
244
EffectFrameImpl* m_effectFrame;
250
int Scene::selfCheckWidth() const
256
int Scene::selfCheckHeight() const
262
int Scene::Window::x() const
264
return toplevel->x();
268
int Scene::Window::y() const
270
return toplevel->y();
274
int Scene::Window::width() const
276
return toplevel->width();
280
int Scene::Window::height() const
282
return toplevel->height();
286
QRect Scene::Window::geometry() const
288
return toplevel->geometry();
292
QSize Scene::Window::size() const
294
return toplevel->size();
298
QPoint Scene::Window::pos() const
300
return toplevel->pos();
304
QRect Scene::Window::rect() const
306
return toplevel->rect();
310
Toplevel* Scene::Window::window()
316
void Scene::Window::updateToplevel(Toplevel* c)
322
void Scene::Window::suspendUnredirect(bool suspend)
324
toplevel->suspendUnredirect(suspend);
328
void Scene::Window::updateShadow(Shadow* shadow)
334
const Shadow* Scene::Window::shadow() const
340
Shadow* Scene::Window::shadow()