Commit 479a6498 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Some cleanup...

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

	Some cleanup...

	* app/Makefile.am: change linking order.

	* app/main.c: move gegl initialization from here...

	* app/app.c: ...to here.

	* app/gegl/gimpops.c: removed.

	* app/gegl/gimp-gegl.[ch]
	* app/gegl/gegl-types.h: added.

	* app/gegl/Makefile.am: changed accordingly.

	* app/gegl/gimpoptilesink.[ch]
	* app/gegl/gimpoptilesource.[ch]: made more gimpish.


svn path=/trunk/; revision=24459
parent b06afdec
2007-12-29 Michael Natterer <mitch@gimp.org>
Some cleanup...
* app/Makefile.am: change linking order.
* app/main.c: move gegl initialization from here...
* app/app.c: ...to here.
* app/gegl/gimpops.c: removed.
* app/gegl/gimp-gegl.[ch]
* app/gegl/gegl-types.h: added.
* app/gegl/Makefile.am: changed accordingly.
* app/gegl/gimpoptilesink.[ch]
* app/gegl/gimpoptilesource.[ch]: made more gimpish.
2007-12-29 Øyvind Kolås <pippin@gimp.org>
Added adapter GEGL operations for reading and writing to TileManagers.
......
......@@ -13,9 +13,9 @@ SUBDIRS = \
paint-funcs \
composite \
base \
gegl \
config \
core \
gegl \
paint \
text \
vectors \
......@@ -99,7 +99,6 @@ gimp_2_5_LDADD = \
gui/libappgui.a \
actions/libappactions.a \
dialogs/libappdialogs.a \
gegl/libappgegl.a \
menus/libappmenus.a \
display/libappdisplay.a \
tools/libapptools.a \
......@@ -114,6 +113,7 @@ gimp_2_5_LDADD = \
paint/libapppaint.a \
text/libapptext.a \
config/libappconfig.a \
gegl/libappgegl.a \
paint-funcs/libapppaint-funcs.a \
composite/libappcomposite.a \
base/libappbase.a \
......@@ -149,7 +149,6 @@ gimp_console_2_5_LDADD = \
widgets/widgets-enums.o \
display/display-enums.o \
display/gimpdisplayoptions.o \
gegl/libappgegl.a \
pdb/libappinternal-procs.a \
xcf/libappxcf.a \
file/libappfile.a \
......@@ -160,6 +159,7 @@ gimp_console_2_5_LDADD = \
paint/libapppaint.a \
text/libapptext.a \
config/libappconfig.a \
gegl/libappgegl.a \
paint-funcs/libapppaint-funcs.a \
composite/libappcomposite.a \
base/libappbase.a \
......
......@@ -44,6 +44,8 @@
#include "base/base.h"
#include "base/tile-swap.h"
#include "gegl/gimp-gegl.h"
#include "core/gimp.h"
#include "core/gimp-user-install.h"
......@@ -186,6 +188,8 @@ app_run (const gchar *full_prog_name,
/* initialize lowlevel stuff */
swap_is_ok = base_init (config, be_verbose, use_cpu_accel);
gimp_gegl_init ();
#ifndef GIMP_CONSOLE_COMPILATION
if (! no_interface)
update_status_func = gui_init (gimp, no_splash);
......@@ -253,8 +257,8 @@ app_run (const gchar *full_prog_name,
g_object_unref (gimp);
errors_exit ();
base_exit ();
gegl_exit ();
base_exit ();
}
......@@ -290,9 +294,11 @@ app_exit_after_callback (Gimp *gimp,
#else
gegl_exit ();
/* make sure that the swap files are removed before we quit */
tile_swap_exit ();
gegl_exit ();
exit (EXIT_SUCCESS);
#endif
......
......@@ -3,9 +3,12 @@
noinst_LIBRARIES = libappgegl.a
libappgegl_a_SOURCES = \
gimp-gegl.c \
gimp-gegl.h \
gimpoptilesink.c \
gimpoptilesink.h \
gimpoptilesource.c \
gimpops.c
gimpoptilesource.h
INCLUDES = \
-I. \
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gegl-types.h
*
* 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 __OUR_GEGL_TYPES_H__
#define __OUR_GEGL_TYPES_H__
#include "base/base-types.h"
typedef struct _GimpOperationTileSink GimpOperationTileSink;
typedef struct _GimpOperationTileSource GimpOperationTileSource;
#endif /* __OUR_GEGL_TYPES_H__ */
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpops.c
* gimp-gegl.c
* Copyright (C) 2007 Øyvind Kolås <pippin@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
......@@ -19,17 +19,22 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gegl.h>
#include <gegl/buffer/gegl-buffer.h>
#include "gegl/gegl-types.h"
#include "gegl-types.h"
#include "gimp-gegl.h"
#include "gimpoptilesink.h"
#include "gimpoptilesource.h"
void gimp_gegl_ops_init (void);
void gimp_gegl_ops_init (void)
void
gimp_gegl_init (void)
{
g_type_class_ref (GIMP_TYPE_OPERATION_TILE_SINK);
g_type_class_ref (GIMP_TYPE_OPERATION_TILE_SOURCE);
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimp-gegl.h
* Copyright (C) 2007 Øyvind Kolås <pippin@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_H__
#define __GIMP_GEGL_H__
void gimp_gegl_init (void);
#endif /* __GIMP_GEGL_H__ */
......@@ -19,24 +19,38 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gegl/buffer/gegl-buffer.h>
#include "gegl/gegl-types.h"
#include "gegl-types.h"
#include "base/base-types.h"
#include "base/tile-manager.h"
#include "base/pixel-region.h"
#include "gimpoptilesink.h"
#include <string.h>
#include "app/base/base-types.h"
#include "app/base/tile-manager.h"
#include "app/base/pixel-region.h"
enum
{
PROP_0,
PROP_TILE_MANAGER
};
static void get_property (GObject *gobject,
guint prop_id,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void set_property (GObject *gobject,
guint prop_id,
guint property_id,
const GValue *value,
GParamSpec *pspec);
......@@ -56,17 +70,6 @@ static Babl *bpp_to_format (guint bpp)
return NULL;
}
enum
{
PROP_0,
PROP_TILE_MANAGER
};
static void
gimp_operation_tile_sink_init (GimpOperationTileSink *self)
{
}
G_DEFINE_TYPE (GimpOperationTileSink, gimp_operation_tile_sink, GEGL_TYPE_OPERATION_SINK)
static void
......@@ -74,55 +77,66 @@ gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationSinkClass *operation_sink_class = GEGL_OPERATION_SINK_CLASS (klass);
GeglOperationSinkClass *sink_class = GEGL_OPERATION_SINK_CLASS (klass);
object_class->set_property = set_property;
object_class->get_property = get_property;
operation_sink_class->process = process;
sink_class->process = process;
gegl_operation_class_set_name (operation_class, "gimp-tilemanager-sink");;
g_object_class_install_property (object_class,
PROP_TILE_MANAGER,
g_param_spec_pointer ("tile_manager",
"tile_manager",
g_param_spec_pointer ("tile-manager",
"Tile Manager",
"The tile manager to use as a destination",
(GParamFlags) ( (G_PARAM_READABLE | G_PARAM_WRITABLE) | G_PARAM_CONSTRUCT)));
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
gimp_operation_tile_sink_init (GimpOperationTileSink *self)
{
}
static void
get_property (GObject *object,
guint prop_id,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationTileSink *self = GIMP_OPERATION_TILE_SINK (object);
switch (prop_id)
switch (property_id)
{
case PROP_TILE_MANAGER:
g_value_set_pointer (value, self->tile_manager);
break;
default:
break;
case PROP_TILE_MANAGER:
g_value_set_pointer (value, self->tile_manager);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
set_property (GObject *object,
guint prop_id,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationTileSink *self = GIMP_OPERATION_TILE_SINK (object);
switch (prop_id)
switch (property_id)
{
case PROP_TILE_MANAGER:
self->tile_manager = g_value_get_pointer (value);
break;
default:
break;
case PROP_TILE_MANAGER:
self->tile_manager = g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
......@@ -130,19 +144,16 @@ static gboolean
process (GeglOperation *operation,
gpointer context_id)
{
GimpOperationTileSink *self;
GimpOperationTileSink *self = GIMP_OPERATION_TILE_SINK (operation);
GeglBuffer *input;
GeglRectangle *extent;
self = GIMP_OPERATION_TILE_SINK (operation);
if (self->tile_manager)
{
gpointer pr;
PixelRegion destPR;
Babl *format;
/* is this somethings that should be done already for all sinks? */
input = GEGL_BUFFER (gegl_operation_get_data (operation, context_id,
"input"));
......@@ -150,13 +161,17 @@ process (GeglOperation *operation,
extent = gegl_operation_result_rect (operation, context_id);
pixel_region_init (&destPR, self->tile_manager,
extent->x, extent->y, extent->width, extent->height, TRUE);
extent->x, extent->y,
extent->width, extent->height,
TRUE);
format = bpp_to_format (tile_manager_bpp (self->tile_manager));
for (pr = pixel_regions_register (1, &destPR); pr; pr = pixel_regions_process (pr))
for (pr = pixel_regions_register (1, &destPR);
pr;
pr = pixel_regions_process (pr))
{
GeglRectangle rect = {destPR.x, destPR.y, destPR.w, destPR.h};
GeglRectangle rect = { destPR.x, destPR.y, destPR.w, destPR.h };
gegl_buffer_get (input,
1.0, &rect, format,
......@@ -168,5 +183,6 @@ process (GeglOperation *operation,
{
g_warning ("no tilemanager?");
}
return TRUE;
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpops.c
* gimpoperationtilesink.h
* Copyright (C) 2007 Øyvind Kolås <pippin@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
......@@ -19,39 +19,35 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GIMP_OPERATION_TILE_SINK_H
#define _GIMP_OPERATION_TILE_SINK_H
#ifndef __GIMP_OPERATION_TILE_SINK_H__
#define __GIMP_OPERATION_TILE_SINK_H__
#include <glib-object.h>
#include "gegl/gegl-types.h"
#include "gegl/gegl-operation-sink.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GIMP_TYPE_OPERATION_TILE_SINK (gimp_operation_tile_sink_get_type ())
#define GIMP_OPERATION_TILE_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_TILE_SINK, GimpOperationTileSink))
#define GIMP_OPERATION_TILE_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_TILE_SINK, GimpOperationTileSinkClass))
#define GIMP_OPERATION_TILE_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_TILE_SINK, GimpOperationTileSinkClass))
typedef struct _GimpOperationTileSink GimpOperationTileSink;
typedef struct _GimpOperationTileSinkClass GimpOperationTileSinkClass;
struct _GimpOperationTileSink
{
GeglOperationSinkClass operation_sink;
gpointer tile_manager;
GeglOperationSink parent_instance;
TileManager *tile_manager;
};
typedef struct _GimpOperationTileSinkClass GimpOperationTileSinkClass;
struct _GimpOperationTileSinkClass
{
GeglOperationSinkClass operation_sink_class;
GeglOperationSinkClass operation_sink_class;
};
GType gimp_operation_tile_sink_get_type (void) G_GNUC_CONST;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
#endif /* __GIMP_OPERATION_TILE_SINK_H__ */
......@@ -19,22 +19,37 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gegl/buffer/gegl-buffer.h>
#include "gegl/gegl-types.h"
#include "gegl-types.h"
#include "base/base-types.h"
#include "base/tile-manager.h"
#include "base/pixel-region.h"
#include "gimpoptilesource.h"
#include <string.h>
#include "app/base/base-types.h"
#include "app/base/tile-manager.h"
#include "app/base/pixel-region.h"
enum
{
PROP_0,
PROP_TILE_MANAGER
};
static void get_property (GObject *gobject,
guint prop_id,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void set_property (GObject *gobject,
guint prop_id,
guint property_id,
const GValue *value,
GParamSpec *pspec);
......@@ -43,87 +58,93 @@ static gboolean process (GeglOperation *operation,
static GeglRectangle get_defined_region (GeglOperation *operation);
enum
{
PROP_0,
PROP_TILE_MANAGER
};
static void
gimp_operation_tile_source_init (GimpOperationTileSource *self)
{
}
G_DEFINE_TYPE (GimpOperationTileSource, gimp_operation_tile_source,
GEGL_TYPE_OPERATION_SOURCE)
G_DEFINE_TYPE (GimpOperationTileSource, gimp_operation_tile_source, GEGL_TYPE_OPERATION_SOURCE)
static void
gimp_operation_tile_source_class_init (GimpOperationTileSourceClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationSourceClass *operation_source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (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 = set_property;
object_class->get_property = get_property;
operation_source_class->process = process;
operation_class->get_defined_region = get_defined_region;
source_class->process = process;
gegl_operation_class_set_name (operation_class, "gimp-tilemanager-source");;
g_object_class_install_property (object_class,
PROP_TILE_MANAGER,
g_param_spec_pointer ("tile_manager",
"tile_manager",
g_param_spec_pointer ("tile-manager",
"Tile Manager",
"The tile manager to use as a destination",
(GParamFlags) ( (G_PARAM_READABLE | G_PARAM_WRITABLE) | G_PARAM_CONSTRUCT)));
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
gimp_operation_tile_source_init (GimpOperationTileSource *self)
{
}
static void
get_property (GObject *object,
guint prop_id,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (object);
switch (prop_id)
switch (property_id)
{
case PROP_TILE_MANAGER:
g_value_set_pointer (value, self->tile_manager);
break;
default:
break;
case PROP_TILE_MANAGER:
g_value_set_pointer (value, self->tile_manager);
break;
default:
break;
}
}
static void
set_property (GObject *object,
guint prop_id,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (object);
switch (prop_id)
switch (property_id)
{
case PROP_TILE_MANAGER:
self->tile_manager = g_value_get_pointer (value);
break;
default:
break;
case PROP_TILE_MANAGER:
self->tile_manager = g_value_get_pointer (value);
break;
default:
break;
}
}
static Babl *bpp_to_format (guint bpp)
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");
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;
}
......@@ -132,51 +153,56 @@ process (GeglOperation *operation,
gpointer context_id)
{
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
GeglBuffer *output;
Babl *format;
GeglBuffer *output;
Babl *format;
if (self->tile_manager)
{
PixelRegion srcPR;
gpointer pr;
GeglRectangle extent = {0,0,
tile_manager_width (self->tile_manager),
tile_manager_height (self->tile_manager)};
GeglRectangle extent = { 0, 0,
tile_manager_width (self->tile_manager),
tile_manager_height (self->tile_manager) };
format = bpp_to_format (tile_manager_bpp (self->tile_manager));
output = gegl_buffer_new (&extent, format);
pixel_region_init (&srcPR, self->tile_manager,
extent.x, extent.y, extent.width, extent.height, FALSE);
extent.x, extent.y,
extent.width, extent.height,
FALSE);
for (pr = pixel_regions_register (1, &srcPR); pr; pr = pixel_regions_process (pr))
for (pr = pixel_regions_register (1, &srcPR);
pr;
pr = pixel_regions_process (pr))
{
GeglRectangle rect = {srcPR.x, srcPR.y, srcPR.w, srcPR.h};
GeglRectangle rect = { srcPR.x, srcPR.y, srcPR.w, srcPR.h };
gegl_buffer_set (output, &rect, format, srcPR.data);
}
gegl_operation_set_data (operation, context_id, "output", G_OBJECT (output));
gegl_operation_set_data (operation, context_id,
"output", G_OBJECT (output));
}
return TRUE;
}
static GeglRectangle
get_defined_region (GeglOperation *operation)
{
GeglRectangle result = {0,0,0,0};
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
GeglRectangle result = { 0, };
if (!self->tile_manager)
if (self->tile_manager)
{
return result;
result.x = 0;
result.y = 0;
result.width = tile_manager_width (self->tile_manager);
result.height = 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);
return result;
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpops.c
* gimpoperationtilesource.h
* Copyright (C) 2007 Øyvind Kolås <pippin@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
......@@ -19,39 +19,35 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GIMP_OPERATION_TILE_SOURCE_H
#define _GIMP_OPERATION_TILE_SOURCE_H
#ifndef __GIMP_OPERATION_TILE_SOURCE_H__
#define __GIMP_OPERATION_TILE_SOURCE_H__
#include <glib-object.h>
#include "gegl/gegl-types.h"
#include "gegl/gegl-operation-source.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GIMP_TYPE_OPERATION_TILE_SOURCE (gimp_operation_tile_source_get_type ())
#define GIMP_OPERATION_TILE_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_TILE_SOURCE, GimpOperationTileSource))
#define GIMP_OPERATION_TILE_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_TILE_SOURCE, GimpOperationTileSourceClass))
#define GIMP_OPERATION_TILE_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_TILE_SOURCE, GimpOperationTileSourceClass))
typedef struct _GimpOperationTileSource GimpOperationTileSource;
typedef struct _GimpOperationTileSourceClass GimpOperationTileSourceClass;