[gimp] app: add (disabled) support for rendering the image at high resolution
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add (disabled) support for rendering the image at high resolution
- Date: Fri, 18 Jan 2013 15:39:26 +0000 (UTC)
commit 2491a3a088b263bf62834c5f3d6912c853bcc9d0
Author: Michael Natterer <mitch gimp org>
Date: Fri Jan 18 16:36:22 2013 +0100
app: add (disabled) support for rendering the image at high resolution
for what Apple calls "Retina". Disabled because the GDK API to figure
the scale factor doesn't exist yet.
app/display/gimpdisplayshell-render.c | 32 +++++++++++++++++++++++++-------
app/display/gimpdisplayshell-render.h | 8 ++++++++
app/display/gimpdisplayshell.c | 6 ++++--
3 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-render.c b/app/display/gimpdisplayshell-render.c
index 252e4d4..67d1c50 100644
--- a/app/display/gimpdisplayshell-render.c
+++ b/app/display/gimpdisplayshell-render.c
@@ -54,6 +54,7 @@ gimp_display_shell_render (GimpDisplayShell *shell,
GimpImage *image;
GimpProjection *projection;
GeglBuffer *buffer;
+ gdouble window_scale = 1.0;
gint viewport_offset_x;
gint viewport_offset_y;
gint viewport_width;
@@ -67,6 +68,13 @@ gimp_display_shell_render (GimpDisplayShell *shell,
projection = gimp_image_get_projection (image);
buffer = gimp_pickable_get_buffer (GIMP_PICKABLE (projection));
+#ifdef GIMP_DISPLAY_RENDER_ENABLE_SCALING
+ /* if we had this future API, things would look pretty on hires (retina) */
+ window_scale = gdk_window_get_scale_factor (gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (shell))));
+#endif
+
+ window_scale = MIN (window_scale, GIMP_DISPLAY_RENDER_MAX_SCALE);
+
gimp_display_shell_scroll_get_scaled_viewport (shell,
&viewport_offset_x,
&viewport_offset_y,
@@ -74,10 +82,11 @@ gimp_display_shell_render (GimpDisplayShell *shell,
&viewport_height);
gegl_buffer_get (buffer,
- GEGL_RECTANGLE (x + viewport_offset_x,
- y + viewport_offset_y,
- w, h),
- shell->scale_x,
+ GEGL_RECTANGLE ((x + viewport_offset_x) * window_scale,
+ (y + viewport_offset_y) * window_scale,
+ w * window_scale,
+ h * window_scale),
+ shell->scale_x * window_scale,
babl_format ("cairo-ARGB32"),
cairo_image_surface_get_data (shell->render_surface),
cairo_image_surface_get_stride (shell->render_surface),
@@ -91,7 +100,9 @@ gimp_display_shell_render (GimpDisplayShell *shell,
if (w != GIMP_DISPLAY_RENDER_BUF_WIDTH ||
h != GIMP_DISPLAY_RENDER_BUF_HEIGHT)
sub = cairo_image_surface_create_for_data (cairo_image_surface_get_data (sub),
- CAIRO_FORMAT_ARGB32, w, h,
+ CAIRO_FORMAT_ARGB32,
+ w * window_scale,
+ h * window_scale,
GIMP_DISPLAY_RENDER_BUF_WIDTH * 4);
gimp_color_display_stack_convert_surface (shell->filter_stack, sub);
@@ -100,7 +111,9 @@ gimp_display_shell_render (GimpDisplayShell *shell,
cairo_surface_destroy (sub);
}
- cairo_surface_mark_dirty_rectangle (shell->render_surface, 0, 0, w, h);
+ cairo_surface_mark_dirty_rectangle (shell->render_surface,
+ 0, 0,
+ w * window_scale, h * window_scale);
#if 0
if (shell->mask)
@@ -136,7 +149,12 @@ gimp_display_shell_render (GimpDisplayShell *shell,
cairo_rectangle (cr, x, y, w, h);
cairo_clip (cr);
- cairo_set_source_surface (cr, shell->render_surface, x, y);
+ cairo_scale (cr, 1.0 / window_scale, 1.0 / window_scale);
+
+ cairo_set_source_surface (cr, shell->render_surface,
+ x * window_scale,
+ y * window_scale);
+
cairo_paint (cr);
#if 0
diff --git a/app/display/gimpdisplayshell-render.h b/app/display/gimpdisplayshell-render.h
index 01cac48..652cddd 100644
--- a/app/display/gimpdisplayshell-render.h
+++ b/app/display/gimpdisplayshell-render.h
@@ -19,9 +19,17 @@
#define __GIMP_DISPLAY_SHELL_RENDER_H__
+/* #define GIMP_DISPLAY_RENDER_ENABLE_SCALING 1 */
+
#define GIMP_DISPLAY_RENDER_BUF_WIDTH 256
#define GIMP_DISPLAY_RENDER_BUF_HEIGHT 256
+#ifdef GIMP_DISPLAY_RENDER_ENABLE_SCALING
+#define GIMP_DISPLAY_RENDER_MAX_SCALE 2.0
+#else
+#define GIMP_DISPLAY_RENDER_MAX_SCALE 1.0
+#endif
+
void gimp_display_shell_render (GimpDisplayShell *shell,
cairo_t *cr,
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 6410d48..3e99799 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -300,8 +300,10 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->y_src_dec = 1;
shell->render_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- GIMP_DISPLAY_RENDER_BUF_WIDTH,
- GIMP_DISPLAY_RENDER_BUF_HEIGHT);
+ GIMP_DISPLAY_RENDER_BUF_WIDTH *
+ GIMP_DISPLAY_RENDER_MAX_SCALE,
+ GIMP_DISPLAY_RENDER_BUF_HEIGHT *
+ GIMP_DISPLAY_RENDER_MAX_SCALE);
gimp_display_shell_items_init (shell);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]