diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c index ea319b437e..9849d65308 100644 --- a/app/display/gimpdisplayshell-handlers.c +++ b/app/display/gimpdisplayshell-handlers.c @@ -117,6 +117,8 @@ static void gimp_display_shell_sample_point_move_handler (GimpImage *i GimpDisplayShell *shell); static void gimp_display_shell_invalidate_preview_handler (GimpImage *image, GimpDisplayShell *shell); +static void gimp_display_shell_precision_changed_handler (GimpImage *image, + GimpDisplayShell *shell); static void gimp_display_shell_profile_changed_handler (GimpColorManaged *image, GimpDisplayShell *shell); static void gimp_display_shell_saved_handler (GimpImage *image, @@ -251,9 +253,15 @@ gimp_display_shell_connect (GimpDisplayShell *shell) g_signal_connect (image, "invalidate-preview", G_CALLBACK (gimp_display_shell_invalidate_preview_handler), shell); + g_signal_connect (image, "precision-changed", + G_CALLBACK (gimp_display_shell_precision_changed_handler), + shell); g_signal_connect (image, "profile-changed", G_CALLBACK (gimp_display_shell_profile_changed_handler), shell); + g_signal_connect (image, "precision-changed", + G_CALLBACK (gimp_display_shell_precision_changed_handler), + shell); g_signal_connect (image, "saved", G_CALLBACK (gimp_display_shell_saved_handler), shell); @@ -453,6 +461,9 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell) g_signal_handlers_disconnect_by_func (image, gimp_display_shell_profile_changed_handler, shell); + g_signal_handlers_disconnect_by_func (image, + gimp_display_shell_precision_changed_handler, + shell); g_signal_handlers_disconnect_by_func (image, gimp_display_shell_invalidate_preview_handler, shell); @@ -790,6 +801,13 @@ gimp_display_shell_invalidate_preview_handler (GimpImage *image, gimp_display_shell_icon_update (shell); } +static void +gimp_display_shell_precision_changed_handler (GimpImage *image, + GimpDisplayShell *shell) +{ + gimp_display_shell_profile_update (shell); +} + static void gimp_display_shell_profile_changed_handler (GimpColorManaged *image, GimpDisplayShell *shell) @@ -797,7 +815,6 @@ gimp_display_shell_profile_changed_handler (GimpColorManaged *image, gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (shell)); } - static void gimp_display_shell_saved_handler (GimpImage *image, GFile *file, diff --git a/app/display/gimpdisplayshell-profile.c b/app/display/gimpdisplayshell-profile.c index 699e9dc940..38cc9e2891 100644 --- a/app/display/gimpdisplayshell-profile.c +++ b/app/display/gimpdisplayshell-profile.c @@ -34,6 +34,7 @@ #include "gegl/gimp-babl.h" +#include "core/gimpimage.h" #include "core/gimppickable.h" #include "gimpdisplay.h" @@ -92,10 +93,15 @@ gimp_display_shell_profile_update (GimpDisplayShell *shell) gimp_image_get_precision (image), TRUE); - if (gimp_display_shell_has_filter (shell)) - dest_format = shell->filter_format; + if (gimp_display_shell_has_filter (shell) || + ! gimp_display_shell_profile_can_convert_to_u8 (shell)) + { + dest_format = shell->filter_format; + } else - dest_format = babl_format ("R'G'B'A u8"); + { + dest_format = babl_format ("R'G'B'A u8"); + } g_printerr ("src_format: %s\n", babl_get_name (src_format)); g_printerr ("dest_format: %s\n", babl_get_name (dest_format)); @@ -130,6 +136,30 @@ gimp_display_shell_profile_update (GimpDisplayShell *shell) } } +gboolean +gimp_display_shell_profile_can_convert_to_u8 (GimpDisplayShell *shell) +{ + GimpImage *image; + + image = gimp_display_get_image (shell->display); + + if (image) + { + switch (gimp_image_get_component_type (image)) + { + case GIMP_COMPONENT_TYPE_U8: + case GIMP_COMPONENT_TYPE_U16: + case GIMP_COMPONENT_TYPE_U32: + return TRUE; + + default: + break; + } + } + + return FALSE; +} + void gimp_display_shell_profile_convert_buffer (GimpDisplayShell *shell, GeglBuffer *src_buffer, diff --git a/app/display/gimpdisplayshell-profile.h b/app/display/gimpdisplayshell-profile.h index 09f2ea9ec5..a961f6c4b5 100644 --- a/app/display/gimpdisplayshell-profile.h +++ b/app/display/gimpdisplayshell-profile.h @@ -19,14 +19,16 @@ #define __GIMP_DISPLAY_SHELL_PROFILE_H__ -void gimp_display_shell_profile_dispose (GimpDisplayShell *shell); -void gimp_display_shell_profile_update (GimpDisplayShell *shell); +void gimp_display_shell_profile_dispose (GimpDisplayShell *shell); +void gimp_display_shell_profile_update (GimpDisplayShell *shell); -void gimp_display_shell_profile_convert_buffer (GimpDisplayShell *shell, - GeglBuffer *src_buffer, - GeglRectangle *src_area, - GeglBuffer *dest_buffer, - GeglRectangle *dest_area); +gboolean gimp_display_shell_profile_can_convert_to_u8 (GimpDisplayShell *shell); + +void gimp_display_shell_profile_convert_buffer (GimpDisplayShell *shell, + GeglBuffer *src_buffer, + GeglRectangle *src_area, + GeglBuffer *dest_buffer, + GeglRectangle *dest_area); #endif /* __GIMP_DISPLAY_SHELL_PROFILE_H__ */ diff --git a/app/display/gimpdisplayshell-render.c b/app/display/gimpdisplayshell-render.c index 9936876bdf..6fa65e5d00 100644 --- a/app/display/gimpdisplayshell-render.c +++ b/app/display/gimpdisplayshell-render.c @@ -163,13 +163,17 @@ gimp_display_shell_render (GimpDisplayShell *shell, if (shell->profile_transform || gimp_display_shell_has_filter (shell)) { + gboolean can_convert_to_u8; + /* if there is a profile transform or a display filter, we need * to use temp buffers */ + can_convert_to_u8 = gimp_display_shell_profile_can_convert_to_u8 (shell); + /* create the filter buffer if we have filters */ - if (gimp_display_shell_has_filter (shell) && + if ((gimp_display_shell_has_filter (shell) || ! can_convert_to_u8) && ! shell->filter_buffer) { gint w = GIMP_DISPLAY_RENDER_BUF_WIDTH * GIMP_DISPLAY_RENDER_MAX_SCALE; @@ -213,7 +217,7 @@ gimp_display_shell_render (GimpDisplayShell *shell, GEGL_BLIT_CACHE); #endif - if (gimp_display_shell_has_filter (shell)) + if (gimp_display_shell_has_filter (shell) || ! can_convert_to_u8) { /* if there are filters, convert the pixels from the * profile_buffer to the filter_buffer @@ -277,7 +281,10 @@ gimp_display_shell_render (GimpDisplayShell *shell, GEGL_RECTANGLE (0, 0, scaled_width, scaled_height)); + } + if (gimp_display_shell_has_filter (shell) || ! can_convert_to_u8) + { /* finally, copy the filter buffer to the cairo-ARGB32 buffer */ gegl_buffer_get (shell->filter_buffer,