[gnome-music/wip/mschraal/artrework] albumartcache: Optimize frame rendering
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/artrework] albumartcache: Optimize frame rendering
- Date: Mon, 29 Jan 2018 12:34:44 +0000 (UTC)
commit d28bb78a4efce45b5e18dcf24653b84b1b9c4f7c
Author: Marinus Schraal <mschraal gnome org>
Date: Mon Jan 29 12:43:47 2018 +0100
albumartcache: Optimize frame rendering
Use the ability to set_device_scale on a cairo.Surface to remove two
steps in the frame drawing method.
Closes: #81
.gitlab-ci.yml | 6 +++---
configure.ac | 3 +++
gnomemusic/albumartcache.py | 21 ++++++++-------------
3 files changed, 14 insertions(+), 16 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 353695c..50ed418 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,9 +6,9 @@ stages:
variables:
DEPENDENCIES: python3 autoconf-archive gettext-devel git pygobject3
- pygobject3-devel python3-gobject redhat-rpm-config gtk3-devel
- gobject-introspection-devel tracker-devel gnome-common which
- libmediaart-devel grilo-devel
+ pygobject3-devel python3-gobject python3-cairo-devel
+ redhat-rpm-config gtk3-devel gobject-introspection-devel
+ tracker-devel gnome-common which libmediaart-devel grilo-devel
build:
stage: build
diff --git a/configure.ac b/configure.ac
index 3a69050..6c4beb7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,6 +39,9 @@ PKG_CHECK_MODULES([MEDIAART], [libmediaart-2.0 >= 1.9.1])
PYGOBJECT_MIN_VERSION=3.21.1
PKG_CHECK_MODULES(PYGOBJECT, [pygobject-3.0 >= $PYGOBJECT_MIN_VERSION])
+PYCAIRO_MIN_VERSION=1.14.0
+PKG_CHECK_MODULES(PYCAIRO, [py3cairo >= $PYCAIRO_MIN_VERSION])
+
TRACKER_MIN_VERSION=1.99.1
PKG_CHECK_MODULES(TRACKER, [tracker-sparql-2.0 >= $TRACKER_MIN_VERSION])
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index ad3a4dc..b4571df 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -85,21 +85,22 @@ class Queue(GObject.GObject):
@log
def _make_icon_frame(pixbuf, art_size=None, scale=1):
- border = 3 * scale
+ border = 3
degrees = pi / 180
- radius = 3 * scale
+ radius = 3
ratio = pixbuf.get_height() / pixbuf.get_width()
# Scale down the image according to the biggest axis
if ratio > 1:
- w = int(art_size.width / ratio * scale)
- h = art_size.height * scale
+ w = int(art_size.width / ratio)
+ h = art_size.height
else:
- w = art_size.width * scale
- h = int(art_size.height * ratio * scale)
+ w = art_size.width
+ h = int(art_size.height * ratio)
- surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)
+ surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, w * scale, h * scale)
+ surface.set_device_scale(scale, scale)
ctx = cairo.Context(surface)
# draw outline
@@ -129,12 +130,6 @@ def _make_icon_frame(pixbuf, art_size=None, scale=1):
ctx.rectangle(border, border, w - border * 2, h - border * 2)
ctx.fill()
- border_pixbuf = Gdk.pixbuf_get_from_surface(surface, 0, 0, w, h)
-
- surface = Gdk.cairo_surface_create_from_pixbuf(border_pixbuf,
- scale,
- None)
-
return surface
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]