diff options
| author | UjinT34 <41110182+UjinT34@users.noreply.github.com> | 2026-03-07 21:21:23 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-07 18:21:23 +0000 |
| commit | 02f30ea15b349d1ed98b608ed06ec88c834592dd (patch) | |
| tree | 5148a3935c43b64f209f2b13e2a0b1bbe987444b /src/managers/screenshare/CursorshareSession.cpp | |
| parent | b227efc8492468cc925014a6c8446a3d044b01e8 (diff) | |
renderer: refactor gl renderer (#13488)
Diffstat (limited to 'src/managers/screenshare/CursorshareSession.cpp')
| -rw-r--r-- | src/managers/screenshare/CursorshareSession.cpp | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/managers/screenshare/CursorshareSession.cpp b/src/managers/screenshare/CursorshareSession.cpp index 63d4d205..5ccc3d22 100644 --- a/src/managers/screenshare/CursorshareSession.cpp +++ b/src/managers/screenshare/CursorshareSession.cpp @@ -116,19 +116,24 @@ void CCursorshareSession::render() { // TODO: implement a monitor independent render mode to buffer that does this in CHyprRenderer::begin() or something like that g_pHyprRenderer->m_renderData.transformDamage = false; - g_pHyprOpenGL->setViewport(0, 0, m_bufferSize.x, m_bufferSize.y); + g_pHyprRenderer->setViewport(0, 0, m_bufferSize.x, m_bufferSize.y); bool overlaps = g_pPointerManager->getCursorBoxGlobal().overlaps(m_pendingFrame.sourceBoxCallback()); + g_pHyprRenderer->startRenderPass(); if (PERM != PERMISSION_RULE_ALLOW_MODE_ALLOW || !overlaps) { // render black when not allowed - g_pHyprOpenGL->clear(Colors::BLACK); + g_pHyprRenderer->draw(makeUnique<CClearPassElement>(CClearPassElement::SClearData{Colors::BLACK}), {}); } else if (!cursorImage.pBuffer || !cursorImage.surface || !cursorImage.bufferTex) { // render clear when cursor is probably hidden - g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 0)); + g_pHyprRenderer->draw(makeUnique<CClearPassElement>(CClearPassElement::SClearData{{0, 0, 0, 0}}), {}); } else { // render cursor CBox texbox = {{}, cursorImage.bufferTex->m_size}; - g_pHyprOpenGL->renderTexture(cursorImage.bufferTex, texbox, {}); + g_pHyprRenderer->draw(makeUnique<CTexPassElement>(CTexPassElement::SRenderData{ + .tex = cursorImage.bufferTex, + .box = texbox, + }), + {}); } g_pHyprRenderer->m_renderData.blockScreenShader = true; @@ -141,8 +146,6 @@ bool CCursorshareSession::copy() { // FIXME: this doesn't really make sense but just to be safe m_pendingFrame.callback(RESULT_TIMESTAMP); - g_pHyprOpenGL->makeEGLCurrent(); - CRegion fakeDamage = {0, 0, INT16_MAX, INT16_MAX}; if (auto attrs = m_pendingFrame.buffer->dmabuf(); attrs.success) { if (attrs.format != m_format) { @@ -150,7 +153,7 @@ bool CCursorshareSession::copy() { return false; } - if (!g_pHyprRenderer->beginRender(m_pendingFrame.monitor, fakeDamage, RENDER_MODE_TO_BUFFER, m_pendingFrame.buffer, nullptr, true)) { + if (!g_pHyprRenderer->beginRenderToBuffer(m_pendingFrame.monitor, fakeDamage, m_pendingFrame.buffer, true)) { LOGM(Log::ERR, "Can't copy: failed to begin rendering to dmabuf"); return false; } @@ -162,8 +165,7 @@ bool CCursorshareSession::copy() { callback(RESULT_COPIED); }); } else if (auto attrs = m_pendingFrame.buffer->shm(); attrs.success) { - auto [bufData, fmt, bufLen] = m_pendingFrame.buffer->beginDataPtr(0); - const auto PFORMAT = NFormatUtils::getPixelFormatFromDRM(m_format); + const auto PFORMAT = NFormatUtils::getPixelFormatFromDRM(m_format); if (attrs.format != m_format || !PFORMAT) { LOGM(Log::ERR, "Can't copy: invalid format"); @@ -173,7 +175,7 @@ bool CCursorshareSession::copy() { auto outFB = g_pHyprRenderer->createFB(); outFB->alloc(m_bufferSize.x, m_bufferSize.y, m_format); - if (!g_pHyprRenderer->beginRender(m_pendingFrame.monitor, fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, outFB, true)) { + if (!g_pHyprRenderer->beginFullFakeRender(m_pendingFrame.monitor, fakeDamage, outFB)) { LOGM(Log::ERR, "Can't copy: failed to begin rendering to shm"); return false; } @@ -182,12 +184,6 @@ bool CCursorshareSession::copy() { g_pHyprRenderer->endRender(); - g_pHyprRenderer->m_renderData.pMonitor = m_pendingFrame.monitor; - outFB->bind(); - glBindFramebuffer(GL_READ_FRAMEBUFFER, GLFB(outFB)->getFBID()); - - glPixelStorei(GL_PACK_ALIGNMENT, 1); - int glFormat = PFORMAT->glFormat; if (glFormat == GL_RGBA) @@ -208,15 +204,10 @@ bool CCursorshareSession::copy() { } } - glReadPixels(0, 0, m_bufferSize.x, m_bufferSize.y, glFormat, PFORMAT->glType, bufData); + outFB->readPixels(m_pendingFrame.buffer, 0, 0, m_bufferSize.x, m_bufferSize.y); g_pHyprRenderer->m_renderData.pMonitor.reset(); - m_pendingFrame.buffer->endDataPtr(); - GLFB(outFB)->unbind(); - glPixelStorei(GL_PACK_ALIGNMENT, 4); - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - m_pendingFrame.callback(RESULT_COPIED); } else { LOGM(Log::ERR, "Can't copy: invalid buffer type"); |
