modules: various changes in clip-warning

Replace "Show NaN" option with "Show bogus".  Bogus values include
infinities, in addition to NaN.

Don't blend the bogus warning color with other warning colors, when
a pixel has both a bogus component, and a shadow/highlight
component.  The bogus warning always takes precedence.

Rename "Include alpha" option to "Include alpha component".

Remove "Opaque" option.  Warnings are now always opaue, even for
non-opaque pixels.

Add "Include transparent pixels" option, which controls whether
fully-transparent pixels are included in the warning.  A fully
transparent pixel is a pixel whose alpha component is less-than or
equal-to zero (note that this doesn't include a NaN alpha
component.)
This commit is contained in:
Ell
2017-11-07 08:55:49 -05:00
parent c97c2fe06d
commit e2fb7a41c6

View File

@ -34,7 +34,7 @@
#define DEFAULT_SHADOWS_COLOR (&(GimpRGB) {0.25, 0.25, 1.00, 1.00}) #define DEFAULT_SHADOWS_COLOR (&(GimpRGB) {0.25, 0.25, 1.00, 1.00})
#define DEFAULT_HIGHLIGHTS_COLOR (&(GimpRGB) {1.00, 0.25, 0.25, 1.00}) #define DEFAULT_HIGHLIGHTS_COLOR (&(GimpRGB) {1.00, 0.25, 0.25, 1.00})
#define DEFAULT_NAN_COLOR (&(GimpRGB) {1.00, 1.00, 0.25, 1.00}) #define DEFAULT_BOGUS_COLOR (&(GimpRGB) {1.00, 1.00, 0.25, 1.00})
#define CDISPLAY_TYPE_CLIP_WARNING (cdisplay_clip_warning_get_type ()) #define CDISPLAY_TYPE_CLIP_WARNING (cdisplay_clip_warning_get_type ())
@ -48,7 +48,7 @@ typedef enum
{ {
WARNING_SHADOW = 1 << 0, WARNING_SHADOW = 1 << 0,
WARNING_HIGHLIGHT = 1 << 1, WARNING_HIGHLIGHT = 1 << 1,
WARNING_NAN = 1 << 2 WARNING_BOGUS = 1 << 2
} Warning; } Warning;
@ -63,10 +63,10 @@ struct _CdisplayClipWarning
GimpRGB shadows_color; GimpRGB shadows_color;
gboolean show_highlights; gboolean show_highlights;
GimpRGB highlights_color; GimpRGB highlights_color;
gboolean show_nan; gboolean show_bogus;
GimpRGB nan_color; GimpRGB bogus_color;
gboolean include_alpha; gboolean include_alpha;
gboolean opaque; gboolean include_transparent;
gfloat colors[8][2][4]; gfloat colors[8][2][4];
}; };
@ -84,10 +84,10 @@ enum
PROP_SHADOWS_COLOR, PROP_SHADOWS_COLOR,
PROP_SHOW_HIGHLIGHTS, PROP_SHOW_HIGHLIGHTS,
PROP_HIGHLIGHTS_COLOR, PROP_HIGHLIGHTS_COLOR,
PROP_SHOW_NAN, PROP_SHOW_BOGUS,
PROP_NAN_COLOR, PROP_BOGUS_COLOR,
PROP_INCLUDE_ALPHA, PROP_INCLUDE_ALPHA,
PROP_OPAQUE PROP_INCLUDE_TRANSPARENT
}; };
@ -192,37 +192,37 @@ cdisplay_clip_warning_class_init (CdisplayClipWarningClass *klass)
g_object_class_find_property (G_OBJECT_CLASS (klass), "highlights-color"), g_object_class_find_property (G_OBJECT_CLASS (klass), "highlights-color"),
"sensitive", "show-highlights"); "sensitive", "show-highlights");
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_NAN, GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_BOGUS,
"show-nan", "show-bogus",
_("Show NaN"), _("Show bogus"),
_("Show warning for pixels with a NaN component"), _("Show warning for pixels with an infinite or NaN component"),
TRUE, TRUE,
GIMP_PARAM_STATIC_STRINGS); GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_RGB (object_class, PROP_NAN_COLOR, GIMP_CONFIG_PROP_RGB (object_class, PROP_BOGUS_COLOR,
"nan-color", "bogus-color",
_("NaN color"), _("Bogus color"),
_("NaN warning color"), _("Bogus warning color"),
FALSE, FALSE,
DEFAULT_NAN_COLOR, DEFAULT_BOGUS_COLOR,
GIMP_PARAM_STATIC_STRINGS | GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_DEFAULTS); GIMP_CONFIG_PARAM_DEFAULTS);
gegl_param_spec_set_property_key ( gegl_param_spec_set_property_key (
g_object_class_find_property (G_OBJECT_CLASS (klass), "nan-color"), g_object_class_find_property (G_OBJECT_CLASS (klass), "bogus-color"),
"sensitive", "show-nan"); "sensitive", "show-bogus");
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_INCLUDE_ALPHA, GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_INCLUDE_ALPHA,
"include-alpha", "include-alpha",
_("Include alpha"), _("Include alpha component"),
_("Include alpha component in the warning"), _("Include alpha component in the warning"),
TRUE, TRUE,
GIMP_PARAM_STATIC_STRINGS); GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_OPAQUE, GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_INCLUDE_TRANSPARENT,
"opaque", "include-transparent",
_("Opaque"), _("Include transparent pixels"),
_("Make warning pixels opaque"), _("Include fully transparent pixels in the warning"),
TRUE, TRUE,
GIMP_PARAM_STATIC_STRINGS); GIMP_PARAM_STATIC_STRINGS);
@ -267,18 +267,18 @@ cdisplay_clip_warning_get_property (GObject *object,
g_value_set_boxed (value, &clip_warning->highlights_color); g_value_set_boxed (value, &clip_warning->highlights_color);
break; break;
case PROP_SHOW_NAN: case PROP_SHOW_BOGUS:
g_value_set_boolean (value, clip_warning->show_nan); g_value_set_boolean (value, clip_warning->show_bogus);
break; break;
case PROP_NAN_COLOR: case PROP_BOGUS_COLOR:
g_value_set_boxed (value, &clip_warning->nan_color); g_value_set_boxed (value, &clip_warning->bogus_color);
break; break;
case PROP_INCLUDE_ALPHA: case PROP_INCLUDE_ALPHA:
g_value_set_boolean (value, clip_warning->include_alpha); g_value_set_boolean (value, clip_warning->include_alpha);
break; break;
case PROP_OPAQUE: case PROP_INCLUDE_TRANSPARENT:
g_value_set_boolean (value, clip_warning->opaque); g_value_set_boolean (value, clip_warning->include_transparent);
break; break;
default: default:
@ -320,18 +320,18 @@ cdisplay_clip_warning_set_property (GObject *object,
SET_MEMBER_PTR (highlights_color, g_value_get_boxed (value)); SET_MEMBER_PTR (highlights_color, g_value_get_boxed (value));
break; break;
case PROP_SHOW_NAN: case PROP_SHOW_BOGUS:
SET_MEMBER_VAL (show_nan, gboolean, g_value_get_boolean (value)); SET_MEMBER_VAL (show_bogus, gboolean, g_value_get_boolean (value));
break; break;
case PROP_NAN_COLOR: case PROP_BOGUS_COLOR:
SET_MEMBER_PTR (nan_color, g_value_get_boxed (value)); SET_MEMBER_PTR (bogus_color, g_value_get_boxed (value));
break; break;
case PROP_INCLUDE_ALPHA: case PROP_INCLUDE_ALPHA:
SET_MEMBER_VAL (include_alpha, gboolean, g_value_get_boolean (value)); SET_MEMBER_VAL (include_alpha, gboolean, g_value_get_boolean (value));
break; break;
case PROP_OPAQUE: case PROP_INCLUDE_TRANSPARENT:
SET_MEMBER_VAL (opaque, gboolean, g_value_get_boolean (value)); SET_MEMBER_VAL (include_transparent, gboolean, g_value_get_boolean (value));
break; break;
default: default:
@ -365,45 +365,35 @@ cdisplay_clip_warning_convert_buffer (GimpColorDisplay *display,
while (count--) while (count--)
{ {
gint warning = 0; gint warning = 0;
gint n_components = clip_warning->opaque ? 4 : 3;
if (clip_warning->show_shadows) if (clip_warning->include_transparent ||
! (data[3] <= 0.0f) /* include nan */)
{ {
if (clip_warning->include_alpha && data[3] < 0.0f) if (clip_warning->show_bogus &&
(! isfinite (data[0]) || ! isfinite (data[1]) || ! isfinite (data[2]) ||
(clip_warning->include_alpha && ! isfinite (data[3]))))
{ {
warning |= WARNING_SHADOW; /* don't combine warning color of pixels with a bogus
n_components = 4; * component with other warnings
*/
warning = WARNING_BOGUS;
} }
else if (data[0] < 0.0f || data[1] < 0.0f || data[2] < 0.0f) else
{
if (clip_warning->show_shadows &&
(data[0] < 0.0f || data[1] < 0.0f || data[2] < 0.0f ||
(clip_warning->include_alpha && data[3] < 0.0f)))
{ {
warning |= WARNING_SHADOW; warning |= WARNING_SHADOW;
} }
}
if (clip_warning->show_highlights) if (clip_warning->show_highlights &&
{ (data[0] > 1.0f || data[1] > 1.0f || data[2] > 1.0f ||
if (clip_warning->include_alpha && data[3] > 1.0f) (clip_warning->include_alpha && data[3] > 1.0f)))
{
warning |= WARNING_HIGHLIGHT;
n_components = 4;
}
else if (data[0] > 1.0f || data[1] > 1.0f || data[2] > 1.0f)
{ {
warning |= WARNING_HIGHLIGHT; warning |= WARNING_HIGHLIGHT;
} }
} }
if (clip_warning->show_nan)
{
if (clip_warning->include_alpha && isnan (data[3]))
{
warning |= WARNING_NAN;
n_components = 4;
}
else if (isnan (data[0]) || isnan (data[1]) || isnan (data[2]))
{
warning |= WARNING_NAN;
}
} }
if (warning) if (warning)
@ -411,7 +401,7 @@ cdisplay_clip_warning_convert_buffer (GimpColorDisplay *display,
gboolean alt = ((x + y) >> 3) & 1; gboolean alt = ((x + y) >> 3) & 1;
memcpy (data, clip_warning->colors[warning][alt], memcpy (data, clip_warning->colors[warning][alt],
n_components * sizeof (gfloat)); 4 * sizeof (gfloat));
} }
data += 4; data += 4;
@ -476,11 +466,11 @@ cdisplay_clip_warning_update_colors (CdisplayClipWarning *clip_warning)
n++; n++;
} }
if (i & WARNING_NAN) if (i & WARNING_BOGUS)
{ {
color[0] += clip_warning->nan_color.r; color[0] += clip_warning->bogus_color.r;
color[1] += clip_warning->nan_color.g; color[1] += clip_warning->bogus_color.g;
color[2] += clip_warning->nan_color.b; color[2] += clip_warning->bogus_color.b;
n++; n++;
} }