Changeset View
Changeset View
Standalone View
Standalone View
platformsupport/scenes/qpainter/backend.h
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | ||||
3 | This file is part of the KDE project. | ||||
4 | | ||||
5 | Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org> | ||||
6 | | ||||
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. | ||||
11 | | ||||
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. | ||||
16 | | ||||
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 | *********************************************************************/ | ||||
20 | #ifndef KWIN_SCENE_QPAINTER_BACKEND_H | ||||
21 | #define KWIN_SCENE_QPAINTER_BACKEND_H | ||||
22 | | ||||
23 | class QImage; | ||||
24 | class QRegion; | ||||
25 | class QSize; | ||||
26 | class QString; | ||||
27 | | ||||
28 | namespace KWin { | ||||
29 | class OverlayWindow; | ||||
30 | | ||||
31 | class QPainterBackend | ||||
32 | { | ||||
33 | public: | ||||
34 | virtual ~QPainterBackend(); | ||||
35 | virtual void present(int mask, const QRegion &damage) = 0; | ||||
36 | | ||||
37 | /** | ||||
38 | * @brief Returns the OverlayWindow used by the backend. | ||||
39 | * | ||||
40 | * A backend does not have to use an OverlayWindow, this is mostly for the X world. | ||||
41 | * In case the backend does not use an OverlayWindow it is allowed to return @c null. | ||||
42 | * It's the task of the caller to check whether it is @c null. | ||||
43 | * | ||||
44 | * @return :OverlayWindow* | ||||
45 | **/ | ||||
46 | virtual OverlayWindow *overlayWindow(); | ||||
47 | virtual bool usesOverlayWindow() const = 0; | ||||
48 | virtual void prepareRenderingFrame() = 0; | ||||
49 | /** | ||||
50 | * @brief Shows the Overlay Window | ||||
51 | * | ||||
52 | * Default implementation does nothing. | ||||
53 | */ | ||||
54 | virtual void showOverlay(); | ||||
55 | /** | ||||
56 | * @brief React on screen geometry changes. | ||||
57 | * | ||||
58 | * Default implementation does nothing. Override if specific functionality is required. | ||||
59 | * | ||||
60 | * @param size The new screen size | ||||
61 | */ | ||||
62 | virtual void screenGeometryChanged(const QSize &size); | ||||
63 | /** | ||||
64 | * @brief Whether the creation of the Backend failed. | ||||
65 | * | ||||
66 | * The SceneQPainter should test whether the Backend got constructed correctly. If this method | ||||
67 | * returns @c true, the SceneQPainter should not try to start the rendering. | ||||
68 | * | ||||
69 | * @return bool @c true if the creation of the Backend failed, @c false otherwise. | ||||
70 | **/ | ||||
71 | bool isFailed() const { | ||||
72 | return m_failed; | ||||
73 | } | ||||
74 | | ||||
75 | virtual QImage *buffer() = 0; | ||||
76 | /** | ||||
77 | * Overload for the case that there is a different buffer per screen. | ||||
78 | * Default implementation just calls buffer. | ||||
79 | * @param screenId The id of the screen as used in Screens | ||||
80 | * @todo Get a better identifier for screen then a counter variable | ||||
81 | **/ | ||||
82 | virtual QImage *bufferForScreen(int screenId); | ||||
83 | virtual bool needsFullRepaint() const = 0; | ||||
84 | /** | ||||
85 | * Whether the rendering needs to be split per screen. | ||||
86 | * Default implementation returns @c false. | ||||
87 | **/ | ||||
88 | virtual bool perScreenRendering() const; | ||||
89 | | ||||
90 | protected: | ||||
91 | QPainterBackend(); | ||||
92 | /** | ||||
93 | * @brief Sets the backend initialization to failed. | ||||
94 | * | ||||
95 | * This method should be called by the concrete subclass in case the initialization failed. | ||||
96 | * The given @p reason is logged as a warning. | ||||
97 | * | ||||
98 | * @param reason The reason why the initialization failed. | ||||
99 | **/ | ||||
100 | void setFailed(const QString &reason); | ||||
101 | | ||||
102 | private: | ||||
103 | bool m_failed; | ||||
104 | }; | ||||
105 | | ||||
106 | } // KWin | ||||
107 | | ||||
108 | #endif |