Let surfaces specify their native resolution, for fallback purposes

This commit is contained in:
Vladimir Vukicevic 2007-08-29 15:34:04 -07:00
parent 79d975f84b
commit 284ed91ee4
5 changed files with 42 additions and 2 deletions

View file

@ -58,6 +58,8 @@ static const cairo_image_surface_t _cairo_image_surface_nil_invalid_format = {
0.0, 1.0,
0.0, 0.0
}, /* device_transform_inverse */
0.0, /* x_resolution */
0.0, /* y_resolution */
0.0, /* x_fallback_resolution */
0.0, /* y_fallback_resolution */
NULL, /* clip */

View file

@ -238,8 +238,8 @@ static cairo_int_status_t
_paint_fallback_image (cairo_paginated_surface_t *surface,
cairo_box_int_t *box)
{
double x_scale = surface->base.x_fallback_resolution / 72.0;
double y_scale = surface->base.y_fallback_resolution / 72.0;
double x_scale = surface->base.x_fallback_resolution / surface->base.x_resolution;
double y_scale = surface->base.y_fallback_resolution / surface->base.y_resolution;
cairo_matrix_t matrix;
int x, y, width, height;
cairo_status_t status;

View file

@ -60,6 +60,14 @@ struct _cairo_surface {
cairo_matrix_t device_transform;
cairo_matrix_t device_transform_inverse;
/* The actual resolution of the device, in dots per inch. */
double x_resolution;
double y_resolution;
/* The resolution that should be used when generating image-based
* fallback; generally only used by the analysis/paginated
* surfaces
*/
double x_fallback_resolution;
double y_fallback_resolution;

View file

@ -62,6 +62,8 @@ const cairo_surface_t name = { \
0.0, 1.0, \
0.0, 0.0 \
}, /* device_transform_inverse */ \
0.0, /* x_resolution */ \
0.0, /* y_resolution */ \
0.0, /* x_fallback_resolution */ \
0.0, /* y_fallback_resolution */ \
NULL, /* clip */ \
@ -195,6 +197,9 @@ _cairo_surface_init (cairo_surface_t *surface,
cairo_matrix_init_identity (&surface->device_transform);
cairo_matrix_init_identity (&surface->device_transform_inverse);
surface->x_resolution = CAIRO_SURFACE_RESOLUTION_DEFAULT;
surface->y_resolution = CAIRO_SURFACE_RESOLUTION_DEFAULT;
surface->x_fallback_resolution = CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT;
surface->y_fallback_resolution = CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT;
@ -2286,5 +2291,24 @@ _cairo_surface_copy_pattern_for_destination (const cairo_pattern_t *pattern,
return CAIRO_STATUS_SUCCESS;
}
/**
* _cairo_surface_set_resolution
* @surface: the surface
* @x_res: x resolution, in dpi
* @y_res: y resolution, in dpi
*
* Set the actual surface resolution of @surface to the given x and y DPI.
* Mainly used for correctly computing the scale factor when fallback
* rendering needs to take place in the paginated surface.
*/
void
_cairo_surface_set_resolution (cairo_surface_t *surface,
double x_res,
double y_res)
{
surface->x_resolution = x_res;
surface->y_resolution = y_res;
}
/* LocalWords: rasterized
*/

View file

@ -1077,6 +1077,7 @@ typedef struct _cairo_traps {
#define CAIRO_GSTATE_MITER_LIMIT_DEFAULT 10.0
#define CAIRO_GSTATE_DEFAULT_FONT_SIZE 10.0
#define CAIRO_SURFACE_RESOLUTION_DEFAULT 72.0
#define CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT 300.0
typedef struct _cairo_gstate cairo_gstate_t;
@ -1694,6 +1695,11 @@ cairo_private void
_cairo_surface_set_error (cairo_surface_t *surface,
cairo_status_t status);
cairo_private void
_cairo_surface_set_resolution (cairo_surface_t *surface,
double x_res,
double y_res);
cairo_private cairo_surface_t *
_cairo_surface_create_similar_scratch (cairo_surface_t *other,
cairo_content_t content,