|
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 <glib.h>
|
|
Packit Service |
2781ba |
#include <glib-object.h>
|
|
Packit Service |
2781ba |
#include <string.h>
|
|
Packit Service |
2781ba |
#include <glib/gprintf.h>
|
|
Packit Service |
2781ba |
#include "config.h"
|
|
Packit Service |
2781ba |
#include "gegl.h"
|
|
Packit Service |
2781ba |
#include "gegl-types-internal.h"
|
|
Packit Service |
2781ba |
#include "gegl-config.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "opencl/gegl-cl.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_DEFINE_TYPE (GeglConfig, gegl_config, G_TYPE_OBJECT)
|
|
Packit Service |
2781ba |
|
|
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_QUALITY,
|
|
Packit Service |
2781ba |
PROP_CACHE_SIZE,
|
|
Packit Service |
2781ba |
PROP_CHUNK_SIZE,
|
|
Packit Service |
2781ba |
PROP_SWAP,
|
|
Packit Service |
2781ba |
PROP_BABL_TOLERANCE,
|
|
Packit Service |
2781ba |
PROP_TILE_WIDTH,
|
|
Packit Service |
2781ba |
PROP_TILE_HEIGHT,
|
|
Packit Service |
2781ba |
PROP_THREADS,
|
|
Packit Service |
2781ba |
PROP_USE_OPENCL
|
|
Packit Service |
2781ba |
};
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_config_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 |
GeglConfig *config = GEGL_CONFIG (gobject);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
switch (property_id)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
case PROP_CACHE_SIZE:
|
|
Packit Service |
2781ba |
g_value_set_int (value, config->cache_size);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_CHUNK_SIZE:
|
|
Packit Service |
2781ba |
g_value_set_int (value, config->chunk_size);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_TILE_WIDTH:
|
|
Packit Service |
2781ba |
g_value_set_int (value, config->tile_width);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_TILE_HEIGHT:
|
|
Packit Service |
2781ba |
g_value_set_int (value, config->tile_height);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_QUALITY:
|
|
Packit Service |
2781ba |
g_value_set_double (value, config->quality);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_BABL_TOLERANCE:
|
|
Packit Service |
2781ba |
g_value_set_double (value, config->babl_tolerance);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_SWAP:
|
|
Packit Service |
2781ba |
g_value_set_string (value, config->swap);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_THREADS:
|
|
Packit Service |
2781ba |
g_value_set_int (value, config->threads);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
case PROP_USE_OPENCL:
|
|
Packit Service |
2781ba |
g_value_set_boolean (value, config->use_opencl);
|
|
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 |
gegl_config_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 |
GeglConfig *config = GEGL_CONFIG (gobject);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
switch (property_id)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
case PROP_CACHE_SIZE:
|
|
Packit Service |
2781ba |
config->cache_size = g_value_get_int (value);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
case PROP_CHUNK_SIZE:
|
|
Packit Service |
2781ba |
config->chunk_size = g_value_get_int (value);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
case PROP_TILE_WIDTH:
|
|
Packit Service |
2781ba |
config->tile_width = g_value_get_int (value);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
case PROP_TILE_HEIGHT:
|
|
Packit Service |
2781ba |
config->tile_height = g_value_get_int (value);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
case PROP_QUALITY:
|
|
Packit Service |
2781ba |
config->quality = g_value_get_double (value);
|
|
Packit Service |
2781ba |
return;
|
|
Packit Service |
2781ba |
case PROP_BABL_TOLERANCE:
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
static gboolean first = TRUE;
|
|
Packit Service |
2781ba |
static gboolean overridden = FALSE;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gchar buf[256];
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (first)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
if (g_getenv ("BABL_TOLERANCE") != NULL)
|
|
Packit Service |
2781ba |
overridden = TRUE;
|
|
Packit Service |
2781ba |
first = FALSE;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
if (!overridden)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
config->babl_tolerance = g_value_get_double (value);
|
|
Packit Service |
2781ba |
g_sprintf (buf, "%f", config->babl_tolerance);
|
|
Packit Service |
2781ba |
g_setenv ("BABL_TOLERANCE", buf, 0);
|
|
Packit Service |
2781ba |
/* babl picks up the babl error through the environment, babl
|
|
Packit Service |
2781ba |
* caches valid conversions though so this needs to be set
|
|
Packit Service |
2781ba |
* before any processing is done
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
return;
|
|
Packit Service |
2781ba |
case PROP_SWAP:
|
|
Packit Service |
2781ba |
if (config->swap)
|
|
Packit Service |
2781ba |
g_free (config->swap);
|
|
Packit Service |
2781ba |
config->swap = g_value_dup_string (value);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
case PROP_THREADS:
|
|
Packit Service |
2781ba |
config->threads = g_value_get_int (value);
|
|
Packit Service |
2781ba |
return;
|
|
Packit Service |
2781ba |
case PROP_USE_OPENCL:
|
|
Packit Service |
2781ba |
config->use_opencl = g_value_get_boolean (value);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (config->use_opencl)
|
|
Packit Service |
2781ba |
gegl_cl_init (NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
break;
|
|
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_config_finalize (GObject *gobject)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglConfig *config = GEGL_CONFIG (gobject);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (config->swap)
|
|
Packit Service |
2781ba |
g_free (config->swap);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_OBJECT_CLASS (gegl_config_parent_class)->finalize (gobject);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_config_class_init (GeglConfigClass *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 = gegl_config_set_property;
|
|
Packit Service |
2781ba |
gobject_class->get_property = gegl_config_get_property;
|
|
Packit Service |
2781ba |
gobject_class->finalize = gegl_config_finalize;
|
|
Packit Service |
2781ba |
|
|
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", "default tile width for created buffers.",
|
|
Packit Service |
2781ba |
0, G_MAXINT, 64,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_TILE_HEIGHT,
|
|
Packit Service |
2781ba |
g_param_spec_int ("tile-height", "Tile height", "default tile height for created buffers.",
|
|
Packit Service |
2781ba |
0, G_MAXINT, 64,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_CACHE_SIZE,
|
|
Packit Service |
2781ba |
g_param_spec_int ("cache-size", "Cache size", "size of cache in bytes",
|
|
Packit Service |
2781ba |
0, G_MAXINT, 512*1024*1024,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_CHUNK_SIZE,
|
|
Packit Service |
2781ba |
g_param_spec_int ("chunk-size", "Chunk size",
|
|
Packit Service |
2781ba |
"the number of pixels processed simultaneously by GEGL.",
|
|
Packit Service |
2781ba |
1, G_MAXINT, 256*300,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_QUALITY,
|
|
Packit Service |
2781ba |
g_param_spec_double ("quality", "Quality", "quality/speed trade off 1.0 = full quality, 0.0=full speed",
|
|
Packit Service |
2781ba |
0.0, 1.0, 1.0,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_BABL_TOLERANCE,
|
|
Packit Service |
2781ba |
g_param_spec_double ("babl-tolerance", "babl error", "the error tolerance babl operates with",
|
|
Packit Service |
2781ba |
0.0, 0.2, 0.002,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE|
|
|
Packit Service |
2781ba |
G_PARAM_CONSTRUCT));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_SWAP,
|
|
Packit Service |
2781ba |
g_param_spec_string ("swap", "Swap", "where gegl stores it's swap files", NULL,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_THREADS,
|
|
Packit Service |
2781ba |
g_param_spec_int ("threads", "Number of concurrent evaluation threads", "default tile height for created buffers.",
|
|
Packit Service |
2781ba |
0, 16, 1,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_USE_OPENCL,
|
|
Packit Service |
2781ba |
g_param_spec_boolean ("use-opencl", "Use OpenCL", "Try to use OpenCL",
|
|
Packit Service |
2781ba |
TRUE,
|
|
Packit Service |
2781ba |
G_PARAM_READWRITE));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_config_init (GeglConfig *self)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
self->swap = NULL;
|
|
Packit Service |
2781ba |
self->quality = 1.0;
|
|
Packit Service |
2781ba |
self->cache_size = 256 * 1024 * 1024;
|
|
Packit Service |
2781ba |
self->chunk_size = 512 * 512;
|
|
Packit Service |
2781ba |
self->tile_width = 128;
|
|
Packit Service |
2781ba |
self->tile_height = 64;
|
|
Packit Service |
2781ba |
self->threads = 1;
|
|
Packit Service |
2781ba |
self->use_opencl = TRUE;
|
|
Packit Service |
2781ba |
}
|