cairo_surface_t * _cairo_image_surface_scale (cairo_surface_t *image, int scaled_width, int scaled_height, scale_filter_t filter, GthAsyncTask *task) { int src_width; int src_height; cairo_surface_t *scaled; cairo_surface_metadata_t *metadata; resize_filter_t *resize_filter; ScaleReal x_factor; ScaleReal y_factor; cairo_surface_t *tmp; src_width = cairo_image_surface_get_width (image); src_height = cairo_image_surface_get_height (image); if ((src_width == scaled_width) && (src_height == scaled_height)) return _cairo_image_surface_copy (image); scaled = _cairo_image_surface_create (CAIRO_FORMAT_ARGB32, scaled_width, scaled_height); _cairo_image_surface_copy_metadata (image, scaled); metadata = _cairo_image_surface_get_metadata (scaled); if (metadata->original_width <= 0) { metadata->original_width = src_width; metadata->original_height = src_height; } if (scaled == NULL) return NULL; if (g_once_init_enter (&coefficients_initialization)) { initialize_coefficients (1.0, 0.0); g_once_init_leave (&coefficients_initialization, 1); } resize_filter = resize_filter_create (task); resize_filter_set_type (resize_filter, filter); resize_filter->total_lines = scaled_width + scaled_height; resize_filter->processed_lines = 0; x_factor = (ScaleReal) scaled_width / src_width; y_factor = (ScaleReal) scaled_height / src_height; tmp = _cairo_image_surface_create (CAIRO_FORMAT_ARGB32, src_height, scaled_width); horizontal_scale_transpose (image, tmp, x_factor, resize_filter); horizontal_scale_transpose (tmp, scaled, y_factor, resize_filter); resize_filter_destroy (resize_filter); cairo_surface_destroy (tmp); return scaled; }
bool ranking_synthesis_satt::generate_functions(void) { exprt templ = instantiate(); if(body.variable_map.size()==0 || templ.is_false()) return false; // some coefficient values c_valuest c_values; debug("Template:" + from_expr(ns, "", templ)); satcheckt::resultt result=satcheckt::P_SATISFIABLE; while(result==satcheckt::P_SATISFIABLE) { if(c_values.size()==0) initialize_coefficients(c_values); else { if(increase_coefficients(c_values)) break; } result=check_for_counterexample(templ, c_values, conversion_time, solver_time); } if(result==satcheckt::P_ERROR) throw ("Solver error."); else if(result==satcheckt::P_UNSATISFIABLE) // no counter-example { debug("Found ranking functions"); // put the coefficient values in the rank relation replace_mapt replace_map; for(c_valuest::const_iterator it=c_values.begin(); it!=c_values.end(); it++) { replace_map[it->first] = from_integer(it->second, it->first.type()); } replace_expr(replace_map, rank_relation); simplify(rank_relation, ns); return true; } else return false; }