|
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 |
#include "config.h"
|
|
Packit Service |
2781ba |
#include <glib.h>
|
|
Packit Service |
2781ba |
#include <glib-object.h>
|
|
Packit Service |
2781ba |
#include <string.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl-types.h"
|
|
Packit Service |
2781ba |
#include "gegl-matrix.h"
|
|
Packit Service |
2781ba |
#include "gegl-buffer-types.h"
|
|
Packit Service |
2781ba |
#include "gegl-buffer-private.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-handler.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-handler-empty.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-handler-cache.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-backend.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_DEFINE_TYPE (GeglTileHandlerEmpty, gegl_tile_handler_empty, GEGL_TYPE_TILE_HANDLER)
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
finalize (GObject *object)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglTileHandlerEmpty *empty = GEGL_TILE_HANDLER_EMPTY (object);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (empty->tile)
|
|
Packit Service |
2781ba |
gegl_tile_unref (empty->tile);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_OBJECT_CLASS (gegl_tile_handler_empty_parent_class)->finalize (object);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static GeglTile *
|
|
Packit Service |
2781ba |
get_tile (GeglTileSource *gegl_tile_source,
|
|
Packit Service |
2781ba |
gint x,
|
|
Packit Service |
2781ba |
gint y,
|
|
Packit Service |
2781ba |
gint z)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglTileSource *source = GEGL_TILE_HANDLER (gegl_tile_source)->source;
|
|
Packit Service |
2781ba |
GeglTileHandlerEmpty *empty = GEGL_TILE_HANDLER_EMPTY (gegl_tile_source);
|
|
Packit Service |
2781ba |
GeglTile *tile = NULL;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (source)
|
|
Packit Service |
2781ba |
tile = gegl_tile_source_get_tile (source, x, y, z);
|
|
Packit Service |
2781ba |
if (tile != NULL)
|
|
Packit Service |
2781ba |
return tile;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
tile = gegl_tile_dup (empty->tile);
|
|
Packit Service |
2781ba |
tile->x = x;
|
|
Packit Service |
2781ba |
tile->y = y;
|
|
Packit Service |
2781ba |
tile->z = z;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (empty->cache)
|
|
Packit Service |
2781ba |
gegl_tile_handler_cache_insert (empty->cache, tile, x, y, z);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return tile;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static gpointer
|
|
Packit Service |
2781ba |
gegl_tile_handler_empty_command (GeglTileSource *buffer,
|
|
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 |
if (command == GEGL_TILE_GET)
|
|
Packit Service |
2781ba |
return get_tile (buffer, x, y, z);
|
|
Packit Service |
2781ba |
return gegl_tile_handler_source_command (buffer, command, x, y, z, data);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_tile_handler_empty_class_init (GeglTileHandlerEmptyClass *klass)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
Packit Service |
2781ba |
gobject_class->finalize = finalize;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_tile_handler_empty_init (GeglTileHandlerEmpty *self)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
((GeglTileSource*)self)->command = gegl_tile_handler_empty_command;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GeglTileHandler *
|
|
Packit Service |
2781ba |
gegl_tile_handler_empty_new (GeglTileBackend *backend,
|
|
Packit Service |
2781ba |
GeglTileHandlerCache *cache)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglTileHandlerEmpty *empty = g_object_new (GEGL_TYPE_TILE_HANDLER_EMPTY, NULL);
|
|
Packit Service |
2781ba |
gint tile_size = gegl_tile_backend_get_tile_size (backend);
|
|
Packit Service |
2781ba |
empty->backend = backend;
|
|
Packit Service |
2781ba |
empty->cache = cache;
|
|
Packit Service |
2781ba |
empty->tile = gegl_tile_new (tile_size);
|
|
Packit Service |
2781ba |
memset (gegl_tile_get_data (empty->tile), 0x00, tile_size);
|
|
Packit Service |
2781ba |
return (void*)empty;
|
|
Packit Service |
2781ba |
}
|