Renderer: rewrite render scheduling (#8683)
This rewrites renderer scheduling. Occlusion is now unified in a new Pass type.
This commit is contained in:
parent
1cc1a46c2e
commit
e536b02248
42 changed files with 1576 additions and 775 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "../../Compositor.hpp"
|
||||
#include "../../config/ConfigValue.hpp"
|
||||
#include "../../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../pass/BorderPassElement.hpp"
|
||||
|
||||
CHyprBorderDecoration::CHyprBorderDecoration(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) {
|
||||
;
|
||||
|
|
@ -66,13 +67,24 @@ void CHyprBorderDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
|||
grad.m_fAngle = normalizeAngleRad(grad.m_fAngle);
|
||||
}
|
||||
|
||||
int borderSize = m_pWindow->getRealBorderSize();
|
||||
const auto ROUNDING = m_pWindow->rounding() * pMonitor->scale;
|
||||
int borderSize = m_pWindow->getRealBorderSize();
|
||||
const auto ROUNDING = m_pWindow->rounding() * pMonitor->scale;
|
||||
|
||||
if (ANIMATED)
|
||||
g_pHyprOpenGL->renderBorder(&windowBox, m_pWindow->m_cRealBorderColorPrevious, grad, m_pWindow->m_fBorderFadeAnimationProgress.value(), ROUNDING, borderSize, a);
|
||||
else
|
||||
g_pHyprOpenGL->renderBorder(&windowBox, grad, ROUNDING, borderSize, a);
|
||||
CBorderPassElement::SBorderData data;
|
||||
data.box = windowBox;
|
||||
data.grad1 = grad;
|
||||
data.round = ROUNDING;
|
||||
data.a = a;
|
||||
data.borderSize = borderSize;
|
||||
|
||||
if (ANIMATED) {
|
||||
data.hasGrad2 = true;
|
||||
data.grad1 = m_pWindow->m_cRealBorderColorPrevious;
|
||||
data.grad2 = grad;
|
||||
data.lerp = m_pWindow->m_fBorderFadeAnimationProgress.value();
|
||||
}
|
||||
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CBorderPassElement>(data));
|
||||
}
|
||||
|
||||
eDecorationType CHyprBorderDecoration::getDecorationType() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../../Compositor.hpp"
|
||||
#include "../../config/ConfigValue.hpp"
|
||||
#include "../pass/ShadowPassElement.hpp"
|
||||
|
||||
CHyprDropShadowDecoration::CHyprDropShadowDecoration(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) {
|
||||
;
|
||||
|
|
@ -87,7 +88,13 @@ void CHyprDropShadowDecoration::updateWindow(PHLWINDOW pWindow) {
|
|||
}
|
||||
|
||||
void CHyprDropShadowDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
||||
CShadowPassElement::SShadowData data;
|
||||
data.deco = this;
|
||||
data.a = a;
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CShadowPassElement>(data));
|
||||
}
|
||||
|
||||
void CHyprDropShadowDecoration::render(PHLMONITOR pMonitor, float const& a) {
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
if (!validMapped(PWINDOW))
|
||||
|
|
@ -141,6 +148,7 @@ void CHyprDropShadowDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
|||
return; // don't draw invisible shadows
|
||||
|
||||
g_pHyprOpenGL->scissor((CBox*)nullptr);
|
||||
g_pHyprOpenGL->m_RenderData.currentWindow = m_pWindow;
|
||||
|
||||
// we'll take the liberty of using this as it should not be used rn
|
||||
CFramebuffer& alphaFB = g_pHyprOpenGL->m_RenderData.pCurrentMonData->mirrorFB;
|
||||
|
|
@ -197,6 +205,7 @@ void CHyprDropShadowDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
|||
LASTFB->bind();
|
||||
|
||||
CBox monbox = {0, 0, pMonitor->vecTransformedSize.x, pMonitor->vecTransformedSize.y};
|
||||
|
||||
g_pHyprOpenGL->setMonitorTransformEnabled(true);
|
||||
g_pHyprOpenGL->setRenderModifEnabled(false);
|
||||
g_pHyprOpenGL->renderTextureMatte(alphaSwapFB.getTexture(), &monbox, alphaFB);
|
||||
|
|
@ -209,6 +218,8 @@ void CHyprDropShadowDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
|||
|
||||
if (m_seExtents != m_seReportedExtents)
|
||||
g_pDecorationPositioner->repositionDeco(this);
|
||||
|
||||
g_pHyprOpenGL->m_RenderData.currentWindow.reset();
|
||||
}
|
||||
|
||||
eDecorationLayer CHyprDropShadowDecoration::getDecorationLayer() {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
|||
|
||||
virtual std::string getDisplayName();
|
||||
|
||||
void render(PHLMONITOR, float const& a);
|
||||
|
||||
private:
|
||||
SBoxExtents m_seExtents;
|
||||
SBoxExtents m_seReportedExtents;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "managers/LayoutManager.hpp"
|
||||
#include <ranges>
|
||||
#include <pango/pangocairo.h>
|
||||
#include "../pass/TexPassElement.hpp"
|
||||
#include "../pass/RectPassElement.hpp"
|
||||
|
||||
// shared things to conserve VRAM
|
||||
static SP<CTexture> m_tGradientActive = makeShared<CTexture>();
|
||||
|
|
@ -71,11 +73,11 @@ void CHyprGroupBarDecoration::updateWindow(PHLWINDOW pWindow) {
|
|||
|
||||
m_dwGroupMembers.clear();
|
||||
PHLWINDOW head = pWindow->getGroupHead();
|
||||
m_dwGroupMembers.push_back(head);
|
||||
m_dwGroupMembers.emplace_back(head);
|
||||
|
||||
PHLWINDOW curr = head->m_sGroupData.pNextWindow.lock();
|
||||
while (curr != head) {
|
||||
m_dwGroupMembers.push_back(curr);
|
||||
m_dwGroupMembers.emplace_back(curr);
|
||||
curr = curr->m_sGroupData.pNextWindow.lock();
|
||||
}
|
||||
|
||||
|
|
@ -113,10 +115,9 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
|||
m_fBarWidth = *PSTACKED ? ASSIGNEDBOX.w : (ASSIGNEDBOX.w - BAR_HORIZONTAL_PADDING * (barsToDraw - 1)) / barsToDraw;
|
||||
m_fBarHeight = *PSTACKED ? ((ASSIGNEDBOX.h - 2 - BAR_PADDING_OUTER_VERT) - BAR_PADDING_OUTER_VERT * (barsToDraw)) / barsToDraw : ASSIGNEDBOX.h - BAR_PADDING_OUTER_VERT;
|
||||
|
||||
const auto DESIREDHEIGHT = *PSTACKED ? (ONEBARHEIGHT * m_dwGroupMembers.size()) + 2 + BAR_PADDING_OUTER_VERT : BAR_PADDING_OUTER_VERT * 2 + ONEBARHEIGHT;
|
||||
if (DESIREDHEIGHT != ASSIGNEDBOX.h) {
|
||||
const auto DESIREDHEIGHT = *PSTACKED ? (ONEBARHEIGHT * m_dwGroupMembers.size()) + 2 + BAR_PADDING_OUTER_VERT : BAR_PADDING_OUTER_VERT * 2L + ONEBARHEIGHT;
|
||||
if (DESIREDHEIGHT != ASSIGNEDBOX.h)
|
||||
g_pDecorationPositioner->repositionDeco(this);
|
||||
}
|
||||
|
||||
float xoff = 0;
|
||||
float yoff = 0;
|
||||
|
|
@ -148,7 +149,10 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
|||
|
||||
CHyprColor color = m_dwGroupMembers[WINDOWINDEX].lock() == g_pCompositor->m_pLastWindow.lock() ? PCOLACTIVE->m_vColors[0] : PCOLINACTIVE->m_vColors[0];
|
||||
color.a *= a;
|
||||
g_pHyprOpenGL->renderRect(&rect, color);
|
||||
CRectPassElement::SRectData rectdata;
|
||||
rectdata.color = color;
|
||||
rectdata.box = rect;
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CRectPassElement>(rectdata));
|
||||
|
||||
rect = {ASSIGNEDBOX.x + floor(xoff) - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
|
||||
ASSIGNEDBOX.y + ASSIGNEDBOX.h - floor(yoff) - ONEBARHEIGHT - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y, m_fBarWidth,
|
||||
|
|
@ -158,26 +162,33 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
|||
if (*PGRADIENTS) {
|
||||
const auto GRADIENTTEX = (m_dwGroupMembers[WINDOWINDEX] == g_pCompositor->m_pLastWindow ? (GROUPLOCKED ? m_tGradientLockedActive : m_tGradientActive) :
|
||||
(GROUPLOCKED ? m_tGradientLockedInactive : m_tGradientInactive));
|
||||
if (GRADIENTTEX->m_iTexID != 0)
|
||||
g_pHyprOpenGL->renderTexture(GRADIENTTEX, &rect, 1.0);
|
||||
if (GRADIENTTEX->m_iTexID) {
|
||||
CTexPassElement::SRenderData data;
|
||||
data.tex = GRADIENTTEX;
|
||||
data.box = rect;
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(data));
|
||||
}
|
||||
}
|
||||
|
||||
if (*PRENDERTITLES) {
|
||||
CTitleTex* pTitleTex = textureFromTitle(m_dwGroupMembers[WINDOWINDEX]->m_szTitle);
|
||||
|
||||
if (!pTitleTex)
|
||||
pTitleTex =
|
||||
m_sTitleTexs.titleTexs
|
||||
.emplace_back(std::make_unique<CTitleTex>(m_dwGroupMembers[WINDOWINDEX].lock(),
|
||||
Vector2D{m_fBarWidth * pMonitor->scale, (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale}, pMonitor->scale))
|
||||
.get();
|
||||
pTitleTex = m_sTitleTexs.titleTexs
|
||||
.emplace_back(std::make_unique<CTitleTex>(m_dwGroupMembers[WINDOWINDEX].lock(),
|
||||
Vector2D{m_fBarWidth * pMonitor->scale, (*PTITLEFONTSIZE + 2L * BAR_TEXT_PAD) * pMonitor->scale},
|
||||
pMonitor->scale))
|
||||
.get();
|
||||
rect.y += (rect.height - pTitleTex->textHeight) / 2.0;
|
||||
rect.height = pTitleTex->textHeight;
|
||||
rect.width = pTitleTex->textWidth;
|
||||
rect.x += (m_fBarWidth * pMonitor->scale) / 2.0 - (pTitleTex->textWidth / 2.0);
|
||||
rect.round();
|
||||
|
||||
g_pHyprOpenGL->renderTexture(pTitleTex->tex, &rect, 1.f);
|
||||
CTexPassElement::SRenderData data;
|
||||
data.tex = pTitleTex->tex;
|
||||
data.box = rect;
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(data));
|
||||
}
|
||||
|
||||
if (*PSTACKED)
|
||||
|
|
@ -203,10 +214,8 @@ void CHyprGroupBarDecoration::invalidateTextures() {
|
|||
m_sTitleTexs.titleTexs.clear();
|
||||
}
|
||||
|
||||
CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float monitorScale) {
|
||||
CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float monitorScale) : szContent(pWindow->m_szTitle), pWindowOwner(pWindow) {
|
||||
tex = makeShared<CTexture>();
|
||||
szContent = pWindow->m_szTitle;
|
||||
pWindowOwner = pWindow;
|
||||
const auto LAYOUTSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0);
|
||||
const auto LAYOUTCAIRO = cairo_create(LAYOUTSURFACE);
|
||||
|
||||
|
|
@ -281,9 +290,7 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float
|
|||
cairo_surface_destroy(CAIROSURFACE);
|
||||
}
|
||||
|
||||
CTitleTex::~CTitleTex() {
|
||||
tex->destroyTexture();
|
||||
}
|
||||
CTitleTex::~CTitleTex() = default;
|
||||
|
||||
void renderGradientTo(SP<CTexture> tex, CGradientValueData* grad) {
|
||||
|
||||
|
|
@ -435,7 +442,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND
|
|||
} while (curr != members[0]);
|
||||
|
||||
// removes all windows
|
||||
for (PHLWINDOW w : members) {
|
||||
for (const PHLWINDOW& w : members) {
|
||||
w->m_sGroupData.pNextWindow.reset();
|
||||
w->m_sGroupData.head = false;
|
||||
w->m_sGroupData.locked = false;
|
||||
|
|
@ -521,7 +528,7 @@ bool CHyprGroupBarDecoration::onMouseButtonOnDeco(const Vector2D& pos, const IPo
|
|||
g_pCompositor->focusWindow(pWindow);
|
||||
|
||||
if (pWindow->m_bIsFloating)
|
||||
g_pCompositor->changeWindowZOrder(pWindow, 1);
|
||||
g_pCompositor->changeWindowZOrder(pWindow, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue