mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-06 11:38:16 +02:00
ps (API): Export the ability to set the creation date of the surface
A PostScript surface embeds a CreationDate comment into its document description pre-amble. Normally this is set to the time the surface is written out, except we set this to a constant value in the boilerplate for the purposes of mimicking a reference file. It may also be useful for external applications, so make it a public export. References: https://bugs.freedesktop.org/show_bug.cgi?id=48577 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
bf5adaf394
commit
6ad8c96fd8
3 changed files with 35 additions and 19 deletions
|
|
@ -55,24 +55,6 @@ typedef struct _ps_target_closure {
|
|||
cairo_ps_level_t level;
|
||||
} ps_target_closure_t;
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_boilerplate_ps_surface_set_creation_date (cairo_surface_t *abstract_surface,
|
||||
time_t date)
|
||||
{
|
||||
cairo_paginated_surface_t *paginated = (cairo_paginated_surface_t*) abstract_surface;
|
||||
cairo_ps_surface_t *surface;
|
||||
|
||||
if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_PS)
|
||||
return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
|
||||
|
||||
surface = (cairo_ps_surface_t*) paginated->target;
|
||||
|
||||
surface->has_creation_date = TRUE;
|
||||
surface->creation_date = date;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_ps_create_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
|
|
@ -106,7 +88,7 @@ _cairo_boilerplate_ps_create_surface (const char *name,
|
|||
goto CLEANUP_FILENAME;
|
||||
|
||||
cairo_ps_surface_restrict_to_level (surface, level);
|
||||
_cairo_boilerplate_ps_surface_set_creation_date (surface, 0);
|
||||
cairo_ps_surface_debug_set_creation_date (surface, 0);
|
||||
cairo_surface_set_fallback_resolution (surface, 72., 72.);
|
||||
|
||||
if (content == CAIRO_CONTENT_COLOR) {
|
||||
|
|
|
|||
|
|
@ -1358,6 +1358,33 @@ cairo_ps_surface_set_size (cairo_surface_t *surface,
|
|||
status = _cairo_surface_set_error (surface, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_ps_surface_debug_set_creation_data:
|
||||
* @surface: a PostScript #cairo_surface_t
|
||||
* @date: A time_t
|
||||
*
|
||||
* Changes the embedded creation date of a PostScript surface.
|
||||
*
|
||||
* This function is only intended to be used by conformance test suites which
|
||||
* require complete control over embedded strings.
|
||||
*
|
||||
* This function can be called at any point before the surface is finished,
|
||||
*
|
||||
* Since: 1.12.2
|
||||
**/
|
||||
void
|
||||
cairo_ps_surface_debug_set_creation_date (cairo_surface_t *abstract_surface,
|
||||
time_t date)
|
||||
{
|
||||
cairo_ps_surface_t *surface = NULL;
|
||||
|
||||
if (! _extract_ps_surface (abstract_surface, TRUE, &surface))
|
||||
return;
|
||||
|
||||
surface->has_creation_date = TRUE;
|
||||
surface->creation_date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_ps_surface_dsc_comment:
|
||||
* @surface: a PostScript #cairo_surface_t
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#if CAIRO_HAS_PS_SURFACE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
|
|
@ -107,6 +108,12 @@ cairo_ps_surface_dsc_begin_setup (cairo_surface_t *surface);
|
|||
cairo_public void
|
||||
cairo_ps_surface_dsc_begin_page_setup (cairo_surface_t *surface);
|
||||
|
||||
/* debug interface */
|
||||
|
||||
cairo_public void
|
||||
cairo_ps_surface_debug_set_creation_date (cairo_surface_t *abstract_surface,
|
||||
time_t date);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /* CAIRO_HAS_PS_SURFACE */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue