app: fix out-of-bounds rendering when alpha channel is invisible
When the image's alpha channel is invisible, paint regions outside the image contents as black, instead of using a checkboard pattern. This is especially notable when viewing the image in "show all" mode.
This commit is contained in:
@ -29,6 +29,7 @@
|
||||
|
||||
#include "core/gimp-cairo.h"
|
||||
#include "core/gimp-utils.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gimpcanvas.h"
|
||||
#include "gimpcanvas-style.h"
|
||||
@ -87,9 +88,13 @@ void
|
||||
gimp_display_shell_draw_checkerboard (GimpDisplayShell *shell,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GimpImage *image;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
image = gimp_display_get_image (shell->display);
|
||||
|
||||
if (G_UNLIKELY (! shell->checkerboard))
|
||||
{
|
||||
GimpCheckSize check_size;
|
||||
@ -114,7 +119,12 @@ gimp_display_shell_draw_checkerboard (GimpDisplayShell *shell,
|
||||
}
|
||||
|
||||
cairo_translate (cr, - shell->offset_x, - shell->offset_y);
|
||||
cairo_set_source (cr, shell->checkerboard);
|
||||
|
||||
if (gimp_image_get_component_visible (image, GIMP_CHANNEL_ALPHA))
|
||||
cairo_set_source (cr, shell->checkerboard);
|
||||
else
|
||||
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
|
||||
|
||||
cairo_paint (cr);
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,10 @@ static void gimp_display_shell_name_changed_handler (GimpImage *i
|
||||
static void gimp_display_shell_selection_invalidate_handler
|
||||
(GimpImage *image,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_component_visibility_changed_handler
|
||||
(GimpImage *image,
|
||||
GimpChannelType channel,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_size_changed_detailed_handler
|
||||
(GimpImage *image,
|
||||
gint previous_origin_x,
|
||||
@ -220,6 +224,9 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
|
||||
g_signal_connect (image, "selection-invalidate",
|
||||
G_CALLBACK (gimp_display_shell_selection_invalidate_handler),
|
||||
shell);
|
||||
g_signal_connect (image, "component-visibility-changed",
|
||||
G_CALLBACK (gimp_display_shell_component_visibility_changed_handler),
|
||||
shell);
|
||||
g_signal_connect (image, "size-changed-detailed",
|
||||
G_CALLBACK (gimp_display_shell_size_changed_detailed_handler),
|
||||
shell);
|
||||
@ -545,6 +552,9 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_resolution_changed_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_component_visibility_changed_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_size_changed_detailed_handler,
|
||||
shell);
|
||||
@ -799,6 +809,15 @@ gimp_display_shell_sample_point_move_handler (GimpImage *image,
|
||||
gimp_canvas_sample_point_set (item, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_component_visibility_changed_handler (GimpImage *image,
|
||||
GimpChannelType channel,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
if (channel == GIMP_CHANNEL_ALPHA && shell->show_all)
|
||||
gimp_display_shell_expose_full (shell);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_size_changed_detailed_handler (GimpImage *image,
|
||||
gint previous_origin_x,
|
||||
|
Reference in New Issue
Block a user