Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/egl_gbm_backend.cpp
Show All 21 Lines | |||||
22 | #include "composite.h" | 22 | #include "composite.h" | ||
23 | #include "drm_backend.h" | 23 | #include "drm_backend.h" | ||
24 | #include "drm_output.h" | 24 | #include "drm_output.h" | ||
25 | #include "logging.h" | 25 | #include "logging.h" | ||
26 | #include "options.h" | 26 | #include "options.h" | ||
27 | #include "screens.h" | 27 | #include "screens.h" | ||
28 | // kwin libs | 28 | // kwin libs | ||
29 | #include <kwinglplatform.h> | 29 | #include <kwinglplatform.h> | ||
30 | // kwayland | ||||
31 | #include <KWayland/Server/buffer_interface.h> | ||||
30 | // Qt | 32 | // Qt | ||
31 | #include <QOpenGLContext> | 33 | #include <QOpenGLContext> | ||
32 | // system | 34 | // system | ||
33 | #include <gbm.h> | 35 | #include <gbm.h> | ||
34 | 36 | | |||
35 | namespace KWin | 37 | namespace KWin | ||
36 | { | 38 | { | ||
37 | 39 | | |||
38 | EglGbmBackend::EglGbmBackend(DrmBackend *b) | 40 | EglGbmBackend::EglGbmBackend(DrmBackend *b) | ||
39 | : QObject(NULL) | 41 | : QObject(NULL) | ||
40 | , AbstractEglBackend() | 42 | , AbstractEglBackend() | ||
41 | , m_backend(b) | 43 | , m_backend(b) | ||
42 | { | 44 | { | ||
43 | // Egl is always direct rendering | 45 | // Egl is always direct rendering | ||
44 | setIsDirectRendering(true); | 46 | setIsDirectRendering(true); | ||
45 | setSyncsToVBlank(true); | 47 | setSyncsToVBlank(true); | ||
48 | setSupportsDirectFullScreenScanout(true); | ||||
46 | connect(m_backend, &DrmBackend::outputAdded, this, &EglGbmBackend::createOutput); | 49 | connect(m_backend, &DrmBackend::outputAdded, this, &EglGbmBackend::createOutput); | ||
47 | connect(m_backend, &DrmBackend::outputRemoved, this, | 50 | connect(m_backend, &DrmBackend::outputRemoved, this, | ||
48 | [this] (DrmOutput *output) { | 51 | [this] (DrmOutput *output) { | ||
49 | auto it = std::find_if(m_outputs.begin(), m_outputs.end(), | 52 | auto it = std::find_if(m_outputs.begin(), m_outputs.end(), | ||
50 | [output] (const Output &o) { | 53 | [output] (const Output &o) { | ||
51 | return o.output == output; | 54 | return o.output == output; | ||
52 | } | 55 | } | ||
53 | ); | 56 | ); | ||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Line(s) | |||||
234 | void EglGbmBackend::presentOnOutput(EglGbmBackend::Output &o) | 237 | void EglGbmBackend::presentOnOutput(EglGbmBackend::Output &o) | ||
235 | { | 238 | { | ||
236 | eglSwapBuffers(eglDisplay(), o.eglSurface); | 239 | eglSwapBuffers(eglDisplay(), o.eglSurface); | ||
237 | o.buffer = m_backend->createBuffer(o.gbmSurface); | 240 | o.buffer = m_backend->createBuffer(o.gbmSurface); | ||
238 | m_backend->present(o.buffer, o.output); | 241 | m_backend->present(o.buffer, o.output); | ||
239 | if (supportsBufferAge()) { | 242 | if (supportsBufferAge()) { | ||
240 | eglQuerySurface(eglDisplay(), o.eglSurface, EGL_BUFFER_AGE_EXT, &o.bufferAge); | 243 | eglQuerySurface(eglDisplay(), o.eglSurface, EGL_BUFFER_AGE_EXT, &o.bufferAge); | ||
241 | } | 244 | } | ||
242 | | ||||
243 | } | 245 | } | ||
244 | 246 | | |||
245 | void EglGbmBackend::screenGeometryChanged(const QSize &size) | 247 | void EglGbmBackend::screenGeometryChanged(const QSize &size) | ||
246 | { | 248 | { | ||
247 | Q_UNUSED(size) | 249 | Q_UNUSED(size) | ||
248 | // TODO, create new buffer? | 250 | // TODO, create new buffer? | ||
249 | } | 251 | } | ||
250 | 252 | | |||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 320 | if (supportsBufferAge() && screenId == 0) { | |||
319 | if (o.damageHistory.count() > 10) { | 321 | if (o.damageHistory.count() > 10) { | ||
320 | o.damageHistory.removeLast(); | 322 | o.damageHistory.removeLast(); | ||
321 | } | 323 | } | ||
322 | 324 | | |||
323 | o.damageHistory.prepend(damagedRegion.intersected(o.output->geometry())); | 325 | o.damageHistory.prepend(damagedRegion.intersected(o.output->geometry())); | ||
324 | } | 326 | } | ||
325 | } | 327 | } | ||
326 | 328 | | |||
329 | bool EglGbmBackend::directScanoutForScreen(int screenId, KWayland::Server::BufferInterface *buffer) | ||||
330 | { | ||||
331 | Output &o = m_outputs[screenId]; | ||||
332 | | ||||
333 | o.buffer = m_backend->createDirectScanoutBuffer(buffer); | ||||
334 | | ||||
335 | if (o.buffer->size() != o.output->size()) { | ||||
336 | delete o.buffer; | ||||
337 | return false; | ||||
338 | } | ||||
339 | if (!m_backend->present(o.buffer, o.output)) { | ||||
340 | return false; | ||||
341 | } | ||||
342 | | ||||
343 | if (screenId == 0) { | ||||
344 | for (auto &o : m_outputs) { | ||||
345 | o.bufferAge = 0; | ||||
346 | } | ||||
347 | } | ||||
348 | | ||||
349 | return true; | ||||
350 | } | ||||
351 | | ||||
327 | bool EglGbmBackend::usesOverlayWindow() const | 352 | bool EglGbmBackend::usesOverlayWindow() const | ||
328 | { | 353 | { | ||
329 | return false; | 354 | return false; | ||
330 | } | 355 | } | ||
331 | 356 | | |||
332 | bool EglGbmBackend::perScreenRendering() const | 357 | bool EglGbmBackend::perScreenRendering() const | ||
333 | { | 358 | { | ||
334 | return true; | 359 | return true; | ||
Show All 14 Lines |