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