[cairo] Speedup _cairo_matrix_to_pixman_matrix
Daniel Amelang
daniel.amelang at gmail.com
Tue Nov 21 14:51:47 PST 2006
On 11/21/06, Behdad Esfahbod <behdad at behdad.org> wrote:
> On Tue, 2006-11-21 at 15:16 -0500, Daniel Amelang wrote:
> > + memcpy (pixman_transform->matrix,
> > + &pixman_identity_matrix,
> > + sizeof (pixman_identity_matrix));
>
> Shouldn't this simply be:
>
> *pixman_transform->matrix = pixman_identity_matrix;
Hmmm...that doesn't work, at least not on any compiler that I'm
familiar with. These are arrays, not structures.
That said, maybe I should have used a pixman_transform structure as
the template, so we could do:
*pixman_transform = pixman_identity_transform;
I do like it better. I'll attach the patch.
Dan
-------------- next part --------------
From nobody Mon Sep 17 00:00:00 2001
From: Dan Amelang <dan at amelang.net>
Date: Tue Nov 21 14:50:29 2006 -0800
Subject: [PATCH] Change _cairo_matrix_to_pixman_matrix to use a pixman_transform_t as the template, thus avoiding a forced memcpy
---
src/cairo-matrix.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
ba7c0516f5082eeaf818030e65f9252ffdb7347a
diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c
index 7f43f23..d4f4bf7 100644
--- a/src/cairo-matrix.c
+++ b/src/cairo-matrix.c
@@ -725,16 +725,14 @@ void
_cairo_matrix_to_pixman_matrix (const cairo_matrix_t *matrix,
pixman_transform_t *pixman_transform)
{
- static const pixman_fixed16_16_t pixman_identity_matrix[3][3] = {
+ static const pixman_transform_t pixman_identity_transform = {{
{1 << 16, 0, 0},
{ 0, 1 << 16, 0},
{ 0, 0, 1 << 16}
- };
+ }};
if (_cairo_matrix_is_identity (matrix)) {
- memcpy (pixman_transform->matrix,
- &pixman_identity_matrix,
- sizeof (pixman_identity_matrix));
+ *pixman_transform = pixman_identity_transform;
}
else {
pixman_transform->matrix[0][0] = _cairo_fixed_from_double (matrix->xx);
--
1.2.6
More information about the cairo
mailing list