mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 01:48:07 +02:00
Win32-Printing: Fix fallback resolution when DC ctm is not identity
And also move the _cairo_surface_set_resolution() into _cairo_win32_printing_surface_start_page as the DC ctm may be changed between pages. This bug was found in Inkscape now that they are using the cairo win32-printing surface for printing on Windows.
This commit is contained in:
parent
ee3981fb92
commit
e9906ae202
1 changed files with 14 additions and 5 deletions
|
|
@ -1419,6 +1419,9 @@ _cairo_win32_printing_surface_start_page (void *abstract_surface)
|
|||
{
|
||||
cairo_win32_surface_t *surface = abstract_surface;
|
||||
XFORM xform;
|
||||
double x_res, y_res;
|
||||
cairo_matrix_t inverse_ctm;
|
||||
cairo_status_t status;
|
||||
|
||||
SaveDC (surface->dc); /* Save application context first, before doing MWT */
|
||||
|
||||
|
|
@ -1431,6 +1434,17 @@ _cairo_win32_printing_surface_start_page (void *abstract_surface)
|
|||
surface->ctm.x0 = xform.eDx;
|
||||
surface->ctm.y0 = xform.eDy;
|
||||
surface->has_ctm = !_cairo_matrix_is_identity (&surface->ctm);
|
||||
|
||||
inverse_ctm = surface->ctm;
|
||||
status = cairo_matrix_invert (&inverse_ctm);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
x_res = (double) GetDeviceCaps(surface->dc, LOGPIXELSX);
|
||||
y_res = (double) GetDeviceCaps(surface->dc, LOGPIXELSY);
|
||||
cairo_matrix_transform_distance (&inverse_ctm, &x_res, &y_res);
|
||||
_cairo_surface_set_resolution (&surface->base, x_res, y_res);
|
||||
|
||||
if (!ModifyWorldTransform (surface->dc, NULL, MWT_IDENTITY))
|
||||
return _cairo_win32_print_gdi_error ("_cairo_win32_printing_surface_start_page:ModifyWorldTransform");
|
||||
|
||||
|
|
@ -1468,7 +1482,6 @@ cairo_surface_t *
|
|||
cairo_win32_printing_surface_create (HDC hdc)
|
||||
{
|
||||
cairo_win32_surface_t *surface;
|
||||
int xr, yr;
|
||||
RECT rect;
|
||||
|
||||
surface = malloc (sizeof (cairo_win32_surface_t));
|
||||
|
|
@ -1504,10 +1517,6 @@ cairo_win32_printing_surface_create (HDC hdc)
|
|||
_cairo_surface_init (&surface->base, &cairo_win32_printing_surface_backend,
|
||||
CAIRO_CONTENT_COLOR_ALPHA);
|
||||
|
||||
xr = GetDeviceCaps(hdc, LOGPIXELSX);
|
||||
yr = GetDeviceCaps(hdc, LOGPIXELSY);
|
||||
_cairo_surface_set_resolution (&surface->base, (double) xr, (double) yr);
|
||||
|
||||
return _cairo_paginated_surface_create (&surface->base,
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
surface->extents.width,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue