Пример #1
0
 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)
Пример #2
0
    def __init__(self, wid, window_alpha):
        self.wid = wid
        self.size = 0, 0
        self.render_size = 0, 0
        self.texture_pixel_format = None
        #this is the pixel format we are currently updating the fbo with
        #can be: "YUV420P", "YUV422P", "YUV444P", "GBRP" or None when not initialized yet.
        self.pixel_format = None
        self.textures = None # OpenGL texture IDs
        self.shaders = None
        self.texture_size = 0, 0
        self.gl_setup = False
        self.debug_setup = False
        self.border = None
        self.paint_screen = False
        self.paint_spinner = False
        self.offscreen_fbo = None
        self.tmp_fbo = None
        self.pending_fbo_paint = []
        self.last_flush = time.time()
        self.default_paint_box_line_width = OPENGL_PAINT_BOX or 1
        self.paint_box_line_width = OPENGL_PAINT_BOX

        GTKWindowBacking.__init__(self, wid, window_alpha)
        self.init_gl_config(window_alpha)
        self.init_backing()
        #this is how many bpp we keep in the texture
        #(pixels are always stored in 32bpp - but this makes it clearer when we do/don't support alpha)
        if self._alpha_enabled:
            self.texture_pixel_format = GL_RGBA
        else:
            self.texture_pixel_format = GL_RGB
        #see #1469
        #self.draw_needs_refresh = False
        self._backing.show()
Пример #3
0
    def __init__(self, wid, window_alpha):
        self.wid = wid
        self.size = 0, 0
        self.render_size = 0, 0
        self.texture_pixel_format = None
        #this is the pixel format we are currently updating the fbo with
        #can be: "YUV420P", "YUV422P", "YUV444P", "GBRP" or None when not initialized yet.
        self.pixel_format = None
        self.textures = None # OpenGL texture IDs
        self.shaders = None
        self.texture_size = 0, 0
        self.gl_setup = False
        self.debug_setup = False
        self.border = None
        self.paint_screen = False
        self.paint_spinner = False
        self.draw_needs_refresh = False
        self.offscreen_fbo = None
        self.pending_fbo_paint = []

        GTKWindowBacking.__init__(self, wid, window_alpha)
        self.init_gl_config(window_alpha)
        self.init_backing()
        #this is how many bpp we keep in the texture
        #(pixels are always stored in 32bpp - but this makes it clearer when we do/don't support alpha)
        if self._alpha_enabled:
            self.texture_pixel_format = GL_RGBA
        else:
            self.texture_pixel_format = GL_RGB
        self._backing.show()
Пример #4
0
 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
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
 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
Пример #8
0
 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
Пример #9
0
    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)
Пример #10
0
 def __init__(self, wid, w, h, has_alpha):
     GTKWindowBacking.__init__(self, wid)
     self._has_alpha = has_alpha and HAS_ALPHA
Пример #11
0
 def __init__(self, wid, w, h, has_alpha):
     GTKWindowBacking.__init__(self, wid)
     self._has_alpha = has_alpha and HAS_ALPHA
Пример #12
0
 def __init__(self, wid, w, h, has_alpha):
     self.pixels = None
     self.format = None
     GTKWindowBacking.__init__(self, wid)
Пример #13
0
 def get_encoding_properties(self):
     props = GTKWindowBacking.get_encoding_properties(self)
     if SCROLL_ENCODING:
         props["encoding.scrolling"] = True
     return props
Пример #14
0
 def get_encoding_properties(self):
     props = GTKWindowBacking.get_encoding_properties(self)
     if SCROLL_ENCODING:
         props["encoding.scrolling"] = True
     return props
Пример #15
0
 def close(self):
     GTKWindowBacking.close(self)
     self._backing.finish()
Пример #16
0
 def __init__(self, wid, w, h, has_alpha):
     GTKWindowBacking.__init__(self, wid)
Пример #17
0
 def close(self):
     if self._backing:
         self._backing.finish()
     GTKWindowBacking.close(self)
Пример #18
0
 def __init__(self, wid, w, h, has_alpha):
     self.pixels = None
     self.format = None
     GTKWindowBacking.__init__(self, wid)
Пример #19
0
 def __init__(self, wid, w, h, has_alpha, data=None):
     self.data = data
     GTKWindowBacking.__init__(self, wid, True)
     self._backing = object()    #pretend we have a backing structure
Пример #20
0
 def __init__(self, wid, w, h, has_alpha, data=None):
     self.data = data
     GTKWindowBacking.__init__(self, wid)
Пример #21
0
 def close(self):
     GTKWindowBacking.close(self)
     self._backing.finish()
Пример #22
0
 def close(self):
     if self._backing:
         self._backing.finish()
     GTKWindowBacking.close(self)
Пример #23
0
 def __init__(self, wid, w, h, has_alpha):
     GTKWindowBacking.__init__(self, wid, has_alpha)