mirror of https://github.com/GNOME/gimp.git
app: add temp-buf-total varaible to the dashboard
Add a temp-buf-total variable to the dashboard's misc group, showing the total size of all GimpTempBuf objects.
This commit is contained in:
parent
cbf581d42f
commit
bb645bae17
|
@ -53,6 +53,13 @@ typedef struct
|
|||
G_STATIC_ASSERT (sizeof (LockData) <= LOCK_DATA_ALIGNMENT);
|
||||
|
||||
|
||||
/* local variables */
|
||||
|
||||
static guintptr gimp_temp_buf_total_memsize = 0;
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpTempBuf *
|
||||
gimp_temp_buf_new (gint width,
|
||||
gint height,
|
||||
|
@ -76,6 +83,9 @@ gimp_temp_buf_new (gint width,
|
|||
temp->format = format;
|
||||
temp->data = gegl_malloc ((gsize) width * height * bpp);
|
||||
|
||||
g_atomic_pointer_add (&gimp_temp_buf_total_memsize,
|
||||
+gimp_temp_buf_get_memsize (temp));
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
@ -162,6 +172,10 @@ gimp_temp_buf_unref (GimpTempBuf *buf)
|
|||
|
||||
if (buf->ref_count < 1)
|
||||
{
|
||||
g_atomic_pointer_add (&gimp_temp_buf_total_memsize,
|
||||
-gimp_temp_buf_get_memsize (buf));
|
||||
|
||||
|
||||
if (buf->data)
|
||||
gegl_free (buf->data);
|
||||
|
||||
|
@ -426,3 +440,12 @@ gimp_gegl_buffer_get_temp_buf (GeglBuffer *buffer)
|
|||
|
||||
return g_object_get_data (G_OBJECT (buffer), "gimp-temp-buf");
|
||||
}
|
||||
|
||||
|
||||
/* public functions (stats) */
|
||||
|
||||
guint64
|
||||
gimp_temp_buf_get_total_memsize (void)
|
||||
{
|
||||
return gimp_temp_buf_total_memsize;
|
||||
}
|
||||
|
|
|
@ -19,45 +19,49 @@
|
|||
#define __GIMP_TEMP_BUF_H__
|
||||
|
||||
|
||||
GimpTempBuf * gimp_temp_buf_new (gint width,
|
||||
gint height,
|
||||
const Babl *format) G_GNUC_WARN_UNUSED_RESULT;
|
||||
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_new (gint width,
|
||||
gint height,
|
||||
const Babl *format) G_GNUC_WARN_UNUSED_RESULT;
|
||||
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 (GimpTempBuf *buf);
|
||||
void gimp_temp_buf_unref (GimpTempBuf *buf);
|
||||
|
||||
GimpTempBuf * gimp_temp_buf_scale (const GimpTempBuf *buf,
|
||||
gint width,
|
||||
gint height) G_GNUC_WARN_UNUSED_RESULT;
|
||||
GimpTempBuf * gimp_temp_buf_scale (const GimpTempBuf *buf,
|
||||
gint width,
|
||||
gint height) G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
gint gimp_temp_buf_get_width (const GimpTempBuf *buf);
|
||||
gint gimp_temp_buf_get_height (const GimpTempBuf *buf);
|
||||
gint gimp_temp_buf_get_width (const GimpTempBuf *buf);
|
||||
gint gimp_temp_buf_get_height (const GimpTempBuf *buf);
|
||||
|
||||
const Babl * gimp_temp_buf_get_format (const GimpTempBuf *buf);
|
||||
void gimp_temp_buf_set_format (GimpTempBuf *buf,
|
||||
const Babl *format);
|
||||
const Babl * gimp_temp_buf_get_format (const GimpTempBuf *buf);
|
||||
void gimp_temp_buf_set_format (GimpTempBuf *buf,
|
||||
const Babl *format);
|
||||
|
||||
guchar * gimp_temp_buf_get_data (const GimpTempBuf *buf);
|
||||
gsize gimp_temp_buf_get_data_size (const GimpTempBuf *buf);
|
||||
guchar * gimp_temp_buf_get_data (const GimpTempBuf *buf);
|
||||
gsize gimp_temp_buf_get_data_size (const GimpTempBuf *buf);
|
||||
|
||||
guchar * gimp_temp_buf_data_clear (GimpTempBuf *buf);
|
||||
guchar * gimp_temp_buf_data_clear (GimpTempBuf *buf);
|
||||
|
||||
gpointer gimp_temp_buf_lock (const GimpTempBuf *buf,
|
||||
const Babl *format,
|
||||
GeglAccessMode access_mode) G_GNUC_WARN_UNUSED_RESULT;
|
||||
void gimp_temp_buf_unlock (const GimpTempBuf *buf,
|
||||
gconstpointer data);
|
||||
gpointer gimp_temp_buf_lock (const GimpTempBuf *buf,
|
||||
const Babl *format,
|
||||
GeglAccessMode access_mode) G_GNUC_WARN_UNUSED_RESULT;
|
||||
void gimp_temp_buf_unlock (const GimpTempBuf *buf,
|
||||
gconstpointer data);
|
||||
|
||||
gsize gimp_temp_buf_get_memsize (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 (GimpTempBuf *temp_buf) G_GNUC_WARN_UNUSED_RESULT;
|
||||
GdkPixbuf * gimp_temp_buf_create_pixbuf (GimpTempBuf *temp_buf) G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
GimpTempBuf * gimp_gegl_buffer_get_temp_buf (GeglBuffer *buffer);
|
||||
GimpTempBuf * gimp_gegl_buffer_get_temp_buf (GeglBuffer *buffer);
|
||||
|
||||
|
||||
/* stats */
|
||||
|
||||
guint64 gimp_temp_buf_get_total_memsize (void);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEMP_BUF_H__ */
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "core/gimp-parallel.h"
|
||||
#include "core/gimpasync.h"
|
||||
#include "core/gimpbacktrace.h"
|
||||
#include "core/gimptempbuf.h"
|
||||
#include "core/gimpwaitable.h"
|
||||
|
||||
#include "gimpactiongroup.h"
|
||||
|
@ -138,6 +139,7 @@ typedef enum
|
|||
VARIABLE_MIPMAPED,
|
||||
VARIABLE_ASYNC_RUNNING,
|
||||
VARIABLE_SCRATCH_TOTAL,
|
||||
VARIABLE_TEMP_BUF_TOTAL,
|
||||
|
||||
|
||||
N_VARIABLES,
|
||||
|
@ -696,6 +698,18 @@ static const VariableInfo variables[] =
|
|||
.type = VARIABLE_TYPE_SIZE,
|
||||
.sample_func = gimp_dashboard_sample_gegl_stats,
|
||||
.data = "scratch-total"
|
||||
},
|
||||
|
||||
[VARIABLE_TEMP_BUF_TOTAL] =
|
||||
{ .name = "temp-buf-total",
|
||||
/* Translators: "TempBuf" is a technical term referring to an internal
|
||||
* GIMP data structure. It's probably OK to leave it untranslated.
|
||||
*/
|
||||
.title = NC_("dashboard-variable", "TempBuf"),
|
||||
.description = N_("Total size of temporary buffers"),
|
||||
.type = VARIABLE_TYPE_SIZE,
|
||||
.sample_func = gimp_dashboard_sample_function,
|
||||
.data = gimp_temp_buf_get_total_memsize
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -897,6 +911,9 @@ static const GroupInfo groups[] =
|
|||
{ .variable = VARIABLE_SCRATCH_TOTAL,
|
||||
.default_active = TRUE
|
||||
},
|
||||
{ .variable = VARIABLE_TEMP_BUF_TOTAL,
|
||||
.default_active = TRUE
|
||||
},
|
||||
|
||||
{}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue