From 1db4a99d102cb08ab8006b4bdeadb71204c86fb4 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 1 Apr 2019 08:57:01 +0000 Subject: [PATCH] #1925: looks like wayland windows always have transparency enabled, so we need to zero out the alpha channel and paint with RGB24 git-svn-id: https://xpra.org/svn/Xpra/trunk@22236 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/gtk3/cairo_backing.py | 2 +- src/xpra/client/gtk3/cairo_workaround.pyx | 24 +++++++++++++++++-- .../client/gtk_base/cairo_backing_base.py | 6 ++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/xpra/client/gtk3/cairo_backing.py b/src/xpra/client/gtk3/cairo_backing.py index 446c25750e..da812afc09 100644 --- a/src/xpra/client/gtk3/cairo_backing.py +++ b/src/xpra/client/gtk3/cairo_backing.py @@ -51,7 +51,7 @@ def _do_paint_rgb(self, cairo_format, has_alpha, img_data, x, y, width, height, rowstride, options, set_image_surface_data, CAIRO_USE_PIXBUF) rgb_format = options.strget(b"rgb_format", "RGB") if set_image_surface_data and not CAIRO_USE_PIXBUF: - if (cairo_format==cairo.FORMAT_RGB24 and rgb_format in ("RGB", "BGR")) or \ + if (cairo_format==cairo.FORMAT_RGB24 and rgb_format in ("RGB", "RGBX", "BGR", "BGRX")) or \ (cairo_format==cairo.FORMAT_ARGB32 and rgb_format in ("BGRX", "BGRA")): img_surface = cairo.ImageSurface(cairo_format, width, height) set_image_surface_data(img_surface, rgb_format, img_data, width, height, rowstride) diff --git a/src/xpra/client/gtk3/cairo_workaround.pyx b/src/xpra/client/gtk3/cairo_workaround.pyx index cc568f13e5..599171bb88 100644 --- a/src/xpra/client/gtk3/cairo_workaround.pyx +++ b/src/xpra/client/gtk3/cairo_workaround.pyx @@ -117,7 +117,7 @@ def set_image_surface_data(object image_surface, rgb_format, object pixel_data, data[dsti + 0] = cbuf[srci + 0] #B data[dsti + 1] = cbuf[srci + 1] #G data[dsti + 2] = cbuf[srci + 2] #R - data[dsti + 3] = 255 #X + data[dsti + 3] = 0 #X elif rgb_format=="RGB": with nogil: for y in range(height): @@ -127,7 +127,27 @@ def set_image_surface_data(object image_surface, rgb_format, object pixel_data, data[dsti + 0] = cbuf[srci + 2] #B data[dsti + 1] = cbuf[srci + 1] #G data[dsti + 2] = cbuf[srci + 0] #R - data[dsti + 3] = 255 #X + data[dsti + 3] = 0 #X + if rgb_format=="BGRX": + with nogil: + for y in range(height): + for x in range(width): + srci = x*4 + y*stride + dsti = x*4 + y*istride + data[dsti + 0] = cbuf[srci + 0] #B + data[dsti + 1] = cbuf[srci + 1] #G + data[dsti + 2] = cbuf[srci + 2] #R + data[dsti + 3] = 0 #X + elif rgb_format=="RGBX": + with nogil: + for y in range(height): + for x in range(width): + srci = x*4 + y*stride + dsti = x*4 + y*istride + data[dsti + 0] = cbuf[srci + 2] #B + data[dsti + 1] = cbuf[srci + 1] #G + data[dsti + 2] = cbuf[srci + 0] #R + data[dsti + 3] = 0 #X else: raise ValueError("unhandled RGB format '%s'" % rgb_format) elif format==CAIRO_FORMAT_ARGB32: diff --git a/src/xpra/client/gtk_base/cairo_backing_base.py b/src/xpra/client/gtk_base/cairo_backing_base.py index 72ab0b0259..84d79efb01 100644 --- a/src/xpra/client/gtk_base/cairo_backing_base.py +++ b/src/xpra/client/gtk_base/cairo_backing_base.py @@ -133,7 +133,11 @@ def _do_paint_rgb24(self, img_data, x, y, width, height, rowstride, options): return self._do_paint_rgb(cairo.FORMAT_RGB24, False, img_data, x, y, width, height, rowstride, options) def _do_paint_rgb32(self, img_data, x, y, width, height, rowstride, options): - return self._do_paint_rgb(cairo.FORMAT_ARGB32, True, img_data, x, y, width, height, rowstride, options) + if self._alpha_enabled: + cformat = cairo.FORMAT_ARGB32 + else: + cformat = cairo.FORMAT_RGB24 + return self._do_paint_rgb(cformat, True, img_data, x, y, width, height, rowstride, options) def _do_paint_rgb(self, *args): raise NotImplementedError()