New upstream version 3.5.99.27
This commit is contained in:
66
nx-X11/programs/Xserver/render/Imakefile
Normal file
66
nx-X11/programs/Xserver/render/Imakefile
Normal file
@@ -0,0 +1,66 @@
|
||||
NULL =
|
||||
|
||||
#include <Server.tmpl>
|
||||
|
||||
#if (!(defined(NXAgentServer) && NXAgentServer))
|
||||
NXAGENT_SKIP_SRCS = \
|
||||
glyph.c \
|
||||
mitrap.c \
|
||||
picture.c \
|
||||
render.c \
|
||||
$(NULL)
|
||||
NXAGENT_SKIP_OBJS = \
|
||||
glyph.o \
|
||||
mitrap.o \
|
||||
picture.o \
|
||||
render.o \
|
||||
$(NULL)
|
||||
#else
|
||||
NX_DEFINES = -DNXAGENT_SERVER
|
||||
#endif
|
||||
|
||||
SRCS = animcur.c \
|
||||
filter.c \
|
||||
glyph.c \
|
||||
matrix.c \
|
||||
miindex.c \
|
||||
mipict.c \
|
||||
mirect.c \
|
||||
mitri.c \
|
||||
renderedge.c \
|
||||
$(NXAGENT_SKIP_SRCS) \
|
||||
$(NULL)
|
||||
|
||||
OBJS = animcur.o \
|
||||
filter.o \
|
||||
glyph.o \
|
||||
matrix.o \
|
||||
miindex.o \
|
||||
mipict.o \
|
||||
mirect.o \
|
||||
mitri.o \
|
||||
renderedge.o \
|
||||
$(NXAGENT_SKIP_OBJS) \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES = -I. -I../include -I../mi \
|
||||
-I../fb -I$(EXTINCSRC) -I$(XINCLUDESRC) \
|
||||
-I../Xext \
|
||||
`pkg-config --cflags-only-I pixman-1`
|
||||
LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
|
||||
|
||||
DEFINES = \
|
||||
$(NX_DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
NormalLibraryTarget(render,$(OBJS))
|
||||
NormalLibraryObjectRule()
|
||||
LintLibraryTarget(render,$(SRCS))
|
||||
NormalLintTarget($(SRCS))
|
||||
|
||||
DependTarget()
|
||||
|
||||
InstallDriverSDKNonExecFile(glyphstr.h,$(DRIVERSDKINCLUDEDIR))
|
||||
InstallDriverSDKNonExecFile(mipict.h,$(DRIVERSDKINCLUDEDIR))
|
||||
InstallDriverSDKNonExecFile(picture.h,$(DRIVERSDKINCLUDEDIR))
|
||||
InstallDriverSDKNonExecFile(picturestr.h,$(DRIVERSDKINCLUDEDIR))
|
||||
400
nx-X11/programs/Xserver/render/animcur.c
Normal file
400
nx-X11/programs/Xserver/render/animcur.c
Normal file
@@ -0,0 +1,400 @@
|
||||
/*
|
||||
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
|
||||
*
|
||||
* 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Animated cursors for X. Not specific to Render in any way, but
|
||||
* stuck there because Render has the other cool cursor extension.
|
||||
* Besides, everyone has Render.
|
||||
*
|
||||
* Implemented as a simple layer over the core cursor code; it
|
||||
* creates composite cursors out of a set of static cursors and
|
||||
* delta times between each image.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xmd.h>
|
||||
#include "servermd.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "dixstruct.h"
|
||||
#include "cursorstr.h"
|
||||
#include "dixfontstr.h"
|
||||
#include "opaque.h"
|
||||
#include "picturestr.h"
|
||||
|
||||
typedef struct _AnimCurElt {
|
||||
CursorPtr pCursor; /* cursor to show */
|
||||
CARD32 delay; /* in ms */
|
||||
} AnimCurElt;
|
||||
|
||||
typedef struct _AnimCur {
|
||||
int nelt; /* number of elements in the elts array */
|
||||
AnimCurElt *elts; /* actually allocated right after the structure */
|
||||
} AnimCurRec, *AnimCurPtr;
|
||||
|
||||
typedef struct _AnimScrPriv {
|
||||
CursorPtr pCursor;
|
||||
int elt;
|
||||
CARD32 time;
|
||||
|
||||
CloseScreenProcPtr CloseScreen;
|
||||
|
||||
ScreenBlockHandlerProcPtr BlockHandler;
|
||||
|
||||
CursorLimitsProcPtr CursorLimits;
|
||||
DisplayCursorProcPtr DisplayCursor;
|
||||
SetCursorPositionProcPtr SetCursorPosition;
|
||||
RealizeCursorProcPtr RealizeCursor;
|
||||
UnrealizeCursorProcPtr UnrealizeCursor;
|
||||
RecolorCursorProcPtr RecolorCursor;
|
||||
} AnimCurScreenRec, *AnimCurScreenPtr;
|
||||
|
||||
typedef struct _AnimCurState {
|
||||
CursorPtr pCursor;
|
||||
ScreenPtr pScreen;
|
||||
int elt;
|
||||
CARD32 time;
|
||||
} AnimCurStateRec, *AnimCurStatePtr;
|
||||
|
||||
static AnimCurStateRec animCurState;
|
||||
|
||||
static unsigned char empty[4];
|
||||
|
||||
static CursorBits animCursorBits = {
|
||||
empty, empty, 2, 1, 1, 0, 0, 1
|
||||
};
|
||||
|
||||
int AnimCurScreenPrivateIndex = -1;
|
||||
int AnimCurGeneration;
|
||||
|
||||
#define IsAnimCur(c) ((c)->bits == &animCursorBits)
|
||||
#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
|
||||
#define GetAnimCurScreen(s) ((AnimCurScreenPtr) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr))
|
||||
#define GetAnimCurScreenIfSet(s) ((AnimCurScreenPrivateIndex != -1) ? GetAnimCurScreen(s) : NULL)
|
||||
#define SetAnimCurScreen(s,p) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr = (void *) (p))
|
||||
|
||||
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
|
||||
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
|
||||
|
||||
static Bool
|
||||
AnimCurDisplayCursor (ScreenPtr pScreen,
|
||||
CursorPtr pCursor);
|
||||
|
||||
static Bool
|
||||
AnimCurSetCursorPosition (ScreenPtr pScreen,
|
||||
int x,
|
||||
int y,
|
||||
Bool generateEvent);
|
||||
|
||||
static Bool
|
||||
AnimCurCloseScreen (ScreenPtr pScreen)
|
||||
{
|
||||
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
||||
Bool ret;
|
||||
|
||||
Unwrap(as, pScreen, CloseScreen);
|
||||
|
||||
Unwrap(as, pScreen, BlockHandler);
|
||||
|
||||
Unwrap(as, pScreen, CursorLimits);
|
||||
Unwrap(as, pScreen, DisplayCursor);
|
||||
Unwrap(as, pScreen, SetCursorPosition);
|
||||
Unwrap(as, pScreen, RealizeCursor);
|
||||
Unwrap(as, pScreen, UnrealizeCursor);
|
||||
Unwrap(as, pScreen, RecolorCursor);
|
||||
SetAnimCurScreen(pScreen,0);
|
||||
ret = (*pScreen->CloseScreen) (pScreen);
|
||||
free (as);
|
||||
if (screenInfo.numScreens <= 1)
|
||||
AnimCurScreenPrivateIndex = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
AnimCurCursorLimits (ScreenPtr pScreen,
|
||||
CursorPtr pCursor,
|
||||
BoxPtr pHotBox,
|
||||
BoxPtr pTopLeftBox)
|
||||
{
|
||||
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
||||
|
||||
Unwrap (as, pScreen, CursorLimits);
|
||||
if (IsAnimCur(pCursor))
|
||||
{
|
||||
AnimCurPtr ac = GetAnimCur(pCursor);
|
||||
|
||||
(*pScreen->CursorLimits) (pScreen, ac->elts[0].pCursor, pHotBox, pTopLeftBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*pScreen->CursorLimits) (pScreen, pCursor, pHotBox, pTopLeftBox);
|
||||
}
|
||||
Wrap (as, pScreen, CursorLimits, AnimCurCursorLimits);
|
||||
}
|
||||
|
||||
/*
|
||||
* This has to be a screen block handler instead of a generic
|
||||
* block handler so that it is well ordered with respect to the DRI
|
||||
* block handler responsible for releasing the hardware to DRI clients
|
||||
*/
|
||||
|
||||
static void
|
||||
AnimCurScreenBlockHandler (int screenNum,
|
||||
void * blockData,
|
||||
void * pTimeout,
|
||||
void * pReadmask)
|
||||
{
|
||||
ScreenPtr pScreen = screenInfo.screens[screenNum];
|
||||
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
||||
|
||||
if (pScreen == animCurState.pScreen)
|
||||
{
|
||||
CARD32 now = GetTimeInMillis ();
|
||||
|
||||
if ((INT32) (now - animCurState.time) >= 0)
|
||||
{
|
||||
AnimCurPtr ac = GetAnimCur(animCurState.pCursor);
|
||||
int elt = (animCurState.elt + 1) % ac->nelt;
|
||||
DisplayCursorProcPtr DisplayCursor;
|
||||
|
||||
/*
|
||||
* Not a simple Unwrap/Wrap as this
|
||||
* isn't called along the DisplayCursor
|
||||
* wrapper chain.
|
||||
*/
|
||||
DisplayCursor = pScreen->DisplayCursor;
|
||||
pScreen->DisplayCursor = as->DisplayCursor;
|
||||
(void) (*pScreen->DisplayCursor) (pScreen, ac->elts[elt].pCursor);
|
||||
as->DisplayCursor = pScreen->DisplayCursor;
|
||||
pScreen->DisplayCursor = DisplayCursor;
|
||||
|
||||
animCurState.elt = elt;
|
||||
animCurState.time = now + ac->elts[elt].delay;
|
||||
}
|
||||
AdjustWaitForDelay (pTimeout, animCurState.time - now);
|
||||
}
|
||||
Unwrap (as, pScreen, BlockHandler);
|
||||
(*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
|
||||
Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
|
||||
}
|
||||
|
||||
static Bool
|
||||
AnimCurDisplayCursor (ScreenPtr pScreen,
|
||||
CursorPtr pCursor)
|
||||
{
|
||||
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
||||
Bool ret;
|
||||
|
||||
Unwrap (as, pScreen, DisplayCursor);
|
||||
if (IsAnimCur(pCursor))
|
||||
{
|
||||
if (pCursor != animCurState.pCursor)
|
||||
{
|
||||
AnimCurPtr ac = GetAnimCur(pCursor);
|
||||
|
||||
ret = (*pScreen->DisplayCursor) (pScreen, ac->elts[0].pCursor);
|
||||
if (ret)
|
||||
{
|
||||
animCurState.elt = 0;
|
||||
animCurState.time = GetTimeInMillis () + ac->elts[0].delay;
|
||||
animCurState.pCursor = pCursor;
|
||||
animCurState.pScreen = pScreen;
|
||||
}
|
||||
}
|
||||
else
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
animCurState.pCursor = 0;
|
||||
animCurState.pScreen = 0;
|
||||
ret = (*pScreen->DisplayCursor) (pScreen, pCursor);
|
||||
}
|
||||
Wrap (as, pScreen, DisplayCursor, AnimCurDisplayCursor);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Bool
|
||||
AnimCurSetCursorPosition (ScreenPtr pScreen,
|
||||
int x,
|
||||
int y,
|
||||
Bool generateEvent)
|
||||
{
|
||||
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
||||
Bool ret;
|
||||
|
||||
Unwrap (as, pScreen, SetCursorPosition);
|
||||
if (animCurState.pCursor)
|
||||
animCurState.pScreen = pScreen;
|
||||
ret = (*pScreen->SetCursorPosition) (pScreen, x, y, generateEvent);
|
||||
Wrap (as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Bool
|
||||
AnimCurRealizeCursor (ScreenPtr pScreen,
|
||||
CursorPtr pCursor)
|
||||
{
|
||||
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
||||
Bool ret;
|
||||
|
||||
Unwrap (as, pScreen, RealizeCursor);
|
||||
if (IsAnimCur(pCursor))
|
||||
ret = TRUE;
|
||||
else
|
||||
ret = (*pScreen->RealizeCursor) (pScreen, pCursor);
|
||||
Wrap (as, pScreen, RealizeCursor, AnimCurRealizeCursor);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Bool
|
||||
AnimCurUnrealizeCursor (ScreenPtr pScreen,
|
||||
CursorPtr pCursor)
|
||||
{
|
||||
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
||||
Bool ret;
|
||||
|
||||
Unwrap (as, pScreen, UnrealizeCursor);
|
||||
if (IsAnimCur(pCursor))
|
||||
{
|
||||
AnimCurPtr ac = GetAnimCur(pCursor);
|
||||
int i;
|
||||
|
||||
if (pScreen->myNum == 0)
|
||||
for (i = 0; i < ac->nelt; i++)
|
||||
FreeCursor (ac->elts[i].pCursor, 0);
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
ret = (*pScreen->UnrealizeCursor) (pScreen, pCursor);
|
||||
Wrap (as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
AnimCurRecolorCursor (ScreenPtr pScreen,
|
||||
CursorPtr pCursor,
|
||||
Bool displayed)
|
||||
{
|
||||
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
||||
|
||||
Unwrap (as, pScreen, RecolorCursor);
|
||||
if (IsAnimCur(pCursor))
|
||||
{
|
||||
AnimCurPtr ac = GetAnimCur(pCursor);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ac->nelt; i++)
|
||||
(*pScreen->RecolorCursor) (pScreen, ac->elts[i].pCursor,
|
||||
displayed &&
|
||||
animCurState.elt == i);
|
||||
}
|
||||
else
|
||||
(*pScreen->RecolorCursor) (pScreen, pCursor, displayed);
|
||||
Wrap (as, pScreen, RecolorCursor, AnimCurRecolorCursor);
|
||||
}
|
||||
|
||||
Bool
|
||||
AnimCurInit (ScreenPtr pScreen)
|
||||
{
|
||||
AnimCurScreenPtr as;
|
||||
|
||||
if (AnimCurGeneration != serverGeneration)
|
||||
{
|
||||
AnimCurScreenPrivateIndex = AllocateScreenPrivateIndex ();
|
||||
if (AnimCurScreenPrivateIndex < 0)
|
||||
return FALSE;
|
||||
AnimCurGeneration = serverGeneration;
|
||||
animCurState.pCursor = 0;
|
||||
animCurState.pScreen = 0;
|
||||
animCurState.elt = 0;
|
||||
animCurState.time = 0;
|
||||
}
|
||||
as = (AnimCurScreenPtr) malloc (sizeof (AnimCurScreenRec));
|
||||
if (!as)
|
||||
return FALSE;
|
||||
Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen);
|
||||
|
||||
Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
|
||||
|
||||
Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
|
||||
Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);
|
||||
Wrap(as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
|
||||
Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor);
|
||||
Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
|
||||
Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor);
|
||||
SetAnimCurScreen(pScreen,as);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor)
|
||||
{
|
||||
CursorPtr pCursor;
|
||||
int i;
|
||||
AnimCurPtr ac;
|
||||
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
if (!GetAnimCurScreenIfSet (screenInfo.screens[i]))
|
||||
return BadImplementation;
|
||||
|
||||
for (i = 0; i < ncursor; i++)
|
||||
if (IsAnimCur (cursors[i]))
|
||||
return BadMatch;
|
||||
|
||||
pCursor = (CursorPtr) malloc (sizeof (CursorRec) +
|
||||
sizeof (AnimCurRec) +
|
||||
ncursor * sizeof (AnimCurElt));
|
||||
if (!pCursor)
|
||||
return BadAlloc;
|
||||
pCursor->bits = &animCursorBits;
|
||||
animCursorBits.refcnt++;
|
||||
pCursor->refcnt = 1;
|
||||
|
||||
pCursor->foreRed = cursors[0]->foreRed;
|
||||
pCursor->foreGreen = cursors[0]->foreGreen;
|
||||
pCursor->foreBlue = cursors[0]->foreBlue;
|
||||
|
||||
pCursor->backRed = cursors[0]->backRed;
|
||||
pCursor->backGreen = cursors[0]->backGreen;
|
||||
pCursor->backBlue = cursors[0]->backBlue;
|
||||
|
||||
/*
|
||||
* Fill in the AnimCurRec
|
||||
*/
|
||||
ac = GetAnimCur (pCursor);
|
||||
ac->nelt = ncursor;
|
||||
ac->elts = (AnimCurElt *) (ac + 1);
|
||||
|
||||
for (i = 0; i < ncursor; i++)
|
||||
{
|
||||
cursors[i]->refcnt++;
|
||||
ac->elts[i].pCursor = cursors[i];
|
||||
ac->elts[i].delay = deltas[i];
|
||||
}
|
||||
|
||||
*ppCursor = pCursor;
|
||||
return Success;
|
||||
}
|
||||
364
nx-X11/programs/Xserver/render/filter.c
Normal file
364
nx-X11/programs/Xserver/render/filter.c
Normal file
@@ -0,0 +1,364 @@
|
||||
/*
|
||||
* $Id: filter.c,v 1.10 2005/07/03 08:53:54 daniels Exp $
|
||||
*
|
||||
* Copyright © 2002 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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"
|
||||
|
||||
static char **filterNames;
|
||||
static int nfilterNames;
|
||||
|
||||
/*
|
||||
* standard but not required filters don't have constant indices
|
||||
*/
|
||||
|
||||
int
|
||||
PictureGetFilterId (char *filter, int len, Bool makeit)
|
||||
{
|
||||
int i;
|
||||
char *name;
|
||||
char **names;
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (filter);
|
||||
for (i = 0; i < nfilterNames; i++)
|
||||
if (!CompareISOLatin1Lowered ((unsigned char *) filterNames[i], -1, (unsigned char *) filter, len))
|
||||
return i;
|
||||
if (!makeit)
|
||||
return -1;
|
||||
name = malloc (len + 1);
|
||||
if (!name)
|
||||
return -1;
|
||||
memcpy (name, filter, len);
|
||||
name[len] = '\0';
|
||||
if (filterNames)
|
||||
names = realloc (filterNames, (nfilterNames + 1) * sizeof (char *));
|
||||
else
|
||||
names = malloc (sizeof (char *));
|
||||
if (!names)
|
||||
{
|
||||
free (name);
|
||||
return -1;
|
||||
}
|
||||
filterNames = names;
|
||||
i = nfilterNames++;
|
||||
filterNames[i] = name;
|
||||
return i;
|
||||
}
|
||||
|
||||
static Bool
|
||||
PictureSetDefaultIds (void)
|
||||
{
|
||||
/* careful here -- this list must match the #define values */
|
||||
|
||||
if (PictureGetFilterId (FilterNearest, -1, TRUE) != PictFilterNearest)
|
||||
return FALSE;
|
||||
if (PictureGetFilterId (FilterBilinear, -1, TRUE) != PictFilterBilinear)
|
||||
return FALSE;
|
||||
|
||||
if (PictureGetFilterId (FilterFast, -1, TRUE) != PictFilterFast)
|
||||
return FALSE;
|
||||
if (PictureGetFilterId (FilterGood, -1, TRUE) != PictFilterGood)
|
||||
return FALSE;
|
||||
if (PictureGetFilterId (FilterBest, -1, TRUE) != PictFilterBest)
|
||||
return FALSE;
|
||||
|
||||
if (PictureGetFilterId (FilterConvolution, -1, TRUE) != PictFilterConvolution)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char *
|
||||
PictureGetFilterName (int id)
|
||||
{
|
||||
if (0 <= id && id < nfilterNames)
|
||||
return filterNames[id];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PictureFreeFilterIds (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nfilterNames; i++)
|
||||
free (filterNames[i]);
|
||||
free (filterNames);
|
||||
nfilterNames = 0;
|
||||
filterNames = 0;
|
||||
}
|
||||
|
||||
int
|
||||
PictureAddFilter (ScreenPtr pScreen,
|
||||
char *filter,
|
||||
PictFilterValidateParamsProcPtr ValidateParams)
|
||||
{
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
int id = PictureGetFilterId (filter, -1, TRUE);
|
||||
int i;
|
||||
PictFilterPtr filters;
|
||||
|
||||
if (id < 0)
|
||||
return -1;
|
||||
/*
|
||||
* It's an error to attempt to reregister a filter
|
||||
*/
|
||||
for (i = 0; i < ps->nfilters; i++)
|
||||
if (ps->filters[i].id == id)
|
||||
return -1;
|
||||
if (ps->filters)
|
||||
filters = realloc (ps->filters, (ps->nfilters + 1) * sizeof (PictFilterRec));
|
||||
else
|
||||
filters = malloc (sizeof (PictFilterRec));
|
||||
if (!filters)
|
||||
return -1;
|
||||
ps->filters = filters;
|
||||
i = ps->nfilters++;
|
||||
ps->filters[i].name = PictureGetFilterName (id);
|
||||
ps->filters[i].id = id;
|
||||
ps->filters[i].ValidateParams = ValidateParams;
|
||||
return id;
|
||||
}
|
||||
|
||||
Bool
|
||||
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias)
|
||||
{
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
int filter_id = PictureGetFilterId (filter, -1, FALSE);
|
||||
int alias_id = PictureGetFilterId (alias, -1, TRUE);
|
||||
int i;
|
||||
|
||||
if (filter_id < 0 || alias_id < 0)
|
||||
return FALSE;
|
||||
for (i = 0; i < ps->nfilterAliases; i++)
|
||||
if (ps->filterAliases[i].alias_id == alias_id)
|
||||
break;
|
||||
if (i == ps->nfilterAliases)
|
||||
{
|
||||
PictFilterAliasPtr aliases;
|
||||
|
||||
if (ps->filterAliases)
|
||||
aliases = realloc (ps->filterAliases,
|
||||
(ps->nfilterAliases + 1) *
|
||||
sizeof (PictFilterAliasRec));
|
||||
else
|
||||
aliases = malloc (sizeof (PictFilterAliasRec));
|
||||
if (!aliases)
|
||||
return FALSE;
|
||||
ps->filterAliases = aliases;
|
||||
ps->filterAliases[i].alias = PictureGetFilterName (alias_id);
|
||||
ps->filterAliases[i].alias_id = alias_id;
|
||||
ps->nfilterAliases++;
|
||||
}
|
||||
ps->filterAliases[i].filter_id = filter_id;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PictFilterPtr
|
||||
PictureFindFilter (ScreenPtr pScreen, char *name, int len)
|
||||
{
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
int id = PictureGetFilterId (name, len, FALSE);
|
||||
int i;
|
||||
|
||||
if (id < 0)
|
||||
return 0;
|
||||
/* Check for an alias, allow them to recurse */
|
||||
for (i = 0; i < ps->nfilterAliases; i++)
|
||||
if (ps->filterAliases[i].alias_id == id)
|
||||
{
|
||||
id = ps->filterAliases[i].filter_id;
|
||||
i = 0;
|
||||
}
|
||||
/* find the filter */
|
||||
for (i = 0; i < ps->nfilters; i++)
|
||||
if (ps->filters[i].id == id)
|
||||
return &ps->filters[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Bool
|
||||
convolutionFilterValidateParams (ScreenPtr pScreen,
|
||||
int filter,
|
||||
xFixed *params,
|
||||
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 (w * h > nparams)
|
||||
return FALSE;
|
||||
|
||||
*width = w;
|
||||
*height = h;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
PictureSetDefaultFilters (ScreenPtr pScreen)
|
||||
{
|
||||
if (!filterNames)
|
||||
if (!PictureSetDefaultIds ())
|
||||
return FALSE;
|
||||
if (PictureAddFilter (pScreen, FilterNearest, 0) < 0)
|
||||
return FALSE;
|
||||
if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0)
|
||||
return FALSE;
|
||||
|
||||
if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
|
||||
return FALSE;
|
||||
if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterGood))
|
||||
return FALSE;
|
||||
if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest))
|
||||
return FALSE;
|
||||
|
||||
if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams) < 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
PictureResetFilters (ScreenPtr pScreen)
|
||||
{
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
|
||||
free (ps->filters);
|
||||
free (ps->filterAliases);
|
||||
PictureFreeFilterIds ();
|
||||
}
|
||||
|
||||
int
|
||||
SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams)
|
||||
{
|
||||
PictFilterPtr pFilter;
|
||||
ScreenPtr pScreen;
|
||||
|
||||
if (pPicture->pDrawable) {
|
||||
pScreen = pPicture->pDrawable->pScreen;
|
||||
}
|
||||
else {
|
||||
pScreen = screenInfo.screens[0];
|
||||
}
|
||||
|
||||
pFilter = PictureFindFilter (pScreen, name, len);
|
||||
|
||||
if (!pFilter)
|
||||
return BadName;
|
||||
|
||||
if (pPicture->pDrawable == NULL) {
|
||||
int s;
|
||||
|
||||
/* For source pictures, the picture isn't tied to a screen. So, ensure
|
||||
* that all screens can handle a filter we set for the picture.
|
||||
*/
|
||||
for (s = 1; s < screenInfo.numScreens; s++) {
|
||||
PictFilterPtr pScreenFilter;
|
||||
|
||||
pScreenFilter = PictureFindFilter(screenInfo.screens[s], name, len);
|
||||
if (!pScreenFilter || pScreenFilter->id != pFilter->id)
|
||||
return BadMatch;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
int width, height;
|
||||
|
||||
if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams, &width, &height))
|
||||
return BadMatch;
|
||||
}
|
||||
else if (nparams) {
|
||||
return BadMatch;
|
||||
}
|
||||
|
||||
if (nparams != pPicture->filter_nparams) {
|
||||
xFixed *new_params = malloc (nparams * sizeof (xFixed));
|
||||
|
||||
if (!new_params && nparams)
|
||||
return BadAlloc;
|
||||
free (pPicture->filter_params);
|
||||
pPicture->filter_params = new_params;
|
||||
pPicture->filter_nparams = nparams;
|
||||
}
|
||||
for (i = 0; i < nparams; i++)
|
||||
pPicture->filter_params[i] = params[i];
|
||||
pPicture->filter = pFilter->id;
|
||||
|
||||
if (pPicture->pDrawable)
|
||||
{
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
int result;
|
||||
|
||||
result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter,
|
||||
params, nparams);
|
||||
|
||||
return result;
|
||||
}
|
||||
pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
|
||||
|
||||
return Success;
|
||||
}
|
||||
699
nx-X11/programs/Xserver/render/glyph.c
Normal file
699
nx-X11/programs/Xserver/render/glyph.c
Normal file
@@ -0,0 +1,699 @@
|
||||
/*
|
||||
* Copyright © 2000 SuSE, Inc.
|
||||
*
|
||||
* 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 SuSE not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. SuSE makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
|
||||
* 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.
|
||||
*
|
||||
* Author: Keith Packard, SuSE, Inc.
|
||||
*/
|
||||
|
||||
#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"
|
||||
#include "glyphstr.h"
|
||||
#include "mipict.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* From Knuth -- a good choice for hash/rehash values is p, p-2 where
|
||||
* p and p-2 are both prime. These tables are sized to have an extra 10%
|
||||
* free to avoid exponential performance degradation as the hash table fills
|
||||
*/
|
||||
static GlyphHashSetRec glyphHashSets[] = {
|
||||
{ 32, 43, 41 },
|
||||
{ 64, 73, 71 },
|
||||
{ 128, 151, 149 },
|
||||
{ 256, 283, 281 },
|
||||
{ 512, 571, 569 },
|
||||
{ 1024, 1153, 1151 },
|
||||
{ 2048, 2269, 2267 },
|
||||
{ 4096, 4519, 4517 },
|
||||
{ 8192, 9013, 9011 },
|
||||
{ 16384, 18043, 18041 },
|
||||
{ 32768, 36109, 36107 },
|
||||
{ 65536, 72091, 72089 },
|
||||
{ 131072, 144409, 144407 },
|
||||
{ 262144, 288361, 288359 },
|
||||
{ 524288, 576883, 576881 },
|
||||
{ 1048576, 1153459, 1153457 },
|
||||
{ 2097152, 2307163, 2307161 },
|
||||
{ 4194304, 4613893, 4613891 },
|
||||
{ 8388608, 9227641, 9227639 },
|
||||
{ 16777216, 18455029, 18455027 },
|
||||
{ 33554432, 36911011, 36911009 },
|
||||
{ 67108864, 73819861, 73819859 },
|
||||
{ 134217728, 147639589, 147639587 },
|
||||
{ 268435456, 295279081, 295279079 },
|
||||
{ 536870912, 590559793, 590559791 }
|
||||
};
|
||||
|
||||
#define NGLYPHHASHSETS (sizeof(glyphHashSets)/sizeof(glyphHashSets[0]))
|
||||
|
||||
const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
|
||||
|
||||
GlyphHashRec globalGlyphs[GlyphFormatNum];
|
||||
|
||||
GlyphHashSetPtr
|
||||
FindGlyphHashSet (CARD32 filled)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NGLYPHHASHSETS; i++)
|
||||
if (glyphHashSets[i].entries >= filled)
|
||||
return &glyphHashSets[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _GlyphSetPrivateAllocateIndex = 0;
|
||||
|
||||
int
|
||||
AllocateGlyphSetPrivateIndex (void)
|
||||
{
|
||||
return _GlyphSetPrivateAllocateIndex++;
|
||||
}
|
||||
|
||||
void
|
||||
ResetGlyphSetPrivateIndex (void)
|
||||
{
|
||||
_GlyphSetPrivateAllocateIndex = 0;
|
||||
}
|
||||
|
||||
Bool
|
||||
_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr)
|
||||
{
|
||||
void **new;
|
||||
|
||||
if (n > glyphSet->maxPrivate) {
|
||||
if (glyphSet->devPrivates &&
|
||||
glyphSet->devPrivates != (void *)(&glyphSet[1])) {
|
||||
new = (void **) realloc (glyphSet->devPrivates,
|
||||
(n + 1) * sizeof (void *));
|
||||
if (!new)
|
||||
return FALSE;
|
||||
} else {
|
||||
new = (void **) malloc ((n + 1) * sizeof (void *));
|
||||
if (!new)
|
||||
return FALSE;
|
||||
if (glyphSet->devPrivates)
|
||||
memcpy (new,
|
||||
glyphSet->devPrivates,
|
||||
(glyphSet->maxPrivate + 1) * sizeof (void *));
|
||||
}
|
||||
glyphSet->devPrivates = new;
|
||||
/* Zero out new, uninitialize privates */
|
||||
while (++glyphSet->maxPrivate < n)
|
||||
glyphSet->devPrivates[glyphSet->maxPrivate] = (void *)0;
|
||||
}
|
||||
glyphSet->devPrivates[n] = ptr;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
GlyphInit (ScreenPtr pScreen)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
GlyphRefPtr
|
||||
FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare)
|
||||
{
|
||||
CARD32 elt, step, s;
|
||||
GlyphPtr glyph;
|
||||
GlyphRefPtr table, gr, del;
|
||||
CARD32 tableSize = hash->hashSet->size;
|
||||
|
||||
table = hash->table;
|
||||
elt = signature % tableSize;
|
||||
step = 0;
|
||||
del = 0;
|
||||
for (;;)
|
||||
{
|
||||
gr = &table[elt];
|
||||
s = gr->signature;
|
||||
glyph = gr->glyph;
|
||||
if (!glyph)
|
||||
{
|
||||
if (del)
|
||||
gr = del;
|
||||
break;
|
||||
}
|
||||
if (glyph == DeletedGlyph)
|
||||
{
|
||||
if (!del)
|
||||
del = gr;
|
||||
else if (gr == del)
|
||||
break;
|
||||
}
|
||||
else if (s == signature &&
|
||||
(!match ||
|
||||
memcmp (&compare->info, &glyph->info, compare->size) == 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!step)
|
||||
{
|
||||
step = signature % hash->hashSet->rehash;
|
||||
if (!step)
|
||||
step = 1;
|
||||
}
|
||||
elt += step;
|
||||
if (elt >= tableSize)
|
||||
elt -= tableSize;
|
||||
}
|
||||
return gr;
|
||||
}
|
||||
#endif
|
||||
|
||||
CARD32
|
||||
HashGlyph (GlyphPtr glyph)
|
||||
{
|
||||
CARD32 *bits = (CARD32 *) &(glyph->info);
|
||||
CARD32 hash;
|
||||
int n = glyph->size / sizeof (CARD32);
|
||||
|
||||
hash = 0;
|
||||
while (n--)
|
||||
hash ^= *bits++;
|
||||
return hash;
|
||||
}
|
||||
|
||||
#ifdef CHECK_DUPLICATES
|
||||
void
|
||||
DuplicateRef (GlyphPtr glyph, char *where)
|
||||
{
|
||||
ErrorF ("Duplicate Glyph 0x%x from %s\n", glyph, where);
|
||||
}
|
||||
|
||||
void
|
||||
CheckDuplicates (GlyphHashPtr hash, char *where)
|
||||
{
|
||||
GlyphPtr g;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < hash->hashSet->size; i++)
|
||||
{
|
||||
g = hash->table[i].glyph;
|
||||
if (!g || g == DeletedGlyph)
|
||||
continue;
|
||||
for (j = i + 1; j < hash->hashSet->size; j++)
|
||||
if (hash->table[j].glyph == g)
|
||||
DuplicateRef (g, where);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define CheckDuplicates(a,b)
|
||||
#define DuplicateRef(a,b)
|
||||
#endif
|
||||
|
||||
void
|
||||
FreeGlyph (GlyphPtr glyph, int format)
|
||||
{
|
||||
CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
|
||||
if (--glyph->refcnt == 0)
|
||||
{
|
||||
GlyphRefPtr gr;
|
||||
int i;
|
||||
int first;
|
||||
|
||||
first = -1;
|
||||
for (i = 0; i < globalGlyphs[format].hashSet->size; i++)
|
||||
if (globalGlyphs[format].table[i].glyph == glyph)
|
||||
{
|
||||
if (first != -1)
|
||||
DuplicateRef (glyph, "FreeGlyph check");
|
||||
first = i;
|
||||
}
|
||||
|
||||
gr = FindGlyphRef (&globalGlyphs[format],
|
||||
HashGlyph (glyph), TRUE, glyph);
|
||||
if (gr - globalGlyphs[format].table != first)
|
||||
DuplicateRef (glyph, "Found wrong one");
|
||||
if (gr->glyph && gr->glyph != DeletedGlyph)
|
||||
{
|
||||
gr->glyph = DeletedGlyph;
|
||||
gr->signature = 0;
|
||||
globalGlyphs[format].tableEntries--;
|
||||
}
|
||||
free (glyph);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
void
|
||||
AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
|
||||
{
|
||||
GlyphRefPtr gr;
|
||||
CARD32 hash;
|
||||
|
||||
CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph top global");
|
||||
/* Locate existing matching glyph */
|
||||
hash = HashGlyph (glyph);
|
||||
gr = FindGlyphRef (&globalGlyphs[glyphSet->fdepth], hash, TRUE, glyph);
|
||||
if (gr->glyph && gr->glyph != DeletedGlyph)
|
||||
{
|
||||
free (glyph);
|
||||
glyph = gr->glyph;
|
||||
}
|
||||
else
|
||||
{
|
||||
gr->glyph = glyph;
|
||||
gr->signature = hash;
|
||||
globalGlyphs[glyphSet->fdepth].tableEntries++;
|
||||
}
|
||||
|
||||
/* Insert/replace glyphset value */
|
||||
gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0);
|
||||
++glyph->refcnt;
|
||||
if (gr->glyph && gr->glyph != DeletedGlyph)
|
||||
FreeGlyph (gr->glyph, glyphSet->fdepth);
|
||||
else
|
||||
glyphSet->hash.tableEntries++;
|
||||
gr->glyph = glyph;
|
||||
gr->signature = id;
|
||||
CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom");
|
||||
}
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
Bool
|
||||
DeleteGlyph (GlyphSetPtr glyphSet, Glyph id)
|
||||
{
|
||||
GlyphRefPtr gr;
|
||||
GlyphPtr glyph;
|
||||
|
||||
gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0);
|
||||
glyph = gr->glyph;
|
||||
if (glyph && glyph != DeletedGlyph)
|
||||
{
|
||||
gr->glyph = DeletedGlyph;
|
||||
glyphSet->hash.tableEntries--;
|
||||
FreeGlyph (glyph, glyphSet->fdepth);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
GlyphPtr
|
||||
FindGlyph (GlyphSetPtr glyphSet, Glyph id)
|
||||
{
|
||||
GlyphPtr glyph;
|
||||
|
||||
glyph = FindGlyphRef (&glyphSet->hash, id, FALSE, 0)->glyph;
|
||||
if (glyph == DeletedGlyph)
|
||||
glyph = 0;
|
||||
return glyph;
|
||||
}
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
GlyphPtr
|
||||
AllocateGlyph (xGlyphInfo *gi, int fdepth)
|
||||
{
|
||||
int size;
|
||||
GlyphPtr glyph;
|
||||
size_t padded_width;
|
||||
|
||||
padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]);
|
||||
if (gi->height && padded_width > (UINT32_MAX - sizeof(GlyphRec))/gi->height)
|
||||
return 0;
|
||||
size = gi->height * padded_width;
|
||||
glyph = (GlyphPtr) malloc (size + sizeof (GlyphRec));
|
||||
if (!glyph)
|
||||
return 0;
|
||||
glyph->refcnt = 0;
|
||||
glyph->size = size + sizeof (xGlyphInfo);
|
||||
glyph->info = *gi;
|
||||
return glyph;
|
||||
}
|
||||
|
||||
Bool
|
||||
AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet)
|
||||
{
|
||||
hash->table = (GlyphRefPtr) malloc (hashSet->size * sizeof (GlyphRefRec));
|
||||
if (!hash->table)
|
||||
return FALSE;
|
||||
memset (hash->table, 0, hashSet->size * sizeof (GlyphRefRec));
|
||||
hash->hashSet = hashSet;
|
||||
hash->tableEntries = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
Bool
|
||||
ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
|
||||
{
|
||||
CARD32 tableEntries;
|
||||
GlyphHashSetPtr hashSet;
|
||||
GlyphHashRec newHash;
|
||||
GlyphRefPtr gr;
|
||||
GlyphPtr glyph;
|
||||
int i;
|
||||
int oldSize;
|
||||
CARD32 s;
|
||||
|
||||
tableEntries = hash->tableEntries + change;
|
||||
hashSet = FindGlyphHashSet (tableEntries);
|
||||
if (hashSet == hash->hashSet)
|
||||
return TRUE;
|
||||
if (global)
|
||||
CheckDuplicates (hash, "ResizeGlyphHash top");
|
||||
if (!AllocateGlyphHash (&newHash, hashSet))
|
||||
return FALSE;
|
||||
if (hash->table)
|
||||
{
|
||||
oldSize = hash->hashSet->size;
|
||||
for (i = 0; i < oldSize; i++)
|
||||
{
|
||||
glyph = hash->table[i].glyph;
|
||||
if (glyph && glyph != DeletedGlyph)
|
||||
{
|
||||
s = hash->table[i].signature;
|
||||
gr = FindGlyphRef (&newHash, s, global, glyph);
|
||||
gr->signature = s;
|
||||
gr->glyph = glyph;
|
||||
++newHash.tableEntries;
|
||||
}
|
||||
}
|
||||
free (hash->table);
|
||||
}
|
||||
*hash = newHash;
|
||||
if (global)
|
||||
CheckDuplicates (hash, "ResizeGlyphHash bottom");
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
Bool
|
||||
ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change)
|
||||
{
|
||||
return (ResizeGlyphHash (&glyphSet->hash, change, FALSE) &&
|
||||
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], change, TRUE));
|
||||
}
|
||||
|
||||
GlyphSetPtr
|
||||
AllocateGlyphSet (int fdepth, PictFormatPtr format)
|
||||
{
|
||||
GlyphSetPtr glyphSet;
|
||||
int size;
|
||||
|
||||
if (!globalGlyphs[fdepth].hashSet)
|
||||
{
|
||||
if (!AllocateGlyphHash (&globalGlyphs[fdepth], &glyphHashSets[0]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
size = (sizeof (GlyphSetRec) +
|
||||
(sizeof (void *) * _GlyphSetPrivateAllocateIndex));
|
||||
glyphSet = malloc (size);
|
||||
if (!glyphSet)
|
||||
return FALSE;
|
||||
bzero((char *)glyphSet, size);
|
||||
glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1;
|
||||
if (_GlyphSetPrivateAllocateIndex)
|
||||
glyphSet->devPrivates = (void *)(&glyphSet[1]);
|
||||
|
||||
if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
|
||||
{
|
||||
free (glyphSet);
|
||||
return FALSE;
|
||||
}
|
||||
glyphSet->refcnt = 1;
|
||||
glyphSet->fdepth = fdepth;
|
||||
glyphSet->format = format;
|
||||
return glyphSet;
|
||||
}
|
||||
|
||||
int
|
||||
FreeGlyphSet (void *value,
|
||||
XID gid)
|
||||
{
|
||||
GlyphSetPtr glyphSet = (GlyphSetPtr) value;
|
||||
|
||||
if (--glyphSet->refcnt == 0)
|
||||
{
|
||||
CARD32 i, tableSize = glyphSet->hash.hashSet->size;
|
||||
GlyphRefPtr table = glyphSet->hash.table;
|
||||
GlyphPtr glyph;
|
||||
|
||||
for (i = 0; i < tableSize; i++)
|
||||
{
|
||||
glyph = table[i].glyph;
|
||||
if (glyph && glyph != DeletedGlyph)
|
||||
FreeGlyph (glyph, glyphSet->fdepth);
|
||||
}
|
||||
if (!globalGlyphs[glyphSet->fdepth].tableEntries)
|
||||
{
|
||||
free (globalGlyphs[glyphSet->fdepth].table);
|
||||
globalGlyphs[glyphSet->fdepth].table = 0;
|
||||
globalGlyphs[glyphSet->fdepth].hashSet = 0;
|
||||
}
|
||||
else
|
||||
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
|
||||
free (table);
|
||||
|
||||
if (glyphSet->devPrivates &&
|
||||
glyphSet->devPrivates != (void *)(&glyphSet[1]))
|
||||
free(glyphSet->devPrivates);
|
||||
|
||||
free (glyphSet);
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
GlyphExtents(int nlist, GlyphListPtr list, GlyphPtr * glyphs, BoxPtr extents)
|
||||
{
|
||||
int x1, x2, y1, y2;
|
||||
int n;
|
||||
GlyphPtr glyph;
|
||||
int x, y;
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
extents->x1 = MAXSHORT;
|
||||
extents->x2 = MINSHORT;
|
||||
extents->y1 = MAXSHORT;
|
||||
extents->y2 = MINSHORT;
|
||||
while (nlist--) {
|
||||
x += list->xOff;
|
||||
y += list->yOff;
|
||||
n = list->len;
|
||||
list++;
|
||||
while (n--) {
|
||||
glyph = *glyphs++;
|
||||
x1 = x - glyph->info.x;
|
||||
if (x1 < MINSHORT)
|
||||
x1 = MINSHORT;
|
||||
y1 = y - glyph->info.y;
|
||||
if (y1 < MINSHORT)
|
||||
y1 = MINSHORT;
|
||||
x2 = x1 + glyph->info.width;
|
||||
if (x2 > MAXSHORT)
|
||||
x2 = MAXSHORT;
|
||||
y2 = y1 + glyph->info.height;
|
||||
if (y2 > MAXSHORT)
|
||||
y2 = MAXSHORT;
|
||||
if (x1 < extents->x1)
|
||||
extents->x1 = x1;
|
||||
if (x2 > extents->x2)
|
||||
extents->x2 = x2;
|
||||
if (y1 < extents->y1)
|
||||
extents->y1 = y1;
|
||||
if (y2 > extents->y2)
|
||||
extents->y2 = y2;
|
||||
x += glyph->info.xOff;
|
||||
y += glyph->info.yOff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
|
||||
|
||||
void
|
||||
CompositeGlyphs(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc, int nlist, GlyphListPtr lists, GlyphPtr * glyphs)
|
||||
{
|
||||
PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
|
||||
|
||||
ValidatePicture(pSrc);
|
||||
ValidatePicture(pDst);
|
||||
(*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists,
|
||||
glyphs);
|
||||
}
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
void
|
||||
miGlyphs(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs)
|
||||
{
|
||||
PixmapPtr pPixmap = 0;
|
||||
PicturePtr pPicture;
|
||||
PixmapPtr pMaskPixmap = 0;
|
||||
PicturePtr pMask;
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
int width = 0, height = 0;
|
||||
int x, y;
|
||||
int xDst = list->xOff, yDst = list->yOff;
|
||||
int n;
|
||||
GlyphPtr glyph;
|
||||
int error;
|
||||
BoxRec extents;
|
||||
CARD32 component_alpha;
|
||||
|
||||
if (maskFormat) {
|
||||
GCPtr pGC;
|
||||
xRectangle rect;
|
||||
|
||||
GlyphExtents(nlist, list, glyphs, &extents);
|
||||
|
||||
if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
|
||||
return;
|
||||
width = extents.x2 - extents.x1;
|
||||
height = extents.y2 - extents.y1;
|
||||
pMaskPixmap =
|
||||
(*pScreen->CreatePixmap) (pScreen, width, height,
|
||||
maskFormat->depth,
|
||||
CREATE_PIXMAP_USAGE_SCRATCH);
|
||||
if (!pMaskPixmap)
|
||||
return;
|
||||
component_alpha = NeedsComponent(maskFormat->format);
|
||||
pMask = CreatePicture(0, &pMaskPixmap->drawable,
|
||||
maskFormat, CPComponentAlpha, &component_alpha,
|
||||
serverClient, &error);
|
||||
if (!pMask) {
|
||||
(*pScreen->DestroyPixmap) (pMaskPixmap);
|
||||
return;
|
||||
}
|
||||
pGC = GetScratchGC(pMaskPixmap->drawable.depth, pScreen);
|
||||
ValidateGC(&pMaskPixmap->drawable, pGC);
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = width;
|
||||
rect.height = height;
|
||||
(*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect);
|
||||
FreeScratchGC(pGC);
|
||||
x = -extents.x1;
|
||||
y = -extents.y1;
|
||||
}
|
||||
else {
|
||||
pMask = pDst;
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
pPicture = 0;
|
||||
while (nlist--) {
|
||||
x += list->xOff;
|
||||
y += list->yOff;
|
||||
n = list->len;
|
||||
while (n--) {
|
||||
glyph = *glyphs++;
|
||||
if (!pPicture) {
|
||||
pPixmap =
|
||||
GetScratchPixmapHeader(pScreen, glyph->info.width,
|
||||
glyph->info.height,
|
||||
list->format->depth,
|
||||
list->format->depth, 0,
|
||||
(void *) (glyph + 1));
|
||||
if (!pPixmap)
|
||||
return;
|
||||
component_alpha = NeedsComponent(list->format->format);
|
||||
pPicture = CreatePicture(0, &pPixmap->drawable, list->format,
|
||||
CPComponentAlpha, &component_alpha,
|
||||
serverClient, &error);
|
||||
if (!pPicture) {
|
||||
FreeScratchPixmapHeader(pPixmap);
|
||||
return;
|
||||
}
|
||||
}
|
||||
(*pScreen->ModifyPixmapHeader) (pPixmap,
|
||||
glyph->info.width,
|
||||
glyph->info.height, 0, 0, -1,
|
||||
(void *) (glyph + 1));
|
||||
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
||||
if (maskFormat) {
|
||||
CompositePicture(PictOpAdd,
|
||||
pPicture,
|
||||
None,
|
||||
pMask,
|
||||
0, 0,
|
||||
0, 0,
|
||||
x - glyph->info.x,
|
||||
y - glyph->info.y,
|
||||
glyph->info.width, glyph->info.height);
|
||||
}
|
||||
else {
|
||||
CompositePicture(op,
|
||||
pSrc,
|
||||
pPicture,
|
||||
pDst,
|
||||
xSrc + (x - glyph->info.x) - xDst,
|
||||
ySrc + (y - glyph->info.y) - yDst,
|
||||
0, 0,
|
||||
x - glyph->info.x,
|
||||
y - glyph->info.y,
|
||||
glyph->info.width, glyph->info.height);
|
||||
}
|
||||
x += glyph->info.xOff;
|
||||
y += glyph->info.yOff;
|
||||
}
|
||||
list++;
|
||||
if (pPicture) {
|
||||
FreeScratchPixmapHeader(pPixmap);
|
||||
FreePicture((void *) pPicture, 0);
|
||||
pPicture = 0;
|
||||
pPixmap = 0;
|
||||
}
|
||||
}
|
||||
if (maskFormat) {
|
||||
x = extents.x1;
|
||||
y = extents.y1;
|
||||
CompositePicture(op,
|
||||
pSrc,
|
||||
pMask,
|
||||
pDst,
|
||||
xSrc + x - xDst,
|
||||
ySrc + y - yDst, 0, 0, x, y, width, height);
|
||||
FreePicture((void *) pMask, (XID) 0);
|
||||
(*pScreen->DestroyPixmap) (pMaskPixmap);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
154
nx-X11/programs/Xserver/render/glyphstr.h
Normal file
154
nx-X11/programs/Xserver/render/glyphstr.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright © 2000 SuSE, Inc.
|
||||
*
|
||||
* 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 SuSE not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. SuSE makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
|
||||
* 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.
|
||||
*
|
||||
* Author: Keith Packard, SuSE, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _GLYPHSTR_H_
|
||||
#define _GLYPHSTR_H_
|
||||
|
||||
#include <nx-X11/extensions/renderproto.h>
|
||||
#include "picture.h"
|
||||
#include "screenint.h"
|
||||
|
||||
#define GlyphFormat1 0
|
||||
#define GlyphFormat4 1
|
||||
#define GlyphFormat8 2
|
||||
#define GlyphFormat16 3
|
||||
#define GlyphFormat32 4
|
||||
#define GlyphFormatNum 5
|
||||
|
||||
typedef struct _Glyph {
|
||||
CARD32 refcnt;
|
||||
CARD32 size; /* info + bitmap */
|
||||
xGlyphInfo info;
|
||||
/* bits follow */
|
||||
} GlyphRec, *GlyphPtr;
|
||||
|
||||
#ifdef NXAGENT_SERVER
|
||||
#include "../hw/nxagent/NXglyphstr_GlyphRef.h"
|
||||
#else
|
||||
typedef struct _GlyphRef {
|
||||
CARD32 signature;
|
||||
GlyphPtr glyph;
|
||||
} GlyphRefRec, *GlyphRefPtr;
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
#define DeletedGlyph ((GlyphPtr) 1)
|
||||
|
||||
typedef struct _GlyphHashSet {
|
||||
CARD32 entries;
|
||||
CARD32 size;
|
||||
CARD32 rehash;
|
||||
} GlyphHashSetRec, *GlyphHashSetPtr;
|
||||
|
||||
typedef struct _GlyphHash {
|
||||
GlyphRefPtr table;
|
||||
GlyphHashSetPtr hashSet;
|
||||
CARD32 tableEntries;
|
||||
} GlyphHashRec, *GlyphHashPtr;
|
||||
|
||||
#ifdef NXAGENT_SERVER
|
||||
#include "../hw/nxagent/NXglyphstr_GlyphSet.h"
|
||||
#else
|
||||
typedef struct _GlyphSet {
|
||||
CARD32 refcnt;
|
||||
PictFormatPtr format;
|
||||
int fdepth;
|
||||
GlyphHashRec hash;
|
||||
int maxPrivate;
|
||||
void **devPrivates;
|
||||
} GlyphSetRec, *GlyphSetPtr;
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
#define GlyphSetGetPrivate(pGlyphSet,n) \
|
||||
((n) > (pGlyphSet)->maxPrivate ? \
|
||||
(void *) 0 : \
|
||||
(pGlyphSet)->devPrivates[n])
|
||||
|
||||
#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \
|
||||
((n) > (pGlyphSet)->maxPrivate ? \
|
||||
_GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \
|
||||
((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE))
|
||||
|
||||
typedef struct _GlyphList {
|
||||
INT16 xOff;
|
||||
INT16 yOff;
|
||||
CARD8 len;
|
||||
PictFormatPtr format;
|
||||
} GlyphListRec, *GlyphListPtr;
|
||||
|
||||
extern GlyphHashRec globalGlyphs[GlyphFormatNum];
|
||||
|
||||
GlyphHashSetPtr
|
||||
FindGlyphHashSet (CARD32 filled);
|
||||
|
||||
int
|
||||
AllocateGlyphSetPrivateIndex (void);
|
||||
|
||||
void
|
||||
ResetGlyphSetPrivateIndex (void);
|
||||
|
||||
Bool
|
||||
_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr);
|
||||
|
||||
Bool
|
||||
GlyphInit (ScreenPtr pScreen);
|
||||
|
||||
GlyphRefPtr
|
||||
FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare);
|
||||
|
||||
CARD32
|
||||
HashGlyph (GlyphPtr glyph);
|
||||
|
||||
void
|
||||
FreeGlyph (GlyphPtr glyph, int format);
|
||||
|
||||
void
|
||||
AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id);
|
||||
|
||||
Bool
|
||||
DeleteGlyph (GlyphSetPtr glyphSet, Glyph id);
|
||||
|
||||
GlyphPtr
|
||||
FindGlyph (GlyphSetPtr glyphSet, Glyph id);
|
||||
|
||||
GlyphPtr
|
||||
AllocateGlyph (xGlyphInfo *gi, int format);
|
||||
|
||||
Bool
|
||||
AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet);
|
||||
|
||||
Bool
|
||||
ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global);
|
||||
|
||||
Bool
|
||||
ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change);
|
||||
|
||||
GlyphSetPtr
|
||||
AllocateGlyphSet (int fdepth, PictFormatPtr format);
|
||||
|
||||
int
|
||||
FreeGlyphSet (void *value,
|
||||
XID gid);
|
||||
|
||||
|
||||
|
||||
#endif /* _GLYPHSTR_H_ */
|
||||
86
nx-X11/programs/Xserver/render/matrix.c
Normal file
86
nx-X11/programs/Xserver/render/matrix.c
Normal file
@@ -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);
|
||||
}
|
||||
355
nx-X11/programs/Xserver/render/miindex.c
Normal file
355
nx-X11/programs/Xserver/render/miindex.c
Normal file
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
|
||||
*
|
||||
* 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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
|
||||
|
||||
#ifndef _MIINDEX_H_
|
||||
#define _MIINDEX_H_
|
||||
|
||||
#include "scrnintstr.h"
|
||||
#include "gcstruct.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "windowstr.h"
|
||||
#include "mi.h"
|
||||
#include "picturestr.h"
|
||||
#include "mipict.h"
|
||||
#include "colormapst.h"
|
||||
|
||||
#define NUM_CUBE_LEVELS 4
|
||||
#define NUM_GRAY_LEVELS 13
|
||||
|
||||
static Bool
|
||||
miBuildRenderColormap (ColormapPtr pColormap, Pixel *pixels, int *nump)
|
||||
{
|
||||
int r, g, b;
|
||||
unsigned short red, green, blue;
|
||||
Pixel pixel;
|
||||
Bool used[MI_MAX_INDEXED];
|
||||
int needed;
|
||||
int policy;
|
||||
int cube, gray;
|
||||
int i, n;
|
||||
|
||||
if (pColormap->mid != pColormap->pScreen->defColormap)
|
||||
{
|
||||
policy = PictureCmapPolicyAll;
|
||||
}
|
||||
else
|
||||
{
|
||||
int avail = pColormap->pVisual->ColormapEntries;
|
||||
policy = PictureCmapPolicy;
|
||||
if (policy == PictureCmapPolicyDefault)
|
||||
{
|
||||
if (avail >= 256 && (pColormap->pVisual->class|DynamicClass) == PseudoColor)
|
||||
policy = PictureCmapPolicyColor;
|
||||
else if (avail >= 64)
|
||||
policy = PictureCmapPolicyGray;
|
||||
else
|
||||
policy = PictureCmapPolicyMono;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Make sure enough cells are free for the chosen policy
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
switch (policy) {
|
||||
case PictureCmapPolicyAll:
|
||||
needed = 0;
|
||||
break;
|
||||
case PictureCmapPolicyColor:
|
||||
needed = 71;
|
||||
break;
|
||||
case PictureCmapPolicyGray:
|
||||
needed = 11;
|
||||
break;
|
||||
case PictureCmapPolicyMono:
|
||||
default:
|
||||
needed = 0;
|
||||
break;
|
||||
}
|
||||
if (needed <= pColormap->freeRed)
|
||||
break;
|
||||
policy--;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute size of cube and gray ramps
|
||||
*/
|
||||
cube = gray = 0;
|
||||
switch (policy) {
|
||||
case PictureCmapPolicyAll:
|
||||
/*
|
||||
* Allocate as big a cube as possible
|
||||
*/
|
||||
if ((pColormap->pVisual->class|DynamicClass) == PseudoColor)
|
||||
{
|
||||
for (cube = 1; cube * cube * cube < pColormap->pVisual->ColormapEntries; cube++)
|
||||
;
|
||||
cube--;
|
||||
if (cube == 1)
|
||||
cube = 0;
|
||||
}
|
||||
else
|
||||
cube = 0;
|
||||
/*
|
||||
* Figure out how many gray levels to use so that they
|
||||
* line up neatly with the cube
|
||||
*/
|
||||
if (cube)
|
||||
{
|
||||
needed = pColormap->pVisual->ColormapEntries - (cube*cube*cube);
|
||||
/* levels to fill in with */
|
||||
gray = needed / (cube - 1);
|
||||
/* total levels */
|
||||
gray = (gray + 1) * (cube - 1) + 1;
|
||||
}
|
||||
else
|
||||
gray = pColormap->pVisual->ColormapEntries;
|
||||
break;
|
||||
|
||||
case PictureCmapPolicyColor:
|
||||
cube = NUM_CUBE_LEVELS;
|
||||
/* fall through ... */
|
||||
case PictureCmapPolicyGray:
|
||||
gray = NUM_GRAY_LEVELS;
|
||||
break;
|
||||
case PictureCmapPolicyMono:
|
||||
default:
|
||||
gray = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
memset (used, '\0', pColormap->pVisual->ColormapEntries * sizeof (Bool));
|
||||
for (r = 0; r < cube; r++)
|
||||
for (g = 0; g < cube; g++)
|
||||
for (b = 0; b < cube; b++)
|
||||
{
|
||||
red = (r * 65535 + (cube-1)/2) / (cube - 1);
|
||||
green = (g * 65535 + (cube-1)/2) / (cube - 1);
|
||||
blue = (b * 65535 + (cube-1)/2) / (cube - 1);
|
||||
if (AllocColor (pColormap, &red, &green,
|
||||
&blue, &pixel, 0) != Success)
|
||||
return FALSE;
|
||||
used[pixel] = TRUE;
|
||||
}
|
||||
for (g = 0; g < gray; g++)
|
||||
{
|
||||
red = green = blue = (g * 65535 + (gray-1)/2) / (gray - 1);
|
||||
if (AllocColor (pColormap, &red, &green, &blue, &pixel, 0) != Success)
|
||||
return FALSE;
|
||||
used[pixel] = TRUE;
|
||||
}
|
||||
n = 0;
|
||||
for (i = 0; i < pColormap->pVisual->ColormapEntries; i++)
|
||||
if (used[i])
|
||||
pixels[n++] = i;
|
||||
|
||||
*nump = n;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* 0 <= red, green, blue < 32 */
|
||||
static Pixel
|
||||
FindBestColor (miIndexedPtr pIndexed, Pixel *pixels, int num,
|
||||
int red, int green, int blue)
|
||||
{
|
||||
Pixel best = pixels[0];
|
||||
int bestDist = 1 << 30;
|
||||
int dist;
|
||||
int dr, dg, db;
|
||||
while (num--)
|
||||
{
|
||||
Pixel pixel = *pixels++;
|
||||
CARD32 v = pIndexed->rgba[pixel];
|
||||
|
||||
dr = ((v >> 19) & 0x1f);
|
||||
dg = ((v >> 11) & 0x1f);
|
||||
db = ((v >> 3) & 0x1f);
|
||||
dr = dr - red;
|
||||
dg = dg - green;
|
||||
db = db - blue;
|
||||
dist = dr * dr + dg * dg + db * db;
|
||||
if (dist < bestDist)
|
||||
{
|
||||
bestDist = dist;
|
||||
best = pixel;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/* 0 <= gray < 32768 */
|
||||
static Pixel
|
||||
FindBestGray (miIndexedPtr pIndexed, Pixel *pixels, int num, int gray)
|
||||
{
|
||||
Pixel best = pixels[0];
|
||||
int bestDist = 1 << 30;
|
||||
int dist;
|
||||
int dr;
|
||||
int r;
|
||||
|
||||
while (num--)
|
||||
{
|
||||
Pixel pixel = *pixels++;
|
||||
CARD32 v = pIndexed->rgba[pixel];
|
||||
|
||||
r = v & 0xff;
|
||||
r = r | (r << 8);
|
||||
dr = gray - (r >> 1);
|
||||
dist = dr * dr;
|
||||
if (dist < bestDist)
|
||||
{
|
||||
bestDist = dist;
|
||||
best = pixel;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
Bool
|
||||
miInitIndexed (ScreenPtr pScreen,
|
||||
PictFormatPtr pFormat)
|
||||
{
|
||||
ColormapPtr pColormap = pFormat->index.pColormap;
|
||||
VisualPtr pVisual = pColormap->pVisual;
|
||||
miIndexedPtr pIndexed;
|
||||
Pixel pixels[MI_MAX_INDEXED];
|
||||
xrgb rgb[MI_MAX_INDEXED];
|
||||
int num;
|
||||
int i;
|
||||
Pixel p, r, g, b;
|
||||
|
||||
if (pVisual->ColormapEntries > MI_MAX_INDEXED)
|
||||
return FALSE;
|
||||
|
||||
if (pVisual->class & DynamicClass)
|
||||
{
|
||||
if (!miBuildRenderColormap (pColormap, pixels, &num))
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = pVisual->ColormapEntries;
|
||||
for (p = 0; p < num; p++)
|
||||
pixels[p] = p;
|
||||
}
|
||||
|
||||
pIndexed = malloc (sizeof (miIndexedRec));
|
||||
if (!pIndexed)
|
||||
return FALSE;
|
||||
|
||||
pFormat->index.nvalues = num;
|
||||
pFormat->index.pValues = malloc (num * sizeof (xIndexValue));
|
||||
if (!pFormat->index.pValues)
|
||||
{
|
||||
free (pIndexed);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Build mapping from pixel value to ARGB
|
||||
*/
|
||||
QueryColors (pColormap, num, pixels, rgb);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
p = pixels[i];
|
||||
pFormat->index.pValues[i].pixel = p;
|
||||
pFormat->index.pValues[i].red = rgb[i].red;
|
||||
pFormat->index.pValues[i].green = rgb[i].green;
|
||||
pFormat->index.pValues[i].blue = rgb[i].blue;
|
||||
pFormat->index.pValues[i].alpha = 0xffff;
|
||||
pIndexed->rgba[p] = (0xff000000 |
|
||||
((rgb[i].red & 0xff00) << 8) |
|
||||
((rgb[i].green & 0xff00) ) |
|
||||
((rgb[i].blue & 0xff00) >> 8));
|
||||
}
|
||||
|
||||
/*
|
||||
* Build mapping from RGB to pixel value. This could probably be
|
||||
* done a bit quicker...
|
||||
*/
|
||||
switch (pVisual->class | DynamicClass) {
|
||||
case GrayScale:
|
||||
pIndexed->color = FALSE;
|
||||
for (r = 0; r < 32768; r++)
|
||||
pIndexed->ent[r] = FindBestGray (pIndexed, pixels, num, r);
|
||||
break;
|
||||
case PseudoColor:
|
||||
pIndexed->color = TRUE;
|
||||
p = 0;
|
||||
for (r = 0; r < 32; r++)
|
||||
for (g = 0; g < 32; g++)
|
||||
for (b = 0; b < 32; b++)
|
||||
{
|
||||
pIndexed->ent[p] = FindBestColor (pIndexed, pixels, num,
|
||||
r, g, b);
|
||||
p++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
pFormat->index.devPrivate = pIndexed;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
miCloseIndexed (ScreenPtr pScreen,
|
||||
PictFormatPtr pFormat)
|
||||
{
|
||||
if (pFormat->index.devPrivate)
|
||||
{
|
||||
free (pFormat->index.devPrivate);
|
||||
pFormat->index.devPrivate = 0;
|
||||
}
|
||||
if (pFormat->index.pValues)
|
||||
{
|
||||
free (pFormat->index.pValues);
|
||||
pFormat->index.pValues = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
miUpdateIndexed (ScreenPtr pScreen,
|
||||
PictFormatPtr pFormat,
|
||||
int ndef,
|
||||
xColorItem *pdef)
|
||||
{
|
||||
miIndexedPtr pIndexed = pFormat->index.devPrivate;
|
||||
|
||||
if (pIndexed)
|
||||
{
|
||||
while (ndef--)
|
||||
{
|
||||
pIndexed->rgba[pdef->pixel] = (0xff000000 |
|
||||
((pdef->red & 0xff00) << 8) |
|
||||
((pdef->green & 0xff00) ) |
|
||||
((pdef->blue & 0xff00) >> 8));
|
||||
pdef++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _MIINDEX_H_ */
|
||||
644
nx-X11/programs/Xserver/render/mipict.c
Normal file
644
nx-X11/programs/Xserver/render/mipict.c
Normal file
@@ -0,0 +1,644 @@
|
||||
/*
|
||||
* Copyright © 1999 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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 "scrnintstr.h"
|
||||
#include "gcstruct.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "windowstr.h"
|
||||
#include "mi.h"
|
||||
#include "picturestr.h"
|
||||
#include "mipict.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __inline
|
||||
#endif
|
||||
|
||||
int
|
||||
miCreatePicture (PicturePtr pPicture)
|
||||
{
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
miDestroyPicture (PicturePtr pPicture)
|
||||
{
|
||||
if (pPicture->freeCompClip)
|
||||
RegionDestroy(pPicture->pCompositeClip);
|
||||
}
|
||||
|
||||
void
|
||||
miDestroyPictureClip (PicturePtr pPicture)
|
||||
{
|
||||
switch (pPicture->clientClipType) {
|
||||
case CT_NONE:
|
||||
return;
|
||||
case CT_PIXMAP:
|
||||
(*pPicture->pDrawable->pScreen->DestroyPixmap) ((PixmapPtr) (pPicture->clientClip));
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* we know we'll never have a list of rectangles, since ChangeClip
|
||||
* immediately turns them into a region
|
||||
*/
|
||||
RegionDestroy(pPicture->clientClip);
|
||||
break;
|
||||
}
|
||||
pPicture->clientClip = NULL;
|
||||
pPicture->clientClipType = CT_NONE;
|
||||
}
|
||||
|
||||
int
|
||||
miChangePictureClip (PicturePtr pPicture,
|
||||
int type,
|
||||
void * value,
|
||||
int n)
|
||||
{
|
||||
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
void * clientClip;
|
||||
int clientClipType;
|
||||
|
||||
switch (type) {
|
||||
case CT_PIXMAP:
|
||||
/* convert the pixmap to a region */
|
||||
clientClip = (void *) BitmapToRegion(pScreen, (PixmapPtr) value);
|
||||
if (!clientClip)
|
||||
return BadAlloc;
|
||||
clientClipType = CT_REGION;
|
||||
(*pScreen->DestroyPixmap) ((PixmapPtr) value);
|
||||
break;
|
||||
case CT_REGION:
|
||||
clientClip = value;
|
||||
clientClipType = CT_REGION;
|
||||
break;
|
||||
case CT_NONE:
|
||||
clientClip = 0;
|
||||
clientClipType = CT_NONE;
|
||||
break;
|
||||
default:
|
||||
clientClip = (void *) RegionFromRects(n,
|
||||
(xRectangle *) value,
|
||||
type);
|
||||
if (!clientClip)
|
||||
return BadAlloc;
|
||||
clientClipType = CT_REGION;
|
||||
free(value);
|
||||
break;
|
||||
}
|
||||
(*ps->DestroyPictureClip) (pPicture);
|
||||
pPicture->clientClip = clientClip;
|
||||
pPicture->clientClipType = clientClipType;
|
||||
pPicture->stateChanges |= CPClipMask;
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
miChangePicture (PicturePtr pPicture,
|
||||
Mask mask)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
miValidatePicture (PicturePtr pPicture,
|
||||
Mask mask)
|
||||
{
|
||||
DrawablePtr pDrawable = pPicture->pDrawable;
|
||||
|
||||
if ((mask & (CPClipXOrigin|CPClipYOrigin|CPClipMask|CPSubwindowMode)) ||
|
||||
(pDrawable->serialNumber != (pPicture->serialNumber & DRAWABLE_SERIAL_BITS)))
|
||||
{
|
||||
if (pDrawable->type == DRAWABLE_WINDOW)
|
||||
{
|
||||
WindowPtr pWin = (WindowPtr) pDrawable;
|
||||
RegionPtr pregWin;
|
||||
Bool freeTmpClip, freeCompClip;
|
||||
|
||||
if (pPicture->subWindowMode == IncludeInferiors)
|
||||
{
|
||||
pregWin = NotClippedByChildren(pWin);
|
||||
freeTmpClip = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pregWin = &pWin->clipList;
|
||||
freeTmpClip = FALSE;
|
||||
}
|
||||
freeCompClip = pPicture->freeCompClip;
|
||||
|
||||
/*
|
||||
* if there is no client clip, we can get by with just keeping the
|
||||
* pointer we got, and remembering whether or not should destroy
|
||||
* (or maybe re-use) it later. this way, we avoid unnecessary
|
||||
* copying of regions. (this wins especially if many clients clip
|
||||
* by children and have no client clip.)
|
||||
*/
|
||||
if (pPicture->clientClipType == CT_NONE)
|
||||
{
|
||||
if (freeCompClip)
|
||||
RegionDestroy(pPicture->pCompositeClip);
|
||||
pPicture->pCompositeClip = pregWin;
|
||||
pPicture->freeCompClip = freeTmpClip;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* we need one 'real' region to put into the composite clip. if
|
||||
* pregWin the current composite clip are real, we can get rid of
|
||||
* one. if pregWin is real and the current composite clip isn't,
|
||||
* use pregWin for the composite clip. if the current composite
|
||||
* clip is real and pregWin isn't, use the current composite
|
||||
* clip. if neither is real, create a new region.
|
||||
*/
|
||||
|
||||
RegionTranslate(pPicture->clientClip,
|
||||
pDrawable->x + pPicture->clipOrigin.x,
|
||||
pDrawable->y + pPicture->clipOrigin.y);
|
||||
|
||||
if (freeCompClip)
|
||||
{
|
||||
RegionIntersect(pPicture->pCompositeClip,
|
||||
pregWin, pPicture->clientClip);
|
||||
if (freeTmpClip)
|
||||
RegionDestroy(pregWin);
|
||||
}
|
||||
else if (freeTmpClip)
|
||||
{
|
||||
RegionIntersect(pregWin, pregWin, pPicture->clientClip);
|
||||
pPicture->pCompositeClip = pregWin;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPicture->pCompositeClip = RegionCreate(NullBox, 0);
|
||||
RegionIntersect(pPicture->pCompositeClip,
|
||||
pregWin, pPicture->clientClip);
|
||||
}
|
||||
pPicture->freeCompClip = TRUE;
|
||||
RegionTranslate(pPicture->clientClip,
|
||||
-(pDrawable->x + pPicture->clipOrigin.x),
|
||||
-(pDrawable->y + pPicture->clipOrigin.y));
|
||||
}
|
||||
} /* end of composite clip for a window */
|
||||
else
|
||||
{
|
||||
BoxRec pixbounds;
|
||||
|
||||
/* XXX should we translate by drawable.x/y here ? */
|
||||
/* If you want pixmaps in offscreen memory, yes */
|
||||
pixbounds.x1 = pDrawable->x;
|
||||
pixbounds.y1 = pDrawable->y;
|
||||
pixbounds.x2 = pDrawable->x + pDrawable->width;
|
||||
pixbounds.y2 = pDrawable->y + pDrawable->height;
|
||||
|
||||
if (pPicture->freeCompClip)
|
||||
{
|
||||
RegionReset(pPicture->pCompositeClip, &pixbounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPicture->freeCompClip = TRUE;
|
||||
pPicture->pCompositeClip = RegionCreate(&pixbounds, 1);
|
||||
}
|
||||
|
||||
if (pPicture->clientClipType == CT_REGION)
|
||||
{
|
||||
if(pDrawable->x || pDrawable->y) {
|
||||
RegionTranslate(pPicture->clientClip,
|
||||
pDrawable->x + pPicture->clipOrigin.x,
|
||||
pDrawable->y + pPicture->clipOrigin.y);
|
||||
RegionIntersect(pPicture->pCompositeClip,
|
||||
pPicture->pCompositeClip, pPicture->clientClip);
|
||||
RegionTranslate(pPicture->clientClip,
|
||||
-(pDrawable->x + pPicture->clipOrigin.x),
|
||||
-(pDrawable->y + pPicture->clipOrigin.y));
|
||||
} else {
|
||||
RegionTranslate(pPicture->pCompositeClip,
|
||||
-pPicture->clipOrigin.x, -pPicture->clipOrigin.y);
|
||||
RegionIntersect(pPicture->pCompositeClip,
|
||||
pPicture->pCompositeClip, pPicture->clientClip);
|
||||
RegionTranslate(pPicture->pCompositeClip,
|
||||
pPicture->clipOrigin.x, pPicture->clipOrigin.y);
|
||||
}
|
||||
}
|
||||
} /* end of composite clip for pixmap */
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
miChangePictureTransform (PicturePtr pPicture,
|
||||
PictTransform *transform)
|
||||
{
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
miChangePictureFilter (PicturePtr pPicture,
|
||||
int filter,
|
||||
xFixed *params,
|
||||
int nparams)
|
||||
{
|
||||
return Success;
|
||||
}
|
||||
|
||||
#define BOUND(v) (INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
|
||||
|
||||
static __inline Bool
|
||||
miClipPictureReg (RegionPtr pRegion,
|
||||
RegionPtr pClip,
|
||||
int dx,
|
||||
int dy)
|
||||
{
|
||||
if (RegionNumRects(pRegion) == 1 &&
|
||||
RegionNumRects(pClip) == 1)
|
||||
{
|
||||
BoxPtr pRbox = RegionRects(pRegion);
|
||||
BoxPtr pCbox = RegionRects(pClip);
|
||||
int v;
|
||||
|
||||
if (pRbox->x1 < (v = pCbox->x1 + dx))
|
||||
pRbox->x1 = BOUND(v);
|
||||
if (pRbox->x2 > (v = pCbox->x2 + dx))
|
||||
pRbox->x2 = BOUND(v);
|
||||
if (pRbox->y1 < (v = pCbox->y1 + dy))
|
||||
pRbox->y1 = BOUND(v);
|
||||
if (pRbox->y2 > (v = pCbox->y2 + dy))
|
||||
pRbox->y2 = BOUND(v);
|
||||
if (pRbox->x1 >= pRbox->x2 ||
|
||||
pRbox->y1 >= pRbox->y2)
|
||||
{
|
||||
RegionEmpty(pRegion);
|
||||
}
|
||||
}
|
||||
else if (!RegionNotEmpty(pClip))
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
if (dx || dy)
|
||||
RegionTranslate(pRegion, -dx, -dy);
|
||||
if (!RegionIntersect(pRegion, pRegion, pClip))
|
||||
return FALSE;
|
||||
if (dx || dy)
|
||||
RegionTranslate(pRegion, dx, dy);
|
||||
}
|
||||
return RegionNotEmpty(pRegion);
|
||||
}
|
||||
|
||||
static __inline Bool
|
||||
miClipPictureSrc (RegionPtr pRegion,
|
||||
PicturePtr pPicture,
|
||||
int dx,
|
||||
int dy)
|
||||
{
|
||||
/* XXX what to do with clipping from transformed pictures? */
|
||||
if (pPicture->transform || !pPicture->pDrawable)
|
||||
return TRUE;
|
||||
if (pPicture->repeat)
|
||||
{
|
||||
if (pPicture->clientClipType != CT_NONE)
|
||||
{
|
||||
RegionTranslate(pRegion,
|
||||
dx - pPicture->clipOrigin.x,
|
||||
dy - pPicture->clipOrigin.y);
|
||||
if (!RegionIntersect(pRegion, pRegion,
|
||||
(RegionPtr) pPicture->clientClip))
|
||||
return FALSE;
|
||||
RegionTranslate(pRegion,
|
||||
- (dx - pPicture->clipOrigin.x),
|
||||
- (dy - pPicture->clipOrigin.y));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return miClipPictureReg (pRegion,
|
||||
pPicture->pCompositeClip,
|
||||
dx,
|
||||
dy);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
miCompositeSourceValidate (PicturePtr pPicture,
|
||||
INT16 x,
|
||||
INT16 y,
|
||||
CARD16 width,
|
||||
CARD16 height)
|
||||
{
|
||||
DrawablePtr pDrawable = pPicture->pDrawable;
|
||||
ScreenPtr pScreen;
|
||||
|
||||
if (!pDrawable)
|
||||
return;
|
||||
|
||||
pScreen = pDrawable->pScreen;
|
||||
|
||||
if (pScreen->SourceValidate)
|
||||
{
|
||||
x -= pPicture->pDrawable->x;
|
||||
y -= pPicture->pDrawable->y;
|
||||
if (pPicture->transform)
|
||||
{
|
||||
xPoint points[4];
|
||||
int i;
|
||||
int xmin, ymin, xmax, ymax;
|
||||
|
||||
#define VectorSet(i,_x,_y) { points[i].x = _x; points[i].y = _y; }
|
||||
VectorSet (0, x, y);
|
||||
VectorSet (1, x + width, y);
|
||||
VectorSet (2, x, y + height);
|
||||
VectorSet (3, x + width, y + height);
|
||||
xmin = ymin = 32767;
|
||||
xmax = ymax = -32737;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
PictVector t;
|
||||
t.vector[0] = IntToxFixed (points[i].x);
|
||||
t.vector[1] = IntToxFixed (points[i].y);
|
||||
t.vector[2] = xFixed1;
|
||||
if (PictureTransformPoint (pPicture->transform, &t))
|
||||
{
|
||||
int tx = xFixedToInt (t.vector[0]);
|
||||
int ty = xFixedToInt (t.vector[1]);
|
||||
if (tx < xmin) xmin = tx;
|
||||
if (tx > xmax) xmax = tx;
|
||||
if (ty < ymin) ymin = ty;
|
||||
if (ty > ymax) ymax = ty;
|
||||
}
|
||||
}
|
||||
x = xmin;
|
||||
y = ymin;
|
||||
width = xmax - xmin;
|
||||
height = ymax - ymin;
|
||||
}
|
||||
(*pScreen->SourceValidate) (pDrawable, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* returns FALSE if the final region is empty. Indistinguishable from
|
||||
* an allocation failure, but rendering ignores those anyways.
|
||||
*/
|
||||
|
||||
Bool
|
||||
miComputeCompositeRegion (RegionPtr pRegion,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height)
|
||||
{
|
||||
int v;
|
||||
|
||||
pRegion->extents.x1 = xDst;
|
||||
v = xDst + width;
|
||||
pRegion->extents.x2 = BOUND(v);
|
||||
pRegion->extents.y1 = yDst;
|
||||
v = yDst + height;
|
||||
pRegion->extents.y2 = BOUND(v);
|
||||
pRegion->data = 0;
|
||||
/* Check for empty operation */
|
||||
if (pRegion->extents.x1 >= pRegion->extents.x2 ||
|
||||
pRegion->extents.y1 >= pRegion->extents.y2)
|
||||
{
|
||||
RegionEmpty(pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
/* clip against dst */
|
||||
if (!miClipPictureReg (pRegion, pDst->pCompositeClip, 0, 0))
|
||||
{
|
||||
RegionUninit(pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
if (pDst->alphaMap)
|
||||
{
|
||||
if (!miClipPictureReg (pRegion, pDst->alphaMap->pCompositeClip,
|
||||
-pDst->alphaOrigin.x,
|
||||
-pDst->alphaOrigin.y))
|
||||
{
|
||||
RegionUninit(pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/* clip against src */
|
||||
if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc))
|
||||
{
|
||||
RegionUninit(pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
if (pSrc->alphaMap)
|
||||
{
|
||||
if (!miClipPictureSrc (pRegion, pSrc->alphaMap,
|
||||
xDst - (xSrc + pSrc->alphaOrigin.x),
|
||||
yDst - (ySrc + pSrc->alphaOrigin.y)))
|
||||
{
|
||||
RegionUninit(pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/* clip against mask */
|
||||
if (pMask)
|
||||
{
|
||||
if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask))
|
||||
{
|
||||
RegionUninit(pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
if (pMask->alphaMap)
|
||||
{
|
||||
if (!miClipPictureSrc (pRegion, pMask->alphaMap,
|
||||
xDst - (xMask + pMask->alphaOrigin.x),
|
||||
yDst - (yMask + pMask->alphaOrigin.y)))
|
||||
{
|
||||
RegionUninit(pRegion);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height);
|
||||
if (pMask)
|
||||
miCompositeSourceValidate (pMask, xMask, yMask, width, height);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
miRenderColorToPixel (PictFormatPtr format,
|
||||
xRenderColor *color,
|
||||
CARD32 *pixel)
|
||||
{
|
||||
CARD32 r, g, b, a;
|
||||
miIndexedPtr pIndexed;
|
||||
|
||||
switch (format->type) {
|
||||
case PictTypeDirect:
|
||||
r = color->red >> (16 - Ones (format->direct.redMask));
|
||||
g = color->green >> (16 - Ones (format->direct.greenMask));
|
||||
b = color->blue >> (16 - Ones (format->direct.blueMask));
|
||||
a = color->alpha >> (16 - Ones (format->direct.alphaMask));
|
||||
r = r << format->direct.red;
|
||||
g = g << format->direct.green;
|
||||
b = b << format->direct.blue;
|
||||
a = a << format->direct.alpha;
|
||||
*pixel = r|g|b|a;
|
||||
break;
|
||||
case PictTypeIndexed:
|
||||
pIndexed = (miIndexedPtr) (format->index.devPrivate);
|
||||
if (pIndexed->color)
|
||||
{
|
||||
r = color->red >> 11;
|
||||
g = color->green >> 11;
|
||||
b = color->blue >> 11;
|
||||
*pixel = miIndexToEnt15 (pIndexed, (r << 10) | (g << 5) | b);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = color->red >> 8;
|
||||
g = color->green >> 8;
|
||||
b = color->blue >> 8;
|
||||
*pixel = miIndexToEntY24 (pIndexed, (r << 16) | (g << 8) | b);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static CARD16
|
||||
miFillColor (CARD32 pixel, int bits)
|
||||
{
|
||||
while (bits < 16)
|
||||
{
|
||||
pixel |= pixel << bits;
|
||||
bits <<= 1;
|
||||
}
|
||||
return (CARD16) pixel;
|
||||
}
|
||||
|
||||
Bool
|
||||
miIsSolidAlpha (PicturePtr pSrc)
|
||||
{
|
||||
ScreenPtr pScreen;
|
||||
char line[1];
|
||||
|
||||
if (!pSrc->pDrawable)
|
||||
return FALSE;
|
||||
|
||||
pScreen = pSrc->pDrawable->pScreen;
|
||||
|
||||
/* Alpha-only */
|
||||
if (PICT_FORMAT_TYPE (pSrc->format) != PICT_TYPE_A)
|
||||
return FALSE;
|
||||
/* repeat */
|
||||
if (!pSrc->repeat)
|
||||
return FALSE;
|
||||
/* 1x1 */
|
||||
if (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1)
|
||||
return FALSE;
|
||||
line[0] = 1;
|
||||
(*pScreen->GetImage) (pSrc->pDrawable, 0, 0, 1, 1, ZPixmap, ~0L, line);
|
||||
switch (pSrc->pDrawable->bitsPerPixel) {
|
||||
case 1:
|
||||
return (CARD8) line[0] == 1 || (CARD8) line[0] == 0x80;
|
||||
case 4:
|
||||
return (CARD8) line[0] == 0xf || (CARD8) line[0] == 0xf0;
|
||||
case 8:
|
||||
return (CARD8) line[0] == 0xff;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
miRenderPixelToColor (PictFormatPtr format,
|
||||
CARD32 pixel,
|
||||
xRenderColor *color)
|
||||
{
|
||||
CARD32 r, g, b, a;
|
||||
miIndexedPtr pIndexed;
|
||||
|
||||
switch (format->type) {
|
||||
case PictTypeDirect:
|
||||
r = (pixel >> format->direct.red) & format->direct.redMask;
|
||||
g = (pixel >> format->direct.green) & format->direct.greenMask;
|
||||
b = (pixel >> format->direct.blue) & format->direct.blueMask;
|
||||
a = (pixel >> format->direct.alpha) & format->direct.alphaMask;
|
||||
color->red = miFillColor (r, Ones (format->direct.redMask));
|
||||
color->green = miFillColor (g, Ones (format->direct.greenMask));
|
||||
color->blue = miFillColor (b, Ones (format->direct.blueMask));
|
||||
color->alpha = miFillColor (a, Ones (format->direct.alphaMask));
|
||||
break;
|
||||
case PictTypeIndexed:
|
||||
pIndexed = (miIndexedPtr) (format->index.devPrivate);
|
||||
pixel = pIndexed->rgba[pixel & (MI_MAX_INDEXED-1)];
|
||||
r = (pixel >> 16) & 0xff;
|
||||
g = (pixel >> 8) & 0xff;
|
||||
b = (pixel ) & 0xff;
|
||||
color->red = miFillColor (r, 8);
|
||||
color->green = miFillColor (g, 8);
|
||||
color->blue = miFillColor (b, 8);
|
||||
color->alpha = 0xffff;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
|
||||
{
|
||||
PictureScreenPtr ps;
|
||||
|
||||
if (!PictureInit (pScreen, formats, nformats))
|
||||
return FALSE;
|
||||
ps = GetPictureScreen(pScreen);
|
||||
ps->CreatePicture = miCreatePicture;
|
||||
ps->DestroyPicture = miDestroyPicture;
|
||||
ps->ChangePictureClip = miChangePictureClip;
|
||||
ps->DestroyPictureClip = miDestroyPictureClip;
|
||||
ps->ChangePicture = miChangePicture;
|
||||
ps->ValidatePicture = miValidatePicture;
|
||||
ps->InitIndexed = miInitIndexed;
|
||||
ps->CloseIndexed = miCloseIndexed;
|
||||
ps->UpdateIndexed = miUpdateIndexed;
|
||||
ps->ChangePictureTransform = miChangePictureTransform;
|
||||
ps->ChangePictureFilter = miChangePictureFilter;
|
||||
|
||||
/* MI rendering routines */
|
||||
ps->Composite = 0; /* requires DDX support */
|
||||
ps->Glyphs = miGlyphs;
|
||||
ps->CompositeRects = miCompositeRects;
|
||||
ps->Trapezoids = miTrapezoids;
|
||||
ps->Triangles = miTriangles;
|
||||
ps->TriStrip = miTriStrip;
|
||||
ps->TriFan = miTriFan;
|
||||
|
||||
ps->RasterizeTrapezoid = 0; /* requires DDX support */
|
||||
ps->AddTraps = 0; /* requires DDX support */
|
||||
ps->AddTriangles = 0; /* requires DDX support */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
214
nx-X11/programs/Xserver/render/mipict.h
Normal file
214
nx-X11/programs/Xserver/render/mipict.h
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright © 2000 SuSE, Inc.
|
||||
*
|
||||
* 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 SuSE not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. SuSE makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
|
||||
* 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.
|
||||
*
|
||||
* Author: Keith Packard, SuSE, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _MIPICT_H_
|
||||
#define _MIPICT_H_
|
||||
|
||||
#include "picturestr.h"
|
||||
|
||||
#define MI_MAX_INDEXED 256 /* XXX depth must be <= 8 */
|
||||
|
||||
#if MI_MAX_INDEXED <= 256
|
||||
typedef CARD8 miIndexType;
|
||||
#endif
|
||||
|
||||
typedef struct _miIndexed {
|
||||
Bool color;
|
||||
CARD32 rgba[MI_MAX_INDEXED];
|
||||
miIndexType ent[32768];
|
||||
} miIndexedRec, *miIndexedPtr;
|
||||
|
||||
#define miCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
|
||||
(((s) >> 6) & 0x03e0) | \
|
||||
(((s) >> 9) & 0x7c00))
|
||||
#define miIndexToEnt15(mif,rgb15) ((mif)->ent[rgb15])
|
||||
#define miIndexToEnt24(mif,rgb24) miIndexToEnt15(mif,miCvtR8G8B8to15(rgb24))
|
||||
|
||||
#define miIndexToEntY24(mif,rgb24) ((mif)->ent[CvtR8G8B8toY15(rgb24)])
|
||||
|
||||
int
|
||||
miCreatePicture (PicturePtr pPicture);
|
||||
|
||||
void
|
||||
miDestroyPicture (PicturePtr pPicture);
|
||||
|
||||
void
|
||||
miDestroyPictureClip (PicturePtr pPicture);
|
||||
|
||||
int
|
||||
miChangePictureClip (PicturePtr pPicture,
|
||||
int type,
|
||||
void * value,
|
||||
int n);
|
||||
|
||||
void
|
||||
miChangePicture (PicturePtr pPicture,
|
||||
Mask mask);
|
||||
|
||||
void
|
||||
miValidatePicture (PicturePtr pPicture,
|
||||
Mask mask);
|
||||
|
||||
int
|
||||
miChangePictureTransform (PicturePtr pPicture,
|
||||
PictTransform *transform);
|
||||
|
||||
int
|
||||
miChangePictureFilter (PicturePtr pPicture,
|
||||
int filter,
|
||||
xFixed *params,
|
||||
int nparams);
|
||||
|
||||
Bool
|
||||
miClipPicture (RegionPtr pRegion,
|
||||
PicturePtr pPicture,
|
||||
INT16 xReg,
|
||||
INT16 yReg,
|
||||
INT16 xPict,
|
||||
INT16 yPict);
|
||||
|
||||
Bool
|
||||
miComputeCompositeRegion (RegionPtr pRegion,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
|
||||
Bool
|
||||
miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
|
||||
|
||||
void
|
||||
miGlyphs (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int nlist,
|
||||
GlyphListPtr list,
|
||||
GlyphPtr *glyphs);
|
||||
|
||||
void
|
||||
miRenderColorToPixel (PictFormatPtr pPict,
|
||||
xRenderColor *color,
|
||||
CARD32 *pixel);
|
||||
|
||||
void
|
||||
miRenderPixelToColor (PictFormatPtr pPict,
|
||||
CARD32 pixel,
|
||||
xRenderColor *color);
|
||||
|
||||
Bool
|
||||
miIsSolidAlpha (PicturePtr pSrc);
|
||||
|
||||
void
|
||||
miCompositeRects (CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
|
||||
void
|
||||
miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box);
|
||||
|
||||
void
|
||||
miTrapezoids (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntrap,
|
||||
xTrapezoid *traps);
|
||||
|
||||
void
|
||||
miPointFixedBounds (int npoint, xPointFixed *points, BoxPtr bounds);
|
||||
|
||||
void
|
||||
miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds);
|
||||
|
||||
void
|
||||
miRasterizeTriangle (PicturePtr pMask,
|
||||
xTriangle *tri,
|
||||
int x_off,
|
||||
int y_off);
|
||||
|
||||
void
|
||||
miTriangles (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntri,
|
||||
xTriangle *tris);
|
||||
|
||||
void
|
||||
miTriStrip (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int npoint,
|
||||
xPointFixed *points);
|
||||
|
||||
void
|
||||
miTriFan (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int npoint,
|
||||
xPointFixed *points);
|
||||
|
||||
PicturePtr
|
||||
miCreateAlphaPicture (ScreenPtr pScreen,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr pPictFormat,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
|
||||
Bool
|
||||
miInitIndexed (ScreenPtr pScreen,
|
||||
PictFormatPtr pFormat);
|
||||
|
||||
void
|
||||
miCloseIndexed (ScreenPtr pScreen,
|
||||
PictFormatPtr pFormat);
|
||||
|
||||
void
|
||||
miUpdateIndexed (ScreenPtr pScreen,
|
||||
PictFormatPtr pFormat,
|
||||
int ndef,
|
||||
xColorItem *pdef);
|
||||
|
||||
#endif /* _MIPICT_H_ */
|
||||
185
nx-X11/programs/Xserver/render/mirect.c
Normal file
185
nx-X11/programs/Xserver/render/mirect.c
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
||||
*
|
||||
* 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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 "scrnintstr.h"
|
||||
#include "gcstruct.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "windowstr.h"
|
||||
#include "mi.h"
|
||||
#include "picturestr.h"
|
||||
#include "mipict.h"
|
||||
|
||||
static void
|
||||
miColorRects (PicturePtr pDst,
|
||||
PicturePtr pClipPict,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects,
|
||||
int xoff,
|
||||
int yoff)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
CARD32 pixel;
|
||||
GCPtr pGC;
|
||||
CARD32 tmpval[5];
|
||||
RegionPtr pClip;
|
||||
unsigned long mask;
|
||||
|
||||
miRenderColorToPixel (pDst->pFormat, color, &pixel);
|
||||
|
||||
pGC = GetScratchGC (pDst->pDrawable->depth, pScreen);
|
||||
if (!pGC)
|
||||
return;
|
||||
tmpval[0] = GXcopy;
|
||||
tmpval[1] = pixel;
|
||||
tmpval[2] = pDst->subWindowMode;
|
||||
mask = GCFunction | GCForeground | GCSubwindowMode;
|
||||
if (pClipPict->clientClipType == CT_REGION)
|
||||
{
|
||||
tmpval[3] = pDst->clipOrigin.x - xoff;
|
||||
tmpval[4] = pDst->clipOrigin.y - yoff;
|
||||
mask |= GCClipXOrigin|GCClipYOrigin;
|
||||
|
||||
pClip = RegionCreate(NULL, 1);
|
||||
RegionCopy(pClip,
|
||||
(RegionPtr) pClipPict->clientClip);
|
||||
(*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
|
||||
}
|
||||
|
||||
ChangeGC (pGC, mask, tmpval);
|
||||
ValidateGC (pDst->pDrawable, pGC);
|
||||
if (xoff || yoff)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nRect; i++)
|
||||
{
|
||||
rects[i].x -= xoff;
|
||||
rects[i].y -= yoff;
|
||||
}
|
||||
}
|
||||
(*pGC->ops->PolyFillRect) (pDst->pDrawable, pGC, nRect, rects);
|
||||
if (xoff || yoff)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nRect; i++)
|
||||
{
|
||||
rects[i].x += xoff;
|
||||
rects[i].y += yoff;
|
||||
}
|
||||
}
|
||||
FreeScratchGC (pGC);
|
||||
}
|
||||
|
||||
void
|
||||
miCompositeRects (CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
|
||||
if (color->alpha == 0xffff)
|
||||
{
|
||||
if (op == PictOpOver)
|
||||
op = PictOpSrc;
|
||||
}
|
||||
if (op == PictOpClear)
|
||||
color->red = color->green = color->blue = color->alpha = 0;
|
||||
|
||||
if (op == PictOpSrc || op == PictOpClear)
|
||||
{
|
||||
miColorRects (pDst, pDst, color, nRect, rects, 0, 0);
|
||||
if (pDst->alphaMap)
|
||||
miColorRects (pDst->alphaMap, pDst,
|
||||
color, nRect, rects,
|
||||
pDst->alphaOrigin.x,
|
||||
pDst->alphaOrigin.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
PictFormatPtr rgbaFormat;
|
||||
PixmapPtr pPixmap;
|
||||
PicturePtr pSrc;
|
||||
xRectangle one;
|
||||
int error;
|
||||
Pixel pixel;
|
||||
GCPtr pGC;
|
||||
CARD32 tmpval[2];
|
||||
|
||||
rgbaFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
|
||||
if (!rgbaFormat)
|
||||
goto bail1;
|
||||
|
||||
pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1,
|
||||
rgbaFormat->depth,
|
||||
CREATE_PIXMAP_USAGE_SCRATCH);
|
||||
if (!pPixmap)
|
||||
goto bail2;
|
||||
|
||||
miRenderColorToPixel (rgbaFormat, color, &pixel);
|
||||
|
||||
pGC = GetScratchGC (rgbaFormat->depth, pScreen);
|
||||
if (!pGC)
|
||||
goto bail3;
|
||||
tmpval[0] = GXcopy;
|
||||
tmpval[1] = pixel;
|
||||
|
||||
ChangeGC (pGC, GCFunction | GCForeground, tmpval);
|
||||
ValidateGC (&pPixmap->drawable, pGC);
|
||||
one.x = 0;
|
||||
one.y = 0;
|
||||
one.width = 1;
|
||||
one.height = 1;
|
||||
(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
|
||||
|
||||
tmpval[0] = xTrue;
|
||||
pSrc = CreatePicture (0, &pPixmap->drawable, rgbaFormat,
|
||||
CPRepeat, tmpval, 0, &error);
|
||||
|
||||
if (!pSrc)
|
||||
goto bail4;
|
||||
|
||||
while (nRect--)
|
||||
{
|
||||
CompositePicture (op, pSrc, 0, pDst, 0, 0, 0, 0,
|
||||
rects->x,
|
||||
rects->y,
|
||||
rects->width,
|
||||
rects->height);
|
||||
rects++;
|
||||
}
|
||||
|
||||
FreePicture ((void *) pSrc, 0);
|
||||
bail4:
|
||||
FreeScratchGC (pGC);
|
||||
bail3:
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
bail2:
|
||||
bail1:
|
||||
;
|
||||
}
|
||||
}
|
||||
190
nx-X11/programs/Xserver/render/mitrap.c
Normal file
190
nx-X11/programs/Xserver/render/mitrap.c
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
|
||||
*
|
||||
* 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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 "scrnintstr.h"
|
||||
#include "gcstruct.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "windowstr.h"
|
||||
#include "servermd.h"
|
||||
#include "mi.h"
|
||||
#include "picturestr.h"
|
||||
#include "mipict.h"
|
||||
|
||||
PicturePtr
|
||||
miCreateAlphaPicture (ScreenPtr pScreen,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr pPictFormat,
|
||||
CARD16 width,
|
||||
CARD16 height)
|
||||
{
|
||||
PixmapPtr pPixmap;
|
||||
PicturePtr pPicture;
|
||||
GCPtr pGC;
|
||||
int error;
|
||||
xRectangle rect;
|
||||
|
||||
if (width > 32767 || height > 32767)
|
||||
return 0;
|
||||
|
||||
if (!pPictFormat)
|
||||
{
|
||||
if (pDst->polyEdge == PolyEdgeSharp)
|
||||
pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
|
||||
else
|
||||
pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
|
||||
if (!pPictFormat)
|
||||
return 0;
|
||||
}
|
||||
|
||||
pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
|
||||
pPictFormat->depth, 0);
|
||||
if (!pPixmap)
|
||||
return 0;
|
||||
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
|
||||
if (!pGC)
|
||||
{
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
return 0;
|
||||
}
|
||||
ValidateGC (&pPixmap->drawable, pGC);
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = width;
|
||||
rect.height = height;
|
||||
(*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, 1, &rect);
|
||||
FreeScratchGC (pGC);
|
||||
pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
|
||||
0, 0, serverClient, &error);
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
return pPicture;
|
||||
}
|
||||
|
||||
static xFixed
|
||||
miLineFixedX (xLineFixed *l, xFixed y, Bool ceil)
|
||||
{
|
||||
xFixed dx = l->p2.x - l->p1.x;
|
||||
xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
|
||||
xFixed dy = l->p2.y - l->p1.y;
|
||||
if (ceil)
|
||||
ex += (dy - 1);
|
||||
return l->p1.x + (xFixed) (ex / dy);
|
||||
}
|
||||
|
||||
void
|
||||
miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box)
|
||||
{
|
||||
box->y1 = MAXSHORT;
|
||||
box->y2 = MINSHORT;
|
||||
box->x1 = MAXSHORT;
|
||||
box->x2 = MINSHORT;
|
||||
for (; ntrap; ntrap--, traps++)
|
||||
{
|
||||
INT16 x1, y1, x2, y2;
|
||||
|
||||
if (!xTrapezoidValid(traps))
|
||||
continue;
|
||||
y1 = xFixedToInt (traps->top);
|
||||
if (y1 < box->y1)
|
||||
box->y1 = y1;
|
||||
|
||||
y2 = xFixedToInt (xFixedCeil (traps->bottom));
|
||||
if (y2 > box->y2)
|
||||
box->y2 = y2;
|
||||
|
||||
x1 = xFixedToInt (min (miLineFixedX (&traps->left, traps->top, FALSE),
|
||||
miLineFixedX (&traps->left, traps->bottom, FALSE)));
|
||||
if (x1 < box->x1)
|
||||
box->x1 = x1;
|
||||
|
||||
x2 = xFixedToInt (xFixedCeil (max (miLineFixedX (&traps->right, traps->top, TRUE),
|
||||
miLineFixedX (&traps->right, traps->bottom, TRUE))));
|
||||
if (x2 > box->x2)
|
||||
box->x2 = x2;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
void
|
||||
miTrapezoids (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntrap,
|
||||
xTrapezoid *traps)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
|
||||
/*
|
||||
* Check for solid alpha add
|
||||
*/
|
||||
if (op == PictOpAdd && miIsSolidAlpha (pSrc))
|
||||
{
|
||||
for (; ntrap; ntrap--, traps++)
|
||||
(*ps->RasterizeTrapezoid) (pDst, traps, 0, 0);
|
||||
}
|
||||
else if (maskFormat)
|
||||
{
|
||||
PicturePtr pPicture;
|
||||
BoxRec bounds;
|
||||
INT16 xDst, yDst;
|
||||
INT16 xRel, yRel;
|
||||
|
||||
xDst = traps[0].left.p1.x >> 16;
|
||||
yDst = traps[0].left.p1.y >> 16;
|
||||
|
||||
miTrapezoidBounds (ntrap, traps, &bounds);
|
||||
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
|
||||
return;
|
||||
pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
|
||||
bounds.x2 - bounds.x1,
|
||||
bounds.y2 - bounds.y1);
|
||||
if (!pPicture)
|
||||
return;
|
||||
for (; ntrap; ntrap--, traps++)
|
||||
(*ps->RasterizeTrapezoid) (pPicture, traps,
|
||||
-bounds.x1, -bounds.y1);
|
||||
xRel = bounds.x1 + xSrc - xDst;
|
||||
yRel = bounds.y1 + ySrc - yDst;
|
||||
CompositePicture (op, pSrc, pPicture, pDst,
|
||||
xRel, yRel, 0, 0, bounds.x1, bounds.y1,
|
||||
bounds.x2 - bounds.x1,
|
||||
bounds.y2 - bounds.y1);
|
||||
FreePicture (pPicture, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pDst->polyEdge == PolyEdgeSharp)
|
||||
maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
|
||||
else
|
||||
maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
|
||||
for (; ntrap; ntrap--, traps++)
|
||||
miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
190
nx-X11/programs/Xserver/render/mitri.c
Normal file
190
nx-X11/programs/Xserver/render/mitri.c
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
|
||||
*
|
||||
* 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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 "scrnintstr.h"
|
||||
#include "gcstruct.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "windowstr.h"
|
||||
#include "mi.h"
|
||||
#include "picturestr.h"
|
||||
#include "mipict.h"
|
||||
|
||||
void
|
||||
miPointFixedBounds (int npoint, xPointFixed *points, BoxPtr bounds)
|
||||
{
|
||||
bounds->x1 = xFixedToInt (points->x);
|
||||
bounds->x2 = xFixedToInt (xFixedCeil (points->x));
|
||||
bounds->y1 = xFixedToInt (points->y);
|
||||
bounds->y2 = xFixedToInt (xFixedCeil (points->y));
|
||||
points++;
|
||||
npoint--;
|
||||
while (npoint-- > 0)
|
||||
{
|
||||
INT16 x1 = xFixedToInt (points->x);
|
||||
INT16 x2 = xFixedToInt (xFixedCeil (points->x));
|
||||
INT16 y1 = xFixedToInt (points->y);
|
||||
INT16 y2 = xFixedToInt (xFixedCeil (points->y));
|
||||
|
||||
if (x1 < bounds->x1)
|
||||
bounds->x1 = x1;
|
||||
else if (x2 > bounds->x2)
|
||||
bounds->x2 = x2;
|
||||
if (y1 < bounds->y1)
|
||||
bounds->y1 = y1;
|
||||
else if (y2 > bounds->y2)
|
||||
bounds->y2 = y2;
|
||||
points++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds)
|
||||
{
|
||||
miPointFixedBounds (ntri * 3, (xPointFixed *) tris, bounds);
|
||||
}
|
||||
|
||||
void
|
||||
miTriangles (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntri,
|
||||
xTriangle *tris)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
|
||||
/*
|
||||
* Check for solid alpha add
|
||||
*/
|
||||
if (op == PictOpAdd && miIsSolidAlpha (pSrc))
|
||||
{
|
||||
(*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
|
||||
}
|
||||
else if (maskFormat)
|
||||
{
|
||||
BoxRec bounds;
|
||||
PicturePtr pPicture;
|
||||
INT16 xDst, yDst;
|
||||
INT16 xRel, yRel;
|
||||
|
||||
xDst = tris[0].p1.x >> 16;
|
||||
yDst = tris[0].p1.y >> 16;
|
||||
|
||||
miTriangleBounds (ntri, tris, &bounds);
|
||||
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
|
||||
return;
|
||||
pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
|
||||
bounds.x2 - bounds.x1,
|
||||
bounds.y2 - bounds.y1);
|
||||
if (!pPicture)
|
||||
return;
|
||||
(*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris);
|
||||
|
||||
xRel = bounds.x1 + xSrc - xDst;
|
||||
yRel = bounds.y1 + ySrc - yDst;
|
||||
CompositePicture (op, pSrc, pPicture, pDst,
|
||||
xRel, yRel, 0, 0, bounds.x1, bounds.y1,
|
||||
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
|
||||
FreePicture (pPicture, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pDst->polyEdge == PolyEdgeSharp)
|
||||
maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
|
||||
else
|
||||
maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
|
||||
|
||||
for (; ntri; ntri--, tris++)
|
||||
miTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
miTriStrip (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int npoint,
|
||||
xPointFixed *points)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
xTriangle *tris, *tri;
|
||||
int ntri;
|
||||
|
||||
if (npoint < 3)
|
||||
return;
|
||||
ntri = npoint - 2;
|
||||
tris = malloc (ntri * sizeof (xTriangle));
|
||||
if (!tris)
|
||||
return;
|
||||
for (tri = tris; npoint >= 3; npoint--, points++, tri++)
|
||||
{
|
||||
tri->p1 = points[0];
|
||||
tri->p2 = points[1];
|
||||
tri->p3 = points[2];
|
||||
}
|
||||
(*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
|
||||
free (tris);
|
||||
}
|
||||
|
||||
void
|
||||
miTriFan (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int npoint,
|
||||
xPointFixed *points)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
PictureScreenPtr ps = GetPictureScreen(pScreen);
|
||||
xTriangle *tris, *tri;
|
||||
xPointFixed *first;
|
||||
int ntri;
|
||||
|
||||
if (npoint < 3)
|
||||
return;
|
||||
ntri = npoint - 2;
|
||||
tris = malloc (ntri * sizeof (xTriangle));
|
||||
if (!tris)
|
||||
return;
|
||||
first = points++;
|
||||
for (tri = tris; npoint >= 3; npoint--, points++, tri++)
|
||||
{
|
||||
tri->p1 = *first;
|
||||
tri->p2 = points[0];
|
||||
tri->p3 = points[1];
|
||||
}
|
||||
(*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
|
||||
free (tris);
|
||||
}
|
||||
1886
nx-X11/programs/Xserver/render/picture.c
Normal file
1886
nx-X11/programs/Xserver/render/picture.c
Normal file
File diff suppressed because it is too large
Load Diff
245
nx-X11/programs/Xserver/render/picture.h
Normal file
245
nx-X11/programs/Xserver/render/picture.h
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
*
|
||||
* Copyright © 2000 SuSE, Inc.
|
||||
*
|
||||
* 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 SuSE not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. SuSE makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
|
||||
* 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.
|
||||
*
|
||||
* Author: Keith Packard, SuSE, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _PICTURE_H_
|
||||
#define _PICTURE_H_
|
||||
|
||||
typedef struct _DirectFormat *DirectFormatPtr;
|
||||
typedef struct _PictFormat *PictFormatPtr;
|
||||
typedef struct _Picture *PicturePtr;
|
||||
|
||||
/*
|
||||
* While the protocol is generous in format support, the
|
||||
* sample implementation allows only packed RGB and GBR
|
||||
* representations for data to simplify software rendering,
|
||||
*/
|
||||
#define PICT_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \
|
||||
((type) << 16) | \
|
||||
((a) << 12) | \
|
||||
((r) << 8) | \
|
||||
((g) << 4) | \
|
||||
((b)))
|
||||
|
||||
/*
|
||||
* gray/color formats use a visual index instead of argb
|
||||
*/
|
||||
#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \
|
||||
((type) << 16) | \
|
||||
((vi)))
|
||||
|
||||
#define PICT_FORMAT_BPP(f) (((f) >> 24) )
|
||||
#define PICT_FORMAT_TYPE(f) (((f) >> 16) & 0xff)
|
||||
#define PICT_FORMAT_A(f) (((f) >> 12) & 0x0f)
|
||||
#define PICT_FORMAT_R(f) (((f) >> 8) & 0x0f)
|
||||
#define PICT_FORMAT_G(f) (((f) >> 4) & 0x0f)
|
||||
#define PICT_FORMAT_B(f) (((f) ) & 0x0f)
|
||||
#define PICT_FORMAT_RGB(f) (((f) ) & 0xfff)
|
||||
#define PICT_FORMAT_VIS(f) (((f) ) & 0xffff)
|
||||
|
||||
#define PICT_TYPE_OTHER 0
|
||||
#define PICT_TYPE_A 1
|
||||
#define PICT_TYPE_ARGB 2
|
||||
#define PICT_TYPE_ABGR 3
|
||||
#define PICT_TYPE_COLOR 4
|
||||
#define PICT_TYPE_GRAY 5
|
||||
|
||||
#define PICT_FORMAT_COLOR(f) (PICT_FORMAT_TYPE(f) & 2)
|
||||
|
||||
/* 32bpp formats */
|
||||
#define PICT_a8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8)
|
||||
#define PICT_x8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8)
|
||||
#define PICT_a8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8)
|
||||
#define PICT_x8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8)
|
||||
|
||||
/* 24bpp formats */
|
||||
#define PICT_r8g8b8 PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8)
|
||||
#define PICT_b8g8r8 PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8)
|
||||
|
||||
/* 16bpp formats */
|
||||
#define PICT_r5g6b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5)
|
||||
#define PICT_b5g6r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5)
|
||||
|
||||
#define PICT_a1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5)
|
||||
#define PICT_x1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5)
|
||||
#define PICT_a1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5)
|
||||
#define PICT_x1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5)
|
||||
#define PICT_a4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
|
||||
#define PICT_x4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,0,4,4,4)
|
||||
#define PICT_a4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ABGR,4,4,4,4)
|
||||
#define PICT_x4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ABGR,0,4,4,4)
|
||||
|
||||
/* 8bpp formats */
|
||||
#define PICT_a8 PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0)
|
||||
#define PICT_r3g3b2 PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2)
|
||||
#define PICT_b2g3r3 PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2)
|
||||
#define PICT_a2r2g2b2 PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2)
|
||||
#define PICT_a2b2g2r2 PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2)
|
||||
|
||||
#define PICT_c8 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0)
|
||||
#define PICT_g8 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0)
|
||||
|
||||
#define PICT_x4a4 PICT_FORMAT(8,PICT_TYPE_A,4,0,0,0)
|
||||
#define PICT_x4r1g2b1 PICT_FORMAT(8,PICT_TYPE_ARGB,0,1,2,1)
|
||||
#define PICT_x4b1g2r1 PICT_FORMAT(8,PICT_TYPE_ABGR,0,1,2,1)
|
||||
#define PICT_x4a1r1g1b1 PICT_FORMAT(8,PICT_TYPE_ARGB,1,1,1,1)
|
||||
#define PICT_x4a1b1g1r1 PICT_FORMAT(8,PICT_TYPE_ABGR,1,1,1,1)
|
||||
|
||||
#define PICT_x4c4 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0)
|
||||
#define PICT_x4g4 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0)
|
||||
|
||||
/* 4bpp formats */
|
||||
#define PICT_a4 PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0)
|
||||
#define PICT_r1g2b1 PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1)
|
||||
#define PICT_b1g2r1 PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1)
|
||||
#define PICT_a1r1g1b1 PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1)
|
||||
#define PICT_a1b1g1r1 PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1)
|
||||
|
||||
#define PICT_c4 PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0)
|
||||
#define PICT_g4 PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0)
|
||||
|
||||
/* 1bpp formats */
|
||||
#define PICT_a1 PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0)
|
||||
|
||||
#define PICT_g1 PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0)
|
||||
|
||||
/*
|
||||
* For dynamic indexed visuals (GrayScale and PseudoColor), these control the
|
||||
* selection of colors allocated for drawing to Pictures. The default
|
||||
* policy depends on the size of the colormap:
|
||||
*
|
||||
* Size Default Policy
|
||||
* ----------------------------
|
||||
* < 64 PolicyMono
|
||||
* < 256 PolicyGray
|
||||
* 256 PolicyColor (only on PseudoColor)
|
||||
*
|
||||
* The actual allocation code lives in miindex.c, and so is
|
||||
* austensibly server dependent, but that code does:
|
||||
*
|
||||
* PolicyMono Allocate no additional colors, use black and white
|
||||
* PolicyGray Allocate 13 gray levels (11 cells used)
|
||||
* PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used)
|
||||
* PolicyAll Allocate as big a cube as possible, fill with gray (all)
|
||||
*
|
||||
* Here's a picture to help understand how many colors are
|
||||
* actually allocated (this is just the gray ramp):
|
||||
*
|
||||
* gray level
|
||||
* all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
|
||||
* b/w 0000 ffff
|
||||
* 4x4x4 5555 aaaa
|
||||
* extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
|
||||
*
|
||||
* The default colormap supplies two gray levels (black/white), the
|
||||
* 4x4x4 cube allocates another two and nine more are allocated to fill
|
||||
* in the 13 levels. When the 4x4x4 cube is not allocated, a total of
|
||||
* 11 cells are allocated.
|
||||
*/
|
||||
|
||||
#define PictureCmapPolicyInvalid -1
|
||||
#define PictureCmapPolicyDefault 0
|
||||
#define PictureCmapPolicyMono 1
|
||||
#define PictureCmapPolicyGray 2
|
||||
#define PictureCmapPolicyColor 3
|
||||
#define PictureCmapPolicyAll 4
|
||||
|
||||
extern int PictureCmapPolicy;
|
||||
|
||||
int PictureParseCmapPolicy (const char *name);
|
||||
|
||||
extern int RenderErrBase;
|
||||
extern int RenderClientPrivateIndex;
|
||||
|
||||
/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
|
||||
|
||||
#if defined(WIN32) && !defined(__GNUC__)
|
||||
typedef __int64 xFixed_32_32;
|
||||
#else
|
||||
# if defined (_LP64) || \
|
||||
defined(__alpha__) || defined(__alpha) || \
|
||||
defined(ia64) || defined(__ia64__) || \
|
||||
defined(__sparc64__) || \
|
||||
defined(__s390x__) || \
|
||||
defined(amd64) || defined (__amd64__)
|
||||
typedef long xFixed_32_32;
|
||||
# else
|
||||
# if defined(__GNUC__) && \
|
||||
((__GNUC__ > 2) || \
|
||||
((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
|
||||
__extension__
|
||||
# endif
|
||||
typedef long long int xFixed_32_32;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef xFixed_32_32 xFixed_48_16;
|
||||
|
||||
#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff)
|
||||
#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31))
|
||||
|
||||
typedef CARD32 xFixed_1_31;
|
||||
typedef CARD32 xFixed_1_16;
|
||||
typedef INT32 xFixed_16_16;
|
||||
|
||||
/*
|
||||
* An unadorned "xFixed" is the same as xFixed_16_16,
|
||||
* (since it's quite common in the code)
|
||||
*/
|
||||
typedef xFixed_16_16 xFixed;
|
||||
#define XFIXED_BITS 16
|
||||
|
||||
#define xFixedToInt(f) (int) ((f) >> XFIXED_BITS)
|
||||
#define IntToxFixed(i) ((xFixed) (i) << XFIXED_BITS)
|
||||
#define xFixedE ((xFixed) 1)
|
||||
#define xFixed1 (IntToxFixed(1))
|
||||
#define xFixed1MinusE (xFixed1 - xFixedE)
|
||||
#define xFixedFrac(f) ((f) & xFixed1MinusE)
|
||||
#define xFixedFloor(f) ((f) & ~xFixed1MinusE)
|
||||
#define xFixedCeil(f) xFixedFloor((f) + xFixed1MinusE)
|
||||
|
||||
#define xFixedFraction(f) ((f) & xFixed1MinusE)
|
||||
#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE))
|
||||
|
||||
/* whether 't' is a well defined not obviously empty trapezoid */
|
||||
#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
|
||||
(t)->right.p1.y != (t)->right.p2.y && \
|
||||
(int) ((t)->bottom - (t)->top) > 0)
|
||||
|
||||
/*
|
||||
* Standard NTSC luminance conversions:
|
||||
*
|
||||
* y = r * 0.299 + g * 0.587 + b * 0.114
|
||||
*
|
||||
* Approximate this for a bit more speed:
|
||||
*
|
||||
* y = (r * 153 + g * 301 + b * 58) / 512
|
||||
*
|
||||
* This gives 17 bits of luminance; to get 15 bits, lop the low two
|
||||
*/
|
||||
|
||||
#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
|
||||
(((s) >> 8) & 0xff) * 301 + \
|
||||
(((s) ) & 0xff) * 58) >> 2)
|
||||
|
||||
#endif /* _PICTURE_H_ */
|
||||
686
nx-X11/programs/Xserver/render/picturestr.h
Normal file
686
nx-X11/programs/Xserver/render/picturestr.h
Normal file
@@ -0,0 +1,686 @@
|
||||
/*
|
||||
* $Id: picturestr.h,v 1.15 2005/12/09 18:35:21 ajax Exp $
|
||||
*
|
||||
* Copyright © 2000 SuSE, Inc.
|
||||
*
|
||||
* 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 SuSE not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. SuSE makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
|
||||
* 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.
|
||||
*
|
||||
* Author: Keith Packard, SuSE, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _PICTURESTR_H_
|
||||
#define _PICTURESTR_H_
|
||||
|
||||
#include "glyphstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "resource.h"
|
||||
|
||||
typedef struct _DirectFormat {
|
||||
CARD16 red, redMask;
|
||||
CARD16 green, greenMask;
|
||||
CARD16 blue, blueMask;
|
||||
CARD16 alpha, alphaMask;
|
||||
} DirectFormatRec;
|
||||
|
||||
typedef struct _IndexFormat {
|
||||
VisualID vid;
|
||||
ColormapPtr pColormap;
|
||||
int nvalues;
|
||||
xIndexValue *pValues;
|
||||
void *devPrivate;
|
||||
} IndexFormatRec;
|
||||
|
||||
typedef struct _PictFormat {
|
||||
CARD32 id;
|
||||
CARD32 format; /* except bpp */
|
||||
unsigned char type;
|
||||
unsigned char depth;
|
||||
DirectFormatRec direct;
|
||||
IndexFormatRec index;
|
||||
} PictFormatRec;
|
||||
|
||||
typedef struct pixman_vector PictVector, *PictVectorPtr;
|
||||
typedef struct pixman_transform PictTransform, *PictTransformPtr;
|
||||
|
||||
#define pict_f_transform pixman_f_transform
|
||||
|
||||
#define PICT_GRADIENT_STOPTABLE_SIZE 1024
|
||||
#define SourcePictTypeSolidFill 0
|
||||
#define SourcePictTypeLinear 1
|
||||
#define SourcePictTypeRadial 2
|
||||
#define SourcePictTypeConical 3
|
||||
|
||||
#ifdef NXAGENT_SERVER
|
||||
#include "../hw/nxagent/NXpicturestr_PictSolidFill.h"
|
||||
#else
|
||||
typedef struct _PictSolidFill {
|
||||
unsigned int type;
|
||||
CARD32 color;
|
||||
} PictSolidFill, *PictSolidFillPtr;
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
typedef struct _PictGradientStop {
|
||||
xFixed x;
|
||||
xRenderColor color;
|
||||
} PictGradientStop, *PictGradientStopPtr;
|
||||
|
||||
typedef struct _PictGradient {
|
||||
unsigned int type;
|
||||
int nstops;
|
||||
PictGradientStopPtr stops;
|
||||
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
|
||||
} PictGradient, *PictGradientPtr;
|
||||
|
||||
typedef struct _PictLinearGradient {
|
||||
unsigned int type;
|
||||
int nstops;
|
||||
PictGradientStopPtr stops;
|
||||
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
|
||||
xPointFixed p1;
|
||||
xPointFixed p2;
|
||||
} PictLinearGradient, *PictLinearGradientPtr;
|
||||
|
||||
typedef struct _PictRadialGradient {
|
||||
unsigned int type;
|
||||
int nstops;
|
||||
PictGradientStopPtr stops;
|
||||
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
|
||||
double fx;
|
||||
double fy;
|
||||
double dx;
|
||||
double dy;
|
||||
double a;
|
||||
double m;
|
||||
double b;
|
||||
} PictRadialGradient, *PictRadialGradientPtr;
|
||||
|
||||
typedef struct _PictConicalGradient {
|
||||
unsigned int type;
|
||||
int nstops;
|
||||
PictGradientStopPtr stops;
|
||||
CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
|
||||
xPointFixed center;
|
||||
xFixed angle;
|
||||
} PictConicalGradient, *PictConicalGradientPtr;
|
||||
|
||||
typedef union _SourcePict {
|
||||
unsigned int type;
|
||||
PictSolidFill solidFill;
|
||||
PictGradient gradient;
|
||||
PictLinearGradient linear;
|
||||
PictRadialGradient radial;
|
||||
PictConicalGradient conical;
|
||||
} SourcePict, *SourcePictPtr;
|
||||
|
||||
typedef struct _Picture {
|
||||
DrawablePtr pDrawable;
|
||||
PictFormatPtr pFormat;
|
||||
CARD32 format; /* PICT_FORMAT */
|
||||
int refcnt;
|
||||
CARD32 id;
|
||||
PicturePtr pNext; /* chain on same drawable */
|
||||
|
||||
unsigned int repeat : 1;
|
||||
unsigned int graphicsExposures : 1;
|
||||
unsigned int subWindowMode : 1;
|
||||
unsigned int polyEdge : 1;
|
||||
unsigned int polyMode : 1;
|
||||
unsigned int freeCompClip : 1;
|
||||
unsigned int clientClipType : 2;
|
||||
unsigned int componentAlpha : 1;
|
||||
unsigned int repeatType : 2;
|
||||
unsigned int unused : 21;
|
||||
|
||||
PicturePtr alphaMap;
|
||||
DDXPointRec alphaOrigin;
|
||||
|
||||
DDXPointRec clipOrigin;
|
||||
void *clientClip;
|
||||
|
||||
Atom dither;
|
||||
|
||||
unsigned long stateChanges;
|
||||
unsigned long serialNumber;
|
||||
|
||||
RegionPtr pCompositeClip;
|
||||
|
||||
DevUnion *devPrivates;
|
||||
|
||||
PictTransform *transform;
|
||||
|
||||
int filter;
|
||||
xFixed *filter_params;
|
||||
int filter_nparams;
|
||||
SourcePictPtr pSourcePict;
|
||||
} PictureRec;
|
||||
|
||||
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
|
||||
#define PictFilterBilinear 1
|
||||
|
||||
#define PictFilterFast 2
|
||||
#define PictFilterGood 3
|
||||
#define PictFilterBest 4
|
||||
|
||||
#define PictFilterConvolution 5
|
||||
|
||||
typedef struct {
|
||||
char *alias;
|
||||
int alias_id;
|
||||
int filter_id;
|
||||
} PictFilterAliasRec, *PictFilterAliasPtr;
|
||||
|
||||
typedef int (*CreatePictureProcPtr) (PicturePtr pPicture);
|
||||
typedef void (*DestroyPictureProcPtr) (PicturePtr pPicture);
|
||||
typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture,
|
||||
int clipType,
|
||||
void *value,
|
||||
int n);
|
||||
typedef void (*DestroyPictureClipProcPtr)(PicturePtr pPicture);
|
||||
|
||||
typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture,
|
||||
PictTransform *transform);
|
||||
|
||||
typedef int (*ChangePictureFilterProcPtr) (PicturePtr pPicture,
|
||||
int filter,
|
||||
xFixed *params,
|
||||
int nparams);
|
||||
|
||||
typedef void (*DestroyPictureFilterProcPtr) (PicturePtr pPicture);
|
||||
|
||||
typedef void (*ChangePictureProcPtr) (PicturePtr pPicture,
|
||||
Mask mask);
|
||||
typedef void (*ValidatePictureProcPtr) (PicturePtr pPicture,
|
||||
Mask mask);
|
||||
typedef void (*CompositeProcPtr) (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
|
||||
typedef void (*GlyphsProcPtr) (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int nlists,
|
||||
GlyphListPtr lists,
|
||||
GlyphPtr *glyphs);
|
||||
|
||||
typedef void (*CompositeRectsProcPtr) (CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
|
||||
typedef void (*RasterizeTrapezoidProcPtr)(PicturePtr pMask,
|
||||
xTrapezoid *trap,
|
||||
int x_off,
|
||||
int y_off);
|
||||
|
||||
typedef void (*TrapezoidsProcPtr) (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntrap,
|
||||
xTrapezoid *traps);
|
||||
|
||||
typedef void (*TrianglesProcPtr) (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntri,
|
||||
xTriangle *tris);
|
||||
|
||||
typedef void (*TriStripProcPtr) (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int npoint,
|
||||
xPointFixed *points);
|
||||
|
||||
typedef void (*TriFanProcPtr) (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int npoint,
|
||||
xPointFixed *points);
|
||||
|
||||
typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen,
|
||||
PictFormatPtr pFormat);
|
||||
|
||||
typedef void (*CloseIndexedProcPtr) (ScreenPtr pScreen,
|
||||
PictFormatPtr pFormat);
|
||||
|
||||
typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen,
|
||||
PictFormatPtr pFormat,
|
||||
int ndef,
|
||||
xColorItem *pdef);
|
||||
|
||||
typedef void (*AddTrapsProcPtr) (PicturePtr pPicture,
|
||||
INT16 xOff,
|
||||
INT16 yOff,
|
||||
int ntrap,
|
||||
xTrap *traps);
|
||||
|
||||
typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture,
|
||||
INT16 xOff,
|
||||
INT16 yOff,
|
||||
int ntri,
|
||||
xTriangle *tris);
|
||||
|
||||
typedef struct _PictureScreen {
|
||||
int totalPictureSize;
|
||||
unsigned int *PicturePrivateSizes;
|
||||
int PicturePrivateLen;
|
||||
|
||||
PictFormatPtr formats;
|
||||
PictFormatPtr fallback;
|
||||
int nformats;
|
||||
|
||||
CreatePictureProcPtr CreatePicture;
|
||||
DestroyPictureProcPtr DestroyPicture;
|
||||
ChangePictureClipProcPtr ChangePictureClip;
|
||||
DestroyPictureClipProcPtr DestroyPictureClip;
|
||||
|
||||
ChangePictureProcPtr ChangePicture;
|
||||
ValidatePictureProcPtr ValidatePicture;
|
||||
|
||||
CompositeProcPtr Composite;
|
||||
GlyphsProcPtr Glyphs;
|
||||
CompositeRectsProcPtr CompositeRects;
|
||||
|
||||
DestroyWindowProcPtr DestroyWindow;
|
||||
CloseScreenProcPtr CloseScreen;
|
||||
|
||||
StoreColorsProcPtr StoreColors;
|
||||
|
||||
InitIndexedProcPtr InitIndexed;
|
||||
CloseIndexedProcPtr CloseIndexed;
|
||||
UpdateIndexedProcPtr UpdateIndexed;
|
||||
|
||||
int subpixel;
|
||||
|
||||
PictFilterPtr filters;
|
||||
int nfilters;
|
||||
PictFilterAliasPtr filterAliases;
|
||||
int nfilterAliases;
|
||||
|
||||
ChangePictureTransformProcPtr ChangePictureTransform;
|
||||
|
||||
/**
|
||||
* Called immediately after a picture's transform is changed through the
|
||||
* SetPictureFilter request. Not called for source-only pictures.
|
||||
*/
|
||||
ChangePictureFilterProcPtr ChangePictureFilter;
|
||||
|
||||
DestroyPictureFilterProcPtr DestroyPictureFilter;
|
||||
|
||||
TrapezoidsProcPtr Trapezoids;
|
||||
TrianglesProcPtr Triangles;
|
||||
TriStripProcPtr TriStrip;
|
||||
TriFanProcPtr TriFan;
|
||||
|
||||
RasterizeTrapezoidProcPtr RasterizeTrapezoid;
|
||||
|
||||
AddTrianglesProcPtr AddTriangles;
|
||||
|
||||
AddTrapsProcPtr AddTraps;
|
||||
|
||||
} PictureScreenRec, *PictureScreenPtr;
|
||||
|
||||
extern int PictureScreenPrivateIndex;
|
||||
extern int PictureWindowPrivateIndex;
|
||||
extern RESTYPE PictureType;
|
||||
extern RESTYPE PictFormatType;
|
||||
extern RESTYPE GlyphSetType;
|
||||
|
||||
#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
|
||||
#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
|
||||
#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (void *) (p))
|
||||
#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
|
||||
#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (void *) (p))
|
||||
|
||||
#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
|
||||
pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
|
||||
if (!pPicture) { \
|
||||
client->errorValue = pid; \
|
||||
return err; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\
|
||||
if (pid == None) \
|
||||
pPicture = 0; \
|
||||
else { \
|
||||
VERIFY_PICTURE(pPicture, pid, client, mode, err); \
|
||||
} \
|
||||
} \
|
||||
|
||||
void
|
||||
ResetPicturePrivateIndex (void);
|
||||
|
||||
int
|
||||
AllocatePicturePrivateIndex (void);
|
||||
|
||||
Bool
|
||||
AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount);
|
||||
|
||||
Bool
|
||||
PictureDestroyWindow (WindowPtr pWindow);
|
||||
|
||||
Bool
|
||||
PictureCloseScreen (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef);
|
||||
|
||||
Bool
|
||||
PictureInitIndexedFormats (ScreenPtr pScreen);
|
||||
|
||||
Bool
|
||||
PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel);
|
||||
|
||||
int
|
||||
PictureGetSubpixelOrder (ScreenPtr pScreen);
|
||||
|
||||
PictFormatPtr
|
||||
PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp);
|
||||
|
||||
PictFormatPtr
|
||||
PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual);
|
||||
|
||||
PictFormatPtr
|
||||
PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 format);
|
||||
|
||||
Bool
|
||||
PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
|
||||
|
||||
int
|
||||
PictureGetFilterId (char *filter, int len, Bool makeit);
|
||||
|
||||
char *
|
||||
PictureGetFilterName (int id);
|
||||
|
||||
int
|
||||
PictureAddFilter (ScreenPtr pScreen,
|
||||
char *filter,
|
||||
PictFilterValidateParamsProcPtr ValidateParams);
|
||||
|
||||
Bool
|
||||
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
|
||||
|
||||
Bool
|
||||
PictureSetDefaultFilters (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
PictureResetFilters (ScreenPtr pScreen);
|
||||
|
||||
PictFilterPtr
|
||||
PictureFindFilter (ScreenPtr pScreen, char *name, int len);
|
||||
|
||||
int
|
||||
SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
|
||||
xFixed *params, int nparams);
|
||||
|
||||
int
|
||||
SetPictureFilter (PicturePtr pPicture, char *name, int len,
|
||||
xFixed *params, int nparams);
|
||||
|
||||
Bool
|
||||
PictureFinishInit (void);
|
||||
|
||||
void
|
||||
SetPictureToDefaults (PicturePtr pPicture);
|
||||
|
||||
PicturePtr
|
||||
AllocatePicture (ScreenPtr pScreen);
|
||||
|
||||
#if 0
|
||||
Bool
|
||||
miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
|
||||
#endif
|
||||
|
||||
|
||||
PicturePtr
|
||||
CreatePicture (Picture pid,
|
||||
DrawablePtr pDrawable,
|
||||
PictFormatPtr pFormat,
|
||||
Mask mask,
|
||||
XID *list,
|
||||
ClientPtr client,
|
||||
int *error);
|
||||
|
||||
int
|
||||
ChangePicture (PicturePtr pPicture,
|
||||
Mask vmask,
|
||||
XID *vlist,
|
||||
DevUnion *ulist,
|
||||
ClientPtr client);
|
||||
|
||||
int
|
||||
SetPictureClipRects (PicturePtr pPicture,
|
||||
int xOrigin,
|
||||
int yOrigin,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
|
||||
int
|
||||
SetPictureClipRegion (PicturePtr pPicture,
|
||||
int xOrigin,
|
||||
int yOrigin,
|
||||
RegionPtr pRegion);
|
||||
|
||||
int
|
||||
SetPictureTransform (PicturePtr pPicture,
|
||||
PictTransform *transform);
|
||||
|
||||
void
|
||||
CopyPicture (PicturePtr pSrc,
|
||||
Mask mask,
|
||||
PicturePtr pDst);
|
||||
|
||||
void
|
||||
ValidatePicture(PicturePtr pPicture);
|
||||
|
||||
int
|
||||
FreePicture (void *pPicture,
|
||||
XID pid);
|
||||
|
||||
int
|
||||
FreePictFormat (void *pPictFormat,
|
||||
XID pid);
|
||||
|
||||
void
|
||||
CompositePicture (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
|
||||
void
|
||||
CompositeGlyphs (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int nlist,
|
||||
GlyphListPtr lists,
|
||||
GlyphPtr *glyphs);
|
||||
|
||||
void
|
||||
CompositeRects (CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
|
||||
void
|
||||
CompositeTrapezoids (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntrap,
|
||||
xTrapezoid *traps);
|
||||
|
||||
void
|
||||
CompositeTriangles (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntriangles,
|
||||
xTriangle *triangles);
|
||||
|
||||
void
|
||||
CompositeTriStrip (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int npoints,
|
||||
xPointFixed *points);
|
||||
|
||||
void
|
||||
CompositeTriFan (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int npoints,
|
||||
xPointFixed *points);
|
||||
|
||||
Bool
|
||||
PictureTransformPoint (PictTransformPtr transform,
|
||||
PictVectorPtr vector);
|
||||
|
||||
Bool
|
||||
PictureTransformPoint3d (PictTransformPtr transform,
|
||||
PictVectorPtr vector);
|
||||
|
||||
void RenderExtensionInit (void);
|
||||
|
||||
Bool
|
||||
AnimCurInit (ScreenPtr pScreen);
|
||||
|
||||
int
|
||||
AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor);
|
||||
|
||||
void
|
||||
AddTraps (PicturePtr pPicture,
|
||||
INT16 xOff,
|
||||
INT16 yOff,
|
||||
int ntraps,
|
||||
xTrap *traps);
|
||||
|
||||
PicturePtr
|
||||
CreateSolidPicture (Picture pid,
|
||||
xRenderColor *color,
|
||||
int *error);
|
||||
|
||||
PicturePtr
|
||||
CreateLinearGradientPicture (Picture pid,
|
||||
xPointFixed *p1,
|
||||
xPointFixed *p2,
|
||||
int nStops,
|
||||
xFixed *stops,
|
||||
xRenderColor *colors,
|
||||
int *error);
|
||||
|
||||
PicturePtr
|
||||
CreateRadialGradientPicture (Picture pid,
|
||||
xPointFixed *inner,
|
||||
xPointFixed *outer,
|
||||
xFixed innerRadius,
|
||||
xFixed outerRadius,
|
||||
int nStops,
|
||||
xFixed *stops,
|
||||
xRenderColor *colors,
|
||||
int *error);
|
||||
|
||||
PicturePtr
|
||||
CreateConicalGradientPicture (Picture pid,
|
||||
xPointFixed *center,
|
||||
xFixed angle,
|
||||
int nStops,
|
||||
xFixed *stops,
|
||||
xRenderColor *colors,
|
||||
int *error);
|
||||
|
||||
#ifdef PANORAMIX
|
||||
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_ */
|
||||
3344
nx-X11/programs/Xserver/render/render.c
Normal file
3344
nx-X11/programs/Xserver/render/render.c
Normal file
File diff suppressed because it is too large
Load Diff
202
nx-X11/programs/Xserver/render/renderedge.c
Normal file
202
nx-X11/programs/Xserver/render/renderedge.c
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* $Id: renderedge.c,v 1.4 2005/07/03 07:02:08 daniels Exp $
|
||||
*
|
||||
* Copyright © 2004 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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 "renderedge.h"
|
||||
|
||||
/*
|
||||
* Compute the smallest value no less than y which is on a
|
||||
* grid row
|
||||
*/
|
||||
|
||||
xFixed
|
||||
RenderSampleCeilY (xFixed y, int n)
|
||||
{
|
||||
xFixed f = xFixedFrac(y);
|
||||
xFixed i = xFixedFloor(y);
|
||||
|
||||
f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
|
||||
if (f > Y_FRAC_LAST(n))
|
||||
{
|
||||
f = Y_FRAC_FIRST(n);
|
||||
i += xFixed1;
|
||||
}
|
||||
return (i | f);
|
||||
}
|
||||
|
||||
#define _div(a,b) ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
|
||||
|
||||
/*
|
||||
* Compute the largest value no greater than y which is on a
|
||||
* grid row
|
||||
*/
|
||||
xFixed
|
||||
RenderSampleFloorY (xFixed y, int n)
|
||||
{
|
||||
xFixed f = xFixedFrac(y);
|
||||
xFixed i = xFixedFloor (y);
|
||||
|
||||
f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
|
||||
if (f < Y_FRAC_FIRST(n))
|
||||
{
|
||||
f = Y_FRAC_LAST(n);
|
||||
i -= xFixed1;
|
||||
}
|
||||
return (i | f);
|
||||
}
|
||||
|
||||
/*
|
||||
* Step an edge by any amount (including negative values)
|
||||
*/
|
||||
void
|
||||
RenderEdgeStep (RenderEdge *e, int n)
|
||||
{
|
||||
xFixed_48_16 ne;
|
||||
|
||||
e->x += n * e->stepx;
|
||||
|
||||
ne = e->e + n * (xFixed_48_16) e->dx;
|
||||
|
||||
if (n >= 0)
|
||||
{
|
||||
if (ne > 0)
|
||||
{
|
||||
int nx = (ne + e->dy - 1) / e->dy;
|
||||
e->e = ne - nx * (xFixed_48_16) e->dy;
|
||||
e->x += nx * e->signdx;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ne <= -e->dy)
|
||||
{
|
||||
int nx = (-ne) / e->dy;
|
||||
e->e = ne + nx * (xFixed_48_16) e->dy;
|
||||
e->x -= nx * e->signdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A private routine to initialize the multi-step
|
||||
* elements of an edge structure
|
||||
*/
|
||||
static void
|
||||
_RenderEdgeMultiInit (RenderEdge *e, int n, xFixed *stepx_p, xFixed *dx_p)
|
||||
{
|
||||
xFixed stepx;
|
||||
xFixed_48_16 ne;
|
||||
|
||||
ne = n * (xFixed_48_16) e->dx;
|
||||
stepx = n * e->stepx;
|
||||
if (ne > 0)
|
||||
{
|
||||
int nx = ne / e->dy;
|
||||
ne -= nx * e->dy;
|
||||
stepx += nx * e->signdx;
|
||||
}
|
||||
*dx_p = ne;
|
||||
*stepx_p = stepx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize one edge structure given the line endpoints and a
|
||||
* starting y value
|
||||
*/
|
||||
void
|
||||
RenderEdgeInit (RenderEdge *e,
|
||||
int n,
|
||||
xFixed y_start,
|
||||
xFixed x_top,
|
||||
xFixed y_top,
|
||||
xFixed x_bot,
|
||||
xFixed y_bot)
|
||||
{
|
||||
xFixed dx, dy;
|
||||
|
||||
e->x = x_top;
|
||||
e->e = 0;
|
||||
dx = x_bot - x_top;
|
||||
dy = y_bot - y_top;
|
||||
e->dy = dy;
|
||||
e->dx = 0;
|
||||
if (dy)
|
||||
{
|
||||
if (dx >= 0)
|
||||
{
|
||||
e->signdx = 1;
|
||||
e->stepx = dx / dy;
|
||||
e->dx = dx % dy;
|
||||
e->e = -dy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e->signdx = -1;
|
||||
e->stepx = -(-dx / dy);
|
||||
e->dx = -dx % dy;
|
||||
e->e = 0;
|
||||
}
|
||||
|
||||
_RenderEdgeMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
|
||||
_RenderEdgeMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
|
||||
}
|
||||
RenderEdgeStep (e, y_start - y_top);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize one edge structure given a line, starting y value
|
||||
* and a pixel offset for the line
|
||||
*/
|
||||
void
|
||||
RenderLineFixedEdgeInit (RenderEdge *e,
|
||||
int n,
|
||||
xFixed y,
|
||||
xLineFixed *line,
|
||||
int x_off,
|
||||
int y_off)
|
||||
{
|
||||
xFixed x_off_fixed = IntToxFixed(x_off);
|
||||
xFixed y_off_fixed = IntToxFixed(y_off);
|
||||
xPointFixed *top, *bot;
|
||||
|
||||
if (line->p1.y <= line->p2.y)
|
||||
{
|
||||
top = &line->p1;
|
||||
bot = &line->p2;
|
||||
}
|
||||
else
|
||||
{
|
||||
top = &line->p2;
|
||||
bot = &line->p1;
|
||||
}
|
||||
RenderEdgeInit (e, n, y,
|
||||
top->x + x_off_fixed,
|
||||
top->y + y_off_fixed,
|
||||
bot->x + x_off_fixed,
|
||||
bot->y + y_off_fixed);
|
||||
}
|
||||
|
||||
120
nx-X11/programs/Xserver/render/renderedge.h
Normal file
120
nx-X11/programs/Xserver/render/renderedge.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* $Id: renderedge.h,v 1.4 2005/08/24 11:18:33 daniels Exp $
|
||||
*
|
||||
* Copyright © 2004 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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.
|
||||
*/
|
||||
|
||||
#ifndef _RENDEREDGE_H_
|
||||
#define _RENDEREDGE_H_
|
||||
|
||||
#include "picturestr.h"
|
||||
|
||||
#define MAX_ALPHA(n) ((1 << (n)) - 1)
|
||||
#define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n)/2)) - 1)
|
||||
#define N_X_FRAC(n) ((1 << ((n)/2)) + 1)
|
||||
|
||||
#define STEP_Y_SMALL(n) (xFixed1 / N_Y_FRAC(n))
|
||||
#define STEP_Y_BIG(n) (xFixed1 - (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
|
||||
|
||||
#define Y_FRAC_FIRST(n) (STEP_Y_SMALL(n) / 2)
|
||||
#define Y_FRAC_LAST(n) (Y_FRAC_FIRST(n) + (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
|
||||
|
||||
#define STEP_X_SMALL(n) (xFixed1 / N_X_FRAC(n))
|
||||
#define STEP_X_BIG(n) (xFixed1 - (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
|
||||
|
||||
#define X_FRAC_FIRST(n) (STEP_X_SMALL(n) / 2)
|
||||
#define X_FRAC_LAST(n) (X_FRAC_FIRST(n) + (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
|
||||
|
||||
#define RenderSamplesX(x,n) ((n) == 1 ? 0 : (xFixedFrac (x) + X_FRAC_FIRST(n)) / STEP_X_SMALL(n))
|
||||
|
||||
/*
|
||||
* An edge structure. This represents a single polygon edge
|
||||
* and can be quickly stepped across small or large gaps in the
|
||||
* sample grid
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
xFixed x;
|
||||
xFixed e;
|
||||
xFixed stepx;
|
||||
xFixed signdx;
|
||||
xFixed dy;
|
||||
xFixed dx;
|
||||
|
||||
xFixed stepx_small;
|
||||
xFixed stepx_big;
|
||||
xFixed dx_small;
|
||||
xFixed dx_big;
|
||||
} RenderEdge;
|
||||
|
||||
/*
|
||||
* Step across a small sample grid gap
|
||||
*/
|
||||
#define RenderEdgeStepSmall(edge) { \
|
||||
edge->x += edge->stepx_small; \
|
||||
edge->e += edge->dx_small; \
|
||||
if (edge->e > 0) \
|
||||
{ \
|
||||
edge->e -= edge->dy; \
|
||||
edge->x += edge->signdx; \
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
* Step across a large sample grid gap
|
||||
*/
|
||||
#define RenderEdgeStepBig(edge) { \
|
||||
edge->x += edge->stepx_big; \
|
||||
edge->e += edge->dx_big; \
|
||||
if (edge->e > 0) \
|
||||
{ \
|
||||
edge->e -= edge->dy; \
|
||||
edge->x += edge->signdx; \
|
||||
} \
|
||||
}
|
||||
|
||||
xFixed
|
||||
RenderSampleCeilY (xFixed y, int bpp);
|
||||
|
||||
xFixed
|
||||
RenderSampleFloorY (xFixed y, int bpp);
|
||||
|
||||
void
|
||||
RenderEdgeStep (RenderEdge *e, int n);
|
||||
|
||||
void
|
||||
RenderEdgeInit (RenderEdge *e,
|
||||
int bpp,
|
||||
xFixed y_start,
|
||||
xFixed x_top,
|
||||
xFixed y_top,
|
||||
xFixed x_bot,
|
||||
xFixed y_bot);
|
||||
|
||||
void
|
||||
RenderLineFixedEdgeInit (RenderEdge *e,
|
||||
int bpp,
|
||||
xFixed y,
|
||||
xLineFixed *line,
|
||||
int x_off,
|
||||
int y_off);
|
||||
|
||||
#endif /* _RENDEREDGE_H_ */
|
||||
Reference in New Issue
Block a user