summaryrefslogtreecommitdiff
path: root/src/protocols/ToplevelExport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocols/ToplevelExport.cpp')
-rw-r--r--src/protocols/ToplevelExport.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp
index 9a97f934..7549425c 100644
--- a/src/protocols/ToplevelExport.cpp
+++ b/src/protocols/ToplevelExport.cpp
@@ -285,8 +285,6 @@ bool CToplevelExportFrame::copyShm(const Time::steady_tp& now) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, outFB.getFBID());
glPixelStorei(GL_PACK_ALIGNMENT, 1);
- auto glFormat = PFORMAT->flipRB ? GL_BGRA_EXT : GL_RGBA;
-
auto origin = Vector2D(0, 0);
switch (PMONITOR->m_transform) {
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
@@ -308,6 +306,26 @@ bool CToplevelExportFrame::copyShm(const Time::steady_tp& now) {
default: break;
}
+ int glFormat = PFORMAT->glFormat;
+
+ if (glFormat == GL_RGBA)
+ glFormat = GL_BGRA_EXT;
+
+ if (glFormat != GL_BGRA_EXT && glFormat != GL_RGB) {
+ if (PFORMAT->swizzle.has_value()) {
+ std::array<GLint, 4> RGBA = SWIZZLE_RGBA;
+ std::array<GLint, 4> BGRA = SWIZZLE_BGRA;
+ if (PFORMAT->swizzle == RGBA)
+ glFormat = GL_RGBA;
+ else if (PFORMAT->swizzle == BGRA)
+ glFormat = GL_BGRA_EXT;
+ else {
+ LOGM(Log::ERR, "Copied frame via shm might be broken or color flipped");
+ glFormat = GL_RGBA;
+ }
+ }
+ }
+
glReadPixels(origin.x, origin.y, m_box.width, m_box.height, glFormat, PFORMAT->glType, pixelData);
if (overlayCursor) {