mirror of
https://github.com/virtcode/hypr-dynamic-cursors
synced 2025-09-19 16:13:21 +02:00
parent
4d1d88522b
commit
fd62146299
1 changed files with 3 additions and 52 deletions
|
@ -245,59 +245,10 @@ SP<Aquamarine::IBuffer> CDynamicCursors::renderHardware(CPointerManager* pointer
|
|||
g_pHyprOpenGL->m_RenderData.pMonitor = state->monitor;
|
||||
|
||||
auto RBO = g_pHyprRenderer->getOrCreateRenderbuffer(buf, state->monitor->cursorSwapchain->currentOptions().format);
|
||||
if (!RBO) {
|
||||
|
||||
// dumb copy won't work with this plugin, as we just copy the buffer, and can't apply transformations to it
|
||||
Debug::log(TRACE, "Failed to create cursor RB with format {}, mod {}", buf->dmabuf().format, buf->dmabuf().modifier);
|
||||
static auto PDUMB = CConfigValue<Hyprlang::INT>("cursor:allow_dumb_copy");
|
||||
if (!*PDUMB)
|
||||
return nullptr;
|
||||
|
||||
auto bufData = buf->beginDataPtr(0);
|
||||
auto bufPtr = std::get<0>(bufData);
|
||||
|
||||
// clear buffer
|
||||
memset(bufPtr, 0, std::get<2>(bufData));
|
||||
|
||||
if (pointers->currentCursorImage.pBuffer) {
|
||||
auto texAttrs = pointers->currentCursorImage.pBuffer->shm();
|
||||
|
||||
if (!texAttrs.success) {
|
||||
Debug::log(TRACE, "Cannot use dumb copy on dmabuf cursor buffers");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto texData = pointers->currentCursorImage.pBuffer->beginDataPtr(GBM_BO_TRANSFER_WRITE);
|
||||
auto texPtr = std::get<0>(texData);
|
||||
Debug::log(TRACE, "cursor texture {}x{} {} {} {}", texAttrs.size.x, texAttrs.size.y, (void*)texPtr, texAttrs.format, texAttrs.stride);
|
||||
// copy cursor texture
|
||||
for (int i = 0; i < texAttrs.size.y; i++)
|
||||
memcpy(bufPtr + i * buf->dmabuf().strides[0], texPtr + i * texAttrs.stride, texAttrs.stride);
|
||||
} else if (pointers->currentCursorImage.surface && pointers->currentCursorImage.surface->resource()->role->role() == SURFACE_ROLE_CURSOR) {
|
||||
const auto SURFACE = pointers->currentCursorImage.surface->resource();
|
||||
auto& shmBuffer = CCursorSurfaceRole::cursorPixelData(SURFACE);
|
||||
Debug::log(TRACE, "cursor texture pixel data length: {}B", shmBuffer.size());
|
||||
|
||||
if (shmBuffer.data()) {
|
||||
// copy cursor texture
|
||||
// assume format is 32bpp
|
||||
size_t STRIDE = 4 * SURFACE->current.bufferSize.x;
|
||||
for (int i = 0; i < SURFACE->current.bufferSize.y; i++)
|
||||
memcpy(bufPtr + i * buf->dmabuf().strides[0], shmBuffer.data() + i * STRIDE, STRIDE);
|
||||
} else {
|
||||
// if there is no data, hide the cursor
|
||||
memset(bufPtr, '\0', buf->size.x * buf->size.y * 4 /* assume 32bpp */);
|
||||
}
|
||||
|
||||
} else {
|
||||
Debug::log(TRACE, "Unsupported cursor buffer/surface, falling back to sw (can't dumb copy)");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
buf->endDataPtr();
|
||||
|
||||
return buf;
|
||||
}
|
||||
// we just fail if we cannot create a render buffer, this will force hl to render sofware cursors, which we support
|
||||
if (!RBO)
|
||||
return nullptr;
|
||||
|
||||
RBO->bind();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue