Commit 867e4d1c authored by Kevin Cozens's avatar Kevin Cozens

Updated to new chanting API.

* operations/io/load-buffer.c:
* operations/io/magick-load.c:
* operations/io/raw-load.c: Updated to new chanting API.

svn path=/trunk/; revision=1995
parent c5dea414
2008-02-10 Kevin Cozens <kcozens@cvs.gnome.org>
* operations/io/load-buffer.c:
* operations/io/magick-load.c:
* operations/io/raw-load.c: Updated to new chanting API.
2008-02-10 Øyvind Kolås <pippin@gimp.org>
* gegl/gegl-chant.h: renamed dummy_filler to chant_data, this means
......
......@@ -15,33 +15,29 @@
*
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#if GEGL_CHANT_PROPERTIES
gegl_chant_object (buffer, "GeglBuffer to use")
#ifdef GEGL_CHANT_PROPERTIES
/* no properties */
#else
#define GEGL_CHANT_SOURCE
#define GEGL_CHANT_NAME load_buffer
#define GEGL_CHANT_DESCRIPTION "A source that uses an in-memory GeglBuffer, for use internally by GEGL."
#define GEGL_CHANT_TYPE_SOURCE
#define GEGL_CHANT_C_FILE "load-buffer.c"
#define GEGL_CHANT_SELF "load-buffer.c"
#define GEGL_CHANT_CATEGORIES "programming:input"
#define GEGL_CHANT_CLASS_INIT
#include "gegl-old-chant.h"
#include "gegl-buffer.h"
#include "graph/gegl-node-context.h"
#include "gegl-chant.h"
static void
dispose (GObject *object)
static GeglRectangle
get_bounding_box (GeglOperation *operation)
{
GeglChantOperation *self = GEGL_CHANT_OPERATION (object);
GeglRectangle result = {0,0,0,0};
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
if (self->buffer)
if (!o->chant_data)
{
g_object_unref (self->buffer);
self->buffer = NULL;
return result;
}
G_OBJECT_CLASS (g_type_class_peek_parent (G_OBJECT_GET_CLASS (object)))->dispose (object);
result = *gegl_buffer_get_extent (GEGL_BUFFER (o->chant_data));
return result;
}
static gboolean
......@@ -50,36 +46,54 @@ process (GeglOperation *operation,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
if (self->buffer)
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
if (o->chant_data)
{
g_object_ref (self->buffer); /* Add an extra reference, since gegl_operation_set_data
g_object_ref (o->chant_data); /* Add an extra reference, since gegl_operation_set_data
is stealing one.
*/
/* override core behaviour, by resetting the buffer in the node_context */
gegl_node_context_set_object (context, "output", G_OBJECT (self->buffer));
gegl_node_context_set_object (context, "output", G_OBJECT (o->chant_data));
}
return TRUE;
}
static GeglRectangle
get_bounding_box (GeglOperation *operation)
static void
dispose (GObject *object)
{
GeglRectangle result = {0,0,0,0};
GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (object);
if (!self->buffer)
if (o->chant_data)
{
return result;
g_object_unref (o->chant_data);
o->chant_data = NULL;
}
result = *gegl_buffer_get_extent (GEGL_BUFFER (self->buffer));
return result;
G_OBJECT_CLASS (g_type_class_peek_parent (G_OBJECT_GET_CLASS (object)))->dispose (object);
}
static void class_init (GeglOperationClass *operation_class)
static void
operation_class_init (GeglChantClass *klass)
{
G_OBJECT_CLASS (operation_class)->dispose = dispose;
GeglOperationClass *operation_class;
GeglOperationSourceClass *source_class;
operation_class = GEGL_OPERATION_CLASS (klass);
source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
source_class->process = process;
operation_class->get_bounding_box = get_bounding_box;
G_OBJECT_CLASS (klass)->dispose = dispose;
operation_class->name = "load-buffer";
operation_class->categories = "programming:input";
operation_class->description =
"A source that uses an in-memory GeglBuffer, for use internally by GEGL.";
operation_class->no_cache = TRUE;
}
......
......@@ -15,26 +15,25 @@
*
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#if GEGL_CHANT_PROPERTIES
gegl_chant_path (path, "/tmp/gegl-logo.svg", "Path of file to load.")
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_path (path, "File", "/tmp/gegl-logo.svg", "Path of file to load.")
#else
#define GEGL_CHANT_SOURCE
#define GEGL_CHANT_NAME magick_load
#define GEGL_CHANT_DESCRIPTION "Image Magick wrapper using the png op."
#define GEGL_CHANT_TYPE_SOURCE
#define GEGL_CHANT_C_FILE "magick-load.c"
#define GEGL_CHANT_SELF "magick-load.c"
#define GEGL_CHANT_CATEGORIES "hidden"
#include "gegl-old-chant.h"
#include "gegl-chant.h"
#include <stdio.h>
/* FIXME: this should not be neccesary to implement this operation */
GeglBuffer *gegl_node_get_cache (GeglNode *node);
static void
load_cache (GeglChantOperation *op_magick_load)
load_cache (GeglChantO *op_magick_load)
{
if (!op_magick_load->priv)
if (!op_magick_load->chant_data)
{
GeglRectangle rect;
GeglNode *temp_gegl;
......@@ -74,54 +73,72 @@ load_cache (GeglChantOperation *op_magick_load)
{
GeglBuffer *cache = GEGL_BUFFER (gegl_node_get_cache (temp_gegl));
GeglBuffer *newbuf = gegl_buffer_create_sub_buffer (cache, &rect);
op_magick_load->priv = (gpointer) newbuf;
op_magick_load->chant_data = (gpointer) newbuf;
g_object_unref (cache);
}
/*g_object_ref (op_magick_load->priv);*/
/*g_object_ref (op_magick_load->chant_data);*/
/*FIXME: this should be unneccesary, using the graph
* directly as a node is more elegant.
*/
/*gegl_node_get (temp_gegl, "output", &(op_magick_load->priv), NULL);*/
/*gegl_node_get (temp_gegl, "output", &(op_magick_load->chant_data), NULL);*/
g_object_unref (temp_gegl);
}
}
static GeglRectangle
get_bounding_box (GeglOperation *operation)
{
GeglRectangle result = {0,0,0,0};
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
gint width, height;
load_cache (o);
g_object_get (o->chant_data, "width", &width,
"height", &height, NULL);
result.width = width;
result.height = height;
return result;
}
static gboolean
process (GeglOperation *operation,
GeglNodeContext *context,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
if (!self->priv)
if (!o->chant_data)
return FALSE;
/* overriding the predefined behavior */
gegl_node_context_set_object (context, "output", G_OBJECT (self->priv));
self->priv = NULL;
gegl_node_context_set_object (context, "output", G_OBJECT (o->chant_data));
o->chant_data = NULL;
return TRUE;
}
static GeglRectangle
get_bounding_box (GeglOperation *operation)
static void
operation_class_init (GeglChantClass *klass)
{
GeglRectangle result = {0,0,0,0};
GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
gint width, height;
GeglOperationClass *operation_class;
GeglOperationSourceClass *source_class;
load_cache (self);
operation_class = GEGL_OPERATION_CLASS (klass);
source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
g_object_get (self->priv, "width", &width,
"height", &height, NULL);
source_class->process = process;
operation_class->get_bounding_box = get_bounding_box;
result.width = width;
result.height = height;
return result;
operation_class->name = "magick-load";
operation_class->categories = "hidden";
operation_class->description =
"Image Magick wrapper using the png op.";
}
#endif
......@@ -17,18 +17,16 @@
*/
#include "config.h"
#if GEGL_CHANT_PROPERTIES
gegl_chant_path (path, "/tmp/test.raw", "Path of file to load.")
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_path (path, "File", "/tmp/test.raw", "Path of file to load.")
#else
#define GEGL_CHANT_SOURCE
#define GEGL_CHANT_NAME raw_load
#define GEGL_CHANT_DESCRIPTION "Raw image loader, wrapping dcraw with pipes."
#define GEGL_CHANT_TYPE_SOURCE
#define GEGL_CHANT_C_FILE "raw-load.c"
#define GEGL_CHANT_SELF "raw-load.c"
#define GEGL_CHANT_CATEGORIES "hidden"
#define GEGL_CHANT_CLASS_INIT
#include "gegl-old-chant.h"
#include "gegl-chant.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......@@ -46,57 +44,10 @@ gegl_chant_path (path, "/tmp/test.raw", "Path of file to load.")
#define MAX_SAMPLE 65535
#define ERROR -1
static void load_buffer (GeglChantOperation *op_raw_load);
static gboolean
process (GeglOperation *operation,
GeglNodeContext *context,
GeglBuffer *output_ignored,
const GeglRectangle *result)
{
GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
GeglBuffer *output;
g_assert (self->priv);
output = GEGL_BUFFER (self->priv);
gegl_node_context_set_object (context, "output", G_OBJECT (output));
self->priv = NULL;
return TRUE;
}
static GeglRectangle
get_bounding_box (GeglOperation *operation)
{
GeglRectangle result = {0,0,0,0};
GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
load_buffer (self);
if (self->priv)
{
result.width = gegl_buffer_get_width (GEGL_BUFFER (self->priv));
result.height = gegl_buffer_get_height (GEGL_BUFFER (self->priv));
}
return result;
}
static void class_init (GeglOperationClass *klass)
{
gegl_extension_handler_register (".raw", "raw-load");
gegl_extension_handler_register (".RAW", "raw-load");
gegl_extension_handler_register (".raf", "raw-load");
gegl_extension_handler_register (".RAF", "raw-load");
gegl_extension_handler_register (".nef", "raw-load");
gegl_extension_handler_register (".NEF", "raw-load");
}
static void
load_buffer (GeglChantOperation *op_raw_load)
load_buffer (GeglChantO *op_raw_load)
{
if (!op_raw_load->priv)
if (!op_raw_load->chant_data)
{
FILE *pfp;
gchar *command;
......@@ -117,20 +68,20 @@ load_buffer (GeglChantOperation *op_raw_load)
{
GeglRectangle extent = { 0, 0, width, height };
op_raw_load->priv = (gpointer) gegl_buffer_new (&extent,
babl_format_new (
babl_model ("RGB"),
babl_type ("u16"),
babl_component ("G"),
babl_component ("B"),
babl_component ("R"),
NULL));
op_raw_load->chant_data = (gpointer) gegl_buffer_new (&extent,
babl_format_new (
babl_model ("RGB"),
babl_type ("u16"),
babl_component ("G"),
babl_component ("B"),
babl_component ("R"),
NULL));
}
{
guint16 *buf = g_new (guint16, width * height * 3);
fread (buf, 1, width * height * 3 * 2, pfp);
gegl_buffer_set (GEGL_BUFFER (op_raw_load->priv),
gegl_buffer_set (GEGL_BUFFER (op_raw_load->chant_data),
NULL,
babl_format_new (
babl_model ("RGB"),
......@@ -148,4 +99,64 @@ load_buffer (GeglChantOperation *op_raw_load)
}
}
static GeglRectangle
get_bounding_box (GeglOperation *operation)
{
GeglRectangle result = {0,0,0,0};
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
load_buffer (o);
if (o->chant_data)
{
result.width = gegl_buffer_get_width (GEGL_BUFFER (o->chant_data));
result.height = gegl_buffer_get_height (GEGL_BUFFER (o->chant_data));
}
return result;
}
static gboolean
process (GeglOperation *operation,
GeglNodeContext *context,
GeglBuffer *output_ignored,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *output;
g_assert (o->chant_data);
output = GEGL_BUFFER (o->chant_data);
gegl_node_context_set_object (context, "output", G_OBJECT (output));
o->chant_data = NULL;
return TRUE;
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationSourceClass *source_class;
operation_class = GEGL_OPERATION_CLASS (klass);
source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
source_class->process = process;
operation_class->get_bounding_box = get_bounding_box;
operation_class->name = "raw-load";
operation_class->categories = "hidden";
operation_class->description =
"Raw image loader, wrapping dcraw with pipes.";
gegl_extension_handler_register (".raw", "raw-load");
gegl_extension_handler_register (".RAW", "raw-load");
gegl_extension_handler_register (".raf", "raw-load");
gegl_extension_handler_register (".RAF", "raw-load");
gegl_extension_handler_register (".nef", "raw-load");
gegl_extension_handler_register (".NEF", "raw-load");
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment