app: accept a const GimpTempBuf in more temp-buf functions

In gimp_temp_buf_{ref,unref}(), and
gimp_temp_buf_create_{buffer,pixmap}(), accept a const GimpTempBuf
argument.
This commit is contained in:
Ell 2019-02-24 12:46:34 -05:00
parent 88685bcf0e
commit 0a1e62768a
2 changed files with 15 additions and 16 deletions

View File

@ -153,24 +153,22 @@ gimp_temp_buf_copy (const GimpTempBuf *src)
}
GimpTempBuf *
gimp_temp_buf_ref (GimpTempBuf *buf)
gimp_temp_buf_ref (const GimpTempBuf *buf)
{
g_return_val_if_fail (buf != NULL, NULL);
buf->ref_count++;
g_atomic_int_inc ((gint *) &buf->ref_count);
return buf;
return (GimpTempBuf *) buf;
}
void
gimp_temp_buf_unref (GimpTempBuf *buf)
gimp_temp_buf_unref (const GimpTempBuf *buf)
{
g_return_if_fail (buf != NULL);
g_return_if_fail (buf->ref_count > 0);
buf->ref_count--;
if (buf->ref_count < 1)
if (g_atomic_int_dec_and_test ((gint *) &buf->ref_count))
{
g_atomic_pointer_add (&gimp_temp_buf_total_memsize,
-gimp_temp_buf_get_memsize (buf));
@ -179,7 +177,7 @@ gimp_temp_buf_unref (GimpTempBuf *buf)
if (buf->data)
gegl_free (buf->data);
g_slice_free (GimpTempBuf, buf);
g_slice_free (GimpTempBuf, (GimpTempBuf *) buf);
}
}
@ -365,8 +363,8 @@ gimp_temp_buf_get_memsize (const GimpTempBuf *buf)
return 0;
}
GeglBuffer *
gimp_temp_buf_create_buffer (GimpTempBuf *temp_buf)
GeglBuffer *
gimp_temp_buf_create_buffer (const GimpTempBuf *temp_buf)
{
GeglBuffer *buffer;
@ -382,13 +380,14 @@ gimp_temp_buf_create_buffer (GimpTempBuf *temp_buf)
(GDestroyNotify) gimp_temp_buf_unref,
gimp_temp_buf_ref (temp_buf));
g_object_set_data (G_OBJECT (buffer), "gimp-temp-buf", temp_buf);
g_object_set_data (G_OBJECT (buffer),
"gimp-temp-buf", (GimpTempBuf *) temp_buf);
return buffer;
}
GdkPixbuf *
gimp_temp_buf_create_pixbuf (GimpTempBuf *temp_buf)
gimp_temp_buf_create_pixbuf (const GimpTempBuf *temp_buf)
{
GdkPixbuf *pixbuf;
const Babl *format;

View File

@ -26,8 +26,8 @@ GimpTempBuf * gimp_temp_buf_new_from_pixbuf (GdkPixbuf *pixbuf,
const Babl *f_or_null) G_GNUC_WARN_UNUSED_RESULT;
GimpTempBuf * gimp_temp_buf_copy (const GimpTempBuf *src) G_GNUC_WARN_UNUSED_RESULT;
GimpTempBuf * gimp_temp_buf_ref (GimpTempBuf *buf);
void gimp_temp_buf_unref (GimpTempBuf *buf);
GimpTempBuf * gimp_temp_buf_ref (const GimpTempBuf *buf);
void gimp_temp_buf_unref (const GimpTempBuf *buf);
GimpTempBuf * gimp_temp_buf_scale (const GimpTempBuf *buf,
gint width,
@ -53,8 +53,8 @@ void gimp_temp_buf_unlock (const GimpTempBuf *buf,
gsize gimp_temp_buf_get_memsize (const GimpTempBuf *buf);
GeglBuffer * gimp_temp_buf_create_buffer (GimpTempBuf *temp_buf) G_GNUC_WARN_UNUSED_RESULT;
GdkPixbuf * gimp_temp_buf_create_pixbuf (GimpTempBuf *temp_buf) G_GNUC_WARN_UNUSED_RESULT;
GeglBuffer * gimp_temp_buf_create_buffer (const GimpTempBuf *temp_buf) G_GNUC_WARN_UNUSED_RESULT;
GdkPixbuf * gimp_temp_buf_create_pixbuf (const GimpTempBuf *temp_buf) G_GNUC_WARN_UNUSED_RESULT;
GimpTempBuf * gimp_gegl_buffer_get_temp_buf (GeglBuffer *buffer);