[gimp/gimp-2-10] app: accept a const GimpTempBuf in more temp-buf functions
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: accept a const GimpTempBuf in more temp-buf functions
- Date: Sun, 24 Feb 2019 18:24:29 +0000 (UTC)
commit 25ed35af628a7b6cc1b60ced67f0381d87f3e4f2
Author: Ell <ell_se yahoo com>
Date: Sun Feb 24 12:46:34 2019 -0500
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.
(cherry picked from commit 0a1e62768a891380ab04d8b53412b76257b39322)
app/core/gimptempbuf.c | 23 +++++++++++------------
app/core/gimptempbuf.h | 8 ++++----
2 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/app/core/gimptempbuf.c b/app/core/gimptempbuf.c
index 0d84d779e2..2879be9241 100644
--- a/app/core/gimptempbuf.c
+++ b/app/core/gimptempbuf.c
@@ -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;
diff --git a/app/core/gimptempbuf.h b/app/core/gimptempbuf.h
index 1569138345..d5228f5e8b 100644
--- a/app/core/gimptempbuf.h
+++ b/app/core/gimptempbuf.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]