Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Separated filters some more.

  • Loading branch information...
commit bf72dd115013fe9e2e6a7d5eeaa5b4aa80d3f5a5 1 parent a670b52
@schani authored
View
1  TODO
@@ -3,6 +3,7 @@
* 1.2.x
** GIMP Plug-In
+Antialiasing in preview for big image sizes!
Icon for about dialog
Marker icon
Color brightness bug (see mail by Alexandre Prokoudine) - ask if it's fixed
View
10 compiler.c
@@ -4509,7 +4509,7 @@ generate_interpreter_code_from_ir (mathmap_t *mathmap)
GHashTable *value_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
GHashTable *label_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
/* the first few values are the internals */
- int num_values = number_of_internals(mathmap->internals);
+ int num_values = number_of_internals(mathmap->main_filter->internals);
int num_insns = 0;
pre_native_insn_t *insn;
int index;
@@ -4668,6 +4668,8 @@ generate_ir_code (filter_t *filter, int constant_analysis, int convert_types)
next_temp_number = 1;
next_value_global_index = 0;
+ compiler_reset_variables(filter->variables);
+
result = (compvar_t**)malloc(sizeof(compvar_t*) * filter->decl->v.filter.body->result.length);
assert(result != 0);
@@ -4838,11 +4840,11 @@ compiler_template_processor (mathmap_t *mathmap, const char *directive, const ch
}
else if (strcmp(directive, "uses_ra") == 0)
{
- fprintf(out, "%d", does_mathmap_use_ra(mathmap) ? 1 : 0);
+ fprintf(out, "%d", does_filter_use_ra(mathmap->main_filter) ? 1 : 0);
}
else if (strcmp(directive, "uses_t") == 0)
{
- fprintf(out, "%d", does_mathmap_use_t(mathmap) ? 1 : 0);
+ fprintf(out, "%d", does_filter_use_t(mathmap->main_filter) ? 1 : 0);
}
else if (strcmp(directive, "filter_name") == 0)
{
@@ -4940,9 +4942,11 @@ gen_and_load_c_code (mathmap_t *mathmap, void **module_info, char *template_file
filter != 0;
++i, filter = filter->next)
{
+ g_print("compiling filter %s\n", filter->decl->name);
filter_codes[i] = generate_ir_code(filter, 0, 0);
}
+ g_print("compiling main filter\n");
main_filter_code = generate_ir_code(mathmap->main_filter, 1, 0);
c_filename = g_strdup_printf("%s%d_%d.c", TMP_PREFIX, pid, ++last_mathfunc);
View
4 exprtree.c
@@ -556,12 +556,12 @@ make_var (const char *name)
tuple_info_t info;
exprtree *tree = 0;
- if (lookup_internal(the_mathmap->internals, name, 0) != 0)
+ if (lookup_internal(the_mathmap->current_filter->internals, name, 0) != 0)
{
tree = alloc_exprtree();
tree->type = EXPR_INTERNAL;
- tree->val.internal = lookup_internal(the_mathmap->internals, name, 0);
+ tree->val.internal = lookup_internal(the_mathmap->current_filter->internals, name, 0);
tree->result = make_tuple_info(nil_tag_number, 1);
}
else if (lookup_variable_macro(name, &info) != 0)
View
4 mathmap.c
@@ -803,7 +803,7 @@ generate_code (int current_frame, float current_t)
}
if (animation_table != 0)
- gtk_widget_set_sensitive(GTK_WIDGET(animation_table), mathmap != 0 && does_mathmap_use_t(mathmap));
+ gtk_widget_set_sensitive(GTK_WIDGET(animation_table), mathmap != 0 && does_filter_use_t(mathmap->main_filter));
}
if (invocation != 0)
@@ -2224,7 +2224,7 @@ dialog_ok_callback (GtkWidget *widget, gpointer data)
if (generate_code(0, 0))
{
wint.run = TRUE;
- if (!does_mathmap_use_t(mathmap))
+ if (!does_filter_use_t(mathmap->main_filter))
mmvals.flags &= ~FLAG_ANIMATION;
gtk_widget_destroy(GTK_WIDGET(data));
}
View
7 mathmap.h
@@ -57,6 +57,7 @@ typedef struct _filter_t
int num_uservals;
userval_info_t *userval_infos;
+ internal_t *internals;
variable_t *variables;
top_level_decl_t *decl;
@@ -66,8 +67,6 @@ typedef struct _filter_t
typedef struct _mathmap_t
{
- internal_t *internals;
-
filter_t *filters;
filter_t *current_filter; /* only valid during parsing */
filter_t *main_filter;
@@ -202,8 +201,8 @@ void free_invocation (mathmap_invocation_t *invocation);
void enable_debugging (mathmap_invocation_t *invocation);
void disable_debugging (mathmap_invocation_t *invocation);
-int does_mathmap_use_ra (mathmap_t *mathmap);
-int does_mathmap_use_t (mathmap_t *mathmap);
+int does_filter_use_ra (filter_t *filter);
+int does_filter_use_t (filter_t *filter);
void start_parsing_filter (mathmap_t *mathmap);
void finish_parsing_filter (mathmap_t *mathmap);
View
9 mathmap_cmdline.c
@@ -282,7 +282,6 @@ cmdline_main (int argc, char *argv[])
#endif
int antialiasing = 0, supersampling = 0;
int img_width, img_height;
- FILE *template;
char *generator = 0;
char *template_filename, *opmacros_filename;
userval_info_t *userval_info;
@@ -449,13 +448,7 @@ cmdline_main (int argc, char *argv[])
template_filename = g_strdup_printf("%s/mathmap/%s", GIMPDATADIR, MAIN_TEMPLATE_FILENAME);
opmacros_filename = g_strdup_printf("%s/mathmap/%s", GIMPDATADIR, OPMACROS_FILENAME);
- template = fopen(template_filename, "r");
- if (template == 0)
- {
- fprintf(stderr, "Error: could not open template file `%s'.\n", template_filename);
- exit(1);
- }
- mathmap = compile_mathmap(argv[optind], template, opmacros_filename);
+ mathmap = compile_mathmap(argv[optind], template_filename, opmacros_filename);
if (mathmap == 0)
{
fprintf(stderr, "Error: %s\n", error_string);
View
62 mathmap_common.c
@@ -127,12 +127,30 @@ register_args_as_uservals (filter_t *filter, arg_decl_t *arg_decls)
}
}
+static void
+init_internals (filter_t *filter)
+{
+ register_internal(&filter->internals, "x", CONST_Y | CONST_T);
+ register_internal(&filter->internals, "y", CONST_X | CONST_T);
+ register_internal(&filter->internals, "r", CONST_T);
+ register_internal(&filter->internals, "a", CONST_T);
+ register_internal(&filter->internals, "t", CONST_X | CONST_Y);
+ register_internal(&filter->internals, "X", CONST_X | CONST_Y | CONST_T);
+ register_internal(&filter->internals, "Y", CONST_X | CONST_Y | CONST_T);
+ register_internal(&filter->internals, "W", CONST_X | CONST_Y | CONST_T);
+ register_internal(&filter->internals, "H", CONST_X | CONST_Y | CONST_T);
+ register_internal(&filter->internals, "R", CONST_X | CONST_Y | CONST_T);
+ register_internal(&filter->internals, "frame", CONST_X | CONST_Y);
+}
+
void
start_parsing_filter (mathmap_t *mathmap)
{
g_assert(mathmap->current_filter == 0);
mathmap->current_filter = g_new0(filter_t, 1);
+
+ init_internals(mathmap->current_filter);
}
void
@@ -213,27 +231,11 @@ free_invocation (mathmap_invocation_t *invocation)
#define R_INTERNAL_INDEX 2
#define A_INTERNAL_INDEX 3
-void
-init_internals (mathmap_t *mathmap)
-{
- register_internal(&mathmap->internals, "x", CONST_Y | CONST_T);
- register_internal(&mathmap->internals, "y", CONST_X | CONST_T);
- register_internal(&mathmap->internals, "r", CONST_T);
- register_internal(&mathmap->internals, "a", CONST_T);
- register_internal(&mathmap->internals, "t", CONST_X | CONST_Y);
- register_internal(&mathmap->internals, "X", CONST_X | CONST_Y | CONST_T);
- register_internal(&mathmap->internals, "Y", CONST_X | CONST_Y | CONST_T);
- register_internal(&mathmap->internals, "W", CONST_X | CONST_Y | CONST_T);
- register_internal(&mathmap->internals, "H", CONST_X | CONST_Y | CONST_T);
- register_internal(&mathmap->internals, "R", CONST_X | CONST_Y | CONST_T);
- register_internal(&mathmap->internals, "frame", CONST_X | CONST_Y);
-}
-
int
-does_mathmap_use_ra (mathmap_t *mathmap)
+does_filter_use_ra (filter_t *filter)
{
- internal_t *r_internal = lookup_internal(mathmap->internals, "r", 1);
- internal_t *a_internal = lookup_internal(mathmap->internals, "a", 1);
+ internal_t *r_internal = lookup_internal(filter->internals, "r", 1);
+ internal_t *a_internal = lookup_internal(filter->internals, "a", 1);
assert(r_internal != 0 && a_internal != 0);
@@ -241,9 +243,9 @@ does_mathmap_use_ra (mathmap_t *mathmap)
}
int
-does_mathmap_use_t (mathmap_t *mathmap)
+does_filter_use_t (filter_t *filter)
{
- internal_t *t_internal = lookup_internal(mathmap->internals, "t", 1);
+ internal_t *t_internal = lookup_internal(filter->internals, "t", 1);
assert(t_internal != 0);
@@ -258,8 +260,6 @@ parse_mathmap (char *expression)
mathmap = g_new0(mathmap_t, 1);
- init_internals(mathmap);
-
the_mathmap = mathmap;
DO_JUMP_CODE {
@@ -543,23 +543,23 @@ update_image_internals (mathmap_invocation_t *invocation)
if (invocation->mathmap->flags & MATHMAP_FLAG_NATIVE)
return;
- internal = lookup_internal(invocation->mathmap->internals, "t", 1);
+ internal = lookup_internal(invocation->mathmap->main_filter->internals, "t", 1);
set_float_internal(invocation, internal->index, invocation->current_t);
- internal = lookup_internal(invocation->mathmap->internals, "X", 1);
+ internal = lookup_internal(invocation->mathmap->main_filter->internals, "X", 1);
set_float_internal(invocation, internal->index, invocation->image_X);
- internal = lookup_internal(invocation->mathmap->internals, "Y", 1);
+ internal = lookup_internal(invocation->mathmap->main_filter->internals, "Y", 1);
set_float_internal(invocation, internal->index, invocation->image_Y);
- internal = lookup_internal(invocation->mathmap->internals, "W", 1);
+ internal = lookup_internal(invocation->mathmap->main_filter->internals, "W", 1);
set_float_internal(invocation, internal->index, invocation->image_W);
- internal = lookup_internal(invocation->mathmap->internals, "H", 1);
+ internal = lookup_internal(invocation->mathmap->main_filter->internals, "H", 1);
set_float_internal(invocation, internal->index, invocation->image_H);
- internal = lookup_internal(invocation->mathmap->internals, "R", 1);
+ internal = lookup_internal(invocation->mathmap->main_filter->internals, "R", 1);
set_float_internal(invocation, internal->index, invocation->image_R);
- internal = lookup_internal(invocation->mathmap->internals, "frame", 1);
+ internal = lookup_internal(invocation->mathmap->main_filter->internals, "frame", 1);
set_float_internal(invocation, internal->index, invocation->current_frame);
}
@@ -628,7 +628,7 @@ calc_lines (mathmap_slice_t *slice, int first_row, int last_row, unsigned char *
float middle_x = invocation->middle_x, middle_y = invocation->middle_y;
float sampling_offset_x = slice->sampling_offset_x, sampling_offset_y = slice->sampling_offset_y;
float scale_x = invocation->scale_x, scale_y = invocation->scale_y;
- int uses_ra = does_mathmap_use_ra(invocation->mathmap);
+ int uses_ra = does_filter_use_ra(invocation->mathmap->main_filter);
for (row = first_row; row < last_row; ++row)
{
View
17 vars.c
@@ -112,6 +112,23 @@ new_temporary_variable (variable_t **vars, tuple_info_t type)
}
void
+compiler_reset_variables (variable_t *vars)
+{
+ while (vars != 0)
+ {
+ int i;
+
+ for (i = 0; i < vars->type.length; ++i)
+ {
+ vars->compvar[i] = 0;
+ vars->last_index[i] = 0;
+ }
+
+ vars = vars->next;
+ }
+}
+
+void
free_variables (variable_t *vars)
{
while (vars != 0)
View
2  vars.h
@@ -44,6 +44,8 @@ variable_t* register_variable (variable_t **vars, const char *name, tuple_info_t
variable_t* lookup_variable (variable_t *vars, const char *name, tuple_info_t *type);
variable_t* new_temporary_variable (variable_t **vars, tuple_info_t type);
+void compiler_reset_variables (variable_t *vars);
+
tuple_t** instantiate_variables (variable_t *vars);
void free_variables (variable_t *vars);
Please sign in to comment.
Something went wrong with that request. Please try again.