aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/render
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-06-20 15:43:35 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-06-21 04:09:17 +0200
commitf9dbc64f0e3c558f9313c3cb87ebee01fe3287cd (patch)
treebd3ed24741e3c921f553ded8576d7b0a0129c051 /nx-X11/programs/Xserver/render
parent6859815ec0500af6915d5bd65c11c0c2552b8de0 (diff)
downloadnx-libs-f9dbc64f0e3c558f9313c3cb87ebee01fe3287cd.tar.gz
nx-libs-f9dbc64f0e3c558f9313c3cb87ebee01fe3287cd.tar.bz2
nx-libs-f9dbc64f0e3c558f9313c3cb87ebee01fe3287cd.zip
Move matrix operations from X server to pixman 0.13.2, handle RandR transform matrices in floating point.
Backported from X.org, inspired by: commit 9ffc6719390df8fdd0a5295a7a7a0eaea792be45 Author: Keith Packard <keithp@keithp.com> Date: Mon Nov 24 13:08:48 2008 -0800 Move matrix operations from X server to pixman 0.13.2 pixman 0.13.2 now holds all of the matrix operations. This leaves the protocol conversion routines and some ABI stubs in place Signed-off-by: Keith Packard <keithp@keithp.com> commit c4b9ab6bf56139fdd8c7c584a6f523c6766cddd6 Author: Keith Packard <keithp@keithp.com> Date: Tue Apr 29 08:29:42 2008 -0700 Handle transform failure when computing shadow damage area. PictureTransformBounds can fail, when this happens, damage the entire screen so that the shadow gets repainted correctly. commit fa6a1df209bd74da1d545982cca437afc2198cc1 Author: Keith Packard <keithp@keithp.com> Date: Fri Mar 21 02:35:28 2008 -0700 Avoid overflow in PictureTransformPoint. Fix PictureTransformIsIdentity. PictureTransformPoint computes homogeneous coordinates internally, but fails to handle intermediate values larger than 16.16. Use 64 bit intermediate values while computing the final result at 16.16 and only complain if that result is too large. PictureTransformIsIdentity was completely wrong -- it was not checking for identity transforms at all. commit 49db14e4ac26070ed86088419483888dda18b603 Author: Keith Packard <keithp@keithp.com> Date: Wed Mar 19 00:46:35 2008 -0700 Handle RandR transform matrices in floating point. RandR matrix computations lose too much precision in fixed point; computations using the inverted matrix can be as much as 10 pixels off. Convert them to double precision values and pass those around. These API changes are fairly heavyweight; the official Render interface remains fixed point, so the fixed point matrix comes along for the ride everywhere. commit 97ab0c6eff870b52c0383b63a78cec49059b2545 Author: Keith Packard <keithp@keithp.com> Date: Tue Mar 18 15:15:40 2008 -0700 When converting from double to fixed, round carefully. This reduces the matrix representation error after inverting a transformation matrix (although it doesn't eliminate it entirely). Perhaps we should extend Render to include 64-bit floating point transforms... commit 160252d94f04acc95f0a4e0f884ff565a5aa0744 Author: Keith Packard <keithp@keithp.com> Date: Mon Mar 17 23:03:56 2008 -0700 Add matrix inversion function (uses doubles) The obvious matrix inversion function, coded using doubles to avoid fiddling with fixed point precision adventures. commit ff9d1cd843a9b0aba69a3d788b21d5f6af702590 Author: Keith Packard <keithp@keithp.com> Date: Thu Mar 13 21:30:18 2008 -0700 Add funcs to convert between protocol and pixman matrices commit f547650328287545a7a4d96df8d6a6c606dd95a9 Author: Keith Packard <keithp@keithp.com> Date: Thu Mar 13 14:50:13 2008 -0700 Export a bunch of matrix operations from render. The render extension uses many matrix operations internally, this change exposes those functions to other parts of the server, drivers and extensions. The change is motivated by the 'transform' additions to the RandR extension but will likely be useful elsewhere. Backport to nx-libs: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Diffstat (limited to 'nx-X11/programs/Xserver/render')
-rw-r--r--nx-X11/programs/Xserver/render/Imakefile2
-rw-r--r--nx-X11/programs/Xserver/render/matrix.c86
-rw-r--r--nx-X11/programs/Xserver/render/picture.c68
-rw-r--r--nx-X11/programs/Xserver/render/picturestr.h27
4 files changed, 109 insertions, 74 deletions
diff --git a/nx-X11/programs/Xserver/render/Imakefile b/nx-X11/programs/Xserver/render/Imakefile
index 23f9476ea..ff272ecbd 100644
--- a/nx-X11/programs/Xserver/render/Imakefile
+++ b/nx-X11/programs/Xserver/render/Imakefile
@@ -4,6 +4,7 @@ XCOMM $XFree86: xc/programs/Xserver/render/Imakefile,v 1.10 2002/11/23 02:38:15
SRCS = animcur.c \
filter.c \
glyph.c \
+ matrix.c \
miglyph.c \
miindex.c \
mipict.c \
@@ -17,6 +18,7 @@ XCOMM $XFree86: xc/programs/Xserver/render/Imakefile,v 1.10 2002/11/23 02:38:15
OBJS = animcur.o \
filter.o \
glyph.o \
+ matrix.o \
miglyph.o \
miindex.o \
mipict.o \
diff --git a/nx-X11/programs/Xserver/render/matrix.c b/nx-X11/programs/Xserver/render/matrix.c
new file mode 100644
index 000000000..83cd66c43
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/matrix.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright © 2007 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "picturestr.h"
+
+void
+PictTransform_from_xRenderTransform(PictTransformPtr pict,
+ xRenderTransform * render)
+{
+ pict->matrix[0][0] = render->matrix11;
+ pict->matrix[0][1] = render->matrix12;
+ pict->matrix[0][2] = render->matrix13;
+
+ pict->matrix[1][0] = render->matrix21;
+ pict->matrix[1][1] = render->matrix22;
+ pict->matrix[1][2] = render->matrix23;
+
+ pict->matrix[2][0] = render->matrix31;
+ pict->matrix[2][1] = render->matrix32;
+ pict->matrix[2][2] = render->matrix33;
+}
+
+void
+xRenderTransform_from_PictTransform(xRenderTransform * render,
+ PictTransformPtr pict)
+{
+ render->matrix11 = pict->matrix[0][0];
+ render->matrix12 = pict->matrix[0][1];
+ render->matrix13 = pict->matrix[0][2];
+
+ render->matrix21 = pict->matrix[1][0];
+ render->matrix22 = pict->matrix[1][1];
+ render->matrix23 = pict->matrix[1][2];
+
+ render->matrix31 = pict->matrix[2][0];
+ render->matrix32 = pict->matrix[2][1];
+ render->matrix33 = pict->matrix[2][2];
+}
+
+Bool
+PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector)
+{
+ return pixman_transform_point(transform, vector);
+}
+
+Bool
+PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector)
+{
+ return pixman_transform_point_3d(transform, vector);
+}
diff --git a/nx-X11/programs/Xserver/render/picture.c b/nx-X11/programs/Xserver/render/picture.c
index ddb21a07c..3c43abd67 100644
--- a/nx-X11/programs/Xserver/render/picture.c
+++ b/nx-X11/programs/Xserver/render/picture.c
@@ -1892,71 +1892,3 @@ AddTraps (PicturePtr pPicture,
ValidatePicture (pPicture);
(*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps);
}
-
-#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff)
-#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31))
-
-Bool
-PictureTransformPoint3d (PictTransformPtr transform,
- PictVectorPtr vector)
-{
- PictVector result;
- int i, j;
- xFixed_32_32 partial;
- xFixed_48_16 v;
-
- for (j = 0; j < 3; j++)
- {
- v = 0;
- for (i = 0; i < 3; i++)
- {
- partial = ((xFixed_48_16) transform->matrix[j][i] *
- (xFixed_48_16) vector->vector[i]);
- v += partial >> 16;
- }
- if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
- return FALSE;
- result.vector[j] = (xFixed) v;
- }
- if (!result.vector[2])
- return FALSE;
- *vector = result;
- return TRUE;
-}
-
-
-Bool
-PictureTransformPoint (PictTransformPtr transform,
- PictVectorPtr vector)
-{
- PictVector result;
- int i, j;
- xFixed_32_32 partial;
- xFixed_48_16 v;
-
- for (j = 0; j < 3; j++)
- {
- v = 0;
- for (i = 0; i < 3; i++)
- {
- partial = ((xFixed_48_16) transform->matrix[j][i] *
- (xFixed_48_16) vector->vector[i]);
- v += partial >> 16;
- }
- if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
- return FALSE;
- result.vector[j] = (xFixed) v;
- }
- if (!result.vector[2])
- return FALSE;
- for (j = 0; j < 2; j++)
- {
- partial = (xFixed_48_16) result.vector[j] << 16;
- v = partial / result.vector[2];
- if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
- return FALSE;
- vector->vector[j] = (xFixed) v;
- }
- vector->vector[2] = xFixed1;
- return TRUE;
-}
diff --git a/nx-X11/programs/Xserver/render/picturestr.h b/nx-X11/programs/Xserver/render/picturestr.h
index 38d2cc5ec..4969f6cab 100644
--- a/nx-X11/programs/Xserver/render/picturestr.h
+++ b/nx-X11/programs/Xserver/render/picturestr.h
@@ -54,13 +54,10 @@ typedef struct _PictFormat {
IndexFormatRec index;
} PictFormatRec;
-typedef struct _PictVector {
- xFixed vector[3];
-} PictVector, *PictVectorPtr;
+typedef struct pixman_vector PictVector, *PictVectorPtr;
+typedef struct pixman_transform PictTransform, *PictTransformPtr;
-typedef struct _PictTransform {
- xFixed matrix[3][3];
-} PictTransform, *PictTransformPtr;
+#define pict_f_transform pixman_f_transform
#define PICT_GRADIENT_STOPTABLE_SIZE 1024
#define SourcePictTypeSolidFill 0
@@ -664,4 +661,22 @@ void PanoramiXRenderInit (void);
void PanoramiXRenderReset (void);
#endif
+/*
+ * matrix.c
+ */
+
+extern _X_EXPORT void
+PictTransform_from_xRenderTransform(PictTransformPtr pict,
+ xRenderTransform * render);
+
+extern _X_EXPORT void
+xRenderTransform_from_PictTransform(xRenderTransform * render,
+ PictTransformPtr pict);
+
+extern _X_EXPORT Bool
+ PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector);
+
+extern _X_EXPORT Bool
+ PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector);
+
#endif /* _PICTURESTR_H_ */