diff options
| author | Vaxry <vaxry@vaxry.net> | 2023-12-01 17:20:56 +0000 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2023-12-01 17:20:56 +0000 |
| commit | 9c09f2a847a1372c73cf67dc9e7e9ebe309b142e (patch) | |
| tree | 5f8b5ed8b1bd9c1cf23155ffbfded231983cd21e /src/protocols/Screencopy.cpp | |
| parent | 8440a30231ea41a6b1dacc60a28837b265a6efec (diff) | |
screencopy: fix shm exports with 10-bit
fixes #4019
Diffstat (limited to 'src/protocols/Screencopy.cpp')
| -rw-r--r-- | src/protocols/Screencopy.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index 7240fd37..6c7178c0 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -210,7 +210,7 @@ void CScreencopyProtocolManager::captureOutput(wl_client* client, wl_resource* r PFRAME->client = PCLIENT; PCLIENT->ref++; - PFRAME->shmFormat = g_pHyprRenderer->isNvidia() ? DRM_FORMAT_XRGB8888 : PFRAME->pMonitor->drmFormat; + PFRAME->shmFormat = g_pHyprOpenGL->getPreferredReadFormat(PFRAME->pMonitor); if (PFRAME->shmFormat == DRM_FORMAT_INVALID) { Debug::log(ERR, "No format supported by renderer in capture output"); zwlr_screencopy_frame_v1_send_failed(PFRAME->resource); @@ -441,7 +441,7 @@ bool CScreencopyProtocolManager::copyFrameShm(SScreencopyFrame* frame, timespec* g_pHyprRenderer->makeEGLCurrent(); CFramebuffer fb; - fb.alloc(frame->box.w, frame->box.h); // 8bit only + fb.alloc(frame->box.w, frame->box.h, frame->pMonitor->drmFormat); if (!g_pHyprRenderer->beginRender(frame->pMonitor, fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, &fb)) { wlr_texture_destroy(sourceTex); @@ -456,13 +456,8 @@ bool CScreencopyProtocolManager::copyFrameShm(SScreencopyFrame* frame, timespec* glBindFramebuffer(GL_READ_FRAMEBUFFER, fb.m_iFb); - const auto PFORMAT = gles2FromDRM(format); - if (!PFORMAT) { - Debug::log(ERR, "[sc] Cannot read pixels, unsupported format {:x}", (uintptr_t)PFORMAT); - wlr_texture_destroy(sourceTex); - wlr_buffer_end_data_ptr_access(frame->buffer); - return false; - } + const auto GLFORMAT = drmFormatToGL(frame->pMonitor->drmFormat); + const auto GLTYPE = glFormatToType(GLFORMAT); g_pHyprRenderer->endRender(); @@ -470,7 +465,7 @@ bool CScreencopyProtocolManager::copyFrameShm(SScreencopyFrame* frame, timespec* g_pHyprOpenGL->m_RenderData.pMonitor = frame->pMonitor; fb.bind(); - glReadPixels(0, 0, frame->box.w, frame->box.h, PFORMAT->gl_format, PFORMAT->gl_type, data); + glReadPixels(0, 0, frame->box.w, frame->box.h, GL_RGBA, GLTYPE, data); g_pHyprOpenGL->m_RenderData.pMonitor = nullptr; |
