Changeset View
Standalone View
plugins/platforms/drm/egl_gbm_backend.cpp
Show First 20 Lines • Show All 252 Lines • ▼ Show 20 Line(s) | 248 | const EGLint config_attribs[] = { | |||
---|---|---|---|---|---|
253 | EGL_ALPHA_SIZE, 0, | 253 | EGL_ALPHA_SIZE, 0, | ||
254 | EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, | 254 | EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, | ||
255 | EGL_CONFIG_CAVEAT, EGL_NONE, | 255 | EGL_CONFIG_CAVEAT, EGL_NONE, | ||
256 | EGL_NONE, | 256 | EGL_NONE, | ||
257 | }; | 257 | }; | ||
258 | 258 | | |||
259 | EGLint count; | 259 | EGLint count; | ||
260 | EGLConfig configs[1024]; | 260 | EGLConfig configs[1024]; | ||
261 | if (eglChooseConfig(eglDisplay(), config_attribs, configs, 1, &count) == EGL_FALSE) { | 261 | if (!eglChooseConfig(eglDisplay(), config_attribs, configs, sizeof(configs)/sizeof(EGLConfig), &count)) { | ||
262 | qCCritical(KWIN_DRM) << "choose config failed"; | 262 | qCCritical(KWIN_DRM) << "choose config failed"; | ||
263 | return false; | 263 | return false; | ||
264 | } | 264 | } | ||
265 | if (count != 1) { | | |||
266 | qCCritical(KWIN_DRM) << "choose config did not return a config" << count; | | |||
267 | return false; | | |||
268 | } | | |||
269 | setConfig(configs[0]); | | |||
270 | 265 | | |||
266 | qCDebug(KWIN_DRM) << "EGL buffer configs count:" << count; | ||||
267 | | ||||
268 | // loop through all configs, chosing the first one that has satisfying format | ||||
269 | for (EGLint i = 0; i < count; i++) { | ||||
270 | EGLint gbm_format, blue_size, red_size, green_size, alpha_size; | ||||
zzag: Coding style nitpick: use camelCase instead of snake_case. | |||||
271 | // query some configuration parameters, to show in debug log | ||||
272 | eglGetConfigAttrib(eglDisplay(), configs[i], EGL_NATIVE_VISUAL_ID, &gbm_format); | ||||
273 | // number of bits for color channel | ||||
274 | eglGetConfigAttrib(eglDisplay(), configs[i], EGL_RED_SIZE, &red_size); | ||||
275 | eglGetConfigAttrib(eglDisplay(), configs[i], EGL_GREEN_SIZE, &green_size); | ||||
276 | eglGetConfigAttrib(eglDisplay(), configs[i], EGL_BLUE_SIZE, &blue_size); | ||||
277 | eglGetConfigAttrib(eglDisplay(), configs[i], EGL_ALPHA_SIZE, &alpha_size); | ||||
278 | | ||||
279 | // output debug info | ||||
280 | // GBM formats are declared as FOURCC code (integer from ASCII chars, so use this fact) | ||||
281 | char gbm_format_str[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | ||||
May as well wrap this bit in QLoggingCategory::isDebugEnabled() If EGLInt is 8 bytes long you need to be 9 to include the '\0' character. davidedmundson: May as well wrap this bit in QLoggingCategory::isDebugEnabled()
If EGLInt is 8 bytes long you… | |||||
282 | memcpy(gbm_format_str, &gbm_format, sizeof(EGLint)); | ||||
283 | qCDebug(KWIN_DRM) << i << "th config GBM format:" << gbm_format_str | ||||
davidedmundson: th -> the | |||||
284 | << "; color sizes (RGBA order):" << red_size << green_size << blue_size << alpha_size; | ||||
285 | | ||||
286 | if (gbm_format == GBM_FORMAT_XRGB8888) { | ||||
(a) Maybe, I'm wrong but that's not how arrays are compared. zzag: (a) Maybe, I'm wrong but that's not how arrays are compared.
(b) GBM_FORMAT_XRGB8888 is an… | |||||
zzag: Stop! Misinterpreted it with gbm_format_str | |||||
Yeah, since GBM_FORMAT_XRGB8888 and others are defined as __gbm_fourcc_code('X', 'R', '2', '4'), which shifts ASCII chars into different offsets in integer, we can directly print this integer as string of chars, if followed by zero bytes. alexeymin: Yeah, since `GBM_FORMAT_XRGB8888` and others are defined as `__gbm_fourcc_code('X', 'R', '2'… | |||||
Sorry for that. Anyways, you could merge these [this and one below] two if statements. zzag: Sorry for that.
Anyways, you could merge these [this and one below] two if statements. | |||||
NP! alexeymin: NP!
About two `if`s, initially I tested configs with `GBM_FORMAT_XRGB8888` and… | |||||
287 | setConfig(configs[i]); | ||||
288 | return true; | ||||
289 | } | ||||
290 | if (gbm_format == GBM_FORMAT_ARGB8888) { | ||||
291 | setConfig(configs[i]); | ||||
271 | return true; | 292 | return true; | ||
272 | } | 293 | } | ||
294 | } | ||||
295 | | ||||
296 | qCCritical(KWIN_DRM) << "choose config did not return a suitable config" << count; | ||||
297 | return false; | ||||
298 | } | ||||
273 | 299 | | |||
274 | void EglGbmBackend::present() | 300 | void EglGbmBackend::present() | ||
275 | { | 301 | { | ||
276 | for (auto &o: m_outputs) { | 302 | for (auto &o: m_outputs) { | ||
277 | makeContextCurrent(o); | 303 | makeContextCurrent(o); | ||
278 | presentOnOutput(o); | 304 | presentOnOutput(o); | ||
279 | } | 305 | } | ||
280 | } | 306 | } | ||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |
Coding style nitpick: use camelCase instead of snake_case.