From 022e10f49876f8d71304f17d6137ae266e6ba986 Mon Sep 17 00:00:00 2001 From: Virt <41426325+VirtCode@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:54:55 +0200 Subject: [PATCH] test: spamming too many logs --- src/cursor.cpp | 35 +++++++++++++++++++++++++++-------- src/renderer.cpp | 1 + 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/cursor.cpp b/src/cursor.cpp index 8d89895..893a50a 100644 --- a/src/cursor.cpp +++ b/src/cursor.cpp @@ -58,6 +58,7 @@ Is also largely identical to hyprlands impl, but uses our custom rendering to ro */ void CDynamicCursors::renderSoftware(CPointerManager* pointers, SP pMonitor, timespec* now, CRegion& damage, std::optional overridePos) { static auto* const* PNEAREST = (Hyprlang::INT* const*) getConfig(CONFIG_SHAKE_NEAREST); + Debug::log(LOG, "[dynamic-cursors] rendering sw cursors with: rotation = {}, scale = {}, stretch.angle = {}, stretch.x = {}, stretch.y = {}", resultShown.rotation, resultShown.scale, resultShown.stretch.angle, resultShown.stretch.magnitude.x, resultShown.stretch.magnitude.y); if (!pointers->hasCursor()) return; @@ -69,6 +70,8 @@ void CDynamicCursors::renderSoftware(CPointerManager* pointers, SP pMo if (pointers->currentCursorImage.surface) pointers->currentCursorImage.surface->resource()->frame(now); + Debug::log(LOG, "[dynamic-cursors] rendering sw cursors: hw cursors are active, not continuing"); + return; } @@ -78,6 +81,8 @@ void CDynamicCursors::renderSoftware(CPointerManager* pointers, SP pMo box.y = overridePos->y; } + Debug::log(LOG, "[dynamic-cursors] rendering sw cursors at: x = {}, y = {}", box.x, box.y); + // poperly transform hotspot, this first has to undo the hotspot transform from getCursorBoxGlobal box.x = box.x + pointers->currentCursorImage.hotspot.x - pointers->currentCursorImage.hotspot.x * zoom; box.y = box.y + pointers->currentCursorImage.hotspot.y - pointers->currentCursorImage.hotspot.y * zoom; @@ -138,6 +143,8 @@ wlr_buffer* CDynamicCursors::renderHardware(CPointerManager* pointers, SPmonitor->output; auto zoom = resultShown.scale; @@ -153,7 +160,7 @@ wlr_buffer* CDynamicCursors::renderHardware(CPointerManager* pointers, SPimpl->get_cursor_size(output, &w, &h); if (w < target.x || h < target.y) { - Debug::log(TRACE, "hardware cursor too big! {} > {}x{}", pointers->currentCursorImage.size, w, h); + Debug::log(LOG, "[dynamic-cursors] hardware cursor too big! {} > {}x{}", pointers->currentCursorImage.size, w, h); return nullptr; } @@ -162,14 +169,14 @@ wlr_buffer* CDynamicCursors::renderHardware(CPointerManager* pointers, SPmonitor->szName, target.x, target.y); + Debug::log(LOG, "[dynamic-cursors] hw cursor for output {} failed the size checks ({}x{} is invalid)", state->monitor->szName, target.x, target.y); return nullptr; } if (!output->cursor_swapchain || target != Vector2D{output->cursor_swapchain->width, output->cursor_swapchain->height}) { wlr_drm_format fmt = {0}; if (!output_pick_cursor_format(output, &fmt)) { - Debug::log(TRACE, "Failed to pick cursor format"); + Debug::log(LOG, "[dynamic-cursors] Failed to pick cursor format"); return nullptr; } @@ -178,14 +185,14 @@ wlr_buffer* CDynamicCursors::renderHardware(CPointerManager* pointers, SPcursor_swapchain) { - Debug::log(TRACE, "Failed to create cursor swapchain"); + Debug::log(LOG, "[dynamic-cursors] Failed to create cursor swapchain"); return nullptr; } } wlr_buffer* buf = wlr_swapchain_acquire(output->cursor_swapchain, nullptr); if (!buf) { - Debug::log(TRACE, "Failed to acquire a buffer from the cursor swapchain"); + Debug::log(LOG, "[dynamic-cursors] Failed to acquire a buffer from the cursor swapchain"); return nullptr; } @@ -225,6 +232,7 @@ Implements the hardware cursor setting. It is also mostly the same as stock hyprland, but with the hotspot translated more into the middle. */ bool CDynamicCursors::setHardware(CPointerManager* pointers, SP state, wlr_buffer* buf) { + Debug::log(LOG, "[dynamic-cursors] attempt at setting hw cursors"); if (!state->monitor->output->impl->set_cursor) return false; @@ -239,6 +247,8 @@ bool CDynamicCursors::setHardware(CPointerManager* pointers, SPtransform)), P_MONITOR->output->cursor_swapchain->width, P_MONITOR->output->cursor_swapchain->height) .pos(); + Debug::log(LOG, "[dynamic-cursors] setting hw cursors: hotspot.x = {}, hotspot.y = {}", HOTSPOT.x, HOTSPOT.y); + Debug::log(TRACE, "[pointer] hw transformed hotspot for {}: {}", state->monitor->szName, HOTSPOT); if (!state->monitor->output->impl->set_cursor(state->monitor->output, buf, HOTSPOT.x, HOTSPOT.y)) @@ -259,6 +269,8 @@ bool CDynamicCursors::setHardware(CPointerManager* pointers, SPhasCursor()) return; @@ -271,6 +283,7 @@ void CDynamicCursors::onCursorMoved(CPointerManager* pointers) { continue; const auto CURSORPOS = pointers->getCursorPosForMonitor(m); + Debug::log(LOG, "[dynamic-cursors] moving hw cursors to : x = {}, y = {}", CURSORPOS.x, CURSORPOS.y); m->output->impl->move_cursor(m->output, CURSORPOS.x, CURSORPOS.y); } @@ -307,6 +320,8 @@ void CDynamicCursors::calculate(EModeUpdate type) { static auto* const* PSHAKE = (Hyprlang::INT* const*) getConfig(CONFIG_SHAKE); static auto* const* PSHAKE_EFFECTS = (Hyprlang::INT* const*) getConfig(CONFIG_SHAKE_EFFECTS); + Debug::log(LOG, "[dynamic-cursors] calculate before: type = {} ########################################################", (int) type); + IMode* mode = currentMode(); // calculate angle and zoom @@ -321,16 +336,18 @@ void CDynamicCursors::calculate(EModeUpdate type) { if (resultShake > 1 && !**PSHAKE_EFFECTS) resultMode = SModeResult(); } else resultShake = 1; - // skip move updates - if (type == MOVE) return; - auto result = resultMode; result.scale *= resultShake; + Debug::log(LOG, "[dynamic-cursors] calculate after: rotation = {}, scale = {}, stretch.angle = {}, stretch.x = {}, stretch.y = {}", result.rotation, result.scale, result.stretch.angle, result.stretch.magnitude.x, result.stretch.magnitude.y); + if (resultShown.hasDifference(&result, **PTHRESHOLD * (PI / 180.0), 0.01, 0.01)) { + Debug::log(LOG, "[dynamic-cursors] calculate has difference!"); resultShown = result; resultShown.clamp(**PTHRESHOLD * (PI / 180.0), 0.01, 0.01); // clamp low values so it is rendered pixel-perfectly when no effect + Debug::log(LOG, "[dynamic-cursors] calculate clamped: rotation = {}, scale = {}, stretch.angle = {}, stretch.x = {}, stretch.y = {}", resultShown.rotation, resultShown.scale, resultShown.stretch.angle, resultShown.stretch.magnitude.x, resultShown.stretch.magnitude.y); + // lock software cursors if zooming if (resultShown.scale > 1) { if (!zoomSoftware) { @@ -355,6 +372,8 @@ void CDynamicCursors::calculate(EModeUpdate type) { for (auto& m : g_pCompositor->m_vMonitors) { auto state = g_pPointerManager->stateFor(m); + Debug::log(LOG, "[dynamic-cursors] calculate output ({}): entered = {}, failed = {}", m.get()->szName, state->entered, state->hardwareFailed); + if (state->entered) entered = true; if (state->hardwareFailed || !state->entered) continue; diff --git a/src/renderer.cpp b/src/renderer.cpp index 2663376..198c0b6 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -59,6 +59,7 @@ void projectCursorBox(float mat[9], CBox& box, eTransform transform, float rotat This renders a texture with damage but rotates the texture around a given hotspot. */ void renderCursorTextureInternalWithDamage(SP tex, CBox* pBox, CRegion* damage, float alpha, Vector2D hotspot, bool nearest, float stretchAngle, Vector2D stretch) { + Debug::log(LOG, "[dynamic-cursors] rendering: pBox.x = {}, pBox.y = {}, pBox.w = {}, pBox.h = {}, bBox.rotation = {}, stretchAngle = {}, stretch.x = {}, stretch.y = {}", pBox->x, pBox->y, pBox->w, pBox->h, pBox->rot, stretchAngle, stretch.x, stretch.y); TRACY_GPU_ZONE("RenderDynamicCursor"); alpha = std::clamp(alpha, 0.f, 1.f);