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: gc.restore() encoding = options.get("encoding") if options and 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()
def paint_box(self, x, y, w, h, options): encoding = options.get("encoding") b = self._backing if not encoding or not b: return gc = b.cairo_create() 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()
def paint_box(self, encoding, is_delta, x, y, w, h): #show region being painted if debug paint box is enabled only: if self.paint_box_line_width<=0: return glLineWidth(self.paint_box_line_width+0.5+int(encoding=="scroll")*2) if is_delta: glLineStipple(1, 0xaaaa) glEnable(GL_LINE_STIPPLE) glBegin(GL_LINE_LOOP) color = get_paint_box_color(encoding) log("Painting colored box around %s screen update using: %s (delta=%s)", encoding, color, is_delta) glColor4f(*color) for px,py in ((x, y), (x+w, y), (x+w, y+h), (x, y+h)): glVertex2i(px, py) glEnd() if is_delta: glDisable(GL_LINE_STIPPLE)
def cairo_paint_box(self, gc, encoding, x, y, w, h): 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()
def test_defaults(self): assert get_default_paint_box_color() == BLACK assert get_paint_box_color("invalid-value") == BLACK for encoding in ("png", "h264"): assert get_paint_box_color(encoding) != BLACK