app/config/gimpdisplayconfig.[ch] app/config/gimprc-blurbs.h

2007-10-08  Sven Neumann  <sven@gimp.org>

	* app/config/gimpdisplayconfig.[ch]
	* app/config/gimprc-blurbs.h
	* app/display/display-enums.[ch]
	* app/display/gimpdisplayshell-handlers.c
	* app/display/gimpdisplayshell-render.c: allow to configure the
	display zoom quality.

	* app/display/gimpdisplayshell-transform.c: formatting. 

svn path=/trunk/; revision=23760
This commit is contained in:
Sven Neumann 2007-10-08 13:30:49 +00:00 committed by Sven Neumann
parent 1af04087df
commit 95c6df090f
9 changed files with 144 additions and 25 deletions

View File

@ -1,3 +1,14 @@
2007-10-08 Sven Neumann <sven@gimp.org>
* app/config/gimpdisplayconfig.[ch]
* app/config/gimprc-blurbs.h
* app/display/display-enums.[ch]
* app/display/gimpdisplayshell-handlers.c
* app/display/gimpdisplayshell-render.c: allow to configure the
display zoom quality.
* app/display/gimpdisplayshell-transform.c: formatting.
2007-10-08 Raphaël Quinet <raphael@gimp.org>
* authors.xml: Added Peter Sikking as author (we do not have a

View File

@ -68,7 +68,8 @@ enum
PROP_DEFAULT_FULLSCREEN_VIEW,
PROP_ACTIVATE_ON_FOCUS,
PROP_SPACE_BAR_ACTION,
PROP_XOR_COLOR
PROP_XOR_COLOR,
PROP_ZOOM_QUALITY
};
@ -231,6 +232,12 @@ gimp_display_config_class_init (GimpDisplayConfigClass *klass)
"xor-color", XOR_COLOR_BLURB,
FALSE, &color,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_ZOOM_QUALITY,
"zoom-quality",
ZOOM_QUALITY_BLURB,
GIMP_TYPE_ZOOM_QUALITY,
GIMP_ZOOM_QUALITY_HIGH,
GIMP_PARAM_STATIC_STRINGS);
}
static void
@ -360,6 +367,9 @@ gimp_display_config_set_property (GObject *object,
case PROP_XOR_COLOR:
display_config->xor_color = *(GimpRGB *) g_value_get_boxed (value);
break;
case PROP_ZOOM_QUALITY:
display_config->zoom_quality = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -452,6 +462,9 @@ gimp_display_config_get_property (GObject *object,
case PROP_XOR_COLOR:
g_value_set_boxed (value, &display_config->xor_color);
break;
case PROP_ZOOM_QUALITY:
g_value_set_enum (value, display_config->zoom_quality);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);

View File

@ -69,6 +69,7 @@ struct _GimpDisplayConfig
gboolean activate_on_focus;
GimpSpaceBarAction space_bar_action;
GimpRGB xor_color;
GimpZoomQuality zoom_quality;
};
struct _GimpDisplayConfigClass

View File

@ -433,5 +433,8 @@ N_("Sets the external web browser to be used. This can be an absolute " \
"a workaround for buggy display drivers. If lines on the canvas are not " \
"correctly undrawn, try to set this to white."
#define ZOOM_QUALITY_BLURB \
"There's a tradeoff between speed and quality of the zoomed-out display."
#endif /* __GIMP_RC_BLURBS_H__ */

View File

@ -100,6 +100,34 @@ gimp_space_bar_action_get_type (void)
return type;
}
GType
gimp_zoom_quality_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_ZOOM_QUALITY_LOW, "GIMP_ZOOM_QUALITY_LOW", "low" },
{ GIMP_ZOOM_QUALITY_HIGH, "GIMP_ZOOM_QUALITY_HIGH", "high" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_ZOOM_QUALITY_LOW, N_("quality|Low"), NULL },
{ GIMP_ZOOM_QUALITY_HIGH, N_("quality|High"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpZoomQuality", values);
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
/* Generated data ends here */

View File

@ -58,4 +58,15 @@ typedef enum
} GimpSpaceBarAction;
#define GIMP_TYPE_ZOOM_QUALITY (gimp_zoom_quality_get_type ())
GType gimp_zoom_quality_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_ZOOM_QUALITY_LOW, /*< desc="quality|Low" >*/
GIMP_ZOOM_QUALITY_HIGH /*< desc="quality|High" >*/
} GimpZoomQuality;
#endif /* __DISPLAY_ENUMS_H__ */

View File

