/* * Install an ICCBased color space. * * Note that an ICCBased color space must be installed before it is known if * the ICC profile or the alternate color space is to be used. */ static int gx_install_CIEICC(gs_color_space * pcs, gs_state * pgs) { const gs_icc_params * picc_params = (const gs_icc_params *)&pcs->params.icc; gs_cie_icc * picc_info = picc_params->picc_info; #if ENABLE_CUSTOM_COLOR_CALLBACK { /* * Check if we want to use the callback color processing for this * color space. */ client_custom_color_params_t * pcb = (client_custom_color_params_t *) pgs->memory->gs_lib_ctx->custom_color_callback; if (pcb != NULL) { if (pcb->client_procs->install_ICCBased(pcb, pcs, pgs)) /* Exit if the client will handle the colorspace completely */ return 0; } } #endif /* update the stub information used by the joint caches */ gx_cie_load_common_cache(&picc_info->common, pgs); gx_cie_common_complete(&picc_info->common); return gs_cie_cs_complete(pgs, true); }
int cie_cache_joint(i_ctx_t *i_ctx_p, const ref_cie_render_procs * pcrprocs, const gs_cie_common *pcie, gs_state * pgs) { const gs_cie_render *pcrd = gs_currentcolorrendering(pgs); gx_cie_joint_caches *pjc = gx_unshare_cie_caches(pgs); gs_ref_memory_t *imem = (gs_ref_memory_t *) gs_state_memory(pgs); ref pqr_procs; uint space; int code; int i; if (pcrd == 0) /* cache is not set up yet */ return 0; if (pjc == 0) /* must already be allocated */ return_error(e_VMerror); if (r_has_type(&pcrprocs->TransformPQR, t_null)) { /* * This CRD came from a driver, not from a PostScript dictionary. * Resample TransformPQR in C code. */ return gs_cie_cs_complete(pgs, true); } gs_cie_compute_points_sd(pjc, pcie, pcrd); code = ialloc_ref_array(&pqr_procs, a_readonly, 3 * (1 + 4 + 4 * 6), "cie_cache_common"); if (code < 0) return code; /* When we're done, deallocate the procs and complete the caches. */ check_estack(3); cie_cache_push_finish(i_ctx_p, cie_tpqr_finish, imem, pgs); *++esp = pqr_procs; space = r_space(&pqr_procs); for (i = 0; i < 3; i++) { ref *p = pqr_procs.value.refs + 3 + (4 + 4 * 6) * i; const float *ppt = (float *)&pjc->points_sd; int j; make_array(pqr_procs.value.refs + i, a_readonly | a_executable | space, 4, p); make_array(p, a_readonly | space, 4 * 6, p + 4); p[1] = pcrprocs->TransformPQR.value.refs[i]; make_oper(p + 2, 0, cie_exec_tpqr); make_oper(p + 3, 0, cie_post_exec_tpqr); for (j = 0, p += 4; j < 4 * 6; j++, p++, ppt++) make_real(p, *ppt); } return cie_prepare_cache3(i_ctx_p, &pcrd->RangePQR, pqr_procs.value.const_refs, pjc->TransformPQR.caches, pjc, imem, "Transform.PQR"); }
/* Free the procs array and complete the joint caches. */ static int cie_tpqr_finish(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_state *pgs = r_ptr(op, gs_state); gs_cie_render *pcrd = (gs_cie_render *)gs_currentcolorrendering(pgs); /* break const */ int code; ifree_ref_array(op - 1, "cie_tpqr_finish"); pcrd->TransformPQR = TransformPQR_from_cache; code = gs_cie_cs_complete(pgs, false); pop(2); return code; }
client_install_ICCtoXYZ(client_custom_color_params_t * pparams, gs_color_space * pcs, gs_state * pgs) { int code; const gs_icc_params * picc_params = (const gs_icc_params *)&pcs->params.icc; gs_cie_icc * picc_info = picc_params->picc_info; /* update the stub information used by the joint caches */ gx_cie_load_common_cache(&picc_info->common, pgs); gx_cie_common_complete(&picc_info->common); if ((code=gs_cie_cs_complete(pgs, true)) < 0) { client_adjust_cspace_count(pcs, -1); /* free it up */ return false; } return true; }
static bool client_install_CIEtoA(client_custom_color_params_t * pparams, gs_color_space * pcs, gs_state * pgs) { /* get ready for converting to XYZ */ demo_color_space_data_t * pdata; /* Exit if we have already installed this color space. */ if (pcs->pclient_color_space_data != NULL) return true; pdata = allocate_client_data_block(1, pcs->rc.memory->stable_memory); pcs->pclient_color_space_data = (client_color_space_data_t *) pdata; if (pdata) { int code; gs_cie_a *pcie = pcs->params.a; gs_sample_loop_params_t lp; int i; pdata->client_is_going_to_handle_color_space = 1; /* Fill the caches we need in the CIE color space */ gs_cie_cache_init(&pcie->caches.DecodeA.floats.params, &lp, &pcie->RangeA, "DecodeA"); for (i = 0; i <= lp.N; ++i) { float in = SAMPLE_LOOP_VALUE(i, lp); pcie->caches.DecodeA.floats.values[i] = (*pcie->DecodeA)(in, pcie); } gx_cie_load_common_cache(&pcie->common, pgs); gs_cie_a_complete(pcie); if ((code=gs_cie_cs_complete(pgs, true)) >= 0) { /* Now allocate the conversion imager state in stable_memory */ /* so that the garbage collector won't free it */ code = gx_cie_to_xyz_alloc(&pdata->CIEtoXYZ_pis, pcs, pcs->rc.memory->stable_memory); } if (code < 0) { client_adjust_cspace_count(pcs, -1); /* free it up */ return false; } } return true; }
static bool client_install_ICCtoXYZ(client_custom_color_params_t * pparams, gs_color_space * pcs, gs_state * pgs) { int code; const gs_icc_params * picc_params = (const gs_icc_params *)&pcs->params.icc; gs_cie_icc * picc_info = picc_params->picc_info; demo_color_space_data_t * pdata; if (pcs->pclient_color_space_data != NULL) return true; pdata = allocate_client_data_block(1, pcs->rc.memory->stable_memory); pcs->pclient_color_space_data = (client_color_space_data_t *) pdata; /* Need to initialize the client data. The imager_state is what is needed in pdata->CIEtoXZY_ps */ /* update the stub information used by the joint caches */ gx_cie_load_common_cache(&picc_info->common, pgs); gx_cie_common_complete(&picc_info->common); if ((code=gs_cie_cs_complete(pgs, true)) < 0) { client_adjust_cspace_count(pcs, -1); /* free it up */ return false; } /* Now allocate the conversion imager state in stable_memory */ /* so that the garbage collector won't free it */ code = gx_cie_to_xyz_alloc(&pdata->CIEtoXYZ_pis, pcs, pcs->rc.memory->stable_memory); if (code < 0) { client_adjust_cspace_count(pcs, -1); /* free it up */ return false; } return true; }