示例#1
0
def cairo_paint_pointer_overlay(context, cursor_data, px, py, start_time):
    if not cursor_data:
        return
    elapsed = max(0, monotonic_time() - start_time)
    if elapsed > 6:
        return
    cw = cursor_data[3]
    ch = cursor_data[4]
    xhot = cursor_data[5]
    yhot = cursor_data[6]
    pixels = cursor_data[8]
    x = px - xhot
    y = py - yhot
    alpha = max(0, (5.0 - elapsed) / 5.0)
    log("cairo_paint_pointer_overlay%s drawing pointer with cairo, alpha=%s",
        (context, x, y, start_time), alpha)
    context.translate(x, y)
    context.rectangle(0, 0, cw, ch)
    argb = unpremultiply_argb(pixels)
    img_data = memoryview_to_bytes(argb)
    pixbuf = pixbuf_new_from_data(img_data, COLORSPACE_RGB, True, 8, cw, ch,
                                  cw * 4)
    context.set_operator(cairo.OPERATOR_OVER)
    cairo_set_source_pixbuf(context, pixbuf, 0, 0)
    context.paint()
示例#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()
示例#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
示例#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()
示例#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