Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/egl_gbm_backend.cpp
| Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 116 | { | |||
|---|---|---|---|---|---|
| 121 | if (!initRenderingContext()) { | 121 | if (!initRenderingContext()) { | ||
| 122 | setFailed("Could not initialize rendering context"); | 122 | setFailed("Could not initialize rendering context"); | ||
| 123 | return; | 123 | return; | ||
| 124 | } | 124 | } | ||
| 125 | 125 | | |||
| 126 | initKWinGL(); | 126 | initKWinGL(); | ||
| 127 | initBufferAge(); | 127 | initBufferAge(); | ||
| 128 | initWayland(); | 128 | initWayland(); | ||
| 129 | initRemotePresent(); | ||||
| 129 | } | 130 | } | ||
| 130 | 131 | | |||
| 131 | bool EglGbmBackend::initRenderingContext() | 132 | bool EglGbmBackend::initRenderingContext() | ||
| 132 | { | 133 | { | ||
| 133 | initBufferConfigs(); | 134 | initBufferConfigs(); | ||
| 134 | 135 | | |||
| 135 | if (!createContext()) { | 136 | if (!createContext()) { | ||
| 136 | return false; | 137 | return false; | ||
| 137 | } | 138 | } | ||
| 138 | 139 | | |||
| 139 | const auto outputs = m_backend->outputs(); | 140 | const auto outputs = m_backend->outputs(); | ||
| 140 | for (DrmOutput *drmOutput: outputs) { | 141 | for (DrmOutput *drmOutput: outputs) { | ||
| 141 | createOutput(drmOutput); | 142 | createOutput(drmOutput); | ||
| 142 | } | 143 | } | ||
| 143 | if (m_outputs.isEmpty()) { | 144 | if (m_outputs.isEmpty()) { | ||
| 144 | qCCritical(KWIN_DRM) << "Create Window Surfaces failed"; | 145 | qCCritical(KWIN_DRM) << "Create Window Surfaces failed"; | ||
| 145 | return false; | 146 | return false; | ||
| 146 | } | 147 | } | ||
| 147 | // set our first surface as the one for the abstract backend, just to make it happy | 148 | // set our first surface as the one for the abstract backend, just to make it happy | ||
| 148 | setSurface(m_outputs.first().eglSurface); | 149 | setSurface(m_outputs.first().eglSurface); | ||
| 149 | 150 | | |||
| 150 | return makeContextCurrent(m_outputs.first()); | 151 | return makeContextCurrent(m_outputs.first()); | ||
| 151 | } | 152 | } | ||
| 152 | 153 | | |||
| 154 | void EglGbmBackend::initRemotePresent() | ||||
| 155 | { | ||||
| 156 | if (!qEnvironmentVariableIsSet("KWIN_REMOTE")) | ||||
romangg: Should be the default not directly activated remote funcitonality? And if one wants to… | |||||
There's no authentication protocol, so any malicious application can get whole screencast for free. Kanedias: There's no authentication protocol, so any malicious application can get whole screencast for… | |||||
romangg: Use braces: https://techbase.kde.org/Policies/Frameworks_Coding_Style#Braces | |||||
| 157 | return; | ||||
| 158 | | ||||
davidedmundson: you can do
bool foo =qEnvironmentVariableIsSet(""); | |||||
| 159 | qCDebug(KWIN_DRM) << "Support for remote access enabled"; | ||||
| 160 | m_remoteaccessManager.reset(new RemoteAccessManager); | ||||
| 161 | } | ||||
| 162 | | ||||
| 153 | bool EglGbmBackend::resetOutput(Output &o, DrmOutput *drmOutput) | 163 | bool EglGbmBackend::resetOutput(Output &o, DrmOutput *drmOutput) | ||
| 154 | { | 164 | { | ||
| 155 | o.output = drmOutput; | 165 | o.output = drmOutput; | ||
| 156 | auto size = drmOutput->pixelSize(); | 166 | auto size = drmOutput->pixelSize(); | ||
| 157 | 167 | | |||
| 158 | auto gbmSurface = std::make_shared<GbmSurface>(m_backend->gbmDevice(), size.width(), size.height(), | 168 | auto gbmSurface = std::make_shared<GbmSurface>(m_backend->gbmDevice(), size.width(), size.height(), | ||
| 159 | GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); | 169 | GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); | ||
| 160 | if (!gbmSurface) { | 170 | if (!gbmSurface) { | ||
| ▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 271 | for (auto &o: m_outputs) { | |||
| 263 | presentOnOutput(o); | 273 | presentOnOutput(o); | ||
| 264 | } | 274 | } | ||
| 265 | } | 275 | } | ||
| 266 | 276 | | |||
| 267 | void EglGbmBackend::presentOnOutput(EglGbmBackend::Output &o) | 277 | void EglGbmBackend::presentOnOutput(EglGbmBackend::Output &o) | ||
| 268 | { | 278 | { | ||
| 269 | eglSwapBuffers(eglDisplay(), o.eglSurface); | 279 | eglSwapBuffers(eglDisplay(), o.eglSurface); | ||
| 270 | o.buffer = m_backend->createBuffer(o.gbmSurface); | 280 | o.buffer = m_backend->createBuffer(o.gbmSurface); | ||
| 281 | if(m_remoteaccessManager && gbm_surface_has_free_buffers(o.gbmSurface->surface())) { | ||||
| 282 | // GBM surface is released on page flip so | ||||
| 283 | // we should pass the buffer before it's presented | ||||
| 284 | m_remoteaccessManager->passBuffer(o.output, o.buffer); | ||||
| 285 | } | ||||
| 271 | m_backend->present(o.buffer, o.output); | 286 | m_backend->present(o.buffer, o.output); | ||
| 287 | | ||||
| 272 | if (supportsBufferAge()) { | 288 | if (supportsBufferAge()) { | ||
| 273 | eglQuerySurface(eglDisplay(), o.eglSurface, EGL_BUFFER_AGE_EXT, &o.bufferAge); | 289 | eglQuerySurface(eglDisplay(), o.eglSurface, EGL_BUFFER_AGE_EXT, &o.bufferAge); | ||
| 274 | } | 290 | } | ||
| 275 | 291 | | |||
| 276 | } | 292 | } | ||
| 277 | 293 | | |||
| 278 | void EglGbmBackend::screenGeometryChanged(const QSize &size) | 294 | void EglGbmBackend::screenGeometryChanged(const QSize &size) | ||
| 279 | { | 295 | { | ||
| ▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines | |||||
Should be the default not directly activated remote funcitonality? And if one wants to deactivate remote set KWIN_NO_REMOTE or something.