mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-08 06:18:00 +02:00
fix screenshare damage
This commit is contained in:
parent
1163688b92
commit
d72d87b286
4 changed files with 17 additions and 15 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "MonitorResources.hpp"
|
||||
#include "render/Renderer.hpp"
|
||||
#include "./cm/ColorManagement.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
|
||||
|
|
@ -61,8 +62,10 @@ SP<Render::IFramebuffer> CMonitorResources::mirrorFB() {
|
|||
if (!m_monitorMirrorFB)
|
||||
m_monitorMirrorFB = g_pHyprRenderer->createFB(std::format("Monitor {} mirror FB", m_monitor->m_name));
|
||||
|
||||
if (!m_monitorMirrorFB->isAllocated())
|
||||
m_monitorMirrorFB->alloc(m_size.x, m_size.y, m_drmFormat);
|
||||
if (!m_monitorMirrorFB->isAllocated()) {
|
||||
m_monitorMirrorFB->alloc(m_size.x, m_size.y, DRM_FORMAT_XRGB8888);
|
||||
m_monitorMirrorFB->getTexture()->m_imageDescription = NColorManagement::DEFAULT_IMAGE_DESCRIPTION;
|
||||
}
|
||||
|
||||
return m_monitorMirrorFB;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "../../desktop/state/FocusState.hpp"
|
||||
#include "../../render/pass/ClearPassElement.hpp"
|
||||
#include "../../render/pass/RectPassElement.hpp"
|
||||
#include "helpers/cm/ColorManagement.hpp"
|
||||
#include <hyprutils/math/Region.hpp>
|
||||
|
||||
using namespace Screenshare;
|
||||
|
|
@ -162,7 +163,7 @@ void CScreenshareFrame::renderMonitor() {
|
|||
|
||||
const auto PMONITOR = m_session->monitor();
|
||||
|
||||
auto TEXTURE = g_pHyprRenderer->m_renderData.prevFB->getTexture();
|
||||
auto TEXTURE = g_pHyprRenderer->m_renderData.pMonitor->resources()->mirrorFB()->getTexture();
|
||||
|
||||
const bool IS_CM_AWARE = PROTO::colorManagement && PROTO::colorManagement->isClientCMAware(m_session->m_client);
|
||||
g_pHyprRenderer->m_renderData.transformDamage = false;
|
||||
|
|
@ -399,6 +400,7 @@ bool CScreenshareFrame::copyShm() {
|
|||
|
||||
auto outFB = g_pHyprRenderer->createFB();
|
||||
outFB->alloc(m_bufferSize.x, m_bufferSize.y, shm.format);
|
||||
outFB->getTexture()->m_imageDescription = NColorManagement::DEFAULT_IMAGE_DESCRIPTION;
|
||||
|
||||
if (!g_pHyprRenderer->beginFullFakeRender(PMONITOR, m_damage, outFB)) {
|
||||
LOGM(Log::ERR, "Can't copy: failed to begin rendering");
|
||||
|
|
@ -431,6 +433,7 @@ void CScreenshareFrame::storeTempFB() {
|
|||
if (!m_session->m_tempFB)
|
||||
m_session->m_tempFB = g_pHyprRenderer->createFB();
|
||||
m_session->m_tempFB->alloc(m_bufferSize.x, m_bufferSize.y);
|
||||
m_session->m_tempFB->getTexture()->m_imageDescription = NColorManagement::DEFAULT_IMAGE_DESCRIPTION;
|
||||
|
||||
CRegion fakeDamage = {0, 0, INT16_MAX, INT16_MAX};
|
||||
|
||||
|
|
|
|||
|
|
@ -776,7 +776,7 @@ void CHyprOpenGLImpl::end() {
|
|||
if UNLIKELY (g_pHyprRenderer->needsACopyFB(g_pHyprRenderer->m_renderData.pMonitor.lock()) && !m_fakeFrame)
|
||||
saveBufferForMirror(monbox);
|
||||
|
||||
g_pHyprRenderer->m_renderData.prevFB = g_pHyprRenderer->m_renderData.currentFB;
|
||||
const auto TEX = g_pHyprRenderer->m_renderData.currentFB->getTexture();
|
||||
g_pHyprRenderer->bindFB(g_pHyprRenderer->m_renderData.outFB);
|
||||
blend(false);
|
||||
|
||||
|
|
@ -784,9 +784,9 @@ void CHyprOpenGLImpl::end() {
|
|||
g_pHyprRenderer->m_renderData.pMonitor->m_imageDescription->value() != SImageDescription{};
|
||||
|
||||
if LIKELY (!PRIMITIVE_BLOCKED || g_pHyprRenderer->m_renderMode != RENDER_MODE_NORMAL)
|
||||
renderTexturePrimitive(g_pHyprRenderer->m_renderData.prevFB->getTexture(), monbox);
|
||||
renderTexturePrimitive(TEX, monbox);
|
||||
else // we need to use renderTexture if we do any CM whatsoever.
|
||||
renderTexture(g_pHyprRenderer->m_renderData.prevFB->getTexture(), monbox, {.finalMonitorCM = true});
|
||||
renderTexture(TEX, monbox, {.finalMonitorCM = true});
|
||||
|
||||
blend(true);
|
||||
|
||||
|
|
@ -1345,12 +1345,8 @@ WP<CShader> CHyprOpenGLImpl::renderToFBInternal(SP<ITexture> tex, const STexture
|
|||
shader = getShaderVariant(SH_FRAG_SURFACE, shaderFeatures);
|
||||
shader = useShader(shader);
|
||||
|
||||
if (data.finalMonitorCM || data.cmBackToSRGB)
|
||||
passCMUniforms(shader, SOURCE_IMAGE_DESCRIPTION, TARGET_IMAGE_DESCRIPTION, true, g_pHyprRenderer->m_renderData.pMonitor->m_sdrMinLuminance,
|
||||
g_pHyprRenderer->m_renderData.pMonitor->m_sdrMaxLuminance, settings);
|
||||
else
|
||||
passCMUniforms(shader, SOURCE_IMAGE_DESCRIPTION, g_pHyprRenderer->workBufferImageDescription(), true, g_pHyprRenderer->m_renderData.pMonitor->m_sdrMinLuminance,
|
||||
g_pHyprRenderer->m_renderData.pMonitor->m_sdrMaxLuminance, settings);
|
||||
passCMUniforms(shader, SOURCE_IMAGE_DESCRIPTION, g_pHyprRenderer->workBufferImageDescription(), true, g_pHyprRenderer->m_renderData.pMonitor->m_sdrMinLuminance,
|
||||
g_pHyprRenderer->m_renderData.pMonitor->m_sdrMaxLuminance, settings);
|
||||
} else {
|
||||
if (!shader)
|
||||
shader = getShaderVariant(SH_FRAG_SURFACE, shaderFeatures);
|
||||
|
|
@ -1408,7 +1404,8 @@ WP<CShader> CHyprOpenGLImpl::renderToFBInternal(SP<ITexture> tex, const STexture
|
|||
|
||||
void CHyprOpenGLImpl::renderTextureInternal(SP<ITexture> tex, const CBox& box, const STextureRenderData& data) {
|
||||
RASSERT(g_pHyprRenderer->m_renderData.pMonitor, "Tried to render texture without begin()!");
|
||||
RASSERT((tex && tex->ok()), "Attempted to draw nullptr texture!");
|
||||
RASSERT(tex, "Attempted to draw nullptr texture!");
|
||||
RASSERT(tex->ok(), "Attempted to draw invalid texture!");
|
||||
|
||||
TRACY_GPU_ZONE("RenderTextureInternalWithDamage");
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ namespace Render {
|
|||
SP<IFramebuffer> currentFB = nullptr; // current rendering to
|
||||
SP<IFramebuffer> mainFB = nullptr; // main to render to
|
||||
SP<IFramebuffer> outFB = nullptr; // out to render to (if offloaded, etc)
|
||||
SP<IFramebuffer> prevFB = nullptr; // out to render to (if offloaded, etc)
|
||||
|
||||
CRegion damage;
|
||||
CRegion finalDamage; // damage used for funal off -> main
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue