/* <dict> .builddevicecolorrendering1 <crd> */ static int zbuilddevicecolorrendering1(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_memory_t *mem = gs_state_memory(igs); dict_param_list list; gs_cie_render *pcrd = 0; int code; check_type(*op, t_dictionary); code = dict_param_list_read(&list, op, NULL, false, iimemory); if (code < 0) return code; code = gs_cie_render1_build(&pcrd, mem, ".builddevicecolorrendering1"); if (code >= 0) { code = param_get_cie_render1(pcrd, (gs_param_list *) & list, gs_currentdevice(igs)); if (code >= 0) { /****** FIX refct ******/ /*rc_decrement(pcrd, ".builddevicecolorrendering1"); *//* build sets rc = 1 */ } } iparam_list_release(&list); if (code < 0) { rc_free_struct(pcrd, ".builddevicecolorrendering1"); return code; } istate->colorrendering.dict = *op; make_istruct_new(op, a_readonly, pcrd); return 0; }
/* <dict> .buildcolorrendering1 <crd> */ static int zbuildcolorrendering1(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_memory_t *mem = gs_state_memory(igs); int code; es_ptr ep = esp; gs_cie_render *pcrd; ref_cie_render_procs procs; check_read_type(*op, t_dictionary); check_dict_read(*op); code = gs_cie_render1_build(&pcrd, mem, ".buildcolorrendering1"); if (code < 0) return code; code = zcrd1_params(op, pcrd, &procs, mem); if (code < 0 || (code = cache_colorrendering1(i_ctx_p, pcrd, &procs, (gs_ref_memory_t *) mem)) < 0 ) { rc_free_struct(pcrd, ".buildcolorrendering1"); esp = ep; return code; } /****** FIX refct ******/ /*rc_decrement(pcrd, ".buildcolorrendering1"); *//* build sets rc = 1 */ istate->colorrendering.dict = *op; make_istruct_new(op, a_readonly, pcrd); return (esp == ep ? 0 : o_push_estack); }
/* * We have collected all of the sample data. Create a type 0 function stucture. */ static int sampled_data_finish(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_sampled_data_enum *penum = senum; /* Build a type 0 function using the given parameters */ gs_function_Sd_params_t * params = (gs_function_Sd_params_t *)&penum->pfn->params; gs_function_t * pfn; ref cref; /* closure */ int code = gs_function_Sd_init(&pfn, params, imemory); if (code < 0) return code; code = ialloc_ref_array(&cref, a_executable | a_execute, 2, "sampled_data_finish(cref)"); if (code < 0) return code; make_istruct_new(cref.value.refs, a_executable | a_execute, pfn); make_oper_new(cref.value.refs + 1, 0, zexecfunction); ref_assign(op, &cref); esp -= estack_storage; ifree_object(penum->pfn, "sampled_data_finish(pfn)"); ifree_object(penum, "sampled_data_finish(enum)"); return o_pop_estack; }
/* Create a function procedure from a function structure. */ static int make_function_proc(i_ctx_t *i_ctx_p, ref *op, gs_function_t *pfn) { ref cref; /* closure */ int code; code = ialloc_ref_array(&cref, a_executable | a_execute, 2, ".buildfunction"); if (code < 0) return code; make_istruct_new(cref.value.refs, a_executable | a_execute, pfn); make_oper_new(cref.value.refs + 1, 0, zexecfunction); ref_assign(op, &cref); return 0; }
/* *op is of type t_astruct(igstate_obj). */ static int gstate_unshare(i_ctx_t *i_ctx_p) { os_ptr op = osp; ref *pgsref = &r_ptr(op, igstate_obj)->gstate; gs_state *pgs = r_ptr(pgsref, gs_state); gs_state *pnew; int_gstate *isp; if (!ref_must_save(pgsref)) return 0; /* Copy the gstate. */ pnew = gs_gstate(pgs); if (pnew == 0) return_error(e_VMerror); isp = gs_int_gstate(pnew); int_gstate_map_refs(isp, ref_mark_new); ref_do_save(op, pgsref, "gstate_unshare"); make_istruct_new(pgsref, 0, pnew); return 0; }
/* - gstate <gstate> */ int zgstate(i_ctx_t *i_ctx_p) { os_ptr op = osp; int code = gstate_check_space(i_ctx_p, istate, icurrent_space); igstate_obj *pigo; gs_state *pnew; int_gstate *isp; if (code < 0) return code; pigo = ialloc_struct(igstate_obj, &st_igstate_obj, "gstate"); if (pigo == 0) return_error(e_VMerror); pnew = gs_state_copy(igs, imemory); if (pnew == 0) { ifree_object(pigo, "gstate"); return_error(e_VMerror); } isp = gs_int_gstate(pnew); int_gstate_map_refs(isp, ref_mark_new); push(1); /* * Since igstate_obj isn't a ref, but only contains a ref, save won't * clear its l_new bit automatically, and restore won't set it * automatically; we have to make sure this ref is on the changes chain. */ make_iastruct(op, a_all, pigo); #if 0 /* Bug 689849 "gstate leaks memory" */ make_null(&pigo->gstate); ref_save(op, &pigo->gstate, "gstate"); make_istruct_new(&pigo->gstate, 0, pnew); #else make_istruct(&pigo->gstate, 0, pnew); #endif return 0; }
/* Common framework for building shadings. */ static int build_shading(i_ctx_t *i_ctx_p, build_shading_proc_t proc) { os_ptr op = osp; int code; float box[4]; gs_shading_params_t params; gs_shading_t *psh; ref *pvalue; check_type(*op, t_dictionary); params.ColorSpace = 0; params.cie_joint_caches = 0; params.Background = 0; /* Collect parameters common to all shading types. */ { gs_color_space *pcs = gs_currentcolorspace(igs); int num_comp = gs_color_space_num_components(pcs); if (num_comp < 0) { /* Pattern color space */ gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "ColorSpace"); return_error(gs_error_typecheck); } params.ColorSpace = pcs; rc_increment_cs(pcs); if (dict_find_string(op, "Background", &pvalue) > 0) { gs_client_color *pcc = ialloc_struct(gs_client_color, &st_client_color, "build_shading"); if (pcc == 0) { code = gs_note_error(gs_error_VMerror); goto fail; } pcc->pattern = 0; params.Background = pcc; code = dict_floats_param(imemory, op, "Background", gs_color_space_num_components(pcs), pcc->paint.values, NULL); if (code < 0) { gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "Background"); goto fail; } } } if (dict_find_string(op, "BBox", &pvalue) <= 0) params.have_BBox = false; else if ((code = dict_floats_param(imemory, op, "BBox", 4, box, NULL)) == 4) { /* Adobe Interpreters accept denormalised BBox - bug 688937 */ if (box[0] <= box[2]) { params.BBox.p.x = box[0]; params.BBox.q.x = box[2]; } else { params.BBox.p.x = box[2]; params.BBox.q.x = box[0]; } if (box[1] <= box[3]) { params.BBox.p.y = box[1]; params.BBox.q.y = box[3]; } else { params.BBox.p.y = box[3]; params.BBox.q.y = box[1]; } params.have_BBox = true; } else { gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "BBox"); goto fail; } code = dict_bool_param(op, "AntiAlias", false, ¶ms.AntiAlias); if (code < 0) { gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "AntiAlias"); goto fail; } /* Finish building the shading. */ code = (*proc)(i_ctx_p, op, ¶ms, &psh, imemory); if (code < 0) goto fail; if (gx_color_space_needs_cie_caches(psh->params.ColorSpace)) { rc_decrement(psh->params.cie_joint_caches, "build_shading"); psh->params.cie_joint_caches = gx_currentciecaches(igs); rc_increment(psh->params.cie_joint_caches); } make_istruct_new(op, 0, psh); return code; fail: gs_free_object(imemory, params.Background, "Background"); if (params.ColorSpace) { rc_decrement_only_cs(params.ColorSpace, "build_shading"); } return (code < 0 ? code : gs_note_error(gs_error_rangecheck)); }