Skip to content

Commit

Permalink
#961: fix transparency with pixbuf backing:
Browse files Browse the repository at this point in the history
* partial revert of r9977: use pixbuf to honour alpha, draw_rgb_32_image otherwise
* skip unpremultiply step if there is no alpha

git-svn-id: https://xpra.org/svn/Xpra/trunk@10419 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 23, 2015
1 parent 087b7c0 commit a33e084
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/xpra/client/gtk2/pixmap_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,22 @@ def _do_paint_rgb24(self, img_data, x, y, width, height, rowstride, options):
return True

def _do_paint_rgb32(self, img_data, x, y, width, height, rowstride, options):
img_data = memoryview_to_bytes(self.unpremultiply(img_data))
has_alpha = options.boolget("has_alpha", False) or options.get("rgb_format", "").find("A")>=0
if has_alpha:
img_data = self.unpremultiply(img_data)
img_data = memoryview_to_bytes(img_data)
if INDIRECT_BGR:
img_data, rowstride = self.bgr_to_rgb(img_data, width, height, rowstride, options.strget("rgb_format", ""), "RGBA")
gc = self._backing.new_gc()
self._backing.draw_rgb_32_image(gc, x, y, width, height, gdk.RGB_DITHER_NONE, img_data, rowstride)
if has_alpha:
#draw_rgb_32_image does not honour alpha, we have to use pixbuf:
pixbuf = gdk.pixbuf_new_from_data(img_data, gdk.COLORSPACE_RGB, True, 8, width, height, rowstride)
cr = self._backing.cairo_create()
cr.rectangle(x, y, width, height)
cr.set_source_pixbuf(pixbuf, x, y)
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.paint()
else:
#no alpha is easier:
gc = self._backing.new_gc()
self._backing.draw_rgb_32_image(gc, x, y, width, height, gdk.RGB_DITHER_NONE, img_data, rowstride)
return True

0 comments on commit a33e084

Please sign in to comment.