mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-11 23:49:49 +01:00
do not set hdr metadata unless needed
This commit is contained in:
parent
983bc067da
commit
8d9c72b1db
5 changed files with 46 additions and 13 deletions
|
@ -194,13 +194,13 @@ CColorManagementSurface::CColorManagementSurface(SP<CXxColorManagementSurfaceV4>
|
|||
return;
|
||||
}
|
||||
|
||||
m_hasImageDescription = true;
|
||||
setHasImageDescription(true);
|
||||
m_imageDescription = imageDescription->get()->settings;
|
||||
});
|
||||
resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) {
|
||||
LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r);
|
||||
m_imageDescription = SImageDescription{};
|
||||
m_hasImageDescription = false;
|
||||
setHasImageDescription(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -222,6 +222,24 @@ bool CColorManagementSurface::hasImageDescription() {
|
|||
return m_hasImageDescription;
|
||||
}
|
||||
|
||||
void CColorManagementSurface::setHasImageDescription(bool has) {
|
||||
m_hasImageDescription = has;
|
||||
m_needsNewMetadata = true;
|
||||
}
|
||||
|
||||
const hdr_output_metadata& CColorManagementSurface::hdrMetadata() {
|
||||
return m_hdrMetadata;
|
||||
}
|
||||
|
||||
void CColorManagementSurface::setHDRMetadata(const hdr_output_metadata& metadata) {
|
||||
m_hdrMetadata = metadata;
|
||||
m_needsNewMetadata = false;
|
||||
}
|
||||
|
||||
bool CColorManagementSurface::needsHdrMetadataUpdate() {
|
||||
return m_needsNewMetadata;
|
||||
}
|
||||
|
||||
CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CXxColorManagementFeedbackSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) :
|
||||
surface(surface_), resource(resource_) {
|
||||
if (!good())
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <drm_mode.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
@ -54,12 +55,18 @@ class CColorManagementSurface {
|
|||
|
||||
const SImageDescription& imageDescription();
|
||||
bool hasImageDescription();
|
||||
void setHasImageDescription(bool has);
|
||||
const hdr_output_metadata& hdrMetadata();
|
||||
void setHDRMetadata(const hdr_output_metadata& metadata);
|
||||
bool needsHdrMetadataUpdate();
|
||||
|
||||
private:
|
||||
SP<CXxColorManagementSurfaceV4> resource;
|
||||
wl_client* pClient = nullptr;
|
||||
SImageDescription m_imageDescription;
|
||||
bool m_hasImageDescription = false;
|
||||
bool m_needsNewMetadata = false;
|
||||
hdr_output_metadata m_hdrMetadata;
|
||||
|
||||
friend class CFrogColorManagementSurface;
|
||||
};
|
||||
|
|
|
@ -92,7 +92,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
|
|||
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SRGB:
|
||||
surface->colorManagement->m_imageDescription.transferFunction = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB;
|
||||
|
||||
surface->colorManagement->m_hasImageDescription = true;
|
||||
surface->colorManagement->setHasImageDescription(true);
|
||||
}
|
||||
});
|
||||
resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) {
|
||||
|
@ -103,12 +103,12 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
|
|||
case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC2020: surface->colorManagement->m_imageDescription.primaries = NColorPrimaries::BT2020; break;
|
||||
}
|
||||
|
||||
surface->colorManagement->m_hasImageDescription = true;
|
||||
surface->colorManagement->setHasImageDescription(true);
|
||||
});
|
||||
resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) {
|
||||
LOGM(TRACE, "Set frog cm intent {}", (uint32_t)intent);
|
||||
pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL;
|
||||
surface->colorManagement->m_hasImageDescription = true;
|
||||
surface->colorManagement->setHasImageDescription(true);
|
||||
});
|
||||
resource->setSetHdrMetadata([this](CFrogColorManagedSurface* r, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y,
|
||||
uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) {
|
||||
|
@ -122,7 +122,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
|
|||
surface->colorManagement->m_imageDescription.maxCLL = cll;
|
||||
surface->colorManagement->m_imageDescription.maxFALL = fall;
|
||||
|
||||
surface->colorManagement->m_hasImageDescription = true;
|
||||
surface->colorManagement->setHasImageDescription(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1472,12 +1472,19 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
|
|||
if (pMonitor->activeWorkspace && pMonitor->activeWorkspace->m_bHasFullscreenWindow && pMonitor->activeWorkspace->m_efFullscreenMode == FSMODE_FULLSCREEN) {
|
||||
const auto WINDOW = pMonitor->activeWorkspace->getFullscreenWindow();
|
||||
const auto SURF = WINDOW->m_pWLSurface->resource();
|
||||
if (SURF->colorManagement.valid() && SURF->colorManagement->hasImageDescription())
|
||||
pMonitor->output->state->setHDRMetadata(createHDRMetadata(SURF->colorManagement.get()->imageDescription(), pMonitor->output->parsedEDID));
|
||||
else
|
||||
pMonitor->output->state->setHDRMetadata(*PHDR ? createHDRMetadata(2, pMonitor->output->parsedEDID) : createHDRMetadata(0, pMonitor->output->parsedEDID));
|
||||
if (SURF->colorManagement.valid() && SURF->colorManagement->hasImageDescription()) {
|
||||
bool needsHdrMetadataUpdate = SURF->colorManagement->needsHdrMetadataUpdate() || m_previousFSWindow != WINDOW;
|
||||
if (SURF->colorManagement->needsHdrMetadataUpdate())
|
||||
SURF->colorManagement->setHDRMetadata(createHDRMetadata(SURF->colorManagement.get()->imageDescription(), pMonitor->output->parsedEDID));
|
||||
if (needsHdrMetadataUpdate)
|
||||
pMonitor->output->state->setHDRMetadata(SURF->colorManagement->hdrMetadata());
|
||||
} else
|
||||
pMonitor->output->state->setHDRMetadata(*PHDR ? createHDRMetadata(2, pMonitor->output->parsedEDID) : createHDRMetadata(0, pMonitor->output->parsedEDID));
|
||||
m_previousFSWindow = WINDOW;
|
||||
} else {
|
||||
pMonitor->output->state->setHDRMetadata(*PHDR ? createHDRMetadata(2, pMonitor->output->parsedEDID) : createHDRMetadata(0, pMonitor->output->parsedEDID));
|
||||
m_previousFSWindow.reset();
|
||||
}
|
||||
}
|
||||
|
||||
if (pMonitor->ctmUpdated) {
|
||||
|
|
|
@ -129,6 +129,7 @@ class CHyprRenderer {
|
|||
|
||||
bool commitPendingAndDoExplicitSync(PHLMONITOR pMonitor);
|
||||
|
||||
WP<CWindow> m_previousFSWindow;
|
||||
bool m_bCursorHidden = false;
|
||||
bool m_bCursorHasSurface = false;
|
||||
SP<CRenderbuffer> m_pCurrentRenderbuffer = nullptr;
|
||||
|
|
Loading…
Reference in a new issue