[gtk+/wip/window-scales2: 10/40] gdkwindow: Respect cairo surfaces with device scale
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/window-scales2: 10/40] gdkwindow: Respect cairo surfaces with device scale
- Date: Wed, 3 Jul 2013 12:42:48 +0000 (UTC)
commit 56bec0c70c1c507934a27b6c241b63360f53e731
Author: Alexander Larsson <alexl redhat com>
Date: Tue Jun 4 10:41:44 2013 +0200
gdkwindow: Respect cairo surfaces with device scale
If a cairo_surface for a window has a device scale set we need
to respect this when creating a similar window. I.e. we want
to then automatically create a larger window which inherits
the scale from the original.
We also need to calculate a different device_offset if there
is a device_scale set.
gdk/gdkwindow.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 99fed9b..6943388 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -2757,6 +2757,7 @@ gdk_window_begin_paint_region (GdkWindow *window,
GdkWindowImplClass *impl_class;
GdkWindowPaint *paint;
GSList *list;
+ double sx, sy;
gboolean needs_surface;
g_return_if_fail (GDK_IS_WINDOW (window));
@@ -2783,7 +2784,11 @@ gdk_window_begin_paint_region (GdkWindow *window,
gdk_window_get_content (window),
MAX (clip_box.width, 1),
MAX (clip_box.height, 1));
- cairo_surface_set_device_offset (paint->surface, -clip_box.x, -clip_box.y);
+ sx = sy = 1;
+#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
+ cairo_surface_get_device_scale (paint->surface, &sx, &sy);
+#endif
+ cairo_surface_set_device_offset (paint->surface, -clip_box.x*sx, -clip_box.y*sy);
}
for (list = window->paint_stack; list != NULL; list = list->next)
@@ -9198,10 +9203,18 @@ gdk_window_create_similar_surface (GdkWindow * window,
int height)
{
cairo_surface_t *window_surface, *surface;
+ double sx, sy;
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-
+
window_surface = gdk_window_ref_impl_surface (window);
+ sx = sy = 1;
+#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
+ cairo_surface_get_device_scale (window_surface, &sx, &sy);
+#endif
+
+ width = width * sx;
+ height = height * sy;
switch (_gdk_rendering_mode)
{
@@ -9224,6 +9237,10 @@ gdk_window_create_similar_surface (GdkWindow * window,
break;
}
+#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
+ cairo_surface_set_device_scale (surface, sx, sy);
+#endif
+
cairo_surface_destroy (window_surface);
return surface;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]