Merge "Support EGL protected content extension"

This commit is contained in:
Elvis Lee 2021-01-28 17:16:04 +09:00 committed by Qt CI Bot
commit b34462c840
4 changed files with 37 additions and 2 deletions

View File

@ -152,6 +152,9 @@ public:
the monitoring of the loss of context, such as, Windows with WGL, or Linux/X11 (xcb) with GLX, will the monitoring of the loss of context, such as, Windows with WGL, or Linux/X11 (xcb) with GLX, will
monitor the status in every call to \l{QOpenGLContext::makeCurrent()}{makeCurrent()}. See monitor the status in every call to \l{QOpenGLContext::makeCurrent()}{makeCurrent()}. See
\l{QOpenGLContext::isValid()}{isValid()} for more information on this. \l{QOpenGLContext::isValid()}{isValid()} for more information on this.
\value ProtectedContent Enables access to protected content. This allows the GPU to operate on protected
resources (surfaces, buffers, textures), for example DRM-protected video content.
Currently only implemented for EGL.
*/ */
/*! /*!
@ -351,6 +354,9 @@ void QSurfaceFormat::setSamples(int numSamples)
Sets the format options to \a options. Sets the format options to \a options.
To verify that an option was respected, compare the actual format to the
requested format after surface/context creation.
\sa options(), testOption() \sa options(), testOption()
*/ */
void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options) void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options)
@ -366,6 +372,9 @@ void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options)
Sets the format option \a option if \a on is true; otherwise, clears the option. Sets the format option \a option if \a on is true; otherwise, clears the option.
To verify that an option was respected, compare the actual format to the
requested format after surface/context creation.
\sa setOptions(), options(), testOption() \sa setOptions(), options(), testOption()
*/ */
void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option, bool on) void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option, bool on)

View File

@ -57,7 +57,8 @@ public:
StereoBuffers = 0x0001, StereoBuffers = 0x0001,
DebugContext = 0x0002, DebugContext = 0x0002,
DeprecatedFunctions = 0x0004, DeprecatedFunctions = 0x0004,
ResetNotification = 0x0008 ResetNotification = 0x0008,
ProtectedContent = 0x0010
}; };
Q_ENUM(FormatOption) Q_ENUM(FormatOption)
Q_DECLARE_FLAGS(FormatOptions, FormatOption) Q_DECLARE_FLAGS(FormatOptions, FormatOption)

View File

@ -155,6 +155,17 @@ QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatform
} }
} }
#ifdef EGL_EXT_protected_content
if (format.testOption(QSurfaceFormat::ProtectedContent)) {
if (q_hasEglExtension(m_eglDisplay, "EGL_EXT_protected_content")) {
contextAttrs.append(EGL_PROTECTED_CONTENT_EXT);
contextAttrs.append(EGL_TRUE);
} else {
m_format.setOption(QSurfaceFormat::ProtectedContent, false);
}
}
#endif
// Special Options for OpenVG surfaces // Special Options for OpenVG surfaces
if (m_format.renderableType() == QSurfaceFormat::OpenVG) { if (m_format.renderableType() == QSurfaceFormat::OpenVG) {
contextAttrs.append(EGL_ALPHA_MASK_SIZE); contextAttrs.append(EGL_ALPHA_MASK_SIZE);

View File

@ -67,7 +67,21 @@ void QEglFSKmsGbmWindow::resetSurface()
} }
if (createPlatformWindowSurface) { if (createPlatformWindowSurface) {
m_surface = createPlatformWindowSurface(display, m_config, reinterpret_cast<void *>(m_window), nullptr); QVector<EGLint> contextAttributes;
#ifdef EGL_EXT_protected_content
if (platformFormat.testOption(QSurfaceFormat::ProtectedContent)) {
if (q_hasEglExtension(display, "EGL_EXT_protected_content")) {
contextAttributes.append(EGL_PROTECTED_CONTENT_EXT);
contextAttributes.append(EGL_TRUE);
qCDebug(qLcEglfsKmsDebug, "Enabled EGL_PROTECTED_CONTENT_EXT for eglCreatePlatformWindowSurfaceEXT");
} else {
m_format.setOption(QSurfaceFormat::ProtectedContent, false);
}
}
#endif
contextAttributes.append(EGL_NONE);
m_surface = createPlatformWindowSurface(display, m_config, reinterpret_cast<void *>(m_window), contextAttributes.constData());
} else { } else {
qCDebug(qLcEglfsKmsDebug, "No eglCreatePlatformWindowSurface for GBM, falling back to eglCreateWindowSurface"); qCDebug(qLcEglfsKmsDebug, "No eglCreatePlatformWindowSurface for GBM, falling back to eglCreateWindowSurface");
m_surface = eglCreateWindowSurface(display, m_config, m_window, nullptr); m_surface = eglCreateWindowSurface(display, m_config, m_window, nullptr);