renderer: make lock fail textures dynamically loaded

this should reduce idle vram usage by a whopping 16MB, but also might fix the tty unknown issue.
This commit is contained in:
Vaxry
2025-06-19 13:46:42 +02:00
parent e999ad664d
commit 54ccf9c6b3
3 changed files with 41 additions and 13 deletions

View File

@@ -17,6 +17,7 @@
#include "../protocols/types/ColorManagement.hpp"
#include "../managers/HookSystemManager.hpp"
#include "../managers/input/InputManager.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../helpers/fs/FsUtils.hpp"
#include "debug/HyprNotificationOverlay.hpp"
#include "hyprerror/HyprError.hpp"
@@ -2752,19 +2753,36 @@ void CHyprOpenGLImpl::useProgram(GLuint prog) {
void CHyprOpenGLImpl::initAssets() {
initMissingAssetTexture();
m_lockDeadTexture = loadAsset("lockdead.png");
m_lockDead2Texture = loadAsset("lockdead2.png");
m_lockTtyTextTexture = renderText(
std::format("Running on tty {}",
g_pCompositor->m_aqBackend->hasSession() && g_pCompositor->m_aqBackend->session->vt > 0 ? std::to_string(g_pCompositor->m_aqBackend->session->vt) : "unknown"),
CHyprColor{0.9F, 0.9F, 0.9F, 0.7F}, 20, true);
m_screencopyDeniedTexture = renderText("Permission denied to share screen", Colors::WHITE, 20);
ensureBackgroundTexturePresence();
}
void CHyprOpenGLImpl::ensureLockTexturesRendered(bool load) {
static bool loaded = false;
if (loaded == load)
return;
loaded = load;
if (load) {
// this will cause a small hitch. I don't think we can do much, other than wasting VRAM and having this loaded all the time.
m_lockDeadTexture = loadAsset("lockdead.png");
m_lockDead2Texture = loadAsset("lockdead2.png");
m_lockTtyTextTexture = renderText(std::format("Running on tty {}",
g_pCompositor->m_aqBackend->hasSession() && g_pCompositor->m_aqBackend->session->vt > 0 ?
std::to_string(g_pCompositor->m_aqBackend->session->vt) :
"unknown"),
CHyprColor{0.9F, 0.9F, 0.9F, 0.7F}, 20, true);
} else {
m_lockDeadTexture.reset();
m_lockDead2Texture.reset();
m_lockTtyTextTexture.reset();
}
}
void CHyprOpenGLImpl::ensureBackgroundTexturePresence() {
static auto PNOWALLPAPER = CConfigValue<Hyprlang::INT>("misc:disable_hyprland_logo");
static auto PFORCEWALLPAPER = CConfigValue<Hyprlang::INT>("misc:force_default_wallpaper");