rsvg_node_component_transfer_function_set_atts(): Parse attributes with the PHF

parent 30949e1a
......@@ -2984,53 +2984,74 @@ static void
rsvg_node_component_transfer_function_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgPropertyBag atts)
{
RsvgNodeComponentTransferFunc *data = impl;
RsvgPropertyBagIter *iter;
const char *key;
RsvgAttribute attr;
const char *value;
if ((value = rsvg_property_bag_lookup (atts, "type"))) {
if (!strcmp (value, "identity"))
data->function = identity_component_transfer_func;
else if (!strcmp (value, "table"))
data->function = table_component_transfer_func;
else if (!strcmp (value, "discrete"))
data->function = discrete_component_transfer_func;
else if (!strcmp (value, "linear"))
data->function = linear_component_transfer_func;
else if (!strcmp (value, "gamma"))
data->function = gamma_component_transfer_func;
}
iter = rsvg_property_bag_iter_begin (atts);
if ((value = rsvg_property_bag_lookup (atts, "tableValues"))) {
unsigned int i;
double *temp;
if (!rsvg_css_parse_number_list (value,
NUMBER_LIST_LENGTH_MAXIMUM,
256,
&temp,
&data->nbTableValues)) {
rsvg_node_set_attribute_parse_error (node, "tableValues", "invalid number list");
return;
while (rsvg_property_bag_iter_next (iter, &key, &attr, &value)) {
switch (attr) {
case RSVG_ATTRIBUTE_TYPE:
if (!strcmp (value, "identity"))
data->function = identity_component_transfer_func;
else if (!strcmp (value, "table"))
data->function = table_component_transfer_func;
else if (!strcmp (value, "discrete"))
data->function = discrete_component_transfer_func;
else if (!strcmp (value, "linear"))
data->function = linear_component_transfer_func;
else if (!strcmp (value, "gamma"))
data->function = gamma_component_transfer_func;
break;
case RSVG_ATTRIBUTE_TABLE_VALUES: {
unsigned int i;
double *temp;
if (!rsvg_css_parse_number_list (value,
NUMBER_LIST_LENGTH_MAXIMUM,
256,
&temp,
&data->nbTableValues)) {
rsvg_node_set_attribute_parse_error (node, "tableValues", "invalid number list");
goto out;
}
data->tableValues = g_new0 (gint, data->nbTableValues);
for (i = 0; i < data->nbTableValues; i++)
data->tableValues[i] = temp[i] * 255.;
g_free (temp);
break;
}
data->tableValues = g_new0 (gint, data->nbTableValues);
for (i = 0; i < data->nbTableValues; i++)
data->tableValues[i] = temp[i] * 255.;
g_free (temp);
}
if ((value = rsvg_property_bag_lookup (atts, "slope"))) {
data->slope = g_ascii_strtod (value, NULL) * 255.;
}
if ((value = rsvg_property_bag_lookup (atts, "intercept"))) {
data->intercept = g_ascii_strtod (value, NULL) * 255.;
}
if ((value = rsvg_property_bag_lookup (atts, "amplitude"))) {
data->amplitude = g_ascii_strtod (value, NULL) * 255.;
}
if ((value = rsvg_property_bag_lookup (atts, "exponent"))) {
data->exponent = g_ascii_strtod (value, NULL);
}
if ((value = rsvg_property_bag_lookup (atts, "offset"))) {
data->offset = g_ascii_strtod (value, NULL) * 255.;
case RSVG_ATTRIBUTE_SLOPE:
data->slope = g_ascii_strtod (value, NULL) * 255.;
break;
case RSVG_ATTRIBUTE_INTERCEPT:
data->intercept = g_ascii_strtod (value, NULL) * 255.;
break;
case RSVG_ATTRIBUTE_AMPLITUDE:
data->amplitude = g_ascii_strtod (value, NULL) * 255.;
break;
case RSVG_ATTRIBUTE_EXPONENT:
data->exponent = g_ascii_strtod (value, NULL);
break;
case RSVG_ATTRIBUTE_OFFSET:
data->offset = g_ascii_strtod (value, NULL) * 255.;
break;
default:
break;
}
}
out:
rsvg_property_bag_iter_end (iter);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment