Skip to content

Commit

Permalink
#1925: looks like wayland windows always have transparency enabled, s…
Browse files Browse the repository at this point in the history
…o 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
  • Loading branch information
totaam committed Apr 1, 2019
1 parent 2f1125c commit 1db4a99
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/xpra/client/gtk3/cairo_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 22 additions & 2 deletions src/xpra/client/gtk3/cairo_workaround.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion src/xpra/client/gtk_base/cairo_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1db4a99

Please sign in to comment.