[gimp/goat-invasion: 478/526] app: remove "x" and "y" members from GimpTempBuf



commit c996034ba810740c2615556d1e5e2b9aa16cccb6
Author: Michael Natterer <mitch gimp org>
Date:   Tue Apr 10 15:51:33 2012 +0200

    app: remove "x" and "y" members from GimpTempBuf
    
    and generally clean up things a bit.

 app/core/gimptempbuf.c |   17 +++++++++--------
 app/core/gimptempbuf.h |   16 ++++++----------
 2 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/app/core/gimptempbuf.c b/app/core/gimptempbuf.c
index fe5a0f6..f014d78 100644
--- a/app/core/gimptempbuf.c
+++ b/app/core/gimptempbuf.c
@@ -44,8 +44,6 @@ gimp_temp_buf_new (gint        width,
   temp->format    = format;
   temp->width     = width;
   temp->height    = height;
-  temp->x         = 0;
-  temp->y         = 0;
 
   temp->data = g_new (guchar,
                       width * height *
@@ -55,7 +53,7 @@ gimp_temp_buf_new (gint        width,
 }
 
 GimpTempBuf *
-gimp_temp_buf_copy (GimpTempBuf *src)
+gimp_temp_buf_copy (const GimpTempBuf *src)
 {
   GimpTempBuf *dest;
 
@@ -98,9 +96,9 @@ gimp_temp_buf_unref (GimpTempBuf *buf)
 }
 
 GimpTempBuf *
-gimp_temp_buf_scale (GimpTempBuf *src,
-                     gint         new_width,
-                     gint         new_height)
+gimp_temp_buf_scale (const GimpTempBuf *src,
+                     gint               new_width,
+                     gint               new_height)
 {
   GimpTempBuf  *dest;
   const guchar *src_data;
@@ -114,6 +112,9 @@ gimp_temp_buf_scale (GimpTempBuf *src,
   g_return_val_if_fail (src != NULL, NULL);
   g_return_val_if_fail (new_width > 0 && new_height > 0, NULL);
 
+  if (new_width == src->width && new_height == src->height)
+    return gimp_temp_buf_copy (src);
+
   dest = gimp_temp_buf_new (new_width,
                             new_height,
                             src->format);
@@ -156,7 +157,7 @@ gimp_temp_buf_get_data (const GimpTempBuf *buf)
 }
 
 gsize
-gimp_temp_buf_get_data_size (GimpTempBuf *buf)
+gimp_temp_buf_get_data_size (const GimpTempBuf *buf)
 {
   return babl_format_get_bytes_per_pixel (buf->format) * buf->width * buf->height;
 }
@@ -170,7 +171,7 @@ gimp_temp_buf_data_clear (GimpTempBuf *buf)
 }
 
 gsize
-gimp_temp_buf_get_memsize (GimpTempBuf *buf)
+gimp_temp_buf_get_memsize (const GimpTempBuf *buf)
 {
   if (buf)
     return (sizeof (GimpTempBuf) + gimp_temp_buf_get_data_size (buf));
diff --git a/app/core/gimptempbuf.h b/app/core/gimptempbuf.h
index 88207a4..404fa17 100644
--- a/app/core/gimptempbuf.h
+++ b/app/core/gimptempbuf.h
@@ -22,34 +22,30 @@
 struct _GimpTempBuf
 {
   gint        ref_count;
-  const Babl *format;  /*  pixel format  */
+  const Babl *format;
   gint        width;
   gint        height;
-  gint        x, y;      /*  origin of data source                          */
-  guchar     *data;      /*  The data buffer. Do never access this field
-                           directly, use temp_buf_get_data() instead !!   */
+  guchar     *data;
 };
 
 
-/*  The temp buffer functions  */
-
 GimpTempBuf * gimp_temp_buf_new           (gint               width,
                                            gint               height,
                                            const Babl        *fomat) G_GNUC_WARN_UNUSED_RESULT;
-GimpTempBuf * gimp_temp_buf_copy          (GimpTempBuf       *src) 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_scale         (GimpTempBuf       *buf,
+GimpTempBuf * gimp_temp_buf_scale         (const GimpTempBuf *buf,
                                            gint               width,
                                            gint               height) G_GNUC_WARN_UNUSED_RESULT;
 
 guchar      * gimp_temp_buf_get_data      (const GimpTempBuf *buf);
-gsize         gimp_temp_buf_get_data_size (GimpTempBuf       *buf);
+gsize         gimp_temp_buf_get_data_size (const GimpTempBuf *buf);
 guchar      * gimp_temp_buf_data_clear    (GimpTempBuf       *buf);
 
-gsize         gimp_temp_buf_get_memsize   (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;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]