/* Reset the remembered graphics state. */ void gdev_vector_reset(gx_device_vector * vdev) { static const gs_imager_state state_initial = {gs_imager_state_initial(1, false)}; vdev->state = state_initial; gx_hld_saved_color_init(&vdev->saved_fill_color); gx_hld_saved_color_init(&vdev->saved_stroke_color); vdev->clip_path_id = vdev->no_clip_path_id = gs_next_ids(vdev->memory, 1); }
/* * Save the device color information including the color space id and * client color data (if available). * * More description in src/gxhldevc.h */ bool gx_hld_save_color(const gs_imager_state * pis, const gx_device_color * pdevc, gx_hl_saved_color * psc) { const gs_state * pgs = gx_hld_get_gstate_ptr(pis); memset(psc, 0, sizeof(*psc)); /* clear the entire structure */ if (pdevc == NULL) { /* No device color given, should not happen */ gx_hld_saved_color_init(psc); /* revert to unknown color */ return false; } else if (pgs == NULL) { /* No color space, simply save device color specific info */ psc->color_space_id = psc->pattern_id = gs_no_id; pdevc->type->save_dc(pdevc, &(psc->saved_dev_color)); return false; } else { /* * Have color space, save id, ccolor, & device color specific info. * Also save the high level colors since two gx_color_index values * may be the same but for differing high level colors (due to the * usual lower resolution of the gx_color_index values. */ const gs_color_space * pcs = pgs->color_space; int i = gs_color_space_num_components(pcs); psc->color_space_id = pcs->id; pdevc->type->save_dc(pdevc, &(psc->saved_dev_color)); if (pdevc->type == gx_dc_type_pattern2) i = 0; else if (i < 0) i = -i - 1; /* See gx_num_components_Pattern. */ for (i--; i >= 0; i--) psc->ccolor.paint.values[i] = pdevc->ccolor.paint.values[i]; /* Save the pattern id - if present */ if ((pdevc->type == gx_dc_type_pattern || pdevc->type == gx_dc_type_pattern2) && pdevc->ccolor_valid) psc->pattern_id = pdevc->ccolor.pattern->pattern_id; else psc->pattern_id = gs_no_id; return true; } }