namespace render interfaces

This commit is contained in:
UjinT34 2026-03-07 22:29:37 +03:00
parent 15f410e998
commit 063a9fda0f
29 changed files with 217 additions and 187 deletions

View file

@ -44,7 +44,7 @@ class CHyprDebugOverlay {
cairo_surface_t* m_cairoSurface = nullptr;
cairo_t* m_cairo = nullptr;
SP<ITexture> m_texture;
SP<Render::ITexture> m_texture;
friend class CHyprMonitorDebugOverlay;
friend class Render::IHyprRenderer;

View file

@ -57,7 +57,7 @@ class CHyprNotificationOverlay {
PHLMONITORREF m_lastMonitor;
Vector2D m_lastSize = Vector2D(-1, -1);
SP<ITexture> m_texture;
SP<Render::ITexture> m_texture;
};
inline UP<CHyprNotificationOverlay> g_pHyprNotificationOverlay;

View file

@ -60,7 +60,7 @@ namespace Desktop::View {
std::string m_namespace = "";
SP<Desktop::View::CPopup> m_popupHead;
SP<IFramebuffer> m_snapshotFB;
SP<Render::IFramebuffer> m_snapshotFB;
pid_t getPID();

View file

@ -58,10 +58,10 @@ namespace Desktop::View {
bool m_mapped = false;
// fade in-out
PHLANIMVAR<float> m_alpha;
bool m_fadingOut = false;
PHLANIMVAR<float> m_alpha;
bool m_fadingOut = false;
SP<IFramebuffer> m_snapshotFB;
SP<Render::IFramebuffer> m_snapshotFB;
private:
CPopup();

View file

@ -255,7 +255,7 @@ namespace Desktop::View {
const uint64_t m_stableID = 0x2137;
// snapshots
SP<IFramebuffer> m_snapshotFB;
SP<Render::IFramebuffer> m_snapshotFB;
// ANR
PHLANIMVAR<float> m_notRespondingTint;

View file

@ -119,8 +119,8 @@ class CMonitor {
Config::CMonitorRule m_activeMonitorRule;
SP<ITexture> m_splash;
SP<ITexture> m_background;
SP<Render::ITexture> m_splash;
SP<Render::ITexture> m_background;
// explicit sync
Hyprutils::OS::CFileDescriptor m_inFence; // TODO: remove when aq uses CFileDescriptor
@ -132,15 +132,15 @@ class CMonitor {
// mirroring
PHLMONITORREF m_mirrorOf;
std::vector<PHLMONITORREF> m_mirrors;
SP<IFramebuffer> m_monitorMirrorFB;
SP<Render::IFramebuffer> m_monitorMirrorFB;
// rendering fb
SP<IFramebuffer> m_offloadFB;
SP<IFramebuffer> m_mirrorFB; // these are used for some effects,
SP<IFramebuffer> m_mirrorSwapFB; // etc
SP<IFramebuffer> m_offMainFB;
SP<IFramebuffer> m_blurFB;
SP<ITexture> m_stencilTex;
SP<Render::IFramebuffer> m_offloadFB;
SP<Render::IFramebuffer> m_mirrorFB; // these are used for some effects,
SP<Render::IFramebuffer> m_mirrorSwapFB; // etc
SP<Render::IFramebuffer> m_offMainFB;
SP<Render::IFramebuffer> m_blurFB;
SP<Render::ITexture> m_stencilTex; // TODO fix blur ignore alpha and remove
// ctm
Mat3x3 m_ctm = Mat3x3::identity();

View file

@ -17,7 +17,9 @@
#define HDR_REF_LUMINANCE 203.0
#define HLG_MAX_LUMINANCE 1000.0
class ITexture;
namespace Render {
class ITexture;
}
namespace NColorManagement {
enum eNoShader : uint8_t {
@ -219,7 +221,7 @@ namespace NColorManagement {
bool present = false;
size_t lutSize = 33;
std::vector<float> lutDataPacked;
SP<ITexture> lutTexture;
SP<Render::ITexture> lutTexture;
std::optional<SVCGTTable16> vcgt;
} icc;

View file

@ -244,7 +244,7 @@ float CHyprError::height() {
return m_lastHeight;
}
SP<ITexture> CHyprError::texture() {
SP<Render::ITexture> CHyprError::texture() {
if (!m_texture)
m_texture = g_pHyprRenderer->createTexture();
return m_texture;

View file

@ -11,28 +11,28 @@ class CHyprError {
CHyprError();
~CHyprError() = default;
void queueCreate(std::string message, const CHyprColor& color);
void queueError(std::string err);
void draw();
void destroy();
void queueCreate(std::string message, const CHyprColor& color);
void queueError(std::string err);
void draw();
void destroy();
bool active();
float height(); // logical
bool active();
float height(); // logical
SP<ITexture> texture();
SP<Render::ITexture> texture();
private:
void createQueued();
std::string m_queued = "";
CHyprColor m_queuedColor;
bool m_queuedDestroy = false;
bool m_isCreated = false;
SP<ITexture> m_texture;
PHLANIMVAR<float> m_fadeOpacity;
CBox m_damageBox = {0, 0, 0, 0};
float m_lastHeight = 0.F;
void createQueued();
std::string m_queued = "";
CHyprColor m_queuedColor;
bool m_queuedDestroy = false;
bool m_isCreated = false;
SP<Render::ITexture> m_texture;
PHLANIMVAR<float> m_fadeOpacity;
CBox m_damageBox = {0, 0, 0, 0};
float m_lastHeight = 0.F;
bool m_monitorChanged = false;
bool m_monitorChanged = false;
};
inline UP<CHyprError> g_pHyprError; // This is a full-screen error. Treat it with respect, and there can only be one at a time.

View file

@ -411,7 +411,7 @@ bool CPointerManager::setHWCursorBuffer(SP<SMonitorPointerState> state, SP<Aquam
return true;
}
SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager::SMonitorPointerState> state, SP<ITexture> texture) {
SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager::SMonitorPointerState> state, SP<Render::ITexture> texture) {
auto maxSize = state->monitor->m_output->cursorPlaneSize();
auto const& cursorSize = m_currentCursorImage.size;
@ -905,7 +905,7 @@ const CPointerManager::SCursorImage& CPointerManager::currentCursorImage() {
return m_currentCursorImage;
}
SP<ITexture> CPointerManager::getCurrentCursorTexture() {
SP<Render::ITexture> CPointerManager::getCurrentCursorTexture() {
if (!m_currentCursorImage.pBuffer && (!m_currentCursorImage.surface || !m_currentCursorImage.surface->resource()->m_current.texture))
return nullptr;

View file

@ -12,7 +12,9 @@
class CMonitor;
class IHID;
class ITexture;
namespace Render {
class ITexture;
}
AQUAMARINE_FORWARD(IBuffer);
@ -71,7 +73,7 @@ class CPointerManager {
struct SCursorImage {
SP<Aquamarine::IBuffer> pBuffer;
SP<ITexture> bufferTex;
SP<Render::ITexture> bufferTex;
WP<Desktop::View::CWLSurface> surface;
Vector2D hotspot;
@ -82,8 +84,8 @@ class CPointerManager {
CHyprSignalListener commitSurface;
};
const SCursorImage& currentCursorImage();
SP<ITexture> getCurrentCursorTexture();
const SCursorImage& currentCursorImage();
SP<Render::ITexture> getCurrentCursorTexture();
struct {
CSignalT<> cursorChanged;
@ -181,7 +183,7 @@ class CPointerManager {
std::vector<SP<SMonitorPointerState>> m_monitorStates;
SP<SMonitorPointerState> stateFor(PHLMONITOR mon);
bool attemptHardwareCursor(SP<SMonitorPointerState> state);
SP<Aquamarine::IBuffer> renderHWCursorBuffer(SP<SMonitorPointerState> state, SP<ITexture> texture);
SP<Aquamarine::IBuffer> renderHWCursorBuffer(SP<SMonitorPointerState> state, SP<Render::ITexture> texture);
bool setHWCursorBuffer(SP<SMonitorPointerState> state, SP<Aquamarine::IBuffer> buf);
struct {

View file

@ -61,24 +61,24 @@ namespace Screenshare {
CScreenshareSession(PHLMONITOR monitor, CBox captureRegion, wl_client* client);
CScreenshareSession(PHLWINDOW window, wl_client* client);
WP<CScreenshareSession> m_self;
bool m_stopped = false;
WP<CScreenshareSession> m_self;
bool m_stopped = false;
eScreenshareType m_type = SHARE_NONE;
PHLMONITORREF m_monitor;
PHLWINDOWREF m_window;
CBox m_captureBox = {}; // given capture area in logical coordinates (see xdg_output)
eScreenshareType m_type = SHARE_NONE;
PHLMONITORREF m_monitor;
PHLWINDOWREF m_window;
CBox m_captureBox = {}; // given capture area in logical coordinates (see xdg_output)
wl_client* m_client = nullptr;
std::string m_name = "";
wl_client* m_client = nullptr;
std::string m_name = "";
std::vector<DRMFormat> m_formats;
Vector2D m_bufferSize = Vector2D(0, 0);
std::vector<DRMFormat> m_formats;
Vector2D m_bufferSize = Vector2D(0, 0);
SP<IFramebuffer> m_tempFB;
SP<Render::IFramebuffer> m_tempFB;
SP<CEventLoopTimer> m_shareStopTimer;
bool m_sharing = false;
SP<CEventLoopTimer> m_shareStopTimer;
bool m_sharing = false;
struct {
CHyprSignalListener monitorDestroyed;

View file

@ -26,7 +26,7 @@ class IHLBuffer : public Aquamarine::IBuffer {
void onBackendRelease(const std::function<void()>& fn);
void addReleasePoint(CDRMSyncPointState& point);
SP<ITexture> m_texture;
SP<Render::ITexture> m_texture;
bool m_opaque = false;
SP<CWLBufferResource> m_resource;
std::vector<UP<CSyncReleaser>> m_syncReleasers;

View file

@ -35,7 +35,7 @@ CRegion SSurfaceState::accumulateBufferDamage() {
return bufferDamage;
}
void SSurfaceState::updateSynchronousTexture(SP<ITexture> lastTexture) {
void SSurfaceState::updateSynchronousTexture(SP<Render::ITexture> lastTexture) {
auto [dataPtr, fmt, size] = buffer->beginDataPtr(0);
if (dataPtr) {
auto drmFmt = NFormatUtils::shmToDRM(fmt);

View file

@ -6,7 +6,9 @@
#include "../WaylandProtocol.hpp"
#include "./Buffer.hpp"
class ITexture;
namespace Render {
class ITexture;
}
class CDRMSyncPointState;
class CWLCallbackResource;
@ -88,8 +90,8 @@ struct SSurfaceState {
eLockReason lockMask = LOCK_REASON_NONE;
// texture of surface content, used for rendering
SP<ITexture> texture;
void updateSynchronousTexture(SP<ITexture> lastTexture);
SP<Render::ITexture> texture;
void updateSynchronousTexture(SP<Render::ITexture> lastTexture);
// fifo
bool barrierSet = false;

View file

@ -1,5 +1,7 @@
#include "Framebuffer.hpp"
using namespace Render;
IFramebuffer::IFramebuffer(const std::string& name) : m_name(name) {}
bool IFramebuffer::alloc(int w, int h, uint32_t format) {

View file

@ -8,33 +8,35 @@
class CHLBufferReference;
class IFramebuffer {
public:
IFramebuffer() = default;
IFramebuffer(const std::string& name);
virtual ~IFramebuffer() = default;
namespace Render {
class IFramebuffer {
public:
IFramebuffer() = default;
IFramebuffer(const std::string& name);
virtual ~IFramebuffer() = default;
virtual bool alloc(int w, int h, uint32_t format = DRM_FORMAT_ARGB8888);
virtual void release() = 0;
virtual bool readPixels(CHLBufferReference buffer, uint32_t offsetX = 0, uint32_t offsetY = 0, uint32_t width = 0, uint32_t height = 0) = 0;
virtual bool alloc(int w, int h, uint32_t format = DRM_FORMAT_ARGB8888);
virtual void release() = 0;
virtual bool readPixels(CHLBufferReference buffer, uint32_t offsetX = 0, uint32_t offsetY = 0, uint32_t width = 0, uint32_t height = 0) = 0;
virtual void bind() = 0;
virtual void bind() = 0;
bool isAllocated();
SP<ITexture> getTexture();
SP<ITexture> getStencilTex();
bool isAllocated();
SP<ITexture> getTexture();
SP<ITexture> getStencilTex();
virtual void addStencil(SP<ITexture> tex) = 0;
virtual void addStencil(SP<ITexture> tex) = 0;
Vector2D m_size;
DRMFormat m_drmFormat = DRM_FORMAT_INVALID;
Vector2D m_size;
DRMFormat m_drmFormat = DRM_FORMAT_INVALID;
protected:
virtual bool internalAlloc(int w, int h, uint32_t format = DRM_FORMAT_ARGB8888) = 0;
protected:
virtual bool internalAlloc(int w, int h, uint32_t format = DRM_FORMAT_ARGB8888) = 0;
SP<ITexture> m_tex;
bool m_fbAllocated = false;
SP<ITexture> m_tex;
bool m_fbAllocated = false;
SP<ITexture> m_stencilTex;
std::string m_name; // name for logging
};
SP<ITexture> m_stencilTex;
std::string m_name; // name for logging
};
}

View file

@ -7,6 +7,8 @@
#include <dlfcn.h>
using namespace Render;
IRenderbuffer::IRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t format) : m_hlBuffer(buffer) {
m_listeners.destroyBuffer = buffer->events.destroy.listen([this] { g_pHyprRenderer->onRenderbufferDestroy(this); });
}

View file

@ -5,24 +5,26 @@
#include "Framebuffer.hpp"
#include <aquamarine/buffer/Buffer.hpp>
class IRenderbuffer {
public:
IRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t format);
virtual ~IRenderbuffer() = default;
namespace Render {
class IRenderbuffer {
public:
IRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t format);
virtual ~IRenderbuffer() = default;
bool good();
SP<IFramebuffer> getFB();
bool good();
SP<IFramebuffer> getFB();
virtual void bind() = 0;
virtual void unbind() = 0;
virtual void bind() = 0;
virtual void unbind() = 0;
WP<Aquamarine::IBuffer> m_hlBuffer;
WP<Aquamarine::IBuffer> m_hlBuffer;
protected:
SP<IFramebuffer> m_framebuffer;
bool m_good = false;
protected:
SP<IFramebuffer> m_framebuffer;
bool m_good = false;
struct {
CHyprSignalListener destroyBuffer;
} m_listeners;
};
struct {
CHyprSignalListener destroyBuffer;
} m_listeners;
};
}

View file

@ -33,7 +33,6 @@ class CWorkspace;
class CInputPopup;
class IHLBuffer;
class CEventLoopTimer;
class CRenderPass;
class CToplevelExportProtocolManager;
class CInputManager;
struct SSessionLockSurface;
@ -43,6 +42,7 @@ namespace Screenshare {
namespace Render {
class IElementRenderer;
class CRenderPass;
class IHyprRenderer {
public:

View file

@ -1,6 +1,8 @@
#include "Texture.hpp"
#include <cstring>
using namespace Render;
ITexture::ITexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size, bool keepDataCopy, bool opaque) :
m_size(size), m_opaque(opaque), m_drmFormat(drmFormat), m_keepDataCopy(keepDataCopy) {
if (m_keepDataCopy && stride && pixels) {

View file

@ -8,51 +8,53 @@
class IHLBuffer;
HYPRUTILS_FORWARD(Math, CRegion);
enum eTextureType : int8_t {
TEXTURE_INVALID = -1, // Invalid
TEXTURE_RGBA = 0, // 4 channels
TEXTURE_RGBX, // discard A
TEXTURE_3D_LUT, // 3D LUT
TEXTURE_EXTERNAL, // EGLImage
};
namespace Render {
enum eTextureType : int8_t {
TEXTURE_INVALID = -1, // Invalid
TEXTURE_RGBA = 0, // 4 channels
TEXTURE_RGBX, // discard A
TEXTURE_3D_LUT, // 3D LUT
TEXTURE_EXTERNAL, // EGLImage
};
class ITexture {
public:
ITexture(ITexture&) = delete;
ITexture(ITexture&&) = delete;
ITexture(const ITexture&&) = delete;
ITexture(const ITexture&) = delete;
class ITexture {
public:
ITexture(ITexture&) = delete;
ITexture(ITexture&&) = delete;
ITexture(const ITexture&&) = delete;
ITexture(const ITexture&) = delete;
virtual ~ITexture() = default;
virtual ~ITexture() = default;
virtual void setTexParameter(GLenum pname, GLint param) = 0;
virtual void allocate(const Vector2D& size, uint32_t drmFormat = 0) = 0;
virtual void update(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const CRegion& damage) = 0;
virtual void bind() {};
virtual void unbind() {};
virtual bool ok();
virtual bool isDMA();
virtual void setTexParameter(GLenum pname, GLint param) = 0;
virtual void allocate(const Vector2D& size, uint32_t drmFormat = 0) = 0;
virtual void update(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const CRegion& damage) = 0;
virtual void bind() {};
virtual void unbind() {};
virtual bool ok();
virtual bool isDMA();
const std::vector<uint8_t>& dataCopy();
const std::vector<uint8_t>& dataCopy();
eTextureType m_type = TEXTURE_RGBA;
Vector2D m_size = {};
eTransform m_transform = HYPRUTILS_TRANSFORM_NORMAL;
bool m_opaque = false;
eTextureType m_type = TEXTURE_RGBA;
Vector2D m_size = {};
eTransform m_transform = HYPRUTILS_TRANSFORM_NORMAL;
bool m_opaque = false;
uint32_t m_drmFormat = 0; // for shm
bool m_isSynchronous = false;
uint32_t m_drmFormat = 0; // for shm
bool m_isSynchronous = false;
// TODO move to GLTexture
GLuint m_texID = 0;
GLenum magFilter = GL_LINEAR; // useNearestNeighbor overwrites these
GLenum minFilter = GL_LINEAR;
// TODO move to GLTexture
GLuint m_texID = 0;
GLenum magFilter = GL_LINEAR; // useNearestNeighbor overwrites these
GLenum minFilter = GL_LINEAR;
protected:
ITexture() = default;
ITexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size, bool keepDataCopy = false, bool opaque = false);
ITexture(std::span<const float> lut3D, size_t N);
protected:
ITexture() = default;
ITexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size, bool keepDataCopy = false, bool opaque = false);
ITexture(std::span<const float> lut3D, size_t N);
bool m_keepDataCopy = false;
std::vector<uint8_t> m_dataCopy;
};
bool m_keepDataCopy = false;
std::vector<uint8_t> m_dataCopy;
};
}

View file

@ -14,7 +14,7 @@ class IWindowTransformer {
// called by Hyprland. For more data about what is being rendered, inspect render data.
// returns the out fb.
virtual IFramebuffer* transform(IFramebuffer* in) = 0;
virtual Render::IFramebuffer* transform(Render::IFramebuffer* in) = 0;
// called by Hyprland before a window main pass is started.
virtual void preWindowRender(CSurfacePassElement::SRenderData* pRenderData);

View file

@ -12,6 +12,8 @@
#include "../../layout/LayoutManager.hpp"
#include "../../layout/supplementary/DragController.hpp"
using namespace Render;
// shared things to conserve VRAM
static SP<ITexture> m_tGradientActive;
static SP<ITexture> m_tGradientInactive;

View file

@ -12,13 +12,13 @@ class CTitleTex {
CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float monitorScale);
~CTitleTex() = default;
SP<ITexture> m_texActive;
SP<ITexture> m_texInactive;
SP<ITexture> m_texLockedActive;
SP<ITexture> m_texLockedInactive;
std::string m_content;
SP<Render::ITexture> m_texActive;
SP<Render::ITexture> m_texInactive;
SP<Render::ITexture> m_texLockedActive;
SP<Render::ITexture> m_texLockedInactive;
std::string m_content;
PHLWINDOWREF m_windowOwner;
PHLWINDOWREF m_windowOwner;
};
void refreshGroupBarGradients();

View file

@ -3,40 +3,44 @@
#include "../../defines.hpp"
#include "PassElement.hpp"
class ITexture;
class CGradientValueData;
class CRenderPass {
public:
bool empty() const;
bool single() const;
namespace Render {
class ITexture;
void add(UP<IPassElement>&& elem);
void clear();
void removeAllOfType(const std::string& type);
class CRenderPass {
public:
bool empty() const;
bool single() const;
CRegion render(const CRegion& damage_);
void add(UP<IPassElement>&& elem);
void clear();
void removeAllOfType(const std::string& type);
private:
CRegion m_damage;
std::vector<CRegion> m_occludedRegions;
CRegion m_totalLiveBlurRegion;
CRegion render(const CRegion& damage_);
struct SPassElementData {
CRegion elementDamage;
UP<IPassElement> element;
bool discard = false;
private:
CRegion m_damage;
std::vector<CRegion> m_occludedRegions;
CRegion m_totalLiveBlurRegion;
struct SPassElementData {
CRegion elementDamage;
UP<IPassElement> element;
bool discard = false;
};
std::vector<UP<SPassElementData>> m_passElements;
void simplify();
float oneBlurRadius();
void renderDebugData();
struct {
bool present = false;
SP<ITexture> keyboardFocusText, pointerFocusText, lastWindowText;
} m_debugData;
friend class CHyprOpenGLImpl;
};
std::vector<UP<SPassElementData>> m_passElements;
void simplify();
float oneBlurRadius();
void renderDebugData();
struct {
bool present = false;
SP<ITexture> keyboardFocusText, pointerFocusText, lastWindowText;
} m_debugData;
friend class CHyprOpenGLImpl;
};
}

View file

@ -5,7 +5,9 @@
#include "../../helpers/time/Time.hpp"
class CWLSurfaceResource;
class ITexture;
namespace Render {
class ITexture;
}
class CSyncTimeline;
class CSurfacePassElement : public IPassElement {
@ -17,7 +19,7 @@ class CSurfacePassElement : public IPassElement {
void* data = nullptr;
SP<CWLSurfaceResource> surface = nullptr;
SP<ITexture> texture = nullptr;
SP<Render::ITexture> texture = nullptr;
bool mainSurface = true;
double w = 0, h = 0;
int rounding = 0;

View file

@ -3,7 +3,9 @@
#include <optional>
class CWLSurfaceResource;
class ITexture;
namespace Render {
class ITexture;
}
class CSyncTimeline;
enum eDiscardMode : uint8_t {
@ -14,7 +16,7 @@ enum eDiscardMode : uint8_t {
class CTexPassElement : public IPassElement {
public:
struct SRenderData {
SP<ITexture> tex;
SP<Render::ITexture> tex;
CBox box;
float a = 1.F;
float blurA = 1.F;
@ -41,7 +43,7 @@ class CTexPassElement : public IPassElement {
CRegion clipRegion;
PHLLSREF currentLS;
SP<ITexture> blurredBG;
SP<Render::ITexture> blurredBG;
};
CTexPassElement(const SRenderData& data);

View file

@ -2,15 +2,17 @@
#include "PassElement.hpp"
#include "../Framebuffer.hpp"
class ITexture;
namespace Render {
class ITexture;
}
class CTextureMatteElement : public IPassElement {
public:
struct STextureMatteData {
CBox box;
SP<ITexture> tex;
SP<IFramebuffer> fb;
bool disableTransformAndModify = false;
CBox box;
SP<Render::ITexture> tex;
SP<Render::IFramebuffer> fb;
bool disableTransformAndModify = false;
};
CTextureMatteElement(const STextureMatteData& data_);