renderer: add expand_undersized_textures

adds an option to disable the texture expansion for textures that are smaller while resizing up
This commit is contained in:
Vaxry 2024-11-04 19:42:47 +00:00
parent 0fb9a04526
commit 88e9e03945
2 changed files with 17 additions and 12 deletions

View file

@ -590,6 +590,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("render:explicit_sync", Hyprlang::INT{2});
m_pConfig->addConfigValue("render:explicit_sync_kms", Hyprlang::INT{2});
m_pConfig->addConfigValue("render:direct_scanout", Hyprlang::INT{0});
m_pConfig->addConfigValue("render:expand_undersized_textures", Hyprlang::INT{1});
// devices
m_pConfig->addSpecialCategory("device", {"name"});

View file

@ -1084,6 +1084,8 @@ void CHyprRenderer::renderSessionLockMissing(PHLMONITOR pMonitor) {
void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResource> pSurface, PHLMONITOR pMonitor, bool main, const Vector2D& projSize,
const Vector2D& projSizeUnscaled, bool fixMisalignedFSV1) {
if (!pWindow || !pWindow->m_bIsX11) {
static auto PEXPANDEDGES = CConfigValue<Hyprlang::INT>("render:expand_undersized_textures");
Vector2D uvTL;
Vector2D uvBR = Vector2D(1, 1);
@ -1115,6 +1117,7 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
// this will break if later on xdg geometry is hit, but we really try
// to let the apps know to NOT add CSD. Also if source is there.
// there is no way to fix this if that's the case
if (*PEXPANDEDGES) {
const auto MONITOR_WL_SCALE = std::ceil(pMonitor->scale);
const bool SCALE_UNAWARE = MONITOR_WL_SCALE != pSurface->current.scale && !pSurface->current.viewport.hasDestination;
const auto EXPECTED_SIZE =
@ -1126,6 +1129,7 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
const auto FIX = projSize / EXPECTED_SIZE;
uvBR = uvBR * FIX;
}
}
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = uvTL;
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = uvBR;