|
Packit |
bc1512 |
/* This file is part of GEGL.
|
|
Packit |
bc1512 |
* ck
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
bc1512 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
bc1512 |
* License as published by the Free Software Foundation; either
|
|
Packit |
bc1512 |
* version 3 of the License, or (at your option) any later version.
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
bc1512 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
bc1512 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
bc1512 |
* Lesser General Public License for more details.
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
bc1512 |
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* Copyright 2006-2008 Øyvind Kolås <pippin@gimp.org>
|
|
Packit |
bc1512 |
*/
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#ifndef __GEGL_BUFFER_PRIVATE_H__
|
|
Packit |
bc1512 |
#define __GEGL_BUFFER_PRIVATE_H__
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#include "gegl-buffer-types.h"
|
|
Packit |
bc1512 |
#include "gegl-buffer.h"
|
|
Packit |
bc1512 |
#include "gegl-tile-handler.h"
|
|
Packit |
bc1512 |
#include "gegl-buffer-iterator.h"
|
|
Packit |
bc1512 |
#include "gegl-buffer-cl-iterator.h"
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
// #define GEGL_USE_TILE_MUTEX
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#define GEGL_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEGL_TYPE_BUFFER, GeglBufferClass))
|
|
Packit |
bc1512 |
#define GEGL_IS_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEGL_TYPE_BUFFER))
|
|
Packit |
bc1512 |
#define GEGL_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEGL_TYPE_BUFFER, GeglBufferClass))
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
struct _GeglBuffer
|
|
Packit |
bc1512 |
{
|
|
Packit |
bc1512 |
GeglTileHandler parent_instance; /* which is a GeglTileHandler which has a
|
|
Packit |
bc1512 |
source field which is used for chaining
|
|
Packit |
bc1512 |
sub buffers with their anchestors */
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
GeglRectangle extent; /* the dimensions of the buffer */
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
const Babl *format; /* the pixel format used for pixels in this
|
|
Packit |
bc1512 |
buffer */
|
|
Packit |
bc1512 |
const Babl *soft_format; /* the format the buffer pretends to be, might
|
|
Packit |
bc1512 |
be different from format */
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gint shift_x; /* The relative offset of origins compared with */
|
|
Packit |
bc1512 |
gint shift_y; /* anchestral tile_storage buffer, during */
|
|
Packit |
bc1512 |
/* construction relative to immediate source */
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
GeglRectangle abyss;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
GeglSampler *sampler; /* cached sampler for speeding up random
|
|
Packit |
bc1512 |
access interpolated fetches from the
|
|
Packit |
bc1512 |
buffer */
|
|
Packit |
bc1512 |
const Babl *sampler_format; /* the format of the cached sampler */
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
GeglTileStorage *tile_storage;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gint tile_width;
|
|
Packit |
bc1512 |
gint tile_height;
|
|
Packit |
bc1512 |
gchar *path;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gint lock_count;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gchar *alloc_stack_trace; /* Stack trace for allocation,
|
|
Packit |
bc1512 |
useful for debugging */
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gpointer backend;
|
|
Packit |
bc1512 |
};
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
struct _GeglBufferClass
|
|
Packit |
bc1512 |
{
|
|
Packit |
bc1512 |
GeglTileHandlerClass parent_class;
|
|
Packit |
bc1512 |
};
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gint gegl_buffer_leaks (void);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
void gegl_buffer_stats (void);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
void gegl_buffer_save (GeglBuffer *buffer,
|
|
Packit |
bc1512 |
const gchar *path,
|
|
Packit |
bc1512 |
const GeglRectangle *roi);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
const gchar *gegl_swap_dir (void);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
void gegl_tile_cache_init (void);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
void gegl_tile_cache_destroy (void);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
GeglTileBackend * gegl_buffer_backend (GeglBuffer *buffer);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gboolean gegl_buffer_is_shared (GeglBuffer *buffer);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gboolean gegl_buffer_try_lock (GeglBuffer *buffer);
|
|
Packit |
bc1512 |
gboolean gegl_buffer_lock (GeglBuffer *buffer);
|
|
Packit |
bc1512 |
gboolean gegl_buffer_unlock (GeglBuffer *buffer);
|
|
Packit |
bc1512 |
void gegl_buffer_set_unlocked (GeglBuffer *buffer,
|
|
Packit |
bc1512 |
const GeglRectangle *rect,
|
|
Packit |
bc1512 |
const Babl *format,
|
|
Packit |
bc1512 |
const void *src,
|
|
Packit |
bc1512 |
gint rowstride);
|
|
Packit |
bc1512 |
void gegl_buffer_get_unlocked (GeglBuffer *buffer,
|
|
Packit |
bc1512 |
gdouble scale,
|
|
Packit |
bc1512 |
const GeglRectangle *rect,
|
|
Packit |
bc1512 |
const Babl *format,
|
|
Packit |
bc1512 |
gpointer dest_buf,
|
|
Packit |
bc1512 |
gint rowstride);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
GeglBuffer *
|
|
Packit |
bc1512 |
gegl_buffer_new_ram (const GeglRectangle *extent,
|
|
Packit |
bc1512 |
const Babl *format);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
void gegl_buffer_sampler (GeglBuffer *buffer,
|
|
Packit |
bc1512 |
gdouble x,
|
|
Packit |
bc1512 |
gdouble y,
|
|
Packit |
bc1512 |
gdouble scale,
|
|
Packit |
bc1512 |
gpointer dest,
|
|
Packit |
bc1512 |
const Babl *format,
|
|
Packit |
bc1512 |
gpointer sampler);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
/* the instance size of a GeglTile is a bit large, and should if possible be
|
|
Packit |
bc1512 |
* trimmed down
|
|
Packit |
bc1512 |
*/
|
|
Packit |
bc1512 |
struct _GeglTile
|
|
Packit |
bc1512 |
{
|
|
Packit |
bc1512 |
/* GObject parent_instance;*/
|
|
Packit |
bc1512 |
gint ref_count;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
guchar *data; /* actual pixel data for tile, a linear buffer*/
|
|
Packit |
bc1512 |
gint size; /* The size of the linear buffer */
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
GeglTileStorage *tile_storage; /* the buffer from which this tile was
|
|
Packit |
bc1512 |
* retrieved needed for the tile to be able to
|
|
Packit |
bc1512 |
* store itself back (for instance when it is
|
|
Packit |
bc1512 |
* unreffed for the last time)
|
|
Packit |
bc1512 |
*/
|
|
Packit |
bc1512 |
gint x, y, z;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
guint rev; /* this tile revision */
|
|
Packit |
bc1512 |
guint stored_rev; /* what revision was we when we from tile_storage?
|
|
Packit |
bc1512 |
(currently set to 1 when loaded from disk */
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gchar lock; /* number of times the tile is write locked
|
|
Packit |
bc1512 |
* should in theory just have the values 0/1
|
|
Packit |
bc1512 |
*/
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#ifdef GEGL_USE_TILE_MUTEX
|
|
Packit |
bc1512 |
GMutex *mutex;
|
|
Packit |
bc1512 |
#endif
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
/* the shared list is a doubly linked circular list */
|
|
Packit |
bc1512 |
GeglTile *next_shared;
|
|
Packit |
bc1512 |
GeglTile *prev_shared;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
/* called when the tile is about to be destroyed */
|
|
Packit |
bc1512 |
GDestroyNotify destroy_notify;
|
|
Packit |
bc1512 |
gpointer destroy_notify_data;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
/* called when the tile has been unlocked which typically means tile
|
|
Packit |
bc1512 |
* data has changed
|
|
Packit |
bc1512 |
*/
|
|
Packit |
bc1512 |
GeglTileCallback unlock_notify;
|
|
Packit |
bc1512 |
gpointer unlock_notify_data;
|
|
Packit |
bc1512 |
};
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
void _gegl_buffer_drop_hot_tile (GeglBuffer *buffer);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#ifndef __GEGL_TILE_C
|
|
Packit |
bc1512 |
#define gegl_tile_get_data(tile) ((guchar*)((tile)->data))
|
|
Packit |
bc1512 |
#endif // __GEGL_TILE_C
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
/* computes the positive integer remainder (also for negative dividends)
|
|
Packit |
bc1512 |
*/
|
|
Packit |
bc1512 |
#define GEGL_REMAINDER(dividend, divisor) \
|
|
Packit |
bc1512 |
(((dividend) < 0) ? \
|
|
Packit |
bc1512 |
(divisor) - 1 - ((-((dividend) + 1)) % (divisor)) : \
|
|
Packit |
bc1512 |
(dividend) % (divisor))
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#define gegl_tile_offset(coordinate, stride) GEGL_REMAINDER((coordinate), (stride))
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
/* helper function to compute tile indices and offsets for coordinates
|
|
Packit |
bc1512 |
* based on a tile stride (tile_width or tile_height)
|
|
Packit |
bc1512 |
*/
|
|
Packit |
bc1512 |
#define gegl_tile_indice(coordinate,stride) \
|
|
Packit |
bc1512 |
(((coordinate) >= 0)?\
|
|
Packit |
bc1512 |
(coordinate) / (stride):\
|
|
Packit |
bc1512 |
((((coordinate) + 1) /(stride)) - 1))
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#endif
|