Commit 25490b02 authored by Ell's avatar Ell

app: implement GimpPickable::get_pixel_average() in various classes

Implement GimpPickable::get_pixel_average(), added in the previous
commit, in GimpDrawable, GimpImage, and GimpProjection, using
gimp_gegl_average_color(), added in the commit before last.  This
is significantly faster than the default implementation.
parent b98a04aa
......@@ -29,6 +29,7 @@
#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-apply-operation.h"
#include "gegl/gimp-gegl-loops.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp-memsize.h"
......@@ -149,6 +150,11 @@ static gboolean gimp_drawable_get_pixel_at (GimpPickable *pickable,
gint y,
const Babl *format,
gpointer pixel);
static void gimp_drawable_get_pixel_average (GimpPickable *pickable,
const GeglRectangle *rect,
const Babl *format,
gpointer pixel);
static void gimp_drawable_real_update (GimpDrawable *drawable,
gint x,
gint y,
......@@ -302,6 +308,7 @@ gimp_pickable_iface_init (GimpPickableInterface *iface)
iface->get_format_with_alpha = (const Babl * (*) (GimpPickable *pickable)) gimp_drawable_get_format_with_alpha;
iface->get_buffer = (GeglBuffer * (*) (GimpPickable *pickable)) gimp_drawable_get_buffer;
iface->get_pixel_at = gimp_drawable_get_pixel_at;
iface->get_pixel_average = gimp_drawable_get_pixel_average;
}
static void
......@@ -710,6 +717,18 @@ gimp_drawable_get_pixel_at (GimpPickable *pickable,
return TRUE;
}
static void
gimp_drawable_get_pixel_average (GimpPickable *pickable,
const GeglRectangle *rect,
const Babl *format,
gpointer pixel)
{
GimpDrawable *drawable = GIMP_DRAWABLE (pickable);
return gimp_gegl_average_color (gimp_drawable_get_buffer (drawable),
rect, TRUE, GEGL_ABYSS_NONE, format, pixel);
}
static void
gimp_drawable_real_update (GimpDrawable *drawable,
gint x,
......
......@@ -207,6 +207,10 @@ static gboolean gimp_image_get_pixel_at (GimpPickable *pickable,
static gdouble gimp_image_get_opacity_at (GimpPickable *pickable,
gint x,
gint y);
static void gimp_image_get_pixel_average (GimpPickable *pickable,
const GeglRectangle *rect,
const Babl *format,
gpointer pixel);
static void gimp_image_pixel_to_srgb (GimpPickable *pickable,
const Babl *format,
gpointer pixel,
......@@ -679,6 +683,7 @@ gimp_pickable_iface_init (GimpPickableInterface *iface)
iface->get_buffer = gimp_image_get_buffer;
iface->get_pixel_at = gimp_image_get_pixel_at;
iface->get_opacity_at = gimp_image_get_opacity_at;
iface->get_pixel_average = gimp_image_get_pixel_average;
iface->pixel_to_srgb = gimp_image_pixel_to_srgb;
iface->srgb_to_pixel = gimp_image_srgb_to_pixel;
}
......@@ -1491,6 +1496,18 @@ gimp_image_get_opacity_at (GimpPickable *pickable,
x, y);
}
static void
gimp_image_get_pixel_average (GimpPickable *pickable,
const GeglRectangle *rect,
const Babl *format,
gpointer pixel)
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (pickable);
return gimp_pickable_get_pixel_average (GIMP_PICKABLE (private->projection),
rect, format, pixel);
}
static void
gimp_image_pixel_to_srgb (GimpPickable *pickable,
const Babl *format,
......
......@@ -30,6 +30,7 @@
#include "core-types.h"
#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-loops.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp.h"
......@@ -135,6 +136,10 @@ static gboolean gimp_projection_get_pixel_at (GimpPickable *picka
static gdouble gimp_projection_get_opacity_at (GimpPickable *pickable,
gint x,
gint y);
static void gimp_projection_get_pixel_average (GimpPickable *pickable,
const GeglRectangle *rect,
const Babl *format,
gpointer pixel);
static void gimp_projection_pixel_to_srgb (GimpPickable *pickable,
const Babl *format,
gpointer pixel,
......@@ -255,6 +260,7 @@ gimp_projection_pickable_iface_init (GimpPickableInterface *iface)
iface->get_buffer = gimp_projection_get_buffer;
iface->get_pixel_at = gimp_projection_get_pixel_at;
iface->get_opacity_at = gimp_projection_get_opacity_at;
iface->get_pixel_average = gimp_projection_get_pixel_average;
iface->pixel_to_srgb = gimp_projection_pixel_to_srgb;
iface->srgb_to_pixel = gimp_projection_srgb_to_pixel;
}
......@@ -459,6 +465,18 @@ gimp_projection_get_opacity_at (GimpPickable *pickable,
return GIMP_OPACITY_OPAQUE;
}
static void
gimp_projection_get_pixel_average (GimpPickable *pickable,
const GeglRectangle *rect,
const Babl *format,
gpointer pixel)
{
GeglBuffer *buffer = gimp_projection_get_buffer (pickable);
return gimp_gegl_average_color (buffer, rect, TRUE, GEGL_ABYSS_NONE, format,
pixel);
}
static void
gimp_projection_pixel_to_srgb (GimpPickable *pickable,
const Babl *format,
......
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