|
Packit Service |
2781ba |
/* This file is part of GEGL.
|
|
Packit Service |
2781ba |
* ck
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
2781ba |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
2781ba |
* version 3 of the License, or (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2781ba |
* Lesser General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright 2008 Øyvind Kolås <pippin@gimp.org>
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#ifndef __GEGL_BUFFER_ITERATOR_H__
|
|
Packit Service |
2781ba |
#define __GEGL_BUFFER_ITERATOR_H__
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl-buffer.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define GEGL_BUFFER_MAX_ITERATORS 6
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define GEGL_BUFFER_READ 1
|
|
Packit Service |
2781ba |
#define GEGL_BUFFER_WRITE 2
|
|
Packit Service |
2781ba |
#define GEGL_BUFFER_READWRITE (GEGL_BUFFER_READ|GEGL_BUFFER_WRITE)
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
typedef struct GeglBufferIterator
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gint length;
|
|
Packit Service |
2781ba |
gpointer data[GEGL_BUFFER_MAX_ITERATORS];
|
|
Packit Service |
2781ba |
GeglRectangle roi[GEGL_BUFFER_MAX_ITERATORS];
|
|
Packit Service |
2781ba |
gint level;
|
|
Packit Service |
2781ba |
} GeglBufferIterator;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/**
|
|
Packit Service |
2781ba |
* gegl_buffer_iterator_new:
|
|
Packit Service |
2781ba |
* @buffer: a #GeglBuffer
|
|
Packit Service |
2781ba |
* @roi: the rectangle to iterate over
|
|
Packit Service |
2781ba |
* @format: the format we want to process this buffers data in, pass 0 to use the buffers format.
|
|
Packit Service |
2781ba |
* @flags: whether we need reading or writing to this buffer one of GEGL_BUFFER_READ, GEGL_BUFFER_WRITE and GEGL_BUFFER_READWRITE.
|
|
Packit Service |
2781ba |
* @level: the level at which we are iterating, the roi will indicate the
|
|
Packit Service |
2781ba |
* extent at 1:1, x,y,width and height are/(2^level)
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Create a new buffer iterator, this buffer will be iterated through
|
|
Packit Service |
2781ba |
* in linear chunks, some chunks might be full tiles the coordinates, see
|
|
Packit Service |
2781ba |
* the documentation of gegl_buffer_iterator_next for how to use it and
|
|
Packit Service |
2781ba |
* destroy it.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Returns: a new buffer iterator that can be used to iterate through the
|
|
Packit Service |
2781ba |
* buffers pixels.
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
GeglBufferIterator * gegl_buffer_iterator_new (GeglBuffer *buffer,
|
|
Packit Service |
2781ba |
const GeglRectangle *roi,
|
|
Packit Service |
2781ba |
gint level,
|
|
Packit Service |
2781ba |
const Babl *format,
|
|
Packit Service |
2781ba |
guint flags,
|
|
Packit Service |
2781ba |
GeglAbyssPolicy abyss_policy);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/**
|
|
Packit Service |
2781ba |
* gegl_buffer_iterator_add:
|
|
Packit Service |
2781ba |
* @iterator: a #GeglBufferIterator
|
|
Packit Service |
2781ba |
* @buffer: a #GeglBuffer
|
|
Packit Service |
2781ba |
* @roi: the rectangle to iterate over
|
|
Packit Service |
2781ba |
* @format: the format we want to process this buffers data in, pass 0 to use the buffers format.
|
|
Packit Service |
2781ba |
* @flags: whether we need reading or writing to this buffer.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Adds an additional buffer iterator that will be processed in sync with
|
|
Packit Service |
2781ba |
* the original one, if the buffer doesn't align with the other for tile access
|
|
Packit Service |
2781ba |
* the corresponding scans and regions will be serialized automatically using
|
|
Packit Service |
2781ba |
* gegl_buffer_get.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Returns: an integer handle refering to the indice in the iterator structure
|
|
Packit Service |
2781ba |
* of the added buffer.
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
gint gegl_buffer_iterator_add (GeglBufferIterator *iterator,
|
|
Packit Service |
2781ba |
GeglBuffer *buffer,
|
|
Packit Service |
2781ba |
const GeglRectangle *roi,
|
|
Packit Service |
2781ba |
gint level,
|
|
Packit Service |
2781ba |
const Babl *format,
|
|
Packit Service |
2781ba |
guint flags,
|
|
Packit Service |
2781ba |
GeglAbyssPolicy abyss_policy);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/**
|
|
Packit Service |
2781ba |
* gegl_buffer_iterator_stop:
|
|
Packit Service |
2781ba |
* @iterator: a GeglBufferIterator
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Cancels the current iteration, freeing up any temporary resources. You have
|
|
Packit Service |
2781ba |
* to bail out of any loop you are currently.
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
void gegl_buffer_iterator_stop (GeglBufferIterator *iterator);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/**
|
|
Packit Service |
2781ba |
* gegl_buffer_iterator_next:
|
|
Packit Service |
2781ba |
* @iterator: a #GeglBufferIterator
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Do an iteration, this causes a new set of iterator->data[] to become
|
|
Packit Service |
2781ba |
* available if there is more data to process. Changed data from a previous
|
|
Packit Service |
2781ba |
* iteration step will also be saved now. When there is no more data to
|
|
Packit Service |
2781ba |
* be processed FALSE will be returned (and the iterator handle is no longer
|
|
Packit Service |
2781ba |
* valid).
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Returns: TRUE if there is more work FALSE if iteration is complete.
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
gboolean gegl_buffer_iterator_next (GeglBufferIterator *iterator);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#ifdef EXAMPLE
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GeglBufferIterator *gi;
|
|
Packit Service |
2781ba |
gi = gegl_buffer_iterator_new (buffer, roi,
|
|
Packit Service |
2781ba |
babl_format("Y' float"), GEGL_BUFFER_WRITE);
|
|
Packit Service |
2781ba |
while (gegl_buffer_iterator_next (gi))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gfloat *buf = gi->data[0];
|
|
Packit Service |
2781ba |
gint i;
|
|
Packit Service |
2781ba |
for (i=0; i<gi->length; i++)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
buf[i]=0.5;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#endif
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#endif
|