def paint_image(self, coding, img_data, x, y, width, height, options, callbacks): log("cairo.paint_image(%s, %s bytes,%s,%s,%s,%s,%s,%s) alpha_enabled=%s", coding, len(img_data), x, y, width, height, options, callbacks, self._alpha_enabled) #catch PNG and jpeg we can handle via cairo or pixbufloader respectively #(both of which need to run from the UI thread) if coding.startswith("png") or coding=="jpeg": def ui_paint_image(): if not self._backing: fire_paint_callbacks(callbacks, False, "no backing") return try: if coding.startswith("png"): reader = BytesIOClass(img_data) img = cairo.ImageSurface.create_from_png(reader) self.cairo_paint_surface(img, x, y) else: assert coding=="jpeg" pbl = GdkPixbuf.PixbufLoader() pbl.write(img_data) pbl.close() pixbuf = pbl.get_pixbuf() del pbl self.cairo_paint_pixbuf(pixbuf, x, y) fire_paint_callbacks(callbacks, True) except Exception as e: log.error("cairo error during paint", exc_info=True) fire_paint_callbacks(callbacks, False, "cairo error during paint: %s" % e) GLib.idle_add(ui_paint_image) return #this will end up calling do_paint_rgb24 after converting the pixels to RGB GTKWindowBacking.paint_image(self, coding, img_data, x, y, width, height, options, callbacks)
def paint_image(self, coding, img_data, x, y, width, height, options, callbacks): """ can be called from any thread """ if USE_PIL and has_codec("PIL"): return GTKWindowBacking.paint_image(self, coding, img_data, x, y, width, height, options, callbacks) # gdk needs UI thread: gobject.idle_add(self.paint_pixbuf_gdk, coding, img_data, x, y, width, height, options, callbacks) return False
def paint_image(self, coding, img_data, x, y, width, height, options, callbacks): """ can be called from any thread """ if USE_PIL and has_codec("dec_pillow"): return GTKWindowBacking.paint_image(self, coding, img_data, x, y, width, height, options, callbacks) #gdk needs UI thread: self.idle_add(self.paint_pixbuf_gdk, coding, img_data, x, y, width, height, options, callbacks) return False
def paint_image(self, coding, img_data, x, y, width, height, options, callbacks): """ can be called from any thread """ use_PIL = has_codec("PIL") and os.environ.get("XPRA_USE_PIL", "1")=="1" if use_PIL: return GTKWindowBacking.paint_image(self, coding, img_data, x, y, width, height, options, callbacks) #gdk needs UI thread: gobject.idle_add(self.paint_pixbuf_gdk, coding, img_data, x, y, width, height, options, callbacks) return False
def paint_image(self, coding, img_data, x, y, width, height, options, callbacks): """ can be called from any thread """ use_PIL = has_codec("PIL") and os.environ.get("XPRA_USE_PIL", "1")=="1" if use_PIL: return GTKWindowBacking.paint_image(self, coding, img_data, x, y, width, height, options, callbacks) #gdk needs UI thread: gobject.idle_add(self.paint_pixbuf_gdk, coding, img_data, x, y, width, height, options, callbacks) return False
def paint_image(self, coding, img_data, x, y, width, height, options, callbacks): """ can be called from any thread """ if use_PIL: return GTKWindowBacking.paint_image(self, coding, img_data, x, y, width, height, options, callbacks) #gdk needs UI thread: gobject.idle_add(self.paint_pixbuf_gdk, coding, img_data, x, y, width, height, options, callbacks) return False
def paint_image(self, coding, img_data, x, y, width, height, options, callbacks): log( "cairo.paint_image(%s, %s bytes,%s,%s,%s,%s,%s,%s) alpha_enabled=%s", coding, len(img_data), x, y, width, height, options, callbacks, self._alpha_enabled) #catch PNG and jpeg we can handle via cairo or pixbufloader respectively #(both of which need to run from the UI thread) if coding.startswith("png") or coding == "jpeg": def ui_paint_image(): if not self._backing: fire_paint_callbacks(callbacks, False, "no backing") return try: if coding.startswith("png"): reader = BytesIOClass(img_data) img = cairo.ImageSurface.create_from_png(reader) self.cairo_paint_surface(img, x, y) else: assert coding == "jpeg" pbl = GdkPixbuf.PixbufLoader() pbl.write(img_data) pbl.close() pixbuf = pbl.get_pixbuf() del pbl self.cairo_paint_pixbuf(pixbuf, x, y) fire_paint_callbacks(callbacks, True) except Exception as e: log.error("cairo error during paint", exc_info=True) fire_paint_callbacks(callbacks, False, "cairo error during paint: %s" % e) GLib.idle_add(ui_paint_image) return #this will end up calling do_paint_rgb24 after converting the pixels to RGB GTKWindowBacking.paint_image(self, coding, img_data, x, y, width, height, options, callbacks)