mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 15:48:00 +02:00
Hook up device scaling so fallback_resolution starts working.
Add new, private _cairo_surface_set_device_scale for getting at the scaling components of device_transform. Use this in paginated surface when replaying to an image surface. The fallback-resolution test now clearly shows that image fallback resolution can be controlled by the user. Hurrah!
This commit is contained in:
parent
b129f747c5
commit
6efeb1e19b
3 changed files with 53 additions and 2 deletions
|
|
@ -217,13 +217,20 @@ _paint_page (cairo_paginated_surface_t *surface)
|
|||
|
||||
if (_cairo_analysis_surface_has_unsupported (analysis))
|
||||
{
|
||||
double x_scale = surface->base.x_fallback_resolution / 72.0;
|
||||
double y_scale = surface->base.y_fallback_resolution / 72.0;
|
||||
cairo_matrix_t matrix;
|
||||
|
||||
image = _cairo_image_surface_create_with_content (surface->content,
|
||||
surface->width,
|
||||
surface->height);
|
||||
surface->width * x_scale,
|
||||
surface->height * y_scale);
|
||||
_cairo_surface_set_device_scale (image, x_scale, y_scale);
|
||||
|
||||
_cairo_meta_surface_replay (surface->meta, image);
|
||||
|
||||
pattern = cairo_pattern_create_for_surface (image);
|
||||
cairo_matrix_init_scale (&matrix, x_scale, y_scale);
|
||||
cairo_pattern_set_matrix (pattern, &matrix);
|
||||
|
||||
_cairo_surface_paint (surface->target, CAIRO_OPERATOR_SOURCE, pattern);
|
||||
|
||||
|
|
|
|||
|
|
@ -611,6 +611,45 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* _cairo_surface_set_device_scale:
|
||||
* @surface: a #cairo_surface_t
|
||||
* @sx: a scale factor in the X direction
|
||||
* @sy: a scale factor in the Y direction
|
||||
*
|
||||
* Private function for setting an extra scale factor to affect all
|
||||
* drawing to a surface. This is used, for example, when replaying a
|
||||
* meta surface to an image fallback intended for an eventual
|
||||
* vector-oriented backend. Since the meta surface will record
|
||||
* coordinates in one backend space, but the image fallback uses a
|
||||
* different backend space, (differing by the fallback resolution
|
||||
* scale factors), we need a scale factor correction.
|
||||
*
|
||||
* Caution: There is no guarantee that a surface with both a
|
||||
* device_scale and a device_offset will be treated in consistent
|
||||
* fashion. So, for now, just don't do that. (And we'll need to
|
||||
* examine this issue in more detail if we were to ever want to export
|
||||
* support for device scaling.)
|
||||
**/
|
||||
void
|
||||
_cairo_surface_set_device_scale (cairo_surface_t *surface,
|
||||
double sx,
|
||||
double sy)
|
||||
{
|
||||
assert (! surface->is_snapshot);
|
||||
|
||||
if (surface->status)
|
||||
return;
|
||||
|
||||
if (surface->finished) {
|
||||
_cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
|
||||
return;
|
||||
}
|
||||
|
||||
surface->device_transform.xx = sx;
|
||||
surface->device_transform.yy = sy;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_surface_set_device_offset:
|
||||
* @surface: a #cairo_surface_t
|
||||
|
|
|
|||
|
|
@ -1855,6 +1855,11 @@ _cairo_surface_composite_shape_fixup_unbounded (cairo_surface_t *dst,
|
|||
cairo_private cairo_bool_t
|
||||
_cairo_surface_is_opaque (const cairo_surface_t *surface);
|
||||
|
||||
cairo_private void
|
||||
_cairo_surface_set_device_scale (cairo_surface_t *surface,
|
||||
double sx,
|
||||
double sy);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
_cairo_surface_has_device_transform (cairo_surface_t *surface);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue