Commit ad2c01f8 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

app: move gimp_drawable_fill() to gimpdrawable-fill.[ch]

and get rid of gimp_drawable_fill_full().
parent 19b6b53f
......@@ -31,6 +31,7 @@
#include "core/gimpchannel.h"
#include "core/gimpchannel-select.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable-fill.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
......
......@@ -33,6 +33,7 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable-fill.h"
#include "core/gimpgrouplayer.h"
#include "core/gimpimage.h"
#include "core/gimpimage-merge.h"
......
......@@ -21,11 +21,14 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"
#include "core-types.h"
#include "gegl/gimp-gegl-apply-operation.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp-utils.h"
#include "gimpbezierdesc.h"
#include "gimpchannel.h"
#include "gimpdrawable-fill.h"
......@@ -42,6 +45,47 @@
/* public functions */
void
gimp_drawable_fill (GimpDrawable *drawable,
GimpContext *context,
GimpFillType fill_type)
{
GimpRGB color;
GimpPattern *pattern;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_CONTEXT (context));
if (! gimp_get_fill_params (context, fill_type, &color, &pattern, NULL))
return;
if (pattern)
{
GeglBuffer *src_buffer = gimp_pattern_create_buffer (pattern);
gegl_buffer_set_pattern (gimp_drawable_get_buffer (drawable),
NULL, src_buffer, 0, 0);
g_object_unref (src_buffer);
}
else
{
GeglColor *gegl_color;
if (! gimp_drawable_has_alpha (drawable))
gimp_rgb_set_alpha (&color, 1.0);
gegl_color = gimp_gegl_color_new (&color);
gegl_buffer_set_color (gimp_drawable_get_buffer (drawable),
NULL, gegl_color);
g_object_unref (gegl_color);
}
gimp_drawable_update (drawable,
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)));
}
void
gimp_drawable_fill_boundary (GimpDrawable *drawable,
GimpFillOptions *options,
......
......@@ -19,6 +19,18 @@
#define __GIMP_DRAWABLE_FILL_H__
/* Lowlevel API that is used for initializing the entire drawable
* before it is added to the image, doesn't even push an undo.
*/
void gimp_drawable_fill (GimpDrawable *drawable,
GimpContext *context,
GimpFillType fill_type);
/* Proper API that is used for actual editing (not just initializing)
*/
void gimp_drawable_fill_boundary (GimpDrawable *drawable,
GimpFillOptions *options,
const GimpBoundSeg *bound_segs,
......
......@@ -1497,59 +1497,6 @@ gimp_drawable_push_undo (GimpDrawable *drawable,
x, y, width, height);
}
void
gimp_drawable_fill (GimpDrawable *drawable,
GimpContext *context,
GimpFillType fill_type)
{
GimpRGB color;
GimpPattern *pattern;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
if (! gimp_get_fill_params (context, fill_type, &color, &pattern, NULL))
return;
gimp_drawable_fill_full (drawable, &color, pattern);
}
void
gimp_drawable_fill_full (GimpDrawable *drawable,
const GimpRGB *color,
const GimpPattern *pattern)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (color != NULL);
g_return_if_fail (pattern == NULL || GIMP_IS_PATTERN (pattern));
if (pattern)
{
GeglBuffer *src_buffer = gimp_pattern_create_buffer (pattern);
gegl_buffer_set_pattern (gimp_drawable_get_buffer (drawable),
NULL, src_buffer, 0, 0);
g_object_unref (src_buffer);
}
else
{
GimpRGB c = *color;
GeglColor *col;
if (! gimp_drawable_has_alpha (drawable))
gimp_rgb_set_alpha (&c, 1.0);
col = gimp_gegl_color_new (&c);
gegl_buffer_set_color (gimp_drawable_get_buffer (drawable),
NULL, col);
g_object_unref (col);
}
gimp_drawable_update (drawable,
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)));
}
const Babl *
gimp_drawable_get_format (const GimpDrawable *drawable)
{
......
......@@ -199,13 +199,6 @@ void gimp_drawable_push_undo (GimpDrawable *drawable,
gint width,
gint height);
void gimp_drawable_fill (GimpDrawable *drawable,
GimpContext *context,
GimpFillType fill_type);
void gimp_drawable_fill_full (GimpDrawable *drawable,
const GimpRGB *color,
const GimpPattern *pattern);
const Babl * gimp_drawable_get_format (const GimpDrawable *drawable);
const Babl * gimp_drawable_get_format_with_alpha
(const GimpDrawable *drawable);
......
......@@ -35,6 +35,7 @@
#include "gimpbuffer.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpdrawable-fill.h"
#include "gimpimage.h"
#include "gimpimage-color-profile.h"
#include "gimpimage-colormap.h"
......
......@@ -30,6 +30,7 @@
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpchannel-select.h"
#include "core/gimpdrawable-fill.h"
#include "core/gimpdrawable-foreground-extract.h"
#include "core/gimpdrawable-offset.h"
#include "core/gimpdrawable-preview.h"
......
......@@ -94,7 +94,6 @@ sub drawable_fill {
$blurb = 'Fill the drawable with the specified fill mode.';
$help = <<'HELP';
This procedure fills the drawable. If the fill mode is foreground the
current foreground color is used. If the fill mode is background, the
current background color is used. If the fill type is white, then
......@@ -119,6 +118,7 @@ HELP
);
%invoke = (
headers => [ qw("core/gimpdrawable-fill.h") ],
code => <<'CODE'
{
if (gimp_pdb_item_is_modifyable (GIMP_ITEM (drawable),
......
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