[eog] EogScrollView: Convert to gdk_cairo_surface_create_from_pixbuf
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog] EogScrollView: Convert to gdk_cairo_surface_create_from_pixbuf
- Date: Sun, 14 Feb 2021 17:05:50 +0000 (UTC)
commit 8211d6b613766572f9c63b237ca59af9230e5357
Author: Felix Riemann <friemann gnome org>
Date: Sun Feb 14 18:02:33 2021 +0100
EogScrollView: Convert to gdk_cairo_surface_create_from_pixbuf
The GDK function does pretty much the same as eog's code before,
but saves one intermediate surface. It also returns an image surface
and not a descendant of the widget surface, which reportedly
helps to improve the situation in #146.
src/eog-scroll-view.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
---
diff --git a/src/eog-scroll-view.c b/src/eog-scroll-view.c
index 13376bb7..9563fcab 100644
--- a/src/eog-scroll-view.c
+++ b/src/eog-scroll-view.c
@@ -210,7 +210,6 @@ create_surface_from_pixbuf (EogScrollView *view, GdkPixbuf *pixbuf)
cairo_surface_t *surface;
cairo_t *cr;
gint w, h;
- gboolean size_invalid = FALSE;
w = gdk_pixbuf_get_width (pixbuf);
h = gdk_pixbuf_get_height (pixbuf);
@@ -219,24 +218,15 @@ create_surface_from_pixbuf (EogScrollView *view, GdkPixbuf *pixbuf)
g_warning ("Image dimensions too large to process");
w = 50;
h = 50;
- size_invalid = TRUE;
- }
-
- surface = gdk_window_create_similar_surface (gtk_widget_get_window (view->priv->display),
- CAIRO_CONTENT_COLOR | CAIRO_CONTENT_ALPHA,
- w, h);
- if (size_invalid) {
- return surface;
+ surface = gdk_window_create_similar_image_surface (
+ gtk_widget_get_window (view->priv->display),
+ CAIRO_FORMAT_ARGB32, w, h, 1.0);
+ } else {
+ surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1.0,
+ gtk_widget_get_window (view->priv->display));
}
- cairo_surface_set_device_scale (surface, 1.0, 1.0);
-
- cr = cairo_create (surface);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
return surface;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]