int gx_san_generate_stems(gx_device_spot_analyzer *padev, bool overall_hints, void *client_data, int (*handler)(void *client_data, gx_san_sect *ss)) { int code; bool got_dc = false; vd_save; if (vd_allowed('F') || vd_allowed('f')) { if (!vd_enabled) { vd_get_dc('f'); got_dc = vd_enabled; } if (vd_enabled) { vd_set_shift(0, 0); vd_set_scale(VD_SCALE); vd_set_origin(0, 0); } } else vd_disable; code = gx_san_generate_stems_aux(padev, overall_hints, client_data, handler); if (got_dc) vd_release_dc; vd_restore; return code; }
int gs_shading_FfGt_fill_rectangle(const gs_shading_t * psh0, const gs_rect * rect, const gs_fixed_rect * rect_clip, gx_device * dev, gs_imager_state * pis) { const gs_shading_FfGt_t * const psh = (const gs_shading_FfGt_t *)psh0; patch_fill_state_t pfs; const gs_shading_mesh_t *pshm = (const gs_shading_mesh_t *)psh; shade_coord_stream_t cs; int num_bits = psh->params.BitsPerFlag; int flag; shading_vertex_t va, vb, vc; patch_color_t *c, *C[3], *ca, *cb, *cc; /* va.c == ca && vb.c == cb && vc.c == cc always, provides a non-const access. */ int code; if (VD_TRACE_TRIANGLE_PATCH && vd_allowed('s')) { vd_get_dc('s'); vd_set_shift(0, 0); vd_set_scale(0.01); vd_set_origin(0, 0); } shade_init_fill_state((shading_fill_state_t *)&pfs, (const gs_shading_t *)psh, dev, pis); pfs.Function = pshm->params.Function; pfs.rect = *rect_clip; code = init_patch_fill_state(&pfs); if (code < 0) { if (pfs.icclink != NULL) gsicc_release_link(pfs.icclink); return code; } reserve_colors(&pfs, C, 3); /* Can't fail */ va.c = ca = C[0]; vb.c = cb = C[1]; vc.c = cc = C[2]; shade_next_init(&cs, (const gs_shading_mesh_params_t *)&psh->params, pis); /* CET 09-47J.PS SpecialTestI04Test01 does not need the color data alignment. */ while ((flag = shade_next_flag(&cs, num_bits)) >= 0) { switch (flag) { default: return_error(gs_error_rangecheck); case 0: if ((code = Gt_next_vertex(pshm, &cs, &va, ca)) < 0 || (code = shade_next_flag(&cs, num_bits)) < 0 || (code = Gt_next_vertex(pshm, &cs, &vb, cb)) < 0 || (code = shade_next_flag(&cs, num_bits)) < 0 ) break; goto v2; case 1: c = ca; va = vb; ca = cb; vb.c = cb = c; case 2: c = cb; vb = vc; cb = cc; vc.c = cc = c; v2: if ((code = Gt_next_vertex(pshm, &cs, &vc, cc)) < 0) break; if ((code = Gt_fill_triangle(&pfs, &va, &vb, &vc)) < 0) break; } cs.align(&cs, 8); /* Debugged with 12-14O.PS page 2. */ } if (VD_TRACE_TRIANGLE_PATCH && vd_allowed('s')) vd_release_dc; release_colors(&pfs, pfs.color_stack, 3); if (term_patch_fill_state(&pfs)) return_error(gs_error_unregistered); /* Must not happen. */ if (!cs.is_eod(&cs)) return_error(gs_error_rangecheck); if (pfs.icclink != NULL) gsicc_release_link(pfs.icclink); return code; }
int gs_shading_LfGt_fill_rectangle(const gs_shading_t * psh0, const gs_rect * rect, const gs_fixed_rect * rect_clip, gx_device * dev, gs_imager_state * pis) { const gs_shading_LfGt_t * const psh = (const gs_shading_LfGt_t *)psh0; patch_fill_state_t pfs; const gs_shading_mesh_t *pshm = (const gs_shading_mesh_t *)psh; shade_coord_stream_t cs; shading_vertex_t *vertex = NULL; byte *color_buffer = NULL; patch_color_t **color_buffer_ptrs = NULL; /* non-const access to vertex[i].c */ shading_vertex_t next; int per_row = psh->params.VerticesPerRow; patch_color_t *c, *cn; /* cn == next.c always, provides a non-contst access. */ int i, code; if (VD_TRACE_TRIANGLE_PATCH && vd_allowed('s')) { vd_get_dc('s'); vd_set_shift(0, 0); vd_set_scale(0.01); vd_set_origin(0, 0); } shade_init_fill_state((shading_fill_state_t *)&pfs, (const gs_shading_t *)psh, dev, pis); pfs.Function = pshm->params.Function; pfs.rect = *rect_clip; code = init_patch_fill_state(&pfs); if (code < 0) goto out; reserve_colors(&pfs, &cn, 1); /* Can't fail. */ next.c = cn; shade_next_init(&cs, (const gs_shading_mesh_params_t *)&psh->params, pis); vertex = (shading_vertex_t *) gs_alloc_byte_array(pis->memory, per_row, sizeof(*vertex), "gs_shading_LfGt_render"); if (vertex == NULL) { code = gs_note_error(gs_error_VMerror); goto out; } color_buffer = gs_alloc_bytes(pis->memory, pfs.color_stack_step * per_row, "gs_shading_LfGt_fill_rectangle"); if (color_buffer == NULL) { code = gs_note_error(gs_error_VMerror); goto out; } color_buffer_ptrs = (patch_color_t **)gs_alloc_bytes(pis->memory, sizeof(patch_color_t *) * per_row, "gs_shading_LfGt_fill_rectangle"); if (color_buffer_ptrs == NULL) { code = gs_note_error(gs_error_VMerror); goto out; } /* CET 09-47K.PS SpecialTestJ02Test05 needs the color data alignment. */ for (i = 0; i < per_row; ++i) { color_buffer_ptrs[i] = (patch_color_t *)(color_buffer + pfs.color_stack_step * i); vertex[i].c = color_buffer_ptrs[i]; if ((code = Gt_next_vertex(pshm, &cs, &vertex[i], color_buffer_ptrs[i])) < 0) goto out; } while (!seofp(cs.s)) { code = Gt_next_vertex(pshm, &cs, &next, cn); if (code < 0) goto out; for (i = 1; i < per_row; ++i) { code = Gt_fill_triangle(&pfs, &vertex[i - 1], &vertex[i], &next); if (code < 0) goto out; c = color_buffer_ptrs[i - 1]; vertex[i - 1] = next; color_buffer_ptrs[i - 1] = cn; next.c = cn = c; code = Gt_next_vertex(pshm, &cs, &next, cn); if (code < 0) goto out; code = Gt_fill_triangle(&pfs, &vertex[i], &vertex[i - 1], &next); if (code < 0) goto out; } c = color_buffer_ptrs[per_row - 1]; vertex[per_row - 1] = next; color_buffer_ptrs[per_row - 1] = cn; next.c = cn = c; } out: if (VD_TRACE_TRIANGLE_PATCH && vd_allowed('s')) vd_release_dc; gs_free_object(pis->memory, vertex, "gs_shading_LfGt_render"); gs_free_object(pis->memory, color_buffer, "gs_shading_LfGt_render"); gs_free_object(pis->memory, color_buffer_ptrs, "gs_shading_LfGt_render"); release_colors(&pfs, pfs.color_stack, 1); if (term_patch_fill_state(&pfs)) return_error(gs_error_unregistered); /* Must not happen. */ if (pfs.icclink != NULL) gsicc_release_link(pfs.icclink); return code; }