protocols/toplevelExport: Support transparency in toplevel export (#12824)
This commit is contained in:
parent
f0b6714539
commit
c44292c723
3 changed files with 21 additions and 4 deletions
|
|
@ -326,3 +326,17 @@ std::string NFormatUtils::drmModifierName(uint64_t mod) {
|
||||||
free(n); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors)
|
free(n); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors)
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DRMFormat NFormatUtils::alphaFormat(DRMFormat prevFormat) {
|
||||||
|
switch (prevFormat) {
|
||||||
|
case DRM_FORMAT_XRGB8888: return DRM_FORMAT_ARGB8888;
|
||||||
|
case DRM_FORMAT_XBGR8888: return DRM_FORMAT_ABGR8888;
|
||||||
|
case DRM_FORMAT_BGRX8888: return DRM_FORMAT_BGRA8888;
|
||||||
|
case DRM_FORMAT_RGBX8888: return DRM_FORMAT_RGBA8888;
|
||||||
|
case DRM_FORMAT_XRGB2101010: return DRM_FORMAT_ARGB2101010;
|
||||||
|
case DRM_FORMAT_XBGR2101010: return DRM_FORMAT_ABGR2101010;
|
||||||
|
case DRM_FORMAT_RGBX1010102: return DRM_FORMAT_RGBA1010102;
|
||||||
|
case DRM_FORMAT_BGRX1010102: return DRM_FORMAT_BGRA1010102;
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,4 +57,5 @@ namespace NFormatUtils {
|
||||||
uint32_t glFormatToType(uint32_t gl);
|
uint32_t glFormatToType(uint32_t gl);
|
||||||
std::string drmFormatName(DRMFormat drm);
|
std::string drmFormatName(DRMFormat drm);
|
||||||
std::string drmModifierName(uint64_t mod);
|
std::string drmModifierName(uint64_t mod);
|
||||||
|
DRMFormat alphaFormat(DRMFormat prevFormat);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,9 @@ CToplevelExportFrame::CToplevelExportFrame(SP<CHyprlandToplevelExportFrameV1> re
|
||||||
|
|
||||||
g_pHyprRenderer->makeEGLCurrent();
|
g_pHyprRenderer->makeEGLCurrent();
|
||||||
|
|
||||||
m_shmFormat = g_pHyprOpenGL->getPreferredReadFormat(PMONITOR);
|
m_shmFormat = NFormatUtils::alphaFormat(g_pHyprOpenGL->getPreferredReadFormat(PMONITOR));
|
||||||
|
LOGM(Log::DEBUG, "Format {:x}", m_shmFormat);
|
||||||
|
//m_shmFormat = NFormatUtils::alphaFormat(m_shmFormat);
|
||||||
if UNLIKELY (m_shmFormat == DRM_FORMAT_INVALID) {
|
if UNLIKELY (m_shmFormat == DRM_FORMAT_INVALID) {
|
||||||
LOGM(Log::ERR, "No format supported by renderer in capture toplevel");
|
LOGM(Log::ERR, "No format supported by renderer in capture toplevel");
|
||||||
m_resource->sendFailed();
|
m_resource->sendFailed();
|
||||||
|
|
@ -114,7 +116,7 @@ CToplevelExportFrame::CToplevelExportFrame(SP<CHyprlandToplevelExportFrameV1> re
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dmabufFormat = g_pHyprOpenGL->getPreferredReadFormat(PMONITOR);
|
m_dmabufFormat = NFormatUtils::alphaFormat(g_pHyprOpenGL->getPreferredReadFormat(PMONITOR));
|
||||||
|
|
||||||
m_box = {0, 0, sc<int>(m_window->m_realSize->value().x * PMONITOR->m_scale), sc<int>(m_window->m_realSize->value().y * PMONITOR->m_scale)};
|
m_box = {0, 0, sc<int>(m_window->m_realSize->value().x * PMONITOR->m_scale), sc<int>(m_window->m_realSize->value().y * PMONITOR->m_scale)};
|
||||||
|
|
||||||
|
|
@ -253,7 +255,7 @@ bool CToplevelExportFrame::copyShm(const Time::steady_tp& now) {
|
||||||
if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, &outFB))
|
if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, &outFB))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 1.0));
|
g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 0));
|
||||||
|
|
||||||
// render client at 0,0
|
// render client at 0,0
|
||||||
if (PERM == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
|
if (PERM == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
|
||||||
|
|
@ -356,7 +358,7 @@ bool CToplevelExportFrame::copyDmabuf(const Time::steady_tp& now) {
|
||||||
if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_TO_BUFFER, m_buffer.m_buffer))
|
if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_TO_BUFFER, m_buffer.m_buffer))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 1.0));
|
g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 0));
|
||||||
if (PERM == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
|
if (PERM == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
|
||||||
if (!m_window->m_ruleApplicator->noScreenShare().valueOrDefault()) {
|
if (!m_window->m_ruleApplicator->noScreenShare().valueOrDefault()) {
|
||||||
g_pHyprRenderer->m_bBlockSurfaceFeedback = g_pHyprRenderer->shouldRenderWindow(m_window); // block the feedback to avoid spamming the surface if it's visible
|
g_pHyprRenderer->m_bBlockSurfaceFeedback = g_pHyprRenderer->shouldRenderWindow(m_window); // block the feedback to avoid spamming the surface if it's visible
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue