new files containing gimp_bpp_to_babl_format().

2007-12-29  Michael Natterer  <mitch@gimp.org>

	* app/gegl/gimp-gegl-utils.c: new files containing
	gimp_bpp_to_babl_format().

	* app/gegl/gimpoptilesink.[ch]
	* app/gegl/gimpoptilesource.[ch]: renamed..

	* app/gegl/gimpoperationtilesink.[ch]
	* app/gegl/gimpoperationtilesource.[ch]: ...to these. Cleaned them
	up quite a bit more.

	* app/gegl/Makefile.am
	* app/gegl/gimp-gegl.c: changed accordingly.


svn path=/trunk/; revision=24460
This commit is contained in:
Michael Natterer
2007-12-29 02:19:23 +00:00
committed by Michael Natterer
parent 479a649898
commit 70f07cd509
9 changed files with 187 additions and 121 deletions

View File

@ -1,3 +1,18 @@
2007-12-29 Michael Natterer <mitch@gimp.org>
* app/gegl/gimp-gegl-utils.c: new files containing
gimp_bpp_to_babl_format().
* app/gegl/gimpoptilesink.[ch]
* app/gegl/gimpoptilesource.[ch]: renamed..
* app/gegl/gimpoperationtilesink.[ch]
* app/gegl/gimpoperationtilesource.[ch]: ...to these. Cleaned them
up quite a bit more.
* app/gegl/Makefile.am
* app/gegl/gimp-gegl.c: changed accordingly.
2007-12-29 Michael Natterer <mitch@gimp.org>
Some cleanup...

View File

@ -3,12 +3,14 @@
noinst_LIBRARIES = libappgegl.a
libappgegl_a_SOURCES = \
gimp-gegl.c \
gimp-gegl.h \
gimpoptilesink.c \
gimpoptilesink.h \
gimpoptilesource.c \
gimpoptilesource.h
gimp-gegl.c \
gimp-gegl.h \
gimp-gegl-utils.c \
gimp-gegl-utils.h \
gimpoperationtilesink.c \
gimpoperationtilesink.h \
gimpoperationtilesource.c \
gimpoperationtilesource.h
INCLUDES = \
-I. \

View File

@ -0,0 +1,45 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimp-gegl-utils.h
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gegl.h>
#include "gegl-types.h"
#include "gimp-gegl-utils.h"
const Babl *
gimp_bpp_to_babl_format (guint bpp)
{
switch (bpp)
{
case 1: return babl_format ("Y' u8");
case 2: return babl_format ("Y'A u8");
case 3: return babl_format ("R'G'B' u8");
case 4: return babl_format ("R'G'B'A u8");
}
g_warning ("bpp !(>0 && <=4)");
return NULL;
}

View File

@ -0,0 +1,29 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimp-gegl-utils.h
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_GEGL_UTILS_H__
#define __GIMP_GEGL_UTILS_H__
const Babl * gimp_bpp_to_babl_format (guint bpp);
#endif /* __GIMP_GEGL_UTILS_H__ */

View File

@ -29,8 +29,8 @@
#include "gegl-types.h"
#include "gimp-gegl.h"
#include "gimpoptilesink.h"
#include "gimpoptilesource.h"
#include "gimpoperationtilesink.h"
#include "gimpoperationtilesource.h"
void

View File

