|
Packit Service |
2781ba |
/* This file is part of GEGL.
|
|
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 2006,2007 Øyvind Kolås <pippin@gimp.org>
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "config.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include <string.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include <glib-object.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl-buffer-types.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-source.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-handler.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-handler-chain.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-storage.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_DEFINE_TYPE (GeglTileHandler, gegl_tile_handler, GEGL_TYPE_TILE_SOURCE)
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
enum
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
PROP0,
|
|
Packit Service |
2781ba |
PROP_SOURCE
|
|
Packit Service |
2781ba |
};
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gboolean gegl_tile_storage_cached_release (GeglTileStorage *storage);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_tile_handler_dispose (GObject *object)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglTileHandler *handler = GEGL_TILE_HANDLER (object);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (handler->source != NULL)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
if (!(GEGL_IS_TILE_STORAGE (handler->source) &&
|
|
Packit Service |
2781ba |
gegl_tile_storage_cached_release ((void*)handler->source)))
|
|
Packit Service |
2781ba |
g_object_unref (handler->source);
|
|
Packit Service |
2781ba |
handler->source = NULL;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_OBJECT_CLASS (gegl_tile_handler_parent_class)->dispose (object);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static gpointer
|
|
Packit Service |
2781ba |
gegl_tile_handler_command (GeglTileSource *gegl_tile_source,
|
|
Packit Service |
2781ba |
GeglTileCommand command,
|
|
Packit Service |
2781ba |
gint x,
|
|
Packit Service |
2781ba |
gint y,
|
|
Packit Service |
2781ba |
gint z,
|
|
Packit Service |
2781ba |
gpointer data)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglTileHandler *handler = (GeglTileHandler*)gegl_tile_source;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return gegl_tile_handler_source_command (handler, command, x, y, z, data);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_tile_handler_get_property (GObject *gobject,
|
|
Packit Service |
2781ba |
guint property_id,
|
|
Packit Service |
2781ba |
GValue *value,
|
|
Packit Service |
2781ba |
GParamSpec *pspec)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglTileHandler *handler = GEGL_TILE_HANDLER (gobject);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
switch (property_id)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
case PROP_SOURCE:
|
|
Packit Service |
2781ba |
g_value_set_object (value, handler->source);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
default:
|
|
Packit Service |
2781ba |
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
void
|
|
Packit Service |
2781ba |
gegl_tile_handler_set_source (GeglTileHandler *handler,
|
|
Packit Service |
2781ba |
GeglTileSource *source)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
if (handler->source != NULL)
|
|
Packit Service |
2781ba |
g_object_unref (handler->source);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (source == NULL)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
handler->source = NULL;
|
|
Packit Service |
2781ba |
return;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
handler->source = g_object_ref (source);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_tile_handler_set_property (GObject *gobject,
|
|
Packit Service |
2781ba |
guint property_id,
|
|
Packit Service |
2781ba |
const GValue *value,
|
|
Packit Service |
2781ba |
GParamSpec *pspec)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglTileHandler *handler = GEGL_TILE_HANDLER (gobject);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
switch (property_id)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
case PROP_SOURCE:
|
|
Packit Service |
2781ba |
gegl_tile_handler_set_source (handler, GEGL_TILE_SOURCE (g_value_get_object (value)));
|
|
Packit Service |
2781ba |
return;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
default:
|
|
Packit Service |
2781ba |
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_tile_handler_class_init (GeglTileHandlerClass *klass)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gobject_class->set_property = gegl_tile_handler_set_property;
|
|
Packit Service |
2781ba |
gobject_class->get_property = gegl_tile_handler_get_property;
|
|
Packit Service |
2781ba |
gobject_class->dispose = gegl_tile_handler_dispose;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_SOURCE,
|
|
Packit Service |
2781ba |
g_param_spec_object ("source",
|
|
Packit Service |
2781ba |
"GeglBuffer",
|
|
Packit Service |
2781ba |
"The tilestore to be a facade for",
|
|
Packit Service |
2781ba |
G_TYPE_OBJECT,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_tile_handler_init (GeglTileHandler *self)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
((GeglTileSource*)self)->command = gegl_tile_handler_command;
|
|
Packit Service |
2781ba |
self->source = NULL;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|