refactor: Use new hyprutils casts (#11377)

This commit is contained in:
Kamikadze
2025-08-14 19:44:56 +05:00
committed by GitHub
parent aa6a78f0a4
commit beee22a95e
116 changed files with 715 additions and 696 deletions

View File

@@ -1139,10 +1139,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
// Adjust UV based on the xdg_surface geometry
if (geom.x != 0 || geom.y != 0 || geom.w != 0 || geom.h != 0) {
const auto XPERC = (double)geom.x / (double)pSurface->m_current.size.x;
const auto YPERC = (double)geom.y / (double)pSurface->m_current.size.y;
const auto WPERC = (double)(geom.x + geom.w ? geom.w : pSurface->m_current.size.x) / (double)pSurface->m_current.size.x;
const auto HPERC = (double)(geom.y + geom.h ? geom.h : pSurface->m_current.size.y) / (double)pSurface->m_current.size.y;
const auto XPERC = geom.x / pSurface->m_current.size.x;
const auto YPERC = geom.y / pSurface->m_current.size.y;
const auto WPERC = (geom.x + geom.w ? geom.w : pSurface->m_current.size.x) / pSurface->m_current.size.x;
const auto HPERC = (geom.y + geom.h ? geom.h : pSurface->m_current.size.y) / pSurface->m_current.size.y;
const auto TOADDTL = Vector2D(XPERC * (uvBR.x - uvTL.x), YPERC * (uvBR.y - uvTL.y));
uvBR = uvBR - Vector2D((1.0 - WPERC) * (uvBR.x - uvTL.x), (1.0 - HPERC) * (uvBR.y - uvTL.y));
@@ -1349,7 +1349,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
// if we have no tracking or full tracking, invalidate the entire monitor
if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR || pMonitor->m_forceFullFrames > 0 || damageBlinkCleanup > 0)
damage = {0, 0, (int)pMonitor->m_transformedSize.x * 10, (int)pMonitor->m_transformedSize.y * 10};
damage = {0, 0, sc<int>(pMonitor->m_transformedSize.x) * 10, sc<int>(pMonitor->m_transformedSize.y) * 10};
finalDamage = damage;
@@ -1375,7 +1375,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
EMIT_HOOK_EVENT("render", RENDER_POST_MIRROR);
renderCursor = false;
} else {
CBox renderBox = {0, 0, (int)pMonitor->m_pixelSize.x, (int)pMonitor->m_pixelSize.y};
CBox renderBox = {0, 0, sc<int>(pMonitor->m_pixelSize.x), sc<int>(pMonitor->m_pixelSize.y)};
renderWorkspace(pMonitor, pMonitor->m_activeWorkspace, NOW, renderBox);
renderLockscreen(pMonitor, NOW, renderBox);
@@ -1431,7 +1431,7 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
frameDamage.transform(wlTransformToHyprutils(TRANSFORM), pMonitor->m_transformedSize.x, pMonitor->m_transformedSize.y);
if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR)
frameDamage.add(0, 0, (int)pMonitor->m_transformedSize.x, (int)pMonitor->m_transformedSize.y);
frameDamage.add(0, 0, sc<int>(pMonitor->m_transformedSize.x), sc<int>(pMonitor->m_transformedSize.y));
if (*PDAMAGEBLINK)
frameDamage.add(damage);
@@ -1481,8 +1481,8 @@ static hdr_output_metadata createHDRMetadata(SImageDescription settings, A
default: return NO_HDR_METADATA; // empty metadata for SDR
}
const auto toNits = [](uint32_t value) { return uint16_t(std::round(value)); };
const auto to16Bit = [](float value) { return uint16_t(std::round(value * 50000)); };
const auto toNits = [](uint32_t value) { return sc<uint16_t>(std::round(value)); };
const auto to16Bit = [](float value) { return sc<uint16_t>(std::round(value * 50000)); };
auto colorimetry = settings.primariesNameSet || settings.primaries == SPCPRimaries{} ? getPrimaries(settings.primariesNamed) : settings.primaries;
auto luminances = settings.masteringLuminances.max > 0 ?
@@ -1622,11 +1622,11 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
void CHyprRenderer::renderWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, const Time::steady_tp& now, const CBox& geometry) {
Vector2D translate = {geometry.x, geometry.y};
float scale = (float)geometry.width / pMonitor->m_pixelSize.x;
float scale = sc<float>(geometry.width) / pMonitor->m_pixelSize.x;
TRACY_GPU_ZONE("RenderWorkspace");
if (!DELTALESSTHAN((double)geometry.width / (double)geometry.height, pMonitor->m_pixelSize.x / pMonitor->m_pixelSize.y, 0.01)) {
if (!DELTALESSTHAN(sc<double>(geometry.width) / sc<double>(geometry.height), pMonitor->m_pixelSize.x / pMonitor->m_pixelSize.y, 0.01)) {
Debug::log(ERR, "Ignoring geometry in renderWorkspace: aspect ratio mismatch");
scale = 1.f;
translate = Vector2D{};
@@ -1792,7 +1792,7 @@ void CHyprRenderer::arrangeLayerArray(PHLMONITOR pMonitor, const std::vector<PHL
box.y -= PSTATE->margin.bottom;
if (box.width <= 0 || box.height <= 0) {
Debug::log(ERR, "LayerSurface {:x} has a negative/zero w/h???", (uintptr_t)ls.get());
Debug::log(ERR, "LayerSurface {:x} has a negative/zero w/h???", rc<uintptr_t>(ls.get()));
continue;
}
@@ -2126,7 +2126,7 @@ std::tuple<float, float, float> CHyprRenderer::getRenderTimes(PHLMONITOR pMonito
static int handleCrashLoop(void* data) {
g_pHyprNotificationOverlay->addNotification("Hyprland will crash in " + std::to_string(10 - (int)(g_pHyprRenderer->m_crashingDistort * 2.f)) + "s.", CHyprColor(0), 5000,
g_pHyprNotificationOverlay->addNotification("Hyprland will crash in " + std::to_string(10 - sc<int>(g_pHyprRenderer->m_crashingDistort * 2.f)) + "s.", CHyprColor(0), 5000,
ICON_INFO);
g_pHyprRenderer->m_crashingDistort += 0.5f;
@@ -2150,7 +2150,7 @@ void CHyprRenderer::initiateManualCrash() {
g_pHyprOpenGL->m_globalTimer.reset();
static auto PDT = (Hyprlang::INT* const*)(g_pConfigManager->getConfigValuePtr("debug:damage_tracking"));
static auto PDT = rc<Hyprlang::INT* const*>(g_pConfigManager->getConfigValuePtr("debug:damage_tracking"));
**PDT = 0;
}
@@ -2419,12 +2419,12 @@ void CHyprRenderer::makeSnapshot(PHLWINDOW pWindow) {
if (!shouldRenderWindow(pWindow))
return; // ignore, window is not being rendered
Debug::log(LOG, "renderer: making a snapshot of {:x}", (uintptr_t)pWindow.get());
Debug::log(LOG, "renderer: making a snapshot of {:x}", rc<uintptr_t>(pWindow.get()));
// we need to "damage" the entire monitor
// so that we render the entire window
// this is temporary, doesn't mess with the actual damage
CRegion fakeDamage{0, 0, (int)PMONITOR->m_transformedSize.x, (int)PMONITOR->m_transformedSize.y};
CRegion fakeDamage{0, 0, sc<int>(PMONITOR->m_transformedSize.x), sc<int>(PMONITOR->m_transformedSize.y)};
PHLWINDOWREF ref{pWindow};
@@ -2454,12 +2454,12 @@ void CHyprRenderer::makeSnapshot(PHLLS pLayer) {
if (!PMONITOR || !PMONITOR->m_output || PMONITOR->m_pixelSize.x <= 0 || PMONITOR->m_pixelSize.y <= 0)
return;
Debug::log(LOG, "renderer: making a snapshot of {:x}", (uintptr_t)pLayer.get());
Debug::log(LOG, "renderer: making a snapshot of {:x}", rc<uintptr_t>(pLayer.get()));
// we need to "damage" the entire monitor
// so that we render the entire window
// this is temporary, doesn't mess with the actual damage
CRegion fakeDamage{0, 0, (int)PMONITOR->m_transformedSize.x, (int)PMONITOR->m_transformedSize.y};
CRegion fakeDamage{0, 0, sc<int>(PMONITOR->m_transformedSize.x), sc<int>(PMONITOR->m_transformedSize.y)};
makeEGLCurrent();
@@ -2491,7 +2491,7 @@ void CHyprRenderer::makeSnapshot(WP<CPopup> popup) {
if (!popup->m_wlSurface || !popup->m_wlSurface->resource() || !popup->m_mapped)
return;
Debug::log(LOG, "renderer: making a snapshot of {:x}", (uintptr_t)popup.get());
Debug::log(LOG, "renderer: making a snapshot of {:x}", rc<uintptr_t>(popup.get()));
CRegion fakeDamage{0, 0, PMONITOR->m_transformedSize.x, PMONITOR->m_transformedSize.y};