cursor: move to a hyprland impl
This moves wlr_cursor to a completely new impl mostly under CPointerManager Also adds beginSimple to OpenGL for simple render passes (e.g. cursor)
This commit is contained in:
parent
e4e84064f2
commit
ed411f53bd
51 changed files with 1550 additions and 496 deletions
|
|
@ -246,13 +246,10 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::begin(CMonitor* pMonitor, const CRegion& damage_, CFramebuffer* fb, std::optional<CRegion> finalDamage) {
|
||||
void CHyprOpenGLImpl::beginSimple(CMonitor* pMonitor, const CRegion& damage, CRenderbuffer* rb, CFramebuffer* fb) {
|
||||
m_RenderData.pMonitor = pMonitor;
|
||||
|
||||
static auto PFORCEINTROSPECTION = CConfigValue<Hyprlang::INT>("opengl:force_introspection");
|
||||
|
||||
#ifndef GLES2
|
||||
|
||||
const GLenum RESETSTATUS = glGetGraphicsResetStatus();
|
||||
if (RESETSTATUS != GL_NO_ERROR) {
|
||||
std::string errStr = "";
|
||||
|
|
@ -265,7 +262,62 @@ void CHyprOpenGLImpl::begin(CMonitor* pMonitor, const CRegion& damage_, CFramebu
|
|||
RASSERT(false, "Aborting, glGetGraphicsResetStatus returned {}. Cannot continue until proper GPU reset handling is implemented.", errStr);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
TRACY_GPU_ZONE("RenderBeginSimple");
|
||||
|
||||
const auto FBO = rb ? rb->getFB() : fb;
|
||||
|
||||
glViewport(0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y);
|
||||
|
||||
matrixProjection(m_RenderData.projection, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y, WL_OUTPUT_TRANSFORM_NORMAL);
|
||||
|
||||
wlr_matrix_identity(m_RenderData.monitorProjection.data());
|
||||
if (pMonitor->transform != WL_OUTPUT_TRANSFORM_NORMAL) {
|
||||
const Vector2D tfmd = pMonitor->transform % 2 == 1 ? Vector2D{FBO->m_vSize.y, FBO->m_vSize.x} : FBO->m_vSize;
|
||||
wlr_matrix_translate(m_RenderData.monitorProjection.data(), FBO->m_vSize.x / 2.0, FBO->m_vSize.y / 2.0);
|
||||
wlr_matrix_transform(m_RenderData.monitorProjection.data(), pMonitor->transform);
|
||||
wlr_matrix_translate(m_RenderData.monitorProjection.data(), -tfmd.x / 2.0, -tfmd.y / 2.0);
|
||||
}
|
||||
|
||||
m_RenderData.pCurrentMonData = &m_mMonitorRenderResources[pMonitor];
|
||||
|
||||
if (!m_RenderData.pCurrentMonData->m_bShadersInitialized)
|
||||
initShaders();
|
||||
|
||||
m_RenderData.damage.set(damage);
|
||||
m_RenderData.finalDamage.set(damage);
|
||||
|
||||
m_bFakeFrame = true;
|
||||
|
||||
m_RenderData.currentFB = FBO;
|
||||
FBO->bind();
|
||||
m_bOffloadedFramebuffer = false;
|
||||
|
||||
m_RenderData.mainFB = m_RenderData.currentFB;
|
||||
m_RenderData.outFB = FBO;
|
||||
|
||||
m_RenderData.simplePass = true;
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::begin(CMonitor* pMonitor, const CRegion& damage_, CFramebuffer* fb, std::optional<CRegion> finalDamage) {
|
||||
m_RenderData.pMonitor = pMonitor;
|
||||
|
||||
static auto PFORCEINTROSPECTION = CConfigValue<Hyprlang::INT>("opengl:force_introspection");
|
||||
|
||||
#ifndef GLES2
|
||||
const GLenum RESETSTATUS = glGetGraphicsResetStatus();
|
||||
if (RESETSTATUS != GL_NO_ERROR) {
|
||||
std::string errStr = "";
|
||||
switch (RESETSTATUS) {
|
||||
case GL_GUILTY_CONTEXT_RESET: errStr = "GL_GUILTY_CONTEXT_RESET"; break;
|
||||
case GL_INNOCENT_CONTEXT_RESET: errStr = "GL_INNOCENT_CONTEXT_RESET"; break;
|
||||
case GL_UNKNOWN_CONTEXT_RESET: errStr = "GL_UNKNOWN_CONTEXT_RESET"; break;
|
||||
default: errStr = "UNKNOWN??"; break;
|
||||
}
|
||||
RASSERT(false, "Aborting, glGetGraphicsResetStatus returned {}. Cannot continue until proper GPU reset handling is implemented.", errStr);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
TRACY_GPU_ZONE("RenderBegin");
|
||||
|
|
@ -274,6 +326,8 @@ void CHyprOpenGLImpl::begin(CMonitor* pMonitor, const CRegion& damage_, CFramebu
|
|||
|
||||
matrixProjection(m_RenderData.projection, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y, WL_OUTPUT_TRANSFORM_NORMAL);
|
||||
|
||||
m_RenderData.monitorProjection = pMonitor->projMatrix;
|
||||
|
||||
if (m_mMonitorRenderResources.contains(pMonitor) && m_mMonitorRenderResources.at(pMonitor).offloadFB.m_vSize != pMonitor->vecPixelSize)
|
||||
destroyMonitorResources(pMonitor);
|
||||
|
||||
|
|
@ -753,7 +807,7 @@ void CHyprOpenGLImpl::renderRectWithDamage(CBox* box, const CColor& col, CRegion
|
|||
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, box->pWlr(), wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), newBox.rot,
|
||||
m_RenderData.pMonitor->projMatrix.data()); // TODO: write own, don't use WLR here
|
||||
m_RenderData.monitorProjection.data()); // TODO: write own, don't use WLR here
|
||||
|
||||
float glMatrix[9];
|
||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
|
@ -814,6 +868,12 @@ void CHyprOpenGLImpl::renderTexture(wlr_texture* tex, CBox* pBox, float alpha, i
|
|||
renderTexture(CTexture(tex), pBox, alpha, round, false, allowCustomUV);
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::renderTextureWithDamage(wlr_texture* tex, CBox* pBox, CRegion* damage, float alpha, int round, bool allowCustomUV) {
|
||||
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
|
||||
|
||||
renderTextureWithDamage(CTexture(tex), pBox, damage, alpha, round, false, allowCustomUV);
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::renderTexture(const CTexture& tex, CBox* pBox, float alpha, int round, bool discardActive, bool allowCustomUV) {
|
||||
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
|
||||
|
||||
|
|
@ -822,6 +882,14 @@ void CHyprOpenGLImpl::renderTexture(const CTexture& tex, CBox* pBox, float alpha
|
|||
scissor((CBox*)nullptr);
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::renderTextureWithDamage(const CTexture& tex, CBox* pBox, CRegion* damage, float alpha, int round, bool discardActive, bool allowCustomUV) {
|
||||
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
|
||||
|
||||
renderTextureInternalWithDamage(tex, pBox, alpha, damage, round, discardActive, false, allowCustomUV, true);
|
||||
|
||||
scissor((CBox*)nullptr);
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, CBox* pBox, float alpha, CRegion* damage, int round, bool discardActive, bool noAA, bool allowCustomUV,
|
||||
bool allowDim) {
|
||||
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
|
||||
|
|
@ -843,7 +911,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, CBox*
|
|||
// get transform
|
||||
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, newBox.pWlr(), TRANSFORM, newBox.rot, m_RenderData.pMonitor->projMatrix.data());
|
||||
wlr_matrix_project_box(matrix, newBox.pWlr(), TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
||||
|
||||
float glMatrix[9];
|
||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
|
@ -1006,7 +1074,7 @@ void CHyprOpenGLImpl::renderTexturePrimitive(const CTexture& tex, CBox* pBox) {
|
|||
// get transform
|
||||
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, newBox.pWlr(), TRANSFORM, newBox.rot, m_RenderData.pMonitor->projMatrix.data());
|
||||
wlr_matrix_project_box(matrix, newBox.pWlr(), TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
||||
|
||||
float glMatrix[9];
|
||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
|
@ -1060,7 +1128,7 @@ void CHyprOpenGLImpl::renderTextureMatte(const CTexture& tex, CBox* pBox, CFrame
|
|||
// get transform
|
||||
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, newBox.pWlr(), TRANSFORM, newBox.rot, m_RenderData.pMonitor->projMatrix.data());
|
||||
wlr_matrix_project_box(matrix, newBox.pWlr(), TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
||||
|
||||
float glMatrix[9];
|
||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
|
@ -1119,7 +1187,7 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, CRegion* o
|
|||
const auto TRANSFORM = wlr_output_transform_invert(m_RenderData.pMonitor->transform);
|
||||
float matrix[9];
|
||||
CBox MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||
wlr_matrix_project_box(matrix, MONITORBOX.pWlr(), TRANSFORM, 0, m_RenderData.pMonitor->projMatrix.data());
|
||||
wlr_matrix_project_box(matrix, MONITORBOX.pWlr(), TRANSFORM, 0, m_RenderData.monitorProjection.data());
|
||||
|
||||
float glMatrix[9];
|
||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
|
@ -1615,7 +1683,7 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in
|
|||
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, box->pWlr(), wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), newBox.rot,
|
||||
m_RenderData.pMonitor->projMatrix.data()); // TODO: write own, don't use WLR here
|
||||
m_RenderData.monitorProjection.data()); // TODO: write own, don't use WLR here
|
||||
|
||||
float glMatrix[9];
|
||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
|
@ -1921,7 +1989,7 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, int range, const
|
|||
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, box->pWlr(), wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), newBox.rot,
|
||||
m_RenderData.pMonitor->projMatrix.data()); // TODO: write own, don't use WLR here
|
||||
m_RenderData.monitorProjection.data()); // TODO: write own, don't use WLR here
|
||||
|
||||
float glMatrix[9];
|
||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
|
|
|||
|
|
@ -95,33 +95,35 @@ struct SMonitorRenderData {
|
|||
};
|
||||
|
||||
struct SCurrentRenderData {
|
||||
CMonitor* pMonitor = nullptr;
|
||||
PHLWORKSPACE pWorkspace = nullptr;
|
||||
float projection[9];
|
||||
float savedProjection[9];
|
||||
CMonitor* pMonitor = nullptr;
|
||||
PHLWORKSPACE pWorkspace = nullptr;
|
||||
float projection[9];
|
||||
float savedProjection[9];
|
||||
std::array<float, 9> monitorProjection;
|
||||
|
||||
SMonitorRenderData* pCurrentMonData = nullptr;
|
||||
CFramebuffer* currentFB = nullptr; // current rendering to
|
||||
CFramebuffer* mainFB = nullptr; // main to render to
|
||||
CFramebuffer* outFB = nullptr; // out to render to (if offloaded, etc)
|
||||
SMonitorRenderData* pCurrentMonData = nullptr;
|
||||
CFramebuffer* currentFB = nullptr; // current rendering to
|
||||
CFramebuffer* mainFB = nullptr; // main to render to
|
||||
CFramebuffer* outFB = nullptr; // out to render to (if offloaded, etc)
|
||||
|
||||
CRegion damage;
|
||||
CRegion finalDamage; // damage used for funal off -> main
|
||||
CRegion damage;
|
||||
CRegion finalDamage; // damage used for funal off -> main
|
||||
|
||||
SRenderModifData renderModif;
|
||||
float mouseZoomFactor = 1.f;
|
||||
bool mouseZoomUseMouse = true; // true by default
|
||||
bool useNearestNeighbor = false;
|
||||
bool forceIntrospection = false; // cleaned in ::end()
|
||||
bool blockScreenShader = false;
|
||||
SRenderModifData renderModif;
|
||||
float mouseZoomFactor = 1.f;
|
||||
bool mouseZoomUseMouse = true; // true by default
|
||||
bool useNearestNeighbor = false;
|
||||
bool forceIntrospection = false; // cleaned in ::end()
|
||||
bool blockScreenShader = false;
|
||||
bool simplePass = false;
|
||||
|
||||
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||
|
||||
CBox clipBox = {}; // scaled coordinates
|
||||
CBox clipBox = {}; // scaled coordinates
|
||||
|
||||
uint32_t discardMode = DISCARD_OPAQUE;
|
||||
float discardOpacity = 0.f;
|
||||
uint32_t discardMode = DISCARD_OPAQUE;
|
||||
float discardOpacity = 0.f;
|
||||
};
|
||||
|
||||
class CGradientValueData;
|
||||
|
|
@ -131,13 +133,16 @@ class CHyprOpenGLImpl {
|
|||
CHyprOpenGLImpl();
|
||||
|
||||
void begin(CMonitor*, const CRegion& damage, CFramebuffer* fb = nullptr, std::optional<CRegion> finalDamage = {});
|
||||
void beginSimple(CMonitor*, const CRegion& damage, CRenderbuffer* rb = nullptr, CFramebuffer* fb = nullptr);
|
||||
void end();
|
||||
|
||||
void renderRect(CBox*, const CColor&, int round = 0);
|
||||
void renderRectWithBlur(CBox*, const CColor&, int round = 0, float blurA = 1.f, bool xray = false);
|
||||
void renderRectWithDamage(CBox*, const CColor&, CRegion* damage, int round = 0);
|
||||
void renderTexture(wlr_texture*, CBox*, float a, int round = 0, bool allowCustomUV = false);
|
||||
void renderTextureWithDamage(wlr_texture*, CBox*, CRegion* damage, float a, int round = 0, bool allowCustomUV = false);
|
||||
void renderTexture(const CTexture&, CBox*, float a, int round = 0, bool discardActive = false, bool allowCustomUV = false);
|
||||
void renderTextureWithDamage(const CTexture&, CBox*, CRegion* damage, float a, int round = 0, bool discardActive = false, bool allowCustomUV = false);
|
||||
void renderTextureWithBlur(const CTexture&, CBox*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false, float blurA = 1.f);
|
||||
void renderRoundedShadow(CBox*, int round, int range, const CColor& color, float a = 1.0);
|
||||
void renderBorder(CBox*, const CGradientValueData&, int round, int borderSize, float a = 1.0, int outerRound = -1 /* use round */);
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ CRenderbuffer::~CRenderbuffer() {
|
|||
if (!g_pCompositor)
|
||||
return;
|
||||
|
||||
if (eglGetCurrentContext() != wlr_egl_get_context(g_pCompositor->m_sWLREGL))
|
||||
eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, wlr_egl_get_context(g_pCompositor->m_sWLREGL));
|
||||
g_pHyprRenderer->makeEGLCurrent();
|
||||
|
||||
unbind();
|
||||
m_sFramebuffer.release();
|
||||
glDeleteRenderbuffers(1, &m_iRBO);
|
||||
|
||||
g_pHyprOpenGL->m_sProc.eglDestroyImageKHR(wlr_egl_get_display(g_pCompositor->m_sWLREGL), m_iImage);
|
||||
}
|
||||
|
||||
CRenderbuffer::CRenderbuffer(wlr_buffer* buffer, uint32_t format) : m_pWlrBuffer(buffer) {
|
||||
CRenderbuffer::CRenderbuffer(wlr_buffer* buffer, uint32_t format) : m_pWlrBuffer(buffer), m_uDrmFormat(format) {
|
||||
|
||||
// EVIL, but we can't include a hidden header because nixos is fucking special
|
||||
static EGLImageKHR (*PWLREGLCREATEIMAGEFROMDMABUF)(wlr_egl*, wlr_dmabuf_attributes*, bool*);
|
||||
|
|
@ -58,7 +58,7 @@ CRenderbuffer::CRenderbuffer(wlr_buffer* buffer, uint32_t format) : m_pWlrBuffer
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
hyprListener_destroyBuffer.initCallback(
|
||||
&buffer->events.destroy, [](void* owner, void* data) { g_pHyprRenderer->onRenderbufferDestroy((CRenderbuffer*)owner); }, this, "CRenderbuffer");
|
||||
&buffer->events.destroy, [this](void* owner, void* data) { g_pHyprRenderer->onRenderbufferDestroy(this); }, this, "CRenderbuffer");
|
||||
}
|
||||
|
||||
void CRenderbuffer::bind() {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class CRenderbuffer {
|
|||
void bindFB();
|
||||
void unbind();
|
||||
CFramebuffer* getFB();
|
||||
uint32_t getFormat();
|
||||
|
||||
wlr_buffer* m_pWlrBuffer = nullptr;
|
||||
|
||||
|
|
@ -22,4 +23,5 @@ class CRenderbuffer {
|
|||
EGLImageKHR m_iImage = 0;
|
||||
GLuint m_iRBO = 0;
|
||||
CFramebuffer m_sFramebuffer;
|
||||
uint32_t m_uDrmFormat = 0;
|
||||
};
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
#include <algorithm>
|
||||
#include "../config/ConfigValue.hpp"
|
||||
#include "../managers/CursorManager.hpp"
|
||||
#include "../managers/PointerManager.hpp"
|
||||
#include "../desktop/Window.hpp"
|
||||
#include "../desktop/LayerSurface.hpp"
|
||||
#include "../protocols/SessionLock.hpp"
|
||||
|
|
@ -95,8 +96,7 @@ static void renderSurface(struct wlr_surface* surface, int x, int y, void* data)
|
|||
|
||||
TRACY_GPU_ZONE("RenderSurface");
|
||||
|
||||
double outputX = 0, outputY = 0;
|
||||
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, RDATA->pMonitor->output, &outputX, &outputY);
|
||||
double outputX = -RDATA->pMonitor->vecPosition.x, outputY = -RDATA->pMonitor->vecPosition.y;
|
||||
|
||||
auto* const PSURFACE = CWLSurface::surfaceFromWlr(surface);
|
||||
|
||||
|
|
@ -217,9 +217,7 @@ static void renderSurface(struct wlr_surface* surface, int x, int y, void* data)
|
|||
}
|
||||
|
||||
bool CHyprRenderer::shouldRenderWindow(PHLWINDOW pWindow, CMonitor* pMonitor) {
|
||||
CBox geometry = pWindow->getFullWindowBoundingBox();
|
||||
|
||||
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, geometry.pWlr()))
|
||||
if (!pWindow->visibleOnMonitor(pMonitor))
|
||||
return false;
|
||||
|
||||
if (!pWindow->m_pWorkspace && !pWindow->m_bFadingOut)
|
||||
|
|
@ -1209,10 +1207,6 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||
|
||||
EMIT_HOOK_EVENT("render", RENDER_PRE);
|
||||
|
||||
const bool UNLOCK_SC = g_pHyprRenderer->m_bSoftwareCursorsLocked;
|
||||
if (UNLOCK_SC)
|
||||
wlr_output_lock_software_cursors(pMonitor->output, true);
|
||||
|
||||
pMonitor->renderingActive = true;
|
||||
|
||||
// we need to cleanup fading out when rendering the appropriate context
|
||||
|
|
@ -1238,12 +1232,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||
CRegion damage, finalDamage;
|
||||
if (!beginRender(pMonitor, damage, RENDER_MODE_NORMAL)) {
|
||||
Debug::log(ERR, "renderer: couldn't beginRender()!");
|
||||
|
||||
if (UNLOCK_SC)
|
||||
wlr_output_lock_software_cursors(pMonitor->output, false);
|
||||
|
||||
pMonitor->state.clear();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1300,7 +1289,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||
|
||||
renderLockscreen(pMonitor, &now, renderBox);
|
||||
|
||||
if (pMonitor == g_pCompositor->m_pLastMonitor) {
|
||||
if (pMonitor == g_pCompositor->m_pLastMonitor.get()) {
|
||||
g_pHyprNotificationOverlay->draw(pMonitor);
|
||||
g_pHyprError->draw();
|
||||
}
|
||||
|
|
@ -1338,11 +1327,11 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||
bool lockSoftware = pMonitor == g_pCompositor->getMonitorFromCursor() && *PZOOMFACTOR != 1.f;
|
||||
|
||||
if (lockSoftware) {
|
||||
wlr_output_lock_software_cursors(pMonitor->output, true);
|
||||
g_pHyprRenderer->renderSoftwareCursors(pMonitor, g_pHyprOpenGL->m_RenderData.damage);
|
||||
wlr_output_lock_software_cursors(pMonitor->output, false);
|
||||
g_pPointerManager->lockSoftwareForMonitor(pMonitor->self.lock());
|
||||
g_pPointerManager->renderSoftwareCursorsFor(pMonitor->self.lock(), &now, g_pHyprOpenGL->m_RenderData.damage);
|
||||
g_pPointerManager->unlockSoftwareForMonitor(pMonitor->self.lock());
|
||||
} else
|
||||
g_pHyprRenderer->renderSoftwareCursors(pMonitor, g_pHyprOpenGL->m_RenderData.damage);
|
||||
g_pPointerManager->renderSoftwareCursorsFor(pMonitor->self.lock(), &now, g_pHyprOpenGL->m_RenderData.damage);
|
||||
}
|
||||
|
||||
EMIT_HOOK_EVENT("render", RENDER_LAST_MOMENT);
|
||||
|
|
@ -1373,21 +1362,13 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||
pMonitor->state.wlr()->tearing_page_flip = shouldTear;
|
||||
|
||||
if (!pMonitor->state.commit()) {
|
||||
|
||||
if (UNLOCK_SC)
|
||||
wlr_output_lock_software_cursors(pMonitor->output, false);
|
||||
|
||||
wlr_damage_ring_add_whole(&pMonitor->damage);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (shouldTear)
|
||||
pMonitor->tearingState.busy = true;
|
||||
|
||||
if (UNLOCK_SC)
|
||||
wlr_output_lock_software_cursors(pMonitor->output, false);
|
||||
|
||||
if (*PDAMAGEBLINK || *PVFR == 0 || pMonitor->pendingFrame)
|
||||
g_pCompositor->scheduleFrameForMonitor(pMonitor);
|
||||
|
||||
|
|
@ -1843,6 +1824,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
pMonitor->onDisconnect();
|
||||
|
||||
pMonitor->events.modeChanged.emit();
|
||||
pMonitor->updateGlobal();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2248,11 +2230,12 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
EMIT_HOOK_EVENT("monitorLayoutChanged", nullptr);
|
||||
|
||||
pMonitor->events.modeChanged.emit();
|
||||
pMonitor->updateGlobal();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CHyprRenderer::setCursorSurface(wlr_surface* surf, int hotspotX, int hotspotY, bool force) {
|
||||
void CHyprRenderer::setCursorSurface(CWLSurface* surf, int hotspotX, int hotspotY, bool force) {
|
||||
m_bCursorHasSurface = surf;
|
||||
|
||||
if (surf == m_sLastCursorData.surf && hotspotX == m_sLastCursorData.hotspotX && hotspotY == m_sLastCursorData.hotspotY && !force)
|
||||
|
|
@ -2266,7 +2249,7 @@ void CHyprRenderer::setCursorSurface(wlr_surface* surf, int hotspotX, int hotspo
|
|||
if (m_bCursorHidden && !force)
|
||||
return;
|
||||
|
||||
wlr_cursor_set_surface(g_pCompositor->m_sWLRCursor, surf, hotspotX, hotspotY);
|
||||
g_pCursorManager->setCursorSurface(surf, {hotspotX, hotspotY});
|
||||
}
|
||||
|
||||
void CHyprRenderer::setCursorFromName(const std::string& name, bool force) {
|
||||
|
|
@ -2338,7 +2321,7 @@ void CHyprRenderer::setCursorHidden(bool hide) {
|
|||
m_bCursorHidden = hide;
|
||||
|
||||
if (hide) {
|
||||
wlr_cursor_unset_image(g_pCompositor->m_sWLRCursor);
|
||||
g_pPointerManager->resetCursorImage();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2544,23 +2527,6 @@ void CHyprRenderer::recheckSolitaryForMonitor(CMonitor* pMonitor) {
|
|||
pMonitor->solitaryClient = PCANDIDATE;
|
||||
}
|
||||
|
||||
void CHyprRenderer::renderSoftwareCursors(CMonitor* pMonitor, const CRegion& damage, std::optional<Vector2D> overridePos) {
|
||||
const auto CURSORPOS = overridePos.value_or(g_pInputManager->getMouseCoordsInternal() - pMonitor->vecPosition) * pMonitor->scale;
|
||||
wlr_output_cursor* cursor;
|
||||
wl_list_for_each(cursor, &pMonitor->output->cursors, link) {
|
||||
if (!cursor->enabled || !cursor->visible || pMonitor->output->hardware_cursor == cursor)
|
||||
continue;
|
||||
|
||||
if (!cursor->texture)
|
||||
continue;
|
||||
|
||||
CBox cursorBox = CBox{CURSORPOS.x, CURSORPOS.y, cursor->width, cursor->height}.translate({-cursor->hotspot_x, -cursor->hotspot_y});
|
||||
|
||||
// TODO: NVIDIA doesn't like if we use renderTexturePrimitive here. Why?
|
||||
g_pHyprOpenGL->renderTexture(cursor->texture, &cursorBox, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
CRenderbuffer* CHyprRenderer::getOrCreateRenderbuffer(wlr_buffer* buffer, uint32_t fmt) {
|
||||
auto it = std::find_if(m_vRenderbuffers.begin(), m_vRenderbuffers.end(), [&](const auto& other) { return other->m_pWlrBuffer == buffer; });
|
||||
|
||||
|
|
@ -2582,7 +2548,7 @@ void CHyprRenderer::unsetEGL() {
|
|||
eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
}
|
||||
|
||||
bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode mode, wlr_buffer* buffer, CFramebuffer* fb) {
|
||||
bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode mode, wlr_buffer* buffer, CFramebuffer* fb, bool simple) {
|
||||
|
||||
makeEGLCurrent();
|
||||
|
||||
|
|
@ -2593,7 +2559,10 @@ bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode
|
|||
if (mode == RENDER_MODE_FULL_FAKE) {
|
||||
RASSERT(fb, "Cannot render FULL_FAKE without a provided fb!");
|
||||
fb->bind();
|
||||
g_pHyprOpenGL->begin(pMonitor, damage, fb);
|
||||
if (simple)
|
||||
g_pHyprOpenGL->beginSimple(pMonitor, damage, nullptr, fb);
|
||||
else
|
||||
g_pHyprOpenGL->begin(pMonitor, damage, fb);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2623,7 +2592,10 @@ bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode
|
|||
wlr_damage_ring_rotate_buffer(&pMonitor->damage, m_pCurrentWlrBuffer, damage.pixman());
|
||||
|
||||
m_pCurrentRenderbuffer->bind();
|
||||
g_pHyprOpenGL->begin(pMonitor, damage);
|
||||
if (simple)
|
||||
g_pHyprOpenGL->beginSimple(pMonitor, damage, m_pCurrentRenderbuffer);
|
||||
else
|
||||
g_pHyprOpenGL->begin(pMonitor, damage);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,8 @@ class CHyprRenderer {
|
|||
void setOccludedForMainWorkspace(CRegion& region, PHLWORKSPACE pWorkspace); // TODO: merge occlusion methods
|
||||
bool canSkipBackBufferClear(CMonitor* pMonitor);
|
||||
void recheckSolitaryForMonitor(CMonitor* pMonitor);
|
||||
void setCursorSurface(wlr_surface* surf, int hotspotX, int hotspotY, bool force = false);
|
||||
void setCursorSurface(CWLSurface* surf, int hotspotX, int hotspotY, bool force = false);
|
||||
void setCursorFromName(const std::string& name, bool force = false);
|
||||
void renderSoftwareCursors(CMonitor* pMonitor, const CRegion& damage, std::optional<Vector2D> overridePos = {});
|
||||
void onRenderbufferDestroy(CRenderbuffer* rb);
|
||||
CRenderbuffer* getCurrentRBO();
|
||||
bool isNvidia();
|
||||
|
|
@ -75,15 +74,14 @@ class CHyprRenderer {
|
|||
|
||||
// if RENDER_MODE_NORMAL, provided damage will be written to.
|
||||
// otherwise, it will be the one used.
|
||||
bool beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode mode = RENDER_MODE_NORMAL, wlr_buffer* buffer = nullptr, CFramebuffer* fb = nullptr);
|
||||
void endRender();
|
||||
bool beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode mode = RENDER_MODE_NORMAL, wlr_buffer* buffer = nullptr, CFramebuffer* fb = nullptr, bool simple = false);
|
||||
void endRender();
|
||||
|
||||
bool m_bBlockSurfaceFeedback = false;
|
||||
bool m_bRenderingSnapshot = false;
|
||||
bool m_bBlockSurfaceFeedback = false;
|
||||
bool m_bRenderingSnapshot = false;
|
||||
PHLWINDOWREF m_pLastScanout;
|
||||
CMonitor* m_pMostHzMonitor = nullptr;
|
||||
bool m_bDirectScanoutBlocked = false;
|
||||
bool m_bSoftwareCursorsLocked = false;
|
||||
CMonitor* m_pMostHzMonitor = nullptr;
|
||||
bool m_bDirectScanoutBlocked = false;
|
||||
|
||||
DAMAGETRACKINGMODES
|
||||
damageTrackingModeFromStr(const std::string&);
|
||||
|
|
@ -100,10 +98,10 @@ class CHyprRenderer {
|
|||
CTimer m_tRenderTimer;
|
||||
|
||||
struct {
|
||||
int hotspotX;
|
||||
int hotspotY;
|
||||
std::optional<wlr_surface*> surf = nullptr;
|
||||
std::string name;
|
||||
int hotspotX;
|
||||
int hotspotY;
|
||||
std::optional<CWLSurface*> surf = nullptr;
|
||||
std::string name;
|
||||
} m_sLastCursorData;
|
||||
|
||||
private:
|
||||
|
|
@ -139,6 +137,7 @@ class CHyprRenderer {
|
|||
friend class CHyprOpenGLImpl;
|
||||
friend class CToplevelExportProtocolManager;
|
||||
friend class CInputManager;
|
||||
friend class CPointerManager;
|
||||
};
|
||||
|
||||
inline std::unique_ptr<CHyprRenderer> g_pHyprRenderer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue