[gimp] app: add a GimpCpmponentType parameter to GimpDrawable::estimate_memsize()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add a GimpCpmponentType parameter to GimpDrawable::estimate_memsize()
- Date: Sat, 14 Jun 2014 21:23:56 +0000 (UTC)
commit 909c4b408468677dd6b8e721b0bb1d14949d91cc
Author: Michael Natterer <mitch gimp org>
Date: Sat Jun 14 23:12:22 2014 +0200
app: add a GimpCpmponentType parameter to GimpDrawable::estimate_memsize()
so we can also estimate converting the drawable to other precisions.
app/core/gimpdrawable.c | 10 +++++++++-
app/core/gimpdrawable.h | 2 ++
app/core/gimpgrouplayer.c | 19 +++++++++++++------
app/core/gimpimage-scale.c | 2 ++
app/core/gimplayer.c | 10 +++++++---
5 files changed, 33 insertions(+), 10 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index ad35c88..b4636ef 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -142,6 +142,7 @@ static void gimp_drawable_real_update (GimpDrawable *drawable,
gint height);
static gint64 gimp_drawable_real_estimate_memsize (const GimpDrawable *drawable,
+ GimpComponentType component_type,
gint width,
gint height);
@@ -759,10 +760,15 @@ gimp_drawable_real_update (GimpDrawable *drawable,
static gint64
gimp_drawable_real_estimate_memsize (const GimpDrawable *drawable,
+ GimpComponentType component_type,
gint width,
gint height)
{
- const Babl *format = gimp_drawable_get_format (drawable);
+ const Babl *format;
+
+ format = gimp_babl_format (gimp_drawable_get_base_type (drawable),
+ gimp_babl_precision (component_type, FALSE),
+ gimp_drawable_has_alpha (drawable));
return (gint64) babl_format_get_bytes_per_pixel (format) * width * height;
}
@@ -1166,12 +1172,14 @@ gimp_drawable_new (GType type,
gint64
gimp_drawable_estimate_memsize (const GimpDrawable *drawable,
+ GimpComponentType component_type,
gint width,
gint height)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), 0);
return GIMP_DRAWABLE_GET_CLASS (drawable)->estimate_memsize (drawable,
+ component_type,
width, height);
}
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 67e6743..3a45bf3 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -54,6 +54,7 @@ struct _GimpDrawableClass
/* virtual functions */
gint64 (* estimate_memsize) (const GimpDrawable *drawable,
+ GimpComponentType component_type,
gint width,
gint height);
void (* invalidate_boundary) (GimpDrawable *drawable);
@@ -121,6 +122,7 @@ GimpDrawable * gimp_drawable_new (GType type,
const Babl *format);
gint64 gimp_drawable_estimate_memsize (const GimpDrawable *drawable,
+ GimpComponentType component_type,
gint width,
gint height);
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index f7e3e99..98d88dd 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -30,6 +30,8 @@
#include "core-types.h"
+#include "gegl/gimp-babl.h"
+
#include "gimpgrouplayer.h"
#include "gimpimage.h"
#include "gimpimage-undo-push.h"
@@ -130,8 +132,9 @@ static void gimp_group_layer_transform (GimpItem *item,
GimpProgress *progress);
static gint64 gimp_group_layer_estimate_memsize (const GimpDrawable *drawable,
- gint width,
- gint height);
+ GimpComponentType component_type,
+ gint width,
+ gint height);
static void gimp_group_layer_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
const Babl *new_format,
@@ -804,6 +807,7 @@ gimp_group_layer_transform (GimpItem *item,
static gint64
gimp_group_layer_estimate_memsize (const GimpDrawable *drawable,
+ GimpComponentType component_type,
gint width,
gint height)
{
@@ -828,6 +832,7 @@ gimp_group_layer_estimate_memsize (const GimpDrawable *drawable,
gimp_item_get_height (GIMP_ITEM (drawable)));
memsize += gimp_drawable_estimate_memsize (child,
+ component_type,
child_width,
child_height);
}
@@ -835,12 +840,14 @@ gimp_group_layer_estimate_memsize (const GimpDrawable *drawable,
base_type = gimp_drawable_get_base_type (drawable);
memsize += gimp_projection_estimate_memsize (base_type,
- gimp_drawable_get_precision (drawable),
+ gimp_babl_precision (component_type,
+ FALSE),
width, height);
- return memsize + GIMP_DRAWABLE_CLASS (parent_class)->estimate_memsize (drawable,
- width,
- height);
+ return memsize +
+ GIMP_DRAWABLE_CLASS (parent_class)->estimate_memsize (drawable,
+ component_type,
+ width, height);
}
static const Babl *
diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c
index 096de93..99da591 100644
--- a/app/core/gimpimage-scale.c
+++ b/app/core/gimpimage-scale.c
@@ -300,10 +300,12 @@ gimp_image_scale_check (const GimpImage *image,
scalable_size +=
gimp_drawable_estimate_memsize (drawable,
+ gimp_drawable_get_component_type (drawable),
width, height);
scaled_size +=
gimp_drawable_estimate_memsize (drawable,
+ gimp_drawable_get_component_type (drawable),
width * new_width /
gimp_image_get_width (image),
height * new_height /
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index bbead1e..af47dd0 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -153,6 +153,7 @@ static void gimp_layer_to_selection (GimpItem *item,
gdouble feather_radius_y);
static gint64 gimp_layer_estimate_memsize (const GimpDrawable *drawable,
+ GimpComponentType component_type,
gint width,
gint height);
static void gimp_layer_convert_type (GimpDrawable *drawable,
@@ -978,6 +979,7 @@ gimp_layer_to_selection (GimpItem *item,
static gint64
gimp_layer_estimate_memsize (const GimpDrawable *drawable,
+ GimpComponentType component_type,
gint width,
gint height)
{
@@ -986,11 +988,13 @@ gimp_layer_estimate_memsize (const GimpDrawable *drawable,
if (layer->mask)
memsize += gimp_drawable_estimate_memsize (GIMP_DRAWABLE (layer->mask),
+ component_type,
width, height);
- return memsize + GIMP_DRAWABLE_CLASS (parent_class)->estimate_memsize (drawable,
- width,
- height);
+ return memsize +
+ GIMP_DRAWABLE_CLASS (parent_class)->estimate_memsize (drawable,
+ component_type,
+ width, height);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]