aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/render
diff options
context:
space:
mode:
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/filter.c51
-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.h40
-rw-r--r--nx-X11/programs/Xserver/render/render.c2
6 files changed, 158 insertions, 91 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/filter.c b/nx-X11/programs/Xserver/render/filter.c
index 776bd4237..57a21a8c0 100644
--- a/nx-X11/programs/Xserver/render/filter.c
+++ b/nx-X11/programs/Xserver/render/filter.c
@@ -215,21 +215,30 @@ PictureFindFilter (ScreenPtr pScreen, char *name, int len)
}
static Bool
-convolutionFilterValidateParams (PicturePtr pPicture,
+convolutionFilterValidateParams (ScreenPtr pScreen,
int filter,
xFixed *params,
- int nparams)
+ int nparams,
+ int* width,
+ int* height)
{
+ int w, h;
+
if (nparams < 3)
return FALSE;
if (xFixedFrac (params[0]) || xFixedFrac (params[1]))
return FALSE;
+ w = xFixedToInt (params[0]);
+ h = xFixedToInt (params[1]);
+
nparams -= 2;
- if ((xFixedToInt (params[0]) * xFixedToInt (params[1])) > nparams)
+ if (w * h > nparams)
return FALSE;
+ *width = w;
+ *height = h;
return TRUE;
}
@@ -271,10 +280,8 @@ PictureResetFilters (ScreenPtr pScreen)
int
SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams)
{
- ScreenPtr pScreen;
PictFilterPtr pFilter;
- xFixed *new_params;
- int i;
+ ScreenPtr pScreen;
if (pPicture->pDrawable) {
pScreen = pPicture->pDrawable->pScreen;
@@ -288,7 +295,7 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
if (!pFilter)
return BadName;
- if (!pPicture->pDrawable) {
+ if (pPicture->pDrawable == NULL) {
int s;
/* For source pictures, the picture isn't tied to a screen. So, ensure
@@ -303,8 +310,25 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
}
}
+ return SetPicturePictFilter (pPicture, pFilter, params, nparams);
+}
+
+int
+SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
+ xFixed *params, int nparams)
+{
+ ScreenPtr pScreen;
+ int i;
+
+ if (pPicture->pDrawable)
+ pScreen = pPicture->pDrawable->pScreen;
+ else
+ pScreen = screenInfo.screens[0];
+
if (pFilter->ValidateParams) {
- if (!(*pFilter->ValidateParams) (pPicture, pFilter->id, params, nparams))
+ int width, height;
+
+ if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams, &width, &height))
return BadMatch;
}
else if (nparams) {
@@ -312,7 +336,7 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
}
if (nparams != pPicture->filter_nparams) {
- new_params = xalloc (nparams * sizeof (xFixed));
+ xFixed *new_params = xalloc (nparams * sizeof (xFixed));
if (!new_params && nparams)
return BadAlloc;
@@ -324,9 +348,10 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
pPicture->filter_params[i] = params[i];
pPicture->filter = pFilter->id;
- if (pPicture->pDrawable) {
- PictureScreenPtr ps = GetPictureScreen (pScreen);
- int result;
+ if (pPicture->pDrawable)
+ {
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ int result;
result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter,
params, nparams);
@@ -335,5 +360,5 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
}
pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
- return Success;
+ return ;
}
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 96c2b8abc..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
@@ -168,12 +165,14 @@ typedef struct _Picture {
SourcePictPtr pSourcePict;
} PictureRec;
-typedef Bool (*PictFilterValidateParamsProcPtr) (PicturePtr pPicture, int id,
- xFixed *params, int nparams);
+typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id,
+ xFixed *params, int nparams,
+ int *width, int *height);
typedef struct {
char *name;
int id;
PictFilterValidateParamsProcPtr ValidateParams;
+ int width, height;
} PictFilterRec, *PictFilterPtr;
#define PictFilterNearest 0
@@ -457,7 +456,12 @@ PictFilterPtr
PictureFindFilter (ScreenPtr pScreen, char *name, int len);
int
-SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams);
+SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
+ xFixed *params, int nparams);
+
+int
+SetPictureFilter (PicturePtr pPicture, char *name, int len,
+ xFixed *params, int nparams);
Bool
PictureFinishInit (void);
@@ -657,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_ */
diff --git a/nx-X11/programs/Xserver/render/render.c b/nx-X11/programs/Xserver/render/render.c
index 2dedbc9c4..b165cf549 100644
--- a/nx-X11/programs/Xserver/render/render.c
+++ b/nx-X11/programs/Xserver/render/render.c
@@ -2663,7 +2663,7 @@ PanoramiXRenderCreatePicture (ClientPtr client)
newPict->info[0].id = stuff->pid;
if (refDraw->type == XRT_WINDOW &&
- stuff->drawable == WindowTable[0]->drawable.id)
+ stuff->drawable == screenInfo.screens[0]->root->drawable.id)
{
newPict->u.pict.root = TRUE;
}