protocols: refactor class member vars (core) (#10259)
This commit is contained in:
parent
0c736217a7
commit
d9cad5e1b6
57 changed files with 1160 additions and 1158 deletions
|
|
@ -1568,7 +1568,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, const CB
|
|||
}
|
||||
|
||||
const auto imageDescription =
|
||||
m_RenderData.surface.valid() && m_RenderData.surface->colorManagement.valid() ? m_RenderData.surface->colorManagement->imageDescription() : SImageDescription{};
|
||||
m_RenderData.surface.valid() && m_RenderData.surface->m_colorManagement.valid() ? m_RenderData.surface->m_colorManagement->imageDescription() : SImageDescription{};
|
||||
|
||||
const bool skipCM = !*PENABLECM || !m_bCMSupported /* CM unsupported or disabled */
|
||||
|| (imageDescription == m_RenderData.pMonitor->m_imageDescription) /* Source and target have the same image description */
|
||||
|
|
@ -2088,9 +2088,9 @@ void CHyprOpenGLImpl::preRender(PHLMONITOR pMonitor) {
|
|||
|
||||
CRegion inverseOpaque;
|
||||
|
||||
pixman_box32_t surfbox = {0, 0, PSURFACE->current.size.x, PSURFACE->current.size.y};
|
||||
CRegion opaqueRegion{PSURFACE->current.opaque};
|
||||
inverseOpaque.set(opaqueRegion).invert(&surfbox).intersect(0, 0, PSURFACE->current.size.x, PSURFACE->current.size.y);
|
||||
pixman_box32_t surfbox = {0, 0, PSURFACE->m_current.size.x, PSURFACE->m_current.size.y};
|
||||
CRegion opaqueRegion{PSURFACE->m_current.opaque};
|
||||
inverseOpaque.set(opaqueRegion).invert(&surfbox).intersect(0, 0, PSURFACE->m_current.size.x, PSURFACE->m_current.size.y);
|
||||
|
||||
if (inverseOpaque.empty())
|
||||
return false;
|
||||
|
|
@ -2224,11 +2224,11 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP<CTexture> tex, const CBox& box, f
|
|||
|
||||
// amazing hack: the surface has an opaque region!
|
||||
CRegion inverseOpaque;
|
||||
if (a >= 1.f && std::round(pSurface->current.size.x * m_RenderData.pMonitor->m_scale) == box.w &&
|
||||
std::round(pSurface->current.size.y * m_RenderData.pMonitor->m_scale) == box.h) {
|
||||
pixman_box32_t surfbox = {0, 0, pSurface->current.size.x * pSurface->current.scale, pSurface->current.size.y * pSurface->current.scale};
|
||||
inverseOpaque = pSurface->current.opaque;
|
||||
inverseOpaque.invert(&surfbox).intersect(0, 0, pSurface->current.size.x * pSurface->current.scale, pSurface->current.size.y * pSurface->current.scale);
|
||||
if (a >= 1.f && std::round(pSurface->m_current.size.x * m_RenderData.pMonitor->m_scale) == box.w &&
|
||||
std::round(pSurface->m_current.size.y * m_RenderData.pMonitor->m_scale) == box.h) {
|
||||
pixman_box32_t surfbox = {0, 0, pSurface->m_current.size.x * pSurface->m_current.scale, pSurface->m_current.size.y * pSurface->m_current.scale};
|
||||
inverseOpaque = pSurface->m_current.opaque;
|
||||
inverseOpaque.invert(&surfbox).intersect(0, 0, pSurface->m_current.size.x * pSurface->m_current.scale, pSurface->m_current.size.y * pSurface->m_current.scale);
|
||||
|
||||
if (inverseOpaque.empty()) {
|
||||
renderTexture(tex, box, a, round, roundingPower, false, true);
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
|
|||
pWindow->m_wlSurface->resource()->breadthfirst(
|
||||
[this, &renderdata, &pWindow](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
|
||||
renderdata.localPos = offset;
|
||||
renderdata.texture = s->current.texture;
|
||||
renderdata.texture = s->m_current.texture;
|
||||
renderdata.surface = s;
|
||||
renderdata.mainSurface = s == pWindow->m_wlSurface->resource();
|
||||
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
|
||||
|
|
@ -657,7 +657,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
|
|||
popup->m_wlSurface->resource()->breadthfirst(
|
||||
[this, &renderdata](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
|
||||
renderdata.localPos = offset;
|
||||
renderdata.texture = s->current.texture;
|
||||
renderdata.texture = s->m_current.texture;
|
||||
renderdata.surface = s;
|
||||
renderdata.mainSurface = false;
|
||||
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
|
||||
|
|
@ -739,7 +739,7 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::s
|
|||
pLayer->m_surface->resource()->breadthfirst(
|
||||
[this, &renderdata, &pLayer](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
|
||||
renderdata.localPos = offset;
|
||||
renderdata.texture = s->current.texture;
|
||||
renderdata.texture = s->m_current.texture;
|
||||
renderdata.surface = s;
|
||||
renderdata.mainSurface = s == pLayer->m_surface->resource();
|
||||
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
|
||||
|
|
@ -760,7 +760,7 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::s
|
|||
|
||||
Vector2D pos = popup->coordsRelativeToParent();
|
||||
renderdata.localPos = pos;
|
||||
renderdata.texture = popup->m_wlSurface->resource()->current.texture;
|
||||
renderdata.texture = popup->m_wlSurface->resource()->m_current.texture;
|
||||
renderdata.surface = popup->m_wlSurface->resource();
|
||||
renderdata.mainSurface = false;
|
||||
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
|
||||
|
|
@ -779,8 +779,8 @@ void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, PHLMONITOR pMonitor, con
|
|||
|
||||
renderdata.surface = SURF;
|
||||
renderdata.decorate = false;
|
||||
renderdata.w = SURF->current.size.x;
|
||||
renderdata.h = SURF->current.size.y;
|
||||
renderdata.w = SURF->m_current.size.x;
|
||||
renderdata.h = SURF->m_current.size.y;
|
||||
|
||||
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
|
||||
static auto PBLURIMES = CConfigValue<Hyprlang::INT>("decoration:blur:input_methods");
|
||||
|
|
@ -795,7 +795,7 @@ void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, PHLMONITOR pMonitor, con
|
|||
SURF->breadthfirst(
|
||||
[this, &renderdata, &SURF](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
|
||||
renderdata.localPos = offset;
|
||||
renderdata.texture = s->current.texture;
|
||||
renderdata.texture = s->m_current.texture;
|
||||
renderdata.surface = s;
|
||||
renderdata.mainSurface = s == SURF;
|
||||
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
|
||||
|
|
@ -816,7 +816,7 @@ void CHyprRenderer::renderSessionLockSurface(WP<SSessionLockSurface> pSurface, P
|
|||
renderdata.surface->breadthfirst(
|
||||
[this, &renderdata, &pSurface](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
|
||||
renderdata.localPos = offset;
|
||||
renderdata.texture = s->current.texture;
|
||||
renderdata.texture = s->m_current.texture;
|
||||
renderdata.surface = s;
|
||||
renderdata.mainSurface = s == pSurface->surface->surface();
|
||||
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
|
||||
|
|
@ -1053,10 +1053,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
|
|||
Vector2D uvTL;
|
||||
Vector2D uvBR = Vector2D(1, 1);
|
||||
|
||||
if (pSurface->current.viewport.hasSource) {
|
||||
if (pSurface->m_current.viewport.hasSource) {
|
||||
// we stretch it to dest. if no dest, to 1,1
|
||||
Vector2D const& bufferSize = pSurface->current.bufferSize;
|
||||
auto const& bufferSource = pSurface->current.viewport.source;
|
||||
Vector2D const& bufferSize = pSurface->m_current.bufferSize;
|
||||
auto const& bufferSource = pSurface->m_current.viewport.source;
|
||||
|
||||
// calculate UV for the basic src_box. Assume dest == size. Scale to dest later
|
||||
uvTL = Vector2D(bufferSource.x / bufferSize.x, bufferSource.y / bufferSize.y);
|
||||
|
|
@ -1071,8 +1071,8 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
|
|||
if (projSize != Vector2D{} && fixMisalignedFSV1) {
|
||||
// instead of nearest_neighbor (we will repeat / skip)
|
||||
// just cut off / expand surface
|
||||
const Vector2D PIXELASUV = Vector2D{1, 1} / pSurface->current.bufferSize;
|
||||
const Vector2D MISALIGNMENT = pSurface->current.bufferSize - projSize;
|
||||
const Vector2D PIXELASUV = Vector2D{1, 1} / pSurface->m_current.bufferSize;
|
||||
const Vector2D MISALIGNMENT = pSurface->m_current.bufferSize - projSize;
|
||||
if (MISALIGNMENT != Vector2D{})
|
||||
uvBR -= MISALIGNMENT * PIXELASUV;
|
||||
}
|
||||
|
|
@ -1083,9 +1083,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
|
|||
// there is no way to fix this if that's the case
|
||||
if (*PEXPANDEDGES) {
|
||||
const auto MONITOR_WL_SCALE = std::ceil(pMonitor->m_scale);
|
||||
const bool SCALE_UNAWARE = MONITOR_WL_SCALE != pSurface->current.scale && !pSurface->current.viewport.hasDestination;
|
||||
const bool SCALE_UNAWARE = MONITOR_WL_SCALE != pSurface->m_current.scale && !pSurface->m_current.viewport.hasDestination;
|
||||
const auto EXPECTED_SIZE =
|
||||
((pSurface->current.viewport.hasDestination ? pSurface->current.viewport.destination : pSurface->current.bufferSize / pSurface->current.scale) * pMonitor->m_scale)
|
||||
((pSurface->m_current.viewport.hasDestination ? pSurface->m_current.viewport.destination : pSurface->m_current.bufferSize / pSurface->m_current.scale) *
|
||||
pMonitor->m_scale)
|
||||
.round();
|
||||
if (!SCALE_UNAWARE && (EXPECTED_SIZE.x < projSize.x || EXPECTED_SIZE.y < projSize.y)) {
|
||||
// this will not work with shm AFAIK, idk why.
|
||||
|
|
@ -1111,10 +1112,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
|
|||
|
||||
// ignore X and Y, adjust uv
|
||||
if (geom.x != 0 || geom.y != 0 || geom.width > projSizeUnscaled.x || geom.height > projSizeUnscaled.y) {
|
||||
const auto XPERC = (double)geom.x / (double)pSurface->current.size.x;
|
||||
const auto YPERC = (double)geom.y / (double)pSurface->current.size.y;
|
||||
const auto WPERC = (double)(geom.x + geom.width) / (double)pSurface->current.size.x;
|
||||
const auto HPERC = (double)(geom.y + geom.height) / (double)pSurface->current.size.y;
|
||||
const auto XPERC = (double)geom.x / (double)pSurface->m_current.size.x;
|
||||
const auto YPERC = (double)geom.y / (double)pSurface->m_current.size.y;
|
||||
const auto WPERC = (double)(geom.x + geom.width) / (double)pSurface->m_current.size.x;
|
||||
const auto HPERC = (double)(geom.y + geom.height) / (double)pSurface->m_current.size.y;
|
||||
|
||||
const auto TOADDTL = Vector2D(XPERC * (uvBR.x - uvTL.x), YPERC * (uvBR.y - uvTL.y));
|
||||
uvBR = uvBR - Vector2D((1.0 - WPERC) * (uvBR.x - uvTL.x), (1.0 - HPERC) * (uvBR.y - uvTL.y));
|
||||
|
|
@ -1501,18 +1502,18 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
|
|||
const auto WINDOW = pMonitor->m_activeWorkspace->getFullscreenWindow();
|
||||
const auto ROOT_SURF = WINDOW->m_wlSurface->resource();
|
||||
const auto SURF =
|
||||
ROOT_SURF->findFirstPreorder([ROOT_SURF](SP<CWLSurfaceResource> surf) { return surf->colorManagement.valid() && surf->extends() == ROOT_SURF->extends(); });
|
||||
ROOT_SURF->findFirstPreorder([ROOT_SURF](SP<CWLSurfaceResource> surf) { return surf->m_colorManagement.valid() && surf->extends() == ROOT_SURF->extends(); });
|
||||
|
||||
wantHDR = PHDR && *PPASS == 2;
|
||||
|
||||
// we have a surface with image description and it's allowed by wantHDR
|
||||
if (SURF && SURF->colorManagement.valid() && SURF->colorManagement->hasImageDescription() &&
|
||||
(!wantHDR || SURF->colorManagement->imageDescription().transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ)) {
|
||||
bool needsHdrMetadataUpdate = SURF->colorManagement->needsHdrMetadataUpdate() || pMonitor->m_previousFSWindow != WINDOW;
|
||||
if (SURF->colorManagement->needsHdrMetadataUpdate())
|
||||
SURF->colorManagement->setHDRMetadata(createHDRMetadata(SURF->colorManagement->imageDescription(), pMonitor->m_output->parsedEDID));
|
||||
if (SURF && SURF->m_colorManagement.valid() && SURF->m_colorManagement->hasImageDescription() &&
|
||||
(!wantHDR || SURF->m_colorManagement->imageDescription().transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ)) {
|
||||
bool needsHdrMetadataUpdate = SURF->m_colorManagement->needsHdrMetadataUpdate() || pMonitor->m_previousFSWindow != WINDOW;
|
||||
if (SURF->m_colorManagement->needsHdrMetadataUpdate())
|
||||
SURF->m_colorManagement->setHDRMetadata(createHDRMetadata(SURF->m_colorManagement->imageDescription(), pMonitor->m_output->parsedEDID));
|
||||
if (needsHdrMetadataUpdate)
|
||||
pMonitor->m_output->state->setHDRMetadata(SURF->colorManagement->hdrMetadata());
|
||||
pMonitor->m_output->state->setHDRMetadata(SURF->m_colorManagement->hdrMetadata());
|
||||
hdrIsHandled = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -244,13 +244,13 @@ void CRenderPass::renderDebugData() {
|
|||
renderHLSurface(debugData.lastWindowText, g_pCompositor->m_lastWindow->m_wlSurface->resource(), Colors::LIGHT_BLUE.modifyA(0.1F));
|
||||
|
||||
if (g_pSeatManager->m_state.pointerFocus) {
|
||||
if (g_pSeatManager->m_state.pointerFocus->current.input.intersect(CBox{{}, g_pSeatManager->m_state.pointerFocus->current.size}).getExtents().size() !=
|
||||
g_pSeatManager->m_state.pointerFocus->current.size) {
|
||||
if (g_pSeatManager->m_state.pointerFocus->m_current.input.intersect(CBox{{}, g_pSeatManager->m_state.pointerFocus->m_current.size}).getExtents().size() !=
|
||||
g_pSeatManager->m_state.pointerFocus->m_current.size) {
|
||||
auto hlSurface = CWLSurface::fromResource(g_pSeatManager->m_state.pointerFocus.lock());
|
||||
if (hlSurface) {
|
||||
auto BOX = hlSurface->getSurfaceBoxGlobal();
|
||||
if (BOX) {
|
||||
auto region = g_pSeatManager->m_state.pointerFocus->current.input.copy()
|
||||
auto region = g_pSeatManager->m_state.pointerFocus->m_current.input.copy()
|
||||
.scale(g_pHyprOpenGL->m_RenderData.pMonitor->m_scale)
|
||||
.translate(BOX->pos() - g_pHyprOpenGL->m_RenderData.pMonitor->m_position);
|
||||
g_pHyprOpenGL->renderRectWithDamage(box, CHyprColor{0.8F, 0.8F, 0.2F, 0.4F}, region);
|
||||
|
|
|
|||
|
|
@ -72,12 +72,12 @@ void CSurfacePassElement::draw(const CRegion& damage) {
|
|||
return;
|
||||
}
|
||||
|
||||
const bool MISALIGNEDFSV1 = std::floor(data.pMonitor->m_scale) != data.pMonitor->m_scale /* Fractional */ && data.surface->current.scale == 1 /* fs protocol */ &&
|
||||
windowBox.size() != data.surface->current.bufferSize /* misaligned */ && DELTALESSTHAN(windowBox.width, data.surface->current.bufferSize.x, 3) &&
|
||||
DELTALESSTHAN(windowBox.height, data.surface->current.bufferSize.y, 3) /* off by one-or-two */ &&
|
||||
const bool MISALIGNEDFSV1 = std::floor(data.pMonitor->m_scale) != data.pMonitor->m_scale /* Fractional */ && data.surface->m_current.scale == 1 /* fs protocol */ &&
|
||||
windowBox.size() != data.surface->m_current.bufferSize /* misaligned */ && DELTALESSTHAN(windowBox.width, data.surface->m_current.bufferSize.x, 3) &&
|
||||
DELTALESSTHAN(windowBox.height, data.surface->m_current.bufferSize.y, 3) /* off by one-or-two */ &&
|
||||
(!data.pWindow || (!data.pWindow->m_realSize->isBeingAnimated() && !INTERACTIVERESIZEINPROGRESS)) /* not window or not animated/resizing */;
|
||||
|
||||
if (data.surface->colorManagement.valid())
|
||||
if (data.surface->m_colorManagement.valid())
|
||||
Debug::log(TRACE, "FIXME: rendering surface with color management enabled, should apply necessary transformations");
|
||||
g_pHyprRenderer->calculateUVForSurface(data.pWindow, data.surface, data.pMonitor->m_self.lock(), data.mainSurface, windowBox.size(), PROJSIZEUNSCALED, MISALIGNEDFSV1);
|
||||
|
||||
|
|
@ -131,8 +131,8 @@ void CSurfacePassElement::draw(const CRegion& damage) {
|
|||
|
||||
// add async (dmabuf) buffers to usedBuffers so we can handle release later
|
||||
// sync (shm) buffers will be released in commitState, so no need to track them here
|
||||
if (data.surface->current.buffer && !data.surface->current.buffer->isSynchronous())
|
||||
g_pHyprRenderer->usedAsyncBuffers.emplace_back(data.surface->current.buffer);
|
||||
if (data.surface->m_current.buffer && !data.surface->m_current.buffer->isSynchronous())
|
||||
g_pHyprRenderer->usedAsyncBuffers.emplace_back(data.surface->m_current.buffer);
|
||||
|
||||
g_pHyprOpenGL->blend(true);
|
||||
}
|
||||
|
|
@ -167,8 +167,8 @@ CBox CSurfacePassElement::getTexBox() {
|
|||
}
|
||||
|
||||
} else { // here we clamp to 2, these might be some tiny specks
|
||||
windowBox = {(int)outputX + data.pos.x + data.localPos.x, (int)outputY + data.pos.y + data.localPos.y, std::max((float)data.surface->current.size.x, 2.F),
|
||||
std::max((float)data.surface->current.size.y, 2.F)};
|
||||
windowBox = {(int)outputX + data.pos.x + data.localPos.x, (int)outputY + data.pos.y + data.localPos.y, std::max((float)data.surface->m_current.size.x, 2.F),
|
||||
std::max((float)data.surface->m_current.size.y, 2.F)};
|
||||
if (data.pWindow && data.pWindow->m_realSize->isBeingAnimated() && data.surface && !data.mainSurface && data.squishOversized /* subsurface */) {
|
||||
// adjust subsurfaces to the window
|
||||
windowBox.width = (windowBox.width / data.pWindow->m_reportedSize.x) * data.pWindow->m_realSize->value().x;
|
||||
|
|
@ -226,8 +226,8 @@ CRegion CSurfacePassElement::opaqueRegion() {
|
|||
if (ALPHA < 1.F)
|
||||
return {};
|
||||
|
||||
if (data.surface && data.surface->current.size == Vector2D{data.w, data.h}) {
|
||||
CRegion opaqueSurf = data.surface->current.opaque.copy().intersect(CBox{{}, {data.w, data.h}});
|
||||
if (data.surface && data.surface->m_current.size == Vector2D{data.w, data.h}) {
|
||||
CRegion opaqueSurf = data.surface->m_current.opaque.copy().intersect(CBox{{}, {data.w, data.h}});
|
||||
const auto texBox = getTexBox();
|
||||
opaqueSurf.scale(texBox.size() / Vector2D{data.w, data.h});
|
||||
return opaqueSurf.translate(data.pos + data.localPos - data.pMonitor->m_position).expand(-data.rounding);
|
||||
|
|
@ -241,7 +241,7 @@ CRegion CSurfacePassElement::visibleRegion(bool& cancel) {
|
|||
if (!PSURFACE)
|
||||
return {};
|
||||
|
||||
const auto& bufferSize = data.surface->current.bufferSize;
|
||||
const auto& bufferSize = data.surface->m_current.bufferSize;
|
||||
|
||||
auto visibleRegion = PSURFACE->m_visibleRegion.copy();
|
||||
if (visibleRegion.empty())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue