Commit 11c6e363 authored by faith's avatar faith
Browse files

Import of XFree86 3.9.17

parent 0387caff
XCOMM $XFree86: xc/programs/Xserver/fb/Imakefile,v 1.1 1999/11/19 13:53:40 hohndel Exp $
XCOMM
XCOMM
XCOMM $Id: Imakefile,v 1.1.1.1 2000/01/06 12:56:51 faith Exp $
#include <Server.tmpl>
#ifdef FbNoPixelAddrCode
DEFINES=-DFBNOPIXADDR -DFBNO24BIT
#endif
SRCS = fbarc.c \
fballpriv.c \
fbbits.c \
fbblt.c \
fbbltone.c \
fbbstore.c \
fbcmap.c \
fbcopy.c \
fbfill.c \
fbfillrect.c \
fbfillsp.c \
fbgc.c \
fbgetsp.c \
fbglyph.c \
fbimage.c \
fbline.c \
fbpixmap.c \
fbpoint.c \
fbpush.c \
fbscreen.c \
fbseg.c \
fbsetsp.c \
fbsolid.c \
fbstipple.c \
fbtile.c \
fbutil.c \
fbwindow.c
OBJS = fbarc.o \
fballpriv.o \
fbbits.o \
fbblt.o \
fbbltone.o \
fbbstore.o \
fbcmap.o \
fbcopy.o \
fbfill.o \
fbfillrect.o \
fbfillsp.o \
fbgc.o \
fbgetsp.o \
fbglyph.o \
fbimage.o \
fbline.o \
fbpixmap.o \
fbpoint.o \
fbpush.o \
fbscreen.o \
fbseg.o \
fbsetsp.o \
fbsolid.o \
fbstipple.o \
fbtile.o \
fbutil.o \
fbwindow.o
INCLUDES = -I. -I../mi -I../include -I$(XINCLUDESRC) \
-I$(FONTINCSRC) $(EXTRAINCLUDES)
LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln \
../mi/llib-lmi.ln
CCOPTIONS=-ansi
NormalLibraryObjectRule()
NormalLibraryTarget(fb,$(OBJS))
LintLibraryTarget(fb,$(SRCS))
NormalLintTarget($(SRCS))
#ifndef OS2Architecture
DependTarget()
#endif
This diff is collapsed.
/*
* $Id: fballpriv.c,v 1.1.1.1 2000/01/06 12:56:51 faith Exp $
*
* Copyright © 1998 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.
*/
/* $XFree86: xc/programs/Xserver/fb/fballpriv.c,v 1.2 1999/12/30 02:33:58 robin Exp $ */
#include "fb.h"
int fbGCPrivateIndex;
int fbGeneration;
#ifdef FB_OLD_SCREEN
#define miAllocateGCPrivateIndex() AllocateGCPrivateIndex()
#endif
Bool
fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
{
if (fbGeneration != serverGeneration)
{
fbGCPrivateIndex = miAllocateGCPrivateIndex ();
fbGeneration = serverGeneration;
}
if (pGCIndex)
*pGCIndex = fbGCPrivateIndex;
if (!AllocateGCPrivate(pScreen, fbGCPrivateIndex, sizeof(FbGCPrivRec)))
return FALSE;
return TRUE;
}
/*
* $Id: fbarc.c,v 1.1.1.1 2000/01/06 12:56:51 faith Exp $
*
* Copyright © 1998 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.
*/
/* $XFree86: xc/programs/Xserver/fb/fbarc.c,v 1.1 1999/11/19 13:53:41 hohndel Exp $ */
#include "fb.h"
#include "mizerarc.h"
typedef void (*FbArc) (FbBits *dst,
FbStride dstStride,
int dstBpp,
xArc *arc,
int dx,
int dy,
FbBits and,
FbBits xor);
void
fbPolyArc (DrawablePtr pDrawable,
GCPtr pGC,
int narcs,
xArc *parcs)
{
FbArc arc;
if (pGC->lineWidth == 0)
{
#ifndef FBNOPIXADDR
arc = 0;
if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid)
{
switch (pDrawable->bitsPerPixel)
{
case 8: arc = fbArc8; break;
case 16: arc = fbArc16; break;
case 32: arc = fbArc32; break;
}
}
if (arc)
{
FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
FbBits *dst;
FbStride dstStride;
int dstBpp;
BoxRec box;
int x2, y2;
RegionPtr cclip;
cclip = fbGetCompositeClip (pGC);
fbGetDrawable (pDrawable, dst, dstStride, dstBpp);
while (narcs--)
{
if (miCanZeroArc (parcs))
{
box.x1 = parcs->x + pDrawable->x;
box.y1 = parcs->y + pDrawable->y;
/*
* Because box.x2 and box.y2 get truncated to 16 bits, and the
* RECT_IN_REGION test treats the resulting number as a signed
* integer, the RECT_IN_REGION test alone can go the wrong way.
* This can result in a server crash because the rendering
* routines in this file deal directly with cpu addresses
* of pixels to be stored, and do not clip or otherwise check
* that all such addresses are within their respective pixmaps.
* So we only allow the RECT_IN_REGION test to be used for
* values that can be expressed correctly in a signed short.
*/
x2 = box.x1 + (int)parcs->width + 1;
box.x2 = x2;
y2 = box.y1 + (int)parcs->height + 1;
box.y2 = y2;
if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
(RECT_IN_REGION(pDrawable->pScreen, cclip, &box) == rgnIN) )
(*arc) (dst, dstStride, dstBpp,
parcs, pDrawable->x, pDrawable->y,
pPriv->and, pPriv->xor);
else
miZeroPolyArc(pDrawable, pGC, 1, parcs);
}
parcs++;
}
}
else
#endif
miZeroPolyArc (pDrawable, pGC, narcs, parcs);
}
else
miPolyArc (pDrawable, pGC, narcs, parcs);
}
/*
* $Id: fbbits.c,v 1.1.1.1 2000/01/06 12:56:51 faith Exp $
*
* Copyright 1998 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.
*/
/* $XFree86: xc/programs/Xserver/fb/fbbits.c,v 1.1 1999/11/19 13:53:41 hohndel Exp $ */
#include "fb.h"
#include "miline.h"
#include "mizerarc.h"
#define BRESSOLID fbBresSolid8
#define BRESDASH fbBresDash8
#define DOTS fbDots8
#define ARC fbArc8
#define GLYPH fbGlyph8
#define BITS BYTE
#define BITS2 CARD16
#define BITS4 CARD32
#include "fbbits.h"
#undef BRESSOLID
#undef BRESDASH
#undef DOTS
#undef ARC
#undef GLYPH
#undef BITS
#undef BITS2
#undef BITS4
#define BRESSOLID fbBresSolid16
#define BRESDASH fbBresDash16
#define DOTS fbDots16
#define ARC fbArc16
#define GLYPH fbGlyph16
#define BITS CARD16
#define BITS2 CARD32
#if FB_SHIFT == 6
#define BITS4 FbBits
#endif
#include "fbbits.h"
#undef BRESSOLID
#undef BRESDASH
#undef DOTS
#undef ARC
#undef GLYPH
#undef BITS
#undef BITS2
#if FB_SHIFT == 6
#undef BITS4
#endif
#define BRESSOLID fbBresSolid32
#define BRESDASH fbBresDash32
#define DOTS fbDots32
#define ARC fbArc32
#define GLYPH fbGlyph32
#define BITS CARD32
#if FB_SHIFT == 6
#define BITS2 FbBits
#endif
#include "fbbits.h"
#undef BRESSOLID
#undef BRESDASH
#undef DOTS
#undef ARC
#undef GLYPH
#undef BITS
#if FB_SHIFT == 6
#undef BITS2
#endif
/*
* $Id: fbbits.h,v 1.1.1.1 2000/01/06 12:56:52 faith Exp $
*
* Copyright 1998 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.
*/
/* $XFree86: xc/programs/Xserver/fb/fbbits.h,v 1.2 1999/12/30 02:33:58 robin Exp $ */
/*
* This file defines functions for drawing some primitives using
* underlying datatypes instead of masks
*/
/*
* Define the following before including this file:
*
* BRESSOLID name of function for drawing a solid segment
* BRESDASH name of function for drawing a dashed segment
* DOTS name of function for drawing dots
* ARC name of function for drawing a solid arc
* BITS type of underlying unit
*/
void
BRESSOLID (DrawablePtr pDrawable,
GCPtr pGC,
int dashOffset,
int signdx,
int signdy,
int axis,
int x1,
int y1,
int e,
int e1,
int e3,
int len)
{
FbBits *dst;
FbStride dstStride;
int dstBpp;
FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
BITS *bits;
FbStride bitsStride;
FbStride majorStep, minorStep;
BITS xor = (BITS) pPriv->xor;
fbGetDrawable (pDrawable, dst, dstStride, dstBpp);
bits = ((BITS *) (dst + (y1 * dstStride))) + x1;
bitsStride = dstStride * (sizeof (FbBits) / sizeof (BITS));
if (signdy < 0)
bitsStride = -bitsStride;
if (axis == X_AXIS)
{
majorStep = signdx;
minorStep = bitsStride;
}
else
{
majorStep = bitsStride;
minorStep = signdx;
}
while (len--)
{
*bits = xor;
bits += majorStep;
e += e1;
if (e >= 0)
{
bits += minorStep;
e += e3;
}
}
}
void
BRESDASH (DrawablePtr pDrawable,
GCPtr pGC,
int dashOffset,
int signdx,
int signdy,
int axis,
int x1,
int y1,
int e,
int e1,
int e3,
int len)
{
FbBits *dst;
FbStride dstStride;
int dstBpp;
FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
BITS *bits;
FbStride bitsStride;
FbStride majorStep, minorStep;
BITS xor = (BITS) pPriv->xor;
BITS bgxor = (BITS) pPriv->bgxor;
unsigned char *dash, *lastDash;
int dashlen;
Bool even;
Bool doOdd;
fbGetDrawable (pDrawable, dst, dstStride, dstBpp);
doOdd = pGC->lineStyle == LineDoubleDash;
even = TRUE;
dash = pGC->dash;
lastDash = dash + pGC->numInDashList;
dashOffset %= pPriv->dashLength;
while (dashOffset >= *dash)
{
dashOffset -= *dash++;
if (dash == lastDash)
dash = pGC->dash;
even = !even;
}
dashlen = *dash - dashOffset;
bits = ((BITS *) (dst + (y1 * dstStride))) + x1;
bitsStride = dstStride * (sizeof (FbBits) / sizeof (BITS));
if (signdy < 0)
bitsStride = -bitsStride;
if (axis == X_AXIS)
{
majorStep = signdx;
minorStep = bitsStride;
}
else
{
majorStep = bitsStride;
minorStep = signdx;
}
while (len--)
{
if (even)
*bits = xor;
else if (doOdd)
*bits = bgxor;
bits += majorStep;
e += e1;
if (e >= 0)
{
bits += minorStep;
e += e3;
}
if (!--dashlen)
{
if (++dash == lastDash)
dash = pGC->dash;
dashlen = *dash;
even = !even;
}
}
}
void
DOTS (FbBits *dst,
FbStride dstStride,
int dstBpp,
BoxPtr pBox,
xPoint *pts,
int npt,
FbBits and,
FbBits xor)
{
BITS *bits = (BITS *) dst;
BITS fg = (BITS) xor;
FbStride bitsStride = dstStride * (sizeof (FbBits) / sizeof (BITS));
int x1, y1, x2, y2;
int x, y;
x1 = pBox->x1;
y1 = pBox->y1;
x2 = pBox->x2;
y2 = pBox->y2;
while (npt--)
{
x = pts->x;
y = pts->y;
pts++;
if (x1 <= x && x < x2 && y1 <= y && y < y2)
*(bits + y * bitsStride + x) = fg;
}
}
void
ARC (FbBits *dst,
FbStride dstStride,
int dstBpp,
xArc *arc,
int drawX,
int drawY,
FbBits and,
FbBits xor)
{
BITS *bits;
FbStride bitsStride;
miZeroArcRec info;
Bool do360;
int x;
BITS *addrp;
BITS *yorgp, *yorgop;
BITS andBits, xorBits;
int yoffset, dyoffset;
int y, a, b, d, mask;
int k1, k3, dx, dy;
bits = (BITS *) dst;
bitsStride = dstStride * (sizeof (FbBits) / sizeof (BITS));
andBits = (BITS) and;
xorBits = (BITS) xor;
do360 = miZeroArcSetup(arc, &info, TRUE);
yorgp = bits + ((info.yorg + drawY) * bitsStride);
yorgop = bits + ((info.yorgo + drawY) * bitsStride);
info.xorg += drawX;
info.xorgo += drawX;
MIARCSETUP();
yoffset = y ? bitsStride : 0;
dyoffset = 0;
mask = info.initialMask;
#define COPY(d) *(d) = xorBits;
#define RROP(d) *(d) = FbDoRRop (*(d), andBits, xorBits)
if (!(arc->width & 1))
{
if (mask & 2)
RROP(yorgp + info.xorgo);
if (mask & 8)
RROP(yorgop + info.xorgo);
}
if (!info.end.x || !info.end.y)
{
mask = info.end.mask;
info.end = info.altend;
}
if (do360 && (arc->width == arc->height) && !(arc->width & 1))
{
int xoffset = bitsStride;
BITS *yorghb = yorgp + (info.h * bitsStride) + info.xorg;
BITS *yorgohb = yorghb - info.h;
yorgp += info.xorg;
yorgop += info.xorg;
yorghb += info.h;
while (1)
{
if (andBits == 0)
{
COPY(yorgp + yoffset + x);
COPY(yorgp + yoffset - x);
COPY(yorgop - yoffset - x);
COPY(yorgop - yoffset + x);
}
else
{
RROP(yorgp + yoffset + x);
RROP(yorgp + yoffset - x);
RROP(yorgop - yoffset - x);
RROP(yorgop - yoffset + x);
}
if (a < 0)
break;
if (andBits == 0)
{
COPY(yorghb - xoffset - y);
COPY(yorgohb - xoffset + y);
COPY(yorgohb + xoffset + y);
COPY(yorghb + xoffset - y);
}
else
{
RROP(yorghb - xoffset - y);
RROP(yorgohb - xoffset + y);