示例#1
0
static void
gegl_config_use_opencl_notify (GObject    *gobject,
                               GParamSpec *pspec,
                               gpointer    user_data)
{
  GeglConfig *cfg = GEGL_CONFIG (gobject);

  g_signal_handlers_block_by_func (gobject,
                                   gegl_config_use_opencl_notify,
                                   NULL);

  if (cfg->use_opencl)
    {
       gegl_cl_init (NULL);
    }
  else
    {
      gegl_cl_disable ();
    }

  cfg->use_opencl = gegl_cl_is_accelerated();

  g_signal_handlers_unblock_by_func (gobject,
                                     gegl_config_use_opencl_notify,
                                     NULL);
}
示例#2
0
static void
gegl_config_set_property (GObject      *gobject,
                          guint         property_id,
                          const GValue *value,
                          GParamSpec   *pspec)
{
  GeglConfig *config = GEGL_CONFIG (gobject);

  switch (property_id)
    {
      case PROP_CACHE_SIZE:
        config->cache_size = g_value_get_int (value);
        break;
      case PROP_CHUNK_SIZE:
        config->chunk_size = g_value_get_int (value);
        break;
      case PROP_TILE_WIDTH:
        config->tile_width = g_value_get_int (value);
        break;
      case PROP_TILE_HEIGHT:
        config->tile_height = g_value_get_int (value);
        break;
      case PROP_QUALITY:
        config->quality = g_value_get_double (value);
        return;
      case PROP_BABL_TOLERANCE:
          {
            static gboolean first = TRUE;
            static gboolean overridden = FALSE;

            gchar buf[256];

            if (first)
              {
                if (g_getenv ("BABL_TOLERANCE") != NULL)
                  overridden = TRUE;
                first = FALSE;
              }
            if (!overridden)
              {
                config->babl_tolerance = g_value_get_double (value);
                g_sprintf (buf, "%f", config->babl_tolerance);
                g_setenv ("BABL_TOLERANCE", buf, 0);
                /* babl picks up the babl error through the environment, babl
                 * caches valid conversions though so this needs to be set
                 * before any processing is done
                 */
              }
          }
        return;
      case PROP_SWAP:
        if (config->swap)
         g_free (config->swap);
        config->swap = g_value_dup_string (value);
        break;
      case PROP_THREADS:
        config->threads = g_value_get_int (value);
        return;
      case PROP_USE_OPENCL:
        config->use_opencl = g_value_get_boolean (value);

        if (config->use_opencl)
          gegl_cl_init (NULL);

        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
        break;
    }
}