Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/fbdev/fb_backend.cpp
Show All 12 Lines | |||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 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/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "fb_backend.h" | 20 | #include "fb_backend.h" | ||
21 | | ||||
21 | #include "composite.h" | 22 | #include "composite.h" | ||
22 | #include "logging.h" | 23 | #include "logging.h" | ||
23 | #include "logind.h" | 24 | #include "logind.h" | ||
24 | #include "scene_qpainter_fb_backend.h" | 25 | #include "scene_qpainter_fb_backend.h" | ||
25 | #include "screens.h" | 26 | #include "outputscreens.h" | ||
26 | #include "virtual_terminal.h" | 27 | #include "virtual_terminal.h" | ||
27 | #include "udev.h" | 28 | #include "udev.h" | ||
28 | // system | 29 | // system | ||
29 | #include <fcntl.h> | 30 | #include <fcntl.h> | ||
30 | #include <unistd.h> | 31 | #include <unistd.h> | ||
31 | #include <sys/ioctl.h> | 32 | #include <sys/ioctl.h> | ||
32 | #include <sys/mman.h> | 33 | #include <sys/mman.h> | ||
33 | // Linux | 34 | // Linux | ||
Show All 12 Lines | 46 | { | |||
46 | unmap(); | 47 | unmap(); | ||
47 | if (m_fd >= 0) { | 48 | if (m_fd >= 0) { | ||
48 | close(m_fd); | 49 | close(m_fd); | ||
49 | } | 50 | } | ||
50 | } | 51 | } | ||
51 | 52 | | |||
52 | Screens *FramebufferBackend::createScreens(QObject *parent) | 53 | Screens *FramebufferBackend::createScreens(QObject *parent) | ||
53 | { | 54 | { | ||
54 | return new BasicScreens(this, parent); | 55 | return new OutputScreens(this, parent); | ||
55 | } | 56 | } | ||
56 | 57 | | |||
57 | QPainterBackend *FramebufferBackend::createQPainterBackend() | 58 | QPainterBackend *FramebufferBackend::createQPainterBackend() | ||
58 | { | 59 | { | ||
59 | return new FramebufferQPainterBackend(this); | 60 | return new FramebufferQPainterBackend(this); | ||
60 | } | 61 | } | ||
61 | 62 | | |||
62 | void FramebufferBackend::init() | 63 | void FramebufferBackend::init() | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 117 | { | |||
142 | varinfo.blue.msb_right = 0; | 143 | varinfo.blue.msb_right = 0; | ||
143 | ioctl(m_fd, FBIOPUT_VSCREENINFO, &varinfo); | 144 | ioctl(m_fd, FBIOPUT_VSCREENINFO, &varinfo); | ||
144 | 145 | | |||
145 | // Probe the device for new screen information. | 146 | // Probe the device for new screen information. | ||
146 | if (ioctl(m_fd, FBIOGET_VSCREENINFO, &varinfo) < 0) { | 147 | if (ioctl(m_fd, FBIOGET_VSCREENINFO, &varinfo) < 0) { | ||
147 | return false; | 148 | return false; | ||
148 | } | 149 | } | ||
149 | 150 | | |||
150 | m_resolution = QSize(varinfo.xres, varinfo.yres); | 151 | auto *output = new FramebufferOutput(this); | ||
151 | m_physicalSize = QSize(varinfo.width, varinfo.height); | 152 | output->setPixelSize(QSize(varinfo.xres, varinfo.yres)); | ||
153 | output->setRawPhysicalSize(QSize(varinfo.width, varinfo.height)); | ||||
154 | m_outputs << output; | ||||
155 | | ||||
152 | m_id = QByteArray(fixinfo.id); | 156 | m_id = QByteArray(fixinfo.id); | ||
153 | m_red = {varinfo.red.offset, varinfo.red.length}; | 157 | m_red = {varinfo.red.offset, varinfo.red.length}; | ||
154 | m_green = {varinfo.green.offset, varinfo.green.length}; | 158 | m_green = {varinfo.green.offset, varinfo.green.length}; | ||
155 | m_blue = {varinfo.blue.offset, varinfo.blue.length}; | 159 | m_blue = {varinfo.blue.offset, varinfo.blue.length}; | ||
156 | m_alpha = {varinfo.transp.offset, varinfo.transp.length}; | 160 | m_alpha = {varinfo.transp.offset, varinfo.transp.length}; | ||
157 | m_bitsPerPixel = varinfo.bits_per_pixel; | 161 | m_bitsPerPixel = varinfo.bits_per_pixel; | ||
158 | m_bufferLength = fixinfo.smem_len; | 162 | m_bufferLength = fixinfo.smem_len; | ||
159 | m_bytesPerLine = fixinfo.line_length; | 163 | m_bytesPerLine = fixinfo.line_length; | ||
Show All 25 Lines | 188 | if (!m_memory) { | |||
185 | return; | 189 | return; | ||
186 | } | 190 | } | ||
187 | if (munmap(m_memory, m_bufferLength) < 0) { | 191 | if (munmap(m_memory, m_bufferLength) < 0) { | ||
188 | qCWarning(KWIN_FB) << "Failed to munmap frame buffer"; | 192 | qCWarning(KWIN_FB) << "Failed to munmap frame buffer"; | ||
189 | } | 193 | } | ||
190 | m_memory = nullptr; | 194 | m_memory = nullptr; | ||
191 | } | 195 | } | ||
192 | 196 | | |||
197 | QSize FramebufferBackend::screenSize() const | ||||
198 | { | ||||
199 | if (m_outputs.isEmpty()) { | ||||
davidedmundson: Best to guard this being called before init() or if init fails. | |||||
I don't think it's necessary because the platform init should always be called before and if init fails, we're screwed anyways. But let's be sure and guard it. romangg: I don't think it's necessary because the platform init should always be called before and if… | |||||
200 | return QSize(); | ||||
201 | } | ||||
202 | return m_outputs[0]->pixelSize(); | ||||
203 | } | ||||
204 | | ||||
193 | QImage::Format FramebufferBackend::imageFormat() const | 205 | QImage::Format FramebufferBackend::imageFormat() const | ||
194 | { | 206 | { | ||
195 | return m_imageFormat; | 207 | return m_imageFormat; | ||
196 | } | 208 | } | ||
197 | 209 | | |||
198 | void FramebufferBackend::initImageFormat() | 210 | void FramebufferBackend::initImageFormat() | ||
199 | { | 211 | { | ||
200 | if (m_fd < 0) { | 212 | if (m_fd < 0) { | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 258 | } else if (m_bitsPerPixel == 16 && | |||
252 | m_red.offset == 11) { | 264 | m_red.offset == 11) { | ||
253 | qCDebug(KWIN_FB) << "Framebuffer Format is RGB16"; | 265 | qCDebug(KWIN_FB) << "Framebuffer Format is RGB16"; | ||
254 | m_imageFormat = QImage::Format_RGB16; | 266 | m_imageFormat = QImage::Format_RGB16; | ||
255 | } else { | 267 | } else { | ||
256 | qCWarning(KWIN_FB) << "Framebuffer format is unknown"; | 268 | qCWarning(KWIN_FB) << "Framebuffer format is unknown"; | ||
257 | } | 269 | } | ||
258 | } | 270 | } | ||
259 | 271 | | |||
272 | Outputs FramebufferBackend::outputs() const | ||||
273 | { | ||||
274 | return m_outputs; | ||||
275 | } | ||||
276 | | ||||
277 | Outputs FramebufferBackend::enabledOutputs() const | ||||
278 | { | ||||
279 | return m_outputs; | ||||
280 | } | ||||
281 | | ||||
260 | } | 282 | } |
Best to guard this being called before init() or if init fails.