@ -114,6 +114,9 @@ static void gimp_display_shell_padding_notify_handler (GObject *c
static void gimp_display_shell_ants_speed_notify_handler (GObject *config,
GParamSpec *param_spec,
GimpDisplayShell *shell);
static void gimp_display_shell_quality_notify_handler (GObject *config,
GParamSpec *param_spec,
GimpDisplayShell *shell);
static gboolean gimp_display_shell_idle_update_icon (gpointer data);
@ -250,6 +253,11 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
G_CALLBACK (gimp_display_shell_ants_speed_notify_handler),
shell);
g_signal_connect (image->gimp->config,
"notify::zoom-quality",
G_CALLBACK (gimp_display_shell_quality_notify_handler),
shell);
gimp_display_shell_invalidate_preview_handler (image, shell);
gimp_display_shell_quick_mask_changed_handler (image, shell);
}
@ -286,6 +294,9 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
shell->pen_gc = NULL;
}
g_signal_handlers_disconnect_by_func (image->gimp->config,
gimp_display_shell_quality_notify_handler,
shell);
g_signal_handlers_disconnect_by_func (image->gimp->config,
gimp_display_shell_ants_speed_notify_handler,
shell);
@ -672,6 +683,14 @@ gimp_display_shell_ants_speed_notify_handler (GObject *config,
gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME);
}
static void
gimp_display_shell_quality_notify_handler (GObject *config,
GParamSpec *param_spec,
GimpDisplayShell *shell)
{
gimp_display_shell_expose_full (shell);
}
static gboolean
gimp_display_shell_idle_update_icon (gpointer data)
{

View File

@ -31,6 +31,8 @@
#include "base/tile-manager.h"
#include "base/tile.h"
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
@ -54,10 +56,6 @@
100% and 200% zoom)
*/
/* The default settings are debatable, and perhaps this should even somehow be
* configurable by the user. */
static gint gimp_zoom_quality = GIMP_DISPLAY_ZOOM_PIXEL_AA;
typedef struct _RenderInfo RenderInfo;
typedef void (* RenderFunc) (RenderInfo *info);
@ -79,6 +77,8 @@ struct _RenderInfo
gint dest_bpl;
gint dest_width;
gint zoom_quality;
/* Bresenham helpers */
gint x_dest_inc; /* amount to increment for each dest. pixel */
gint x_src_dec; /* amount to decrement for each source pixel */
@ -216,12 +216,15 @@ gimp_display_shell_render (GimpDisplayShell *shell,
GdkRectangle *highlight)
{
GimpProjection *projection;
GimpImage *image;
RenderInfo info;
GimpImageType type;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (w > 0 && h > 0);
projection = shell->display->image->projection;
image = shell->display->image;
projection = image->projection;
/* Initialize RenderInfo with values that don't change during the
* call of this function.
@ -237,6 +240,17 @@ gimp_display_shell_render (GimpDisplayShell *shell,
info.dest_bpl = info.dest_bpp * GIMP_RENDER_BUF_WIDTH;
info.dest_width = info.dest_bpp * info.w;
switch (GIMP_DISPLAY_CONFIG (image->gimp->config)->zoom_quality)
{
case GIMP_ZOOM_QUALITY_LOW:
info.zoom_quality = GIMP_DISPLAY_ZOOM_FAST;
break;
case GIMP_ZOOM_QUALITY_HIGH:
info.zoom_quality = GIMP_DISPLAY_ZOOM_PIXEL_AA;
break;
}
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_projection_get_image_type (projection)))
{
gdouble opacity = gimp_projection_get_opacity (projection);
@ -244,6 +258,8 @@ gimp_display_shell_render (GimpDisplayShell *shell,
info.alpha = render_image_init_alpha (opacity * 255.999);
}
/* Setup RenderInfo for rendering a GimpProjection level. */
{
TileManager *src_tiles;
@ -828,11 +844,11 @@ render_image_tile_fault (RenderInfo *info)
guint source_width;
guint source_height;
source_width = tile_manager_width (info->src_tiles);
source_width = tile_manager_width (info->src_tiles);
source_height = tile_manager_height (info->src_tiles);
/* dispatch to fast path functions on special conditions */
if ((gimp_zoom_quality & GIMP_DISPLAY_ZOOM_FAST)
if ((info->zoom_quality & GIMP_DISPLAY_ZOOM_FAST)
/* use nearest neighbour for exact levels */
|| (info->scalex == 1.0 &&
@ -841,7 +857,7 @@ render_image_tile_fault (RenderInfo *info)
/* or when we're larger than 1.0 and not using any AA */
|| (info->shell->scale_x > 1.0 &&
info->shell->scale_y > 1.0 &&
(!(gimp_zoom_quality & GIMP_DISPLAY_ZOOM_PIXEL_AA)))
(! (info->zoom_quality & GIMP_DISPLAY_ZOOM_PIXEL_AA)))
/* or at any point when both scale factors are greater or equal to 200% */
|| (info->shell->scale_x >= 2.0 &&

View File

@ -110,6 +110,7 @@ gimp_display_shell_transform_xy (GimpDisplayShell *shell,
item = GIMP_ITEM (gimp_image_get_active_drawable (shell->display->image));
gimp_item_offsets (item, &offset_x, &offset_y);
x += offset_x;
y += offset_y;
}
@ -313,11 +314,15 @@ gimp_display_shell_transform_points (GimpDisplayShell *shell,
x = points[i*2] + offset_x;
y = points[i*2+1] + offset_y;
x = PROJ_ROUND64 (shell->x_src_dec * x + (shell->x_dest_inc >> 1) - 1) / shell->x_dest_inc;
y = PROJ_ROUND64 (shell->y_src_dec * y + (shell->y_dest_inc >> 1) - 1) / shell->y_dest_inc;
x = PROJ_ROUND64 (shell->x_src_dec * x +
(shell->x_dest_inc >> 1) - 1) / shell->x_dest_inc;
y = PROJ_ROUND64 (shell->y_src_dec * y +
(shell->y_dest_inc >> 1) - 1) / shell->y_dest_inc;
coords[i].x = CLAMP (x + shell->disp_xoffset - shell->offset_x, G_MININT, G_MAXINT);
coords[i].y = CLAMP (y + shell->disp_yoffset - shell->offset_y, G_MININT, G_MAXINT);
coords[i].x = CLAMP (x + shell->disp_xoffset - shell->offset_x,
G_MININT, G_MAXINT);
coords[i].y = CLAMP (y + shell->disp_yoffset - shell->offset_y,
G_MININT, G_MAXINT);
}
}
@ -361,11 +366,15 @@ gimp_display_shell_transform_coords (GimpDisplayShell *shell,
x = image_coords[i].x + offset_x;
y = image_coords[i].y + offset_y;
x = PROJ_ROUND64 (shell->x_src_dec * x + (shell->x_dest_inc >> 1) - 1) / shell->x_dest_inc;
y = PROJ_ROUND64 (shell->y_src_dec * y + (shell->y_dest_inc >> 1) - 1) / shell->y_dest_inc;
x = PROJ_ROUND64 (shell->x_src_dec * x +
(shell->x_dest_inc >> 1) - 1) / shell->x_dest_inc;
y = PROJ_ROUND64 (shell->y_src_dec * y +
(shell->y_dest_inc >> 1) - 1) / shell->y_dest_inc;
disp_coords[i].x = CLAMP (x + shell->disp_xoffset - shell->offset_x, G_MININT, G_MAXINT);
disp_coords[i].y = CLAMP (y + shell->disp_yoffset - shell->offset_y, G_MININT, G_MAXINT);
disp_coords[i].x = CLAMP (x + shell->disp_xoffset - shell->offset_x,
G_MININT, G_MAXINT);
disp_coords[i].y = CLAMP (y + shell->disp_yoffset - shell->offset_y,
G_MININT, G_MAXINT);
}
}
@ -412,15 +421,23 @@ gimp_display_shell_transform_segments (GimpDisplayShell *shell,
y1 = src_segs[i].y1 + offset_y;
y2 = src_segs[i].y2 + offset_y;
x1 = (x1 * shell->x_src_dec + (shell->x_dest_inc >> 1) - 1) / shell->x_dest_inc;
x2 = (x2 * shell->x_src_dec + (shell->x_dest_inc >> 1) - 1) / shell->x_dest_inc;
y1 = (y1 * shell->y_src_dec + (shell->y_dest_inc >> 1) - 1) / shell->y_dest_inc;
y2 = (y2 * shell->y_src_dec + (shell->y_dest_inc >> 1) - 1) / shell->y_dest_inc;
x1 = (x1 * shell->x_src_dec +
(shell->x_dest_inc >> 1) - 1) / shell->x_dest_inc;
x2 = (x2 * shell->x_src_dec +
(shell->x_dest_inc >> 1) - 1) / shell->x_dest_inc;
y1 = (y1 * shell->y_src_dec +
(shell->y_dest_inc >> 1) - 1) / shell->y_dest_inc;
y2 = (y2 * shell->y_src_dec +
(shell->y_dest_inc >> 1) - 1) / shell->y_dest_inc;
dest_segs[i].x1 = CLAMP (x1 + shell->disp_xoffset - shell->offset_x, G_MININT, G_MAXINT);
dest_segs[i].x2 = CLAMP (x2 + shell->disp_xoffset - shell->offset_x, G_MININT, G_MAXINT);
dest_segs[i].y1 = CLAMP (y1 + shell->disp_yoffset - shell->offset_y, G_MININT, G_MAXINT);
dest_segs[i].y2 = CLAMP (y2 + shell->disp_yoffset - shell->offset_y, G_MININT, G_MAXINT);
dest_segs[i].x1 = CLAMP (x1 + shell->disp_xoffset - shell->offset_x,
G_MININT, G_MAXINT);
dest_segs[i].x2 = CLAMP (x2 + shell->disp_xoffset - shell->offset_x,
G_MININT, G_MAXINT);
dest_segs[i].y1 = CLAMP (y1 + shell->disp_yoffset - shell->offset_y,
G_MININT, G_MAXINT);
dest_segs[i].y2 = CLAMP (y2 + shell->disp_yoffset - shell->offset_y,
G_MININT, G_MAXINT);
}
}