@ -34,7 +34,8 @@
#include "base/tile-manager.h"
#include "base/pixel-region.h"
#include "gimpoptilesink.h"
#include "gimp-gegl-utils.h"
#include "gimpoperationtilesink.h"
enum
@ -44,33 +45,21 @@ enum
};
static void get_property (GObject *gobject,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void tile_sink_get_property (GObject *gobject,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void tile_sink_set_property (GObject *gobject,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void set_property (GObject *gobject,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean tile_sink_process (GeglOperation *operation,
gpointer context_id);
static gboolean process (GeglOperation *operation,
gpointer context_id);
static Babl *bpp_to_format (guint bpp)
{
switch (bpp)
{
case 1: return babl_format ("Y' u8");
case 2: return babl_format ("Y'A u8");
case 3: return babl_format ("R'G'B' u8");
case 4: return babl_format ("R'G'B'A u8");
}
g_warning ("bpp !(>0 && <=4)");
return NULL;
}
G_DEFINE_TYPE (GimpOperationTileSink, gimp_operation_tile_sink, GEGL_TYPE_OPERATION_SINK)
G_DEFINE_TYPE (GimpOperationTileSink, gimp_operation_tile_sink,
GEGL_TYPE_OPERATION_SINK)
static void
gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass * klass)
@ -79,10 +68,10 @@ gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass * klass)
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationSinkClass *sink_class = GEGL_OPERATION_SINK_CLASS (klass);
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->set_property = tile_sink_set_property;
object_class->get_property = tile_sink_get_property;
sink_class->process = process;
sink_class->process = tile_sink_process;
gegl_operation_class_set_name (operation_class, "gimp-tilemanager-sink");;
@ -101,10 +90,10 @@ gimp_operation_tile_sink_init (GimpOperationTileSink *self)
}
static void
get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
tile_sink_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationTileSink *self = GIMP_OPERATION_TILE_SINK (object);
@ -121,10 +110,10 @@ get_property (GObject *object,
}
static void
set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
tile_sink_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationTileSink *self = GIMP_OPERATION_TILE_SINK (object);
@ -141,18 +130,18 @@ set_property (GObject *object,
}
static gboolean
process (GeglOperation *operation,
gpointer context_id)
tile_sink_process (GeglOperation *operation,
gpointer context_id)
{
GimpOperationTileSink *self = GIMP_OPERATION_TILE_SINK (operation);
GeglBuffer *input;
GeglRectangle *extent;
if (self->tile_manager)
{
gpointer pr;
PixelRegion destPR;
Babl *format;
GeglBuffer *input;
GeglRectangle *extent;
gpointer pr;
PixelRegion destPR;
const Babl *format;
/* is this somethings that should be done already for all sinks? */
input = GEGL_BUFFER (gegl_operation_get_data (operation, context_id,
@ -165,7 +154,7 @@ process (GeglOperation *operation,
extent->width, extent->height,
TRUE);
format = bpp_to_format (tile_manager_bpp (self->tile_manager));
format = gimp_bpp_to_babl_format (tile_manager_bpp (self->tile_manager));
for (pr = pixel_regions_register (1, &destPR);
pr;

View File

@ -34,7 +34,8 @@
#include "base/tile-manager.h"
#include "base/pixel-region.h"
#include "gimpoptilesource.h"
#include "gimp-gegl-utils.h"
#include "gimpoperationtilesource.h"
enum
@ -44,19 +45,19 @@ enum
};
static void get_property (GObject *gobject,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void set_property (GObject *gobject,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void tile_source_get_property (GObject *gobject,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void tile_source_set_property (GObject *gobject,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean process (GeglOperation *operation,
gpointer context_id);
static GeglRectangle tile_source_get_defined_region (GeglOperation *operation);
static GeglRectangle get_defined_region (GeglOperation *operation);
static gboolean tile_source_process (GeglOperation *operation,
gpointer context_id);
G_DEFINE_TYPE (GimpOperationTileSource, gimp_operation_tile_source,
@ -70,12 +71,12 @@ gimp_operation_tile_source_class_init (GimpOperationTileSourceClass * klass)
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationSourceClass *source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->set_property = tile_source_set_property;
object_class->get_property = tile_source_get_property;
operation_class->get_defined_region = get_defined_region;
operation_class->get_defined_region = tile_source_get_defined_region;
source_class->process = process;
source_class->process = tile_source_process;
gegl_operation_class_set_name (operation_class, "gimp-tilemanager-source");;
@ -95,10 +96,10 @@ gimp_operation_tile_source_init (GimpOperationTileSource *self)
}
static void
get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
tile_source_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (object);
@ -109,15 +110,16 @@ get_property (GObject *object,
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
tile_source_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (object);
@ -128,44 +130,45 @@ set_property (GObject *object,
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static Babl *
bpp_to_format (guint bpp)
static GeglRectangle
tile_source_get_defined_region (GeglOperation *operation)
{
switch (bpp)
{
case 1: return babl_format ("Y' u8");
case 2: return babl_format ("Y'A u8");
case 3: return babl_format ("R'G'B' u8");
case 4: return babl_format ("R'G'B'A u8");
}
g_warning ("bpp !(>0 && <=4)");
return NULL;
}
static gboolean
process (GeglOperation *operation,
gpointer context_id)
{
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
GeglBuffer *output;
Babl *format;
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
GeglRectangle result = { 0, };
if (self->tile_manager)
{
PixelRegion srcPR;
gpointer pr;
GeglRectangle extent = { 0, 0,
tile_manager_width (self->tile_manager),
tile_manager_height (self->tile_manager) };
result.x = 0;
result.y = 0;
result.width = tile_manager_width (self->tile_manager);
result.height = tile_manager_height (self->tile_manager);
}
format = bpp_to_format (tile_manager_bpp (self->tile_manager));
return result;
}
static gboolean
tile_source_process (GeglOperation *operation,
gpointer context_id)
{
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
if (self->tile_manager)
{
GeglBuffer *output;
const Babl *format;
PixelRegion srcPR;
gpointer pr;
GeglRectangle extent = { 0, 0,
tile_manager_width (self->tile_manager),
tile_manager_height (self->tile_manager) };
format = gimp_bpp_to_babl_format (tile_manager_bpp (self->tile_manager));
output = gegl_buffer_new (&extent, format);
@ -189,20 +192,3 @@ process (GeglOperation *operation,
return TRUE;
}
static GeglRectangle
get_defined_region (GeglOperation *operation)
{
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
GeglRectangle result = { 0, };
if (self->tile_manager)
{
result.x = 0;
result.y = 0;
result.width = tile_manager_width (self->tile_manager);
result.height = tile_manager_height (self->tile_manager);
}
return result;
}