From 966f20d305345b3042dc1d37a1dd8833f3a4783b Mon Sep 17 00:00:00 2001 From: UjinT34 <41110182+UjinT34@users.noreply.github.com> Date: Sat, 7 Mar 2026 16:13:34 +0300 Subject: renderer: refactor resources and flags (#13471) --- src/render/Renderer.hpp | 149 +++++++++++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 59 deletions(-) (limited to 'src/render/Renderer.hpp') diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index b854715d..53ca9f12 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -101,34 +101,35 @@ class CHyprRenderer { CHyprRenderer(); ~CHyprRenderer(); - void renderMonitor(PHLMONITOR pMonitor, bool commit = true); - void arrangeLayersForMonitor(const MONITORID&); - void damageSurface(SP, double, double, double scale = 1.0); - void damageWindow(PHLWINDOW, bool forceFull = false); - void damageBox(const CBox&, bool skipFrameSchedule = false); - void damageBox(const int& x, const int& y, const int& w, const int& h); - void damageRegion(const CRegion&); - void damageMonitor(PHLMONITOR); - void damageMirrorsWith(PHLMONITOR, const CRegion&); - bool shouldRenderWindow(PHLWINDOW, PHLMONITOR); - bool shouldRenderWindow(PHLWINDOW); - void ensureCursorRenderingMode(); - bool shouldRenderCursor(); - void setCursorHidden(bool hide); + WP glBackend(); + + void renderMonitor(PHLMONITOR pMonitor, bool commit = true); + void arrangeLayersForMonitor(const MONITORID&); + void damageSurface(SP, double, double, double scale = 1.0); + void damageWindow(PHLWINDOW, bool forceFull = false); + void damageBox(const CBox&, bool skipFrameSchedule = false); + void damageBox(const int& x, const int& y, const int& w, const int& h); + void damageRegion(const CRegion&); + void damageMonitor(PHLMONITOR); + void damageMirrorsWith(PHLMONITOR, const CRegion&); + bool shouldRenderWindow(PHLWINDOW, PHLMONITOR); + bool shouldRenderWindow(PHLWINDOW); + void ensureCursorRenderingMode(); + bool shouldRenderCursor(); + void setCursorHidden(bool hide); void calculateUVForSurface(PHLWINDOW, SP, PHLMONITOR pMonitor, bool main = false, const Vector2D& projSize = {}, const Vector2D& projSizeUnscaled = {}, bool fixMisalignedFSV1 = false); std::tuple getRenderTimes(PHLMONITOR pMonitor); // avg max min + void ensureLockTexturesRendered(bool load); void renderLockscreen(PHLMONITOR pMonitor, const Time::steady_tp& now, const CBox& geometry); void setCursorSurface(SP surf, int hotspotX, int hotspotY, bool force = false); void setCursorFromName(const std::string& name, bool force = false); - void onRenderbufferDestroy(CGLRenderbuffer* rb); + void onRenderbufferDestroy(IRenderbuffer* rb); SP getCurrentRBO(); bool isNvidia(); bool isIntel(); bool isSoftware(); bool isMgpu(); - void makeEGLCurrent(); - void unsetEGL(); void addWindowToRenderUnfocused(PHLWINDOW window); void makeSnapshot(PHLWINDOW); void makeSnapshot(PHLLS); @@ -170,33 +171,54 @@ class CHyprRenderer { std::string name; } m_lastCursorData; - CRenderPass m_renderPass = {}; - - SP createStencilTexture(const int width, const int height); - SP createTexture(bool opaque = false); - SP createTexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size, bool keepDataCopy = false, bool opaque = false); - SP createTexture(const Aquamarine::SDMABUFAttrs&, bool opaque = false); - SP createTexture(const int width, const int height, unsigned char* const); - SP createTexture(cairo_surface_t* cairo); - SP createTexture(const SP buffer, bool keepDataCopy = false); - SP createTexture(std::span lut3D, size_t N); - SP createFB(const std::string& name = ""); - - SCMSettings getCMSettings(const NColorManagement::PImageDescription imageDescription, const NColorManagement::PImageDescription targetImageDescription, - SP surface = nullptr, bool modifySDR = false, float sdrMinLuminance = -1.0f, int sdrMaxLuminance = -1); - bool reloadShaders(const std::string& path = ""); - - void draw(CBorderPassElement* element, const CRegion& damage); - void draw(CClearPassElement* element, const CRegion& damage); - void draw(CFramebufferElement* element, const CRegion& damage); - void draw(CPreBlurElement* element, const CRegion& damage); - void draw(CRectPassElement* element, const CRegion& damage); - void draw(CRendererHintsPassElement* element, const CRegion& damage); - void draw(CShadowPassElement* element, const CRegion& damage); - void draw(CSurfacePassElement* element, const CRegion& damage); - void draw(CTexPassElement* element, const CRegion& damage); - void draw(CTextureMatteElement* element, const CRegion& damage); - void draw(WP element, const CRegion& damage); + CRenderPass m_renderPass = {}; + + SP getOrCreateRenderbuffer(SP buffer, uint32_t fmt); // TODO? move to protected and fix CPointerManager::renderHWCursorBuffer + SP m_screencopyDeniedTexture; // TODO? make readonly + uint m_failedAssetsNo = 0; // TODO? make readonly + bool m_reloadScreenShader = true; // at launch it can be set + CTimer m_globalTimer; + + SP createStencilTexture(const int width, const int height); + SP createTexture(bool opaque = false); + SP createTexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size, bool keepDataCopy = false, bool opaque = false); + SP createTexture(const Aquamarine::SDMABUFAttrs&, bool opaque = false); + SP createTexture(const int width, const int height, unsigned char* const); + SP createTexture(cairo_surface_t* cairo); + SP createTexture(const SP buffer, bool keepDataCopy = false); + SP createTexture(std::span lut3D, size_t N); + SP renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "", int maxWidth = 0, int weight = 400); + SP loadAsset(const std::string& filename); + bool shouldUseNewBlurOptimizations(PHLLS pLayer, PHLWINDOW pWindow); + bool explicitSyncSupported(); + std::vector getDRMFormats(); + std::vector getDRMFormatModifiers(DRMFormat format); + SP createFB(const std::string& name = ""); + void pushMonitorTransformEnabled(bool enabled); + void popMonitorTransformEnabled(); + bool monitorTransformEnabled(); + + SCMSettings getCMSettings(const NColorManagement::PImageDescription imageDescription, const NColorManagement::PImageDescription targetImageDescription, + SP surface = nullptr, bool modifySDR = false, float sdrMinLuminance = -1.0f, int sdrMaxLuminance = -1); + bool reloadShaders(const std::string& path = ""); + + void draw(CBorderPassElement* element, const CRegion& damage); + void draw(CClearPassElement* element, const CRegion& damage); + void draw(CFramebufferElement* element, const CRegion& damage); + void draw(CPreBlurElement* element, const CRegion& damage); + void draw(CRectPassElement* element, const CRegion& damage); + void draw(CRendererHintsPassElement* element, const CRegion& damage); + void draw(CShadowPassElement* element, const CRegion& damage); + void draw(CSurfacePassElement* element, const CRegion& damage); + void draw(CTexPassElement* element, const CRegion& damage); + void draw(CTextureMatteElement* element, const CRegion& damage); + void draw(WP element, const CRegion& damage); + + SP m_lockDeadTexture; + SP m_lockDead2Texture; + SP m_lockTtyTextTexture; + bool m_monitorTransformEnabled = false; // do not modify directly + std::stack m_monitorTransformStack; private: void arrangeLayerArray(PHLMONITOR, const std::vector&, bool, CBox*); @@ -216,20 +238,30 @@ class CHyprRenderer { bool commitPendingAndDoExplicitSync(PHLMONITOR pMonitor); - bool shouldBlur(PHLLS ls); - bool shouldBlur(PHLWINDOW w); - bool shouldBlur(WP p); - - bool m_cursorHidden = false; - bool m_cursorHiddenByCondition = false; - bool m_cursorHasSurface = false; - SP m_currentRenderbuffer = nullptr; - SP m_currentBuffer = nullptr; - eRenderMode m_renderMode = RENDER_MODE_NORMAL; - bool m_nvidia = false; - bool m_intel = false; - bool m_software = false; - bool m_mgpu = false; + void requestBackgroundResource(); + // + SP getOrCreateRenderbufferInternal(SP buffer, uint32_t fmt); + std::string resolveAssetPath(const std::string& file); + void initMissingAssetTexture(); + void initAssets(); + SP m_missingAssetTexture; + ASP m_backgroundResource; + bool m_backgroundResourceFailed = false; + + bool shouldBlur(PHLLS ls); + bool shouldBlur(PHLWINDOW w); + bool shouldBlur(WP p); + + bool m_cursorHidden = false; + bool m_cursorHiddenByCondition = false; + bool m_cursorHasSurface = false; + SP m_currentRenderbuffer = nullptr; + SP m_currentBuffer = nullptr; + eRenderMode m_renderMode = RENDER_MODE_NORMAL; + bool m_nvidia = false; + bool m_intel = false; + bool m_software = false; + bool m_mgpu = false; struct { bool hiddenOnTouch = false; @@ -238,7 +270,6 @@ class CHyprRenderer { bool hiddenOnKeyboard = false; } m_cursorHiddenConditions; - SP getOrCreateRenderbuffer(SP buffer, uint32_t fmt); std::vector> m_renderbuffers; std::vector m_renderUnfocused; SP m_renderUnfocusedTimer; -- cgit v1.2.3