|
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 GEGL; 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 <babl/babl.h>
|
|
Packit Service |
2781ba |
#include "gegl-buffer-types.h"
|
|
Packit Service |
2781ba |
#include "gegl-buffer-private.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-source.h"
|
|
Packit Service |
2781ba |
#include "gegl-tile-backend.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_DEFINE_TYPE (GeglTileBackend, gegl_tile_backend, GEGL_TYPE_TILE_SOURCE)
|
|
Packit Service |
2781ba |
static GObjectClass * parent_class = NULL;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
enum
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
PROP_0,
|
|
Packit Service |
2781ba |
PROP_TILE_WIDTH,
|
|
Packit Service |
2781ba |
PROP_TILE_HEIGHT,
|
|
Packit Service |
2781ba |
PROP_PX_SIZE,
|
|
Packit Service |
2781ba |
PROP_TILE_SIZE,
|
|
Packit Service |
2781ba |
PROP_FORMAT
|
|
Packit Service |
2781ba |
};
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
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 |
GeglTileBackend *backend = GEGL_TILE_BACKEND (gobject);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
switch (property_id)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
case PROP_TILE_WIDTH:
|
|
Packit Service |
2781ba |
g_value_set_int (value, backend->priv->tile_width);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_TILE_HEIGHT:
|
|
Packit Service |
2781ba |
g_value_set_int (value, backend->priv->tile_height);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_TILE_SIZE:
|
|
Packit Service |
2781ba |
g_value_set_int (value, backend->priv->tile_size);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_PX_SIZE:
|
|
Packit Service |
2781ba |
g_value_set_int (value, backend->priv->px_size);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_FORMAT:
|
|
Packit Service |
2781ba |
g_value_set_pointer (value, (void*)backend->priv->format);
|
|
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 |
static void
|
|
Packit Service |
2781ba |
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 |
GeglTileBackend *backend = GEGL_TILE_BACKEND (gobject);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
switch (property_id)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
case PROP_TILE_WIDTH:
|
|
Packit Service |
2781ba |
backend->priv->tile_width = g_value_get_int (value);
|
|
Packit Service |
2781ba |
return;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_TILE_HEIGHT:
|
|
Packit Service |
2781ba |
backend->priv->tile_height = g_value_get_int (value);
|
|
Packit Service |
2781ba |
return;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_FORMAT:
|
|
Packit Service |
2781ba |
backend->priv->format = g_value_get_pointer (value);
|
|
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 |
static GObject *
|
|
Packit Service |
2781ba |
constructor (GType type,
|
|
Packit Service |
2781ba |
guint n_params,
|
|
Packit Service |
2781ba |
GObjectConstructParam *params)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GObject *object;
|
|
Packit Service |
2781ba |
GeglTileBackend *backend;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
Packit Service |
2781ba |
backend = GEGL_TILE_BACKEND (object);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_assert (backend->priv->tile_width > 0 && backend->priv->tile_height > 0);
|
|
Packit Service |
2781ba |
g_assert (backend->priv->format);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
backend->priv->px_size = babl_format_get_bytes_per_pixel (backend->priv->format);
|
|
Packit Service |
2781ba |
backend->priv->tile_size = backend->priv->tile_width * backend->priv->tile_height * backend->priv->px_size;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return object;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_tile_backend_class_init (GeglTileBackendClass *klass)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
parent_class = g_type_class_peek_parent (klass);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gobject_class->set_property = set_property;
|
|
Packit Service |
2781ba |
gobject_class->get_property = get_property;
|
|
Packit Service |
2781ba |
gobject_class->constructor = constructor;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_TILE_WIDTH,
|
|
Packit Service |
2781ba |
g_param_spec_int ("tile-width", "tile-width", "Tile width in pixels",
|
|
Packit Service |
2781ba |
0, G_MAXINT, 0,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE |
|
|
Packit Service |
2781ba |
G_PARAM_CONSTRUCT_ONLY));
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_TILE_HEIGHT,
|
|
Packit Service |
2781ba |
g_param_spec_int ("tile-height", "tile-height", "Tile height in pixels",
|
|
Packit Service |
2781ba |
0, G_MAXINT, 0,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE |
|
|
Packit Service |
2781ba |
G_PARAM_CONSTRUCT_ONLY));
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_TILE_SIZE,
|
|
Packit Service |
2781ba |
g_param_spec_int ("tile-size", "tile-size", "Size of the tiles linear buffer in bytes",
|
|
Packit Service |
2781ba |
0, G_MAXINT, 0,
|
|
Packit Service |
2781ba |
G_PARAM_READABLE));
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_PX_SIZE,
|
|
Packit Service |
2781ba |
g_param_spec_int ("px-size", "px-size", "Size of a single pixel in bytes",
|
|
Packit Service |
2781ba |
0, G_MAXINT, 0,
|
|
Packit Service |
2781ba |
G_PARAM_READABLE));
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_FORMAT,
|
|
Packit Service |
2781ba |
g_param_spec_pointer ("format", "format", "babl format",
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE |
|
|
Packit Service |
2781ba |
G_PARAM_CONSTRUCT_ONLY));
|
|
Packit Service |
2781ba |
g_type_class_add_private (gobject_class, sizeof (GeglTileBackendPrivate));
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define GEGL_TILE_BACKEND_GET_PRIVATE(obj) \
|
|
Packit Service |
2781ba |
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GEGL_TYPE_TILE_BACKEND, GeglTileBackendPrivate))
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_tile_backend_init (GeglTileBackend *self)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
self->priv = GEGL_TILE_BACKEND_GET_PRIVATE (self);
|
|
Packit Service |
2781ba |
self->priv->shared = FALSE;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gint gegl_tile_backend_get_tile_size (GeglTileBackend *tile_backend)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
return tile_backend->priv->tile_size;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
const Babl *gegl_tile_backend_get_format (GeglTileBackend *tile_backend)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
return tile_backend->priv->format;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
void gegl_tile_backend_set_extent (GeglTileBackend *tile_backend,
|
|
Packit Service |
2781ba |
GeglRectangle *rectangle)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
tile_backend->priv->extent = *rectangle;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GeglRectangle gegl_tile_backend_get_extent (GeglTileBackend *tile_backend)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
return tile_backend->priv->extent;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GeglTileSource *gegl_tile_backend_peek_storage (GeglTileBackend *backend)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
return backend->priv->storage;
|
|
Packit Service |
2781ba |
}
|