Commit 82c44949 authored by Ell's avatar Ell

app, pdb: use compat formats for brushes/patterns in plug-ins

Plug-ins are not prepared to handle high-precision brushes/
patterns, even when they're otherwise aware of high-precision
drawables, so make sure to always use compat formats when
communicating brush/pattern data to plug-ins.

Allowing plug-ins to handle high-precision brush/pattern data would
require some additional API.
parent 18537706
......@@ -88,3 +88,13 @@ gimp_babl_compat_u8_format (const Babl *format)
babl_format_has_alpha (format),
babl_format_get_space (format));
}
const Babl *
gimp_babl_compat_u8_mask_format (const Babl *format)
{
g_return_val_if_fail (format != NULL, NULL);
return gimp_babl_format (gimp_babl_format_get_base_type (format),
GIMP_PRECISION_U8_LINEAR,
FALSE);
}
......@@ -25,6 +25,7 @@
GimpImageType gimp_babl_format_get_image_type (const Babl *format);
const Babl * gimp_babl_compat_u8_format (const Babl *format);
const Babl * gimp_babl_compat_u8_mask_format (const Babl *format);
#endif /* __GIMP_BABL_COMPAT_H__ */
......@@ -36,6 +36,7 @@
#include "core/gimpdatafactory.h"
#include "core/gimpparamspecs.h"
#include "core/gimptempbuf.h"
#include "gegl/gimp-babl-compat.h"
#include "gimppdb.h"
#include "gimppdb-utils.h"
......@@ -283,11 +284,22 @@ brush_get_info_invoker (GimpProcedure *procedure,
{
GimpTempBuf *mask = gimp_brush_get_mask (brush);
GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush);
const Babl *format;
width = gimp_brush_get_width (brush);
height = gimp_brush_get_height (brush);
mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (mask));
color_bpp = pixmap ? babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pixmap)) : 0;
format = gimp_babl_compat_u8_mask_format (
gimp_temp_buf_get_format (mask));
width = gimp_brush_get_width (brush);
height = gimp_brush_get_height (brush);
mask_bpp = babl_format_get_bytes_per_pixel (format);
if (pixmap)
{
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pixmap));
color_bpp = babl_format_get_bytes_per_pixel (format);
}
}
else
success = FALSE;
......@@ -337,23 +349,35 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
{
GimpTempBuf *mask = gimp_brush_get_mask (brush);
GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush);
const Babl *format;
gpointer data;
format = gimp_babl_compat_u8_mask_format (
gimp_temp_buf_get_format (mask));
data = gimp_temp_buf_lock (mask, format, GEGL_ACCESS_READ);
width = gimp_temp_buf_get_width (mask);
height = gimp_temp_buf_get_height (mask);
mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (mask));
mask_bpp = babl_format_get_bytes_per_pixel (format);
num_mask_bytes = gimp_temp_buf_get_height (mask) *
gimp_temp_buf_get_width (mask) * mask_bpp;
mask_bytes = g_memdup (gimp_temp_buf_get_data (mask),
num_mask_bytes);
mask_bytes = g_memdup (data, num_mask_bytes);
gimp_temp_buf_unlock (mask, data);
if (pixmap)
{
color_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pixmap));
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pixmap));
data = gimp_temp_buf_lock (pixmap, format, GEGL_ACCESS_READ);
color_bpp = babl_format_get_bytes_per_pixel (format);
num_color_bytes = gimp_temp_buf_get_height (pixmap) *
gimp_temp_buf_get_width (pixmap) *
color_bpp;
color_bytes = g_memdup (gimp_temp_buf_get_data (pixmap),
num_color_bytes);
color_bytes = g_memdup (data, num_color_bytes);
gimp_temp_buf_unlock (pixmap, data);
}
}
else
......
......@@ -34,6 +34,7 @@
#include "core/gimpparamspecs.h"
#include "core/gimppattern.h"
#include "core/gimptempbuf.h"
#include "gegl/gimp-babl-compat.h"
#include "gimppdb.h"
#include "gimppdb-utils.h"
......@@ -64,9 +65,14 @@ pattern_get_info_invoker (GimpProcedure *procedure,
if (pattern)
{
const Babl *format;
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pattern->mask));
width = gimp_temp_buf_get_width (pattern->mask);
height = gimp_temp_buf_get_height (pattern->mask);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
bpp = babl_format_get_bytes_per_pixel (format);
}
else
success = FALSE;
......@@ -110,12 +116,20 @@ pattern_get_pixels_invoker (GimpProcedure *procedure,
if (pattern)
{
const Babl *format;
gpointer data;
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pattern->mask));
data = gimp_temp_buf_lock (pattern->mask, format, GEGL_ACCESS_READ);
width = gimp_temp_buf_get_width (pattern->mask);
height = gimp_temp_buf_get_height (pattern->mask);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
bpp = babl_format_get_bytes_per_pixel (format);
num_color_bytes = gimp_temp_buf_get_data_size (pattern->mask);
color_bytes = g_memdup (gimp_temp_buf_get_data (pattern->mask),
num_color_bytes);
color_bytes = g_memdup (data, num_color_bytes);
gimp_temp_buf_unlock (pattern->mask, data);
}
else
success = FALSE;
......
......@@ -28,6 +28,8 @@
#include "widgets-types.h"
#include "gegl/gimp-babl-compat.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpbrush.h"
......@@ -259,11 +261,18 @@ gimp_brush_select_run_callback (GimpPdbDialog *dialog,
{
GimpBrush *brush = GIMP_BRUSH (object);
GimpTempBuf *mask = gimp_brush_get_mask (brush);
const Babl *format;
gpointer data;
GimpArray *array;
GimpValueArray *return_vals;
array = gimp_array_new (gimp_temp_buf_get_data (mask),
gimp_temp_buf_get_data_size (mask),
format = gimp_babl_compat_u8_mask_format (gimp_temp_buf_get_format (mask));
data = gimp_temp_buf_lock (mask, format, GEGL_ACCESS_READ);
array = gimp_array_new (data,
gimp_temp_buf_get_width (mask) *
gimp_temp_buf_get_height (mask) *
babl_format_get_bytes_per_pixel (format),
TRUE);
return_vals =
......@@ -284,6 +293,8 @@ gimp_brush_select_run_callback (GimpPdbDialog *dialog,
gimp_array_free (array);
gimp_temp_buf_unlock (mask, data);
return return_vals;
}
......
......@@ -28,6 +28,8 @@
#include "widgets-types.h"
#include "gegl/gimp-babl-compat.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpparamspecs.h"
......@@ -103,11 +105,19 @@ gimp_pattern_select_run_callback (GimpPdbDialog *dialog,
GError **error)
{
GimpPattern *pattern = GIMP_PATTERN (object);
const Babl *format;
gpointer data;
GimpArray *array;
GimpValueArray *return_vals;
array = gimp_array_new (gimp_temp_buf_get_data (pattern->mask),
gimp_temp_buf_get_data_size (pattern->mask),
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pattern->mask));
data = gimp_temp_buf_lock (pattern->mask, format, GEGL_ACCESS_READ);
array = gimp_array_new (data,
gimp_temp_buf_get_width (pattern->mask) *
gimp_temp_buf_get_height (pattern->mask) *
babl_format_get_bytes_per_pixel (format),
TRUE);
return_vals =
......@@ -126,5 +136,7 @@ gimp_pattern_select_run_callback (GimpPdbDialog *dialog,
gimp_array_free (array);
gimp_temp_buf_unlock (pattern->mask, data);
return return_vals;
}
......@@ -243,11 +243,22 @@ HELP
{
GimpTempBuf *mask = gimp_brush_get_mask (brush);
GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush);
const Babl *format;
width = gimp_brush_get_width (brush);
height = gimp_brush_get_height (brush);
mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (mask));
color_bpp = pixmap ? babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pixmap)) : 0;
format = gimp_babl_compat_u8_mask_format (
gimp_temp_buf_get_format (mask));
width = gimp_brush_get_width (brush);
height = gimp_brush_get_height (brush);
mask_bpp = babl_format_get_bytes_per_pixel (format);
if (pixmap)
{
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pixmap));
color_bpp = babl_format_get_bytes_per_pixel (format);
}
}
else
success = FALSE;
......@@ -297,23 +308,35 @@ HELP
{
GimpTempBuf *mask = gimp_brush_get_mask (brush);
GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush);
const Babl *format;
gpointer data;
format = gimp_babl_compat_u8_mask_format (
gimp_temp_buf_get_format (mask));
data = gimp_temp_buf_lock (mask, format, GEGL_ACCESS_READ);
width = gimp_temp_buf_get_width (mask);
height = gimp_temp_buf_get_height (mask);
mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (mask));
mask_bpp = babl_format_get_bytes_per_pixel (format);
num_mask_bytes = gimp_temp_buf_get_height (mask) *
gimp_temp_buf_get_width (mask) * mask_bpp;
mask_bytes = g_memdup (gimp_temp_buf_get_data (mask),
num_mask_bytes);
mask_bytes = g_memdup (data, num_mask_bytes);
gimp_temp_buf_unlock (mask, data);
if (pixmap)
{
color_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pixmap));
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pixmap));
data = gimp_temp_buf_lock (pixmap, format, GEGL_ACCESS_READ);
color_bpp = babl_format_get_bytes_per_pixel (format);
num_color_bytes = gimp_temp_buf_get_height (pixmap) *
gimp_temp_buf_get_width (pixmap) *
color_bpp;
color_bytes = g_memdup (gimp_temp_buf_get_data (pixmap),
num_color_bytes);
color_bytes = g_memdup (data, num_color_bytes);
gimp_temp_buf_unlock (pixmap, data);
}
}
else
......@@ -849,6 +872,7 @@ CODE
@headers = qw(<string.h>
"gegl/gimp-babl-compat.h"
"core/gimp.h"
"core/gimpbrush.h"
"core/gimpbrushgenerated.h"
......
......@@ -47,9 +47,14 @@ HELP
if (pattern)
{
const Babl *format;
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pattern->mask));
width = gimp_temp_buf_get_width (pattern->mask);
height = gimp_temp_buf_get_height (pattern->mask);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
bpp = babl_format_get_bytes_per_pixel (format);
}
else
success = FALSE;
......@@ -95,12 +100,20 @@ HELP
if (pattern)
{
const Babl *format;
gpointer data;
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pattern->mask));
data = gimp_temp_buf_lock (pattern->mask, format, GEGL_ACCESS_READ);
width = gimp_temp_buf_get_width (pattern->mask);
height = gimp_temp_buf_get_height (pattern->mask);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
bpp = babl_format_get_bytes_per_pixel (format);
num_color_bytes = gimp_temp_buf_get_data_size (pattern->mask);
color_bytes = g_memdup (gimp_temp_buf_get_data (pattern->mask),
num_color_bytes);
color_bytes = g_memdup (data, num_color_bytes);
gimp_temp_buf_unlock (pattern->mask, data);
}
else
success = FALSE;
......@@ -111,6 +124,7 @@ CODE
@headers = qw(<string.h>
"gegl/gimp-babl-compat.h"
"core/gimpcontext.h"
"core/gimpdatafactory.h"
"core/gimppattern.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment