mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-09 06:08:02 +02:00
[matrix] Avoid error correction overhead for translation matrices.
We can only correct rounding errors between cairo and pixman matrices for scaled matrices - so skip the inversion and point transformation overhead for simple translation matrices.
This commit is contained in:
parent
57a1d932f3
commit
2c277ddbea
1 changed files with 8 additions and 3 deletions
|
|
@ -813,8 +813,8 @@ _cairo_matrix_to_pixman_matrix (const cairo_matrix_t *matrix,
|
|||
*pixman_transform = pixman_identity_transform;
|
||||
}
|
||||
else {
|
||||
cairo_matrix_t inv = *matrix;
|
||||
double x = 0, y = 0;
|
||||
cairo_matrix_t inv;
|
||||
double x,y;
|
||||
pixman_vector_t vector;
|
||||
|
||||
pixman_transform->matrix[0][0] = _cairo_fixed_16_16_from_double (matrix->xx);
|
||||
|
|
@ -839,11 +839,16 @@ _cairo_matrix_to_pixman_matrix (const cairo_matrix_t *matrix,
|
|||
* space and adjust pixman's transform to agree with cairo's at
|
||||
* that point. */
|
||||
|
||||
if (_cairo_matrix_is_translation (matrix))
|
||||
return;
|
||||
|
||||
/* Note: If we can't invert the transformation, skip the adjustment. */
|
||||
inv = *matrix;
|
||||
if (cairo_matrix_invert (&inv) != CAIRO_STATUS_SUCCESS)
|
||||
return;
|
||||
|
||||
/* find the device space coordinate that maps to (0, 0) */
|
||||
x = 0, y = 0;
|
||||
cairo_matrix_transform_point (&inv, &x, &y);
|
||||
|
||||
/* transform the resulting device space coordinate back
|
||||
|
|
@ -852,7 +857,7 @@ _cairo_matrix_to_pixman_matrix (const cairo_matrix_t *matrix,
|
|||
vector.vector[1] = _cairo_fixed_16_16_from_double (y);
|
||||
vector.vector[2] = 1 << 16;
|
||||
|
||||
if (!pixman_transform_point_3d (pixman_transform, &vector))
|
||||
if (! pixman_transform_point_3d (pixman_transform, &vector))
|
||||
return;
|
||||
|
||||
/* Ideally, the vector should now be (0, 0). We can now compensate
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue