summaryrefslogtreecommitdiff
path: root/src/protocols
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2023-12-04 03:52:54 +0000
committerVaxry <vaxry@vaxry.net>2023-12-04 03:52:54 +0000
commit68783d904d850df65887adb1bab7eff59943c1ac (patch)
tree8c79712bf5213c1236b3a20f5874854459303f08 /src/protocols
parent5d100bdcbbd87bac74935eae6b7d7aed25620323 (diff)
screencopy: use buffer format for glReadPixels
fixes #4029
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/Screencopy.cpp19
-rw-r--r--src/protocols/ToplevelExport.cpp13
2 files changed, 15 insertions, 17 deletions
diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp
index 65f50893..e5aaab62 100644
--- a/src/protocols/Screencopy.cpp
+++ b/src/protocols/Screencopy.cpp
@@ -457,12 +457,12 @@ bool CScreencopyProtocolManager::copyFrameShm(SScreencopyFrame* frame, timespec*
glBindFramebuffer(GL_READ_FRAMEBUFFER, fb.m_iFb);
- GLint glf, glt;
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &glf);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &glt);
- if (glf == 0 || glt == 0) {
- glf = drmFormatToGL(frame->pMonitor->drmFormat);
- glt = glFormatToType(glf);
+ const auto PFORMAT = g_pHyprOpenGL->getPixelFormatFromDRM(format);
+ if (!PFORMAT) {
+ g_pHyprRenderer->endRender();
+ wlr_texture_destroy(sourceTex);
+ wlr_buffer_end_data_ptr_access(frame->buffer);
+ return false;
}
g_pHyprRenderer->endRender();
@@ -473,16 +473,15 @@ bool CScreencopyProtocolManager::copyFrameShm(SScreencopyFrame* frame, timespec*
glPixelStorei(GL_PACK_ALIGNMENT, 1);
- const auto FMT = g_pHyprOpenGL->getPreferredReadFormat(frame->pMonitor);
- const wlr_pixel_format_info* drmFmtWlr = drm_get_pixel_format_info(FMT);
+ const wlr_pixel_format_info* drmFmtWlr = drm_get_pixel_format_info(format);
uint32_t packStride = pixel_format_info_min_stride(drmFmtWlr, frame->box.w);
if (packStride == stride) {
- glReadPixels(frame->box.x, frame->box.y, frame->box.w, frame->box.h, glf, glt, data);
+ glReadPixels(frame->box.x, frame->box.y, frame->box.w, frame->box.h, PFORMAT->glFormat, PFORMAT->glType, data);
} else {
for (size_t i = 0; i < frame->box.h; ++i) {
uint32_t y = frame->box.x + i;
- glReadPixels(frame->box.x, y, frame->box.w, 1, glf, glt, ((unsigned char*)data) + i * stride);
+ glReadPixels(frame->box.x, y, frame->box.w, 1, PFORMAT->glFormat, PFORMAT->glType, ((unsigned char*)data) + i * stride);
}
}
diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp
index 6a001c02..dabad2ab 100644
--- a/src/protocols/ToplevelExport.cpp
+++ b/src/protocols/ToplevelExport.cpp
@@ -387,19 +387,18 @@ bool CToplevelExportProtocolManager::copyFrameShm(SScreencopyFrame* frame, times
if (frame->overlayCursor)
g_pHyprRenderer->renderSoftwareCursors(PMONITOR, fakeDamage, g_pInputManager->getMouseCoordsInternal() - frame->pWindow->m_vRealPosition.vec());
- GLint glf, glt;
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &glf);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &glt);
- if (glf == 0 || glt == 0) {
- glf = drmFormatToGL(frame->pMonitor->drmFormat);
- glt = glFormatToType(glf);
+ const auto PFORMAT = g_pHyprOpenGL->getPixelFormatFromDRM(format);
+ if (!PFORMAT) {
+ g_pHyprRenderer->endRender();
+ wlr_buffer_end_data_ptr_access(frame->buffer);
+ return false;
}
g_pHyprOpenGL->m_RenderData.mainFB->bind();
glPixelStorei(GL_PACK_ALIGNMENT, 1);
- glReadPixels(0, 0, frame->box.width, frame->box.height, glf, glt, data);
+ glReadPixels(0, 0, frame->box.width, frame->box.height, PFORMAT->glFormat, PFORMAT->glType, data);
g_pHyprRenderer->endRender();