Performance: use Surface instead of PixBuf

This commit is contained in:
Vulcalien 2021-12-09 23:00:35 +01:00
parent a06e7951f6
commit 5a6237cc47
1 changed files with 3 additions and 2 deletions

View File

@ -189,7 +189,8 @@ class Terminal(Gtk.VBox):
def set_background_image(self,image): def set_background_image(self,image):
try: try:
self.background_image = GdkPixbuf.Pixbuf.new_from_file(image) bg_pixbuf = GdkPixbuf.Pixbuf.new_from_file(image)
self.background_image = Gdk.cairo_surface_create_from_pixbuf(bg_pixbuf, 1, None)
self.vte.set_clear_background(False) self.vte.set_clear_background(False)
self.vte.connect("draw",self.background_draw) self.vte.connect("draw",self.background_draw)
except Exception as e: except Exception as e:
@ -1135,7 +1136,7 @@ class Terminal(Gtk.VBox):
yratio = float(rect.height) / float(self.background_image.get_height()) yratio = float(rect.height) / float(self.background_image.get_height())
cr.save() cr.save()
cr.scale(xratio,yratio) cr.scale(xratio,yratio)
Gdk.cairo_set_source_pixbuf(cr, self.background_image, 0, 0) cr.set_source_surface(self.background_image)
cr.paint() cr.paint()
Gdk.cairo_set_source_rgba(cr,self.bgcolor) Gdk.cairo_set_source_rgba(cr,self.bgcolor)
cr.paint() cr.paint()