Skip to content

Commit

Permalink
#465 / #640: if we have bytes already, don't do anything
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@9069 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 20, 2015
1 parent 99e101e commit d4856aa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ def add_DLLs(*dll_names):

#list of DLLs we want to include, without the "lib" prefix, or the version and extension
#(ie: "libatk-1.0-0.dll" -> "atk")
add_DLLs('atk', 'cairo-gobject',
add_DLLs('atk', 'cairo-gobject', 'cairo',
'dbus', 'dbus-glib', 'gdk', 'gdk_pixbuf', 'openraw',
'gdkglext', 'gio', 'girepository', 'glib',
'gnutls', 'gobject', 'gthread',
Expand All @@ -1105,7 +1105,7 @@ def add_DLLs(*dll_names):
'p11-kit', 'proxy',
'pango', 'pangocairo', 'pangoft2', 'pangowin32',
'png16',
'rsvg', 'webp',
'rsvg', 'webp', "iconv",
'winpthread',
'zzz')
#this one may be missing in pygi-aio 3.14?
Expand Down Expand Up @@ -1440,6 +1440,9 @@ def add_keywords(path_dirs=[], inc_dirs=[], lib_dirs=[], libs=[], noref=True, no
elif "cairo" in pkgs_options:
add_to_keywords(kw, 'include_dirs', GTK_INCLUDE_DIR, cairo_include_dir)
add_to_keywords(kw, 'libraries', "cairo")
if PYTHON3:
cairo_library_dir = os.path.join(PYCAIRO_DIR, "lib")
add_to_keywords(kw, "library_dirs", cairo_library_dir)
checkdirs(cairo_include_dir)
elif "pycairo" in pkgs_options:
kw = pycairo_pkgconfig(*pkgs_options, **ekw)
Expand Down
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 @@ -77,7 +77,7 @@ def ui_paint_image():

def _do_paint_rgb(self, cairo_format, has_alpha, img_data, x, y, width, height, rowstride, options):
""" must be called from UI thread """
log("cairo._do_paint_rgb(%s, %s, %s bytes,%s,%s,%s,%s,%s,%s)", FORMATS.get(cairo_format, cairo_format), has_alpha, len(img_data), x, y, width, height, rowstride, options)
log("cairo._do_paint_rgb(%s, %s, %s %s,%s,%s,%s,%s,%s,%s) set_image_surface_data=%s", FORMATS.get(cairo_format, cairo_format), has_alpha, len(img_data), type(img_data), x, y, width, height, rowstride, options, set_image_surface_data)
rgb_format = options.strget("rgb_format", "RGB")
#this format we can handle with the workaround:
if cairo_format==cairo.FORMAT_RGB24 and rgb_format=="RGB" and set_image_surface_data:
Expand Down
8 changes: 6 additions & 2 deletions src/xpra/client/gtk_base/cairo_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from xpra.gtk_common.gtk_util import cairo_set_source_pixbuf, gdk_cairo_context
from xpra.client.gtk_base.gtk_window_backing_base import GTKWindowBacking
from xpra.codecs.loader import get_codec
from xpra.os_util import BytesIOClass
from xpra.os_util import BytesIOClass, memoryview_to_bytes

from xpra.log import Logger
log = Logger("paint", "cairo")
Expand Down Expand Up @@ -114,7 +114,11 @@ def nasty_rgb_via_png_paint(self, cairo_format, has_alpha, img_data, x, y, width
oformat = "RGBA"
else:
oformat = "RGB"
img = PIL.Image.frombuffer(oformat, (width,height), img_data, "raw", rgb_format, rowstride, 1)
#use frombytes rather than frombuffer to be compatible with python3 new-style buffers
#this is slower, but since this codepath is already dreadfully slow, we don't care
bdata = memoryview_to_bytes(img_data)
log("bdata=%s", type(bdata))
img = PIL.Image.frombytes(oformat, (width,height), bdata, "raw", rgb_format, rowstride, 1)
#This is insane, the code below should work, but it doesn't:
# img_data = bytearray(img.tostring('raw', oformat, 0, 1))
# pixbuf = pixbuf_new_from_data(img_data, COLORSPACE_RGB, True, 8, width, height, rowstride)
Expand Down
2 changes: 2 additions & 0 deletions src/xpra/os_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def bytestostr(x):

if _memoryview:
def memoryview_to_bytes(v):
if type(v)==bytes:
return v
if isinstance(v, _memoryview):
return v.tobytes()
return str(v)
Expand Down

0 comments on commit d4856aa

Please sign in to comment.