Skip to content

Commit

Permalink
transform fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Nov 4, 2024
1 parent 89b9352 commit f1b300d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/helpers/LayerSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ CLayerSurface::CLayerSurface(SMonitor* pMonitor) {
pFractionalScale = makeShared<CCWpFractionalScaleV1>(g_pHyprpicker->m_pFractionalMgr->sendGetFractionalScale(pSurface->resource()));
pFractionalScale->setPreferredScale([this](CCWpFractionalScaleV1* r, uint32_t scale120) { //
Debug::log(TRACE, "Received a preferredScale for %s: %.2f", m_pMonitor->name.c_str(), scale120 / 120.F);
fractionalScale = scale120 / 120.F;
wantsReload = true;
g_pHyprpicker->recheckACK();
});
}

Expand Down
8 changes: 5 additions & 3 deletions src/helpers/LayerSurface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ class CLayerSurface {
SP<CCWpViewport> pViewport = nullptr;
SP<CCWpFractionalScaleV1> pFractionalScale = nullptr;

bool wantsACK = false;
uint32_t ACKSerial = 0;
bool working = false;
float fractionalScale = 1.F;
bool wantsACK = false;
bool wantsReload = false;
uint32_t ACKSerial = 0;
bool working = false;

int lastBuffer = 0;
SP<SPoolBuffer> buffers[2];
Expand Down
4 changes: 3 additions & 1 deletion src/helpers/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void SMonitor::initSCFrame() {
if (pLS->m_pMonitor->transform % 2 == 1)
std::swap(transformedSize.x, transformedSize.y);

Debug::log(TRACE, "Frame ready: pixel %.0fx%.0f, xfmd: %.0fx%.0f", pLS->screenBuffer->pixelSize.x, pLS->screenBuffer->pixelSize.y, transformedSize.x, transformedSize.y);

SP<SPoolBuffer> newBuf = makeShared<SPoolBuffer>(transformedSize, pLS->screenBufferFormat, transformedSize.x * 4);

int bytesPerPixel = pLS->screenBuffer->stride / (int)pLS->screenBuffer->pixelSize.x;
Expand Down Expand Up @@ -112,7 +114,7 @@ void SMonitor::initSCFrame() {

pSCFrame.reset();
});
pSCFrame->setFailed([this](CCZwlrScreencopyFrameV1* r) {
pSCFrame->setFailed([](CCZwlrScreencopyFrameV1* r) {
Debug::log(CRIT, "Failed to get a Screencopy!");
g_pHyprpicker->finish(1);
});
Expand Down
14 changes: 10 additions & 4 deletions src/hyprpicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,17 @@ void CHyprpicker::finish(int code) {

void CHyprpicker::recheckACK() {
for (auto& ls : m_vLayerSurfaces) {
if (ls->wantsACK) {
ls->wantsACK = false;
ls->pLayerSurface->sendAckConfigure(ls->ACKSerial);
if ((ls->wantsACK || ls->wantsReload) && ls->screenBuffer) {
if (ls->wantsACK)
ls->pLayerSurface->sendAckConfigure(ls->ACKSerial);
ls->wantsACK = false;
ls->wantsReload = false;

const auto MONITORSIZE = ls->screenBuffer && !g_pHyprpicker->m_bNoFractional ? ls->screenBuffer->pixelSize : ls->m_pMonitor->size * ls->m_pMonitor->scale;
const auto MONITORSIZE =
(ls->screenBuffer && !g_pHyprpicker->m_bNoFractional ? ls->m_pMonitor->size * ls->fractionalScale : ls->m_pMonitor->size * ls->m_pMonitor->scale).round();

if (!ls->buffers[0] || ls->buffers[0]->pixelSize != MONITORSIZE) {
Debug::log(TRACE, "making new buffers: size changed to %.0fx%.0f", MONITORSIZE.x, MONITORSIZE.y);
ls->buffers[0] = makeShared<SPoolBuffer>(MONITORSIZE, WL_SHM_FORMAT_ARGB8888, MONITORSIZE.x * 4);
ls->buffers[1] = makeShared<SPoolBuffer>(MONITORSIZE, WL_SHM_FORMAT_ARGB8888, MONITORSIZE.x * 4);
}
Expand Down Expand Up @@ -360,6 +364,8 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) {
const auto MOUSECOORDSABS = m_vLastCoords.floor() / pSurface->m_pMonitor->size;
const auto CLICKPOS = MOUSECOORDSABS * PBUFFER->pixelSize;

Debug::log(TRACE, "renderSurface: scalebufs %.2fx%.2f", SCALEBUFS.x, SCALEBUFS.y);

const auto PATTERNPRE = cairo_pattern_create_for_surface(pSurface->screenBuffer->surface);
cairo_pattern_set_filter(PATTERNPRE, CAIRO_FILTER_BILINEAR);
cairo_matrix_t matrixPre;
Expand Down

0 comments on commit f1b300d

Please sign in to comment.