app, pdb, libgimp: remove the "plug-in precision-enabled" API and logic

There is no old way of accessing pixels any longer, all plug-ins are
now precsion-enabled.
This commit is contained in:
Michael Natterer 2019-07-20 01:53:31 +02:00
parent 3811a65218
commit b2f660ae43
19 changed files with 10 additions and 361 deletions

View File

@ -71,9 +71,6 @@ drawable_get_format_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
/* this only transfers the encoding, losing the space, see the
* code in libgimp/gimpdrawable.c which reconstructs the actual
* format in the plug-in process
@ -315,12 +312,6 @@ drawable_bpp_invoker (GimpProcedure *procedure,
{
const Babl *format = gimp_drawable_get_format (drawable);
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
format = gimp_babl_compat_u8_format (format);
}
bpp = babl_format_get_bytes_per_pixel (format);
}
@ -625,12 +616,6 @@ drawable_get_pixel_invoker (GimpProcedure *procedure,
{
const Babl *format = gimp_drawable_get_format (drawable);
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
format = gimp_babl_compat_u8_format (format);
}
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{
@ -682,12 +667,6 @@ drawable_set_pixel_invoker (GimpProcedure *procedure,
{
const Babl *format = gimp_drawable_get_format (drawable);
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
format = gimp_babl_compat_u8_format (format);
}
if (gimp_pdb_item_is_modifiable (GIMP_ITEM (drawable),
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
@ -1246,7 +1225,7 @@ register_drawable_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-bpp",
"Returns the bytes per pixel.",
"This procedure returns the number of bytes per pixel, which corresponds to the number of components unless 'gimp-plugin-enable-precision' was called.",
"This procedure returns the number of bytes per pixel.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",

View File

@ -42,8 +42,6 @@
#include "operations/gimpcurvesconfig.h"
#include "operations/gimphuesaturationconfig.h"
#include "operations/gimplevelsconfig.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
#include "gimppdb.h"
#include "gimppdb-utils.h"
@ -404,18 +402,10 @@ drawable_histogram_invoker (GimpProcedure *procedure,
GimpHistogram *histogram;
gint n_bins;
gint start;
gboolean precision_enabled;
GimpTRCType trc;
gint end;
precision_enabled =
gimp->plug_in_manager->current_plug_in &&
gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in);
if (precision_enabled)
trc = gimp_drawable_get_trc (drawable);
else
trc = GIMP_TRC_NON_LINEAR;
trc = gimp_drawable_get_trc (drawable);
histogram = gimp_histogram_new (trc);
gimp_drawable_calculate_histogram (drawable, histogram, FALSE);
@ -438,7 +428,7 @@ drawable_histogram_invoker (GimpProcedure *procedure,
g_object_unref (histogram);
if (n_bins == 256 || ! precision_enabled)
if (n_bins == 256)
{
mean *= 255;
std_dev *= 255;

View File

@ -194,9 +194,6 @@ image_new_with_precision_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
if (gimp_babl_is_valid (type, precision))
{
image = gimp_create_image (gimp, width, height, type,
@ -320,9 +317,6 @@ image_get_precision_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
precision = gimp_image_get_precision (image);
}

View File

@ -36,8 +36,6 @@
#include "core/gimppalette.h"
#include "core/gimpparamspecs.h"
#include "gegl/gimp-babl.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
#include "gimppdb.h"
#include "gimppdberror.h"
@ -242,9 +240,6 @@ image_convert_precision_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
gimp_pdb_image_is_not_precision (image, precision, error) &&
gimp_babl_is_valid (gimp_image_get_base_type (image), precision))

View File

@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 745 procedures registered total */
/* 743 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View File

@ -344,62 +344,6 @@ plugin_get_pdb_error_handler_invoker (GimpProcedure *procedure,
return return_vals;
}
static GimpValueArray *
plugin_enable_precision_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in)
{
gimp_plug_in_enable_precision (plug_in);
}
else
{
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plugin_precision_enabled_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
gboolean enabled = FALSE;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in)
{
enabled = gimp_plug_in_precision_enabled (plug_in);
}
else
{
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (gimp_value_array_index (return_vals, 1), enabled);
return return_vals;
}
void
register_plug_in_procs (GimpPDB *pdb)
{
@ -708,44 +652,4 @@ register_plug_in_procs (GimpPDB *pdb)
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plugin-enable-precision
*/
procedure = gimp_procedure_new (plugin_enable_precision_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-plugin-enable-precision");
gimp_procedure_set_static_strings (procedure,
"gimp-plugin-enable-precision",
"Switches this plug-in to using the real bit depth of drawables.",
"Switches this plug-in to using the real bit depth of drawables. This setting can only be enabled, and not disabled again during the lifetime of the plug-in. Using 'gimp-drawable-get-buffer', 'gimp-drawable-get-shadow-buffer' or 'gimp-drawable-get-format' will automatically call this function.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2012",
NULL);
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plugin-precision-enabled
*/
procedure = gimp_procedure_new (plugin_precision_enabled_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-plugin-precision-enabled");
gimp_procedure_set_static_strings (procedure,
"gimp-plugin-precision-enabled",
"Whether this plug-in is using the real bit depth of drawables.",
"Returns whether this plug-in is using the real bit depth of drawables, which can be more than 8 bits per channel.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2012",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("enabled",
"enabled",
"Whether precision is enabled",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

View File

@ -315,11 +315,6 @@ gimp_plug_in_handle_tile_put (GimpPlugIn *plug_in,
format = gegl_buffer_get_format (buffer);
if (! gimp_plug_in_precision_enabled (plug_in))
{
format = gimp_babl_compat_u8_format (format);
}
if (tile_data.use_shm)
{
gegl_buffer_set (buffer, &tile_rect, 0, format,
@ -411,11 +406,6 @@ gimp_plug_in_handle_tile_get (GimpPlugIn *plug_in,
format = gegl_buffer_get_format (buffer);
if (! gimp_plug_in_precision_enabled (plug_in))
{
format = gimp_babl_compat_u8_format (format);
}
tile_size = (babl_format_get_bytes_per_pixel (format) *
tile_rect.width * tile_rect.height);

View File

@ -1047,19 +1047,3 @@ gimp_plug_in_get_error_handler (GimpPlugIn *plug_in)
return GIMP_PDB_ERROR_HANDLER_INTERNAL;
}
void
gimp_plug_in_enable_precision (GimpPlugIn *plug_in)
{
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
plug_in->precision = TRUE;
}
gboolean
gimp_plug_in_precision_enabled (GimpPlugIn *plug_in)
{
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
return plug_in->precision;
}

View File

@ -47,7 +47,6 @@ struct _GimpPlugIn
GimpPlugInCallMode call_mode; /* QUERY, INIT or RUN */
guint open : 1; /* Is the plug-in open? */
guint hup : 1; /* Did we receive a G_IO_HUP */
guint precision : 1; /* True drawable precision enabled */
GPid pid; /* Plug-in's process id */
GIOChannel *my_read; /* App's read and write channels */
@ -120,8 +119,5 @@ void gimp_plug_in_set_error_handler (GimpPlugIn *plug_in,
GimpPDBErrorHandler
gimp_plug_in_get_error_handler (GimpPlugIn *plug_in);
void gimp_plug_in_enable_precision (GimpPlugIn *plug_in);
gboolean gimp_plug_in_precision_enabled (GimpPlugIn *plug_in);
#endif /* __GIMP_PLUG_IN_H__ */

View File

@ -586,13 +586,11 @@ EXPORTS
gimp_patterns_set_popup
gimp_pencil
gimp_plugin_domain_register
gimp_plugin_enable_precision
gimp_plugin_get_pdb_error_handler
gimp_plugin_help_register
gimp_plugin_icon_register
gimp_plugin_menu_branch_register
gimp_plugin_menu_register
gimp_plugin_precision_enabled
gimp_plugin_set_pdb_error_handler
gimp_procedural_db_dump
gimp_procedural_db_get_data

View File

@ -103,8 +103,6 @@ gimp_drawable_get_sub_thumbnail_data (gint32 drawable_ID,
GeglBuffer *
gimp_drawable_get_buffer (gint32 drawable_ID)
{
gimp_plugin_enable_precision ();
if (gimp_item_is_valid (drawable_ID))
{
GeglTileBackend *backend;
@ -138,8 +136,6 @@ gimp_drawable_get_buffer (gint32 drawable_ID)
GeglBuffer *
gimp_drawable_get_shadow_buffer (gint32 drawable_ID)
{
gimp_plugin_enable_precision ();
if (gimp_item_is_valid (drawable_ID))
{
GeglTileBackend *backend;

View File

@ -299,9 +299,7 @@ gimp_drawable_is_indexed (gint32 drawable_ID)
*
* Returns the bytes per pixel.
*
* This procedure returns the number of bytes per pixel, which
* corresponds to the number of components unless
* gimp_plugin_enable_precision() was called.
* This procedure returns the number of bytes per pixel.
*
* Returns: Bytes per pixel.
**/

View File

@ -291,67 +291,3 @@ gimp_plugin_get_pdb_error_handler (void)
return handler;
}
/**
* gimp_plugin_enable_precision:
*
* Switches this plug-in to using the real bit depth of drawables.
*
* Switches this plug-in to using the real bit depth of drawables. This
* setting can only be enabled, and not disabled again during the
* lifetime of the plug-in. Using gimp_drawable_get_buffer(),
* gimp_drawable_get_shadow_buffer() or gimp_drawable_get_format() will
* automatically call this function.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
gimp_plugin_enable_precision (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-plugin-enable-precision",
&nreturn_vals,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_plugin_precision_enabled:
*
* Whether this plug-in is using the real bit depth of drawables.
*
* Returns whether this plug-in is using the real bit depth of
* drawables, which can be more than 8 bits per channel.
*
* Returns: Whether precision is enabled.
*
* Since: 2.10
**/
gboolean
gimp_plugin_precision_enabled (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean enabled = FALSE;
return_vals = gimp_run_procedure ("gimp-plugin-precision-enabled",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
enabled = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return enabled;
}

View File

@ -46,8 +46,6 @@ G_GNUC_INTERNAL gboolean _gimp_plugin_icon_register (const gchar
const guint8 *icon_data);
gboolean gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler handler);
GimpPDBErrorHandler gimp_plugin_get_pdb_error_handler (void);
gboolean gimp_plugin_enable_precision (void);
gboolean gimp_plugin_precision_enabled (void);
G_END_DECLS

View File

@ -294,9 +294,6 @@ HELP
%invoke = (
code => <<'CODE'
{
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
/* this only transfers the encoding, losing the space, see the
* code in libgimp/gimpdrawable.c which reconstructs the actual
* format in the plug-in process
@ -521,8 +518,7 @@ sub drawable_bpp {
$blurb = 'Returns the bytes per pixel.';
$help = <<'HELP';
This procedure returns the number of bytes per pixel, which corresponds to
the number of components unless gimp_plugin_enable_precision() was called.
This procedure returns the number of bytes per pixel.
HELP
&std_pdb_misc;
@ -542,12 +538,6 @@ HELP
{
const Babl *format = gimp_drawable_get_format (drawable);
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
format = gimp_babl_compat_u8_format (format);
}
bpp = babl_format_get_bytes_per_pixel (format);
}
CODE
@ -669,12 +659,6 @@ HELP
{
const Babl *format = gimp_drawable_get_format (drawable);
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
format = gimp_babl_compat_u8_format (format);
}
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{
@ -723,12 +707,6 @@ HELP
{
const Babl *format = gimp_drawable_get_format (drawable);
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
format = gimp_babl_compat_u8_format (format);
}
if (gimp_pdb_item_is_modifiable (GIMP_ITEM (drawable),
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&

View File

@ -450,18 +450,10 @@ HELP
GimpHistogram *histogram;
gint n_bins;
gint start;
gboolean precision_enabled;
GimpTRCType trc;
gint end;
precision_enabled =
gimp->plug_in_manager->current_plug_in &&
gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in);
if (precision_enabled)
trc = gimp_drawable_get_trc (drawable);
else
trc = GIMP_TRC_NON_LINEAR;
trc = gimp_drawable_get_trc (drawable);
histogram = gimp_histogram_new (trc);
gimp_drawable_calculate_histogram (drawable, histogram, FALSE);
@ -484,7 +476,7 @@ HELP
g_object_unref (histogram);
if (n_bins == 256 || ! precision_enabled)
if (n_bins == 256)
{
mean *= 255;
std_dev *= 255;
@ -814,8 +806,6 @@ CODE
"core/gimp.h"
"core/gimpdrawable.h"
"core/gimpdrawable-operation.h"
"plug-in/gimpplugin.h"
"plug-in/gimppluginmanager.h"
"gimppdb-utils.h"
"gimp-intl.h");

View File

@ -159,9 +159,6 @@ HELP
%invoke = (
code => <<'CODE'
{
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
if (gimp_babl_is_valid (type, precision))
{
image = gimp_create_image (gimp, width, height, type,
@ -1386,9 +1383,6 @@ HELP
%invoke = (
code => <<'CODE'
{
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
precision = gimp_image_get_precision (image);
}
CODE

View File

@ -239,9 +239,6 @@ HELP
%invoke = (
code => <<'CODE'
{
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
gimp_pdb_image_is_not_precision (image, precision, error) &&
gimp_babl_is_valid (gimp_image_get_base_type (image), precision))
@ -269,8 +266,6 @@ CODE
"core/gimpimage-convert-type.h"
"core/gimpitemstack.h"
"core/gimppalette.h"
"plug-in/gimpplugin.h"
"plug-in/gimppluginmanager.h"
"gimppdberror.h"
"gimppdb-utils.h"
"gimp-intl.h");

View File

@ -353,70 +353,6 @@ CODE
);
}
sub plugin_enable_precision {
$blurb = "Switches this plug-in to using the real bit depth of drawables.";
$help = <<HELP;
Switches this plug-in to using the real bit depth of drawables. This
setting can only be enabled, and not disabled again during the
lifetime of the plug-in. Using gimp_drawable_get_buffer(),
gimp_drawable_get_shadow_buffer() or gimp_drawable_get_format() will
automatically call this function.
HELP
&mitch_pdb_misc('2012', '2.10');
%invoke = (
code => <<'CODE'
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in)
{
gimp_plug_in_enable_precision (plug_in);
}
else
{
success = FALSE;
}
}
CODE
);
}
sub plugin_precision_enabled {
$blurb = "Whether this plug-in is using the real bit depth of drawables.";
$help = <<HELP;
Returns whether this plug-in is using the real bit depth of drawables,
which can be more than 8 bits per channel.
HELP
&mitch_pdb_misc('2012', '2.10');
@outargs = (
{ name => 'enabled', type => 'boolean',
desc => "Whether precision is enabled" }
);
%invoke = (
code => <<'CODE'
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in)
{
enabled = gimp_plug_in_precision_enabled (plug_in);
}
else
{
success = FALSE;
}
}
CODE
);
}
@headers = qw(<string.h>
<stdlib.h>
"libgimpbase/gimpbase.h"
@ -435,11 +371,9 @@ CODE
plugin_menu_branch_register
plugin_icon_register
plugin_set_pdb_error_handler
plugin_get_pdb_error_handler
plugin_enable_precision
plugin_precision_enabled);
plugin_get_pdb_error_handler);
%exports = (app => [@procs], lib => [@procs[1,2,3,4,5,6,7,8,9]]);
%exports = (app => [@procs], lib => [@procs[1,2,3,4,5,6,7]]);
$desc = 'Plug-in';
$doc_title = 'gimpplugin';