From f699389818f1f11f3edddcdddcd0a43be21ba4c0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 18 Mar 2008 14:06:47 -0700 Subject: [PATCH] Add i830_transform_is_affine and i830_get_transformed_coordinates_3d. These are needed to deal with projective transforms in the composite operation. --- src/i830.h | 7 +++++++ src/i830_exa.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/i830.h b/src/i830.h index ee0f03ad..512938cd 100644 --- a/src/i830.h +++ b/src/i830.h @@ -790,6 +790,9 @@ Bool i830_check_composite(int op, PicturePtr pSrc, PicturePtr pMask, Bool i830_prepare_composite(int op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, PixmapPtr pSrcPixmap, PixmapPtr pMaskPixmap, PixmapPtr pDstPixmap); +Bool +i830_transform_is_affine (PictTransformPtr t); + void i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int w, int h); void i830_done_composite(PixmapPtr pDst); @@ -812,6 +815,10 @@ void i830_get_transformed_coordinates(int x, int y, PictTransformPtr transform, float *x_out, float *y_out); +void +i830_get_transformed_coordinates_3d(int x, int y, PictTransformPtr transform, + float *x_out, float *y_out, float *z_out); + void i830_enter_render(ScrnInfoPtr); static inline int i830_fb_compression_supported(I830Ptr pI830) diff --git a/src/i830_exa.c b/src/i830_exa.c index bf9fc669..0206ab91 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -363,6 +363,45 @@ i830_get_transformed_coordinates(int x, int y, PictTransformPtr transform, } } +** + * Returns the un-normalized floating-point coordinates transformed by the given transform. + * + * transform may be null. + */ +void +i830_get_transformed_coordinates_3d(int x, int y, PictTransformPtr transform, + float *x_out, float *y_out, float *w_out) +{ + if (transform == NULL) { + *x_out = x; + *y_out = y; + *w_out = 1; + } else { + PictVector v; + + v.vector[0] = IntToxFixed(x); + v.vector[1] = IntToxFixed(y); + v.vector[2] = xFixed1; + PictureTransformPoint3d(transform, &v); + *x_out = xFixedToFloat(v.vector[0]); + *y_out = xFixedToFloat(v.vector[1]); + *w_out = xFixedToFloat(v.vector[2]); + } +} + +/** + * Returns whether the provided transform is affine. + * + * transform may be null. + */ +Bool +i830_transform_is_affine (PictTransformPtr t) +{ + if (t == NULL) + return TRUE; + return t->matrix[2][0] == 0 && t->matrix[2][1] == 0; +} + /* * TODO: * - Dual head?