Example #1
0
    def cairo_paint_from_source(self, set_source_fn, source, x, y, w, h,
                                options):
        """ must be called from UI thread """
        log(
            "cairo_paint_surface(%s, %s, %s, %s, %s, %s, %s) backing=%s, paint box line width=%i",
            set_source_fn, source, x, y, w, h, options, self._backing,
            self.paint_box_line_width)
        gc = gdk_cairo_context(cairo.Context(self._backing))
        if self.paint_box_line_width:
            gc.save()

        gc.rectangle(x, y, w, h)
        gc.clip()

        gc.set_operator(cairo.OPERATOR_CLEAR)
        gc.rectangle(x, y, w, h)
        gc.fill()

        gc.set_operator(cairo.OPERATOR_SOURCE)
        gc.translate(x, y)
        gc.rectangle(0, 0, w, h)
        set_source_fn(gc, source, 0, 0)
        gc.paint()
        if self.paint_box_line_width and options:
            gc.restore()
            encoding = options.get("encoding")
            if encoding:
                color = get_paint_box_color(encoding)
                gc.set_line_width(self.paint_box_line_width)
                gc.set_source_rgba(*color)
                gc.rectangle(x, y, w, h)
                gc.stroke()
Example #2
0
 def cairo_paint_pixbuf(self, pixbuf, x, y):
     """ must be called from UI thread """
     log("cairo_paint_pixbuf(%s, %s, %s) backing=%s", pixbuf, x, y, self._backing)
     #now use it to paint:
     gc = gdk_cairo_context(cairo.Context(self._backing))
     gc.set_operator(cairo.OPERATOR_SOURCE)
     cairo_set_source_pixbuf(gc, pixbuf, x, y)
     gc.paint()
Example #3
0
 def cairo_paint_pixbuf(self, pixbuf, x, y):
     """ must be called from UI thread """
     log("cairo_paint_pixbuf(%s, %s, %s) backing=%s", pixbuf, x, y, self._backing)
     #now use it to paint:
     gc = gdk_cairo_context(cairo.Context(self._backing))
     cairo_set_source_pixbuf(gc, pixbuf, x, y)
     gc.paint()
     return True
Example #4
0
 def cairo_paint_pixbuf(self, pixbuf, x, y):
     """ must be called from UI thread """
     log("cairo_paint_pixbuf(%s, %s, %s) backing=%s", pixbuf, x, y,
         self._backing)
     #now use it to paint:
     gc = gdk_cairo_context(cairo.Context(self._backing))
     gc.set_operator(cairo.OPERATOR_SOURCE)
     cairo_set_source_pixbuf(gc, pixbuf, x, y)
     gc.paint()
Example #5
0
 def cairo_paint_pixbuf(self, pixbuf, x, y):
     """ must be called from UI thread """
     log("cairo_paint_pixbuf(%s, %s, %s) backing=%s", pixbuf, x, y,
         self._backing)
     #now use it to paint:
     gc = gdk_cairo_context(cairo.Context(self._backing))
     cairo_set_source_pixbuf(gc, pixbuf, x, y)
     gc.paint()
     return True
Example #6
0
 def cairo_paint_surface(self, img_surface, x, y):
     """ must be called from UI thread """
     log("cairo_paint_surface(%s, %s, %s)", img_surface, x, y)
     gc = gdk_cairo_context(cairo.Context(self._backing))
     gc.set_operator(cairo.OPERATOR_CLEAR)
     gc.rectangle(x, y, img_surface.get_width(), img_surface.get_height())
     gc.fill()
     gc.set_operator(cairo.OPERATOR_SOURCE)
     gc.set_source_surface(img_surface, x, y)
     gc.paint()
     return True
Example #7
0
 def cairo_paint_surface(self, img_surface, x, y):
     """ must be called from UI thread """
     log("cairo_paint_surface(%s, %s, %s)", img_surface, x, y)
     gc = gdk_cairo_context(cairo.Context(self._backing))
     gc.set_operator(cairo.OPERATOR_CLEAR)
     gc.rectangle(x, y, img_surface.get_width(), img_surface.get_height())
     gc.fill()
     gc.set_operator(cairo.OPERATOR_OVER)
     gc.set_source_surface(img_surface, x, y)
     gc.paint()
     return True
Example #8
0
 def do_paint_scroll(self, scrolls, callbacks):
     old_backing = self._backing
     w, h = self.size
     ww, wh = self.render_size
     self.init(ww, wh, w, h)
     gc = gdk_cairo_context(cairo.Context(self._backing))
     gc.set_operator(cairo.OPERATOR_SOURCE)
     for sx, sy, sw, sh, xdelta, ydelta in scrolls:
         gc.set_source_surface(old_backing, xdelta, ydelta)
         gc.rectangle(sx + xdelta, sy + ydelta, sw, sh)
         gc.fill()
     fire_paint_callbacks(callbacks)
Example #9
0
 def cairo_paint_surface(self, img_surface, x, y):
     """ must be called from UI thread """
     log("cairo_paint_surface(%s, %s, %s)", img_surface, x, y)
     log("source image surface: %s", (
         img_surface.get_format(),
         img_surface.get_width(),
         img_surface.get_height(),
         img_surface.get_stride(),
         img_surface.get_content(),
     ))
     gc = gdk_cairo_context(cairo.Context(self._backing))
     gc.set_operator(cairo.OPERATOR_CLEAR)
     gc.rectangle(x, y, img_surface.get_width(), img_surface.get_height())
     gc.fill()
     gc.set_operator(cairo.OPERATOR_SOURCE)
     gc.set_source_surface(img_surface, x, y)
     gc.paint()