diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:57 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:57 +0000 |
commit | 9508a382f8a9f241dab097d921b6d290c1c3a776 (patch) | |
tree | fa456480bae7040c3f971a70b390f2d091c680b5 /hw/xfree86/xf4bpp | |
parent | ded6147bfb5d75ff1e67c858040a628b61bc17d1 (diff) |
Initial revision
Diffstat (limited to 'hw/xfree86/xf4bpp')
48 files changed, 12458 insertions, 0 deletions
diff --git a/hw/xfree86/xf4bpp/NOTES b/hw/xfree86/xf4bpp/NOTES new file mode 100644 index 000000000..f9ccc95c1 --- /dev/null +++ b/hw/xfree86/xf4bpp/NOTES @@ -0,0 +1,194 @@ +This code originally hails from IBM. It was ported to an early XFree86 by +Gertjan Akkerman, whose BUGS file I append here. + +In turn, this is a port of Gertjan's work to the new server design. Among the +changes are: + +- The removal of almost all unreferenced code. +- The removal of this code's own copy of mfb (xf1bpp is used instead). +- The removal of banking support (mibank is used instead). +- External symbols were made static where this was sufficient. +- The remaining external names were renamed to xf4bpp*. +- Several minor cleanups too many to mention here. + +To understate the matter, this code is >UGLY<. This seems inherent in IBM's +corporate culture. Be that as it may, it *does* survive X11R4's xtest +(whatever that means these days...). For now, this is sufficient for 4bpp +support in the new design, but at some point, I'll have to sit down and +rewrite this from scratch. A more technical justification for a rewrite is +that the pixmap format is 8bpp, instead of 4bpp, which is causing me to +pepper the rest of the server with unclean accomodations. + +Marc. + +=============================================================================== +Section 1: From IBM's X11R4 contribution towards XFree86. + +This section describes what I did to obtain a 16 colour vga server. + +I started with the SYSV, ppc, vga and common directories from IBM's X11R4 +contribution. Those directories have the following function: +1. SYSV implements the mouse and keyboard. +2. ppc is a generic layer implementing ddx in terms of drawing operations + through rectangles. (With spans as a boundary case: height = 1.) +3. vga implements a layer of operations drawing through rectangles. +4. common implements ddx initialization and quitting, and screen saving. + +I eliminated SYSV and common since the functionality provided therein is +already provided in XFree86. Since XFree86 is actively being ported to +new operating systems, while X11R4 is out of date, I preferred the XFree86 +code here above the SYSV and common code. +Whatever functionality was still needed from common (default colormap +initialization -- not much code) was moved into ppc. + +Since XFree86 uses the mi-provided software cursor code, IBM's software +cursor code was deleted from ppc and vga. This is a pity, since it is +expected that it is more efficient than mi's code, but the XFree86 mouse and +keyboard code directly call mi, and I do not want to maintain the XFree86 +mouse and keyboard code. + +Since we cannot support a monolithic multi-screen server using all of the +x11r4 contributed code yet, all multi screen code was deleted. This includes +one header file containing a nasty copyright statement. + +Since glyph handling has changed between X11R4 and X11R5, the code handling +glyphs was replaced by appropriate calls to mi. +I hope it can be modified and put back one day. + +Provisionally, some code was added (viz. file vga/offscreen.c) to intercept +calls to the rectangle drawing code when we are switched out of the VT. +I hope this can be replaced by some window tree invalidation and GC validation +scheme. + + +Section 2: BUGS + +This section describes fixed and still unfixed bugs in this code. +All bugs not labeled otherwise also occur in IBM's X11R4 code, and may be of +interest to anybody using that code. + +1. (Fixed.) +I found (and provisionally fixed) a bug in the IBM bitblit code: +In file ddx/ibm/vga/vgaImages.c a function vgaReadColorImage is defined. +When this function is used to read less than 8 pixels starting on a byte +boundary it will always read precisely 8 pixels. +Thus, when space is allocated for 4 or less pixels, it will write beyond +the allocated space. +Since the code is rather convoluted, this may not be apparent at first sight, +but going through the code with an example shows the error. + +2. (Fixed.) +In ppcPixmapFS.c, function ppcStipplePixmapFS there was a bug +regarding the stipple origin: The horizontal origin is added while +the vertical one is subtracted. The horizontal origin should be subtracted +instead of added here. +This bug gets visible when backing-store is enabled and one uses twm: +the submenu icons get truncated on their left hand side. +(In case you wonder why this bug appears: under those circumstances +twm prepares its menus by drawing into an unmapped window. +The miCopyPlane function uses the ppcStipplePixmap (and many others) +to get the plane copied.) +I also fixed this bug in the other routines (ppcOpStipplePixmapFS, +ppcTilePixmapFS) in this file, although I had no visible clues for this. +I hope this is appropriate. + +3. (Fixed.) +I find it suspect that ppcSetSpans gives different output when one +claims that an actually sorted list of spans is unsorted. +The unsorted code is wrong, and should be made to look more like the sorted +code. I.e., use ( xStart - ppt->x ) instead of ( xStart - pbox->x1 ) + +4. (Fixed.) +There used to be another bug that became visible when using twm and backing +store: popping up a submenu, and moving the cursor upwards til it leaves the +submenu, the submenu would disappears, as it should. +But the submenu icon would not get restored, while it should be. +10b. By replacing the clip-computing code in ppcValidateGC by that in +cfbValidateGC, I *finally* fixed the disappearing twm menu icon problem. + +5. Added mfbRegisterCopyplaneProc call. [Its omission was an error on my + part.] + Fixing a server core dump in XTest. + +6. Fixed not-very-high tile bug in function ppcTileRect, file emulTile.c + (I.e., if the tile was higher than the area to be tiled, far too much + was drawn, causing server core dumps in XTest.) + Actually, "savey" ought to be used to determine the height of the tiles in + the top line to be tiled, instead of "pTile->drawable.height". +7. A use of height where width was intended was fixed in ppcTileRect: + "savehcount = w / pTile->drawable.height;" should use "... .width" and + "savehcount = ( x + w - htarget ) / pTile->drawable.height;" too. + +8. Deleted overly clever code in ppcCReduce.c + (All code that tried to pre-compute how alu's could be replaced by + other alu's with inverted colors, etc. was deleted. I think it is + at least wrong for FillSolid.) + +9. Looked at suspicious code in ppcSetSp.c + "tmpx = *pdst;" was never updated during the loop. We took it out of the + initialization position of the for and moved it into the loop. + +10. Add xSrc := GC->patOrg.x + pDrawable.x and ySrc := ... in ppcPixmapFS.c, + functions ppcStipplePixmapFS, ppcOpStipplePixmapFS, and ppcTilePixmapFS. + This because stipple and tile origins are taken relative to the drawable. + Also use a "modulo" function that gets the cases of a negative stipple + or tile offset right. (When the stipple origin is to the right of or + below the origin of the drawable.) + +11. File vgaSolid.c, function vgaFillSolid: + Inverting is XORing with all ones. Not with the color we want to AND/OR + later. So we'll have to set the color to VGA_ALLPLANES + whenever we want to invert existing data, and reset it before the + AND/OR is done. + Also we replaced an outb( 0x3CF, tmp2 ) by the SetVideoGraphicsData( tmp2 ) + it is representing. (Just a cosmetic replacement.) + +12. File vgaImages, function vgaDrawColorImage. + Moved a line "invert_existing_data = TRUE;" two lines down, past a case + label. Now it is also part of the code executed for GXorReverse, as it + should be. + +13. The pixmap FillSpans routines (file ppcPixmapFS.c) got somewhat better + after importing some code from ddx/ibm/vga. (A getbits function that does + wrapping.) + They were wrong for the FillStippled and FillOpaqueStippled modes. + I don't understand the old code. How could it handle stipples of a size not + an exact multiple of 32? (or 8, for that matter.) + +14. In function vgaBitBlt file vgaBitBlt.c, in the shortcuts for + GXSet, GXClear and GXInvert, the source (x0,y0) is accidentally operated + upon by vgaFillSolid, instead of the destination (x1,y1). + +15. Notice that in DoMonoSingle and DoMonoMany in file vgaStipple.c, the left + edge of the square to be stippled is treated wrong. + Correct would be to get the bits with getbits using offset xshift, and + to shift them right (x & 07) places. + [One might wish to use the variable tmp1 at this place, since it had been + set to (x & 07) at this place; but that is already re-used at this point.] + Also note that NeedValX is set wrong: The implicit assumption was that + stipples are more than 8 wide. + This only fixes the problem when miPushPixel is used instead of ppcPushPixel. + I think I should look some more into this. + +16. I took out some code of the CopyArea function, in which a no-op function + was called while a real one was needed. My fix does not completely work, + although it improved the behaviour of GetImage somewhat. + +17. After finding three kinds of errors in this single function, + -- the new kinds being the right side not being always written due to + an incorrect if scope, and the lower end not always being written due + to variables being updated at the wrong place -- + (requiring modifications to be made at at least 10 places, + I decided to REWRITE the body of the ppcTileRect function from scratch. + This version simply computes all relevant margins in advance, and does + not try to reuse temporary variables. I leave that to the compiler. + (This was a maintenance and robustness nightmare anyway.) + +MORE NOTES: + It is funny that there are two files in mi that require compilation + with the proper #defines ( -DXF86VGA16 in my case ): + Besides the obvious mibitblt.c, there is also mipushpxl.c. + + + +$XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/NOTES,v 1.2 1998/07/25 16:59:26 dawes Exp $ diff --git a/hw/xfree86/xf4bpp/OScompiler.h b/hw/xfree86/xf4bpp/OScompiler.h new file mode 100644 index 000000000..3891f1e21 --- /dev/null +++ b/hw/xfree86/xf4bpp/OScompiler.h @@ -0,0 +1,57 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/OScompiler.h,v 1.4 2000/07/26 01:52:26 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: OScompiler.h /main/4 1996/02/21 17:56:09 kaleb $ */ + +#ifndef __COMPILER_DEPENDANCIES__ +#define __COMPILER_DEPENDANCIES__ + +#define MOVE( src, dst, length ) memcpy( dst, src, length) +#define MAX(a,b) (((a)>(b))?(a):(b)) +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define ABS(x) (((x)>0)?(x):-(x)) + +#include "misc.h" +#include "xf86_ansic.h" +#include "compiler.h" + +#ifdef lint +/* So that lint doesn't complain about constructs it doesn't understand */ +#ifdef volatile +#undef volatile +#endif +#define volatile +#ifdef const +#undef const +#endif +#define const +#ifdef signed +#undef signed +#endif +#define signed +#ifdef _ANSI_DECLS_ +#undef _ANSI_DECLS_ +#endif +#endif + +#endif /* !__COMPILER_DEPENDANCIES__ */ diff --git a/hw/xfree86/xf4bpp/emulOpStip.c b/hw/xfree86/xf4bpp/emulOpStip.c new file mode 100644 index 000000000..e9ac98dc9 --- /dev/null +++ b/hw/xfree86/xf4bpp/emulOpStip.c @@ -0,0 +1,100 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/emulOpStip.c,v 1.3 1999/06/06 08:48:54 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: emulOpStip.c /main/4 1996/02/21 17:56:12 kaleb $ */ + +/* ppc OpaqueStipple + * + * Based on the private stipple; does a foreground, and then an inverted + * on the background + * + */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" + +void +xf4bppOpaqueStipple( pWin, pStipple, fg, bg, alu, planes, x, y, w, h, xSrc, ySrc ) +WindowPtr pWin; /* GJA */ +register PixmapPtr pStipple ; +unsigned long int fg ; +unsigned long int bg ; +int alu ; +unsigned long int planes ; +register int x, y, w, h ; +int xSrc, ySrc ; +{ + /* DO BACKGROUND */ + switch ( alu ) { + /* Easy Cases -- i.e. Final Result Doesn't Depend On Initial Dest. */ + case GXclear: /* 0x0 Zero 0 */ + case GXset: /* 0xf 1 */ + /* Foreground And Background Are Both The Same !! */ + xf4bppFillSolid( pWin, bg, alu, planes, x, y, w, h ) ; + case GXnoop: /* 0x5 dst */ + break ; + case GXcopy: /* 0x3 src */ + case GXcopyInverted: /* 0xc NOT src */ + { /* Special Case Code */ + register int vtarget, htarget ; + + /* We Can Draw Just One Copy Then Blit The Rest !! */ + /* Draw The One Copy */ + htarget = MIN( w, pStipple->drawable.width ) ; + vtarget = MIN( h, pStipple->drawable.height ) ; + + /* First The Background */ + xf4bppFillSolid( pWin, bg, alu, planes, x, y, + htarget, vtarget ) ; + /* Then The Foreground */ + xf4bppFillStipple( pWin, pStipple, fg, alu, planes, + x, y, htarget, vtarget, + xSrc, ySrc ) ; + + /* Here We Double The Size Of The BLIT Each Iteration */ + xf4bppReplicateArea(pWin, x, y, planes, w, h, htarget, vtarget); + } + break ; + default: + /* Hard Cases -- i.e. Final Result DOES Depend On Initial Dest. */ + { /* Do The Background */ + register int i, j; + register PixmapPtr pInvPixmap = xf4bppCopyPixmap( pStipple ) ; + register unsigned char *data = pInvPixmap->devPrivate.ptr ; + + /* INVERT PIXMAP OK, jeff, this is for you */ + for ( i = pInvPixmap->drawable.height ; i-- ; ) + for ( j = pInvPixmap->devKind ; j-- ; data++ ) + *data = ~ ( *data ) ; + + xf4bppFillStipple( pWin, pInvPixmap, bg, alu, planes, x, y, w, h, xSrc, ySrc ); + mfbDestroyPixmap( pInvPixmap ) ; + /* DO FOREGROUND */ + xf4bppFillStipple( pWin, pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc ); + } + break ; + } + return; +} diff --git a/hw/xfree86/xf4bpp/emulRepAre.c b/hw/xfree86/xf4bpp/emulRepAre.c new file mode 100644 index 000000000..42f118aac --- /dev/null +++ b/hw/xfree86/xf4bpp/emulRepAre.c @@ -0,0 +1,67 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/emulRepAre.c,v 1.3 1999/06/06 08:48:54 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: emulRepAre.c /main/5 1996/02/21 17:56:16 kaleb $ */ + +/* ppc Replicate Area -- A Divide & Conquer Algorithm + * a "ppc" Helper Function For Stipples And Tiling + * P. Shupak 1/88 + */ + +#include "xf4bpp.h" + +void xf4bppReplicateArea( pWin, x, y, planeMask, goalWidth, goalHeight, + currentHoriz, currentVert) +WindowPtr pWin; /* GJA */ +register int x, y, planeMask ; +int goalWidth, goalHeight ; +int currentHoriz, currentVert ; +{ + for ( ; + currentHoriz <= ( goalWidth >> 1 ) ; + currentHoriz <<= 1 ) { + xf4bppBitBlt( pWin, GXcopy, planeMask, + x, y, + x + currentHoriz, y, + currentHoriz, currentVert ) ; + } + if ( goalWidth - currentHoriz ) + xf4bppBitBlt( pWin, GXcopy, planeMask, + x, y, + x + currentHoriz, y, + goalWidth - currentHoriz, currentVert ) ; + for ( ; + currentVert <= ( goalHeight >> 1 ) ; + currentVert <<= 1 ) { + xf4bppBitBlt( pWin, GXcopy, planeMask, + x, y, + x, y + currentVert, + goalWidth, currentVert ) ; + } + if ( goalHeight - currentVert ) + xf4bppBitBlt( pWin, GXcopy, planeMask, + x, y, + x, y + currentVert, + goalWidth, goalHeight - currentVert ) ; +return ; +} diff --git a/hw/xfree86/xf4bpp/emulTile.c b/hw/xfree86/xf4bpp/emulTile.c new file mode 100644 index 000000000..a2d24f4d9 --- /dev/null +++ b/hw/xfree86/xf4bpp/emulTile.c @@ -0,0 +1,352 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/emulTile.c,v 1.3 1999/06/06 08:48:54 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: emulTile.c /main/4 1996/02/21 17:56:23 kaleb $ */ + +/* ppc Tile + * P. Shupak 11/87 + * Modified From original ppc Tile + * T. Paquin 9/87 + * Uses private imageFill a bunch of times + */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "ibmTrace.h" + +static void +DrawFirstTile +( + WindowPtr pWin, /* GJA */ + register PixmapPtr pTile, + register int x, + register int y, + int w, + int h, + int alu, + unsigned long int planes, + int xOffset, + int yOffset +) +{ +register int htarget ; +register int vtarget ; + + if ( xOffset ) { /* Not X-Aligned */ + if ( yOffset ) { /* Nor Y-Aligned */ + htarget = MIN( pTile->drawable.width - xOffset, w ), + vtarget = MIN( pTile->drawable.height - yOffset, h ), + yOffset *= pTile->devKind ; + xf4bppDrawColorImage( pWin,x, y, + htarget, + vtarget, + (unsigned char *)pTile->devPrivate.ptr + yOffset + xOffset, + pTile->devKind, + alu, planes ) ; + if ( w > htarget ) { + w = MIN( w, pTile->drawable.width ) ; + if ( h > vtarget ) { + h = MIN( h, pTile->drawable.height ) ; + xf4bppDrawColorImage( pWin, x, y + vtarget, + htarget, + h - vtarget, + (unsigned char *)pTile->devPrivate.ptr + xOffset, + pTile->devKind, + alu, planes ) ; + xf4bppDrawColorImage( pWin, x + htarget, y, + w - htarget, + vtarget, + (unsigned char *)pTile->devPrivate.ptr + yOffset, + pTile->devKind, + alu, planes ) ; + xf4bppDrawColorImage( pWin, x + htarget, + y + vtarget, + w - htarget, + h - vtarget, + pTile->devPrivate.ptr, + pTile->devKind, + alu, planes ) ; + } + else { /* h <= vtarget */ + xf4bppDrawColorImage( pWin, x + htarget, y, + w - htarget, + vtarget, + (unsigned char *)pTile->devPrivate.ptr + yOffset, + pTile->devKind, + alu, planes ) ; + } + } + else if ( h > vtarget ) { + xf4bppDrawColorImage( pWin, x, y + vtarget, + htarget, + MIN( h, pTile->drawable.height ) - vtarget, + (unsigned char *)pTile->devPrivate.ptr + xOffset, + pTile->devKind, + alu, planes ) ; + vtarget = pTile->drawable.height ; + } + } + else { /* No Y Offset */ + xf4bppDrawColorImage( pWin, x, y, + htarget = MIN( pTile->drawable.width - xOffset, w ), + vtarget = MIN( pTile->drawable.height, h ), + (unsigned char *)pTile->devPrivate.ptr + xOffset, + pTile->devKind, + alu, planes ) ; + if ( w > htarget ) { + xf4bppDrawColorImage( pWin, x + htarget, y, + MIN( pTile->drawable.width, w ) - htarget, + vtarget, + pTile->devPrivate.ptr, + pTile->devKind, + alu, planes ) ; + } + } + } + else if ( yOffset ) { + xf4bppDrawColorImage( pWin, x, y, + htarget = MIN( pTile->drawable.width, w ), + vtarget = MIN( pTile->drawable.height - yOffset, h ), + (unsigned char *)pTile->devPrivate.ptr + ( yOffset * pTile->devKind ), + pTile->devKind, + alu, planes ) ; + if ( h > vtarget ) { + xf4bppDrawColorImage( pWin, x, y + vtarget, + htarget, + MIN( pTile->drawable.height, h ) - vtarget, + pTile->devPrivate.ptr, + pTile->devKind, + alu, planes ) ; + } + } + else { /* NO Offset */ + xf4bppDrawColorImage( pWin, x, y, + htarget = MIN( pTile->drawable.width, w ), + vtarget = MIN( pTile->drawable.height, h ), + pTile->devPrivate.ptr, + pTile->devKind, + alu, planes ) ; + } + + return ; +} + +/* GJA -- + * After finding three kinds of errors in this single function, + * (requiring modifications to be made at at least 10 places, + * I decided to REWRITE the body of the xf4bppTileRect function from scratch. + * This version simply computes all relevant margins in advance, and does + * not try to reuse temporary variables. I leave that to the compiler. + * (This was a maintenance and robustness nightmare anyway.) + * The code is pretty obvious: all margins, coordinates, and numbers of tiles + * are computed before drawing starts. + * Notice that the margins consist of incompletely drawn tiles. Therefore + * we need offsets in the data for the left and upper margins. + * The right and lower margins are also incomplete, but start at offset 0 + * in the data. They just end at awkward offsets. + * The center block, by definition, consists of fully drawn tiles. + * Perhaps we could leave out some if's. But why bother? It would decrease + * robustness. + */ +void +xf4bppTileRect( pWin, pTile, alu, planes, x0, y0, w, h, xSrc, ySrc ) +WindowPtr pWin; /* GJA */ +register PixmapPtr pTile ; +const int alu ; +const unsigned long int planes ; +register int x0, y0, w, h ; +int xSrc ; +int ySrc ; +{ +ScreenPtr pScreen ; +int xOffset ; +int yOffset ; +int width, height; + +TRACE( ( "xf4bppTileRect(pTile=x%x,alu=x%x,planes=x%02x,x0=%d,y0=%d,w=%d,h=%d,xSrc=%d,ySrc=%d\n", + pTile, alu, planes, x0, y0, w, h, xSrc, ySrc ) ) ; + + pScreen = pTile->drawable.pScreen ; + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + xf4bppFillSolid + ( pWin, 0xFF, alu, planes, x0, y0, w, h ) ; + case GXnoop: /* 0x5 dst */ + return ; + default: + break ; +} + + width = pTile->drawable.width; + if ( ( xOffset = ( x0 - xSrc ) ) > 0 ) + xOffset %= width ; + else + xOffset = width - (( - xOffset ) % width ) ; + if ( xOffset == width ) xOffset = 0; /* For else case */ + + height = pTile->drawable.height; + if ( ( yOffset = ( y0 - ySrc ) ) > 0 ) + yOffset %= height ; + else + yOffset = height - (( - yOffset ) % height ) ; + if ( yOffset == height ) yOffset = 0; /* For else case */ + + switch ( alu ) { + case GXcopyInverted: /* 0xc NOT src */ + case GXcopy: /* 0x3 src */ + /* Special Case Code */ + DrawFirstTile( pWin, pTile, x0, y0, w, h, + alu, planes, xOffset, yOffset ) ; + /* Here We Double The Size Of The BLIT Each Iteration */ + xf4bppReplicateArea( pWin, x0, y0, planes, w, h, + MIN( w, pTile->drawable.width ), + MIN( h, pTile->drawable.height ) ) ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + case GXandReverse: /* 0x2 src AND NOT dst */ + case GXorReverse: /* 0xb src OR NOT dst */ + case GXnand: /* 0xe NOT src OR NOT dst */ + case GXandInverted: /* 0x4 NOT src AND dst */ + case GXand: /* 0x1 src AND dst */ + case GXequiv: /* 0x9 NOT src XOR dst */ + case GXxor: /* 0x6 src XOR dst */ + case GXorInverted: /* 0xd NOT src OR dst */ + case GXor: /* 0x7 src OR dst */ + default: + { + register unsigned char *data ; + register int hcount, vcount ; /* Number of tiles in center */ + int xcount, ycount; /* Temporaries */ + int x1, y1; /* Left upper corner of center */ + int x2, y2; /* Left upper corner of lower right margin */ + int leftmgn, rightmgn, topmgn, botmgn; /* Margins */ + + int htarget, vtarget ; + + data = pTile->devPrivate.ptr; + + /* Compute the various sizes and coordinates. */ + leftmgn = MIN( w, width - xOffset ) ; + x1 = x0 + leftmgn; + topmgn = MIN( h, height - yOffset ) ; + y1 = y0 + topmgn; + + rightmgn = (w - leftmgn) % width; + hcount = (w - leftmgn) / width; + x2 = x0 + w - rightmgn; + botmgn = (h - topmgn) % height; + vcount = (h - topmgn) / height; + y2 = y0 + h - botmgn; + + /* We'll use yOffset as offset in data. + * This requires yOffset != height (ditto xOffset). + */ + yOffset *= pTile->devKind; + + /* Draw top margin, including corners */ + if ( topmgn ) { + if ( leftmgn ) { + xf4bppDrawColorImage( pWin, x0, y0, leftmgn, topmgn, + data + yOffset + xOffset, + pTile->devKind, alu, planes ) ; + } + for ( xcount = hcount, htarget = x1; + xcount ; + xcount--, htarget += width ) + { + xf4bppDrawColorImage( pWin, htarget, y0, width, topmgn, + data + yOffset, + pTile->devKind, alu, planes ) ; + } + if ( rightmgn ) { + xf4bppDrawColorImage( pWin, x2, y0, rightmgn, topmgn, + data + yOffset, + pTile->devKind, alu, planes ) ; + } + } + + /* Draw bottom margin, including corners */ + if ( botmgn ) { + if ( leftmgn ) { + xf4bppDrawColorImage( pWin, x0, y2, leftmgn, botmgn, + data + xOffset, + pTile->devKind, alu, planes ) ; + } + for ( xcount = hcount, htarget = x1; + xcount ; + xcount--, htarget += width ) + { + xf4bppDrawColorImage( pWin, htarget, y2, width, botmgn, + data, + pTile->devKind, alu, planes ) ; + } + if ( rightmgn ) { + xf4bppDrawColorImage( pWin, x2, y2, rightmgn, botmgn, + data, + pTile->devKind, alu, planes ) ; + } + } + + /* Draw left margin, excluding corners */ + if ( leftmgn ) { + for ( ycount = vcount, vtarget = y1 ; + ycount ; + ycount--, vtarget += height ) + { + xf4bppDrawColorImage( pWin, x0, vtarget, leftmgn, height, + data + xOffset, + pTile->devKind, alu, planes ) ; + } + } + + /* Draw right margin, excluding corners */ + if ( rightmgn ) { + for ( ycount = vcount, vtarget = y1 ; + ycount ; + ycount--, vtarget += height ) + { + xf4bppDrawColorImage( pWin, x2, vtarget, rightmgn, height, + data, + pTile->devKind, alu, planes ) ; + } + } + + /* Draw center consisting of full tiles */ + for ( ycount = vcount, vtarget = y1 ; + ycount ; + ycount--, vtarget += height ) + { + for ( xcount = hcount, htarget = x1 ; + xcount ; + xcount--, htarget += width ) + { + xf4bppDrawColorImage( pWin, htarget, vtarget, width, height, + data, + pTile->devKind, alu, planes ) ; + + } + } + } } /* Block + switch */ +} diff --git a/hw/xfree86/xf4bpp/ibmTrace.h b/hw/xfree86/xf4bpp/ibmTrace.h new file mode 100644 index 000000000..f99ce33e0 --- /dev/null +++ b/hw/xfree86/xf4bpp/ibmTrace.h @@ -0,0 +1,10 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ibmTrace.h,v 1.2 1998/07/25 16:59:28 dawes Exp $ */ + + + + + +/* $XConsortium: ibmTrace.h /main/3 1996/02/21 17:56:27 kaleb $ */ + +#define TRACE(x) /* empty */ + diff --git a/hw/xfree86/xf4bpp/mfbbres.c b/hw/xfree86/xf4bpp/mfbbres.c new file mode 100644 index 000000000..300256021 --- /dev/null +++ b/hw/xfree86/xf4bpp/mfbbres.c @@ -0,0 +1,162 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/mfbbres.c,v 1.3 1999/06/06 08:48:54 dawes Exp $ */ +/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* GJA -- modified this file for vga16 */ +/* $XConsortium: mfbbres.c /main/5 1996/02/21 17:56:30 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "miline.h" +#include "wm3.h" + +/* Solid bresenham line */ +/* NOTES + e2 is used less often than e1, so it's not in a register +*/ + +void +xf4bppBresS(addrlbase, nlwidth, signdx, signdy, axis, x1, y1, e, e1, e2, len) +PixelType *addrlbase; /* pointer to base of bitmap */ +int nlwidth; /* width in longwords of bitmap */ +int signdx, signdy; /* signs of directions */ +int axis; /* major axis (Y_AXIS or X_AXIS) */ +int x1, y1; /* initial point */ +register int e; /* error accumulator */ +register int e1; /* bresenham increments */ +int e2; +int len; /* length of line */ +{ + register int yinc; /* increment to next scanline, in bytes */ + register PixelType *addrl; /* bitmask long pointer + *dont* * cast to char pointer */ + register PixelType bit; /* current bit being set/cleared/etc. */ + PixelType leftbit = mask[0]; /* leftmost bit to process in new word */ + PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */ + + register int e3 = e2-e1; + + /* point to longword containing first point */ + addrl = mfbScanline(addrlbase, x1, y1, nlwidth); + yinc = signdy * nlwidth; + e = e-e1; /* to make looping easier */ + bit = mask[x1 & PIM]; + + if (!len) + return; + + if (axis == X_AXIS) + { + if (signdx > 0) + { + while(len--) + { + UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + addrl += yinc; + e += e3; + } + bit = SCRRIGHT(bit,1); + if (!bit) { bit = leftbit; addrl++; } + } + } + else + { + while(len--) + { + UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + addrl += yinc; + e += e3; + } + bit = SCRLEFT(bit,1); + if (!bit) { bit = rightbit; addrl--; } + } + } + } /* if X_AXIS */ + else + { + if (signdx > 0) + { + while(len--) + { + UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + bit = SCRRIGHT(bit,1); + if (!bit) { bit = leftbit; addrl++; } + e += e3; + } + addrl += yinc; + } + } + else + { + while(len--) + { + UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + bit = SCRLEFT(bit,1); + if (!bit) { bit = rightbit; addrl--; } + e += e3; + } + addrl += yinc; + } + } + } /* else Y_AXIS */ +} diff --git a/hw/xfree86/xf4bpp/mfbbresd.c b/hw/xfree86/xf4bpp/mfbbresd.c new file mode 100644 index 000000000..560995957 --- /dev/null +++ b/hw/xfree86/xf4bpp/mfbbresd.c @@ -0,0 +1,203 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/mfbbresd.c,v 1.4 2002/01/25 21:56:22 tsi Exp $ */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* GJA -- modified this file for vga16 */ +/* $XConsortium: mfbbresd.c /main/5 1996/02/21 17:56:34 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "miline.h" +#include "wm3.h" +#include "xf86.h" + +/* Dashed bresenham line */ + +#define NO_INK (-1) /* GJA -- means: dash is off */ + +#define StepDash\ + if (!--dashRemaining) { \ + if (++ dashIndex == numInDashList) \ + dashIndex = 0; \ + dashRemaining = pDash[dashIndex]; \ + ink = fgink; \ + if (dashIndex & 1) \ + ink = bgink; \ + if (isDoubleDash) \ + WM3_SET_INK(ink); \ + } + +void +xf4bppBresD(pDrawable, fgink, bgink, + pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash, + addrlbase, nlwidth, + signdx, signdy, axis, x1, y1, e, e1, e2, len) +DrawablePtr pDrawable; +int fgink, bgink; +int *pdashIndex; /* current dash */ +unsigned char *pDash; /* dash list */ +int numInDashList; /* total length of dash list */ +int *pdashOffset; /* offset into current dash */ +int isDoubleDash; +PixelType *addrlbase; /* pointer to base of bitmap */ +int nlwidth; /* width in longwords of bitmap */ +int signdx, signdy; /* signs of directions */ +int axis; /* major axis (Y_AXIS or X_AXIS) */ +int x1, y1; /* initial point */ +register int e; /* error accumulator */ +register int e1; /* bresenham increments */ +int e2; +int len; /* length of line */ +{ + IOADDRESS REGBASE = + xf86Screens[pDrawable->pScreen->myNum]->domainIOBase + 0x300; + register int yinc; /* increment to next scanline, in bytes */ + register PixelType *addrl; + register int e3 = e2-e1; + register unsigned long bit; + PixelType leftbit = mask[0]; /* leftmost bit to process in new word */ + PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */ + int dashIndex; + int dashOffset; + int dashRemaining; + int ink; + + fgink &= 0x0F; bgink &= 0x0F; /* GJA -- so they're != NO_INK */ + + dashOffset = *pdashOffset; + dashIndex = *pdashIndex; + dashRemaining = pDash[dashIndex] - dashOffset; + ink = fgink; + if (!isDoubleDash) + bgink = NO_INK; + if (dashIndex & 1) + ink = bgink; + if ( ink != NO_INK ) WM3_SET_INK(ink); + + /* point to longword containing first point */ + addrl = mfbScanline(addrlbase, x1, y1, nlwidth); + yinc = signdy * nlwidth; + e = e-e1; /* to make looping easier */ + bit = mask[x1 & PIM]; + if (axis == X_AXIS) + { + if (signdx > 0) + { + while(len--) + { + if ( ink != NO_INK ) UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + addrl += yinc; + e += e3; + } + bit = SCRRIGHT(bit,1); + if (!bit) { bit = leftbit; addrl++; } + StepDash + } + } + else + { + while(len--) + { + + if ( ink != NO_INK ) UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + addrl += yinc; + e += e3; + } + bit = SCRLEFT(bit,1); + if (!bit) { bit = rightbit; addrl--; } + StepDash + } + } + } /* if X_AXIS */ + else + { + if (signdx > 0) + { + while(len--) + { + if ( ink != NO_INK ) UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + bit = SCRRIGHT(bit,1); + if (!bit) { bit = leftbit; addrl++; } + e += e3; + } + addrl += yinc; + StepDash + } + } + else + { + while(len--) + { + + if ( ink != NO_INK ) UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + bit = SCRLEFT(bit,1); + if (!bit) { bit = rightbit; addrl--; } + e += e3; + } + addrl += yinc; + StepDash + } + } + } /* else Y_AXIS */ + *pdashIndex = dashIndex; + *pdashOffset = pDash[dashIndex] - dashRemaining; +} diff --git a/hw/xfree86/xf4bpp/mfbfillarc.c b/hw/xfree86/xf4bpp/mfbfillarc.c new file mode 100644 index 000000000..14c2ccb66 --- /dev/null +++ b/hw/xfree86/xf4bpp/mfbfillarc.c @@ -0,0 +1,299 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/mfbfillarc.c,v 1.5 2003/02/18 21:29:59 tsi Exp $ */ +/************************************************************ + +Copyright (c) 1989 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + +********************************************************/ + +/* GJA -- Took mfb code and modified it. */ + +/* $XConsortium: mfbfillarc.c /main/4 1996/02/21 17:56:37 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "mifillarc.h" +#include "wm3.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +static void +v16FillEllipseSolid +( + DrawablePtr pDraw, + xArc *arc +) +{ + int x, y, e; + int yk, xk, ym, xm, dx, dy, xorg, yorg; + register int slw; + miFillArcRec info; + int *addrlt, *addrlb; + register int *addrl; + register int n; + int nlwidth; + register int xpos; + int startmask, endmask, nlmiddle; + + if (pDraw->type == DRAWABLE_WINDOW) + { + addrlt = (int *) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr); + nlwidth = (int) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2; + } + else + { + addrlt = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr); + nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2; + } + + miFillArcSetup(arc, &info); + MIFILLARCSETUP(); + xorg += pDraw->x; + yorg += pDraw->y; + addrlb = addrlt; + addrlt += nlwidth * (yorg - y); + addrlb += nlwidth * (yorg + y + dy); + while (y) + { + addrlt += nlwidth; + addrlb -= nlwidth; + MIFILLARCSTEP(slw); + if (!slw) + continue; + xpos = xorg - x; + addrl = addrlt + (xpos >> PWSH); + if (((xpos & PIM) + slw) < PPW) + { + maskpartialbits(xpos, slw, startmask); + UPDRW(addrl,startmask); + if (miFillArcLower(slw)) + { + addrl = addrlb + (xpos >> PWSH); + UPDRW(addrl,startmask); + } + continue; + } + maskbits(xpos, slw, startmask, endmask, nlmiddle); + if (startmask) + { + UPDRW(addrl,startmask); addrl++; + } + n = nlmiddle; + while (n--) { + UPDRW(addrl,~0); addrl++; + } + if (endmask) + { + UPDRW(addrl,endmask); + } + if (!miFillArcLower(slw)) + continue; + addrl = addrlb + (xpos >> PWSH); + if (startmask) + { + UPDRW(addrl,startmask); addrl++; + } + n = nlmiddle; + while (n--) { + UPDRW(addrl,~0); addrl++; + } + if (endmask) + { + UPDRW(addrl,endmask); + } + } +} + +#define FILLSPAN(xl,xr,addr) \ + if (xr >= xl) \ + { \ + width = xr - xl + 1; \ + addrl = addr + (xl >> PWSH); \ + if (((xl & PIM) + width) < PPW) \ + { \ + maskpartialbits(xl, width, startmask); \ + UPDRW(addrl,startmask); \ + } \ + else \ + { \ + maskbits(xl, width, startmask, endmask, nlmiddle); \ + if (startmask) \ + { \ + UPDRW(addrl,startmask); addrl++; \ + } \ + n = nlmiddle; \ + while (n--) { \ + UPDRW(addrl,~0); addrl++; \ + } \ + if (endmask) \ + { \ + UPDRW(addrl,endmask); \ + } \ + } \ + } + +#define FILLSLICESPANS(flip,addr) \ + if (!flip) \ + { \ + FILLSPAN(xl, xr, addr); \ + } \ + else \ + { \ + xc = xorg - x; \ + FILLSPAN(xc, xr, addr); \ + xc += slw - 1; \ + FILLSPAN(xl, xc, addr); \ + } + +static void +v16FillArcSliceSolidCopy +( + DrawablePtr pDraw, + GCPtr pGC, + xArc *arc +) +{ + register int *addrl; + register int n; + int yk, xk, ym, xm, dx, dy, xorg, yorg, slw; + register int x, y, e; + miFillArcRec info; + miArcSliceRec slice; + int xl, xr, xc; + int *addrlt, *addrlb; + int nlwidth; + int width; + int startmask, endmask, nlmiddle; + + if (pDraw->type == DRAWABLE_WINDOW) + { + addrlt = (int *) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr); + nlwidth = (int) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2; + } + else + { + addrlt = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr); + nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2; + } + + miFillArcSetup(arc, &info); + miFillArcSliceSetup(arc, &slice, pGC); + MIFILLARCSETUP(); + xorg += pDraw->x; + yorg += pDraw->y; + addrlb = addrlt; + addrlt += nlwidth * (yorg - y); + addrlb += nlwidth * (yorg + y + dy); + slice.edge1.x += pDraw->x; + slice.edge2.x += pDraw->x; + while (y > 0) + { + addrlt += nlwidth; + addrlb -= nlwidth; + MIFILLARCSTEP(slw); + MIARCSLICESTEP(slice.edge1); + MIARCSLICESTEP(slice.edge2); + if (miFillSliceUpper(slice)) + { + MIARCSLICEUPPER(xl, xr, slice, slw); + FILLSLICESPANS(slice.flip_top, addrlt); + } + if (miFillSliceLower(slice)) + { + MIARCSLICELOWER(xl, xr, slice, slw); + FILLSLICESPANS(slice.flip_bot, addrlb); + } + } +} + +static void +xf4bppPolyFillArcSolid +( + register DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +) +{ + mfbPrivGC *priv; + register xArc *arc; + register int i; + BoxRec box; + RegionPtr cclip; + int rop; + + priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr; + rop = priv->rop; +#if 0 + if ((rop == RROP_NOP) || !(pGC->planemask & 1)) +#else + if ( !(pGC->planemask & 0x0F)) +#endif + return; + cclip = pGC->pCompositeClip; + for (arc = parcs, i = narcs; --i >= 0; arc++) + { + if (miFillArcEmpty(arc)) + continue; + if (miCanFillArc(arc)) + { + box.x1 = arc->x + pDraw->x; + box.y1 = arc->y + pDraw->y; + box.x2 = box.x1 + (int)arc->width + 1; + box.y2 = box.y1 + (int)arc->height + 1; + if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) + { + if ((arc->angle2 >= FULLCIRCLE) || + (arc->angle2 <= -FULLCIRCLE)) + DO_WM3(pGC,v16FillEllipseSolid(pDraw, arc)) + else + DO_WM3(pGC,v16FillArcSliceSolidCopy(pDraw, pGC, arc)) + continue; + } + } + miPolyFillArc(pDraw, pGC, 1, arc); + } +} + +void +xf4bppPolyFillArc(pDraw, pGC, narcs, parcs) + register DrawablePtr pDraw; + GCPtr pGC; + int narcs; + xArc *parcs; +{ + if ( !xf86Screens[pDraw->pScreen->myNum]->vtSema || (pGC->fillStyle != FillSolid) ) { + miPolyFillArc(pDraw, pGC, narcs, parcs); + } else { + xf4bppPolyFillArcSolid(pDraw, pGC, narcs, parcs); + } +} diff --git a/hw/xfree86/xf4bpp/mfbhrzvert.c b/hw/xfree86/xf4bpp/mfbhrzvert.c new file mode 100644 index 000000000..3d6c3df52 --- /dev/null +++ b/hw/xfree86/xf4bpp/mfbhrzvert.c @@ -0,0 +1,133 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/mfbhrzvert.c,v 1.3 1999/06/06 08:48:55 dawes Exp $ */ +/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* GJA -- modified this file for vga16 */ +/* $XConsortium: mfbhrzvert.c /main/3 1996/02/21 17:56:41 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "wm3.h" + +/* horizontal solid line + abs(len) > 1 +*/ + +void +xf4bppHorzS(addrl, nlwidth, x1, y1, len) +register PixelType *addrl; /* pointer to base of bitmap */ +register int nlwidth; /* width in longwords of bitmap */ +int x1; /* initial point */ +int y1; +int len; /* length of line */ +{ + register PixelType startmask; + register PixelType endmask; + register int nlmiddle; + + + /* force the line to go left to right + but don't draw the last point + */ + if (len < 0) + { + x1 += len; + x1 += 1; + len = -len; + } + + addrl = mfbScanline(addrl, x1, y1, nlwidth); + + /* all bits inside same longword */ + if ( ((x1 & PIM) + len) < PPW) + { + maskpartialbits(x1, len, startmask); + UPDRW(addrl,startmask); + } + else + { + maskbits(x1, len, startmask, endmask, nlmiddle); + if (startmask) { + UPDRW(addrl,startmask); addrl++; + } + Duff (nlmiddle, UPDRW(addrl,~0); addrl++); + if (endmask) { + UPDRW(addrl,endmask); + } + } +} + +/* vertical solid line + this uses do loops because pcc (Ultrix 1.2, bsd 4.2) generates + better code. sigh. we know that len will never be 0 or 1, so + it's OK to use it. +*/ + +void +xf4bppVertS(addrl, nlwidth, x1, y1, len) +register PixelType *addrl; /* pointer to base of bitmap */ +register int nlwidth; /* width in longwords of bitmap */ +int x1, y1; /* initial point */ +register int len; /* length of line */ +{ + register PixelType bitmask; + + addrl = mfbScanline(addrl, x1, y1, nlwidth); + + if (len < 0) + { + nlwidth = -nlwidth; + len = -len; + } + + bitmask = mask[x1 & PIM]; + Duff(len, UPDRW(addrl,bitmask); addrl += nlwidth); +} diff --git a/hw/xfree86/xf4bpp/mfbimggblt.c b/hw/xfree86/xf4bpp/mfbimggblt.c new file mode 100644 index 000000000..cb2e63125 --- /dev/null +++ b/hw/xfree86/xf4bpp/mfbimggblt.c @@ -0,0 +1,501 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/mfbimggblt.c,v 1.7 2003/02/18 21:29:59 tsi Exp $ */ + +/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* $XConsortium: mfbimggblt.c /main/5 1996/02/21 17:56:44 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "dixfontstr.h" +#include "ppcGCstr.h" +#include "wm3.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +/* + we should eventually special-case fixed-width fonts for ImageText. + + this works for fonts with glyphs <= 32 bits wide. + + the clipping calculations are done for worst-case fonts. +we make no assumptions about the heights, widths, or bearings +of the glyphs. if we knew that the glyphs are all the same height, +we could clip the tops and bottoms per clipping box, rather +than per character per clipping box. if we knew that the glyphs' +left and right bearings were wlle-behaved, we could clip a single +character at the start, output until the last unclipped +character, and then clip the last one. this is all straightforward +to determine based on max-bounds and min-bounds from the font. + there is some inefficiency introduced in the per-character +clipping to make what's going on clearer. + + (it is possible, for example, for a font to be defined in which the +next-to-last character in a font would be clipped out, but the last +one wouldn't. the code below deals with this.) + + Image text looks at the bits in the glyph and the fg and bg in the +GC. it paints a rectangle, as defined in the protocol dcoument, +and the paints the characters. + + to avoid source proliferation, this file is compiled +three times: + MFBIMAGEGLYPHBLT OPEQ + mfbImageGlyphBltWhite |= + mfbImageGlyphBltBlack &=~ + + the register allocations for startmask and endmask may not +be the right thing. are there two other deserving candidates? +xoff, pdst, pglyph, and tmpSrc seem like the right things, though. +*/ + +/* Forward declarations -- GJA */ +static void doImageGlyphBlt( +#if NeedFunctionPrototypes + DrawablePtr, + GC *, + int, + int, + unsigned int, + CharInfoPtr *, + unsigned char *, + ExtentInfoRec * +#endif +); + +void +xf4bppImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) + DrawablePtr pDrawable; + GC *pGC; + int x, y; + unsigned int nglyph; + CharInfoPtr *ppci; /* array of character info */ + pointer pglyphBase; /* start of array of glyphs */ +{ + ExtentInfoRec info; /* used by QueryGlyphExtents() */ + xRectangle backrect;/* backing rectangle to paint. + in the general case, NOT necessarily + the same as the string's bounding box + */ + /* GJA -- I agree, this ALL should be moved to GC validation. */ + if ( (pDrawable->type != DRAWABLE_WINDOW) || (pGC->alu != GXcopy) || + !xf86Screens[pDrawable->pScreen->myNum]->vtSema || + ((pGC->font) && + (FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 || + FONTMINBOUNDS(pGC->font,characterWidth) < 0)) ) { + miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); + } else { + ppcPrivGC *pPrivGC; + int oldfillStyle, oldfg, oldalu; + + if (!(pGC->planemask & 0x0F)) + return; + + QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info); + + backrect.x = x; + backrect.y = y - FONTASCENT(pGC->font); + backrect.width = info.overallWidth; + backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + + + pPrivGC = pGC->devPrivates[mfbGCPrivateIndex].ptr; + oldfillStyle = pPrivGC->colorRrop.fillStyle; /* GJA */ + oldfg = pPrivGC->colorRrop.fgPixel; /* GJA */ + oldalu = pPrivGC->colorRrop.alu; /* GJA */ + + pPrivGC->colorRrop.fillStyle = FillSolid; /* GJA */ + pPrivGC->colorRrop.fgPixel = pGC->bgPixel; /* GJA */ + pGC->fgPixel = pGC->bgPixel; + pPrivGC->colorRrop.alu = GXcopy; /* GJA */ + pGC->alu = GXcopy; + + /* Required fields: + * colorRrop.alu, colorRrop.planemask, colorRrop.fgPixel + */ + xf4bppPolyFillRect(pDrawable, pGC, 1, &backrect); + + pPrivGC->colorRrop.fgPixel = oldfg; /* GJA */ + pGC->fgPixel = oldfg; + + /* the faint-hearted can open their eyes now */ + + DO_WM3(pGC,doImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, + pglyphBase,&info)) + + pPrivGC->colorRrop.fillStyle = oldfillStyle; /* GJA */ + pPrivGC->colorRrop.alu = oldalu; /* GJA */ + pGC->alu = oldalu; + } + +} + +static void +doImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,infop) + DrawablePtr pDrawable; + GC *pGC; + int x, y; + unsigned int nglyph; + CharInfoPtr *ppci; /* array of character info */ + unsigned char *pglyphBase; /* start of array of glyphs */ + ExtentInfoRec* infop; /* used by QueryGlyphExtents() */ +{ + BoxRec bbox; /* string's bounding box */ + + CharInfoPtr pci; + int xorg, yorg; /* origin of drawable in bitmap */ + int widthDst; /* width of dst in longwords */ + + /* these keep track of the character origin */ + CARD32 *pdstBase; + /* points to longword with character origin */ + int xchar; /* xorigin of char (mod 32) */ + + /* these are used for placing the glyph */ + register int xoff; /* x offset of left edge of glyph (mod 32) */ + register CARD32 *pdst; + /* pointer to current longword in dst */ + + int w; /* width of glyph in bits */ + int h; /* height of glyph */ + int widthGlyph; /* width of glyph, in bytes */ + register unsigned char *pglyph; + /* pointer to current row of glyph */ + + /* used for putting down glyph */ + register unsigned int tmpSrc; + /* for getting bits from glyph */ + register int startmask; + register int endmask; + + register int nFirst;/* bits of glyph in current longword */ + + xorg = pDrawable->x; + yorg = pDrawable->y; + if (pDrawable->type == DRAWABLE_WINDOW) + { + pdstBase = (CARD32 *) + (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devPrivate.ptr); + widthDst = (int) + (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind) >> 2; + } + else + { + pdstBase = (CARD32 *)(((PixmapPtr)pDrawable)->devPrivate.ptr); + widthDst = (int)(((PixmapPtr)pDrawable)->devKind) >> 2; + } + + x += xorg; + y += yorg; + bbox.x1 = x + infop->overallLeft; + bbox.x2 = x + infop->overallRight; + bbox.y1 = y - infop->overallAscent; + bbox.y2 = y + infop->overallDescent; + + /* UNCLEAN CODE + we know the mfbPolyFillRect uses only three fields in + devPrivate[mfbGCPrivateIndex].ptr, two of which (the rotated + tile/stipple and the ropFillArea) are + irrelevant for solid filling, so we just poke the FillArea + field. the GC is now in an inconsistent state, but we'll fix + it as soon as PolyFillRect returns. fortunately, the server + is single threaded. + + NOTE: + if you are not using the standard mfbFillRectangle code, you + need to poke any fields in the GC the rectangle stuff need + (probably alu, fgPixel, and fillStyle) and in devPrivate[mfbGCPrivateIndex].ptr + (probably rop or ropFillArea.) You could just call ValidateGC, + but that is usually not a cheap thing to do. + */ + + switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) + { + case rgnOUT: + break; + case rgnIN: + pdstBase = pdstBase + (widthDst * y) + (x >> PWSH); + xchar = x & PIM; + + while(nglyph--) + { + pci = *ppci; + pglyph = FONTGLYPHBITS(pglyphBase, pci); + w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; + h = pci->metrics.ascent + pci->metrics.descent; + widthGlyph = GLYPHWIDTHBYTESPADDED(pci); + + /* start at top scanline of glyph */ + pdst = pdstBase - (pci->metrics.ascent * widthDst); + + /* find correct word in scanline and x offset within it + for left edge of glyph + */ + xoff = xchar + pci->metrics.leftSideBearing; + if (xoff > PIM) + { + pdst++; + xoff &= PIM; + } + else if (xoff < 0) + { + xoff += PPW; + pdst--; + } + + if ((xoff + w) <= PPW) + { + /* glyph all in one longword */ + maskpartialbits(xoff, w, startmask); + + while (h--) + { + getleftbits(pglyph, w, tmpSrc); + UPDRW(pdst,(SCRRIGHT(tmpSrc, xoff) & startmask)); + pglyph += widthGlyph; + pdst += widthDst; + } + } + else + { + /* glyph crosses longword boundary */ + maskPPWbits(xoff, w, startmask, endmask); + nFirst = PPW - xoff; + while (h--) + { + getleftbits(pglyph, w, tmpSrc); + UPDRW(pdst,(SCRRIGHT(tmpSrc, xoff) & startmask)); + UPDRW(&(pdst[1]),(SCRLEFT(tmpSrc, nFirst) & endmask)); + pglyph += widthGlyph; + pdst += widthDst; + } + } /* glyph crosses longwords boundary */ + + /* update character origin */ + x += pci->metrics.characterWidth; + xchar += pci->metrics.characterWidth; + if (xchar > PLST) + { + xchar -= PPW; + pdstBase++; + } + else if (xchar < 0) + { + xchar += PPW; + pdstBase--; + } + ppci++; + } /* while nglyph-- */ + break; + case rgnPART: + { + TEXTPOS *ppos; + int nbox; + BoxPtr pbox; + RegionPtr cclip; + int xpos; /* x position of char origin */ + unsigned int i; + BoxRec clip; + int leftEdge, rightEdge; + int topEdge, bottomEdge; + int glyphRow; /* first row of glyph not wholly + clipped out */ + int glyphCol; /* leftmost visible column of glyph */ + int getWidth; /* bits to get from glyph */ + + if(!(ppos = (TEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(TEXTPOS)))) + return; + + pdstBase = pdstBase + (widthDst * y) + (x >> PWSH); + xpos = x; + xchar = xpos & PIM; + + for (i=0; i<nglyph; i++) + { + pci = ppci[i]; + + ppos[i].xpos = xpos; + ppos[i].xchar = xchar; + ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing; + ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing; + ppos[i].topEdge = y - pci->metrics.ascent; + ppos[i].bottomEdge = y + pci->metrics.descent; + ppos[i].pdstBase = pdstBase; + ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci); + + xpos += pci->metrics.characterWidth; + xchar += pci->metrics.characterWidth; + if (xchar > PLST) + { + xchar &= PIM; + pdstBase++; + } + else if (xchar < 0) + { + xchar += PPW; + pdstBase--; + } + } + + cclip = pGC->pCompositeClip; + pbox = REGION_RECTS(cclip); + nbox = REGION_NUM_RECTS(cclip); + + /* HACK ALERT + since we continue out of the loop below so often, it + is easier to increment pbox at the top than at the end. + don't try this at home. + */ + pbox--; + while(nbox--) + { + pbox++; + clip.x1 = max(bbox.x1, pbox->x1); + clip.y1 = max(bbox.y1, pbox->y1); + clip.x2 = min(bbox.x2, pbox->x2); + clip.y2 = min(bbox.y2, pbox->y2); + if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1)) + continue; + + for(i=0; i<nglyph; i++) + { + pci = ppci[i]; + xchar = ppos[i].xchar; + + /* clip the left and right edges */ + if (ppos[i].leftEdge < clip.x1) + leftEdge = clip.x1; + else + leftEdge = ppos[i].leftEdge; + + if (ppos[i].rightEdge > clip.x2) + rightEdge = clip.x2; + else + rightEdge = ppos[i].rightEdge; + + w = rightEdge - leftEdge; + if (w <= 0) + continue; + + /* clip the top and bottom edges */ + if (ppos[i].topEdge < clip.y1) + topEdge = clip.y1; + else + topEdge = ppos[i].topEdge; + + if (ppos[i].bottomEdge > clip.y2) + bottomEdge = clip.y2; + else + bottomEdge = ppos[i].bottomEdge; + + h = bottomEdge - topEdge; + if (h <= 0) + continue; + + glyphRow = (topEdge - y) + pci->metrics.ascent; + widthGlyph = ppos[i].widthGlyph; + pglyph = FONTGLYPHBITS(pglyphBase, pci); + pglyph += (glyphRow * widthGlyph); + + pdst = ppos[i].pdstBase - ((y-topEdge) * widthDst); + + glyphCol = (leftEdge - ppos[i].xpos) - + (pci->metrics.leftSideBearing); + getWidth = w + glyphCol; + xoff = xchar + (leftEdge - ppos[i].xpos); + if (xoff > PLST) + { + xoff &= PIM; + pdst++; + } + else if (xoff < 0) + { + xoff += PPW; + pdst--; + } + + if ((xoff + w) <= PPW) + { + maskpartialbits(xoff, w, startmask); + while (h--) + { + getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc); + UPDRW(pdst,(SCRRIGHT(tmpSrc, xoff) & startmask)); + pglyph += widthGlyph; + pdst += widthDst; + } + } + else + { + maskPPWbits(xoff, w, startmask, endmask); + nFirst = PPW - xoff; + while (h--) + { + getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc); + UPDRW(pdst,(SCRRIGHT(tmpSrc, xoff) & startmask)); + UPDRW(&(pdst[1]),(SCRLEFT(tmpSrc, nFirst) & endmask)); + pglyph += widthGlyph; + pdst += widthDst; + } + } + } /* for each glyph */ + } /* while nbox-- */ + DEALLOCATE_LOCAL(ppos); + break; + } + default: + break; + } +} + diff --git a/hw/xfree86/xf4bpp/mfbline.c b/hw/xfree86/xf4bpp/mfbline.c new file mode 100644 index 000000000..dc85e3d92 --- /dev/null +++ b/hw/xfree86/xf4bpp/mfbline.c @@ -0,0 +1,982 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/mfbline.c,v 1.4 2002/01/25 21:56:22 tsi Exp $ */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* GJA -- modified this file for vga16 */ +/* $XConsortium: mfbline.c /main/4 1996/02/21 17:56:48 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "miline.h" +#include "vgaVideo.h" +#include "wm3.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +/* single-pixel lines on a color frame buffer + + NON-SLOPED LINES + horizontal lines are always drawn left to right; we have to +move the endpoints right by one after they're swapped. + horizontal lines will be confined to a single band of a +region. the code finds that band (giving up if the lower +bound of the band is above the line we're drawing); then it +finds the first box in that band that contains part of the +line. we clip the line to subsequent boxes in that band. + vertical lines are always drawn top to bottom (y-increasing.) +this requires adding one to the y-coordinate of each endpoint +after swapping. + + SLOPED LINES + when clipping a sloped line, we bring the second point inside +the clipping box, rather than one beyond it, and then add 1 to +the length of the line before drawing it. this lets us use +the same box for finding the outcodes for both endpoints. since +the equation for clipping the second endpoint to an edge gives us +1 beyond the edge, we then have to move the point towards the +first point by one step on the major axis. + eventually, there will be a diagram here to explain what's going +on. the method uses Cohen-Sutherland outcodes to determine +outsideness, and a method similar to Pike's layers for doing the +actual clipping. + +*/ +#ifdef POLYSEGMENT +static void DoV16SegmentSS( +#if NeedFunctionPrototypes + DrawablePtr, GCPtr, int, xSegment* +#endif +); + +void +xf4bppSegmentSS (pDrawable, pGC, nseg, pSeg) + DrawablePtr pDrawable; + GCPtr pGC; + int nseg; + register xSegment *pSeg; +{ + if ( ! xf86Screens[pDrawable->pScreen->myNum]->vtSema ) { + miPolySegment(pDrawable, pGC, nseg, pSeg); + } else { + DO_WM3(pGC,DoV16SegmentSS (pDrawable, pGC, nseg, pSeg)); + } +} + +#else +static void DoV16LineSS( +#if NeedFunctionPrototypes + DrawablePtr, GCPtr, int, int, DDXPointPtr +#endif +); + +void +xf4bppLineSS (pDrawable, pGC, mode, npt, pptInit) + DrawablePtr pDrawable; + GCPtr pGC; + int mode; /* Origin or Previous */ + int npt; /* number of points */ + DDXPointPtr pptInit; +{ + if ( ! xf86Screens[pDrawable->pScreen->myNum]->vtSema ) { + miZeroLine(pDrawable, pGC, mode, npt, pptInit); + } else { + DO_WM3(pGC,DoV16LineSS (pDrawable, pGC, mode, npt, pptInit)); + } +} +#endif + +static void +#ifdef POLYSEGMENT +DoV16SegmentSS (pDrawable, pGC, nseg, pSeg) + DrawablePtr pDrawable; + GCPtr pGC; + int nseg; + register xSegment *pSeg; +#else +DoV16LineSS (pDrawable, pGC, mode, npt, pptInit) + DrawablePtr pDrawable; + GCPtr pGC; + int mode; /* Origin or Previous */ + int npt; /* number of points */ + DDXPointPtr pptInit; +#endif +{ + int nboxInit; + register int nbox; + BoxPtr pboxInit; + register BoxPtr pbox; +#ifndef POLYSEGMENT + register DDXPointPtr ppt; /* pointer to list of translated points */ +#endif + + unsigned int oc1; /* outcode of point 1 */ + unsigned int oc2; /* outcode of point 2 */ + + PixelType *addrlBase; /* pointer to start of drawable */ +#ifndef POLYSEGMENT + PixelType *addrl; /* address of destination pixmap */ +#endif + int nlwidth; /* width in longwords of destination pixmap */ + int xorg, yorg; /* origin of window */ + + int adx; /* abs values of dx and dy */ + int ady; + int signdx; /* sign of dx and dy */ + int signdy; + int e, e1, e2; /* bresenham error and increments */ + int len; /* length of segment */ + int axis; /* major axis */ + int octant; + unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); + + /* a bunch of temporaries */ + register int y1, y2; + register int x1, x2; + RegionPtr cclip; + int alu; + + if (!(pGC->planemask & 0x0F)) + return; + + cclip = pGC->pCompositeClip; + alu = pGC->alu; /* GJA */ + pboxInit = REGION_RECTS(cclip); + nboxInit = REGION_NUM_RECTS(cclip); + + nlwidth = BYTES_PER_LINE(pDrawable) >> 2; /* GJA */ + addrlBase = (PixelType *)VIDBASE(pDrawable); /* GJA */ + + xorg = pDrawable->x; + yorg = pDrawable->y; +#ifdef POLYSEGMENT + while (nseg--) +#else + ppt = pptInit; + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; + while(--npt) +#endif + { + nbox = nboxInit; + pbox = pboxInit; + +#ifdef POLYSEGMENT + x1 = pSeg->x1 + xorg; + y1 = pSeg->y1 + yorg; + x2 = pSeg->x2 + xorg; + y2 = pSeg->y2 + yorg; + pSeg++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) + { + xorg = x1; + yorg = y1; + } + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; +#endif + + if (x1 == x2) /* vertical line */ + { + /* make the line go top to bottom of screen, keeping + endpoint semantics + */ + if (y1 > y2) + { + register int tmp; + + tmp = y2; + y2 = y1 + 1; + y1 = tmp + 1; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) + y1--; +#endif + } +#ifdef POLYSEGMENT + else if (pGC->capStyle != CapNotLast) + y2++; +#endif + /* get to first band that might contain part of line */ + while ((nbox) && (pbox->y2 <= y1)) + { + pbox++; + nbox--; + } + + if (nbox) + { + /* stop when lower edge of box is beyond end of line */ + while((nbox) && (y2 >= pbox->y1)) + { + if ((x1 >= pbox->x1) && (x1 < pbox->x2)) + { + int y1t, y2t; + /* this box has part of the line in it */ + y1t = max(y1, pbox->y1); + y2t = min(y2, pbox->y2); + if (y1t != y2t) + { + xf4bppVertS (addrlBase, nlwidth, + x1, y1t, y2t-y1t); + } + } + nbox--; + pbox++; + } + } +#ifndef POLYSEGMENT + y2 = ppt->y + yorg; +#endif + } + else if (y1 == y2) /* horizontal line */ + { + /* force line from left to right, keeping + endpoint semantics + */ + if (x1 > x2) + { + register int tmp; + + tmp = x2; + x2 = x1 + 1; + x1 = tmp + 1; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) + x1--; +#endif + } +#ifdef POLYSEGMENT + else if (pGC->capStyle != CapNotLast) + x2++; +#endif + + /* find the correct band */ + while( (nbox) && (pbox->y2 <= y1)) + { + pbox++; + nbox--; + } + + /* try to draw the line, if we haven't gone beyond it */ + if ((nbox) && (pbox->y1 <= y1)) + { + int tmp; + + /* when we leave this band, we're done */ + tmp = pbox->y1; + while((nbox) && (pbox->y1 == tmp)) + { + int x1t, x2t; + + if (pbox->x2 <= x1) + { + /* skip boxes until one might contain start point */ + nbox--; + pbox++; + continue; + } + + /* stop if left of box is beyond right of line */ + if (pbox->x1 >= x2) + { + nbox = 0; + break; + } + + x1t = max(x1, pbox->x1); + x2t = min(x2, pbox->x2); + if (x1t != x2t) + { + xf4bppHorzS (addrlBase, nlwidth, + x1t, y1, x2t-x1t); + } + nbox--; + pbox++; + } + } +#ifndef POLYSEGMENT + x2 = ppt->x + xorg; +#endif + } + else /* sloped line */ + { + CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, + 1, 1, octant); + + if (adx > ady) + { + axis = X_AXIS; + e1 = ady << 1; + e2 = e1 - (adx << 1); + e = e1 - adx; + } + else + { + axis = Y_AXIS; + e1 = adx << 1; + e2 = e1 - (ady << 1); + e = e1 - ady; + SetYMajorOctant(octant); + } + + FIXUP_ERROR(e, octant, bias); + + /* we have bresenham parameters and two points. + all we have to do now is clip and draw. + */ + + while(nbox--) + { + oc1 = 0; + oc2 = 0; + OUTCODES(oc1, x1, y1, pbox); + OUTCODES(oc2, x2, y2, pbox); + if ((oc1 | oc2) == 0) + { + if (axis == X_AXIS) + len = adx; + else + len = ady; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) + len++; +#endif + xf4bppBresS (addrlBase, nlwidth, + signdx, signdy, axis, x1, y1, + e, e1, e2, len); + break; + } + else if (oc1 & oc2) + { + pbox++; + } + else + { + int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; + int clip1 = 0, clip2 = 0; + int clipdx, clipdy; + int err; + + if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1, + pbox->y2-1, + &new_x1, &new_y1, &new_x2, &new_y2, + adx, ady, &clip1, &clip2, + octant, bias, oc1, oc2) == -1) + { + pbox++; + continue; + } + + if (axis == X_AXIS) + len = abs(new_x2 - new_x1); + else + len = abs(new_y2 - new_y1); +#ifdef POLYSEGMENT + if (clip2 != 0 || pGC->capStyle != CapNotLast) + len++; +#else + len += (clip2 != 0); +#endif + if (len) + { + /* unwind bresenham error term to first point */ + if (clip1) + { + clipdx = abs(new_x1 - x1); + clipdy = abs(new_y1 - y1); + if (axis == X_AXIS) + err = e+((clipdy*e2) + ((clipdx-clipdy)*e1)); + else + err = e+((clipdx*e2) + ((clipdy-clipdx)*e1)); + } + else + err = e; + xf4bppBresS (addrlBase, nlwidth, + signdx, signdy, axis, new_x1, new_y1, + err, e1, e2, len); + } + pbox++; + } + } /* while (nbox--) */ + } /* sloped line */ + } /* while (nline--) */ + +#ifndef POLYSEGMENT + + /* paint the last point if the end style isn't CapNotLast. + (Assume that a projecting, butt, or round cap that is one + pixel wide is the same as the single pixel of the endpoint.) + */ + + if ((pGC->capStyle != CapNotLast) && + ((ppt->x + xorg != pptInit->x + pDrawable->x) || + (ppt->y + yorg != pptInit->y + pDrawable->y) || + (ppt == pptInit + 1))) + { + PixelType _mask; + + if (alu == RROP_BLACK) + _mask = rmask[x2 & PIM]; + else + _mask = mask[x2 & PIM]; + + nbox = nboxInit; + pbox = pboxInit; + while (nbox--) + { + if ((x2 >= pbox->x1) && + (y2 >= pbox->y1) && + (x2 < pbox->x2) && + (y2 < pbox->y2)) + { + addrl = mfbScanline(addrlBase, x2, y2, nlwidth); + UPDRW(addrl,_mask); + break; + } + else + pbox++; + } + } +#endif +} + +/* + * Draw dashed 1-pixel lines. + */ + +#ifdef POLYSEGMENT +static void DoV16SegmentSD( +#if NeedFunctionPrototypes + DrawablePtr, GCPtr, int, xSegment* +#endif +); + +void +xf4bppSegmentSD (pDrawable, pGC, nseg, pSeg) + DrawablePtr pDrawable; + GCPtr pGC; + int nseg; + register xSegment *pSeg; +{ + if ( ! xf86Screens[pDrawable->pScreen->myNum]->vtSema ) { + miPolySegment(pDrawable, pGC, nseg, pSeg); + } else { + DO_WM3(pGC,DoV16SegmentSD (pDrawable, pGC, nseg, pSeg)); + } +} + +#else +static void DoV16LineSD( +#if NeedFunctionPrototypes + DrawablePtr, GCPtr, int, int, DDXPointPtr +#endif +); + +void +xf4bppLineSD (pDrawable, pGC, mode, npt, pptInit) + DrawablePtr pDrawable; + GCPtr pGC; + int mode; /* Origin or Previous */ + int npt; /* number of points */ + DDXPointPtr pptInit; +{ + if ( ! xf86Screens[pDrawable->pScreen->myNum]->vtSema ) { + miZeroDashLine(pDrawable, pGC, mode, npt, pptInit); + } else { + DO_WM3(pGC,DoV16LineSD (pDrawable, pGC, mode, npt, pptInit)); + } +} +#endif + +static void +#ifdef POLYSEGMENT +DoV16SegmentSD (pDrawable, pGC, nseg, pSeg) + DrawablePtr pDrawable; + register GCPtr pGC; + int nseg; + register xSegment *pSeg; +#else +DoV16LineSD( pDrawable, pGC, mode, npt, pptInit) + DrawablePtr pDrawable; + register GCPtr pGC; + int mode; /* Origin or Previous */ + int npt; /* number of points */ + DDXPointPtr pptInit; +#endif +{ + int nboxInit; + register int nbox; + BoxPtr pboxInit; + register BoxPtr pbox; +#ifndef POLYSEGMENT + register DDXPointPtr ppt; /* pointer to list of translated points */ +#endif + + register unsigned int oc1; /* outcode of point 1 */ + register unsigned int oc2; /* outcode of point 2 */ + + PixelType *addrl; /* address of destination pixmap */ + int nlwidth; /* width in longwords of destination pixmap */ + int xorg, yorg; /* origin of window */ + + int adx; /* abs values of dx and dy */ + int ady; + int signdx; /* sign of dx and dy */ + int signdy; + int e, e1, e2; /* bresenham error and increments */ + int len; /* length of segment */ + int axis; /* major axis */ + int octant; + unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); + int x1, x2, y1, y2; + RegionPtr cclip; + int fgink, bgink; /* GJA */ + unsigned char *pDash; + int dashOffset; + int numInDashList; + int dashIndex; + int isDoubleDash; + int dashIndexTmp, dashOffsetTmp; + int unclippedlen; + + if (!(pGC->planemask & 0x0F)) + return; + + cclip = pGC->pCompositeClip; + fgink = bgink = pGC->fgPixel; /* GJA */ + pboxInit = REGION_RECTS(cclip); + nboxInit = REGION_NUM_RECTS(cclip); + + nlwidth = BYTES_PER_LINE(pDrawable) >> 2; /* GJA */ + addrl = (PixelType *)VIDBASE(pDrawable); /* GJA */ + + /* compute initial dash values */ + + pDash = (unsigned char *) pGC->dash; + numInDashList = pGC->numInDashList; + isDoubleDash = (pGC->lineStyle == LineDoubleDash); + dashIndex = 0; + dashOffset = 0; + miStepDash ((int)pGC->dashOffset, &dashIndex, pDash, + numInDashList, &dashOffset); + + if (isDoubleDash) + bgink = pGC->bgPixel; /* GJA */ + + xorg = pDrawable->x; + yorg = pDrawable->y; +#ifdef POLYSEGMENT + while (nseg--) +#else + ppt = pptInit; + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; + while(--npt) +#endif + { + nbox = nboxInit; + pbox = pboxInit; + +#ifdef POLYSEGMENT + x1 = pSeg->x1 + xorg; + y1 = pSeg->y1 + yorg; + x2 = pSeg->x2 + xorg; + y2 = pSeg->y2 + yorg; + pSeg++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) + { + xorg = x1; + yorg = y1; + } + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; +#endif + + CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, 1, 1, octant); + + if (adx > ady) + { + axis = X_AXIS; + e1 = ady << 1; + e2 = e1 - (adx << 1); + e = e1 - adx; + unclippedlen = adx; + } + else + { + axis = Y_AXIS; + e1 = adx << 1; + e2 = e1 - (ady << 1); + e = e1 - ady; + unclippedlen = ady; + SetYMajorOctant(octant); + } + + FIXUP_ERROR(e, octant, bias); + + /* we have bresenham parameters and two points. + all we have to do now is clip and draw. + */ + + while(nbox--) + { + oc1 = 0; + oc2 = 0; + OUTCODES(oc1, x1, y1, pbox); + OUTCODES(oc2, x2, y2, pbox); + if ((oc1 | oc2) == 0) + { +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) + unclippedlen++; + dashIndexTmp = dashIndex; + dashOffsetTmp = dashOffset; + xf4bppBresD (pDrawable, fgink, bgink, + &dashIndexTmp, pDash, numInDashList, + &dashOffsetTmp, isDoubleDash, + addrl, nlwidth, + signdx, signdy, axis, x1, y1, + e, e1, e2, unclippedlen); + break; +#else + xf4bppBresD (pDrawable, fgink, bgink, + &dashIndex, pDash, numInDashList, + &dashOffset, isDoubleDash, + addrl, nlwidth, + signdx, signdy, axis, x1, y1, + e, e1, e2, unclippedlen); + goto dontStep; +#endif + } + else if (oc1 & oc2) + { + pbox++; + } + else /* have to clip */ + { + int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; + int clip1 = 0, clip2 = 0; + int clipdx, clipdy; + int err; + + if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1, pbox->y2-1, + &new_x1, &new_y1, &new_x2, &new_y2, + adx, ady, &clip1, &clip2, + octant, bias, oc1, oc2) == -1) + { + pbox++; + continue; + } + dashIndexTmp = dashIndex; + dashOffsetTmp = dashOffset; + if (clip1) + { + int dlen; + + if (axis == X_AXIS) + dlen = abs(new_x1 - x1); + else + dlen = abs(new_y1 - y1); + miStepDash (dlen, &dashIndexTmp, pDash, + numInDashList, &dashOffsetTmp); + } + if (axis == X_AXIS) + len = abs(new_x2 - new_x1); + else + len = abs(new_y2 - new_y1); +#ifdef POLYSEGMENT + if (clip2 != 0 || pGC->capStyle != CapNotLast) + len++; +#else + len += (clip2 != 0); +#endif + if (len) + { + /* unwind bresenham error term to first point */ + if (clip1) + { + clipdx = abs(new_x1 - x1); + clipdy = abs(new_y1 - y1); + if (axis == X_AXIS) + err = e+((clipdy*e2) + ((clipdx-clipdy)*e1)); + else + err = e+((clipdx*e2) + ((clipdy-clipdx)*e1)); + } + else + err = e; + xf4bppBresD (pDrawable, fgink, bgink, + &dashIndexTmp, pDash, numInDashList, + &dashOffsetTmp, isDoubleDash, + addrl, nlwidth, + signdx, signdy, axis, new_x1, new_y1, + err, e1, e2, len); + } + pbox++; + } + } /* while (nbox--) */ +#ifndef POLYSEGMENT + /* + * walk the dash list around to the next line + */ + miStepDash (unclippedlen, &dashIndex, pDash, + numInDashList, &dashOffset); +dontStep: ; +#endif + } /* while (nline--) */ + +#ifndef POLYSEGMENT + /* paint the last point if the end style isn't CapNotLast. + (Assume that a projecting, butt, or round cap that is one + pixel wide is the same as the single pixel of the endpoint.) + */ + + if ((pGC->capStyle != CapNotLast) && + ((dashIndex & 1) == 0 || isDoubleDash) && + ((ppt->x + xorg != pptInit->x + pDrawable->x) || + (ppt->y + yorg != pptInit->y + pDrawable->y) || + (ppt == pptInit + 1))) + { + nbox = nboxInit; + pbox = pboxInit; + while (nbox--) + { + if ((x2 >= pbox->x1) && + (y2 >= pbox->y1) && + (x2 < pbox->x2) && + (y2 < pbox->y2)) + { + unsigned long _mask; + int ink; + + ink = fgink; + if (dashIndex & 1) ink = bgink; + _mask = mask[x2 & PIM]; + addrl = mfbScanline(addrl, x2, y2, nlwidth); + UPDRW(addrl,_mask); + break; + } + else + pbox++; + } + } +#endif +} + + +#if 0 +#ifndef POLYSEGMENT +/* + the clipping code could be cleaned up some; most of its +mess derives from originally being inline in the line code, +then pulled out to make clipping dashes easier. +*/ + +int +mfbClipLine(pbox, box, + ppt1Orig, ppt1, ppt2, + adx, ady, signdx, signdy, axis, + pclip1, pclip2) +BoxPtr pbox; /* box to clip to */ +BoxRec box; /* box to do calculations with */ +DDXPointPtr ppt1Orig, ppt1, ppt2; +int adx, ady; +int signdx, signdy; +register int axis; +int *pclip1, *pclip2; +{ + DDXPointRec pt1Orig, pt1, pt2; + register int swapped = 0; + int clipDone = 0; + register unsigned int utmp; + register int oc1, oc2; + int clip1, clip2; + + pt1Orig = *ppt1Orig; + pt1 = *ppt1; + pt2 = *ppt2; + clip1 = 0; + clip2 = 0; + + do + { + oc1 = 0; + oc2 = 0; + OUTCODES(oc1, pt1.x, pt1.y, pbox); + OUTCODES(oc2, pt2.x, pt2.y, pbox); + + if (oc1 & oc2) + clipDone = -1; + else if ((oc1 | oc2) == 0) + { + clipDone = 1; + if (swapped) + { + SWAPPT(pt1, pt2); + SWAPINT(oc1, oc2); + SWAPINT(clip1, clip2); + } + } + else /* have to clip */ + { + /* only clip one point at a time */ + if (!oc1) + { + SWAPPT(pt1, pt2); + SWAPINT(oc1, oc2); + SWAPINT(clip1, clip2); + swapped = !swapped; + } + + clip1 |= oc1; + if (oc1 & OUT_LEFT) + { + pt1.x = box.x1; + utmp = abs(box.x1 - pt1Orig.x); + utmp *= ady; + if(axis==X_AXIS) + { + pt1.y = pt1Orig.y + SignTimes(signdy, round(utmp, adx)); + } + else + { + utmp <<= 1; + if (swapped) + utmp += ady; + else + utmp -= ady; + pt1.y = pt1Orig.y + SignTimes(signdy, ceiling(utmp, 2*adx)); + if (swapped) + pt1.y -= signdy; + } + } + else if (oc1 & OUT_ABOVE) + { + pt1.y = box.y1; + utmp = abs(box.y1 - pt1Orig.y); + utmp *= adx; + if (axis == Y_AXIS) + { + pt1.x = pt1Orig.x + SignTimes(signdx, round(utmp, ady)); + } + else + { + utmp <<= 1; + if (swapped) + utmp += adx; + else + utmp -= adx; + pt1.x = pt1Orig.x + SignTimes(signdx, ceiling(utmp, 2*ady)); + if (swapped) + pt1.x -= signdx; + } + } + else if (oc1 & OUT_RIGHT) + { + pt1.x = box.x2; + utmp = abs(pt1Orig.x - box.x2); + utmp *= ady; + if (axis == X_AXIS) + { + pt1.y = pt1Orig.y + SignTimes(signdy, round(utmp, adx)); + } + else + { + utmp <<= 1; + if (swapped) + utmp += ady; + else + utmp -= ady; + pt1.y = pt1Orig.y + SignTimes(signdy, ceiling(utmp, 2*adx)); + if (swapped) + pt1.y -= signdy; + } + } + else if (oc1 & OUT_BELOW) + { + pt1.y = box.y2; + utmp = abs(pt1Orig.y - box.y2); + utmp *= adx; + if (axis == Y_AXIS) + { + pt1.x = pt1Orig.x + SignTimes(signdx, round(utmp, ady)); + } + else + { + utmp <<= 1; + if (swapped) + utmp += adx; + else + utmp -= adx; + pt1.x = pt1Orig.x + SignTimes(signdx, ceiling(utmp, 2*ady)); + if (swapped) + pt1.x -= signdx; + } + } + } /* else have to clip */ + } while(!clipDone); + *ppt1 = pt1; + *ppt2 = pt2; + *pclip1 = clip1; + *pclip2 = clip2; + + return clipDone; +} +#endif +#endif diff --git a/hw/xfree86/xf4bpp/mfbzerarc.c b/hw/xfree86/xf4bpp/mfbzerarc.c new file mode 100644 index 000000000..7ca32d903 --- /dev/null +++ b/hw/xfree86/xf4bpp/mfbzerarc.c @@ -0,0 +1,266 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/mfbzerarc.c,v 1.5 2003/02/18 21:29:59 tsi Exp $ */ + +/************************************************************ + +Copyright (c) 1989 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + +********************************************************/ +/* GJA -- Took mfb code and modified it. */ + +/* $XConsortium: mfbzerarc.c /main/4 1996/02/21 17:56:52 kaleb $ */ + +/* Derived from: + * "Algorithm for drawing ellipses or hyperbolae with a digital plotter" + * by M. L. V. Pitteway + * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289 + */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "mizerarc.h" +#include "wm3.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +/* + * Note, LEFTMOST must be the bit leftmost in the actual screen + * representation. This depends on both BITMAP_BIT_ORDER and + * IMAGE_BYTE_ORDER + * DHD 10/92 + */ + +#if (BITMAP_BIT_ORDER == MSBFirst) +#if (IMAGE_BYTE_ORDER == MSBFirst) +#define LEFTMOST ((unsigned int) 0x80000000) +#else +#define LEFTMOST ((unsigned int) 0x80) +#endif +#else +#if (IMAGE_BYTE_ORDER == LSBFirst) +#define LEFTMOST ((unsigned int) 1) +#else +#define LEFTMOST ((unsigned int) 0x1000000) +#endif +#endif + +#define PixelateWhite(addr,off) \ +{ \ + register int *tmpaddr = &((addr)[(off)>>PWSH]); \ + UPDRW(tmpaddr,SCRRIGHT (LEFTMOST, ((off) & PIM))); \ +} +#define PixelateBlack(addr,off) \ +{ \ + register int *tmpaddr = &((addr)[(off)>>PWSH]); \ + UPDRW(tmpaddr,~(SCRRIGHT (LEFTMOST, ((off) & PIM)))); \ +} + +#define Pixelate(base,off) \ +{ \ + paddr = base + ((off)>>PWSH); \ + pmask = SCRRIGHT(LEFTMOST, (off) & PIM); \ + UPDRW(paddr,(pixel & pmask)); \ +} + +#define DoPix(bit,base,off) if (msk & bit) Pixelate(base,off); + +static void +v16ZeroArcSS +( + DrawablePtr pDraw, + GCPtr pGC, + xArc *arc +) +{ + miZeroArcRec info; + Bool do360; + register int x, y, a, b, d, msk; + register int k1, k3, dx, dy; + int *addrl; + int *yorgl, *yorgol; + unsigned long pixel; + int nlwidth, yoffset, dyoffset; + int pmask; + register int *paddr; + + if (((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop == + RROP_BLACK) + pixel = 0; + else + pixel = ~0UL; + + if (pDraw->type == DRAWABLE_WINDOW) + { + addrl = (int *) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr); + nlwidth = (int) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2; + } + else + { + addrl = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr); + nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2; + } + + do360 = miZeroArcSetup(arc, &info, TRUE); + yorgl = addrl + ((info.yorg + pDraw->y) * nlwidth); + yorgol = addrl + ((info.yorgo + pDraw->y) * nlwidth); + info.xorg += pDraw->x; + info.xorgo += pDraw->x; + MIARCSETUP(); + yoffset = y ? nlwidth : 0; + dyoffset = 0; + msk = info.initialMask; + if (!(arc->width & 1)) + { + DoPix(2, yorgl, info.xorgo); + DoPix(8, yorgol, info.xorgo); + } + if (!info.end.x || !info.end.y) + { + msk = info.end.mask; + info.end = info.altend; + } + if (do360 && (arc->width == arc->height) && !(arc->width & 1)) + { + int xoffset = nlwidth; + int *yorghl = yorgl + (info.h * nlwidth); + int xorghp = info.xorg + info.h; + int xorghn = info.xorg - info.h; + + while (1) + { + PixelateWhite(yorgl + yoffset, info.xorg + x); + PixelateWhite(yorgl + yoffset, info.xorg - x); + PixelateWhite(yorgol- yoffset, info.xorg - x); + PixelateWhite(yorgol - yoffset, info.xorg + x); + if (a < 0) + break; + PixelateWhite(yorghl - xoffset, xorghp - y); + PixelateWhite(yorghl - xoffset, xorghn + y); + PixelateWhite(yorghl + xoffset, xorghn + y); + PixelateWhite(yorghl + xoffset, xorghp - y); + xoffset += nlwidth; + MIARCCIRCLESTEP(yoffset += nlwidth;); + } + x = info.w; + yoffset = info.h * nlwidth; + } + else if (do360) + { + while (y < info.h || x < info.w) + { + MIARCOCTANTSHIFT(dyoffset = nlwidth;); + Pixelate(yorgl + yoffset, info.xorg + x); + Pixelate(yorgl + yoffset, info.xorgo - x); + Pixelate(yorgol - yoffset, info.xorgo - x); + Pixelate(yorgol - yoffset, info.xorg + x); + MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;); + } + } + else + { + while (y < info.h || x < info.w) + { + MIARCOCTANTSHIFT(dyoffset = nlwidth;); + if ((x == info.start.x) || (y == info.start.y)) + { + msk = info.start.mask; + info.start = info.altstart; + } + DoPix(1, yorgl + yoffset, info.xorg + x); + DoPix(2, yorgl + yoffset, info.xorgo - x); + DoPix(4, yorgol - yoffset, info.xorgo - x); + DoPix(8, yorgol - yoffset, info.xorg + x); + if ((x == info.end.x) || (y == info.end.y)) + { + msk = info.end.mask; + info.end = info.altend; + } + MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;); + } + } + if ((x == info.start.x) || (y == info.start.y)) + msk = info.start.mask; + DoPix(1, yorgl + yoffset, info.xorg + x); + DoPix(4, yorgol - yoffset, info.xorgo - x); + if (arc->height & 1) + { + DoPix(2, yorgl + yoffset, info.xorgo - x); + DoPix(8, yorgol - yoffset, info.xorg + x); + } +} + +static void +xf4bppZeroPolyArcSS +( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +) +{ + register xArc *arc; + register int i; + BoxRec box; + RegionPtr cclip; + + if (!pGC->planemask & 0x0F) + return; + cclip = pGC->pCompositeClip; + for (arc = parcs, i = narcs; --i >= 0; arc++) + { + if (miCanZeroArc(arc)) + { + box.x1 = arc->x + pDraw->x; + box.y1 = arc->y + pDraw->y; + box.x2 = box.x1 + (int)arc->width + 1; + box.y2 = box.y1 + (int)arc->height + 1; + if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) + v16ZeroArcSS(pDraw, pGC, arc); + else + miZeroPolyArc(pDraw, pGC, 1, arc); + } + else + miPolyArc(pDraw, pGC, 1, arc); + } +} + +void +xf4bppZeroPolyArc(pDraw, pGC, narcs, parcs) + DrawablePtr pDraw; + GCPtr pGC; + int narcs; + xArc *parcs; +{ + if ( !xf86Screens[pDraw->pScreen->myNum]->vtSema ) { + miZeroPolyArc(pDraw, pGC, narcs, parcs); + } else { + DO_WM3(pGC,xf4bppZeroPolyArcSS(pDraw, pGC, narcs, parcs)); + } +} diff --git a/hw/xfree86/xf4bpp/offscreen.c b/hw/xfree86/xf4bpp/offscreen.c new file mode 100644 index 000000000..1d118863f --- /dev/null +++ b/hw/xfree86/xf4bpp/offscreen.c @@ -0,0 +1,359 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/offscreen.c,v 1.5 2001/08/01 00:44:56 tsi Exp $ */ +/* + * Copyright 1993 Gerrit Jan Akkerman + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 Gerrit Jan Akkerman not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * GERRIT JAN AKKERMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL GERRIT JAN AKKERMAN 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. + * +*/ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: offscreen.c /main/4 1996/02/21 17:56:55 kaleb $ */ + +#include "xf4bpp.h" +#include "vgaVideo.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "windowstr.h" + +#define saved_screen(pWin) \ + ((unsigned char *)(((PixmapPtr)((pWin)->drawable.pScreen->devPrivate))->devPrivate.ptr)) + +#define SAVEDSCREEN(pWin, x, y) \ + (*(saved_screen(pWin) + (y) * (BYTES_PER_LINE(pWin)) + (x))) + +#define DO_ROP(src,dst,alu,planes) \ + ((dst) = do_rop((src),(dst),(alu),(planes))) + +/* NOTE: + * The following to functions don't do anything. They're just there to + * provide a stable interface to the rest of the system. + */ + +static int +do_rop +( + int src, + int dst, + int alu, + const unsigned long planes +) +{ + int _dst; /* New dst */ + + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + _dst = 0; break ; + case GXinvert: /* 0xa NOT dst */ + _dst = ~dst; break ; + case GXset: /* 0xf 1 */ + _dst = src; break ; + default: + case GXnoop: /* 0x5 dst */ + return dst; + case GXnor: /* 0x8 NOT src AND NOT dst */ + _dst = ~src & ~dst; break ; + case GXandInverted: /* 0x4 NOT src AND dst */ + _dst = ~src & dst; break ; + case GXand: /* 0x1 src AND dst */ + _dst = src & dst; break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + _dst = ~src ^ dst; break ; + case GXxor: /* 0x6 src XOR dst */ + _dst = src ^ dst; break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + _dst = src & ~dst; break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + _dst = ~src | ~dst; break ; + case GXorReverse: /* 0xb src OR NOT dst */ + _dst = src | ~dst; break ; + case GXorInverted: /* 0xd NOT src OR dst */ + _dst = ~src | dst; break ; + case GXor: /* 0x7 src OR dst */ + _dst = src | dst; break ; + case GXcopyInverted: /* 0xc NOT src */ + _dst = ~src; break ; + case GXcopy: /* 0x3 src */ + _dst = src; break ; + } + return (dst & ~planes) | (_dst & planes); +} + +/* File vgaBitBlt.c */ +void +xf4bppOffBitBlt( pWin, alu, writeplanes, x0, y0, x1, y1, w, h ) +WindowPtr pWin; /* GJA */ +const int alu, writeplanes ; +register int x0 ; +int y0 ; +register int x1 ; +int y1 ; +register int w, h ; +{ + int x,y; + + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + xf4bppOffFillSolid( pWin, VGA_ALLPLANES, alu, writeplanes, + x0, y0, w, h ) ; + case GXnoop: /* 0x5 dst */ + return ; + default: + break ; + } + + if ( (w <= 0) || (h <= 0) ) return; + + for ( y = 0 ; y < h ; y++ ) { + for ( x = 0 ; x < w ; x++ ) { + DO_ROP(SAVEDSCREEN(pWin,x0+x,y0+y),SAVEDSCREEN(pWin,x1+x,y1+y), + alu,writeplanes); + } + } +} + +/* for file vgaImages.c */ + +void +xf4bppOffDrawColorImage( pWin, x, y, w, h, data, RowIncrement, alu, planes ) +WindowPtr pWin; /* GJA */ +int x, y ; +register int w, h ; +unsigned char *data ; +register int RowIncrement ; +const int alu ; +const unsigned long int planes ; +{ + int dx,dy; + + for ( dy = 0 ; dy < h ; dy++ ) { + for ( dx = 0 ; dx < w ; dx++ ) { + DO_ROP( data[dy * RowIncrement + dx], + SAVEDSCREEN(pWin,x+dx,y+dy), alu, planes); + } + } +} + +void +xf4bppOffReadColorImage( pWin, x, y, lx, ly, data, RowIncrement ) +WindowPtr pWin; /* GJA */ +int x, y ; +int lx, ly ; +unsigned char *data ; +int RowIncrement ; +{ + int dx, dy; + + if ( ( lx <= 0 ) || ( ly <= 0 ) ) + return ; + + for ( dy = 0 ; dy < ly ; dy++ ) { + for ( dx = 0 ; dx < lx ; dx++ ) { + data[dy*RowIncrement+dx] = SAVEDSCREEN(pWin,x+dx,y+dy); + } + } +} + +/* For file vgaSolid.c */ + +void xf4bppOffFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ) +WindowPtr pWin; /* GJA */ +unsigned long int color ; +const int alu ; +unsigned long int planes ; +register int x0 ; +register const int y0 ; +register int lx ; +register const int ly ; /* MUST BE > 0 !! */ +{ + int dx, dy; + + if ( ( lx == 0 ) || ( ly == 0 ) ) + return; + + for ( dy = 0 ; dy < ly ; dy++ ) { + for ( dx = 0 ; dx < lx ; dx++ ) { + DO_ROP(color,SAVEDSCREEN(pWin, x0+dx,y0+dy),alu,planes); + } + } +} + +/* For file vgaStipple.c */ + +/* GJA -- modified this to take both Width and Height, and to + * reduce x and y to Width and Height by taking remainders. + */ +static unsigned char +xygetbits +( + register int x, + register int y, + register const unsigned int Width, + register const unsigned int paddedByteWidth, + register const unsigned int Height, + register const unsigned char * const data +) +{ + register unsigned char bits ; + unsigned const char *lineptr, *cptr ; + register int shift ; + register int wrap ; + + x = x % Width; + y = y % Height; + + lineptr = data + (y * paddedByteWidth); + cptr = lineptr + (x >> 3) ; + bits = *cptr ; + if ((shift = x & 7)) + bits = SCRLEFT8( bits, shift ) | + SCRRIGHT8( cptr[1], ( 8 - shift ) ) ; + if ( ( wrap = x + 8 - Width ) > 0 ) { + bits &= SCRLEFT8( 0xFF, wrap ) ; + bits |= SCRRIGHT8( *lineptr, ( 8 - wrap ) ) ; + } + + return bits ; +} + +static void +DoMono +( + WindowPtr pWin, /* GJA */ + int w, + int x, + int y, + register const unsigned char *mastersrc, + int h, + unsigned int width, + register unsigned int paddedByteWidth, + unsigned int height, + int xshift, + int yshift, + int alu, + int planes, + int fg +) +{ + int dy, dx, i; + int byte; + + for ( dy = 0 ; dy < h ; dy++ ) { + for ( dx = 0; dx <= w - 8 ; dx += 8 ) { + /* get next byte */ + byte = xygetbits(dx+xshift,dy+yshift,width, + paddedByteWidth, height, mastersrc); + for ( i = 0 ; i < 8 ; i++ ) { + if ( byte & (128 >> i) ) { + DO_ROP(fg,SAVEDSCREEN(pWin,x+dx+i,y+dy), + alu,planes); + } + } + } + /* get last bits */ + byte = xygetbits(dx+xshift,dy+yshift,width, + paddedByteWidth, height, mastersrc); + for ( i = 0 ; i < (w - dx) ; i++ ) { + if ( byte & (128 >> i) ) { + DO_ROP(fg,SAVEDSCREEN(pWin,x+dx+i,y+dy), + alu,planes); + } + } + } +} + +void +xf4bppOffDrawMonoImage( pWin, data, x, y, w, h, fg, alu, planes ) +WindowPtr pWin; /* GJA */ +unsigned char *data; +int x, y, w, h ; +unsigned long int fg ; +int alu ; +unsigned long int planes; +{ + + if ( ( alu == GXnoop ) || !( planes &= VGA_ALLPLANES ) ) + return ; + + DoMono( pWin, w, x, y, (const unsigned char *) data, h, + w, ( ( w + 31 ) & ~31 ) >> 3, h, 0, 0, alu, + (int)planes, (int)fg) ; + +} + +void +xf4bppOffFillStipple( pWin, pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc ) +WindowPtr pWin; /* GJA */ +register PixmapPtr const pStipple ; +unsigned long int fg ; +const int alu ; +unsigned long int planes ; +int x, y, w, h ; +const int xSrc, ySrc ; +{ + unsigned int width ; + unsigned int height ; + int xshift ; + int yshift ; + + if ( ( alu == GXnoop ) || !( planes &= VGA_ALLPLANES ) ) + return ; + + /* Figure Bit Offsets & Source Address */ + width = pStipple->drawable.width ; + if ( ( xshift = ( x - xSrc ) ) < 0 ) + xshift = width - ( ( - xshift ) % width ) ; + else + xshift %= width ; + + height = pStipple->drawable.height ; + if ( ( yshift = ( y - ySrc ) ) < 0 ) + yshift = height - ( ( - yshift ) % height ) ; + else + yshift %= height ; + + DoMono( pWin, w, x, y, + (const unsigned char *) pStipple->devPrivate.ptr, + h, + width, + ( ( width + 31 ) & (unsigned)(~31) ) >> 3, + height, + xshift, yshift, + alu, (int)planes, (int)fg ) ; + return ; +} diff --git a/hw/xfree86/xf4bpp/ppcArea.c b/hw/xfree86/xf4bpp/ppcArea.c new file mode 100644 index 000000000..40e9d5b32 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcArea.c @@ -0,0 +1,95 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcArea.c,v 1.4 2003/02/18 21:29:59 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: ppcArea.c /main/4 1996/02/21 17:57:02 kaleb $ */ + +/* + * ppc solid area fill + * + * Tom Paquin 8/87 + */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "ppcGCstr.h" +#include "ibmTrace.h" + +void +xf4bppFillArea( pWin, nboxes, pBox, pGC ) + register WindowPtr pWin ; + register int nboxes ; + register BoxPtr pBox ; + GCPtr pGC ; +{ +register int x, y, w, h ; +int alu ; +unsigned long int fg, bg, pm ; +int xSrc, ySrc ; +PixmapPtr pPixmap ; +ppcPrivGC *pPrivGC = pGC->devPrivates[mfbGCPrivateIndex].ptr; + +TRACE( ( "xf4bppFillArea(0x%x,%d,0x%x,0x%x)\n", pWin, nboxes, pBox, pGC ) ) ; + +if ( ( alu = pPrivGC->colorRrop.alu ) == GXnoop || !nboxes ) + return ; + +xSrc = pGC->patOrg.x + pWin->drawable.x ; +ySrc = pGC->patOrg.y + pWin->drawable.y ; + +pm = pPrivGC->colorRrop.planemask ; +fg = pPrivGC->colorRrop.fgPixel ; +bg = pPrivGC->colorRrop.bgPixel ; + +nboxes++ ; +switch ( pPrivGC->colorRrop.fillStyle ) { + case FillTiled: + for ( pPixmap = pGC->tile.pixmap ; --nboxes ; pBox++ ) + if ( ( w = pBox->x2 - ( x = pBox->x1 ) ) + && ( h = pBox->y2 - ( y = pBox->y1 ) ) ) + xf4bppTileRect( pWin, pPixmap, alu, pm, + x, y, w, h, xSrc, ySrc ) ; + break ; + case FillOpaqueStippled: + for ( pPixmap = pGC->stipple ; --nboxes ; pBox++ ) + if ( ( w = pBox->x2 - ( x = pBox->x1 ) ) + && ( h = pBox->y2 - ( y = pBox->y1 ) ) ) + xf4bppOpaqueStipple( pWin, pPixmap, fg, bg, alu, pm, + x, y, w, h, xSrc, ySrc ) ; + break ; + case FillStippled: + for ( pPixmap = pGC->stipple ; --nboxes ; pBox++ ) + if ( ( w = pBox->x2 - ( x = pBox->x1 ) ) + && ( h = pBox->y2 - ( y = pBox->y1 ) ) ) + xf4bppFillStipple( pWin, pPixmap, fg, alu, pm, + x, y, w, h, xSrc, ySrc ) ; + break ; + case FillSolid: + for ( ; --nboxes ; pBox++ ) + if ( ( w = pBox->x2 - ( x = pBox->x1 ) ) + && ( h = pBox->y2 - ( y = pBox->y1 ) ) ) + xf4bppFillSolid( pWin, fg, alu, pm, x, y, w, h ) ; + break ; +} + +} diff --git a/hw/xfree86/xf4bpp/ppcBStore.c b/hw/xfree86/xf4bpp/ppcBStore.c new file mode 100644 index 000000000..a1f49a486 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcBStore.c @@ -0,0 +1,153 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcBStore.c,v 1.3 1999/06/06 08:48:57 dawes Exp $ */ +/* + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM 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. + + +Copyright 1987 by the Regents of the University of California +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +*/ +/* $XConsortium: ppcBStore.c /main/5 1996/02/21 17:57:06 kaleb $ */ + +#include "xf4bpp.h" +#include "vgaVideo.h" +#include "ibmTrace.h" + +/*----------------------------------------------------------------------- + * xf4bppSaveAreas -- + * Function called by miSaveAreas to actually fetch the areas to be + * saved into the backing pixmap. + * + * Results: + * None. + * + * Side Effects: + * Data are copied from the screen into the pixmap. + * + *----------------------------------------------------------------------- + */ +void +xf4bppSaveAreas( pPixmap, prgnSave, xorg, yorg, pWin ) + register PixmapPtr pPixmap ; /* Backing pixmap */ + RegionPtr prgnSave ; /* Region to save (pixmap-relative) */ + int xorg ; /* X origin of region */ + int yorg ; /* Y origin of region */ + WindowPtr pWin; +{ + register BoxPtr pBox ; + register int nBox ; + + TRACE( ( "xf4bppSaveAreas(0x%x,0x%x,%d,%d)\n", + pPixmap, prgnSave, xorg, yorg ) ) ; +/* WHOOP WHOOP WHOOP XXX -- depth 8 *only* */ /* GJA -- ? */ + + if ( !( nBox = REGION_NUM_RECTS(prgnSave) ) ) + return ; + + for ( pBox = REGION_RECTS(prgnSave) ; nBox-- ; pBox++ ) + xf4bppReadColorImage( pWin, pBox->x1 + xorg, + pBox->y1 + yorg, + pBox->x2 - pBox->x1, + pBox->y2 - pBox->y1, + ( (unsigned char *) pPixmap->devPrivate.ptr ) + + ( pBox->y1 * pPixmap->devKind ) + pBox->x1, + pPixmap->devKind ) ; + + return ; +} + +/*----------------------------------------------------------------------- + * xf4bppRestoreAreas -- + * Function called by miRestoreAreas to actually fetch the areas to be + * restored from the backing pixmap. + * + * Results: + * None. + * + * Side Effects: + * Data are copied from the pixmap into the screen. + * + *----------------------------------------------------------------------- + */ +void +xf4bppRestoreAreas( pPixmap, prgnRestore, xorg, yorg, pWin ) + register PixmapPtr pPixmap ; /* Backing pixmap */ + RegionPtr prgnRestore ; /* Region to restore (screen-relative)*/ + int xorg ; /* X origin of window */ + int yorg ; /* Y origin of window */ + WindowPtr pWin; +{ + register BoxPtr pBox ; + register int nBox ; + + TRACE( ( "xf4bppRestoreAreas(0x%x,0x%x,%d,%d)\n", + pPixmap, prgnRestore, xorg, yorg ) ) ; +/* WHOOP WHOOP WHOOP XXX -- depth 8 *only* */ + + if ( !( nBox = REGION_NUM_RECTS(prgnRestore) ) ) + return ; + for ( pBox = REGION_RECTS(prgnRestore) ; nBox-- ; pBox++ ) + xf4bppDrawColorImage( pWin, pBox->x1, + pBox->y1, + pBox->x2 - pBox->x1, + pBox->y2 - pBox->y1, + ( (unsigned char *)pPixmap->devPrivate.ptr ) + + ( ( pBox->y1 - yorg ) * pPixmap->devKind ) + + ( pBox->x1 - xorg ), + pPixmap->devKind, + GXcopy, VGA_ALLPLANES ) ; + return ; +} diff --git a/hw/xfree86/xf4bpp/ppcCReduce.c b/hw/xfree86/xf4bpp/ppcCReduce.c new file mode 100644 index 000000000..a68f5faff --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcCReduce.c @@ -0,0 +1,236 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcCReduce.c,v 1.3 1999/06/06 08:48:58 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* $XConsortium: ppcCReduce.c /main/3 1996/02/21 17:57:17 kaleb $ */ + +#include "xf4bpp.h" +#include "ppcGCstr.h" + +/* xf4bppGetReducedColorRrop( pGC, drawableDepth, returnLoc ) + * An attempt to do "strength reduction" on color raster-ops + * P. Shupak 1/88 + */ + +static void +ppcReduceGeneral +( + register int alu, + register unsigned long pm, + register unsigned long fg, + register unsigned long bg, + register int fillStyle, + int drawableDepth, + ppcReducedRrop *returnLoc +) +{ + +if ( ( alu == GXnoop ) + || !( pm &= ( ( 1 << drawableDepth ) - 1 ) ) ) { + returnLoc->alu = GXnoop ; + return ; +} + +#ifdef DELETE_THIS +switch ( fillStyle ) { + case FillTiled: + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + fillStyle = FillSolid ; + default: /* We Can't Do Much Here */ + break ; + } + break ; + case FillOpaqueStippled: + if ( ( fg & pm ) != ( bg & pm ) ) { /* else FillSolid */ + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXset: /* 0xf 1 */ + case GXinvert: /* 0xa NOT dst */ + fillStyle = FillSolid ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + case GXnand: /* 0xe NOT src OR NOT dst */ + case GXcopy: /* 0x3 src */ + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXnor ; + break ; + case GXandInverted: /* 0x4 NOT src AND dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXand ; /* Fall Through */ + case GXand: /* 0x1 src AND dst */ + pm &= ~( fg & bg ) ; + if ( ( bg & pm ) == pm ) { + fillStyle = FillStippled ; + alu = GXclear ; + } + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXxor ; /* Fall Through */ + case GXxor: /* 0x6 src XOR dst */ + pm &= ( fg | bg ) ; + if ( !( bg & pm ) ) { + fillStyle = FillStippled ; + alu = GXinvert ; + } + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXnand ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + fg = ~fg ; + bg = ~bg ; + alu = GXcopy ; + break ; + case GXorInverted: /* 0xd NOT src OR dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXor ; /* Fall Through */ + case GXor: /* 0x7 src OR dst */ + pm &= ( fg | bg ) ; + if ( !( bg & pm ) ) { + fillStyle = FillStippled ; + alu = GXset ; + } + break ; + default: + ErrorF( + "xf4bppGetReducedColorRrop: Unknown Alu Raster-Op" ) ; + break ; + } + break ; /* Don't Fall Through */ + } + else + fillStyle = FillSolid ; + /* Fall Through */ + case FillStippled: + case FillSolid: + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXset: /* 0xf 1 */ + case GXinvert: /* 0xa NOT dst */ + break ; + case GXand: /* 0x1 src AND dst */ + pm &= ~fg ; + alu = GXclear ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + fg = ~fg ; + alu = GXnor ; /* Fall Through */ + case GXnor: /* 0x8 NOT src AND NOT dst */ + if ( !( fg & pm ) ) + alu = GXclear ; + else if ( ( fg & pm ) == pm ) + alu = GXinvert ; + break ; + case GXandInverted: /* 0x4 NOT src AND dst */ + pm &= fg ; + alu = GXclear ; + break ; + case GXxor: /* 0x6 src XOR dst */ + pm &= fg ; + alu = GXinvert ; + break ; + case GXor: /* 0x7 src OR dst */ + pm &= fg ; + alu = GXset ; + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + pm &= ~fg ; + alu = GXinvert ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + fg = ~fg ; + alu = GXnand ; /* Fall Through */ + case GXnand: /* 0xe NOT src OR NOT dst */ + if ( !( fg & pm ) ) + alu = GXset ; + else if ( ( fg & pm ) == pm ) + alu = GXinvert ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + fg = ~fg ; + alu = GXcopy ; /* Fall Through */ + case GXcopy: /* 0x3 src */ + if ( !( fg & pm ) ) + alu = GXclear ; + else if ( ( fg & pm ) == pm ) + alu = GXset ; + break ; + case GXorInverted: /* 0xd NOT src OR dst */ + pm &= ~fg ; + alu = GXset ; + break ; + default: + ErrorF( + "xf4bppGetReducedColorRrop: Unknown Alu Raster-Op" ) ; + break ; + } + break; + default: + ErrorF("xf4bppGetReducedColorRrop: Bad Fillstyle\n"); + break; +} +#endif + +/* Final Test On Restricted Plane Mask */ +if ( !pm ) + alu = GXnoop ; + +/* Set Actual Returned Values */ +returnLoc->planemask = pm ; +returnLoc->fgPixel = fg ; +returnLoc->bgPixel = bg ; +returnLoc->alu = alu ; +returnLoc->fillStyle = fillStyle ; + +return ; +} + +void +xf4bppGetReducedColorRrop( pGC, drawableDepth, returnLoc ) +GC *pGC ; +int drawableDepth ; +ppcReducedRrop *returnLoc ; +{ + +ppcReduceGeneral( pGC->alu, + pGC->planemask, + pGC->fgPixel, + pGC->bgPixel, + pGC->fillStyle, + drawableDepth, + returnLoc ) ; + +return ; +} diff --git a/hw/xfree86/xf4bpp/ppcClip.c b/hw/xfree86/xf4bpp/ppcClip.c new file mode 100644 index 000000000..cd307fe94 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcClip.c @@ -0,0 +1,153 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcClip.c,v 1.5 1999/09/25 14:38:16 dawes Exp $ */ +/* + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM 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. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +*/ +/* $XConsortium: ppcClip.c /main/4 1996/02/21 17:57:21 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "scrnintstr.h" + +void +xf4bppDestroyClip(pGC) + GCPtr pGC; +{ + if(pGC->clientClipType == CT_NONE) + return; + else if (pGC->clientClipType == CT_PIXMAP) + { + mfbDestroyPixmap((PixmapPtr)(pGC->clientClip)); + } + else + { + /* we know we'll never have a list of rectangles, since + ChangeClip immediately turns them into a region + */ + REGION_DESTROY(pGC->pScreen, pGC->clientClip); + } + pGC->clientClip = NULL; + pGC->clientClipType = CT_NONE; +} + +void +xf4bppChangeClip(pGC, type, pvalue, nrects) + GCPtr pGC; + int type; + pointer pvalue; + int nrects; +{ + xf4bppDestroyClip(pGC); + if(type == CT_PIXMAP) + { + /* convert the pixmap to a region */ + pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pvalue); + /* you wouldn't do this if you were leaving the pixmap in + rather than converting it. + */ + (*pGC->pScreen->DestroyPixmap)(pvalue); + } + else if (type == CT_REGION) + { + /* stuff the region in the GC */ + pGC->clientClip = pvalue; + } + else if (type != CT_NONE) + { + pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nrects, + (xRectangle *)pvalue, + type); + xfree(pvalue); + } + pGC->clientClipType = (type != CT_NONE && pGC->clientClip) ? CT_REGION : + CT_NONE; + pGC->stateChanges |= GCClipMask; +} + +void +xf4bppCopyClip (pgcDst, pgcSrc) + GCPtr pgcDst, pgcSrc; +{ + RegionPtr prgnNew; + + switch(pgcSrc->clientClipType) + { + case CT_PIXMAP: + ((PixmapPtr) pgcSrc->clientClip)->refcnt++; + /* Fall through !! */ + case CT_NONE: + xf4bppChangeClip(pgcDst, pgcSrc->clientClipType, pgcSrc->clientClip, 0); + break; + case CT_REGION: + prgnNew = REGION_CREATE(pgcSrc->pScreen, NULL, 1); + REGION_COPY(pgcSrc->pScreen, prgnNew, (RegionPtr)(pgcSrc->clientClip)); + xf4bppChangeClip(pgcDst, CT_REGION, (pointer)prgnNew, 0); + break; + } +} diff --git a/hw/xfree86/xf4bpp/ppcCpArea.c b/hw/xfree86/xf4bpp/ppcCpArea.c new file mode 100644 index 000000000..e5202c267 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcCpArea.c @@ -0,0 +1,494 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcCpArea.c,v 1.5 2000/09/26 15:57:21 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* $XConsortium: ppcCpArea.c /main/6 1996/02/21 17:57:24 kaleb $ */ + +/*********************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ + +#include "xf4bpp.h" +#include "mfbmap.h" +#define PSZ 8 +#include "cfb.h" +#include "cfbmskbits.h" +#include "mergerop.h" +#include "mi.h" +#include "pixmapstr.h" +#include "scrnintstr.h" + +/* + * Graft in the DoBitblt from cfb. It does everything correctly. + */ +static void +vga16DoBitblt +( + DrawablePtr pSrc, + DrawablePtr pDst, + int alu, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long planemask +) +{ + CARD32 *psrcBase, *pdstBase; + /* start of src and dst bitmaps */ + int widthSrc, widthDst; /* add to get to same position in next line */ + + BoxPtr pbox; + int nbox; + + BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2; + /* temporaries for shuffling rectangles */ + DDXPointPtr pptTmp, pptNew1, pptNew2; + /* shuffling boxes entails shuffling the + source points too */ + int w, h; + int xdir; /* 1 = left right, -1 = right left/ */ + int ydir; /* 1 = top down, -1 = bottom up */ + + MROP_DECLARE_REG() + + int careful; + + MROP_INITIALIZE(alu,planemask); + + cfbGetLongWidthAndPointer (pSrc, widthSrc, psrcBase) + + cfbGetLongWidthAndPointer (pDst, widthDst, pdstBase) + + /* XXX we have to err on the side of safety when both are windows, + * because we don't know if IncludeInferiors is being used. + */ + careful = ((pSrc == pDst) || + ((pSrc->type == DRAWABLE_WINDOW) && + (pDst->type == DRAWABLE_WINDOW))); + + pbox = REGION_RECTS(prgnDst); + nbox = REGION_NUM_RECTS(prgnDst); + + pboxNew1 = NULL; + pptNew1 = NULL; + pboxNew2 = NULL; + pptNew2 = NULL; + if (careful && (pptSrc->y < pbox->y1)) + { + /* walk source botttom to top */ + ydir = -1; + widthSrc = -widthSrc; + widthDst = -widthDst; + + if (nbox > 1) + { + /* keep ordering in each band, reverse order of bands */ + pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox); + if(!pboxNew1) + return; + pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox); + if(!pptNew1) + { + DEALLOCATE_LOCAL(pboxNew1); + return; + } + pboxBase = pboxNext = pbox+nbox-1; + while (pboxBase >= pbox) + { + while ((pboxNext >= pbox) && + (pboxBase->y1 == pboxNext->y1)) + pboxNext--; + pboxTmp = pboxNext+1; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp <= pboxBase) + { + *pboxNew1++ = *pboxTmp++; + *pptNew1++ = *pptTmp++; + } + pboxBase = pboxNext; + } + pboxNew1 -= nbox; + pbox = pboxNew1; + pptNew1 -= nbox; + pptSrc = pptNew1; + } + } + else + { + /* walk source top to bottom */ + ydir = 1; + } + + if (careful && (pptSrc->x < pbox->x1)) + { + /* walk source right to left */ + xdir = -1; + + if (nbox > 1) + { + /* reverse order of rects in each band */ + pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox); + pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox); + if(!pboxNew2 || !pptNew2) + { + if (pptNew2) DEALLOCATE_LOCAL(pptNew2); + if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2); + if (pboxNew1) + { + DEALLOCATE_LOCAL(pptNew1); + DEALLOCATE_LOCAL(pboxNew1); + } + return; + } + pboxBase = pboxNext = pbox; + while (pboxBase < pbox+nbox) + { + while ((pboxNext < pbox+nbox) && + (pboxNext->y1 == pboxBase->y1)) + pboxNext++; + pboxTmp = pboxNext; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp != pboxBase) + { + *pboxNew2++ = *--pboxTmp; + *pptNew2++ = *--pptTmp; + } + pboxBase = pboxNext; + } + pboxNew2 -= nbox; + pbox = pboxNew2; + pptNew2 -= nbox; + pptSrc = pptNew2; + } + } + else + { + /* walk source left to right */ + xdir = 1; + } + + while(nbox--) + { + w = pbox->x2 - pbox->x1; + h = pbox->y2 - pbox->y1; + + if( pSrc->type == DRAWABLE_WINDOW ) + xf4bppBitBlt( (WindowPtr)pDst, alu, planemask, + pptSrc->x, /* x0 */ + pptSrc->y, /* y0 */ + pbox->x1, /* x1 */ + pbox->y1, /* y1 */ + w, h ); /* w, h */ + else /* DRAWABLE_PIXMAP */ + xf4bppDrawColorImage( (WindowPtr)pDst, + pbox->x1, pbox->y1, + w, + h, + ((unsigned char *)((PixmapPtr)pSrc)->devPrivate.ptr + + pptSrc->x + (pptSrc->y*((PixmapPtr)pSrc)->devKind)), + ((PixmapPtr)pSrc)->devKind, + alu, planemask ) ; + pbox++; + pptSrc++; + } + if (pboxNew2) + { + DEALLOCATE_LOCAL(pptNew2); + DEALLOCATE_LOCAL(pboxNew2); + } + if (pboxNew1) + { + DEALLOCATE_LOCAL(pptNew1); + DEALLOCATE_LOCAL(pboxNew1); + } +} + + +/* + * Graft in the CopyArea from mfb/cfb. It does everything correctly. + */ + +RegionPtr +xf4bppCopyArea(pSrcDrawable, pDstDrawable, + pGC, srcx, srcy, width, height, dstx, dsty) +register DrawablePtr pSrcDrawable; +register DrawablePtr pDstDrawable; +register GC *pGC; +int srcx, srcy; +int width, height; +int dstx, dsty; +{ + RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */ + Bool freeSrcClip = FALSE; + + RegionPtr prgnExposed; + RegionRec rgnDst; + DDXPointPtr pptSrc; + register DDXPointPtr ppt; + register BoxPtr pbox; + int i; + register int dx; + register int dy; + xRectangle origSource; + DDXPointRec origDest; + int numRects; + BoxRec fastBox; + int fastClip = 0; /* for fast clipping with pixmap source */ + int fastExpose = 0; /* for fast exposures with pixmap source */ + + if ( pDstDrawable->type != DRAWABLE_WINDOW ) + return miCopyArea( pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, dstx, dsty ) ; + + /* Begin code from mfb/cfbCopyArea */ + + origSource.x = srcx; + origSource.y = srcy; + origSource.width = width; + origSource.height = height; + origDest.x = dstx; + origDest.y = dsty; + + if ((pSrcDrawable != pDstDrawable) && + pSrcDrawable->pScreen->SourceValidate) + { + (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height); + } + + srcx += pSrcDrawable->x; + srcy += pSrcDrawable->y; + + /* clip the source */ + + if (pSrcDrawable->type == DRAWABLE_PIXMAP) + { + if ((pSrcDrawable == pDstDrawable) && + (pGC->clientClipType == CT_NONE)) + { + prgnSrcClip = pGC->pCompositeClip; + } + else + { + fastClip = 1; + } + } + else + { + if (pGC->subWindowMode == IncludeInferiors) + { + if (!((WindowPtr) pSrcDrawable)->parent) + { + /* + * special case bitblt from root window in + * IncludeInferiors mode; just like from a pixmap + */ + fastClip = 1; + } + else if ((pSrcDrawable == pDstDrawable) && + (pGC->clientClipType == CT_NONE)) + { + prgnSrcClip = pGC->pCompositeClip; + } + else + { + prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable); + freeSrcClip = TRUE; + } + } + else + { + prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList; + } + } + + fastBox.x1 = srcx; + fastBox.y1 = srcy; + fastBox.x2 = srcx + width; + fastBox.y2 = srcy + height; + + /* Don't create a source region if we are doing a fast clip */ + if (fastClip) + { + fastExpose = 1; + /* + * clip the source; if regions extend beyond the source size, + * make sure exposure events get sent + */ + if (fastBox.x1 < pSrcDrawable->x) + { + fastBox.x1 = pSrcDrawable->x; + fastExpose = 0; + } + if (fastBox.y1 < pSrcDrawable->y) + { + fastBox.y1 = pSrcDrawable->y; + fastExpose = 0; + } + if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width) + { + fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width; + fastExpose = 0; + } + if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height) + { + fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height; + fastExpose = 0; + } + } + else + { + REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); + REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip); + } + + dstx += pDstDrawable->x; + dsty += pDstDrawable->y; + + if (pDstDrawable->type == DRAWABLE_WINDOW) + { + if (!((WindowPtr)pDstDrawable)->realized) + { + if (!fastClip) + REGION_UNINIT(pGC->pScreen, &rgnDst); + if (freeSrcClip) + REGION_DESTROY(pGC->pScreen, prgnSrcClip); + return NULL; + } + } + + dx = srcx - dstx; + dy = srcy - dsty; + + /* Translate and clip the dst to the destination composite clip */ + if (fastClip) + { + RegionPtr cclip; + + /* Translate the region directly */ + fastBox.x1 -= dx; + fastBox.x2 -= dx; + fastBox.y1 -= dy; + fastBox.y2 -= dy; + + /* If the destination composite clip is one rectangle we can + do the clip directly. Otherwise we have to create a full + blown region and call intersect */ + cclip = pGC->pCompositeClip; + if (REGION_NUM_RECTS(cclip) == 1) + { + BoxPtr pBox = REGION_RECTS(cclip); + + if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1; + if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2; + if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1; + if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2; + + /* Check to see if the region is empty */ + if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) + { + REGION_INIT(pGC->pScreen, &rgnDst, NullBox, 0); + } + else + { + REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); + } + } + else + { + /* We must turn off fastClip now, since we must create + a full blown region. It is intersected with the + composite clip below. */ + fastClip = 0; + REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); + } + } + else + { + REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy); + } + + if (!fastClip) + { + REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, pGC->pCompositeClip); + } + + /* Do bit blitting */ + numRects = REGION_NUM_RECTS(&rgnDst); + if (numRects && width && height) + { + if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects * + sizeof(DDXPointRec)))) + { + REGION_UNINIT(pGC->pScreen, &rgnDst); + if (freeSrcClip) + REGION_DESTROY(pGC->pScreen, prgnSrcClip); + return NULL; + } + pbox = REGION_RECTS(&rgnDst); + ppt = pptSrc; + for (i = numRects; --i >= 0; pbox++, ppt++) + { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + vga16DoBitblt(pSrcDrawable, pDstDrawable, pGC->alu, + &rgnDst, pptSrc, pGC->planemask ); + DEALLOCATE_LOCAL(pptSrc); + } + + prgnExposed = NULL; + if (pGC->fExpose) + { + /* Pixmap sources generate a NoExposed (we return NULL to do this) */ + if (!fastExpose) + prgnExposed = + miHandleExposures(pSrcDrawable, pDstDrawable, pGC, + origSource.x, origSource.y, + (int)origSource.width, + (int)origSource.height, + origDest.x, origDest.y, (unsigned long)0); + } + REGION_UNINIT(pGC->pScreen, &rgnDst); + if (freeSrcClip) + REGION_DESTROY(pGC->pScreen, prgnSrcClip); + return prgnExposed; +} diff --git a/hw/xfree86/xf4bpp/ppcDepth.c b/hw/xfree86/xf4bpp/ppcDepth.c new file mode 100644 index 000000000..919fa0133 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcDepth.c @@ -0,0 +1,52 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcDepth.c,v 1.3 1999/06/06 08:48:58 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* $XConsortium: ppcDepth.c /main/3 1996/02/21 17:57:31 kaleb $ */ + +/* Check to see if the alleged depth is acceptable for the Screen + * + * T. Paquin 9/87 + * + */ + +#include "xf4bpp.h" +#include "scrnintstr.h" + +Bool +xf4bppDepthOK(pDraw,depth) +register DrawablePtr pDraw; +register int depth; +{ +register ScreenPtr pScreen= pDraw->pScreen; +register int i = pScreen->numDepths; + + if ( ( pDraw->type == DRAWABLE_PIXMAP ) && ( depth == 1 ) ) + return TRUE ; + + while ( i-- ) + if ( depth == pScreen->allowedDepths[i].depth ) + return TRUE ; + + return FALSE ; +} diff --git a/hw/xfree86/xf4bpp/ppcFillRct.c b/hw/xfree86/xf4bpp/ppcFillRct.c new file mode 100644 index 000000000..7e1c866ef --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcFillRct.c @@ -0,0 +1,221 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcFillRct.c,v 1.5 2003/02/18 21:29:59 tsi Exp $ */ +/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* $XConsortium: ppcFillRct.c /main/5 1996/02/21 17:57:35 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "scrnintstr.h" + +#define MODEQ(a, b) ((a) %= (b)) + +/* + filled rectangles. + translate the rectangles, clip them, and call the +helper function in the GC. +*/ + +#define NUM_STACK_RECTS 1024 + +void +xf4bppPolyFillRect(pDrawable, pGC, nrectFill, prectInit) + DrawablePtr pDrawable; + GCPtr pGC; + int nrectFill; /* number of rectangles to fill */ + xRectangle *prectInit; /* Pointer to first rectangle to fill */ +{ + xRectangle *prect; + RegionPtr prgnClip; + register BoxPtr pbox; + register BoxPtr pboxClipped; + BoxPtr pboxClippedBase; + BoxPtr pextent; + BoxRec stackRects[NUM_STACK_RECTS]; + int numRects; + int n; + int xorg, yorg; + mfbPrivGC *priv; +/* int alu; */ +/* mfbFillAreaProcPtr pfn; */ +/* PixmapPtr ppix; */ + + if (!(pGC->planemask & 0x0F)) /* GJA */ + return; + + priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr; +/* alu = priv->ropFillArea; */ +/* pfn = priv->FillArea; */ +/* ppix = pGC->pRotatedPixmap; */ + prgnClip = pGC->pCompositeClip; + + prect = prectInit; + xorg = pDrawable->x; + yorg = pDrawable->y; + if (xorg || yorg) + { + prect = prectInit; + n = nrectFill; + Duff (n, prect->x += xorg; prect->y += yorg; prect++); + } + + + prect = prectInit; + + numRects = REGION_NUM_RECTS(prgnClip) * nrectFill; + if (numRects > NUM_STACK_RECTS) + { + pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec)); + if (!pboxClippedBase) + return; + } + else + pboxClippedBase = stackRects; + + pboxClipped = pboxClippedBase; + + if (REGION_NUM_RECTS(prgnClip) == 1) + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_RECTS(prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + if ((pboxClipped->x1 = prect->x) < x1) + pboxClipped->x1 = x1; + + if ((pboxClipped->y1 = prect->y) < y1) + pboxClipped->y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + pboxClipped->x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + pboxClipped->y2 = by2; + + prect++; + if ((pboxClipped->x1 < pboxClipped->x2) && + (pboxClipped->y1 < pboxClipped->y2)) + { + pboxClipped++; + } + } + } + else + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_EXTENTS(pGC->pScreen, prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + BoxRec box; + + if ((box.x1 = prect->x) < x1) + box.x1 = x1; + + if ((box.y1 = prect->y) < y1) + box.y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + box.x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + box.y2 = by2; + + prect++; + + if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) + continue; + + n = REGION_NUM_RECTS (prgnClip); + pbox = REGION_RECTS(prgnClip); + + /* clip the rectangle to each box in the clip region + this is logically equivalent to calling Intersect() + */ + while(n--) + { + pboxClipped->x1 = max(box.x1, pbox->x1); + pboxClipped->y1 = max(box.y1, pbox->y1); + pboxClipped->x2 = min(box.x2, pbox->x2); + pboxClipped->y2 = min(box.y2, pbox->y2); + pbox++; + + /* see if clipping left anything */ + if(pboxClipped->x1 < pboxClipped->x2 && + pboxClipped->y1 < pboxClipped->y2) + { + pboxClipped++; + } + } + } + } + if (pboxClipped != pboxClippedBase) + xf4bppFillArea((WindowPtr)pDrawable, pboxClipped-pboxClippedBase, + pboxClippedBase, pGC); + if (pboxClippedBase != stackRects) + DEALLOCATE_LOCAL(pboxClippedBase); +} diff --git a/hw/xfree86/xf4bpp/ppcGC.c b/hw/xfree86/xf4bpp/ppcGC.c new file mode 100644 index 000000000..df8ae335f --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcGC.c @@ -0,0 +1,458 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGC.c,v 1.8 2003/02/18 21:29:59 tsi Exp $ */ +/* + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM 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. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +*/ + +/* $XConsortium: ppcGC.c /main/6 1996/02/21 17:57:38 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "scrnintstr.h" +#include "ppcGCstr.h" +#include "vgaVideo.h" +#include "ibmTrace.h" + +#define ppcGCInterestValidateMask \ +( GCLineStyle | GCLineWidth | GCJoinStyle | GCBackground | GCForeground \ +| GCFunction | GCPlaneMask | GCFillStyle | GC_CALL_VALIDATE_BIT \ +| GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode ) + + +/* GJA -- we modified the following function to get rid of + * the records in file vgaData.c + */ +static GCFuncs vgaGCFuncs = { + xf4bppValidateGC, + (void (*)())NoopDDA, + (void (*)())NoopDDA, + xf4bppDestroyGC, + xf4bppChangeClip, + xf4bppDestroyClip, + xf4bppCopyClip, + { NULL } +}; + + +static ppcPrivGC vgaPrototypeGCPriv = { + GXcopy, /* unsigned char rop */ + 0, /* unsigned char ropOpStip */ + 0, /* unsigned char ropFillArea */ + {0, }, /* unsigned char unused[sizeof(long) - 3] */ + NULL, /* mfbFillAreaProcPtr FillArea */ + { + VGA_ALLPLANES, /* unsigned long planemask */ + 1, /* unsigned long fgPixel */ + 0, /* unsigned long bgPixel */ + GXcopy, /* int alu */ + FillSolid, /* int fillStyle */ + }, /* ppcReducedRrop colorRrop */ + -1, /* short lastDrawableType */ + -1, /* short lastDrawableDepth */ + 0 /* pointer devPriv */ +} ; + +static GCOps vgaGCOps = { + xf4bppSolidWindowFS, /* void (* FillSpans)() */ + xf4bppSetSpans, /* void (* SetSpans)() */ + miPutImage, /* void (* PutImage)() */ + xf4bppCopyArea, /* RegionPtr (* CopyArea)() */ + miCopyPlane, /* void (* CopyPlane)() */ + xf4bppPolyPoint, /* void (* PolyPoint)() */ + miZeroLine, /* void (* Polylines)() */ + miPolySegment, /* void (* PolySegment)() */ + miPolyRectangle, /* void (* PolyRectangle)() */ + xf4bppZeroPolyArc, /* void (* PolyArc)() */ + miFillPolygon, /* void (* FillPolygon)() */ + miPolyFillRect, /* void (* PolyFillRect)() */ + xf4bppPolyFillArc, /* void (* PolyFillArc)() */ + miPolyText8, /* int (* PolyText8)() */ + miPolyText16, /* int (* PolyText16)() */ + miImageText8, /* void (* ImageText8)() */ + miImageText16, /* void (* ImageText16)() */ + xf4bppImageGlyphBlt, /* GJA -- void (* ImageGlyphBlt)() */ + miPolyGlyphBlt, /* GJA -- void (* PolyGlyphBlt)() */ + miPushPixels, /* void (* PushPixels)() */ +#ifdef NEED_LINEHELPER + miMiter, /* void (* LineHelper)() */ +#endif + {NULL} /* devPrivate */ +}; + +Bool +xf4bppCreateGC( pGC ) +register GCPtr pGC ; +{ + ppcPrivGC *pPriv ; + GCOps *pOps ; + + if ( pGC->depth == 1 ) + { + return (mfbCreateGC(pGC)); + } + + if ( !( pPriv = xalloc( sizeof( ppcPrivGC ) ) ) ) + return FALSE ; + + if ( !( pOps = xalloc( sizeof( GCOps ) ) ) ) { + xfree(pPriv); + return FALSE; + } + + /* Now we initialize the GC fields */ + pGC->miTranslate = 1; + pGC->unused = 0; + pGC->planemask = VGA_ALLPLANES; + pGC->fgPixel = VGA_BLACK_PIXEL; + pGC->bgPixel = VGA_WHITE_PIXEL; + pGC->funcs = &vgaGCFuncs; + /* ops, -- see below */ + + pGC->fExpose = TRUE; + pGC->freeCompClip = FALSE; + pGC->pRotatedPixmap = NullPixmap; + + /* GJA: I don't like this code: + * they allocated a mfbPrivGC, ignore the allocated data and place + * a pointer to a ppcPrivGC in its slot. + */ + *pPriv = vgaPrototypeGCPriv; + (pGC->devPrivates[mfbGCPrivateIndex].ptr) = (pointer) pPriv; + + /* Set the vgaGCOps */ + *pOps = vgaGCOps; + pOps->devPrivate.val = 1; + pGC->ops = pOps; + + return TRUE ; +} + +void +xf4bppDestroyGC( pGC ) + register GC *pGC ; + +{ + TRACE( ( "xf4bppDestroyGC(pGC=0x%x)\n", pGC ) ) ; + + /* (ef) 11/9/87 -- ppc doesn't use rotated tile or stipple, but */ + /* *does* call mfbValidateGC under some conditions. */ + /* mfbValidateGC *does* use rotated tile and stipple */ + if ( pGC->pRotatedPixmap ) + mfbDestroyPixmap( pGC->pRotatedPixmap ) ; + + if ( pGC->freeCompClip && pGC->pCompositeClip ) + REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); + if(pGC->ops->devPrivate.val) xfree( pGC->ops ); + xfree( pGC->devPrivates[mfbGCPrivateIndex].ptr ) ; + return ; +} + +static Mask +ppcChangePixmapGC +( + register GC *pGC, + register Mask changes +) +{ +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr ) ; +register unsigned long int idx ; /* used for stepping through bitfields */ + +#define LOWBIT( x ) ( x & - x ) /* Two's complement */ +while ((idx = LOWBIT(changes))) { + switch ( idx ) { + + case GCLineStyle: + case GCLineWidth: + pGC->ops->Polylines = ( ! pGC->lineWidth ) + ? miZeroLine + : ( ( pGC->lineStyle == LineSolid ) + ? miWideLine : miWideDash ) ; + changes &= ~( GCLineStyle | GCLineWidth ) ; + break ; + + case GCJoinStyle: +#ifdef NEED_LINEHELPER + pGC->ops->LineHelper = ( pGC->joinStyle == JoinMiter ) + ? miMiter : miNotMiter ; +#endif + changes &= ~ idx ; /* i.e. changes &= ~ GCJoinStyle */ + break ; + + case GCBackground: + if ( pGC->fillStyle != FillOpaqueStippled ) { + changes &= ~ idx ; /* i.e. changes &= ~GCBackground */ + break ; + } /* else Fall Through */ + case GCForeground: + if ( pGC->fillStyle == FillTiled ) { + changes &= ~ idx ; /* i.e. changes &= ~GCForeground */ + break ; + } /* else Fall Through */ + case GCFunction: + case GCPlaneMask: + case GCFillStyle: + { /* new_fill */ + int fillStyle = devPriv->colorRrop.fillStyle ; + /* install a suitable fillspans */ + if ( fillStyle == FillSolid ) + pGC->ops->FillSpans = xf4bppSolidPixmapFS ; + else if ( fillStyle == FillStippled ) + pGC->ops->FillSpans = xf4bppStipplePixmapFS ; + else if ( fillStyle == FillOpaqueStippled ) + pGC->ops->FillSpans = xf4bppOpStipplePixmapFS ; + else /* fillStyle == FillTiled */ + pGC->ops->FillSpans = xf4bppTilePixmapFS ; + changes &= ~( GCBackground | GCForeground + | GCFunction | GCPlaneMask | GCFillStyle ) ; + break ; + } /* end of new_fill */ + + default: + ErrorF( "ppcChangePixmapGC: Unexpected GC Change\n" ) ; + changes &= ~ idx ; /* Remove it anyway */ + break ; + } +} + +return 0 ; +} + +/* Clipping conventions + if the drawable is a window + CT_REGION ==> pCompositeClip really is the composite + CT_other ==> pCompositeClip is the window clip region + if the drawable is a pixmap + CT_REGION ==> pCompositeClip is the translated client region + clipped to the pixmap boundary + CT_other ==> pCompositeClip is the pixmap bounding box +*/ + +void +xf4bppValidateGC( pGC, changes, pDrawable ) + GCPtr pGC; + unsigned long changes; + DrawablePtr pDrawable; +{ + register ppcPrivGCPtr devPriv ; + WindowPtr pWin ; + + devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr ) ; + + if ( pDrawable->type != devPriv->lastDrawableType ) { + devPriv->lastDrawableType = pDrawable->type ; + xf4bppChangeGCtype( pGC, devPriv ) ; + changes = (unsigned)~0 ; + } + + if ( pDrawable->depth == 1 ) { +/* ibmAbort(); */ + xf4bppNeverCalled(); + } + + if ( pDrawable->type == DRAWABLE_WINDOW ) { + pWin = (WindowPtr) pDrawable ; + pGC->lastWinOrg.x = pWin->drawable.x ; + pGC->lastWinOrg.y = pWin->drawable.y ; + } + else { + pWin = (WindowPtr) NULL ; + pGC->lastWinOrg.x = 0 ; + pGC->lastWinOrg.y = 0 ; + } + + changes &= ppcGCInterestValidateMask ; + /* If Nothing REALLY Changed, Just Return */ + if ( pDrawable->serialNumber == (pGC->serialNumber & DRAWABLE_SERIAL_BITS) ) + if ( !( changes &= ~ GC_CALL_VALIDATE_BIT ) ) + return ; + + /* GJA -- start of cfb code */ + /* + * if the client clip is different or moved OR the subwindowMode has + * changed OR the window's clip has changed since the last validation + * we need to recompute the composite clip + */ + + if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) || + (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)) + ) + { + if (pWin) { + RegionPtr pregWin; + Bool freeTmpClip, freeCompClip; + + if (pGC->subWindowMode == IncludeInferiors) { + pregWin = NotClippedByChildren(pWin); + freeTmpClip = TRUE; + } + else { + pregWin = &pWin->clipList; + freeTmpClip = FALSE; + } + freeCompClip = pGC->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 (pGC->clientClipType == CT_NONE) { + if (freeCompClip) + REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); + pGC->pCompositeClip = pregWin; + pGC->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. + */ + + REGION_TRANSLATE(pGC->pScreen, pGC->clientClip, + pDrawable->x + pGC->clipOrg.x, + pDrawable->y + pGC->clipOrg.y); + + if (freeCompClip) + { + REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, + pregWin, pGC->clientClip); + if (freeTmpClip) + REGION_DESTROY(pGC->pScreen, pregWin); + } + else if (freeTmpClip) + { + REGION_INTERSECT(pGC->pScreen, pregWin, pregWin, + pGC->clientClip); + pGC->pCompositeClip = pregWin; + } + else + { + pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, NullBox, 0); + REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, + pregWin, pGC->clientClip); + } + pGC->freeCompClip = TRUE; + REGION_TRANSLATE(pGC->pScreen, pGC->clientClip, + -(pDrawable->x + pGC->clipOrg.x), + -(pDrawable->y + pGC->clipOrg.y)); + + } + } /* end of composite clip for a window */ + else { + BoxRec pixbounds; + + /* XXX should we translate by drawable.x/y here ? */ + pixbounds.x1 = 0; + pixbounds.y1 = 0; + pixbounds.x2 = pDrawable->width; + pixbounds.y2 = pDrawable->height; + + if (pGC->freeCompClip) { + REGION_RESET(pGC->pScreen, pGC->pCompositeClip, &pixbounds); + } else { + pGC->freeCompClip = TRUE; + pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, &pixbounds, 1); + } + + if (pGC->clientClipType == CT_REGION) + { + REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, + -pGC->clipOrg.x, -pGC->clipOrg.y); + REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, + pGC->pCompositeClip, pGC->clientClip); + REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, + pGC->clipOrg.x, pGC->clipOrg.y); + } + } /* end of composute clip for pixmap */ + } + /* GJA -- End of cfb code */ + + changes &= ~ ( GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode + | GC_CALL_VALIDATE_BIT ) ; + + /* If needed, Calculate the Color Reduced Raster-Op */ + if ( changes & ( GCFillStyle | GCBackground | GCForeground + | GCPlaneMask | GCFunction ) ) + xf4bppGetReducedColorRrop( pGC, pDrawable->depth, + &devPriv->colorRrop ) ; + + (* ( ( pDrawable->type == DRAWABLE_WINDOW ) + ? xf4bppChangeWindowGC + : ppcChangePixmapGC ) )( pGC, changes ) ; + + return ; +} diff --git a/hw/xfree86/xf4bpp/ppcGCstr.h b/hw/xfree86/xf4bpp/ppcGCstr.h new file mode 100644 index 000000000..5f863fa73 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcGCstr.h @@ -0,0 +1,95 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGCstr.h,v 1.3 2003/02/18 21:29:59 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/*********************************************************** + Copyright IBM Corporation 1988 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM 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. + +******************************************************************/ +/* $XConsortium: ppcGCstr.h /main/3 1996/02/21 17:57:42 kaleb $ */ + +#include "gc.h" +#include "mfb.h" + +typedef struct { + unsigned long planemask ; + unsigned long fgPixel ; + unsigned long bgPixel ; + int alu ; + int fillStyle ; + } ppcReducedRrop ; + +/* ************************************************************************ */ + +/* private field of GC */ +typedef struct { +/* The next five (5) fields MUST CORRESPOND to + * the fields of a "mfbPrivGC" struct + * ----- BEGINNING OF "DO-NOT-CHANGE" REGION ----- + */ + unsigned char rop ; /* reduction of rasterop to 1 of 3 */ + unsigned char ropOpStip ; /* rop for opaque stipple */ + unsigned char ropFillArea ; /* == alu, rop, or ropOpStip */ + unsigned char unused[sizeof(long) - 3]; + mfbFillAreaProcPtr FillArea; /* fills regions; look at the code */ +/* ----- END OF "DO-NOT-CHANGE" REGION ----- */ + ppcReducedRrop colorRrop ; + short lastDrawableType ; /* was last drawable a window or a pixmap? */ + short lastDrawableDepth ; /* was last drawable 1 or 8 planes? */ + pointer devPriv ; /* Private area for device specific stuff */ + } ppcPrivGC ; +typedef ppcPrivGC *ppcPrivGCPtr ; + +/* ppcCReduce.c */ +void xf4bppGetReducedColorRrop( +#if NeedFunctionPrototypes + GCPtr, + int, + ppcReducedRrop * +#endif +); + +/* vgaGC.c */ +void xf4bppChangeGCtype( +#if NeedFunctionPrototypes + GCPtr, + ppcPrivGCPtr +#endif +); diff --git a/hw/xfree86/xf4bpp/ppcGetSp.c b/hw/xfree86/xf4bpp/ppcGetSp.c new file mode 100644 index 000000000..b6c404e80 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcGetSp.c @@ -0,0 +1,139 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGetSp.c,v 1.3 1999/06/06 08:48:59 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ + +/* $XConsortium: ppcGetSp.c /main/5 1996/02/21 17:57:45 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "servermd.h" +#include "ibmTrace.h" + +/* GetSpans -- for each span, gets bits from drawable starting at ppt[i] + * and continuing for pwidth[i] bits + * Each scanline returned will be server scanline padded, i.e., it will come + * out to an integral number of words. + */ +void +xf4bppGetSpans( pDrawable, wMax, ppt, pwidth, nspans, pdstStart ) + DrawablePtr pDrawable ; /* drawable from which to get bits */ + int wMax ; /* largest value of all *pwidths */ + DDXPointPtr ppt ; /* points to start copying from */ + int *pwidth ; /* list of number of bits to copy */ + int nspans ; /* number of scanlines to copy */ + char *pdstStart ; +{ + register int j ; + register unsigned char *pdst ; /* where to put the bits */ + register unsigned char *psrc ; /* where to get the bits */ + register int pixmapStride ; + + + TRACE( ( "xf4bppGetSpans(pDrawable=0x%x,wMax=%d,ppt=0x%x,pwidth=0x%x,nspans=%d)\n", + pDrawable, wMax, ppt, pwidth, nspans ) ) ; + + if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) + { + mfbGetSpans( pDrawable, wMax, ppt, pwidth, nspans, pdstStart ) ; + return; + } + + pixmapStride = PixmapBytePad( wMax, pDrawable->depth ) ; + pdst = (unsigned char *) /* GJA */ pdstStart ; + + if ( pDrawable->type == DRAWABLE_WINDOW ) { + for ( ; nspans-- ; ppt++, pwidth++ ) { + xf4bppReadColorImage( (WindowPtr)pDrawable, + ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride ) ; + pdst += j ; /* width is in 32 bit words */ + j = ( -j ) & 3 ; + while ( j-- ) /* Pad out to 32-bit boundary */ + *pdst++ = 0 ; + } + } + else { /* OK, if we are here, we had better be a DRAWABLE PIXMAP */ + register int widthSrc = /* width of pixmap in bytes */ + (int) ( (PixmapPtr) pDrawable )->devKind ; + + psrc = (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ; + for ( ; nspans-- ; ppt++, pwidth++ ) { + MOVE( psrc + ( ppt->y * widthSrc ) + ppt->x, + pdst, j = *pwidth ) ; + pdst += j ; + j = ( -j ) & 3 ; + while ( j-- ) /* Pad out to 32-bit boundary */ + *pdst++ = 0 ; + } + } + return ; +} diff --git a/hw/xfree86/xf4bpp/ppcIO.c b/hw/xfree86/xf4bpp/ppcIO.c new file mode 100644 index 000000000..43cc7bd33 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcIO.c @@ -0,0 +1,252 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcIO.c,v 1.5 2001/10/28 03:34:06 tsi Exp $ */ +/* + +Copyright (c) 1990 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM 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. + +*/ +/* $XConsortium: ppcIO.c /main/8 1996/02/21 17:57:49 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "micmap.h" +#include "scrnintstr.h" +#include "vgaVideo.h" + +#if 0 +/* XXX This remains to remind of the PC98 difference */ +static VisualRec vgaVisuals[] = { +/* StaticColor needs to be first so is can be used as the default */ +/* vid class bpRGB cmpE nplan rMask gMask bMask oRed oGreen oBlue */ +#ifdef PC98 +{ 0, StaticColor, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, StaticGray, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, GrayScale, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, PseudoColor, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +#else +{ 0, StaticColor, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, StaticGray, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, GrayScale, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, PseudoColor, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +#endif +} ; +#endif + +int +xf4bppNeverCalled() +{ + FatalError("xf4bppNeverCalled was nevertheless called\n"); +} + +static BSFuncRec ppcBSFuncRec = { + xf4bppSaveAreas, + xf4bppRestoreAreas, + (BackingStoreSetClipmaskRgnProcPtr) 0, + (BackingStoreGetImagePixmapProcPtr) 0, + (BackingStoreGetSpansPixmapProcPtr) 0, +}; + +/*ARGSUSED*/ +static Bool +vgaScreenClose +( + int idx, + ScreenPtr pScreen +) +{ + pScreen->defColormap = 0 ; + return TRUE; +} + + +static GCPtr sampleGCperDepth[MAXFORMATS+1] = { 0 }; +static PixmapPtr samplePixmapPerDepth[1] = { 0 }; + +/* GJA -- Took this from miscrinit.c. + * We want that devKind contains the distance in bytes between two scanlines. + * The computation that mi does is not appropriate for planar VGA. + * Therefore we provide here our own routine. + */ + +/* GJA -- WARNING: this is an internal structure declaration, taken from + * miscrinit.c + */ +typedef struct +{ + pointer pbits; /* pointer to framebuffer */ + int width; /* delta to add to a framebuffer addr to move one row down */ +} miScreenInitParmsRec, *miScreenInitParmsPtr; + +/* With the introduction of pixmap privates, the "screen pixmap" can no + * longer be created in miScreenInit, since all the modules that could + * possibly ask for pixmap private space have not been initialized at + * that time. pScreen->CreateScreenResources is called after all + * possible private-requesting modules have been inited; we create the + * screen pixmap here. + */ +static Bool +v16CreateScreenResources +( + ScreenPtr pScreen +) +{ + miScreenInitParmsPtr pScrInitParms; + pointer value; + + pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate; + + /* if width is non-zero, pScreen->devPrivate will be a pixmap + * else it will just take the value pbits + */ + if (pScrInitParms->width) + { + PixmapPtr pPixmap; + + /* create a pixmap with no data, then redirect it to point to + * the screen + */ + pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth); + if (!pPixmap) + return FALSE; + + if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width, + pScreen->height, pScreen->rootDepth, 8 /* bits per pixel */, +/* GJA: was PixmapBytePad(pScrInitParms->width, pScreen->rootDepth), */ +#define BITS_PER_BYTE_SHIFT 3 + pScrInitParms->width >> BITS_PER_BYTE_SHIFT, + pScrInitParms->pbits)) + return FALSE; + value = (pointer)pPixmap; + } + else + { + value = pScrInitParms->pbits; + } + xfree(pScreen->devPrivate); /* freeing miScreenInitParmsRec */ + pScreen->devPrivate = value; /* pPixmap or pbits */ + return TRUE; +} + + +Bool +xf4bppScreenInit( pScreen, pbits, virtx, virty, dpix, dpiy, width ) + ScreenPtr pScreen; + pointer pbits; + int virtx, virty; + int dpix, dpiy; + int width; +{ + Bool ret; + VisualPtr visuals; + DepthPtr depths; + int nvisuals; + int ndepths; + int rootdepth; + VisualID defaultVisual; + + rootdepth = 0; + ret = miInitVisuals(&visuals, &depths, &nvisuals, &ndepths, &rootdepth, + &defaultVisual, (unsigned long)1 << 8, 6, -1); + if (!ret) + return FALSE; + + pScreen-> id = 0; + pScreen->defColormap = FakeClientID(0); + pScreen-> whitePixel = VGA_WHITE_PIXEL; + pScreen-> blackPixel = VGA_BLACK_PIXEL; + pScreen-> rgf = 0; + *(pScreen-> GCperDepth) = *(sampleGCperDepth); + *(pScreen-> PixmapPerDepth) = *(samplePixmapPerDepth); + pScreen-> CloseScreen = vgaScreenClose; + pScreen-> QueryBestSize = xf4bppQueryBestSize; + pScreen-> GetImage = xf4bppGetImage; + pScreen-> GetSpans = xf4bppGetSpans; + pScreen-> CreateWindow = xf4bppCreateWindowForXYhardware; + pScreen-> DestroyWindow = xf4bppDestroyWindow; + pScreen-> PositionWindow = xf4bppPositionWindow; + pScreen-> ChangeWindowAttributes = mfbChangeWindowAttributes; + pScreen-> RealizeWindow = mfbMapWindow; + pScreen-> UnrealizeWindow = mfbUnmapWindow; + pScreen-> PaintWindowBackground = xf4bppPaintWindow; + pScreen-> PaintWindowBorder = xf4bppPaintWindow; + pScreen-> CopyWindow = xf4bppCopyWindow; + pScreen-> CreatePixmap = xf4bppCreatePixmap; + pScreen-> DestroyPixmap = mfbDestroyPixmap; + pScreen-> SaveDoomedAreas = (SaveDoomedAreasProcPtr)NoopDDA; + pScreen-> RestoreAreas = (RestoreAreasProcPtr)NoopDDA; + pScreen-> ExposeCopy = (ExposeCopyProcPtr)NoopDDA; + pScreen-> TranslateBackingStore = (TranslateBackingStoreProcPtr)NoopDDA; + pScreen-> ClearBackingStore = (ClearBackingStoreProcPtr)NoopDDA; + pScreen-> DrawGuarantee = (DrawGuaranteeProcPtr)NoopDDA; + pScreen-> RealizeFont = mfbRealizeFont; + pScreen-> UnrealizeFont = mfbUnrealizeFont; + pScreen-> CreateGC = xf4bppCreateGC; + pScreen-> CreateColormap = xf4bppInitializeColormap; + pScreen-> DestroyColormap = (DestroyColormapProcPtr)NoopDDA; + pScreen-> InstallColormap = miInstallColormap; + pScreen-> UninstallColormap = miUninstallColormap; + pScreen-> ListInstalledColormaps = miListInstalledColormaps; + pScreen-> StoreColors = (StoreColorsProcPtr)NoopDDA; + pScreen-> ResolveColor = xf4bppResolveColor; + pScreen-> BitmapToRegion = mfbPixmapToRegion; + + if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL)) + return FALSE; + + if (!miScreenInit(pScreen, pbits, virtx, virty, dpix, dpiy, width, + rootdepth, ndepths, depths, defaultVisual /* See above */, + nvisuals, visuals)) + return FALSE; + pScreen->BackingStoreFuncs = ppcBSFuncRec; + + /* GJA -- Now we override the supplied default: */ + pScreen -> CreateScreenResources = v16CreateScreenResources; + + mfbRegisterCopyPlaneProc(pScreen,miCopyPlane); /* GJA -- R4->R5 */ + return TRUE; +} diff --git a/hw/xfree86/xf4bpp/ppcImg.c b/hw/xfree86/xf4bpp/ppcImg.c new file mode 100644 index 000000000..275db433a --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcImg.c @@ -0,0 +1,118 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcImg.c,v 1.5 2003/02/18 21:29:59 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* $XConsortium: ppcImg.c /main/4 1996/02/21 17:57:53 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mi.h" +#include "scrnintstr.h" +#include "servermd.h" + +/* Was MIGETIMAGE -- public entry for the GetImage Request + * We're getting the image into a memory buffer. While we have to use GetSpans + * to read a line from the device ( since we don't know what that looks like ) , + * we can just write into the destination buffer + * + * two different strategies are used, depending on whether we're getting the + * image in Z format or XY format + * Z format: + * Line at a time, GetSpans a line and bcopy it to the destination + * buffer, except that if the planemask is not all ones, we create a + * temporary pixmap and do a SetSpans into it ( to get bits turned off ) + * and then another GetSpans to get stuff back ( because pixmaps are + * opaque, and we are passed in the memory to write into ) . This is + * completely ugly and slow but works, but the interfaces just aren't + * designed for this case. Life is hard. + * XY format: + * get the single plane specified in planemask + */ +void +xf4bppGetImage( pDraw, sx, sy, w, h, format, planeMask, pdstLine ) + DrawablePtr pDraw ; + int sx, sy, w, h ; + unsigned int format ; + unsigned long planeMask ; + char * pdstLine ; +{ +#if 1 + int depth, i, linelength, width ; + DDXPointRec pt ; + char *pbits ; + XID gcv[2] ; + PixmapPtr pPixmap = (PixmapPtr) NULL ; + GCPtr pGC ; + char *pDst = pdstLine ; + + depth = pDraw->depth ; + if ( format == ZPixmap ) { + linelength = PixmapBytePad( w, depth ) ; +/* if ( pDraw->type == DRAWABLE_WINDOW ) { */ + sx += pDraw->x ; + sy += pDraw->y ; +/* } */ + if ( ( ( ( 1 << pDraw->depth ) - 1 ) & planeMask ) + != (unsigned)( 1 << pDraw->depth ) - 1 ) { + pGC = GetScratchGC( depth, pDraw->pScreen ) ; + pPixmap = (PixmapPtr) + (* pDraw->pScreen->CreatePixmap)( pDraw->pScreen, w, h, depth ) ; + gcv[0] = GXcopy ; + gcv[1] = planeMask ; + DoChangeGC( pGC, GCPlaneMask | GCFunction, gcv, 0 ) ; + ValidateGC( (DrawablePtr)pPixmap, pGC ) ; + + pbits = (char *)ALLOCATE_LOCAL(w); + + for ( i = 0 ; i < h ; i++ ) { + pt.x = sx ; + pt.y = sy + i ; + width = w ; + (* pDraw->pScreen->GetSpans)( pDraw, w, &pt, &width, 1, pbits ) ; + pt.x = 0 ; + pt.y = i ; + width = w ; + if ( planeMask & ((1 << depth) - 1) ) /* GJA -- mfb bug */ + (* pGC->ops->SetSpans)( (DrawablePtr)pPixmap, pGC, pbits, &pt, &width, 1, TRUE ) ; + (* pDraw->pScreen->GetSpans)( (DrawablePtr)pPixmap, w, &pt, &width, 1, pDst ) ; + pDst += linelength ; + } + + DEALLOCATE_LOCAL(pbits) ; + (* pGC->pScreen->DestroyPixmap)( pPixmap ) ; + FreeScratchGC( pGC ) ; + return ; + } + + for ( i = 0 ; i < h ; i++ ) { + pt.x = sx ; + pt.y = sy + i ; + width = w ; + (* pDraw->pScreen->GetSpans)( pDraw, w, &pt, &width, 1, pDst ) ; + pDst += linelength ; + } + } + else +#endif + miGetImage( pDraw, sx, sy, w, h, format, planeMask, pdstLine ) ; +} diff --git a/hw/xfree86/xf4bpp/ppcPixFS.c b/hw/xfree86/xf4bpp/ppcPixFS.c new file mode 100644 index 000000000..261c8e809 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcPixFS.c @@ -0,0 +1,502 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixFS.c,v 1.4 2001/08/01 00:44:56 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/****************************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* $XConsortium: ppcPixFS.c /main/3 1996/02/21 17:57:57 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "mispans.h" +#include "ppcGCstr.h" +#include "ppcSpMcro.h" +#include "vgaVideo.h" +#include "ibmTrace.h" + +#define LeftMostBitInScreenLongWord SCRLEFT( 0xFFFFFFFF, 31 ) + +/* GJA -- copied this from VGA */ +#define SCRLEFT8(lw, n) ( (unsigned char) (((unsigned char) lw) << (n)) ) +#define SCRRIGHT8(lw, n) ( (unsigned char) (((unsigned char)lw) >> (n)) ) +/* +********** ********** ********** ********** ********** ********** ********** + these routines all clip. they assume that anything that has called +them has already translated the points (i.e. pGC->miTranslate is +non-zero, which is howit gets set in mfbCreateGC().) + + the number of new scnalines created by clipping == +MaxRectsPerBand * nSpans. +********** ********** ********** ********** ********** ********** ********** +*/ +/* A mod definition that goes smoothly into the negative. + */ +static int +modulo +( + int n1, + int n2 +) +{ + int tmp; + if ( n1 < 0 ) { + tmp = (-n1) % n2; + if ( tmp == 0 ) { + return 0; + } else { + return n2 - tmp; + } + } else { + return n1 % n2; + } +} + +void +xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) + DrawablePtr pDrawable ; + GCPtr pGC ; + int nInit ; /* number of spans to fill */ + DDXPointPtr pptInit ; /* pointer to list of start points */ + int *pwidthInit ; /* pointer to list of n widths */ + int fSorted ; +{ + register unsigned long int pm, npm ; + register unsigned long int fg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + register unsigned char *addrl ; /* pointer to current longword in bitmap */ + int i ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE(("xf4bppSolidPixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ; + + if ( pDrawable->type != DRAWABLE_PIXMAP ) { + ErrorF("xf4bppSolidPixmapFS: drawable is not a pixmap\n") ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + return ; + + n = nInit * miFindMaxBand(pGC->pCompositeClip) ; + if ( !( pwidth = (int *) ALLOCATE_LOCAL( n * sizeof( int ) ) ) ) + return ; + pwidthFree = pwidth ; + + if ( !( ppt = (DDXPointRec *) + ALLOCATE_LOCAL( n * sizeof( DDXPointRec ) ) ) ) { + DEALLOCATE_LOCAL( pwidth ) ; + return ; + } + pptFree = ppt ; + + n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, + ppt, pwidth, fSorted ) ; + + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; + + for ( ; n-- ; ppt++, pwidth++ ) { + addrl = ( (unsigned char *) ( ( (PixmapPtr) pDrawable )->devPrivate.ptr ) ) + + ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) ) + + ppt->x ; + for ( i = *pwidth ; i-- ; addrl++ ) + { + unsigned _p; + DoRop( _p, alu, fg, *addrl ); + *addrl = ( *addrl & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *addrl = ( *addrl & npm ) | ( pm & DoRop( alu, fg, *addrl ) ) ; +#endif /* PURDUE */ + } + DEALLOCATE_LOCAL( pptFree ) ; + DEALLOCATE_LOCAL( pwidthFree ) ; + return ; +} + +/* GJA -- copied from vgaStipple.c */ +static unsigned char +vgagetbits +( + register const int x, + register const unsigned int patternWidth, + register const unsigned char * const lineptr +) +{ +register unsigned char bits ; +register const unsigned char *cptr ; +register int shift ; +register int wrap ; + +cptr = lineptr + ( x >> 3 ) ; +bits = *cptr ; +if ((shift = x & 7)) + bits = SCRLEFT8( bits, shift ) | SCRRIGHT8( cptr[1], ( 8 - shift ) ) ; +if ( ( wrap = x + 8 - patternWidth ) > 0 ) { + bits &= SCRLEFT8( 0xFF, wrap ) ; + bits |= SCRRIGHT8( *lineptr, ( 8 - wrap ) ) ; +} + +/* GJA -- Handle extraction of 8 bits from < 8 bits wide stipple. + * I duplicated case 4,5,6,7 to give the compiler a chance to optimize. + */ +switch (patternWidth) { +case 1: /* Not really useful. */ + bits &= ~SCRRIGHT8(0xFF,1); + bits |= SCRRIGHT8(bits,1); + bits |= SCRRIGHT8(bits,2); + bits |= SCRRIGHT8(bits,4); + break; +case 2: + bits &= ~SCRRIGHT8(0xFF,2); + bits |= SCRRIGHT8(bits,2); bits |= SCRRIGHT8(bits,4); break; +case 3: + bits &= ~SCRRIGHT8(0xFF,3); + bits |= (SCRRIGHT8(bits,3) | SCRRIGHT8(bits,6)); break; +case 4: + bits = (bits & ~SCRRIGHT8(0xFF,4)) | SCRRIGHT8(bits,4); break; +case 5: + bits = (bits & ~SCRRIGHT8(0xFF,5)) | SCRRIGHT8(bits,5); break; +case 6: + bits = (bits & ~SCRRIGHT8(0xFF,6)) | SCRRIGHT8(bits,6); break; +case 7: + bits = (bits & ~SCRRIGHT8(0xFF,7)) | SCRRIGHT8(bits,7); break; +default: + ; + /* Do nothing, of course */ +} + +return bits ; +} + +void +xf4bppStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +register DrawablePtr pDrawable ; +GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register unsigned char *pdst ; /* pointer to current word in bitmap */ + register int *psrc ; /* pointer to current word in tile */ + register unsigned long int pm, npm ; + register unsigned long int fg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + PixmapPtr pTile ; /* pointer to tile we want to fill with */ + int width, x, xSrc, ySrc ; + int tlwidth, tileWidth ; + unsigned char *psrcT ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + int xoff, count, stip, i ; + + TRACE(("xf4bppStipplePixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ; + + if ( pDrawable->type != DRAWABLE_PIXMAP ) { + ErrorF( "xf4bppStippleWindowFS: drawable is not a pixmap\n") ; + return ; + } + if ( pGC->stipple->drawable.depth != 1 ) { + ErrorF( "ppcStippleFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pGC->stipple->drawable.depth ) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit, + ppt, pwidthFree, pptFree, fSorted ) ; + + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + + pTile = pGC->stipple ; + tlwidth = pTile->devKind ; + + tileWidth = pTile->drawable.width ; + + npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; + + /* this replaces rotating the stipple. Instead, we just adjust the offset + * at which we start grabbing bits from the stipple */ + xSrc = pGC->patOrg.x + pDrawable->x; + ySrc = pGC->patOrg.y + pDrawable->y; + + while ( n-- ) { + pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ) + + ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) ) + + ppt->x ; + psrcT = (unsigned char *)pTile->devPrivate.ptr + + ( modulo( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ; + x = ppt->x ; + + xoff = modulo( x - xSrc, tileWidth) ; + for ( width = *pwidth ; width ; psrc++, width -= count, xoff+=count ) { + + if ( xoff >= tileWidth ) xoff -= tileWidth; + + if ( width < 8 ) + count = width; + else + count = 8; + + stip = vgagetbits( xoff, tileWidth, psrcT ) ; + + for ( i = count ; i-- ; ) { + if ( stip & 128 ) + { + unsigned _p; + DoRop( _p, alu, fg, *pdst ) ; + *pdst = ( *pdst & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ; +#endif /* PURDUE */ + pdst++ ; + stip = SCRLEFT( stip, 1 ) ; + } + } + ppt++ ; + pwidth++ ; + } + DEALLOCATE_LOCAL( pptFree ) ; + DEALLOCATE_LOCAL( pwidthFree ) ; + return ; +} + +void +xf4bppOpStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +DrawablePtr pDrawable ; +GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register unsigned char *pdst ; /* pointer to current word in bitmap */ + register unsigned long int pm, npm ; + register unsigned long int fg, bg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + register int *psrc ; /* pointer to current word in tile */ + PixmapPtr pTile ; /* pointer to tile we want to fill with */ + int width ; + int xSrc, ySrc ; + int tlwidth, tileWidth ; + unsigned char *psrcT ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + int xoff, count, stip, i ; + + TRACE( ( "xf4bppOpStipplePixmapFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( pGC->stipple->drawable.depth != 1 ) { + ErrorF( "xf4bppOpStipplePixmapFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pGC->stipple->drawable.depth ) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit, + ppt, pwidthFree, pptFree, fSorted ) ; + + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.bgPixel ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; + + pTile = pGC->stipple ; + tlwidth = pTile->devKind ; + tileWidth = pTile->drawable.width ; + + xSrc = pGC->patOrg.x + pDrawable->x; + ySrc = pGC->patOrg.y + pDrawable->y; + + /* this replaces rotating the stipple. Instead, we just adjust the offset + * at which we start grabbing bits from the stipple */ + for ( ; n-- ; ppt++, pwidth++ ) { + pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ) + + ( ppt->y * ( (int) ( (PixmapPtr) pDrawable )->devKind ) ) + + ppt->x ; + psrcT = (unsigned char *)pTile->devPrivate.ptr + + ( modulo( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ; + + xoff = modulo( ppt->x - xSrc, tileWidth) ; + + for ( width = *pwidth ; width ; psrc++, width -= count, xoff+=count ) { + + if ( xoff >= tileWidth ) xoff -= tileWidth; + + if ( width < 8 ) + count = width; + else + count = 8; + + stip = vgagetbits( xoff, tileWidth, psrcT ) ; + for ( i = count ; i-- ; pdst++, stip = SCRLEFT( stip, 1 ) ) + if ( stip & 128 ) + { + unsigned _p; + DoRop( _p, alu, fg, *pdst ) ; + *pdst = ( *pdst & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ; +#endif /* PURDUE */ + else + { + unsigned _p; + DoRop( _p, alu, bg, *pdst ) ; + *pdst = ( *pdst & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, bg, *pdst ) ) ; +#endif /* PURDUE */ + } + } + DEALLOCATE_LOCAL( pptFree ) ; + DEALLOCATE_LOCAL( pwidthFree ) ; + return ; +} + +void +xf4bppTilePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +register DrawablePtr pDrawable ; +GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + register unsigned char *pdst ; /* pointer to current word in bitmap */ + register unsigned char *psrc ; /* pointer to current word in tile */ + register PixmapPtr pTile ; /* pointer to tile we want to fill with */ + int i ; + int alu ; + unsigned char pm, npm ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + int tileWidth ; + int xSrc, ySrc; + unsigned char *psrcT ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "ppcTileFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) { + mfbTileFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ; + return ; + } + if ( !xf4bppDepthOK( pDrawable, pGC->tile.pixmap->drawable.depth ) ) { + ErrorF( "ppcTileFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pDrawable->depth) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit, + ppt, pwidthFree, pptFree, fSorted ) ; + + /* the following code is for 8 bits per pixel addressable memory only */ + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; + pTile = pGC->tile.pixmap ; + tileWidth = pTile->drawable.width ; + + xSrc = pGC->patOrg.x + pDrawable->x; + ySrc = pGC->patOrg.y + pDrawable->y; + /* this replaces rotating the tile. Instead we just adjust the offset + * at which we start grabbing bits from the tile */ + for ( ; n-- ; ppt++, pwidth++ ) { + pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ) + + ( ppt->y * ( (int) ( (PixmapPtr) pDrawable )->devKind ) ) + + ppt->x ; + psrcT = (unsigned char *) pTile->devPrivate.ptr + + ( modulo( ppt->y - ySrc, pTile->drawable.height) * pTile->devKind ) ; + + psrc = psrcT + modulo( ppt->x - xSrc, tileWidth ) ; + for ( i = *pwidth ; i-- ; pdst++, psrc++ ) { + if ( psrc >= ( psrcT + tileWidth ) ) + psrc = psrcT ; + { + unsigned _p; + DoRop( _p, alu, *psrc, *pdst ) ; + *pdst = ( *pdst & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, *psrc, *pdst ) ) ; +#endif /* PURDUE */ + } + } + DEALLOCATE_LOCAL( pptFree ) ; + DEALLOCATE_LOCAL( pwidthFree ) ; + return ; +} diff --git a/hw/xfree86/xf4bpp/ppcPixmap.c b/hw/xfree86/xf4bpp/ppcPixmap.c new file mode 100644 index 000000000..2317fbdfa --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcPixmap.c @@ -0,0 +1,144 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixmap.c,v 1.5 2000/04/27 16:26:49 eich Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* $XConsortium: ppcPixmap.c /main/5 1996/02/21 17:58:00 kaleb $ */ + +#include "xf4bpp.h" +#include "servermd.h" +#include "OScompiler.h" +#include "ibmTrace.h" +#include "scrnintstr.h" + +PixmapPtr +xf4bppCreatePixmap( pScreen, width, height, depth ) + ScreenPtr pScreen ; + int width ; + int height ; + int depth ; +{ + register PixmapPtr pPixmap = (PixmapPtr)NULL; + int size ; + + TRACE(("xf4bppCreatePixmap(pScreen=0x%x, width=%d, height=%d, depth=%d)\n", pScreen, width, height, depth)) ; + + if ( depth > 8 ) + return (PixmapPtr) NULL ; + + size = PixmapBytePad(width, depth); + pPixmap = AllocatePixmap (pScreen, (height * size)); + + if ( !pPixmap ) + return (PixmapPtr) NULL ; + pPixmap->drawable.type = DRAWABLE_PIXMAP ; + pPixmap->drawable.class = 0 ; + pPixmap->drawable.pScreen = pScreen ; + pPixmap->drawable.depth = depth ; + pPixmap->drawable.id = 0 ; + pPixmap->drawable.bitsPerPixel = ( depth == 1 ) ? 1 : 8 ; + pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER ; + pPixmap->drawable.x = 0 ; + pPixmap->drawable.y = 0 ; + pPixmap->drawable.width = width ; + pPixmap->drawable.height = height ; + pPixmap->devKind = size; + pPixmap->refcnt = 1 ; + size = height * pPixmap->devKind ; +#ifdef PIXPRIV + pPixmap->devPrivate.ptr = (pointer) (((CARD8*)pPixmap) + + pScreen->totalPixmapSize); +#else + pPixmap->devPrivate.ptr = (pointer) (pPixmap + 1); +#endif + bzero( (char *) pPixmap->devPrivate.ptr, size ) ; + return pPixmap ; +} + +PixmapPtr +xf4bppCopyPixmap(pSrc) + register PixmapPtr pSrc; +{ + register PixmapPtr pDst; + int size; + + TRACE(("xf4bppCopyPixmap(pSrc=0x%x)\n", pSrc)) ; + size = pSrc->drawable.height * pSrc->devKind; + pDst = xalloc(sizeof(PixmapRec) + size); + if (!pDst) + return NullPixmap; + pDst->drawable = pSrc->drawable; + pDst->drawable.id = 0; + pDst->drawable.serialNumber = NEXT_SERIAL_NUMBER; + pDst->devKind = pSrc->devKind; + pDst->refcnt = 1; + pDst->devPrivate.ptr = (pointer)(pDst + 1); + MOVE( (char *)pSrc->devPrivate.ptr, (char *)pDst->devPrivate.ptr, size ) ; + return pDst; +} diff --git a/hw/xfree86/xf4bpp/ppcPntWin.c b/hw/xfree86/xf4bpp/ppcPntWin.c new file mode 100644 index 000000000..e61fed342 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcPntWin.c @@ -0,0 +1,218 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPntWin.c,v 1.3 1999/06/06 08:49:01 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* $XConsortium: ppcPntWin.c /main/5 1996/02/21 17:58:04 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "scrnintstr.h" +#include "ibmTrace.h" + +/* NOTE: These functions only work for visuals up to 31-bits deep */ +static void xf4bppPaintWindowSolid( +#if NeedFunctionPrototypes + WindowPtr, + RegionPtr, + int +#endif +); +static void xf4bppPaintWindowTile( +#if NeedFunctionPrototypes + WindowPtr, + RegionPtr, + int +#endif +); + +void +xf4bppPaintWindow(pWin, pRegion, what) + WindowPtr pWin; + RegionPtr pRegion; + int what; +{ + + register mfbPrivWin *pPrivWin; + pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr); + + TRACE(("xf4bppPaintWindow( pWin= 0x%x, pRegion= 0x%x, what= %d )\n", + pWin,pRegion,what)); + + switch (what) { + case PW_BACKGROUND: + switch (pWin->backgroundState) { + case None: + return; + case ParentRelative: + do { + pWin = pWin->parent; + } while (pWin->backgroundState == ParentRelative); + (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion, + what); + return; + case BackgroundPixmap: + if (pPrivWin->fastBackground) + { + xf4bppPaintWindowTile(pWin, pRegion, what); + return; + } + break; + case BackgroundPixel: + xf4bppPaintWindowSolid(pWin, pRegion, what); + return; + } + break; + case PW_BORDER: + if (pWin->borderIsPixel) + { + xf4bppPaintWindowSolid(pWin, pRegion, what); + return; + } + else if (pPrivWin->fastBorder) + { + xf4bppPaintWindowTile(pWin, pRegion, what); + return; + } + break; + } + miPaintWindow(pWin, pRegion, what); +} + +static void +xf4bppPaintWindowSolid(pWin, pRegion, what) + register WindowPtr pWin; + register RegionPtr pRegion; + int what; +{ + register int nbox; + register BoxPtr pbox; + register unsigned long int pixel; + register unsigned long int pm ; + + TRACE(("xf4bppPaintWindowSolid(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what)); + + if ( !( nbox = REGION_NUM_RECTS(pRegion))) + return ; + pbox = REGION_RECTS(pRegion); + + if (what == PW_BACKGROUND) + pixel = pWin->background.pixel; + else + pixel = pWin->border.pixel; + + pm = ( 1 << pWin->drawable.depth ) - 1 ; + for ( ; nbox-- ; pbox++ ) { + /* + * call fill routine, the parms are: + * fill(color, alu, planes, x, y, width, height); + */ + xf4bppFillSolid( pWin, pixel, GXcopy, pm, pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ; + } + return ; +} + +static void +xf4bppPaintWindowTile(pWin, pRegion, what) + register WindowPtr pWin; + register RegionPtr pRegion; + int what; +{ + register int nbox; + register BoxPtr pbox; + register PixmapPtr pTile; + register unsigned long int pm ; + + TRACE(("xf4bppPaintWindowTile(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what)); + + if ( !( nbox = REGION_NUM_RECTS(pRegion))) + return ; + pbox = REGION_RECTS(pRegion); + + if (what == PW_BACKGROUND) + pTile = pWin->background.pixmap; + else + pTile = pWin->border.pixmap; + + pm = ( 1 << pWin->drawable.depth ) - 1 ; + for ( ; nbox-- ; pbox++ ) { + /* + * call tile routine, the parms are: + * tile(tile, alu, planes, x, y, width, height,xSrc,ySrc); + */ + xf4bppTileRect(pWin, pTile, GXcopy, pm, + pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, + pWin->drawable.x, pWin->drawable.y ); + } + return ; +} diff --git a/hw/xfree86/xf4bpp/ppcPolyPnt.c b/hw/xfree86/xf4bpp/ppcPolyPnt.c new file mode 100644 index 000000000..d080a623f --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcPolyPnt.c @@ -0,0 +1,141 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPolyPnt.c,v 1.4 1999/09/25 14:38:17 dawes Exp $ */ +/* + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM 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. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +*/ +/* $XConsortium: ppcPolyPnt.c /main/5 1996/02/21 17:58:07 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "scrnintstr.h" +#include "ppcGCstr.h" +#include "ibmTrace.h" + +void +xf4bppPolyPoint( pDrawable, pGC, mode, npt, pptInit ) +DrawablePtr pDrawable ; +GCPtr pGC ; +int mode ; /* Origin or Previous */ +int npt ; +xPoint *pptInit ; +{ +register xPoint *ppt ; +ppcPrivGC *devPriv ; +int alu ; +int nptTmp ; + +TRACE( ("xf4bppPolyPoint(0x%x,0x%x,%d,%d,0x%x)\n", + pDrawable, pGC, mode, npt, pptInit ) ) ; + +if ( pDrawable->type == DRAWABLE_PIXMAP ) { + if ( pGC->alu != GXnoop ) + miPolyPoint( pDrawable, pGC, mode, npt, pptInit ) ; + return ; +} + +devPriv = (ppcPrivGC *) ( pGC->devPrivates[mfbGCPrivateIndex].ptr ) ; +if ( ( alu = devPriv->colorRrop.alu ) == GXnoop ) + return ; + +/* make pointlist origin relative */ +if ( mode == CoordModePrevious ) + for ( ppt = pptInit, nptTmp = npt ; --nptTmp ; ) { + ppt++ ; + ppt->x += (ppt-1)->x ; + ppt->y += (ppt-1)->y ; + } + +if ( pGC->miTranslate ) { + register int xorg = pDrawable->x ; + register int yorg = pDrawable->y ; + for ( ppt = pptInit, nptTmp = npt ; nptTmp-- ; ppt++ ) { + ppt->x += xorg ; + ppt->y += yorg ; + } +} + +{ + register RegionPtr pRegion = pGC->pCompositeClip ; + register unsigned long int fg = devPriv->colorRrop.fgPixel ; + register unsigned long int pm = devPriv->colorRrop.planemask ; + BoxRec box ; /* Scratch Space */ + + if ( ! REGION_NUM_RECTS(pRegion)) + return ; + + for ( ppt = pptInit ; npt-- ; ppt++ ) + if (POINT_IN_REGION(pDrawable->pScreen, pRegion, + ppt->x, ppt->y, &box)) + xf4bppFillSolid( (WindowPtr)pDrawable, + fg, alu, pm, ppt->x, ppt->y, 1, 1 ) ; +} + +return ; +} diff --git a/hw/xfree86/xf4bpp/ppcPolyRec.c b/hw/xfree86/xf4bpp/ppcPolyRec.c new file mode 100644 index 000000000..754eb3732 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcPolyRec.c @@ -0,0 +1,127 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPolyRec.c,v 1.3 1999/06/06 08:49:01 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* $XConsortium: ppcPolyRec.c /main/4 1996/02/21 17:58:11 kaleb $ */ + +#include "xf4bpp.h" + +void +xf4bppPolyRectangle(pDraw, pGC, nrects, pRects) + DrawablePtr pDraw; + GCPtr pGC; + int nrects; + xRectangle *pRects; +{ + int i; + xRectangle *pR = pRects; + xRectangle *tmprects, *tmprectsinit; + int lw, fs, ss; + + if ( ! ( tmprectsinit = tmprects = (xRectangle *)ALLOCATE_LOCAL( ( sizeof ( xRectangle ) * nrects ) << 2 ) ) ) + return; + + lw = pGC->lineWidth; + ss = lw >> 1; /* skinny side of line */ + fs = ( lw + 1 ) >> 1; /* fat side of line */ + + for (i=0; i<nrects; i++) + { + tmprects->x = pR->x - ss; + tmprects->y = pR->y - ss; + tmprects->width = pR->width + lw; + tmprects->height = lw; + tmprects++; + + tmprects->x = pR->x - ss; + tmprects->y = pR->y + fs; + tmprects->width = lw; + tmprects->height = pR->height - lw; + tmprects++; + + tmprects->x = pR->x + pR->width - ss; + tmprects->y = pR->y + fs; + tmprects->width = lw; + tmprects->height = pR->height - lw; + tmprects++; + + tmprects->x = pR->x - ss; + tmprects->y = pR->y + pR->height - ss; + tmprects->width = pR->width + lw; + tmprects->height = lw; + tmprects++; + + pR++; + } + + (* pGC->ops->PolyFillRect)( pDraw, pGC, nrects << 2, tmprectsinit ); + + DEALLOCATE_LOCAL( tmprectsinit ); + return ; +} diff --git a/hw/xfree86/xf4bpp/ppcQuery.c b/hw/xfree86/xf4bpp/ppcQuery.c new file mode 100644 index 000000000..57d5fcff8 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcQuery.c @@ -0,0 +1,44 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcQuery.c,v 1.3 1999/06/06 08:49:01 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: ppcQuery.c /main/3 1996/02/21 17:58:18 kaleb $ */ + +#include "xf4bpp.h" + +void +xf4bppQueryBestSize +( + register int class, + register unsigned short *pwidth, + register unsigned short *pheight, + ScreenPtr pScreen +) +{ +if ( class == CursorShape ) + *pwidth = *pheight = 32 ; /* ppc's cursor max out at 32 by 32 */ +else /* either TileShape or StippleShape */ + /* Round Up To Nearest Multiple Of 8 -- We don't care what height they use */ + *pwidth = ( *pwidth + 0x7 ) & ~ 0x7 ; + +return ; +} diff --git a/hw/xfree86/xf4bpp/ppcRslvC.c b/hw/xfree86/xf4bpp/ppcRslvC.c new file mode 100644 index 000000000..5d33bc3c9 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcRslvC.c @@ -0,0 +1,176 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcRslvC.c,v 1.5 2001/12/17 20:00:46 dawes Exp $ */ +/************************************************************ +Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright no- +tice appear in all copies and that both that copyright no- +tice and this permission notice appear in supporting docu- +mentation, and that the names of Sun or X Consortium +not be used in advertising or publicity pertaining to +distribution of the software without specific prior +written permission. Sun and X Consortium make no +representations about the suitability of this software for +any purpose. It is provided "as is" without any express or +implied warranty. + +SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- +NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- +ABLE 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. + +********************************************************/ + +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* $XConsortium: ppcRslvC.c /main/7 1996/02/21 17:58:25 kaleb $ */ + +/* Generic Color Resolution Scheme + * P. Shupak 12/31/87 + */ + +#include "xf4bpp.h" +#include "scrnintstr.h" + +/* + * New colormap routines that can support multiple Visual types. + */ + +static unsigned short defstaticpalette[16][3] = { + /* R G B */ + { 0x0000, 0x0000, 0x0000 }, /* black */ + { 0xFFFF, 0xFFFF, 0xFFFF }, /* white */ + { 0xAAAA, 0xAAAA, 0xAAAA }, /* grey */ + { 0x0000, 0x0000, 0xAAAA }, /* dark blue */ + { 0x0000, 0x0000, 0xFFFF }, /* medium blue */ + { 0x0000, 0xAAAA, 0xFFFF }, /* light blue */ + { 0x0000, 0xFFFF, 0xFFFF }, /* cyan */ + { 0x0000, 0xAAAA, 0x0000 }, /* dark green */ + { 0x0000, 0xFFFF, 0x0000 }, /* green */ + { 0xAAAA, 0xFFFF, 0x5555 }, /* pale green */ + { 0xAAAA, 0x5555, 0x0000 }, /* brown */ + { 0xFFFF, 0xAAAA, 0x0000 }, /* light brown */ + { 0xFFFF, 0xFFFF, 0x0000 }, /* yellow */ + { 0xAAAA, 0x0000, 0xAAAA }, /* purple */ + { 0xFFFF, 0x0000, 0xFFFF }, /* magenta */ + { 0xFFFF, 0x0000, 0x0000 }, /* red */ + }; + +Bool +xf4bppInitializeColormap(pmap) + register ColormapPtr pmap; +{ + register unsigned i; + register VisualPtr pVisual; + unsigned lim, maxent, shift; + + pVisual = pmap->pVisual; + lim = (1 << pVisual->bitsPerRGBValue) - 1; + shift = 16 - pVisual->bitsPerRGBValue; + maxent = pVisual->ColormapEntries - 1; + + switch( pVisual->class ) + { + case StaticGray: + for ( i = 0 ; i < maxent ; i++ ) { + pmap->red[i].co.local.red = + pmap->red[i].co.local.green = + pmap->red[i].co.local.blue = + ((((i * 65535) / maxent) >> shift) * 65535) / lim; + } + break; + case StaticColor: + for ( i = 0 ; i < 16 ; i++ ) { + pmap->red[i].co.local.red = (defstaticpalette[i][0]); + pmap->red[i].co.local.green = (defstaticpalette[i][1]); + pmap->red[i].co.local.blue = (defstaticpalette[i][2]); + } + break; + case GrayScale: + case PseudoColor: + for(i=0;i<=maxent;i++) { + int a,b,c; + a = i << 10; + b = i << 12; + c = i << 14; + pmap->red[i].co.local.red = a; + pmap->red[i].co.local.green = b; + pmap->red[i].co.local.blue = c; + } + break; + case TrueColor: + case DirectColor: + default: + ErrorF( "Unsupported Visual class %d\b", pVisual->class ); + return FALSE; + } + return TRUE; +} + +void +xf4bppResolveColor( pred, pgreen, pblue, pVisual ) +register unsigned short* pred ; +register unsigned short* pgreen ; +register unsigned short* pblue ; +register VisualPtr pVisual ; +{ + unsigned lim, maxent, shift; + + lim = (1 << pVisual->bitsPerRGBValue) - 1; + shift = 16 - pVisual->bitsPerRGBValue; + maxent = pVisual->ColormapEntries - 1; + + switch( pVisual->class ) + { + case StaticGray: + *pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100; + *pred = (((*pred * (maxent + 1)) >> 16) * 65535) / maxent; + *pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim; + break; + case StaticColor: + break; + case GrayScale: + *pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100; + *pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim; + break; + case PseudoColor: + /* rescale to rgb bits */ + *pred = ((*pred >> shift) * 65535) / lim; + *pgreen = ((*pgreen >> shift) * 65535) / lim; + *pblue = ((*pblue >> shift) * 65535) / lim; + break; + case TrueColor: + case DirectColor: + default: + ErrorF( "Unsupported Visual class %d\b", pVisual->class ); + } +} + diff --git a/hw/xfree86/xf4bpp/ppcSetSp.c b/hw/xfree86/xf4bpp/ppcSetSp.c new file mode 100644 index 000000000..81294b2cc --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcSetSp.c @@ -0,0 +1,315 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcSetSp.c,v 1.3 1999/06/06 08:49:02 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* $XConsortium: ppcSetSp.c /main/5 1996/02/21 17:58:32 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "servermd.h" + +/* SetScanline -- copies the bits from psrc to the drawable starting at + * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc + * starts on the scanline. (I.e., if this scanline passes through multiple + * boxes, we may not want to start grabbing bits at psrc but at some offset + * further on.) + */ +static void +ppcSetScanline +( + register int pixCount, /* width of scanline in bits */ + register char *psrc, + register unsigned char *pdst, /* where to put the bits */ + register int pm, /* plane mask */ + const int alu /* raster op */ +) +{ +register int npm = ~pm ; /* inverted plane mask */ +register char tmpx ; + +pm &= 0x0F; npm &= 0x0F; /* GJA */ + +switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + while ( pixCount-- ) + *pdst++ &= npm ; + break ; + case GXand: /* 0x1 src AND dst */ + while ( pixCount-- ) + *pdst++ &= *psrc++ | npm ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + for ( ; pixCount-- ; pdst++, psrc++ ) { + tmpx = *pdst; + *pdst = ( tmpx & npm ) | ( pm & *psrc & ~tmpx ) ; + } + break ; + case GXcopy: /* 0x3 src */ + for ( ; pixCount-- ; pdst++, psrc++ ) + *pdst = ( *pdst & npm ) | ( pm & *psrc ) ; + break ; + case GXandInverted: /* 0x4 NOT src AND dst */ + while ( pixCount-- ) + *pdst++ &= npm | ~*psrc++ ; + break ; + case GXnoop: /* 0x5 dst */ + break ; + case GXxor: /* 0x6 src XOR dst */ + while ( pixCount-- ) + *pdst++ ^= pm & *psrc++ ; + break ; + case GXor: /* 0x7 src OR dst */ + while ( pixCount-- ) + *pdst++ |= *psrc++ & pm ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + for ( ; pixCount-- ; pdst++, psrc++ ) { + tmpx = *pdst; + *pdst = ( tmpx & npm ) | ( pm & ~( tmpx | *psrc ) ) ; + } + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + while ( pixCount-- ) + *pdst++ ^= pm & ~ *psrc++ ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + for ( ; pixCount-- ; pdst++, psrc++ ) { + tmpx = *pdst; + *pdst = ( tmpx & npm ) | ( pm & ( *psrc | ~tmpx ) ) ; + } + break ; + case GXinvert: /* 0xa NOT dst */ + while ( pixCount-- ) + *pdst++ ^= pm ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + for ( ; pixCount-- ; pdst++, psrc++ ) + *pdst = ( *pdst & npm ) | ( pm & ~ *psrc ) ; + break ; + case GXorInverted: /* 0xd NOT src OR dst */ + while ( pixCount-- ) + *pdst++ |= pm & ~ *psrc++ ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + for ( ; pixCount-- ; pdst++, psrc++ ) { + tmpx = *pdst; + *pdst = ( tmpx & npm ) | ( pm & ~( tmpx & *psrc ) ) ; + } + break ; + case GXset: /* 0xf 1 */ + while ( pixCount-- ) + *pdst++ |= pm ; + break ; + default: + ErrorF( "ppcSetScanLine: bad alu value == 0x%02X\n", alu ) ; + break ; +} + +return ; +} + +/* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at + * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines + * are in increasing Y order. + * Source bit lines are server scanline padded so that they always begin + * on a word boundary. + */ +void +xf4bppSetSpans( pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted ) + register DrawablePtr pDrawable ; + GCPtr pGC ; + char *psrc ; + register DDXPointPtr ppt ; + int *pwidth ; + int nspans ; + int fSorted ; +{ + unsigned char *pdstBase = NULL; /* start of dst bitmap */ + int widthDst = 0; /* width of bitmap in words */ + register BoxPtr pbox, pboxLast, pboxTest ; + register DDXPointPtr pptLast ; + RegionPtr prgnDst ; + register int width ; + int xStart, xEnd ; + int yMax ; + int alu ; + int pm ; + + /* allow for 1-deep windows on nfb machines (eg apa8, aed) */ + if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) { + mfbSetSpans( pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted ) ; + return ; + } + + if ( !( pm = pGC->planemask & ~( (~0) << pDrawable->depth ) ) + || ( ( alu = pGC->alu ) == GXnoop ) ) + return ; + + prgnDst = pGC->pCompositeClip ; + + if ( ! REGION_NUM_RECTS(prgnDst)) + return ; + + pboxLast = ( pbox = REGION_RECTS(prgnDst) ) + REGION_NUM_RECTS(prgnDst); + pptLast = ppt + nspans ; + + if ( pDrawable->type == DRAWABLE_WINDOW ) { + yMax = (int) pDrawable->height + pDrawable->y ; + } + else { + pdstBase = (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ; + widthDst = (int) ( (PixmapPtr) pDrawable )->devKind ; + yMax = pDrawable->height ; + } + + if ( fSorted ) { + /* scan lines sorted in ascending order. Because they are sorted, we + * don't have to check each scanline against each clip box. We can be + * sure that this scanline only has to be clipped to boxes at or after the + * beginning of this y-band + */ + for ( pboxTest = pbox ; + ( ppt < pptLast ) && ( ppt->y < yMax ) ; + ppt++, pwidth++, + psrc += PixmapBytePad( width, pDrawable->depth ) ) { + width = *pwidth ; + for ( pbox = pboxTest ; + pbox < pboxLast ; + pbox++ ) { + if ( pbox->y2 <= ppt->y ) { + /* clip box is before scanline */ + pboxTest = pbox + 1 ; + } + else if ( ( pbox->y1 > ppt->y ) + || ( pbox->x1 > ppt->x + width ) ) + break ; /* scanline before clip box or left of clip box */ + else if ( pbox->x2 > ppt->x ) { + /* some of the scanline is in the current clip box */ + xStart = MAX( pbox->x1, ppt->x ) ; + xEnd = MIN( ppt->x + width, pbox->x2 ) ; + if ( pDrawable->type == DRAWABLE_PIXMAP ) + ppcSetScanline( xEnd - xStart, + psrc + ( xStart - ppt->x ), + pdstBase + xStart + + ( ppt->y * widthDst ), + pm, alu ) ; + else + xf4bppDrawColorImage( (WindowPtr)pDrawable, + xStart, ppt->y, xEnd - xStart, 1, + (unsigned char *)psrc + ( xStart - ppt->x ), + xEnd - xStart, alu, pm ) ; + if ( ppt->x + width <= pbox->x2 ) + break ; /* End of the line, as it were */ + } + } + /* We've tried this line against every box ; it must be outside them + * all. move on to the next point */ + } + } + else { + /* scan lines not sorted. We must clip each line against all the boxes */ + for ( ; + ppt < pptLast ; + ppt++, pwidth++, + psrc += PixmapBytePad( width, pDrawable->depth ) ) { + width = *pwidth ; + if ( ppt->y >= 0 && ppt->y < yMax ) { + for ( pbox = REGION_RECTS(prgnDst) ; pbox < pboxLast ; pbox++ ) { + if ( pbox->y1 > ppt->y ) + break ; /* rest of clip region is above this scanline */ + else if ( ( pbox->y2 > ppt->y ) + && ( pbox->x1 <= ppt->x + width ) + && ( pbox->x2 > ppt->x ) ) { + xStart = MAX( pbox->x1, ppt->x ) ; + xEnd = MIN( pbox->x2, ppt->x + width ) ; + if ( pDrawable->type == DRAWABLE_PIXMAP ) + ppcSetScanline( xEnd - xStart, + psrc + ( xStart - ppt->x ), + /* ^ GJA */ + ( ( pdstBase + + ( ppt->y * widthDst ) ) + + xStart ), + pm, alu ) ; + else /* pDrawable->type == DRAWABLE_WINDOW */ + xf4bppDrawColorImage( (WindowPtr)pDrawable, + xStart, ppt->y, xEnd - xStart, 1, + (unsigned char *)psrc + ( xStart - ppt->x ), + /* GJA ^ */ + xEnd - xStart, alu, pm ) ; + } + + } + } + } + } + return ; +} diff --git a/hw/xfree86/xf4bpp/ppcSpMcro.h b/hw/xfree86/xf4bpp/ppcSpMcro.h new file mode 100644 index 000000000..7ea244f66 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcSpMcro.h @@ -0,0 +1,45 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcSpMcro.h,v 1.2 1998/07/25 16:59:42 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: ppcSpMcro.h /main/3 1996/02/21 17:58:36 kaleb $ */ + +/* This screwy macro is used in all the spans routines and you find + it all over the place, so it is a macro just to tidy things up. +*/ + +#define SETSPANPTRS(IN,N,IPW,PW,IPPT,PPT,FPW,FPPT,FSORT) \ + { \ + N = IN * miFindMaxBand(pGC->pCompositeClip); \ + if(!(PW = (int *)ALLOCATE_LOCAL(N * sizeof(int)))) \ + return; \ + if(!(PPT = (DDXPointRec *)ALLOCATE_LOCAL(N * sizeof(DDXPointRec)))) \ + { \ + DEALLOCATE_LOCAL(PW); \ + return; \ + } \ + FPW = PW; \ + FPPT = PPT; \ + N = miClipSpans(pGC->pCompositeClip, IPPT, IPW, IN, \ + PPT, PW, FSORT); \ + } + diff --git a/hw/xfree86/xf4bpp/ppcWinFS.c b/hw/xfree86/xf4bpp/ppcWinFS.c new file mode 100644 index 000000000..29d466f00 --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcWinFS.c @@ -0,0 +1,278 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcWinFS.c,v 1.3 1999/06/06 08:49:02 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/****************************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +/* $XConsortium: ppcWinFS.c /main/3 1996/02/21 17:58:39 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "mispans.h" +#include "ppcGCstr.h" +#include "ppcSpMcro.h" +#include "ibmTrace.h" + +#define LeftMostBitInScreenLongWord SCRLEFT( 0xFFFFFFFF, 31 ) +/* +********** ********** ********** ********** ********** ********** ********** + these routines all clip. they assume that anything that has called +them has already translated the points (i.e. pGC->miTranslate is +non-zero, which is howit gets set in mfbCreateGC().) + + the number of new scanlines created by clipping == +MaxRectsPerBand * nSpans. +********** ********** ********** ********** ********** ********** ********** +*/ + +void +xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) + DrawablePtr pDrawable ; + GCPtr pGC ; + int nInit ; /* number of spans to fill */ + DDXPointPtr pptInit ; /* pointer to list of start points */ + int *pwidthInit ; /* pointer to list of n widths */ + int fSorted ; +{ + register unsigned long int pm ; + register unsigned long int fg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "xf4bppSolidWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( pDrawable->type != DRAWABLE_WINDOW ) { + ErrorF( "xf4bppSolidWindowFS: drawable is not a window\n") ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + return ; + + n = nInit * miFindMaxBand( pGC->pCompositeClip ) ; + if ( !( pwidth = (int *) ALLOCATE_LOCAL( n * sizeof( int ) ) ) ) + return ; + pwidthFree = pwidth ; + + if ( !( ppt = (DDXPointRec *) + ALLOCATE_LOCAL( n * sizeof( DDXPointRec ) ) ) ) { + DEALLOCATE_LOCAL( pwidth ) ; + return ; + } + pptFree = ppt ; + + n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, + ppt, pwidth, fSorted ) ; + + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + + for ( ; n-- ; ppt++, pwidth++ ) + if ( *pwidth ) + xf4bppFillSolid( (WindowPtr)pDrawable, + fg, alu, pm, ppt->x, ppt->y, *pwidth, 1 ) ; + + DEALLOCATE_LOCAL( pptFree ) ; + DEALLOCATE_LOCAL( pwidthFree ) ; + return ; +} + +void +xf4bppStippleWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +DrawablePtr pDrawable ; +register GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register unsigned long int pm ; + register unsigned long int fg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + PixmapPtr pTile ; /* pointer to tile we want to fill with */ + int xSrc ; + int ySrc ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "xf4bppStippleWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( pDrawable->type != DRAWABLE_WINDOW ) { + ErrorF( "xf4bppStippleWindowFS: drawable is not a window\n" ) ; + return ; + } + + if ( pGC->stipple->drawable.depth != 1 ) { + ErrorF("ppcStippleFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pGC->stipple->drawable.depth ) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit, + ppt, pwidthFree, pptFree, fSorted ) ; + + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + + xSrc = pGC->patOrg.x + pDrawable->x ; + ySrc = pGC->patOrg.y + pDrawable->y ; + pTile = pGC->stipple ; + + for ( ; n-- ; ppt++, pwidth++ ) + xf4bppFillStipple( (WindowPtr)pDrawable, pTile, fg, alu, pm, + ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ; + + DEALLOCATE_LOCAL( pptFree ) ; + DEALLOCATE_LOCAL( pwidthFree ) ; + + return ; +} + +void +xf4bppOpStippleWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +DrawablePtr pDrawable ; +register GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + int n ; /* number of spans to fill */ + int xSrc ; + int ySrc ; + unsigned long int pm ; + unsigned long int fg, bg ; + int alu ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "xf4bppOpStippleWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( pGC->stipple->drawable.depth != 1 ) { + ErrorF( "xf4bppOpStippleWindowFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pGC->stipple->drawable.depth ) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit, + ppt, pwidthFree, pptFree, fSorted ) ; + + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.bgPixel ; + + xSrc = pGC->patOrg.x + pDrawable->x ; + ySrc = pGC->patOrg.y + pDrawable->y ; + + for ( ; n-- ; ppt++, pwidth++ ) + xf4bppOpaqueStipple( (WindowPtr)pDrawable, pGC->stipple, fg, bg, alu, pm, + ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ; + + DEALLOCATE_LOCAL( pptFree ) ; + DEALLOCATE_LOCAL( pwidthFree ) ; + return ; +} + +void +xf4bppTileWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +DrawablePtr pDrawable ; +register GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + /* next three parameters are post-clip */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + int n ; /* number of spans to fill */ + unsigned char pm ; + int alu ; + int xSrc ; + int ySrc ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "xf4bppTileWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit, + ppt, pwidthFree, pptFree, fSorted ) ; + + xSrc = pGC->patOrg.x + pDrawable->x ; + ySrc = pGC->patOrg.y + pDrawable->y ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + + for ( ; n-- ; ppt++, pwidth++ ) + xf4bppTileRect( (WindowPtr)pDrawable, pGC->tile.pixmap, alu, pm, + ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ; + + DEALLOCATE_LOCAL( pptFree ) ; + DEALLOCATE_LOCAL( pwidthFree ) ; + return ; +} diff --git a/hw/xfree86/xf4bpp/ppcWindow.c b/hw/xfree86/xf4bpp/ppcWindow.c new file mode 100644 index 000000000..1de8d68ee --- /dev/null +++ b/hw/xfree86/xf4bpp/ppcWindow.c @@ -0,0 +1,224 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcWindow.c,v 1.4 1999/09/25 14:38:17 dawes Exp $ */ +/* + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM 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. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +*/ +/* $XConsortium: ppcWindow.c /main/5 1996/02/21 17:58:43 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "scrnintstr.h" +#include "ibmTrace.h" + +/* + xf4bppCopyWindow copies only the parts of the destination that are +visible in the source. +*/ + +void +xf4bppCopyWindow(pWin, ptOldOrg, prgnSrc) + register WindowPtr pWin ; + DDXPointRec ptOldOrg ; + RegionPtr prgnSrc ; +{ + RegionPtr prgnDst ; + register BoxPtr pbox ; + register int dx, dy ; + register int nbox ; + register int pm ; + + BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew ; + /* temporaries for shuffling rectangles */ + + TRACE(("xf4bppCopyWindow(pWin= 0x%x, ptOldOrg= 0x%x, prgnSrc= 0x%x)\n", pWin, ptOldOrg, prgnSrc)) ; + + + dx = ptOldOrg.x - pWin->drawable.x ; + dy = ptOldOrg.y - pWin->drawable.y ; + REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); + + prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1); + REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, + &pWin->borderClip, prgnSrc); + + if ( !( nbox = REGION_NUM_RECTS(prgnDst) ) ) + return; + + pbox = REGION_RECTS(prgnDst); + + pboxNew = 0 ; + if ( nbox > 1 ) { + if ( dy < 0 ) { + if ( dx > 0 ) { + /* walk source bottom to top */ + /* keep ordering in each band, reverse order of bands */ + if ( !( pboxNew = + (BoxPtr) ALLOCATE_LOCAL( sizeof( BoxRec ) * nbox ) ) ) + return ; + pboxBase = pboxNext = pbox+nbox - 1 ; + while ( pboxBase >= pbox ) { + while ( ( pboxNext >= pbox ) + && ( pboxBase->y1 == pboxNext->y1 ) ) + pboxNext-- ; + pboxTmp = pboxNext + 1 ; + while ( pboxTmp <= pboxBase ) + *pboxNew++ = *pboxTmp++ ; + pboxBase = pboxNext ; + } + pboxNew -= nbox ; + pbox = pboxNew ; + } + else { /* dx <= 0 */ + /* we can just reverse the entire list in place */ + /* Do three-position swaps */ + BoxRec tmpBox ; + + pboxBase = pbox ; + pboxNext = pbox + nbox - 1 ; + while ( pboxBase < pboxNext ) { + /* ****** Warning Structure Assignment !! ****** */ + tmpBox = *pboxBase ; + *pboxBase = *pboxNext ; + *pboxNext = tmpBox ; + pboxBase++ ; + pboxNext-- ; + } + } + } + else if ( dx < 0 ) { + /* walk source right to left */ + /* reverse order of rects in each band */ + if ( !( pboxNew = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox) ) ) + return ; + pboxBase = pboxNext = pbox ; + while (pboxBase < pbox+nbox) + { + while ((pboxNext < pbox+nbox) && + (pboxNext->y1 == pboxBase->y1)) + pboxNext++ ; + pboxTmp = pboxNext ; + while (pboxTmp != pboxBase) + *pboxNew++ = *--pboxTmp ; + pboxBase = pboxNext ; + } + pboxNew -= nbox ; + pbox = pboxNew ; + } + } /* END if nbox > 1 */ + + /* + * call blit several times, the parms are: + * blit( alu,rplanes, wplanes, srcx, srcy, destx, desty, width, height ) ; + */ + + pm = ( 1 << pWin->drawable.depth ) - 1 ; + for ( ; nbox-- ; pbox++ ) + xf4bppBitBlt( pWin, GXcopy, pm, + pbox->x1 + dx, pbox->y1 + dy, + pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1) ; + + /* free up stuff */ + if ( pboxNew ) + DEALLOCATE_LOCAL( pboxNew ) ; + + REGION_DESTROY(pWin->drawable.pScreen, prgnDst); +} + +Bool xf4bppPositionWindow(pWin, x, y) +register WindowPtr pWin ; +register int x, y ; +{ + return TRUE ; +} + +Bool +xf4bppDestroyWindow(pWin) +register WindowPtr pWin ; +{ +return pWin ? TRUE : FALSE ; +} + +/* As The Name Says -- Used For ega, vga and apa8c */ +Bool +xf4bppCreateWindowForXYhardware(pWin) +register WindowPtr pWin ; +{ + register mfbPrivWin *pPrivWin; + + TRACE(("xf4bppCreateWindowForXYhardware (pWin= 0x%x)\n", pWin)); + + pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr); + pPrivWin->pRotatedBorder = NullPixmap; + pPrivWin->pRotatedBackground = NullPixmap; + pPrivWin->fastBackground = 0; + pPrivWin->fastBorder = 0; + + return TRUE; +} diff --git a/hw/xfree86/xf4bpp/vgaBitBlt.c b/hw/xfree86/xf4bpp/vgaBitBlt.c new file mode 100644 index 000000000..53eb3b314 --- /dev/null +++ b/hw/xfree86/xf4bpp/vgaBitBlt.c @@ -0,0 +1,763 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/vgaBitBlt.c,v 1.4 2002/01/25 21:56:22 tsi Exp $ */ +/* GJA -- span move routines */ + + + +/* $XConsortium: vgaBitBlt.c /main/8 1996/10/27 11:06:39 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "vgaReg.h" +#include "vgaVideo.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +#ifndef PC98_EGC /* not PC98_EGC */ +/* NOTE: It seems that there is no way to program the VGA to copy just + * a part of a byte in the smarter modes. Therefore we copy the boundaries + * plane by plane. + */ +#define WORDSZ 8 + /* The fast blit code requires WORDSZ = 8 for its read-modify write cycle. + * Therefore, we do not fully implement the other options. + */ +#define HIGHPLANEMASK 0x08 +#define HIGHPLANEINDEX 3 + +/* Of course, we want the following anyway: + * (Yes, they're identical now.) + */ +#define SMEM(x,y) ( VIDBASE(pWin) + (y) * BYTES_PER_LINE(pWin) + (x) ) +#define DMEM(x,y) ( VIDBASE(pWin) + (y) * BYTES_PER_LINE(pWin) + (x) ) + +#define WORD8 unsigned char +#define LW8 BYTES_PER_LINE(pWin) /* Line width */ +#define WSHIFT8 0x3 +#define WMASK8 0x07 +/* NOTE: lmask[8] matters. It must be different from lmask[0] */ +static unsigned char lmasktab[] = { + 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF +} ; +static unsigned char rmasktab[] = { + 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00 +} ; + +#define LMASK8(n) lmasktab[n] +#define RMASK8(n) rmasktab[n] +#define SWAPB8(x) (x) + +#if (WORDSZ == 8) + +#define WORD WORD8 +#define LW LW8 +#define WSHIFT WSHIFT8 +#define WMASK WMASK8 + +#define LMASK(n) LMASK8(n) +#define RMASK(n) RMASK8(n) +#define SWAPB(x) SWAPB8(x) + +#endif /* WORDSZ == 8 */ + +#define DO_ALU(dst,src,mask,alu) {\ + int _ndst, _odst; _odst = dst; \ + switch ( alu ) { \ + case GXclear: \ + _ndst = 0; break; \ + case GXand: \ + _ndst = src & _odst; break; \ + case GXandReverse: \ + _ndst = src & ~ _odst; break; \ + case GXcopy: \ + _ndst = src; break; \ + case GXandInverted: \ + _ndst = ~ src & _odst; break; \ + default: \ + case GXnoop: \ + _ndst = _odst; break; \ + case GXxor: \ + _ndst = src ^ _odst; break; \ + case GXor: \ + _ndst = src | _odst; break; \ + case GXnor: \ + _ndst = ~ src & ~ _odst; break; \ + case GXequiv: \ + _ndst = ~ src ^ _odst; break; \ + case GXinvert: \ + _ndst = ~ _odst; break; \ + case GXorReverse: \ + _ndst = src | ~ _odst; break; \ + case GXcopyInverted: \ + _ndst = ~ src; break; \ + case GXorInverted: \ + _ndst = ~ src | _odst; break; \ + case GXnand: \ + _ndst = ~ src | ~ _odst; break; \ + case GXset: \ + _ndst = ~0; break; \ + } \ + dst = (_odst & ~(mask)) | (_ndst & (mask)); \ + } + +static void aligned_blit( +#if NeedFunctionPrototypes + WindowPtr, int, int, int, int, int, int, int, int +#endif +); + +static void aligned_blit_center( +#if NeedFunctionPrototypes + WindowPtr, int, int, int, int, int, int +#endif +); + +static void shift( +#if NeedFunctionPrototypes + WindowPtr, int, int, int, int, int, int, int +#endif +); + +static void shift_thin_rect( +#if NeedFunctionPrototypes + WindowPtr, int, int, int, int, int, int, int +#endif +); + +static void shift_center( +#if NeedFunctionPrototypes + WindowPtr, int, int, int, int, int, int, int +#endif +); + +void xf4bppBitBlt(pWin,alu,writeplanes,x0,y0,x1,y1,w,h) +WindowPtr pWin; /* GJA */ +int alu; +int writeplanes; /* planes */ +int x0, y0, x1, y1, w, h; +{ + IOADDRESS REGBASE; + int plane, bit; + + if ( !w || !h ) return; + + if ( ! xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffBitBlt(pWin,alu,writeplanes,x0,y0,x1,y1,w,h); + return; + } + + REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; + + /* 0x7, not WMASK: it is hardware dependant */ + if ( ((x0 - x1) & 0x7) || (alu != GXcopy) ) { + /* Use slow copy */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX ; + plane ; plane >>= 1, bit-- ) + { + + if ( writeplanes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift(pWin,x0,x1,y0,y1,w,h,alu); + } + } + } else { + aligned_blit(pWin,x0,x1,y0,y1,w,h,alu,writeplanes); + } +} + +/* Copy a span a number of places to the right. + */ +static void +shift(pWin,x0,x1,y0,y1,w,h,alu) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +int alu; +{ + if ( ((x1 & WMASK) + w) <= WORDSZ ) { + shift_thin_rect(pWin,x0,x1,y0,y1,w,h,alu); + } else if ( x1 > x0 ) { /* Shift right: start right */ + int l1 = x1 & WMASK, r1 = (x1 + w) & WMASK; + + if ( r1 ) /* right edge */ + shift_thin_rect(pWin,x0+w-r1,x1+w-r1,y0,y1,r1,h,alu); + shift_center(pWin,x0,x1,y0,y1,w,h,alu); + if ( l1 ) /* left edge */ + shift_thin_rect(pWin,x0,x1,y0,y1,(WORDSZ-l1),h,alu); + } else { + int l1 = x1 & WMASK, r1 = (x1 + w) & WMASK; + + if ( l1 ) /* left edge */ + shift_thin_rect(pWin,x0,x1,y0,y1,(WORDSZ-l1),h,alu); + shift_center(pWin,x0,x1,y0,y1,w,h,alu); + if ( r1 ) /* right edge */ + shift_thin_rect(pWin,x0+w-r1,x1+w-r1,y0,y1,r1,h,alu); + } +} + +/* The whole rectangle is so thin that it fits in one byte written */ +static void +shift_thin_rect(pWin,x0,x1,y0,y1,w,h,alu) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +int alu; +{ + int l0 = x0 & WMASK; /* Left edge of source, as bit */ + int l1 = x1 & WMASK; /* Left edge of target, as bit */ + int L0 = x0 >> WSHIFT; /* Left edge of source, as byte */ + int L1 = x1 >> WSHIFT; /* Left edge of target, as byte */ + int pad; + int htmp; + int mask; + int tmp; + int bs; + + volatile unsigned char *sp, *dp; + + mask = RMASK(l1) & LMASK(l1+w); + bs = (x1 - x0) & WMASK; + + if ( y1 > y0 ) { /* Move down, start at the bottom */ + pad = - BYTES_PER_LINE(pWin); + sp = SMEM(L0,y0+h-1); + dp = DMEM(L1,y1+h-1); + } else { /* Move up, start at the top */ + pad = BYTES_PER_LINE(pWin); + sp = SMEM(L0,y0); + dp = DMEM(L1,y1); + } + + if ( l0+w > WORDSZ ) { + /* Need two bytes */ + for ( htmp = h ; htmp ; htmp-- ) { + tmp = (sp[0] << (WORDSZ - bs)); + sp++; + tmp |= (sp[0] >> bs); + sp--; + DO_ALU(dp[0],tmp,mask,alu); + dp += pad; + sp += pad; + } + } else if ( l0 <= l1 ) { + /* Need one byte, shifted right */ + for ( htmp = h ; htmp ; htmp-- ) { + tmp = (sp[0] >> bs); + DO_ALU(dp[0],tmp,mask,alu); + dp += pad; + sp += pad; + } + } else { + /* Need one byte, shifted left */ + for ( htmp = h ; htmp ; htmp-- ) { + tmp = (sp[0] << (WORDSZ - bs)); + DO_ALU(dp[0],tmp,mask,alu); + dp += pad; + sp += pad; + } + } +} + +static void +shift_center(pWin,x0,x1,y0,y1,w,h,alu) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +int alu; +{ + int l1 = x1 & WMASK; /* Left edge of target, as bit */ + int r1 = (x1 + w) & WMASK; /* Right edge of target, as bit */ + int pad; + int htmp, wtmp; /* Temporaries for indices over height and width */ + volatile unsigned char tmp; /* Temporary result of the shifts */ + int bs; + int rem; /* Remaining bits; temporary in loop */ + int bytecnt; + + volatile unsigned char *sp, *dp; + + bs = (x1 - x0) & WMASK; + + if ( l1 ) { + bytecnt = (w - (WORDSZ - l1) - r1) >> WSHIFT; + sp = SMEM( ((x0 + (WORDSZ - l1)) >> WSHIFT), y0); + dp = DMEM( ((x1 + (WORDSZ - l1)) >> WSHIFT), y1); + } else { + bytecnt = (w - r1) >> WSHIFT; + sp = SMEM( (x0 >> WSHIFT), y0); + dp = DMEM( (x1 >> WSHIFT), y1); + } + + if ( y1 > y0 ) { /* Move down, start at the bottom */ + if ( x1 > x0 ) { /* Move right, start right */ + pad = - BYTES_PER_LINE(pWin) + bytecnt; + sp += BYTES_PER_LINE(pWin) * (h - 1) + bytecnt - 1; + dp += BYTES_PER_LINE(pWin) * (h - 1) + bytecnt - 1; + } else { /* Move left, start left */ + pad = - BYTES_PER_LINE(pWin) - bytecnt; + sp += BYTES_PER_LINE(pWin) * (h - 1); + dp += BYTES_PER_LINE(pWin) * (h - 1); + } + } else { /* Move up, start at the top */ + if ( x1 > x0 ) { /* Move right, start right */ + pad = BYTES_PER_LINE(pWin) + bytecnt; + sp += bytecnt - 1; + dp += bytecnt - 1; + } else { /* Move left, start left */ + pad = BYTES_PER_LINE(pWin) - bytecnt; + sp += 0; + dp += 0; + } + } + + if ( x1 > x0 ) { /* Move right, start right */ + if ( bs == 0 ) { /* No shift. Need one byte only */ + for ( htmp = h ; htmp ; htmp-- ) { + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = sp[0]; + DO_ALU(dp[0],tmp,~0,alu); + dp--; + sp--; + } + dp += pad; + sp += pad; + } + } else { + for ( htmp = h ; htmp ; htmp-- ) { + if ( bytecnt ) { + sp++; + rem = sp[0]; + sp--; + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = (rem >> bs); + rem = sp[0]; + tmp |= (rem << (WORDSZ - bs)) ; + DO_ALU(dp[0],tmp,~0,alu); + dp--; + sp--; + } + } + dp += pad; + sp += pad; + } + } + } else { /* x1 <= x0 */ /* Move left, start left */ + if ( bs == 0 ) { /* No shift. Need one byte only */ + for ( htmp = h ; htmp ; htmp-- ) { + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = sp[0]; + DO_ALU(dp[0],tmp,~0,alu); + dp++; + sp++; + } + dp += pad; + sp += pad; + } + } else { + for ( htmp = h ; htmp ; htmp-- ) { + if ( bytecnt ) { + rem = sp[0]; + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = (rem << (WORDSZ - bs)); + sp++; + rem = sp[0]; + sp--; + tmp |= (rem >> bs); + DO_ALU(dp[0],tmp,~0,alu); + dp++; + sp++; + } + } + dp += pad; + sp += pad; + } + } + } +} + +/* Copy a rectangle. + */ +static void +aligned_blit(pWin,x0,x1,y0,y1,w,h,alu,planes) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +int alu; +int planes; +{ + IOADDRESS REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; + int plane, bit; + + if ( ((x1 & WMASK) + w) <= WORDSZ ) { + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0,x1,y0,y1,w,h,alu); + } + } + } else if ( x1 > x0 ) { /* Shift right: start right */ + int l1 = x1 & WMASK, r1 = (x1 + w) & WMASK; + + if ( r1 ) { /* right edge */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0+w-r1,x1+w-r1,y0,y1,r1,h,alu); + } + } + } + + /* Center */ + SetVideoGraphics(Graphics_ModeIndex, 1); /* Write mode 1 */ + SetVideoSequencer(Mask_MapIndex, planes); + + aligned_blit_center(pWin,x0,x1,y0,y1,w,h); + + if ( l1 ) { /* left edge */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0,x1,y0,y1,(WORDSZ-l1),h,alu); + } + } + } + } else { + int l1 = x1 & WMASK, r1 = (x1 + w) & WMASK; + + if ( l1 ) { /* left edge */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0,x1,y0,y1,(WORDSZ-l1),h,alu); + } + } + } + + /* Center */ + SetVideoGraphics(Graphics_ModeIndex, 1); /* Write mode 1 */ + SetVideoSequencer(Mask_MapIndex, planes); + + aligned_blit_center(pWin,x0,x1,y0,y1,w,h); + + if ( r1 ) { /* right edge */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX ; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0+w-r1,x1+w-r1,y0,y1,r1,h,alu); + } + } + } + } +} + +static void +aligned_blit_center(pWin,x0,x1,y0,y1,w,h) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +{ + int l1 = x1 & WMASK; /* Left edge of target, as bit */ + int r1 = (x1 + w) & WMASK; /* Right edge of target, as bit */ + int pad; + int htmp, wtmp; /* Temporaries for indices over height and width */ + volatile unsigned char tmp; /* Temporary result of the shifts */ + int bs; + int bytecnt; + + volatile unsigned char *sp, *dp; + + bs = (x1 - x0) & WMASK; + + if ( l1 ) { + bytecnt = (w - (WORDSZ - l1) - r1) >> WSHIFT; + sp = SMEM( ((x0 + (WORDSZ - l1)) >> WSHIFT), y0); + dp = DMEM( ((x1 + (WORDSZ - l1)) >> WSHIFT), y1); + } else { + bytecnt = (w - r1) >> WSHIFT; + sp = SMEM( (x0 >> WSHIFT), y0); + dp = DMEM( (x1 >> WSHIFT), y1); + } + + if ( y1 > y0 ) { /* Move down, start at the bottom */ + if ( x1 > x0 ) { /* Move right, start right */ + pad = - BYTES_PER_LINE(pWin) + bytecnt; + sp += BYTES_PER_LINE(pWin) * (h - 1) + bytecnt - 1; + dp += BYTES_PER_LINE(pWin) * (h - 1) + bytecnt - 1; + } else { /* Move left, start left */ + pad = - BYTES_PER_LINE(pWin) - bytecnt; + sp += BYTES_PER_LINE(pWin) * (h - 1); + dp += BYTES_PER_LINE(pWin) * (h - 1); + } + } else { /* Move up, start at the top */ + if ( x1 > x0 ) { /* Move right, start right */ + pad = BYTES_PER_LINE(pWin) + bytecnt; + sp += bytecnt - 1; + dp += bytecnt - 1; + } else { /* Move left, start left */ + pad = BYTES_PER_LINE(pWin) - bytecnt; + sp += 0; + dp += 0; + } + } + + if ( x1 > x0 ) { /* Move right, start right */ + for ( htmp = h ; htmp ; htmp-- ) { + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = sp[0]; + dp[0] = tmp; + dp--; + sp--; + } + dp += pad; + sp += pad; + } + } else { /* x1 <= x0 */ /* Move left, start left */ + for ( htmp = h ; htmp ; htmp-- ) { + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = sp[0]; + dp[0] = tmp; + dp++; + sp++; + } + dp += pad; + sp += pad; + } + } +} +#else /* PC98_EGC */ + +static void +egc_fast_blt (pWin, alu, writeplanes, x0, y0, x1, y1, w, h) +WindowPtr pWin; +const int alu, writeplanes ; +register int x0, x1 ; +int y0, y1 ; +register int w, h ; +{ +register volatile unsigned char *src ; +register volatile unsigned char *dst ; +unsigned short *src_x ; +unsigned short *dst_x ; +int x_direction, y_interval ; +int src_off, dst_off ; +register int k, i ; +unsigned short ROP_value; + +src = (unsigned char *)SCREENADDRESS( pWin, 0, y0); +dst = (unsigned char *)SCREENADDRESS( pWin, 0, y1); + +/* Set Map Mask */ +outw(EGC_PLANE, ~(writeplanes & VGA_ALLPLANES)); +switch(alu) { +case GXnor: /* ~(S|D) */ + ROP_value = 0x2903; + break; +case GXandInverted: /* ~S&D */ + ROP_value = 0x290c; + break; +case GXand: /* S&D */ + ROP_value = 0x29c0; + break; +case GXequiv: /* ~S ^ D */ + ROP_value = 0x29c3; + break; +case GXxor: /* S^D */ + ROP_value = 0x293c; + break; +case GXandReverse: /* S&~D */ + ROP_value = 0x2930; + break; +case GXorReverse: /* S|~D */ + ROP_value = 0x29f3; + break; +case GXnand: /* ~(S&D) */ + ROP_value = 0x293f; + break; +case GXorInverted: /* ~S|D */ + ROP_value = 0x29cf; + break; +case GXor: /* S|D */ + ROP_value = 0x29fa; + break; +case GXcopyInverted: /* ~S */ + ROP_value = 0x290f; + break; +case GXcopy: /* S */ +default: + ROP_value = 0x29f0; +} +outw(EGC_MODE, ROP_value); +if ( y1 > y0 ) { + y_interval = - BYTES_PER_LINE(pWin) * 8 ; + src += BYTES_PER_LINE(pWin) * ( h - 1 ) ; + dst += BYTES_PER_LINE(pWin) * ( h - 1 ) ; +} +else { + y_interval = BYTES_PER_LINE(pWin) * 8 ; +} + +src = (unsigned char *)((int)src << 3) ; +dst = (unsigned char *)((int)dst << 3) ; + +if ( y1 > y0) { + x_direction = 0x1000 ; + src += x0 + w - 1 ; + dst += x1 + w - 1 ; +} else if ( y1 < y0 ) { + x_direction = 0 ; + src += x0 ; + dst += x1 ; +} else { + if ( x1 < x0 ) { + x_direction = 0 ; + src += x0 ; + dst += x1 ; + } else { + x_direction = 0x1000 ; + src += x0 + w - 1 ; + dst += x1 + w - 1 ; + } +} + outw ( EGC_LENGTH , w - 1 ) ; + +for ( ; h-- ; ) { + if ( x_direction ) { + src_off = 15 - (int)src & 0xf ; + dst_off = 15 - (int)dst & 0xf ; + } else { + src_off = (int)src & 0xf ; + dst_off = (int)dst & 0xf ; + } +#if defined(__NetBSD__) || defined(__OpenBSD__) + src_x = (unsigned short *)(((unsigned int)src >> 4 ) << 1) ; + dst_x = (unsigned short *)(((unsigned int)dst >> 4 ) << 1) ; +#else + src_x = (unsigned short *)(((int)src >> 4 ) << 1) ; + dst_x = (unsigned short *)(((int)dst >> 4 ) << 1) ; +#endif + k = ( src_off + w + 15 ) >> 4 ; + if ( src_off < dst_off ) { + if ( ((src_off + w - 1 ) >> 4) < ((dst_off + w - 1) >> 4)) k++ ; + } + if ( src_off > dst_off ) { + if ( ((src_off + w - 1) >> 4 ) == ((dst_off + w - 1) >> 4) ) k++ ; + if ( x_direction ) dst_x ++ ; + else dst_x -- ; + } + outw ( EGC_ADD , x_direction | src_off | dst_off << 4 ); + if ( x_direction ) { + wcopyl ( src_x, dst_x, k, VIDBASE(pWin) ) ; + } else { + wcopyr ( src_x, dst_x, k, VIDBASE(pWin) ) ; + } +src += y_interval ; +dst += y_interval ; +} +outw ( EGC_ADD, 0 ) ; +outw ( EGC_LENGTH , 0xf ); +return; +} + +void +xf4bppBitBlt( pWin,alu, writeplanes, x0, y0, x1, y1, w, h ) +WindowPtr pWin; /* GJA */ +int alu; +int writeplanes; /* planes */ +int x0, y0, x1, y1, w, h; +{ + if ( ! xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffBitBlt( pWin, alu, writeplanes, + x0, y0, x1, y1, w, h ); + return; + } + +switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + xf4bppFillSolid( pWin, VGA_ALLPLANES, alu, writeplanes, x1, y1, w, h ) ; + /* x1, y1, GJA */ + case GXnoop: /* 0x5 dst */ + return ; + default: + break ; +} + +egc_fast_blt ( pWin, alu, writeplanes, x0, y0, x1, y1, w, h); +return; +} +#endif diff --git a/hw/xfree86/xf4bpp/vgaGC.c b/hw/xfree86/xf4bpp/vgaGC.c new file mode 100644 index 000000000..867e2c50e --- /dev/null +++ b/hw/xfree86/xf4bpp/vgaGC.c @@ -0,0 +1,216 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/vgaGC.c,v 1.4 2003/02/18 21:29:59 tsi Exp $ */ +/* + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM 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. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +*/ + +/* $XConsortium: vgaGC.c /main/6 1996/02/21 17:58:54 kaleb $ */ + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "ppcGCstr.h" + +void +xf4bppChangeGCtype( pGC, devPriv ) +register GC *pGC ; +register ppcPrivGCPtr devPriv ; +{ + if ( devPriv->lastDrawableType == DRAWABLE_PIXMAP ) { + pGC->ops->CopyArea = miCopyArea ; + pGC->ops->PolyFillRect = miPolyFillRect ; + pGC->ops->PushPixels = miPushPixels ; + pGC->ops->PolyArc = miPolyArc ; + pGC->ops->PolyFillArc = miPolyFillArc ; + pGC->ops->PolySegment = miPolySegment ; + } + else { + pGC->ops->CopyArea = xf4bppCopyArea ; + pGC->ops->PolyFillRect = xf4bppPolyFillRect ; + pGC->ops->PushPixels = miPushPixels ; /* GJA */ + pGC->ops->PolyArc = xf4bppZeroPolyArc ; + pGC->ops->PolyFillArc = xf4bppPolyFillArc ; + pGC->ops->PolySegment = xf4bppSegmentSS ; + } + return; +} + +Mask +xf4bppChangeWindowGC( pGC, changes ) +register GC *pGC ; +register Mask changes ; +{ +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr) ; +register unsigned long int idx ; /* used for stepping through bitfields */ + +#define LOWBIT( x ) ( x & - x ) /* Two's complement */ + while ((idx = LOWBIT(changes))) { + switch ( idx ) { + + case GCLineStyle: + case GCLineWidth: + pGC->ops->PolyArc = ( ( pGC->lineStyle == LineSolid ) + ? ( ( pGC->lineWidth == 0 ) ? xf4bppZeroPolyArc + : miPolyArc ) + : miPolyArc ) ; + pGC->ops->PolySegment = ( ( pGC->lineStyle == LineSolid ) + ? ( ( pGC->lineWidth == 0 ) + ? ( ( pGC->fillStyle == FillSolid ) ? + xf4bppSegmentSS : miPolySegment ) + : miPolySegment ) + : ( ( pGC->lineWidth == 0 ) + ? ( ( pGC->fillStyle == FillSolid ) ? + xf4bppSegmentSD : miPolySegment ) + : miPolySegment ) ) ; + pGC->ops->Polylines = ( ( pGC->lineStyle == LineSolid ) + ? ( ( pGC->lineWidth == 0 ) + ? ( (pGC->fillStyle == FillSolid ) ? + xf4bppLineSS : miZeroLine ) + : miWideLine ) + : ( ( pGC->lineWidth == 0 ) + ? ( (pGC->fillStyle == FillSolid ) ? + xf4bppLineSD : miWideDash ) + : miWideDash ) ) ; + /* + * If these are just square boxes with no funny business + * going on we can call the fast routine that draws + * rectangles without floating point. + */ +/* too buggy */ +#if 0 + if ( ( pGC->lineStyle == LineSolid ) + && ( pGC->joinStyle == JoinMiter ) + && ( pGC->lineWidth != 0 ) ) + pGC->ops->PolyRectangle = xf4bppPolyRectangle; + else +#endif + pGC->ops->PolyRectangle = miPolyRectangle; + + changes &= ~( GCLineStyle | GCLineWidth ) ; + break ; + case GCJoinStyle: +#ifdef NEED_LINEHELPER + pGC->ops->LineHelper = + ( pGC->joinStyle == JoinMiter ) ? miMiter : miNotMiter ; +#endif + /* + * If these are just square boxes with no funny business + * going on we can call the fast routine that draws + * rectangles without floating point. + */ +/* too buggy */ +#if 0 + if ( ( pGC->lineStyle == LineSolid ) + && ( pGC->joinStyle == JoinMiter ) + && ( pGC->lineWidth != 0 ) ) + pGC->ops->PolyRectangle = xf4bppPolyRectangle; + else +#endif + pGC->ops->PolyRectangle = miPolyRectangle; + changes &= ~ idx ; /* i.e. changes &= ~ GCJoinStyle */ + break ; + + case GCBackground: + if ( pGC->fillStyle != FillOpaqueStippled ) { + changes &= ~ idx ; /* i.e. changes &= ~GCBackground */ + break ; + } /* else Fall Through */ + case GCForeground: + if ( pGC->fillStyle == FillTiled ) { + changes &= ~ idx ; /* i.e. changes &= ~GCForeground */ + break ; + } /* else Fall Through */ + case GCFunction: + case GCPlaneMask: + case GCFillStyle: + { /* new_fill */ + int fillStyle = devPriv->colorRrop.fillStyle ; + /* install a suitable fillspans */ + if ( fillStyle == FillSolid ) + pGC->ops->FillSpans = xf4bppSolidWindowFS ; + else if ( fillStyle == FillStippled ) + pGC->ops->FillSpans = xf4bppStippleWindowFS ; + else if ( fillStyle == FillOpaqueStippled ) + pGC->ops->FillSpans = xf4bppOpStippleWindowFS ; + else /* fillStyle == FillTiled */ + pGC->ops->FillSpans = xf4bppTileWindowFS ; + } /* end of new_fill */ + changes &= ~( GCBackground | GCForeground + | GCFunction + | GCPlaneMask | GCFillStyle ) ; + break ; + + default: + ErrorF("xf4bppChangeWindowGC: Unexpected GC Change\n") ; + changes &= ~ idx ; /* Remove it anyway */ + break ; + } + } + return changes; +} diff --git a/hw/xfree86/xf4bpp/vgaImages.c b/hw/xfree86/xf4bpp/vgaImages.c new file mode 100644 index 000000000..66c2c14e0 --- /dev/null +++ b/hw/xfree86/xf4bpp/vgaImages.c @@ -0,0 +1,457 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/vgaImages.c,v 1.4 2002/01/25 21:56:22 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: vgaImages.c /main/5 1996/02/21 17:58:58 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "vgaReg.h" +#include "vgaVideo.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +#undef TRUE +#undef FALSE +#define TRUE 1 +#define FALSE 0 + +void +xf4bppDrawColorImage( pWin, x, y, w, h, data, RowIncrement, alu, planes ) +WindowPtr pWin; /* GJA */ +int x, y ; +register int w, h ; +unsigned char *data ; +register int RowIncrement ; +const int alu ; +const unsigned long int planes ; +{ +IOADDRESS REGBASE; +register unsigned long int tmp ; +register const unsigned char *src ; +register volatile unsigned char *dst ; +register int Pixel_Count ; +register unsigned int currMask ; +register unsigned int InitialMask ; +register volatile unsigned char *StartByte ; +unsigned int invert_source_data = FALSE ; +#ifdef PC98_EGC /* new EGC test */ +register unsigned char tmp1; +#endif + +{ /* Start GJA */ + if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffDrawColorImage( pWin, x, y, w, h, data, RowIncrement, alu, planes ); + return; + } +} /* End GJA */ + +{ + unsigned int invert_existing_data = FALSE ; + unsigned int data_rotate_value = VGA_COPY_MODE ; +#ifdef PC98_EGC + unsigned short ROP_value; +#endif + + REGBASE = 0x300 + + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase; + + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + xf4bppFillSolid( pWin, VGA_ALLPLANES, alu, planes, x, y, w, h ) ; + case GXnoop: /* 0x5 dst */ + return ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + invert_existing_data = TRUE ; + case GXandInverted: /* 0x4 NOT src AND dst */ + invert_source_data = TRUE ; + case GXand: /* 0x1 src AND dst */ + data_rotate_value = VGA_AND_MODE ; + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + invert_source_data = TRUE ; + case GXxor: /* 0x6 src XOR dst */ + data_rotate_value = VGA_XOR_MODE ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_AND_MODE ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + invert_source_data = TRUE ; + case GXorReverse: /* 0xb src OR NOT dst */ + invert_existing_data = TRUE ; + /* GJA -- moved this here */ + data_rotate_value = VGA_OR_MODE ; + break ; + case GXorInverted: /* 0xd NOT src OR dst */ + invert_source_data = TRUE ; + case GXor: /* 0x7 src OR dst */ + data_rotate_value = VGA_OR_MODE ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + invert_source_data = TRUE ; + case GXcopy: /* 0x3 src */ + default: + break ; + } +#ifndef PC98_EGC + if ( invert_existing_data ) + xf4bppFillSolid( pWin, VGA_ALLPLANES, GXinvert, planes, x, y, w, h ) ; +#endif +#ifdef PC98_EGC + /* Setup EGC Registers */ + switch(data_rotate_value) { +/* EGC MODE.. Cmp Read: Flase, WriteSource=ROP, ReadSource=CPU */ + case VGA_AND_MODE: + if (invert_existing_data) + ROP_value = EGC_AND_INV_MODE; + else + ROP_value = EGC_AND_MODE; + break; + case VGA_OR_MODE: + if (invert_existing_data) + ROP_value = EGC_OR_INV_MODE; + else + ROP_value = EGC_OR_MODE; + break; + case VGA_XOR_MODE: + if (invert_existing_data) + ROP_value = EGC_XOR_INV_MODE; + else + ROP_value = EGC_XOR_MODE; + break; + case VGA_COPY_MODE: + default: + ROP_value = EGC_COPY_MODE; + break; + } + outw(EGC_PLANE, ~(planes & VGA_ALLPLANES)); + outw(EGC_MODE, ROP_value); + outw(EGC_FGC, 0x0000); + tmp1 = 0; +#else + /* Setup VGA Registers */ + SetVideoSequencer( Mask_MapIndex, planes & VGA_ALLPLANES ) ; + /* Set Raster Op */ + SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + SetVideoGraphics( Graphics_ModeIndex, VGA_WRITE_MODE_2 ) ; +#endif +} + +StartByte = SCREENADDRESS(pWin, x, y); +InitialMask = SCRRIGHT8( LeftmostBit, BIT_OFFSET( x ) ) ; +if ( invert_source_data ) +#ifdef PC98_EGC +#if 0 /* New EGC version */ + egc_image_invert ( StartByte, data, InitialMask, w, h, + RowIncrement ) ; +#else /* new EGC c version */ + for ( ; + h-- ; + data += RowIncrement, StartByte += BYTES_PER_LINE(pWin) ) { + dst = StartByte; + for ( src = data, + Pixel_Count = w, currMask = InitialMask ; + Pixel_Count-- ; + src++ ) { + if (tmp1 != (~*src & VGA_ALLPLANES)) { + tmp1 = ~*src & VGA_ALLPLANES; + /* set FGC */ + outw(EGC_FGC, ~*src & VGA_ALLPLANES); + } + *((VgaMemoryPtr) dst) = currMask; + if ( currMask & RightmostBit ) { + currMask = LeftmostBit ; + dst++; + } + else + currMask = SCRRIGHT8( currMask, 1 ) ; + } + } +#endif /* new EGC */ +#else /* original */ + for ( ; + h-- ; + data += RowIncrement, StartByte += BYTES_PER_LINE(pWin) ) { + dst = StartByte; + for ( src = data, + Pixel_Count = w, currMask = InitialMask ; + Pixel_Count-- ; + src++ ) { + /* Set The Bit Mask Reg */ + SetVideoGraphics( Bit_MaskIndex, currMask ) ; + /* Read To Load vga Data Latches */ + tmp = *( (VgaMemoryPtr) dst ) ; + *( (VgaMemoryPtr) dst ) = ~ *src ; + if ( currMask & RightmostBit ) { + currMask = LeftmostBit ; + dst++; + } + else + currMask = SCRRIGHT8( currMask, 1 ) ; + } + } +#endif +else /* invert_source_data == FALSE */ +#ifdef PC98_EGC +#if 0 /* new EGC version */ + egc_image ( StartByte, data, InitialMask, w, h, + RowIncrement ); +#else /* new EGC c version */ + for ( ; + h-- ; + data += RowIncrement, StartByte += BYTES_PER_LINE(pWin) ) { + dst = StartByte; + for ( src = data, + Pixel_Count = w, currMask = InitialMask ; + Pixel_Count-- ; + src++ ) { + if (tmp1 != *src & VGA_ALLPLANES) { + tmp1 = *src & VGA_ALLPLANES; + outw(EGC_FGC, tmp1); /* set FGC */ + } + *((VgaMemoryPtr) dst) = currMask; /* write with mask */ + if ( currMask & RightmostBit ) { + currMask = LeftmostBit ; + dst++; + } + else + currMask = SCRRIGHT8( currMask, 1 ) ; + } + } +#endif /* new EGC version */ +#else /* original */ + for ( ; + h-- ; + data += RowIncrement, StartByte += BYTES_PER_LINE(pWin) ) { + dst = StartByte; + for ( src = data, + Pixel_Count = w, currMask = InitialMask ; + Pixel_Count-- ; + src++ ) { + /* Set The Bit Mask Reg */ + SetVideoGraphics( Bit_MaskIndex, currMask ) ; /* GJA */ + /* Read To Load vga Data Latches */ + tmp = *( (VgaMemoryPtr) dst ) ; + *( (VgaMemoryPtr) dst ) = *src ; + if ( currMask & RightmostBit ) { + currMask = LeftmostBit ; + dst++; + } + else + currMask = SCRRIGHT8( currMask, 1 ) ; + } + } +#endif /* original */ + +return ; +} + +#ifndef PC98_EGC +static unsigned long int +read8Z +( + IOADDRESS REGBASE, + register volatile unsigned char *screen_ptr +) +{ +register unsigned long int i ; +register unsigned long int j ; + +/* Read One Byte At A Time to get + * i == [ Plane 3 ] [ Plane 2 ] [ Plane 1 ] [ Plane 0 ] + * into a single register + */ +SetVideoGraphicsData( 3 ) ; +i = *( (VgaMemoryPtr) screen_ptr ) << 8 ; +SetVideoGraphicsData( 2 ) ; +i |= *( (VgaMemoryPtr) screen_ptr ) ; +i <<= 8 ; +SetVideoGraphicsData( 1 ) ; +i |= *( (VgaMemoryPtr) screen_ptr ) ; +i <<= 8 ; +SetVideoGraphicsData( 0 ) ; +i |= *( (VgaMemoryPtr) screen_ptr ) ; + +/* Push Bits To Get + * j == [Pixel 7][Pixel 6][Pixel 5][Pixel 4][Pixel 3][Pixel 2][Pixel 1][Pixel 0] + * into one register + */ + +j = ( i & 0x1 ) << 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; + +j |= ( i & 0x2 ) << 28 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 24 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 20 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 16 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 12 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 8 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 4 ; +j |= ( i >>= 1 ) & 0x2 ; + +j |= ( i & 0x4 ) << 28 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 24 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 20 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 16 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 12 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 8 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 4 ; +j |= ( i >>= 1 ) & 0x4 ; + +j |= ( i & 0x8 ) << 28 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 24 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 20 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 16 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 12 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 8 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 4 ; +j |= ( i >>= 1 ) & 0x8 ; + +return j ; +} +#endif /* not PC98_EGC */ + +void +xf4bppReadColorImage( pWin, x, y, lx, ly, data, RowIncrement ) +WindowPtr pWin; /* GJA */ +int x, y ; +int lx, ly ; +register unsigned char *data ; +int RowIncrement ; +{ +IOADDRESS REGBASE; +register unsigned long int tmp ; +register volatile unsigned char *src ; +volatile unsigned char *masterSrc ; +int savCenterWidth ; +int dx ; +int skip ; +int center_width ; +int ignore ; +int pad ; +unsigned char tmpc; + +{ /* Start GJA */ + if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffReadColorImage( pWin, x, y, lx, ly, data, RowIncrement ); + return; + } +} /* End GJA */ + +if ( ( lx <= 0 ) || ( ly <= 0 ) ) + return ; + + REGBASE = 0x300 + + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase; + +/* Setup VGA Registers */ +#ifndef PC98_EGC +SetVideoGraphicsIndex( Graphics_ModeIndex ) ; +tmpc = inb( GraphicsDataRegister ); +SetVideoGraphicsData( tmpc & ~0x8 ) ; /* Clear the bit */ +SetVideoGraphicsIndex( Read_Map_SelectIndex ) ; +#else +outw(EGC_MODE, 0x0800); +#endif + +skip = BIT_OFFSET( x ) ; +pad = RowIncrement - lx ; +ignore = BIT_OFFSET( x + lx ) ; +masterSrc = SCREENADDRESS( pWin, x, y ) ; +center_width = ROW_OFFSET( x + lx ) - ROW_OFFSET( ( x + 0x7 ) & ~0x7 ) ; + +#define SINGLE_STEP *data++ = tmp & VGA_ALLPLANES ; tmp >>= 4 + + +if ( center_width < 0 ) { + src = masterSrc; + for ( ; ly-- ; ) { + tmp = read8Z( REGBASE, src ) >> ( skip << 2 ) ; + for ( dx = lx + 1 ; --dx ; ) { + SINGLE_STEP ; + } + data += pad ; + src += BYTES_PER_LINE(pWin); + } +} else + for ( savCenterWidth = center_width ; + ly-- ; + center_width = savCenterWidth, + masterSrc += BYTES_PER_LINE(pWin) ) { + src = masterSrc ; + tmp = read8Z( REGBASE, src ) ; src++; + if ((dx = skip)) + tmp >>= ( dx << 2 ) ; + else + if ( lx < 8 ) { /* kludge -- GJA */ + --center_width ; /* kludge -- GJA */ + dx = 8 - lx ; /* kludge -- GJA */ + } else /* kludge -- GJA */ + --center_width ; + BranchPoint: + switch ( dx ) { + LoopTop: + case 0x0: SINGLE_STEP ; + case 0x1: SINGLE_STEP ; + case 0x2: SINGLE_STEP ; + case 0x3: SINGLE_STEP ; + case 0x4: SINGLE_STEP ; + case 0x5: SINGLE_STEP ; + case 0x6: SINGLE_STEP ; + case 0x7: *data++ = tmp & VGA_ALLPLANES ; + + /* Fall Through To End Of Inner Loop */ + if ( center_width > 0 ) { + tmp = read8Z( REGBASE, src ) ; src++; + center_width-- ; + goto LoopTop ; + } + else if ( ( center_width == 0 ) + && ( dx = ( - ignore ) & 07 ) ) { + tmp = read8Z( REGBASE, src ) ; src++; + center_width-- ; + goto BranchPoint ; /* Do Mod 8 edge */ + } + else /* End of this line */ + data += pad ; + } + } + +return ; +} diff --git a/hw/xfree86/xf4bpp/vgaReg.h b/hw/xfree86/xf4bpp/vgaReg.h new file mode 100644 index 000000000..43f59d938 --- /dev/null +++ b/hw/xfree86/xf4bpp/vgaReg.h @@ -0,0 +1,136 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/vgaReg.h,v 1.4 2002/01/25 21:56:22 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* $XConsortium: vgaReg.h /main/4 1996/02/21 17:59:02 kaleb $ */ + +#define SET_BYTE_REGISTER( ioport, value ) outb( ioport, value ) +#define SET_INDEX_REGISTER( ioport, value ) SET_BYTE_REGISTER( ioport, value ) +#define SET_DATA_REGISTER( ioport, value ) SET_BYTE_REGISTER( ioport, value ) +/* GJA -- deleted RTIO and ATRIO case here, so that a PCIO #define became + * superfluous. + */ +#define SET_INDEXED_REGISTER(RegGroup, Index, Value) \ + (SET_BYTE_REGISTER(RegGroup, Index), \ + SET_BYTE_REGISTER((RegGroup) + 1, Value)) + +/* There is a jumper on the ega to change this to 0x200 instead !! */ +#if 0 /* This is now a stack variable, as needed */ +#define REGBASE 0x300 +#endif + +#define AttributeIndexRegister REGBASE + 0xC0 +#define AttributeDataWriteRegister REGBASE + 0xC0 +#define AttributeDataReadRegister REGBASE + 0xC1 +#define AttributeRegister AttributeIndexRegister +#define AttributeModeIndex 0x30 +#define OverScanColorIndex 0x31 +#define ColorPlaneEnableIndex 0x32 +#define HorizPelPanIndex 0x33 +#define ColorSelectIndex 0x34 +#ifndef PC98_EGC +#define SetVideoAttributeIndex( index ) \ + SET_INDEX_REGISTER( AttributeIndexRegister, index ) +#define SetVideoAttribute( index, value ) \ + SetVideoAttributeIndex( index ) ; \ + SET_BYTE_REGISTER( AttributeDataWriteRegister, value ) +#endif + + /* Graphics Registers 03CE & 03CF */ +#define GraphicsIndexRegister REGBASE + 0xCE +#define GraphicsDataRegister REGBASE + 0xCF +#define GraphicsRegister GraphicsIndexRegister +#define Set_ResetIndex 0x00 +#define Enb_Set_ResetIndex 0x01 +#define Color_CompareIndex 0x02 +#define Data_RotateIndex 0x03 +#define Read_Map_SelectIndex 0x04 +#define Graphics_ModeIndex 0x05 +#define MiscellaneousIndex 0x06 +#define Color_Dont_CareIndex 0x07 +#define Bit_MaskIndex 0x08 +#ifndef PC98_EGC +#define SetVideoGraphicsIndex( index ) \ + SET_INDEX_REGISTER( GraphicsIndexRegister, index ) +#define SetVideoGraphicsData( value ) \ + SET_INDEX_REGISTER( GraphicsDataRegister, value ) +#define SetVideoGraphics( index, value ) \ + SET_INDEXED_REGISTER( GraphicsRegister, index, value ) +#endif + +/* Sequencer Registers 03C4 & 03C5 */ +#define SequencerIndexRegister REGBASE + 0xC4 +#define SequencerDataRegister REGBASE + 0xC5 +#define SequencerRegister SequencerIndexRegister +#define Seq_ResetIndex 00 +#define Clock_ModeIndex 01 +#define Mask_MapIndex 02 +#define Char_Map_SelectIndex 03 +#define Memory_ModeIndex 04 +#ifndef PC98_EGC +#define SetVideoSequencerIndex( index ) \ + SET_INDEX_REGISTER( SequencerIndexRegister, index ) +#define SetVideoSequencer( index, value ) \ + SET_INDEXED_REGISTER( SequencerRegister, index, value ) +#endif + +/* BIT CONSTANTS FOR THE VGA/EGA HARDWARE */ +/* for the Graphics' Data_Rotate Register */ +#define VGA_ROTATE_FUNC_SHIFT 3 +#define VGA_COPY_MODE ( 0 << VGA_ROTATE_FUNC_SHIFT ) /* 0x00 */ +#define VGA_AND_MODE ( 1 << VGA_ROTATE_FUNC_SHIFT ) /* 0x08 */ +#define VGA_OR_MODE ( 2 << VGA_ROTATE_FUNC_SHIFT ) /* 0x10 */ +#define VGA_XOR_MODE ( 3 << VGA_ROTATE_FUNC_SHIFT ) /* 0x18 */ +/* for the Graphics' Graphics_Mode Register */ +#define VGA_READ_MODE_SHIFT 3 +#define VGA_WRITE_MODE_0 0 +#define VGA_WRITE_MODE_1 1 +#define VGA_WRITE_MODE_2 2 +#define VGA_WRITE_MODE_3 3 +#define VGA_READ_MODE_0 ( 0 << VGA_READ_MODE_SHIFT ) +#define VGA_READ_MODE_1 ( 1 << VGA_READ_MODE_SHIFT ) + +#ifdef PC98_EGC +/* I/O port address define for extended EGC */ +#define EGC_PLANE 0x4a0 /* EGC active plane select */ +#define EGC_READ 0x4a2 /* EGC FGC,EGC,Read Plane */ +#define EGC_MODE 0x4a4 /* EGC Mode register & ROP */ +#define EGC_FGC 0x4a6 /* EGC Forground color */ +#define EGC_MASK 0x4a8 /* EGC Mask register */ +#define EGC_BGC 0x4aa /* EGC Background color */ +#define EGC_ADD 0x4ac /* EGC Dest/Source address */ +#define EGC_LENGTH 0x4ae /* EGC Bit length */ + +#define PALETTE_ADD 0xa8 /* Palette address */ +#define PALETTE_GRE 0xaa /* Palette Green */ +#define PALETTE_RED 0xac /* Palette Red */ +#define PALETTE_BLU 0xae /* Palette Blue */ + +#define EGC_AND_MODE 0x2c8c /* (S&P&D)|(~S&D) */ +#define EGC_AND_INV_MODE 0x2c2c /* (S&P&~D)|(~S&D) */ +#define EGC_OR_MODE 0x2cec /* S&(P|D)|(~S&D) */ +#define EGC_OR_INV_MODE 0x2cbc /* S&(P|~D)|(~S&D) */ +#define EGC_XOR_MODE 0x2c6c /* (S&(P&~D|~P&D))|(~S&D) */ +#define EGC_XOR_INV_MODE 0x2c9c /* (S&(P&D)|(~P&~D))|(~S&D) */ +#define EGC_COPY_MODE 0x2cac /* (S&P)|(~S&D) */ +#endif diff --git a/hw/xfree86/xf4bpp/vgaSolid.c b/hw/xfree86/xf4bpp/vgaSolid.c new file mode 100644 index 000000000..ceb39ef77 --- /dev/null +++ b/hw/xfree86/xf4bpp/vgaSolid.c @@ -0,0 +1,569 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/vgaSolid.c,v 1.5 2002/01/25 21:56:22 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* $XConsortium: vgaSolid.c /main/5 1996/02/21 17:59:06 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "vgaReg.h" +#include "vgaVideo.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +#undef TRUE +#undef FALSE +#define TRUE 1 +#define FALSE 0 + +#ifndef PC98_EGC +#ifdef USE_ASM +extern void fastFill(); +extern void fastFillRMW(); +#else + +static void fastFill +( + register volatile unsigned char *destination, + register const unsigned int bytes_per_line, + register const unsigned int bytewidth, /* MUST BE > 0 !! */ + register unsigned int height /* MUST BE > 0 !! */ +) +{ +int stop_count = bytewidth ; +register int row_jump = bytes_per_line - bytewidth ; +#if !defined(OLDHC) && defined(BSDrt) && !defined(i386) +register const unsigned int notZero = ((unsigned char)(~0x0)); +#else +#define notZero ((unsigned char)(~0)) +#endif + +#define SINGLE_STORE \ + ( *( (VgaMemoryPtr) destination ) = notZero ); \ + destination++; stop_count--; + +/* TOP OF FIRST LOOP */ +BranchPoint: + +switch ( bytewidth & 0xF ) { /* Jump into loop at mod 16 remainder */ + LoopTop : + case 0x0 : SINGLE_STORE ; + case 0xF : SINGLE_STORE ; + case 0xE : SINGLE_STORE ; + case 0xD : SINGLE_STORE ; + case 0xC : SINGLE_STORE ; + case 0xB : SINGLE_STORE ; + case 0xA : SINGLE_STORE ; + case 0x9 : SINGLE_STORE ; + case 0x8 : SINGLE_STORE ; + case 0x7 : SINGLE_STORE ; + case 0x6 : SINGLE_STORE ; + case 0x5 : SINGLE_STORE ; + case 0x4 : SINGLE_STORE ; + case 0x3 : SINGLE_STORE ; + case 0x2 : SINGLE_STORE ; + case 0x1 : SINGLE_STORE ; +/* FIRST LOOP */ + if ( stop_count ) + goto LoopTop ; +/* SECOND LOOP */ + if ( --height ) { + destination += row_jump ; + stop_count = bytewidth ; + goto BranchPoint ; + } + else + return ; +#undef SINGLE_STORE +} +/*NOTREACHED*/ +} + +/* For Read-Modify-Write Case */ +static void fastFillRMW +( + register volatile unsigned char *destination, + register const unsigned int bytes_per_line, + register const unsigned int bytewidth, /* MUST BE > 0 !! */ + register unsigned int height /* MUST BE > 0 !! */ +) +{ +int stop_count = bytewidth ; +register int row_jump = bytes_per_line - bytewidth ; +#if !defined(OLDHC) && defined(BSDrt) && !defined(i386) +register const unsigned int notZero = ((unsigned char)(~0x0)); +#endif +register int tmp ; + +#define SINGLE_STORE \ + tmp = *( (VgaMemoryPtr) destination ) ; \ + ( *( (VgaMemoryPtr) destination ) = notZero ) ; \ + destination++; stop_count-- ; + +/* TOP OF FIRST LOOP */ +BranchPoint: + +switch ( bytewidth & 0xF ) { /* Jump into loop at mod 16 remainder */ + LoopTop : + case 0x0 : SINGLE_STORE ; + case 0xF : SINGLE_STORE ; + case 0xE : SINGLE_STORE ; + case 0xD : SINGLE_STORE ; + case 0xC : SINGLE_STORE ; + case 0xB : SINGLE_STORE ; + case 0xA : SINGLE_STORE ; + case 0x9 : SINGLE_STORE ; + case 0x8 : SINGLE_STORE ; + case 0x7 : SINGLE_STORE ; + case 0x6 : SINGLE_STORE ; + case 0x5 : SINGLE_STORE ; + case 0x4 : SINGLE_STORE ; + case 0x3 : SINGLE_STORE ; + case 0x2 : SINGLE_STORE ; + case 0x1 : SINGLE_STORE ; +/* FIRST LOOP */ + if ( stop_count ) + goto LoopTop ; +/* SECOND LOOP */ + if ( --height ) { + destination += row_jump ; + stop_count = bytewidth ; + goto BranchPoint ; + } + else + return ; +} +#undef SINGLE_STORE +/*NOTREACHED*/ +} +#endif + + +void xf4bppFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ) +WindowPtr pWin; /* GJA */ +unsigned long int color ; +const int alu ; +unsigned long int planes ; +register int x0 ; +register const int y0 ; +register int lx ; +register const int ly ; /* MUST BE > 0 !! */ +{ +IOADDRESS REGBASE; +register volatile unsigned char *dst ; +register int tmp ; +register int tmp2 ; +register int tmp3 ; +unsigned int data_rotate_value = VGA_COPY_MODE ; +unsigned int read_write_modify = FALSE ; +unsigned int invert_existing_data = FALSE ; + +{ /* Start GJA */ + if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ); + return; + } +} /* End GJA */ + +if ( ( lx == 0 ) || ( ly == 0 ) ) + return; + +switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + color = 0 ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + invert_existing_data = TRUE ; + case GXandInverted: /* 0x4 NOT src AND dst */ + color = ~color ; + case GXand: /* 0x1 src AND dst */ + data_rotate_value = VGA_AND_MODE ; + read_write_modify = TRUE ; + case GXcopy: /* 0x3 src */ + break ; + case GXnoop: /* 0x5 dst */ + return ; + case GXequiv: /* 0x9 NOT src XOR dst */ + color = ~color ; + case GXxor: /* 0x6 src XOR dst */ + data_rotate_value = VGA_XOR_MODE ; + read_write_modify = TRUE ; + planes &= color ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_AND_MODE ; + read_write_modify = TRUE ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_OR_MODE ; + read_write_modify = TRUE ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + invert_existing_data = TRUE ; + case GXorInverted: /* 0xd NOT src OR dst */ + color = ~color ; + case GXor: /* 0x7 src OR dst */ + data_rotate_value = VGA_OR_MODE ; + read_write_modify = TRUE ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + color = ~color ; + break ; + case GXinvert: /* 0xa NOT dst */ + data_rotate_value = VGA_XOR_MODE ; + read_write_modify = TRUE ; + case GXset: /* 0xf 1 */ + color = VGA_ALLPLANES ; + default: + break ; +} + +if ( !( planes &= VGA_ALLPLANES ) ) + return ; + +REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; + +/* + * Set The Plane-Enable + */ +SetVideoSequencer( Mask_MapIndex, planes ) ; +SetVideoGraphics( Enb_Set_ResetIndex, planes ) ; +/* + * Put Display Into SET/RESET Write Mode + */ +SetVideoGraphics( Graphics_ModeIndex, VGA_WRITE_MODE_3 ) ; +/* + * Set The Color in The Set/Reset Register + */ +SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ; +/* + * Set The Function-Select In The Data Rotate Register + */ +SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + +/* Do Left Edge */ +if ((tmp = x0 & 07)) { + tmp2 = SCRRIGHT8( ( (unsigned) 0xFF ), tmp ) ; + /* Catch The Cases Where The Entire Region Is Within One Byte */ + if ( ( lx -= 8 - tmp ) < 0 ) { + tmp2 &= SCRLEFT8( 0xFF, -lx ) ; + lx = 0 ; + } + /* Set The Bit Mask Reg */ + SetVideoGraphics(Bit_MaskIndex, tmp2 ) ; + if ( invert_existing_data == TRUE ) { + SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ; + dst = SCREENADDRESS( pWin, x0, y0 ); + for ( tmp = ly; + tmp-- ; ) { + tmp3 = *( (VgaMemoryPtr) dst ) ; + *( (VgaMemoryPtr) dst ) = tmp2 ; + dst += BYTES_PER_LINE(pWin); + } + SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + /* Un-Set XOR */ + } + dst = SCREENADDRESS( pWin, x0, y0 ); + for ( tmp = ly; + tmp-- ; ) { + tmp3 = *( (VgaMemoryPtr) dst ) ; + *( (VgaMemoryPtr) dst ) = tmp2 ; + dst += BYTES_PER_LINE(pWin); + } + if ( !lx ) { /* All Handled In This Byte */ + return ; + } + x0 = ( x0 + 8 ) & ~07 ; +} + +/* Fill The Center Of The Box */ +if ( ROW_OFFSET( lx ) ) { + SetVideoGraphics(Bit_MaskIndex, 0xFF ) ; + if ( invert_existing_data == TRUE ) { + SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ; + fastFillRMW( SCREENADDRESS( pWin, x0, y0 ), + BYTES_PER_LINE(pWin), + ROW_OFFSET( lx ), ly ) ; + SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + /* Un-Set XOR */ + /* Point At The Bit Mask Reg */ + } + (* ( ( read_write_modify == FALSE ) ? fastFill : fastFillRMW ) ) + ( SCREENADDRESS( pWin, x0, y0 ), BYTES_PER_LINE(pWin), + ROW_OFFSET( lx ), ly ) ; +} + +/* Do Right Edge */ +if ((tmp = BIT_OFFSET(lx))) { /* x0 Now Is Byte Aligned */ + /* Set The Bit Mask */ + SetVideoGraphics( Bit_MaskIndex, + (tmp2 = SCRLEFT8( 0xFF, ( 8 - tmp ) ) ) ) ; + if ( invert_existing_data == TRUE ) { + SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ; + dst = SCREENADDRESS( pWin, ( x0 + lx ), y0 ); + for ( tmp = ly; + tmp-- ; ) { + tmp3 = *( (VgaMemoryPtr) dst ) ; + *( (VgaMemoryPtr) dst ) = tmp2 ; + dst += BYTES_PER_LINE(pWin); + } + SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + /* Un-Set XOR */ + } + dst = SCREENADDRESS( pWin, ( x0 + lx ), y0 ); + for ( tmp = ly; + tmp-- ; ) { + tmp3 = *( (VgaMemoryPtr) dst ) ; + *( (VgaMemoryPtr) dst ) = tmp2 ; + dst += BYTES_PER_LINE(pWin) ; + } +} +/* Disable Set/Reset Register */ +SetVideoGraphics( Enb_Set_ResetIndex, 0 ) ; + + +return ; +} + +#else /* for PC98 EGC */ +static void WordfastFill( destination, bytes_per_line, wordwidth, height ) +register volatile unsigned char *destination ; +register const unsigned int bytes_per_line ; +register const unsigned int wordwidth ; /* MUST BE > 0 !! */ +register unsigned int height ; /* MUST BE > 0 !! */ +{ +int stop_count = wordwidth ; +register int row_jump = bytes_per_line - wordwidth*2 ; +#if !defined(OLDHC) && defined(BSDrt) && !defined(i386) && 0 +register const int notZero = ~0x0 ; +#else +#define notZero ( ~0 ) +#endif + +#define SINGLE_STORE \ + ( *( (unsigned short *) destination++ ) = notZero ); \ + destination++; stop_count--; + +/* TOP OF FIRST LOOP */ +BranchPoint: + +switch ( wordwidth & 0xF ) { /* Jump into loop at mod 16 remainder */ + LoopTop : + case 0x0 : SINGLE_STORE ; + case 0xF : SINGLE_STORE ; + case 0xE : SINGLE_STORE ; + case 0xD : SINGLE_STORE ; + case 0xC : SINGLE_STORE ; + case 0xB : SINGLE_STORE ; + case 0xA : SINGLE_STORE ; + case 0x9 : SINGLE_STORE ; + case 0x8 : SINGLE_STORE ; + case 0x7 : SINGLE_STORE ; + case 0x6 : SINGLE_STORE ; + case 0x5 : SINGLE_STORE ; + case 0x4 : SINGLE_STORE ; + case 0x3 : SINGLE_STORE ; + case 0x2 : SINGLE_STORE ; + case 0x1 : SINGLE_STORE ; +/* FIRST LOOP */ + if ( stop_count ) + goto LoopTop ; +/* SECOND LOOP */ + if ( --height ) { + destination += row_jump ; + stop_count = wordwidth ; + goto BranchPoint ; + } + else + return ; +#undef SINGLE_STORE +} +/*NOTREACHED*/ +} + +void xf4bppFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ) +WindowPtr pWin; /* GJA */ +unsigned long int color ; +const int alu ; +unsigned long int planes ; +register int x0 ; +register const int y0 ; +register int lx ; +register const int ly ; /* MUST BE > 0 !! */ +{ +register volatile unsigned char *dst ; +register tmp ; +register tmp2 ; +register unsigned short tmp3 ; +unsigned short ROP_value; +unsigned int data_rotate_value = VGA_COPY_MODE ; +unsigned int read_write_modify = FALSE ; +unsigned int invert_existing_data = FALSE ; + +{ /* Start GJA */ + if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ); + return; + } +} /* End GJA */ + +if ( ( lx == 0 ) || ( ly == 0 ) ) + return; + +switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + color = 0 ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + invert_existing_data = TRUE ; + case GXandInverted: /* 0x4 NOT src AND dst */ + color = ~color ; + case GXand: /* 0x1 src AND dst */ + data_rotate_value = VGA_AND_MODE ; + read_write_modify = TRUE ; + case GXcopy: /* 0x3 src */ + break ; + case GXnoop: /* 0x5 dst */ + return ; + case GXequiv: /* 0x9 NOT src XOR dst */ + color = ~color ; + case GXxor: /* 0x6 src XOR dst */ + data_rotate_value = VGA_XOR_MODE ; + read_write_modify = TRUE ; + planes &= color ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_AND_MODE ; + read_write_modify = TRUE ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_OR_MODE ; + read_write_modify = TRUE ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + invert_existing_data = TRUE ; + case GXorInverted: /* 0xd NOT src OR dst */ + color = ~color ; + case GXor: /* 0x7 src OR dst */ + data_rotate_value = VGA_OR_MODE ; + read_write_modify = TRUE ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + color = ~color ; + break ; + case GXinvert: /* 0xa NOT dst */ + data_rotate_value = VGA_XOR_MODE ; + read_write_modify = TRUE ; + case GXset: /* 0xf 1 */ + color = VGA_ALLPLANES ; + default: + break ; +} + +if ( !( planes &= VGA_ALLPLANES ) ) + return ; + +/* Set Access Planes */ +outw(EGC_PLANE, ~planes); +switch(data_rotate_value) { +/* EGC MODE.. Cmp Read: Flase, WriteSource=ROP, ReadSource=CPU */ + case VGA_AND_MODE: + if (invert_existing_data) + ROP_value = EGC_AND_INV_MODE; + else + ROP_value = EGC_AND_MODE; + break; + case VGA_OR_MODE: + if (invert_existing_data) + ROP_value = EGC_OR_INV_MODE; + else + ROP_value = EGC_OR_MODE; + break; + case VGA_XOR_MODE: + if (invert_existing_data) + ROP_value = EGC_XOR_INV_MODE; + else + ROP_value = EGC_XOR_MODE; + break; + case VGA_COPY_MODE: + default: + ROP_value = EGC_COPY_MODE; + break; +} +outw(EGC_MODE, ROP_value); +outw(EGC_FGC, color & VGA_ALLPLANES); +/* Do Left Edge */ +if ( tmp = x0 & 0x0f ) { + dst = (unsigned char *)((int)(SCREENADDRESS(pWin,x0,y0)) & ~0x01); + tmp3 = (unsigned)0xffff >>tmp; + /* Catch The Cases Where The Entire Region Is Within One Word */ + if ( ( lx -= 16 - tmp ) < 0 ) { + tmp3 &= (unsigned)0xffff << -lx; + lx = 0 ; + } + tmp3 = (unsigned short)(tmp3 >> 8 | tmp3 << 8); + for ( tmp = ly; + tmp-- ; ) { + *((unsigned short *) dst ) = tmp3 ; + dst += BYTES_PER_LINE(pWin); + } + if ( !lx ) { /* All Handled In This Word */ + return ; + } + x0 = ( x0 + 0x0f ) & ~0x0f ; +} + +/* Fill The Center Of The Box */ +if (lx >> 4) { + WordfastFill( SCREENADDRESS( pWin, x0, y0 ), BYTES_PER_LINE(pWin), + (lx >> 4), ly ) ; +} + +/* Do Right Edge */ +if ( tmp = lx & 0x0f ) { /* x0 Now Is Word Aligned */ + /* Set The Bit Mask */ + tmp3 = (unsigned)0xffff << ( 16 - tmp ); + dst = (unsigned char*)((int)SCREENADDRESS(pWin,(x0+lx),y0) & ~0x01); + tmp3 = (unsigned short)(tmp3 >> 8 | tmp3 << 8); + for ( tmp = ly; + tmp-- ; ) { + *( (unsigned short *) dst ) = tmp3 ; + dst += BYTES_PER_LINE(pWin); + } +} + +return ; +} +#endif diff --git a/hw/xfree86/xf4bpp/vgaStipple.c b/hw/xfree86/xf4bpp/vgaStipple.c new file mode 100644 index 000000000..a4f3cef6b --- /dev/null +++ b/hw/xfree86/xf4bpp/vgaStipple.c @@ -0,0 +1,715 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/vgaStipple.c,v 1.5 2002/01/25 21:56:22 tsi Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ +/* $XConsortium: vgaStipple.c /main/5 1996/02/21 17:59:10 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "vgaReg.h" +#include "vgaVideo.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +#ifndef PC98_EGC +static unsigned char +getbits +( + register const int x, + register const unsigned int patternWidth, + register const unsigned char * const lineptr +) +{ +register unsigned char bits ; +register const unsigned char *cptr ; +register int shift ; +register int wrap ; + +cptr = lineptr + ( x >> 3 ) ; +bits = *cptr ; +if ((shift = x & 7)) + bits = SCRLEFT8( bits, shift ) | SCRRIGHT8( cptr[1], ( 8 - shift ) ) ; +if ( ( wrap = x + 8 - patternWidth ) > 0 ) { + bits &= SCRLEFT8( 0xFF, wrap ) ; + bits |= SCRRIGHT8( *lineptr, ( 8 - wrap ) ) ; +} + +/* GJA -- Handle extraction of 8 bits from < 8 bits wide stipple. + * I duplicated case 4,5,6,7 to give the compiler a chance to optimize. + */ +switch (patternWidth) { +case 1: /* Not really useful. */ + bits &= ~SCRRIGHT8(0xFF,1); + bits |= SCRRIGHT8(bits,1); + bits |= SCRRIGHT8(bits,2); + bits |= SCRRIGHT8(bits,4); + break; +case 2: + bits &= ~SCRRIGHT8(0xFF,2); + bits |= SCRRIGHT8(bits,2); bits |= SCRRIGHT8(bits,4); break; +case 3: + bits &= ~SCRRIGHT8(0xFF,3); + bits |= (SCRRIGHT8(bits,3) | SCRRIGHT8(bits,6)); break; +case 4: + bits = (bits & ~SCRRIGHT8(0xFF,4)) | SCRRIGHT8(bits,4); break; +case 5: + bits = (bits & ~SCRRIGHT8(0xFF,5)) | SCRRIGHT8(bits,5); break; +case 6: + bits = (bits & ~SCRRIGHT8(0xFF,6)) | SCRRIGHT8(bits,6); break; +case 7: + bits = (bits & ~SCRRIGHT8(0xFF,7)) | SCRRIGHT8(bits,7); break; +default: + ; + /* Do nothing, of course */ +} +return bits ; +} +#endif + +/* GJA -- + * Basically, in the code below, we will draw a stipple in the usual + * three parts: left edge, center and right edge. + * For efficiency reasons, the center will be drawn byte aligned, so that + * we will have to shuffle the bits in the left and right edges. + * The hard cases will be stipples with width < 8: In order to get 8 + * bits from those, we will need a loop. One single 'if' will never do. + * This is taken care of above. + */ +static void +DoMonoSingle +( + WindowPtr pWin, /* GJA */ + int w, + int x, + int y, + register const unsigned char *mastersrc, + int h, + register unsigned int width, + register unsigned int paddedByteWidth, + unsigned int height, + int xshift, + int yshift +) +{ +IOADDRESS REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; +register volatile unsigned char *xDst ; +register VideoAdapterObject tmp2 ; +register int NeedValX ; +register int counter ; +register int tmp1 ; +unsigned int rowCounter ; +int byte_cnt ; +#ifdef PC98_EGC +unsigned char bitmask; +#endif + +/* Do Left Edge */ +if ((tmp1 = x & 07)) { + tmp2 = SCRRIGHT8( ( (unsigned) 0xFF ), tmp1 ) ; + /* Catch The Cases Where The Entire Region Is Within One Byte */ + if ( ( w -= 8 - tmp1 ) < 0 ) { + tmp2 &= SCRLEFT8( (unsigned) 0xFF, -w ) ; + w = 0 ; + } +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, tmp2 ) ; /* Set The Bit Mask */ +#else + bitmask = tmp2; /* Set The Bit Mask */ +#endif + /* + * For Each Line In The Source Pixmap + */ + xDst = SCREENADDRESS( pWin, x, y ); + for ( tmp1 = yshift, rowCounter = h; + rowCounter ; + rowCounter-- , tmp1++ ) { + + if ( tmp1 >= (int)height ) + tmp1 -= height ; +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst) ; +#endif + /* Write Pattern */ + *( (VgaMemoryPtr) xDst ) = +#ifndef PC98_EGC + getbits( xshift /* GJA */, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) >> (x & 07) ; +#else +#if 0 + (getbits( xshift /* GJA */, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) >> (x & 07) + & bitmask); +#else + (getbits_x( xshift /* GJA */, width, + mastersrc + + ( tmp1 * paddedByteWidth ), (x & 07)) + & bitmask); +#endif +#endif + xDst += BYTES_PER_LINE(pWin); + } + NeedValX = (xshift + 8 - (x & 07)) % width; + x = ( x + 7 ) & ~07 ; +} +else { + NeedValX = xshift ; +} + +if ((byte_cnt = ROW_OFFSET(w))) { /* Fill The Center Of The Box */ + int SavNeedX = NeedValX ; + +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* Set The Bit Mask */ +#endif + /* + * For Each Line In The Source Pixmap + */ + xDst = SCREENADDRESS( pWin, x, y ); + for ( tmp1 = yshift, rowCounter = h; + rowCounter ; + rowCounter-- , tmp1++ ) { + register const unsigned char *l_ptr ; + if ( tmp1 >= (int)height ) + tmp1 -= height ; + l_ptr = mastersrc + ( tmp1 * paddedByteWidth ) ; + /* + * For Each Byte Across The Pattern In X + */ + for ( counter = byte_cnt, NeedValX = SavNeedX ; + counter-- ; ) { +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst) ; +#endif + /* Write Pattern */ + *( (VgaMemoryPtr) xDst ) = +#ifndef PC98_EGC + getbits( NeedValX, width, l_ptr ) ; +#else +#if 0 + getbits( NeedValX, width, l_ptr ) ; +#else + getbits_x ( NeedValX, width, l_ptr, 0 ) ; +#endif +#endif + /* GJA -- The '%' is there since width could be < 8 */ + NeedValX = (NeedValX + 8) % width; + xDst++; + } + xDst += BYTES_PER_LINE(pWin) - byte_cnt; + } +} + +/* Do Right Edge */ +if ((tmp1 = BIT_OFFSET(w))) { /* x Now Is Byte Aligned */ + /* Set The Bit Mask */ +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, SCRLEFT8( 0xFF, ( 8 - tmp1 ) ) ) ; +#else + bitmask = SCRLEFT8( 0xFF, ( 8 - tmp1 )); +#endif + /* + * For Each Line In The Source Pixmap + */ + xDst = SCREENADDRESS( pWin, ( x + w ), y ); + for ( tmp1 = yshift, rowCounter = h; + rowCounter ; + rowCounter-- , tmp1++ ) { + if ( tmp1 >= (int)height ) + tmp1 -= height ; +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst) ; +#endif + /* Write Pattern */ + *( (VgaMemoryPtr) xDst ) = +#ifndef PC98_EGC + getbits( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else +#if 0 + (getbits( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) & bitmask); +#else + (getbits_x( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ), 0 ) & bitmask); +#endif +#endif + xDst += BYTES_PER_LINE(pWin) ; + } +} + +return ; +} + +static void +DoMonoMany +( + WindowPtr pWin, /* GJA */ + int w, + int x, + int y, + register const unsigned char *mastersrc, + int h, + register unsigned int width, + register unsigned int paddedByteWidth, + unsigned int height, + int xshift, + int yshift +) +{ +IOADDRESS REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; +register volatile unsigned char *xDst ; +register VideoAdapterObject tmp2 ; +register int NeedValX ; +register int byte_cnt ; +register int tmp1 ; +unsigned DestinationRow ; +unsigned int SourceRow ; +volatile unsigned char *dst ; +int scr_incr = ( height * BYTES_PER_LINE(pWin) ) ; +#ifdef PC98_EGC +unsigned char bitmask; +#endif + +/* Do Left Edge */ +if ((tmp1 = x & 07)) { + tmp2 = SCRRIGHT8( ( (unsigned) 0xFF ), tmp1 ) ; + /* Catch The Cases Where The Entire Region Is Within One Byte */ + if ( ( w -= 8 - tmp1 ) < 0 ) { + tmp2 &= SCRLEFT8( (unsigned) 0xFF, -w ) ; + w = 0 ; + } +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, tmp2 ) ; /* Set The Bit Mask */ +#else + bitmask = tmp2; /* Set The Bit Mask */ +#endif + /* + * For Each Line In The Source Pixmap + */ + for ( tmp1 = yshift, SourceRow = 0, dst = SCREENADDRESS( pWin, x, y ) ; + SourceRow < height ; + tmp1++, SourceRow++, dst += BYTES_PER_LINE(pWin) ) { + register unsigned bitPattern ; + + if ( tmp1 >= (int)height ) + tmp1 -= height ; + /* + * For Each Time Pattern Repeats In The Y Dimension + */ + xDst = dst; + for ( DestinationRow = SourceRow, +#ifndef PC98_EGC + bitPattern = getbits( xshift, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else +#if 0 + bitPattern = getbits( xshift, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else + bitPattern = getbits_x( xshift, width, + mastersrc + + ( tmp1 * paddedByteWidth ), 0 ) ; +#endif +#endif + (int)DestinationRow < h ; + DestinationRow += height ) { +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst ) ; +#endif + /* Write Pattern */ +#ifndef PC98_EGC + *( (VgaMemoryPtr) xDst ) = bitPattern >> (x & 07); +#else + *( (VgaMemoryPtr) xDst ) = (bitPattern >> (x & 07)) & bitmask; +#endif + xDst += scr_incr; + } + } + NeedValX = (xshift + 8 - (x & 07)) % width; + x = ( x + 7 ) & ~07 ; +} +else { + NeedValX = xshift ; +} + +if ((byte_cnt = ROW_OFFSET(w))) { /* Fill The Center Of The Box */ + int SavNeedX = NeedValX ; + +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* Set The Bit Mask */ +#endif + /* + * For Each Line In The Source Pixmap + */ + for ( tmp1 = yshift, SourceRow = 0, dst = SCREENADDRESS( pWin, x, y ) ; + SourceRow < height ; + tmp1++, SourceRow++, dst += BYTES_PER_LINE(pWin) - byte_cnt ) { + register const unsigned char *l_ptr ; + if ( tmp1 >= (int)height ) + tmp1 -= height ; + l_ptr = mastersrc + ( tmp1 * paddedByteWidth ) ; + /* + * For Each Byte Across The Pattern In X + */ + for ( tmp2 = byte_cnt, NeedValX = SavNeedX ; + tmp2-- ; + dst++ ) { + register unsigned bitPattern ; + register VideoAdapterObject tmp3 ; + /* + * For Each Time Pattern Repeats In Y + */ + xDst = dst; + for ( DestinationRow = SourceRow, +#ifndef PC98_EGC + bitPattern = getbits( NeedValX, width, l_ptr ) ; +#else +#if 0 + bitPattern = getbits( NeedValX, width, l_ptr ) ; +#else + bitPattern = getbits_x( NeedValX, width, l_ptr, 0 ) ; +#endif +#endif + (int)DestinationRow < h ; + DestinationRow += height ) { +#ifndef PC98_EGC + /* Read To Save */ + tmp3 = *( (VgaMemoryPtr) xDst) ; +#endif + /* Write Pattern */ + *( (VgaMemoryPtr) xDst ) = bitPattern ; + xDst += scr_incr; + } + NeedValX = (NeedValX + 8) % width; + } + } +} + +/* Do Right Edge */ +if ((tmp1 = BIT_OFFSET(w))) { /* x Now Is Byte Aligned */ + /* Set The Bit Mask */ +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, SCRLEFT8( 0xFF, ( 8 - tmp1 ) ) ) ; +#else + bitmask = SCRLEFT8( 0xFF, ( 8 - tmp1 ) ); +#endif + /* + * For Each Line In The Source Pixmap + */ + for ( tmp1 = yshift, SourceRow = 0, + dst = SCREENADDRESS( pWin, ( x + w ), y ) ; + SourceRow < height ; + tmp1++, SourceRow++, dst += BYTES_PER_LINE(pWin) ) { + register unsigned bitPattern ; + if ( tmp1 >= (int)height ) + tmp1 -= height ; + /* + * For Each Time Pattern Repeats In The Y Dimension + */ + xDst = dst; + for ( DestinationRow = SourceRow, +#ifndef PC98_EGC + bitPattern = getbits( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else +#if 0 + bitPattern = getbits( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else + bitPattern = getbits_x( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ), 0 ) ; +#endif +#endif + (int)DestinationRow < h ; + DestinationRow += height ) { +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst) ; +#endif + /* Write Pattern */ +#ifndef PC98_EGC + *( (VgaMemoryPtr) xDst ) = bitPattern ; +#else + *( (VgaMemoryPtr) xDst ) = bitPattern & bitmask; +#endif + xDst += scr_incr; + } + } +} + +return ; +} + +#define DO_RECURSE 0x10000 + +static void +vgaSetMonoRegisters +( + DrawablePtr pDrawable, + register unsigned long int plane_mask, + register unsigned long int desiredState +) +{ +IOADDRESS REGBASE = + xf86Screens[pDrawable->pScreen->myNum]->domainIOBase + 0x300; +#ifndef PC98_EGC +/* Setup VGA Registers */ +/* + * Set The Plane-Enable + */ +SetVideoSequencer( Mask_MapIndex, plane_mask ) ; +SetVideoGraphics( Enb_Set_ResetIndex, plane_mask ) ; +/* + * Put Display Into SET-AND (i.e. Write Mode 3 ) + */ +SetVideoGraphics( Graphics_ModeIndex, VGA_WRITE_MODE_3 ) ; +/* + * Set The Color in The Set/Reset Register + */ +SetVideoGraphics( Set_ResetIndex, desiredState & VGA_ALLPLANES ) ; +/* + * Set The Vga's Alu Function + */ +SetVideoGraphics( Data_RotateIndex, desiredState >> 8 ) ; +#else /* PC98_EGC */ +unsigned short ROP_value; +/* Setup VGA Registers */ +/* + * Set The Plane-Enable + */ +outw(EGC_PLANE, ~plane_mask); +switch((desiredState >> 8)&0x18) { +/* EGC MODE.. Cmp Read: Flase, WriteSource=ROP, ReadSource=CPU */ + case VGA_AND_MODE: + if (desiredState & DO_RECURSE) + ROP_value = EGC_AND_INV_MODE; + else + ROP_value = EGC_AND_MODE; + break; + case VGA_OR_MODE: + if (desiredState & DO_RECURSE) + ROP_value = EGC_OR_INV_MODE; + else + ROP_value = EGC_OR_MODE; + break; + case VGA_XOR_MODE: + if (desiredState & DO_RECURSE) + ROP_value = EGC_XOR_INV_MODE; + else + ROP_value = EGC_XOR_MODE; + break; + case VGA_COPY_MODE: + default: + ROP_value = EGC_COPY_MODE; + break; +} +outw(EGC_MODE, ROP_value); +outw(EGC_FGC, desiredState & VGA_ALLPLANES); +#endif + +return ; +} + +static unsigned long +vgaCalcMonoMode +( + int rasterOp, + register unsigned long int color +) +{ +register unsigned int data_rotate_value = VGA_COPY_MODE << 8 ; +register unsigned int invert_existing_data = 0 ; + +/* Test The Raster-Op */ +switch ( rasterOp ) { + case GXclear: /* 0x0 Zero 0 */ + color = 0 ; + break ; + case GXinvert: /* 0xa NOT dst */ + data_rotate_value = VGA_XOR_MODE << 8 ; + case GXset: /* 0xf 1 */ + color = VGA_ALLPLANES ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + invert_existing_data = DO_RECURSE ; + case GXandInverted: /* 0x4 NOT src AND dst */ + color = ~color ; + case GXand: /* 0x1 src AND dst */ + data_rotate_value = VGA_AND_MODE << 8 ; + case GXcopy: /* 0x3 src */ + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + color = ~color ; + case GXxor: /* 0x6 src XOR dst */ + data_rotate_value = VGA_XOR_MODE << 8 ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + invert_existing_data = DO_RECURSE ; + data_rotate_value = VGA_AND_MODE << 8 ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + invert_existing_data = DO_RECURSE ; + data_rotate_value = VGA_OR_MODE << 8 ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + invert_existing_data = DO_RECURSE ; + case GXorInverted: /* 0xd NOT src OR dst */ + color = ~color ; + case GXor: /* 0x7 src OR dst */ + data_rotate_value = VGA_OR_MODE << 8 ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + color = ~color ; + break ; + case GXnoop: /* 0x5 dst */ + ; /* Shouldn't Get Here !! */ +} + +return ( color & VGA_ALLPLANES ) | data_rotate_value | invert_existing_data ; +} + +static void +vgaDrawMonoImage +( + WindowPtr pWin, /* GJA */ + unsigned char *data, + int x, + int y, + int w, + int h, + unsigned long int fg, + int alu, + unsigned long int planes +) +{ +unsigned long regState ; + +if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffDrawMonoImage( pWin, data, x, y, w, h, fg, alu, planes ); + return; +} + +if ( ( alu == GXnoop ) || !( planes &= VGA_ALLPLANES ) ) + return ; + +#ifndef PC98_EGC +if ( ( regState = vgaCalcMonoMode( alu, fg ) ) & DO_RECURSE ) { + vgaDrawMonoImage( pWin, data, x, y, w, h, + VGA_ALLPLANES, GXinvert, planes ) ; + regState &= ~DO_RECURSE ; +} +#else +regState = vgaCalcMonoMode(alu, (char)fg); +#endif + + +vgaSetMonoRegisters( (DrawablePtr)pWin, planes, regState ) ; + +DoMonoSingle( pWin, w, x, y, (const unsigned char *) data, h, + w, ( ( w + 31 ) & ~31 ) >> 3, h, 0, 0 ) ; + + +return ; +} + +void +xf4bppFillStipple( pWin, pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc ) +WindowPtr pWin; /* GJA */ +register PixmapPtr const pStipple ; +unsigned long int fg ; +const int alu ; +unsigned long int planes ; +int x, y, w, h ; +const int xSrc, ySrc ; +{ +unsigned int width ; +unsigned int height ; +int xshift ; +int yshift ; +unsigned long regState ; + +if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffFillStipple( pWin, pStipple, fg, alu, planes, + x, y, w, h, xSrc, ySrc ); + return; +} + +if ( ( alu == GXnoop ) || !( planes &= VGA_ALLPLANES ) ) + return ; + +#if 1 +if ( ( regState = vgaCalcMonoMode( alu, fg ) ) & DO_RECURSE ) { + xf4bppFillStipple( pWin, pStipple, VGA_ALLPLANES, GXinvert, planes, + x, y, w, h, xSrc, ySrc ) ; + regState &= ~DO_RECURSE ; +} +#else +regState = vgaCalcMonoMode(alu, (char)fg); +#endif + + +vgaSetMonoRegisters( (DrawablePtr)pWin, planes, regState ) ; + +/* Figure Bit Offsets & Source Address */ +width = pStipple->drawable.width ; +if ( ( xshift = ( x - xSrc ) ) < 0 ) + xshift = width - ( ( - xshift ) % width ) ; +else + xshift %= width ; +if ( xshift == (int)width ) xshift = 0; + +height = pStipple->drawable.height ; +if ( ( yshift = ( y - ySrc ) ) < 0 ) + yshift = height - ( ( - yshift ) % height ) ; +else + yshift %= height ; +if ( yshift == (int)height ) yshift = 0; + + (* ( (h > (int)height) ? DoMonoMany : DoMonoSingle ) ) ( + pWin, w, x, y, + (const unsigned char *) pStipple->devPrivate.ptr, + h, + width, + ( ( width + 31 ) & ((unsigned)(~31)) ) >> 3, + height, + xshift, yshift + ) ; + +return ; +} diff --git a/hw/xfree86/xf4bpp/vgaVideo.h b/hw/xfree86/xf4bpp/vgaVideo.h new file mode 100644 index 000000000..ecc2fa738 --- /dev/null +++ b/hw/xfree86/xf4bpp/vgaVideo.h @@ -0,0 +1,92 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/vgaVideo.h,v 1.2 1998/07/25 16:59:45 dawes Exp $ */ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * 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 IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* $XConsortium: vgaVideo.h /main/4 1996/02/21 17:59:14 kaleb $ */ + +#include "misc.h" /* GJA -- for pointer data type */ +#ifdef lint +#if defined(volatile) +#undef volatile +#endif +#define volatile /**/ +#if defined(const) +#undef const +#endif +#define const /**/ +#if defined(signed) +#undef signed +#endif +#define signed /**/ +#endif + +/* + * References to all pc ( i.e. '286 ) memory in the + * regions used by the [ev]ga server ( the 128K windows ) + * MUST be long-word ( i.e. 32-bit ) reads or writes. + * This definition will change for other memory architectures + * ( e.g. AIX-Rt ) + */ +typedef unsigned char VideoAdapterObject ; +typedef volatile VideoAdapterObject *VideoMemoryPtr ; +typedef volatile VideoAdapterObject *VgaMemoryPtr ; +#if !defined(BITMAP_BIT_ORDER) +#define BITMAP_BIT_ORDER MSBFirst +#endif + +#if !defined(IMAGE_BYTE_ORDER) +#define IMAGE_BYTE_ORDER LSBFirst +#endif + +/* Bit Ordering Macros */ +#if !defined(SCRLEFT8) +#define SCRLEFT8(lw, n) ( (unsigned char) (((unsigned char) lw) << (n)) ) +#endif +#if !defined(SCRRIGHT8) +#define SCRRIGHT8(lw, n) ( (unsigned char) (((unsigned char)lw) >> (n)) ) +#endif +/* These work ONLY on 8-bit wide Quantities !! */ +#define LeftmostBit ( SCRLEFT8( 0xFF, 7 ) & 0xFF ) +#define RightmostBit ( SCRRIGHT8( 0xFF, 7 ) & 0xFF ) + +/* + * [ev]ga video screen defines & macros + */ +#define VGA_BLACK_PIXEL 0 +#define VGA_WHITE_PIXEL 1 + +#define VGA_MAXPLANES 4 +#define VGA_ALLPLANES 0xFL + +#define VIDBASE(pDraw) ((volatile unsigned char *) \ + (((PixmapPtr)(((DrawablePtr)(pDraw))->pScreen->devPrivate))-> \ + devPrivate.ptr)) +#define BYTES_PER_LINE(pDraw) \ + ((int)((PixmapPtr)(((DrawablePtr)(pDraw))->pScreen->devPrivate))->devKind) + +#define ROW_OFFSET( x ) ( ( x ) >> 3 ) +#define BIT_OFFSET( x ) ( ( x ) & 0x7 ) +#define SCREENADDRESS( pWin, x, y ) \ + ( VIDBASE(pWin) + (y) * BYTES_PER_LINE(pWin) + ROW_OFFSET(x) ) + + diff --git a/hw/xfree86/xf4bpp/vgamodule.c b/hw/xfree86/xf4bpp/vgamodule.c new file mode 100644 index 000000000..c7cf1b7d3 --- /dev/null +++ b/hw/xfree86/xf4bpp/vgamodule.c @@ -0,0 +1,57 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/vgamodule.c,v 1.8 1999/01/26 05:54:20 dawes Exp $ */ +/* + * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef XFree86LOADER +#include "xf86Module.h" + +static MODULESETUPPROTO(xf4bppSetup); + +static XF86ModuleVersionInfo VersRec = +{ + "xf4bpp", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +XF86ModuleData xf4bppModuleData = { &VersRec, xf4bppSetup, NULL }; + +static pointer +xf4bppSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + /* This module requires xf1bpp for bitmap support */ + return LoadSubModule(module, "xf1bpp", NULL, NULL, NULL, NULL, + errmaj, errmin); +} + +#endif diff --git a/hw/xfree86/xf4bpp/wm3.c b/hw/xfree86/xf4bpp/wm3.c new file mode 100644 index 000000000..3509ce77f --- /dev/null +++ b/hw/xfree86/xf4bpp/wm3.c @@ -0,0 +1,207 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/wm3.c,v 1.4 2002/01/25 21:56:23 tsi Exp $ */ + + + + + +/* $XConsortium: wm3.c /main/5 1996/02/21 17:59:21 kaleb $ */ + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "wm3.h" +#include "vgaVideo.h" +#include "xf86.h" + +/* Ferraro is wrong. GJA */ +#define COPY (0 << 3) +#define AND (1 << 3) +#define OR (2 << 3) +#define XOR (3 << 3) + +int +wm3_set_regs(pGC) +GC *pGC; +{ +#ifndef PC98_EGC + IOADDRESS REGBASE = xf86Screens[pGC->pScreen->myNum]->domainIOBase + 0x300; + int post_invert = 0; + int ALU; + + switch(pGC->alu) { + case GXclear: /* rop0 = RROP_BLACK; rop1 = RROP_BLACK; */ + pGC->fgPixel = 0; + pGC->bgPixel = 0; + ALU = COPY; + break; + case GXand: /* rop0 = RROP_BLACK; rop1 = RROP_NOP; */ + ALU = AND; + break; + case GXandReverse: /* rop0 = RROP_BLACK; rop1 = RROP_INVERT; -- TRICKY */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = OR; + post_invert = 1; + break; + case GXcopy: /* rop0 = RROP_BLACK; rop1 = RROP_WHITE; */ + ALU = COPY; + break; + case GXandInverted: /* rop0 = RROP_NOP; rop1 = RROP_BLACK; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = AND; + break; + default: + case GXnoop: /* rop0 = RROP_NOP; rop1 = RROP_NOP; */ + return 0; + case GXxor: /* rop0 = RROP_NOP; rop1 = RROP_INVERT; */ + ALU = XOR; + break; + case GXor: /* rop0 = RROP_NOP; rop1 = RROP_WHITE; */ + ALU = OR; + break; + case GXnor: /* rop0 = RROP_INVERT; rop1 = RROP_BLACK; -- TRICKY*/ + ALU = OR; + post_invert = 1; + break; + case GXequiv: /* rop0 = RROP_INVERT; rop1 = RROP_NOP; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = XOR; + break; + case GXinvert: /* rop0 = RROP_INVERT; rop1 = RROP_INVERT; */ + pGC->fgPixel = 0x0F; + pGC->bgPixel = 0x0F; + ALU = XOR; + break; + case GXorReverse: /* rop0 = RROP_INVERT; rop1 = RROP_WHITE; -- TRICKY */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = AND; + post_invert = 1; + break; + case GXcopyInverted: /* rop0 = RROP_WHITE; rop1 = RROP_BLACK; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = COPY; + break; + case GXorInverted: /* rop0 = RROP_WHITE; rop1 = RROP_NOP; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = OR; + break; + case GXnand: /* rop0 = RROP_WHITE; rop1 = RROP_INVERT; -- TRICKY */ + ALU = AND; + post_invert = 1; + break; + case GXset: /* rop0 = RROP_WHITE; rop1 = RROP_WHITE; */ + pGC->fgPixel = 0x0F; + pGC->bgPixel = 0x0F; + ALU = COPY; + break; + } + + + SetVideoSequencer(Mask_MapIndex, (pGC->planemask & VGA_ALLPLANES)); + SetVideoGraphics(Enb_Set_ResetIndex, VGA_ALLPLANES); + SetVideoGraphics(Set_ResetIndex, pGC->fgPixel); + SetVideoGraphics(Bit_MaskIndex, 0xFF); + SetVideoGraphics(Graphics_ModeIndex, 3); /* Write Mode 3 */ + SetVideoGraphics(Data_RotateIndex, ALU); + + return post_invert; +#else + int ALU; + + switch(pGC->alu) { + case GXclear: /* rop0 = RROP_BLACK; rop1 = RROP_BLACK; */ + pGC->fgPixel = 0; + pGC->bgPixel = 0; + ALU = EGC_COPY_MODE; + break; + case GXand: /* rop0 = RROP_BLACK; rop1 = RROP_NOP; */ + ALU = EGC_AND_MODE; + break; + case GXandReverse: /* rop0 = RROP_BLACK; rop1 = RROP_INVERT; -- TRICKY */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_OR_INV_MODE; + break; + case GXcopy: /* rop0 = RROP_BLACK; rop1 = RROP_WHITE; */ + ALU = EGC_COPY_MODE; + break; + case GXandInverted: /* rop0 = RROP_NOP; rop1 = RROP_BLACK; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_AND_MODE; + break; + case GXnoop: /* rop0 = RROP_NOP; rop1 = RROP_NOP; */ + return 0; + case GXxor: /* rop0 = RROP_NOP; rop1 = RROP_INVERT; */ + ALU = EGC_XOR_MODE; + break; + case GXor: /* rop0 = RROP_NOP; rop1 = RROP_WHITE; */ + ALU = EGC_OR_MODE; + break; + case GXnor: /* rop0 = RROP_INVERT; rop1 = RROP_BLACK; -- TRICKY*/ + ALU = EGC_OR_INV_MODE; + break; + case GXequiv: /* rop0 = RROP_INVERT; rop1 = RROP_NOP; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_XOR_MODE; + break; + case GXinvert: /* rop0 = RROP_INVERT; rop1 = RROP_INVERT; */ + pGC->fgPixel = 0x0F; + pGC->bgPixel = 0x0F; + ALU = EGC_XOR_MODE; + break; + case GXorReverse: /* rop0 = RROP_INVERT; rop1 = RROP_WHITE; -- TRICKY */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_AND_INV_MODE; + break; + case GXcopyInverted: /* rop0 = RROP_WHITE; rop1 = RROP_BLACK; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_COPY_MODE; + break; + case GXorInverted: /* rop0 = RROP_WHITE; rop1 = RROP_NOP; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_OR_MODE; + break; + case GXnand: /* rop0 = RROP_WHITE; rop1 = RROP_INVERT; -- TRICKY */ + ALU = EGC_OR_INV_MODE; + break; + case GXset: /* rop0 = RROP_WHITE; rop1 = RROP_WHITE; */ + pGC->fgPixel = 0x0F; + pGC->bgPixel = 0x0F; + ALU = EGC_COPY_MODE; + break; + } + + outw(EGC_PLANE, ~(pGC->planemask & VGA_ALLPLANES)); + outw(EGC_MODE, ALU); + outw(EGC_FGC, pGC->fgPixel & VGA_ALLPLANES); /* set FGC */ + + return 0; +#endif +} + +/* + Now we will have to set the alu. + Problematic is: How do we handle IsDoubleDash, which draws with both fg + and bg colour? + The answer is: We take care to store the ink colour in one register only. + Then we need set only this register to change the ink. + */ + +/* -- MORE NOTES: + We might try to 'wrap' the mfb functions in a 16-colour wrapper that does + all operations once. However, this does not work: + Some operations (esp) CopyArea may for example cause expositions. + Such expositions will cause data to be copied in from backing store, + and this copying in may damage the contents of the VGA registers. + So we must take care to set the VGA registers at each place where they could + be modified. + */ diff --git a/hw/xfree86/xf4bpp/wm3.h b/hw/xfree86/xf4bpp/wm3.h new file mode 100644 index 000000000..5fd303d7d --- /dev/null +++ b/hw/xfree86/xf4bpp/wm3.h @@ -0,0 +1,77 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/wm3.h,v 1.3 2000/09/26 15:57:21 tsi Exp $ */ + + + + + +/* $XConsortium: wm3.h /main/4 1996/02/21 17:59:24 kaleb $ */ + +#include "vgaReg.h" + +#ifdef PC98_EGC +#define VGA_ALLPLANES 0xFL +#endif + +/* Do call in Write Mode 3. + * We take care of the possibility that two passes are needed. + */ +#ifndef PC98_EGC +#define DO_WM3(pgc,call) \ + { int _tp, _fg, _bg, _alu; \ + _fg = pgc->fgPixel; _bg = pgc->bgPixel; \ + _tp = wm3_set_regs(pgc); \ + (call); \ + if ( _tp ) { \ + _alu = pgc->alu; \ + pgc->alu = GXinvert; \ + _tp = wm3_set_regs(pgc); \ + (call); \ + pgc->alu = _alu; \ + } \ + pgc->fgPixel = _fg; pgc->bgPixel = _bg; \ + } +#else +#define DO_WM3(pgc,call) \ + { int _tp, _fg, _bg; \ + _fg = pgc->fgPixel; _bg = pgc->bgPixel; \ + _tp = wm3_set_regs(pgc); \ + (call); \ + pgc->fgPixel = _fg; pgc->bgPixel = _bg; \ + } +#endif + +#ifndef PC98_EGC +#define WM3_SET_INK(ink) \ + SetVideoGraphics(Set_ResetIndex, ink) +#else +#define WM3_SET_INK(ink) \ + outw(EGC_FGC, ink) +#endif + +/* GJA -- Move a long word to screen memory. + * The reads into 'dummy' are here to load the VGA latches. + * This is a RMW operation except for trivial cases. + * Notice that we ignore the operation. + */ +#ifdef PC98_EGC +#define UPDRW(destp,src) \ + { volatile unsigned short *_dtmp = \ + (volatile unsigned short *)(destp); \ + unsigned int _stmp = (src); \ + *_dtmp = _stmp; _dtmp++; _stmp >>= 16; \ + *_dtmp = _stmp; } +#else +#define UPDRW(destp,src) \ + { volatile char *_dtmp = (volatile char *)(destp); \ + unsigned int _stmp = (src); \ + volatile int dummy; /* Bit bucket. */ \ + _stmp = ldl_u(&_stmp); \ + dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \ + dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \ + dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \ + dummy = *_dtmp; *_dtmp = _stmp; } +#endif + +#define UPDRWB(destp,src) \ + { volatile int dummy; /* Bit bucket. */ \ + dummy = *(destp); *(destp) = (src); } diff --git a/hw/xfree86/xf4bpp/xf4bpp.h b/hw/xfree86/xf4bpp/xf4bpp.h new file mode 100644 index 000000000..f9141e5e1 --- /dev/null +++ b/hw/xfree86/xf4bpp/xf4bpp.h @@ -0,0 +1,804 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/xf4bpp.h,v 1.8 2003/02/18 21:29:59 tsi Exp $ */ + + +#ifndef __XF4BPP_H__ +#define __XF4BPP_H__ + + +#include "windowstr.h" +#include "gcstruct.h" +#include "colormapst.h" +#include "fontstruct.h" +#ifndef PixelType +#define PixelType CARD32 +#endif + +/* ppcArea.c */ +void xf4bppFillArea( +#if NeedFunctionPrototypes + WindowPtr, + int, + BoxPtr, + GCPtr +#endif +); + +/* ppcBStore.c */ +void xf4bppSaveAreas( +#if NeedFunctionPrototypes + PixmapPtr, + RegionPtr, + int, + int, + WindowPtr +#endif +); +void xf4bppRestoreAreas( +#if NeedFunctionPrototypes + PixmapPtr, + RegionPtr, + int, + int, + WindowPtr +#endif +); + +/* ppcClip.c */ +void xf4bppDestroyClip( +#if NeedFunctionPrototypes + GCPtr +#endif +); +void xf4bppChangeClip( +#if NeedFunctionPrototypes + GCPtr, + int, + pointer, + int +#endif +); +void xf4bppCopyClip( +#if NeedFunctionPrototypes + GCPtr, + GCPtr +#endif +); + +/* ppcCpArea.c */ +RegionPtr xf4bppCopyArea( +#if NeedFunctionPrototypes + DrawablePtr, + DrawablePtr, + GCPtr, + int, + int, + int, + int, + int, + int +#endif +); + +/* ppcDepth.c */ +Bool xf4bppDepthOK( +#if NeedFunctionPrototypes + DrawablePtr, + int +#endif +); + +/* ppcFillRct.c */ +void xf4bppPolyFillRect( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + xRectangle * +#endif +); + +/* ppcWindowFS.c */ +void xf4bppSolidWindowFS( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +#endif +); +void xf4bppStippleWindowFS( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +#endif +); +void xf4bppOpStippleWindowFS( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +#endif +); +void xf4bppTileWindowFS( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +#endif +); + +/* xf4bppPixmapFS.c */ +void xf4bppSolidPixmapFS( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +#endif +); +void xf4bppStipplePixmapFS( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +#endif +); +void xf4bppOpStipplePixmapFS( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +#endif +); +void xf4bppTilePixmapFS( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +#endif +); + +/* ppcGC.c */ +Bool xf4bppCreateGC( +#if NeedFunctionPrototypes + GCPtr +#endif +); +void xf4bppDestroyGC( +#if NeedFunctionPrototypes + GC * +#endif +); +void xf4bppValidateGC( +#if NeedFunctionPrototypes + GCPtr, + unsigned long, + DrawablePtr +#endif +); + +/* ppcGetSp.c */ +void xf4bppGetSpans( +#if NeedFunctionPrototypes + DrawablePtr, + int, + DDXPointPtr, + int *, + int, + char * +#endif +); + +/* ppcImg.c */ +void xf4bppGetImage( +#if NeedFunctionPrototypes + DrawablePtr, + int, + int, + int, + int, + unsigned int, + unsigned long, + char * +#endif +); + +/* ppcLine.c */ +void xf4bppScrnZeroLine( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + int, + DDXPointPtr +#endif +); +void xf4bppScrnZeroDash( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + int, + DDXPointPtr +#endif +); +void xf4bppScrnZeroSegs( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + xSegment * +#endif +); + +/* ppcPixmap.c */ +PixmapPtr xf4bppCreatePixmap( +#if NeedFunctionPrototypes + ScreenPtr, + int, + int, + int +#endif +); +PixmapPtr xf4bppCopyPixmap( +#if NeedFunctionPrototypes + PixmapPtr +#endif +); + +/* ppcPntWin.c */ +void xf4bppPaintWindow( +#if NeedFunctionPrototypes + WindowPtr, + RegionPtr, + int +#endif +); + +/* ppcPolyPnt.c */ +void xf4bppPolyPoint( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + int, + xPoint * +#endif +); + +/* ppcPolyRec.c */ +void xf4bppPolyRectangle( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + xRectangle * +#endif +); + +/* ppcQuery.c */ +void xf4bppQueryBestSize( +#if NeedFunctionPrototypes + int, + unsigned short *, + unsigned short *, + ScreenPtr +#endif +); + +/* ppcRslvC.c */ +void xf4bppResolveColor( +#if NeedFunctionPrototypes + unsigned short *, + unsigned short *, + unsigned short *, + VisualPtr +#endif +); +Bool xf4bppInitializeColormap( +#if NeedFunctionPrototypes + ColormapPtr +#endif +); + +/* ppcSetSp.c */ +void xf4bppSetSpans( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + char *, + DDXPointPtr, + int *, + int, + int +#endif +); + +/* ppcWindow.c */ +void xf4bppCopyWindow( +#if NeedFunctionPrototypes + WindowPtr, + DDXPointRec, + RegionPtr +#endif +); +Bool xf4bppPositionWindow( +#if NeedFunctionPrototypes + WindowPtr, + int, + int +#endif +); +Bool xf4bppUnrealizeWindow( +#if NeedFunctionPrototypes + WindowPtr, + int, + int +#endif +); +Bool xf4bppDestroyWindow( +#if NeedFunctionPrototypes + WindowPtr +#endif +); +Bool xf4bppCreateWindowForXYhardware( +#if NeedFunctionPrototypes + WindowPtr +#endif +); + +/* emulOpStip.c */ +void xf4bppOpaqueStipple( +#if NeedFunctionPrototypes + WindowPtr, + PixmapPtr, + unsigned long int, + unsigned long int, + int, + unsigned long int, + int, + int, + int, + int, + int, + int +#endif +); + +/* emulRepAre.c */ +void xf4bppReplicateArea( +#if NeedFunctionPrototypes + WindowPtr, + int, + int, + int, + int, + int, + int, + int +#endif +); + +/* emulTile.c */ +void xf4bppTileRect( +#if NeedFunctionPrototypes + WindowPtr, + PixmapPtr, + const int, + const unsigned long int, + int, + int, + int, + int, + int, + int +#endif +); + +/* vgaGC.c */ +Mask xf4bppChangeWindowGC( +#if NeedFunctionPrototypes + GCPtr, + Mask +#endif +); + +/* vgaBitBlt.c */ +void xf4bppBitBlt( +#if NeedFunctionPrototypes + WindowPtr, + int, + int, + int, + int, + int, + int, + int, + int +#endif +); + +/* vgaImages.c */ +void xf4bppDrawColorImage( +#if NeedFunctionPrototypes + WindowPtr, + int, + int, + int, + int, + unsigned char *, + int, + const int, + const unsigned long int +#endif +); +void xf4bppReadColorImage( +#if NeedFunctionPrototypes + WindowPtr, + int, + int, + int, + int, + unsigned char *, + int +#endif +); + +/* vgaLine.c */ +void xf4bppHorzLine( +#if NeedFunctionPrototypes + WindowPtr, + unsigned long int, + int, + unsigned long int, + int, + int, + int +#endif +); +void xf4bppVertLine( +#if NeedFunctionPrototypes + WindowPtr, + unsigned long int, + int, + unsigned long int, + int, + int, + int +#endif +); +void xf4bppBresLine( +#if NeedFunctionPrototypes + WindowPtr, + unsigned long int, + int, + unsigned long int, + int, + int, + int, + int, + int, + int, + int, + int, + unsigned long int +#endif +); + +/* vgaStipple.c */ +void xf4bppFillStipple( +#if NeedFunctionPrototypes + WindowPtr, + const PixmapPtr, + unsigned long int, + const int, + unsigned long int, + int, + int, + int, + int, + const int, + const int +#endif +); + +/* vgaSolid.c */ +void xf4bppFillSolid( +#if NeedFunctionPrototypes + WindowPtr, + unsigned long int, + const int, + unsigned long int, + int, + const int, + int, + const int +#endif +); + +/* offscreen.c */ +void xf4bppOffBitBlt( +#if NeedFunctionPrototypes + WindowPtr, + const int, + const int, + int, + int, + int, + int, + int, + int +#endif +); +void xf4bppOffDrawColorImage( +#if NeedFunctionPrototypes + WindowPtr, + int, + int, + int, + int, + unsigned char *, + int, + const int, + const unsigned long int +#endif +); +void xf4bppOffReadColorImage( +#if NeedFunctionPrototypes + WindowPtr, + int, + int, + int, + int, + unsigned char *, + int +#endif +); +void xf4bppOffFillSolid( +#if NeedFunctionPrototypes + WindowPtr, + unsigned long int, + const int, + unsigned long int, + int, + const int, + int, + const int +#endif +); +void xf4bppOffDrawMonoImage( +#if NeedFunctionPrototypes + WindowPtr, + unsigned char *, + int, + int, + int, + int, + unsigned long int, + int, + unsigned long int +#endif +); +void xf4bppOffFillStipple( +#if NeedFunctionPrototypes + WindowPtr, + const PixmapPtr, + unsigned long int, + const int, + unsigned long int, + int, + int, + int, + int, + const int, + const int +#endif +); + +/* mfbimggblt.c */ +void xf4bppImageGlyphBlt( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + int, + unsigned int, + CharInfoPtr *, + pointer +#endif +); + +/* wm3.c */ +int wm3_set_regs( +#if NeedFunctionPrototypes + GC * +#endif +); + +/* ppcIO.c */ +int xf4bppNeverCalled( +#if NeedFunctionPrototypes + void +#endif +); +Bool xf4bppScreenInit( +#if NeedFunctionPrototypes + ScreenPtr, + pointer, + int, + int, + int, + int, + int +#endif +); + +/* mfbfillarc.c */ +void xf4bppPolyFillArc( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + xArc * +#endif +); + +/* mfbzerarc.c */ +void xf4bppZeroPolyArc( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + xArc * +#endif +); + +/* mfbline.c */ +void xf4bppSegmentSS ( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + xSegment * +#endif +); +void xf4bppLineSS ( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + int, + DDXPointPtr +#endif +); +void xf4bppSegmentSD ( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + xSegment * +#endif +); +void xf4bppLineSD ( +#if NeedFunctionPrototypes + DrawablePtr, + GCPtr, + int, + int, + DDXPointPtr +#endif +); + +/* mfbbres.c */ +void xf4bppBresS( +#if NeedFunctionPrototypes + PixelType *, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int +#endif +); + +/* mfbbresd.c */ +void xf4bppBresD( +#if NeedFunctionPrototypes + DrawablePtr, + int, int, + int *, + unsigned char *, + int, + int *, + int, + PixelType *, + int, int, int, int, int, int, + int, int, + int, int +#endif +); + +/* mfbhrzvert.c */ +void xf4bppHorzS( +#if NeedFunctionPrototypes + PixelType *, + int, + int, + int, + int +#endif +); +void xf4bppVertS( +#if NeedFunctionPrototypes + PixelType *, + int, + int, + int, + int +#endif +); + +#ifdef PC98_EGC + +/* egc_asm.s */ +unsigned char getbits_x( +#if NeedFunctionPrototypes + int, + unsigned int, + pointer, + unsigned int +#endif +); +void wcopyr( +#if NeedFunctionPrototypes + pointer, + pointer, + int, + pointer +#endif +); +void wcopyl( +#if NeedFunctionPrototypes + pointer, + pointer, + int, + pointer +#endif +); +unsigned long int read8Z( +#if NeedFunctionPrototypes + pointer +#endif +); + +#endif /* PC98_EGC */ + +#endif /* __XF4BPP_H__ */ |