mirror of https://github.com/GNOME/gimp.git
app: add a GimpCpmponentType parameter to GimpDrawable::estimate_memsize()
so we can also estimate converting the drawable to other precisions.
This commit is contained in:
parent
a7c82d2964
commit
909c4b4084
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 *
|
||||
|
|
|
@ -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 /
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue