Hyprland/src/render/Renderer.hpp

95 lines
4.1 KiB
C++
Raw Normal View History

2022-03-17 20:22:29 +01:00
#pragma once
#include "../defines.hpp"
2022-03-19 14:37:40 +01:00
#include <list>
#include "../helpers/Monitor.hpp"
2022-03-21 19:18:33 +01:00
#include "../helpers/Workspace.hpp"
2022-03-19 16:13:19 +01:00
#include "../Window.hpp"
2022-04-05 20:49:15 +02:00
#include "OpenGL.hpp"
2023-05-01 03:49:41 +02:00
#include "../helpers/Timer.hpp"
2022-03-17 20:22:29 +01:00
2022-04-19 19:01:23 +02:00
struct SMonitorRule;
2022-04-14 16:43:29 +02:00
// TODO: add fuller damage tracking for updating only parts of a window
enum DAMAGETRACKINGMODES
{
2022-04-14 16:43:29 +02:00
DAMAGE_TRACKING_INVALID = -1,
DAMAGE_TRACKING_NONE = 0,
2022-04-14 16:43:29 +02:00
DAMAGE_TRACKING_MONITOR,
DAMAGE_TRACKING_FULL
};
enum eRenderPassMode
{
RENDER_PASS_ALL = 0,
RENDER_PASS_MAIN,
RENDER_PASS_POPUP
};
class CToplevelExportProtocolManager;
2023-01-26 11:39:06 +01:00
class CInputManager;
2023-02-03 12:58:55 +01:00
struct SSessionLockSurface;
2022-03-17 20:22:29 +01:00
class CHyprRenderer {
public:
void renderMonitor(CMonitor* pMonitor);
void outputMgrApplyTest(wlr_output_configuration_v1*, bool);
void arrangeLayersForMonitor(const int&);
2023-06-11 21:52:13 +02:00
void damageSurface(wlr_surface*, double, double, double scale = 1.0);
void damageWindow(CWindow*);
void damageBox(wlr_box*);
void damageBox(const int& x, const int& y, const int& w, const int& h);
void damageRegion(pixman_region32_t*);
void damageMonitor(CMonitor*);
void damageMirrorsWith(CMonitor*, pixman_region32_t*);
bool applyMonitorRule(CMonitor*, SMonitorRule*, bool force = false);
bool shouldRenderWindow(CWindow*, CMonitor*, CWorkspace*);
bool shouldRenderWindow(CWindow*);
void ensureCursorRenderingMode();
bool shouldRenderCursor();
void calculateUVForSurface(CWindow*, wlr_surface*, bool main = false);
std::tuple<float, float, float> getRenderTimes(CMonitor* pMonitor); // avg max min
void renderLockscreen(CMonitor* pMonitor, timespec* now);
void setOccludedForBackLayers(pixman_region32_t* region, CWorkspace* pWorkspace);
2022-06-26 13:43:32 +02:00
bool m_bWindowRequestedCursorHide = false;
bool m_bBlockSurfaceFeedback = false;
bool m_bRenderingSnapshot = false;
CWindow* m_pLastScanout = nullptr;
CMonitor* m_pMostHzMonitor = nullptr;
bool m_bDirectScanoutBlocked = false;
bool m_bSoftwareCursorsLocked = false;
2022-04-14 16:43:29 +02:00
2023-04-16 15:48:38 +02:00
DAMAGETRACKINGMODES
damageTrackingModeFromStr(const std::string&);
2022-03-17 20:22:29 +01:00
2023-04-16 15:48:38 +02:00
bool attemptDirectScanout(CMonitor*);
void setWindowScanoutMode(CWindow*);
void initiateManualCrash();
2023-04-04 15:49:58 +02:00
2023-04-16 15:48:38 +02:00
bool m_bCrashingInProgress = false;
float m_fCrashingDistort = 0.5f;
wl_event_source* m_pCrashingLoop = nullptr;
2022-11-05 13:50:47 +01:00
2023-05-01 03:49:41 +02:00
CTimer m_tRenderTimer;
private:
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*);
void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
void renderLayer(SLayerSurface*, CMonitor*, timespec*);
2023-02-03 12:58:55 +01:00
void renderSessionLockSurface(SSessionLockSurface*, CMonitor*, timespec*);
void renderDragIcon(CMonitor*, timespec*);
void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*);
void renderWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const wlr_box& geometry);
void renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f);
2022-06-24 23:27:02 +02:00
bool m_bHasARenderedCursor = true;
2022-04-05 20:49:15 +02:00
friend class CHyprOpenGLImpl;
friend class CToplevelExportProtocolManager;
2023-01-26 11:39:06 +01:00
friend class CInputManager;
2022-03-17 20:22:29 +01:00
};
inline std::unique_ptr<CHyprRenderer> g_pHyprRenderer;