diff options
author | kaleb <empty> | 1995-01-26 15:06:18 +0000 |
---|---|---|
committer | kaleb <empty> | 1995-01-26 15:06:18 +0000 |
commit | 60adac2a4cdaee5c8d1dc598aea13f456ca21fd6 (patch) | |
tree | 73c3f92baa2e166d21aab2c683c7bca6909fc3d2 /xc/programs/Xserver/hw/xfree86 | |
parent | eb27e5f6ad0ae1a7107f14e3dd3a779a06a30bf4 (diff) |
Initial revision
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86')
6 files changed, 2020 insertions, 0 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirBlitMM.h b/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirBlitMM.h new file mode 100644 index 000000000..b009db86d --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirBlitMM.h @@ -0,0 +1,143 @@ +/* $XConsortium: $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirBlitMM.h,v 3.3 1994/12/25 12:34:47 dawes Exp $ */ + +/* Definitions for BitBLT engine communication. */ +/* Using Memory-Mapped I/O. */ + +#if !defined(__STDC__) && !defined(__GNUC__) + +/* If we don't have volatile, MMIO isn't used, but we compile anyway. */ + +#ifdef volatile +#undef volatile +#endif +#define volatile /**/ + +#endif + +/* BitBLT modes. */ + +#define FORWARDS 0x00 +#define BACKWARDS 0x01 +#define SYSTEMDEST 0x02 +#define SYSTEMSRC 0x04 +#define TRANSPARENCYCOMPARE 0x08 +#define PIXELWIDTH16 0x10 +#define PIXELWIDTH32 0x30 /* 543x only. */ +#define PATTERNCOPY 0x40 +#define COLOREXPAND 0x80 + +/* MMIO addresses (offset from 0xb8000). */ + +#define MMIOBACKGROUNDCOLOR 0x00 +#define MMIOFOREGROUNDCOLOR 0x04 +#define MMIOWIDTH 0x08 +#define MMIOHEIGHT 0x0a +#define MMIODESTPITCH 0x0c +#define MMIOSRCPITCH 0x0e +#define MMIODESTADDR 0x10 +#define MMIOSRCADDR 0x14 +#define MMIOBLTWRITEMASK 0x17 +#define MMIOBLTMODE 0x18 +#define MMIOROP 0x1a +#define MMIOBLTSTATUS 0x40 + +extern unsigned char *cirrusMMIOBase; + +/* Address: the 5426 adresses 2MBytes, the 5434 can address 4MB. */ + +#define SETDESTADDR(dstAddr) \ + *(unsigned int *)(cirrusMMIOBase + MMIODESTADDR) = dstAddr; +#if 0 + *(unsigned short *)(cirrusMMIOBase + MMIODESTADDR) = dstAddr; \ + *(unsigned char *)(cirrusMMIOBase + MMIODESTADDR + 2) = dstAddr >> 16; +#endif + +#define SETSRCADDR(srcAddr) \ + *(unsigned int *)(cirrusMMIOBase + MMIOSRCADDR) = srcAddr; +#if 0 + *(unsigned short *)(cirrusMMIOBase + MMIOSRCADDR) = srcAddr; \ + *(unsigned char *)(cirrusMMIOBase + MMIOSRCADDR + 2) = srcAddr >> 16; +#endif + +#define SETSRCADDRUNMODIFIED SETSRCADDR + +/* Pitch: the 5426 goes up to 4095, the 5434 can do 8191. */ + +#define SETDESTPITCH(dstPitch) \ + *(unsigned short *)(cirrusMMIOBase + MMIODESTPITCH) = dstPitch; + +#define SETSRCPITCH(srcPitch) \ + *(unsigned short *)(cirrusMMIOBase + MMIOSRCPITCH) = srcPitch; + +/* Width: the 5426 goes up to 2048, the 5434 can do 8192. */ + +#define SETWIDTH(fillWidth) \ + *(unsigned short *)(cirrusMMIOBase + MMIOWIDTH) = fillWidth - 1; + +/* Height: the 5426 goes up to 1024, the 5434 can do 2048. */ + +#define SETHEIGHT(fillHeight) \ + *(unsigned short *)(cirrusMMIOBase + MMIOHEIGHT) = fillHeight - 1; + +#define SETBLTMODE(m) \ + *(unsigned char *)(cirrusMMIOBase + MMIOBLTMODE) = m; + +#define SETBLTWRITEMASK(m) \ + *(unsigned char *)(cirrusMMIOBase + MMIOBLTWRITEMASK) = m; + +#define SETROP(rop) \ + *(unsigned char *)(cirrusMMIOBase + MMIOROP) = rop; + +#define STARTBLT() \ + *(unsigned char *)(cirrusMMIOBase + MMIOBLTSTATUS) |= 0x02; + +#define BLTBUSY(s) \ + s = *(volatile unsigned char *)(cirrusMMIOBase + MMIOBLTSTATUS) & 1; + +/* BitBLT reset: temporarily set bit 2 of GR31 */ +#define BLTRESET() \ + *(volatile unsigned char *)(cirrusMMIOBase + MMIOBLTSTATUS) ^= 0x04; \ + *(volatile unsigned char *)(cirrusMMIOBase + MMIOBLTSTATUS) ^= 0x04; + +#define WAITUNTILFINISHED() CirrusBLTWaitUntilFinished() + +/* The macros for setting the background/foreground color are already + defined using OUTs in cir_driver.h. */ + +/* To keep consistency with non-MMIO shadow variables, we also update the + * shadow variables. Note that this is not done for the BitBLT registers; + * functions that use them with port I/O while MMIO is also enabled must + * invalidate the shadow variables. + * Also note that the upper bytes of the potentially 32-bit color must + * be preserved (they are used even in 8bpp on the 543x). */ + +#undef SETBACKGROUNDCOLOR +#define SETBACKGROUNDCOLOR(c) \ + *(unsigned char *)(cirrusMMIOBase + MMIOBACKGROUNDCOLOR) = c; \ + *(unsigned char *)(&cirrusBackgroundColorShadow) = c; + +#undef SETFOREGROUNDCOLOR +#define SETFOREGROUNDCOLOR(c) \ + *(unsigned char *)(cirrusMMIOBase + MMIOFOREGROUNDCOLOR) = c; \ + *(unsigned char *)(&cirrusForegroundColorShadow) = c; + +#undef SETBACKGROUNDCOLOR16 +#define SETBACKGROUNDCOLOR16(c) \ + *(unsigned short *)(cirrusMMIOBase + MMIOBACKGROUNDCOLOR) = c; \ + *(unsigned short *)(&cirrusBackgroundColorShadow) = c; + +#undef SETFOREGROUNDCOLOR16 +#define SETFOREGROUNDCOLOR16(c) \ + *(unsigned short *)(cirrusMMIOBase + MMIOFOREGROUNDCOLOR) = c; \ + *(unsigned short *)(&cirrusForegroundColorShadow) = c; + +/* 32-bit colors are exclusive to the BitBLT engine. */ + +#define SETBACKGROUNDCOLOR32(c) \ + *(unsigned int *)(cirrusMMIOBase + MMIOBACKGROUNDCOLOR) = c; \ + cirrusBackgroundColorShadow = c; + +#define SETFOREGROUNDCOLOR32(c) \ + *(unsigned int *)(cirrusMMIOBase + MMIOFOREGROUNDCOLOR) = c; \ + cirrusForegroundColorShadow = c; diff --git a/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirBlitter.h b/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirBlitter.h new file mode 100644 index 000000000..db406b685 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirBlitter.h @@ -0,0 +1,145 @@ +/* $XConsortium: cir_blitter.h,v 1.1 94/03/28 21:48:17 dpw Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirBlitter.h,v 3.6 1995/01/04 04:42:18 dawes Exp $ */ + +/* Definitions for BitBLT engine communication. */ + +/* BitBLT modes. */ + +#define FORWARDS 0x00 +#define BACKWARDS 0x01 +#define SYSTEMDEST 0x02 +#define SYSTEMSRC 0x04 +#define TRANSPARENCYCOMPARE 0x08 +#define PIXELWIDTH16 0x10 +#define PIXELWIDTH32 0x30 /* 543x only. */ +#define PATTERNCOPY 0x40 +#define COLOREXPAND 0x80 + + +/* Address: the 5426 adresses 2MBytes, the 5434 can address 4MB. */ + +/* Set BLT source address; source address is modified by blit. + * Shadow variable is invalidated. */ +#define SETSRCADDR(srcAddr) \ + outw (0x3CE, (((srcAddr) & 0x000000FF) << 8) | 0x2C); \ + outw (0x3CE, (((srcAddr) & 0x0000FF00)) | 0x2D); \ + outw (0x3CE, (((srcAddr) & 0x003F0000) >> 8) | 0x2E); \ + cirrusBltSrcAddrShadow = -1; + +/* Set BLT source address; source address is preserved by blit. + * Usually dummy source address that needs to set to 0. */ +#define SETSRCADDRUNMODIFIED(srcAddr) \ + if (srcAddr != cirrusBltSrcAddrShadow) { \ + cirrusBltSrcAddrShadow = srcAddr; \ + outw (0x3CE, (((srcAddr) & 0x000000FF) << 8) | 0x2C); \ + outw (0x3CE, (((srcAddr) & 0x0000FF00)) | 0x2D); \ + outw (0x3CE, (((srcAddr) & 0x003F0000) >> 8) | 0x2E); \ + } + +#define SETDESTADDR(dstAddr) \ + outw (0x3CE, (((dstAddr) & 0x000000FF) << 8) | 0x28); \ + outw (0x3CE, (((dstAddr) & 0x0000FF00)) | 0x29); \ + outw (0x3CE, (((dstAddr) & 0x003F0000) >> 8) | 0x2A); + +/* Pitch: the 5426 goes up to 4095, the 5434 can do 8191. */ + +#define SETDESTPITCH(dstPitch) \ + if ((dstPitch) != cirrusBltDestPitchShadow) { \ + cirrusBltDestPitchShadow = dstPitch; \ + outw (0x3CE, (((dstPitch) & 0x000000FF) << 8) | 0x24); \ + outw (0x3CE, (((dstPitch) & 0x00001F00)) | 0x25); \ + } + +#define SETSRCPITCH(srcPitch) \ + if ((srcPitch) != cirrusBltSrcPitchShadow) { \ + cirrusBltSrcPitchShadow = srcPitch; \ + outw (0x3CE, (((srcPitch) & 0x000000FF) << 8) | 0x26); \ + outw (0x3CE, (((srcPitch) & 0x00001F00)) | 0x27); \ + } + +/* Width: the 5426 goes up to 2048, the 5434 can do 8192. */ + +#define SETWIDTH(fillWidth) \ + outw (0x3CE, ((((fillWidth) - 1) & 0x000000FF) << 8) | 0x20); \ + outw (0x3CE, ((((fillWidth) - 1) & 0x00001F00)) | 0x21); + +/* Height: the 5426 goes up to 1024, the 5434 can do 2048. */ +/* It appears many 5434's only go up to 2048. */ + +/* The height is preserved by a blit only on the 543x. */ +#define SETHEIGHT543X(fillHeight) \ + if ((fillHeight) != cirrusBltHeightShadow) { \ + cirrusBltHeightShadow = fillHeight; \ + outw (0x3CE, ((((fillHeight) - 1) & 0x000000FF) << 8) | 0x22); \ + outw (0x3CE, (((fillHeight) - 1) & 0x00000700) | 0x23); \ + } + +#define SETHEIGHT(fillHeight) \ + outw (0x3CE, ((((fillHeight) - 1) & 0x000000FF) << 8) | 0x22); \ + outw (0x3CE, (((fillHeight) - 1) & 0x00000700) | 0x23); + +#define SETBLTMODE(m) \ + if ((m) != cirrusBltModeShadow) { \ + cirrusBltModeShadow = m; \ + outw(0x3CE, ((m) << 8) | 0x30); \ + } + +#define SETBLTWRITEMASK(m) outw(0x3ce, ((m) << 8) | 0x2f); + +#define SETTRANSPARENCYCOLOR(c) outw(0x3ce, ((c) << 8) | 0x34); + +#define SETTRANSPARENCYCOLOR16(c) \ + outw(0x3ce, ((c) << 8) | 0x34); \ + outw(0x3ce, (c & 0xff00) | 0x35); + +#define SETTRANSPARENCYCOLORMASK16(m) \ + outw(0x3ce, ((m) << 8) | 0x38); \ + outw(0x3ce, ((m) & 0xff00) | 0x39); + +#define SETROP(rop) \ + if ((rop) != cirrusBltRopShadow) { \ + cirrusBltRopShadow = rop; \ + outw (0x3CE, ((rop) << 8) | 0x32); \ + } + +/* 32-bit colors are specific to the BitBLT engine, so define macros here. */ + +#define SETFOREGROUNDCOLOR32(c) \ + if (c != cirrusForegroundColorShadow) { \ + cirrusForegroundColorShadow = c; \ + outw(0x3ce, 0x01 + ((c) << 8)); \ + outw(0x3ce, 0x11 + ((c) & 0xff00)); \ + outw(0x3ce, 0x13 + (((c) & 0xff0000) >> 8)); \ + outw(0x3ce, 0x15 + (((unsigned int)(c) & 0xff000000) >> 16)); \ + } + +#define SETBACKGROUNDCOLOR32(c) \ + if (c != cirrusBackgroundColorShadow) { \ + cirrusBackgroundColorShadow = c; \ + outw(0x3ce, 0x00 + ((c) << 8)); \ + outw(0x3ce, 0x10 + ((c) & 0xff00)); \ + outw(0x3ce, 0x12 + (((c) & 0xff0000) >> 8)); \ + outw(0x3ce, 0x14 + (((unsigned int)(c) & 0xff000000) >> 16)); \ + } + +#define STARTBLT() { \ + unsigned char tmp; \ + outb(0x3ce, 0x31); \ + tmp = inb(0x3cf); \ + outb(0x3cf, tmp | 0x02); \ + } + +#define BLTBUSY(s) { \ + outb(0x3ce, 0x31); \ + s = inb(0x3cf) & 1; \ + } + +#define BLTRESET() { \ + unsigned char tmp; \ + outb(0x3ce, 0x31); \ + tmp = inb(0x3cf); \ + outb(0x3cf, tmp | 0x04); \ + outb(0x3cf, tmp); \ + } + +#define WAITUNTILFINISHED() CirrusBLTWaitUntilFinished() diff --git a/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirFillRct.c b/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirFillRct.c new file mode 100644 index 000000000..78148cc24 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirFillRct.c @@ -0,0 +1,313 @@ +/* + * Fill rectangles. + */ + +/* + +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. +*/ + +/* $XConsortium: cir_fillrct.c,v 5.14 94/04/17 20:32:33 dpw Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirFillRct.c,v 3.5 1994/12/25 12:35:02 dawes Exp $ */ + +/* Modified for Cirrus by Harm Hanemaayer, <hhanemaa@cs.ruu.nl> */ + + +/* + * This file contains the high level PolyFillRect function. + * + * We need to reproduce this to be able to use our own non-GXcopy + * solid fills, and tiles. + * + * Works for 8bpp, and linear framebuffer 16bpp and 32bpp (compiled once). + */ + + +#include "vga256.h" +#include "cfbrrop.h" +#include "mergerop.h" +#include "xf86.h" +#include "vga.h" +#include "vgaBank.h" /* For CHECKSCREEN. */ + +#include "cir_driver.h" + +#if PPW == 4 +extern void cfb8FillRectStippledUnnatural(); +#endif + +extern void cfb16FillRectSolidCopy(); +extern void cfb16FillRectSolidGeneral(); +extern void cfb16FillRectTileOdd(); +extern void cfb32FillRectSolidCopy(); +extern void cfb32FillRectSolidGeneral(); +extern void cfb32FillRectTileOdd(); + +#define NUM_STACK_RECTS 1024 + +void +CirrusPolyFillRect(pDrawable, pGC, nrectFill, prectInit) + DrawablePtr pDrawable; + register 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]; + cfbPrivGC *priv; + int numRects; + void (*BoxFill)(); + int n; + int xorg, yorg; + unsigned long *pdstBase; + int widthDst; + RROP_DECLARE + +#if 0 /* Can't use this for different depths. */ + cfbGetLongWidthAndPointer(pDrawable, widthDst, pdstBase) +#endif + + if (!xf86VTSema || pDrawable->type != DRAWABLE_WINDOW) + { + if (vgaBitsPerPixel == 8) { + cfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit); + return; + } + if (vgaBitsPerPixel == 16) { + cfb16PolyFillRect(pDrawable, pGC, nrectFill, prectInit); + return; + } + if (vgaBitsPerPixel == 32) { + cfb32PolyFillRect(pDrawable, pGC, nrectFill, prectInit); + return; + } + return; + } + + priv = (cfbPrivGC *) pGC->devPrivates[cfbGCPrivateIndex].ptr; + prgnClip = priv->pCompositeClip; + + BoxFill = 0; + switch (pGC->fillStyle) + { + case FillSolid: + RROP_FETCH_GCPRIV(priv) + switch (priv->rop) { + case GXcopy: + if (cirrusUseMMIO && HAVEBITBLTENGINE()) + BoxFill = CirrusMMIOFillRectSolid; /* Optimized. */ + else { + if (vgaBitsPerPixel == 8) + BoxFill = vga256LowlevFuncs.fillRectSolidCopy; + else if (vgaBitsPerPixel == 16) + BoxFill = cfb16FillRectSolidCopy; + else + BoxFill = cfb32FillRectSolidCopy; + } + break; + default: + /* BoxFill = cfbFillRectSolidGeneral; */ + if (cirrusUseMMIO && HAVEBITBLTENGINE()) + BoxFill = CirrusMMIOFillRectSolid; + else { + if (vgaBitsPerPixel == 8) + BoxFill = CirrusFillRectSolidGeneral; + else if (vgaBitsPerPixel == 16) + BoxFill = cfb16FillRectSolidGeneral; + else + BoxFill = cfb32FillRectSolidGeneral; + } + break; + } + break; + case FillTiled: + /* Hmm, it seems FillRectTileOdd always gets called. --HH */ +#if 0 + if (!((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr)-> + pRotatedPixmap) + BoxFill = cfbFillRectTileOdd; + else +#endif + if (vgaBitsPerPixel == 8) + { + if (pGC->alu == GXcopy && (pGC->planemask & 0xFF) == 0xFF) + /* BoxFill = cfbFillRectTile32Copy; */ + BoxFill = CirrusFillRectTile; + else + BoxFill = vga256FillRectTileOdd; + } + else if (vgaBitsPerPixel == 16) + BoxFill = cfb16FillRectTileOdd; + else + BoxFill = cfb32FillRectTileOdd; + break; +#if (PPW == 4) + case FillStippled: + if (!((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr)-> + pRotatedPixmap) + BoxFill = vga2568FillRectStippledUnnatural; + else + BoxFill = CirrusFillRectTransparentStippled32; + break; + case FillOpaqueStippled: + if (!((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr)-> + pRotatedPixmap) + BoxFill = vga2568FillRectStippledUnnatural; + else + BoxFill = CirrusFillRectOpaqueStippled32; + break; +#endif + } + prect = prectInit; + xorg = pDrawable->x; + yorg = pDrawable->y; + if (xorg || yorg) + { + prect = prectInit; + n = nrectFill; + while(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 = (*pGC->pScreen->RegionExtents)(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) + (*BoxFill) (pDrawable, pGC, + pboxClipped-pboxClippedBase, pboxClippedBase); + if (pboxClippedBase != stackRects) + DEALLOCATE_LOCAL(pboxClippedBase); +} diff --git a/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirFillSt.c b/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirFillSt.c new file mode 100644 index 000000000..5c5535a4e --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirFillSt.c @@ -0,0 +1,478 @@ +/* $XConsortium: cir_fillst.c,v 1.1 94/03/28 21:49:18 dpw Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/cirrus/cirFillSt.c,v 3.7 1995/01/04 04:42:26 dawes Exp $ */ +/* + * + * Copyright 1993 by H. Hanemaayer, Utrecht, The Netherlands + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of H. Hanemaayer not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. H. Hanemaayer makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * H. HANEMAAYER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL H. HANEMAAYER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Author: H. Hanemaayer, <hhanemaa@cs.ruu.nl> + * + */ + +/* + * These are the functions for stipples and tiles, which call low-level + * functions. + */ + +#include "vga256.h" +#include "cfbrrop.h" +#include "mergerop.h" +#include "vgaBank.h" +#include "xf86.h" +#include "vga.h" /* For vga256InfoRec */ + +#include "compiler.h" + +#include "cir_driver.h" +#include "cir_alloc.h" + + +/* + * This function uses the color expand fill for opaque stipples. + * I'm not entirely sure about the origin of the stipple; I assume + * it should be (0, 0). + */ + +void CirrusFillRectOpaqueStippled32(pDrawable, pGC, nBox, pBox) + DrawablePtr pDrawable; + GCPtr pGC; + int nBox; /* number of boxes to fill */ + register BoxPtr pBox; /* pointer to list of boxes to fill */ +{ + unsigned long *src; + int stippleHeight; + cfbPrivGCPtr devPriv; + PixmapPtr stipple; + int destPitch; + + devPriv = ((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr); + stipple = devPriv->pRotatedPixmap; + + destPitch = (int) + (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind); + + cfb8CheckOpaqueStipple(pGC->alu, pGC->fgPixel, pGC->bgPixel, + pGC->planemask); + + stippleHeight = stipple->drawable.height; + src = (unsigned long *)stipple->devPrivate.ptr; + + for (;nBox; nBox--, pBox++) { + int w = pBox->x2 - pBox->x1; + int h = pBox->y2 - pBox->y1; + if (cfb8StippleRRop == GXcopy && w >= 32 && h >= 10) + CirrusColorExpandOpaqueStippleFill(pBox->x1, pBox->y1, + w, h, src, stippleHeight, + 0, 0, pGC->bgPixel, pGC->fgPixel, destPitch); + else { + /* Special raster op. */ + /* Let cfb do this one. */ + speedupvga2568FillRectOpaqueStippled32( + pDrawable, pGC, 1, pBox); + } + } +} + + +/* + * This function uses the color expand fill for transparent stipples. + */ + +void CirrusFillRectTransparentStippled32(pDrawable, pGC, nBox, pBox) + DrawablePtr pDrawable; + GCPtr pGC; + int nBox; /* number of boxes to fill */ + register BoxPtr pBox; /* pointer to list of boxes to fill */ +{ + unsigned long *src; + int stippleHeight; + cfbPrivGCPtr devPriv; + PixmapPtr stipple; + int destPitch; + + devPriv = ((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr); + stipple = devPriv->pRotatedPixmap; + + destPitch = (int) + (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind); + + cfb8CheckStipple(pGC->alu, pGC->fgPixel, pGC->planemask); + + stippleHeight = stipple->drawable.height; + src = (unsigned long *)stipple->devPrivate.ptr; + + for (;nBox; nBox--, pBox++) { + int w = pBox->x2 - pBox->x1; + int h = pBox->y2 - pBox->y1; + if (cfb8StippleRRop == GXcopy && w >= 32 && h >= 10) + CirrusColorExpandStippleFill(pBox->x1, pBox->y1, + w, h, src, stippleHeight, + 0, 0, pGC->fgPixel, destPitch); + else { + /* Special raster op. */ + /* Let cfb do this one. */ + speedupvga2568FillRectTransparentStippled32( + pDrawable, pGC, 1, pBox); + } + } +} + + +/* + * Cirrus Tile fill. + * There's no clear way to do tiling efficiently. There are lots of + * different ways. + * Uses a specific latched-write function for multiple-of-8 pixels wide tiles. + * For 8x8 and 16x16 tiles, the BitBLT engine fill is used. For larger + * tiles, we use repeated BitBlt. + * + * There's potential for using the 8x8 BitBLT engine pattern fill for + * (1, 2, 4, 8, 16) x (1, 2, 4, 8) tiles, and more sizes by splitting + * the area into 'bands' (the BitBLT engine should also work for any rop). + * Also you can 'interleave' by using a doubled pitch (with a virtual screen + * width < 2048, this works for height 16 because the pitch range goes up to + * 4095). + * On the 5434 (which can handle a pitch up to 8191) 4-way interleaving + * can be used, so that we can use the BitBlt engine for 32x32 tiling + * with 4 vertical subdivisions, and 16 pixels wide bands horizontally. + * The 5434 may support a 32 byte wide pattern (for truecolor 8x8 pattern + * fill), which would make it easier. + * + * Currently the accel routine is very restrictive. + * I think for the 5434, the cfb routine (which does a very good + * job) may be more efficient than the 32xH latched write fill (h != 32) + * because of the 32-bit host interface. + */ + +void rotatepattern( unsigned char *pattern, unsigned char *src, int pixWidth, +int width, int height, int hrot, int vrot ) { + int i; + for (i = 0; i < height; i++) { + int j; + unsigned char *srcline; + srcline = src + ((i + vrot) & (height - 1)) * pixWidth; + for (j = 0; j < width; j++) { + *pattern = *(srcline + ((j + hrot) & (width - 1))); + pattern++; + } + } +} + +void CirrusFillRectTile(pDrawable, pGC, nBox, pBox) + DrawablePtr pDrawable; + GCPtr pGC; + int nBox; /* number of boxes to fill */ + register BoxPtr pBox; /* pointer to list of boxes to fill */ +{ + unsigned long *src; + int stippleHeight; + PixmapPtr pPix; + int destPitch; + int width, height; + int pixWidth; + int xrot, yrot; + unsigned char *pattern; + int vidpattern; + + pPix = pGC->tile.pixmap; + width = pPix->drawable.width; + height = pPix->drawable.height; + pixWidth = PixmapBytePad(width, pPix->drawable.depth); + + destPitch = (int) + (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind); + + src = (unsigned long *)pPix->devPrivate.ptr; + xrot = pDrawable->x + pGC->patOrg.x; + yrot = pDrawable->y + pGC->patOrg.y; + + if (HAVEBITBLTENGINE()) { + if (width == 8 && height == 8) + goto tile8x8; + /* For 16x16 tile, prefer the extended write mode function + * to the 5426 BitBLT engine, except for small sizes. + * Always use BitBLT on the 543x. + */ + if (width == 16 && height == 16 && ((!HAVE543X() && + vga256InfoRec.virtualX < 2048) || + (HAVE543X() && vga256InfoRec.virtualX < 4096))) + goto tile16x16; + if (width == 32 && height == 32 && HAVE543X() && + vga256InfoRec.virtualX < 2048 && cirrusUseMMIO) + goto tile32x32; +#if 0 /* broken. */ + if (width * height >= 500 && (width != 32 || height > 32 || + cirrusBusType == CIRRUS_SLOWBUS || HAVE543X())) + goto tileblit; +#endif + } + /* Use the extended write mode function for (?*8)xH tiles. + */ + if (width == 8 || width == 16 || width == 32 || width == 64) + goto tile8mx; + + vga256FillRectTileOdd(pDrawable, pGC, nBox, pBox); + return; + +tile8x8: + /* + * This function does 8x8 tile fills with the BitBLT engine. + */ + pattern = NULL; + for (; nBox; nBox--, pBox++) { + int w, h; + w = pBox->x2 - pBox->x1; + h = pBox->y2 - pBox->y1; + if (w * h < 5000) { + vga256FillRectTileOdd(pDrawable, pGC, 1, pBox); + continue; + } + if (pattern == NULL) { + int i; + /* + * Generate a square of four copies of the tile in + * system memory, so that any rotated position can + * be copied out of it. + */ + pattern = (unsigned char *)ALLOCATE_LOCAL(16 * 16); + for (i = 0; i < 8; i++) { + memcpy(pattern + i * 16, + (unsigned char *)src + i * pixWidth, 8); + memcpy(pattern + i * 16 + 8, + (unsigned char *)src + i * pixWidth, 8); + memcpy(pattern + (i + 8) * 16, + (unsigned char *)src + i * pixWidth, 8); + memcpy(pattern + (i + 8) * 16 + 8, + (unsigned char *)src + i * pixWidth, 8); + } + } + if (cirrusUseMMIO) + CirrusMMIOBLT8x8PatternFill(pBox->y1 * destPitch + pBox->x1, + w, h, pattern + ((pBox->y1 - yrot) & 7) * 16 + + ((pBox->x1 - xrot) & 7), 16, destPitch, CROP_SRC); + else + CirrusBLT8x8PatternFill(pBox->y1 * destPitch + pBox->x1, + w, h, pattern + ((pBox->y1 - yrot) & 7) * 16 + + ((pBox->x1 - xrot) & 7), 16, destPitch, CROP_SRC); + } + if (pattern != NULL) + DEALLOCATE_LOCAL(pattern); + return; + +tile16x16: + /* + * This function does 16x16 tile fills with the BitBLT engine + * by dividing them into two-way vertically interleaved + * 16x8 pattern fills. + */ + pattern = NULL; + for (; nBox; nBox--, pBox++) { + int w, h; + w = pBox->x2 - pBox->x1; + h = pBox->y2 - pBox->y1; + if (w * h < 5000) { + vga256FillRectTileOdd(pDrawable, pGC, 1, pBox); + continue; + } + if (pattern == NULL) { + int i; + /* + * Generate a square of four copies of the tile in + * system memory, so that any rotated position can + * be copied out of it. + */ + pattern = (unsigned char *)ALLOCATE_LOCAL(32 * 32); + for (i = 0; i < 16; i++) { + memcpy(pattern + i * 32, + (unsigned char *)src + i * pixWidth, 16); + memcpy(pattern + i * 32 + 16, + (unsigned char *)src + i * pixWidth, 16); + memcpy(pattern + (i + 16) * 32, + (unsigned char *)src + i * pixWidth, 16); + memcpy(pattern + (i + 16) * 32 + 16, + (unsigned char *)src + i * pixWidth, 16); + } + } + if (cirrusUseMMIO) + CirrusMMIOBLT16x16PatternFill(pBox->y1 * destPitch + pBox->x1, + w, h, pattern + ((pBox->y1 - yrot) & 15) * 32 + + ((pBox->x1 - xrot) & 15), 32, destPitch, CROP_SRC); + else + CirrusBLT16x16PatternFill(pBox->y1 * destPitch + pBox->x1, + w, h, pattern + ((pBox->y1 - yrot) & 15) * 32 + + ((pBox->x1 - xrot) & 15), 32, destPitch, CROP_SRC); + } + if (pattern != NULL) + DEALLOCATE_LOCAL(pattern); + return; + +tile32x32: + /* + * This function does 32x32 tile fills with the BitBLT engine + * by dividing them into vertical bands of 16x8 tile fills + * (four-way vertically interleaved). + * Current revisions of the 5434 do not work correctly with + * 32-byte wide BitBLT pattern copy without color expansion; + * for chips that do support it the vertical bands are not + * necessary. + */ + pattern = NULL; + for (; nBox; nBox--, pBox++) { + int w, h; + w = pBox->x2 - pBox->x1; + h = pBox->y2 - pBox->y1; + if (w * h < 5000) { + vga256FillRectTileOdd(pDrawable, pGC, 1, pBox); + continue; + } + if (pattern == NULL) { + int i; + /* + * Generate a square of four copies of the tile in + * system memory, so that any rotated position can + * be copied out of it. + */ + pattern = (unsigned char *)ALLOCATE_LOCAL(64 * 64); + for (i = 0; i < 32; i++) { + memcpy(pattern + i * 64, + (unsigned char *)src + i * pixWidth, 32); + memcpy(pattern + i * 64 + 32, + (unsigned char *)src + i * pixWidth, 32); + memcpy(pattern + (i + 32) * 64, + (unsigned char *)src + i * pixWidth, 32); + memcpy(pattern + (i + 32) * 64 + 32, + (unsigned char *)src + i * pixWidth, 32); + } + } + if (cirrusUseMMIO) + CirrusMMIOBLT32x32PatternFill(pBox->y1 * destPitch + pBox->x1, + w, h, pattern + ((pBox->y1 - yrot) & 31) * 64 + + ((pBox->x1 - xrot) & 31), 64, destPitch, CROP_SRC); + else + CirrusBLT32x32PatternFill(pBox->y1 * destPitch + pBox->x1, + w, h, pattern + ((pBox->y1 - yrot) & 31) * 64 + + ((pBox->x1 - xrot) & 31), 64, destPitch, CROP_SRC); + } + if (pattern != NULL) + DEALLOCATE_LOCAL(pattern); + return; + +#if 0 +tileblit: + /* Tile with repeated BitBLT. For largish tiles. */ + for (;nBox; nBox--, pBox++) { + int w, h, x, y; + int blitx, blith, blity; + BoxRec box; + x = pBox->x1; + y = pBox->y1; + w = pBox->x2 - x; + h = pBox->y2 - y; + /* Don't use the blitter for small tile fills. */ + if (w * h < 250) { + vga256FillRectTileOdd(pDrawable, pGC, 1, pBox); + continue; + } + box.x1 = x; + box.y1 = y; + box.x2 = x + min(width, w); + box.y2 = y + height; + /* Draw first tile. */ + vga256FillRectTileOdd(pDrawable, pGC, 1, &box); + /* Repeat tile horizontally. */ + blitx = x + width; /* Will skip if width > w. */ + blith = height; + if (h < height) + blith = h; + while (blitx <= x + w - width) { + CirrusBLTBitBlt(y * destPitch + blitx, y * destPitch + + x, destPitch, destPitch, width, blith, 1); + blitx += width; + } + /* Right edge. */ + if (blitx < x + w) + CirrusBLTBitBlt(y * destPitch + blitx, y * destPitch + + x, destPitch, destPitch, x + w - blitx, + blith, 1); + /* Repeat row of tiles vertically. */ + blity = y + height; /* Will skip if height > h. */ + while (blity < y + h - height) { + CirrusBLTBitBlt(blity * destPitch + x, y * destPitch + + x, destPitch, destPitch, w, height, 1); + blity += height; + } + /* Bottom edge. */ + if (blity < y + h) + CirrusBLTBitBlt(blity * destPitch + x, y * destPitch + + x, destPitch, destPitch, w, y + h - blity, 1); + } + return; +#endif + +tile8mx: + /* For width == multiple of 8, max. 64. */ + + /* Only rotate the pattern and allocate it in video memory when */ + /* we actually start to use the accelerated routine. */ + vidpattern = -1; + + for (;nBox; nBox--, pBox++) { + int w, h, x, y; + w = pBox->x2 - pBox->x1; + h = pBox->y2 - pBox->y1; + if (w * h < 10000) + vga256FillRectTileOdd(pDrawable, pGC, 1, pBox); + else { + /* Check if we have not already uploaded the pattern + * to video memory. */ + if (vidpattern == -1) { + /* Allocate space for the pattern in video + * memory. */ + vidpattern = CirrusAllocate(width * height); + if (vidpattern == -1) { + /* Do the rest with vga256. */ + vga256FillRectTileOdd(pDrawable, pGC, + nBox, pBox); + return; + } + + /* Do the work. */ + pattern = (unsigned char *) + ALLOCATE_LOCAL(width * height); + /* Align to start of screen. */ + rotatepattern(pattern, (unsigned char *)src, + pixWidth, width, height, + (0 - xrot) & (width - 1), 0); + + CirrusUploadPattern(pattern, width, height, + vidpattern, width); + } + + x = pBox->x1; + y = pBox->y1; + CirrusColorExpandFillTile8(x, y, w, h, vidpattern, + width, width / 8, height, yrot, destPitch); + } + } + if (vidpattern != -1) { + CirrusFree(vidpattern); + DEALLOCATE_LOCAL(pattern); + } +} diff --git a/xc/programs/Xserver/hw/xfree86/vga256/enhanced/suBBlt2.s b/xc/programs/Xserver/hw/xfree86/vga256/enhanced/suBBlt2.s new file mode 100644 index 000000000..6fe1792eb --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/vga256/enhanced/suBBlt2.s @@ -0,0 +1,859 @@ +/* $XConsortium: suBitBlt2.s,v 1.2 94/03/29 11:19:16 dpw Exp $ */ +/******************************************************************************* + Copyright 1992 by Glenn G. Lai + + 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 Glenn G. Lai not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +Glenn G. Lai 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. + +Glenn G. Lai +P.O. Box 4314 +Austin, Tx 78765 +(glenn@cs.utexas.edu) +7/27/92 +*******************************************************************************/ + +#include "assyntax.h" + + FILE("suBitBlt2.s") + AS_BEGIN + +#include "vgaAsm.h" + +/* void PixWin(src, dst, height, width, sWidth, dWidth) */ + +#define src REGOFF(8,EBP) +#define dst REGOFF(12,EBP) +#define height REGOFF(16,EBP) +#define width REGOFF(20,EBP) +#define sWidth REGOFF(24,EBP) +#define dWidth REGOFF(28,EBP) + + SEG_DATA +copyright: + STRING("Copyright 7/27/1992 by Glenn G. Lai") + ALIGNDATA4 +speedUpTop: + D_LONG 0 +sOffset: + D_LONG 0 +dOffset: + D_LONG 0 +allowance: + D_LONG 0 +lCount: + D_LONG 0 +mCount: + D_LONG 0 +rCount: + D_LONG 0 +heightCount: + D_LONG 0 +func: + D_LONG 0 +sPixWinTable: + D_LONG 0, sPixWin1, sPixWin2, sPixWin3, sPixWin4 +pixWinTable: + D_LONG pwM, pwMR, pwLM, pwLMR +segment: + D_BYTE 0 +/*************************************/ + SEG_TEXT + ALIGNTEXT4 + GLOBL GLNAME(PixWin) +GLNAME(PixWin): + MOV_L (REGOFF(12,ESP), EAX) + OR_L (REGOFF(16,ESP), EAX) + JZ (return) + + CLD + PUSH_L (EBP) + MOV_L (ESP, EBP) + PUSH_L (EDI) + PUSH_L (ESI) + PUSH_L (EBX) + + MOV_L (dWidth, EAX) + MOV_L (width, ECX) + SUB_L (ECX, EAX) + MOV_L (EAX, CONTENT(dOffset)) + ADD_L (CONTENT(GLNAME(vgaWriteTop)), EAX) + MOV_L (EAX, CONTENT(speedUpTop)) + + MOV_L (sWidth, EAX) + SUB_L (ECX, EAX) + MOV_L (EAX, CONTENT(sOffset)) + + MOV_L (src, ESI) + MOV_L (dst, EDI) + SUB_L (VGABASE, EDI) + CMP_L (CONST(5), ECX) + JNC (pixWin1) + MOV_L (REGDIS(sPixWinTable,ECX,4), EAX) + MOV_L (EAX, CONTENT(func)) + JMP (pixWin2) +/*************************************/ + ALIGNTEXT4 +pixWin1: + MOV_L (ADDR(pixWinTable), EAX) + TEST_L (CONST(1), EDI) + JZ (pixWin3) + ADD_L (CONST(8), EAX) + DEC_L (ECX) +pixWin3: + MOV_L (ECX, EBX) + AND_L (CONST(3), EBX) + JZ (pixWin4) + ADD_L (CONST(4), EAX) +pixWin4: + MOV_L (REGIND(EAX), EAX) + MOV_L (EAX, CONTENT(func)) + MOV_L (EBX, CONTENT(rCount)) + SHR_L (CONST(2), ECX) + MOV_L (ECX, CONTENT(mCount)) +pixWin2: + MOV_L (EDI, EAX) + SHR_L (CONST(16), EAX) + MOV_B (AL, CONTENT(segment)) + + AND_L (CONST(0xffff), EDI) + ADD_L (CONTENT(GLNAME(vgaWriteBottom)), EDI) + JMP (pwLoop3) +/*************************************/ + ALIGNTEXT4 +pwLoop: + CMP_L (CONTENT(GLNAME(vgaWriteTop)), EDI) + JC (pwLoop1) + SUB_L (CONST(0x10000), EDI) + MOV_B (CONTENT(segment), AL) + INC_B (AL) + MOV_B (AL, CONTENT(segment)) +pwLoop3: + MOV_W (CONST(0x3cd), DX) + OUT1_B (DX) +pwLoop1: + MOV_L (CONTENT(speedUpTop), EAX) + SUB_L (EDI, EAX) + XOR_L (EDX, EDX) + DIV_L (dWidth) + + OR_L (EAX, EAX) + JZ (pwPartial) + + MOV_L (height, EBX) + CMP_L (EBX, EAX) + JC (pwLoop2) + MOV_L (EBX, EAX) +pwLoop2: + MOV_L (EAX, CONTENT(allowance)) + MOV_L (EAX, EDX) + MOV_L (CONTENT(sOffset), EAX) + MOV_L (CONTENT(dOffset), EBX) + + CALL (VARINDIRECT(func)) + + MOV_L (height, EAX) + SUB_L (CONTENT(allowance), EAX) + MOV_L (EAX, height) + JNZ (pwLoop) + + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE +return: + RET +/********************************/ + ALIGNTEXT4 +pwM: +wpM: + MOV_L (CONTENT(mCount), ECX) + REP + MOVS_L + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (EDX) + JNZ (pwM) + RET +/********************************/ + ALIGNTEXT4 +pwMR: +wpMR: + MOV_L (CONTENT(mCount), ECX) + REP + MOVS_L + MOV_L (CONTENT(rCount), ECX) + REP + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (EDX) + JNZ (pwMR) + RET +/********************************/ + ALIGNTEXT4 +pwLM: +wpLM: + MOVS_B + MOV_L (CONTENT(mCount), ECX) + REP + MOVS_L + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (EDX) + JNZ (pwLM) + RET +/********************************/ + ALIGNTEXT4 +pwLMR: +wpLMR: + MOVS_B + MOV_L (CONTENT(mCount), ECX) + REP + MOVS_L + MOV_L (CONTENT(rCount), ECX) + REP + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (EDX) + JNZ (pwLMR) + RET +/********************************/ +pwPartial: + SUB_L (CONTENT(dOffset), EDX) + MOV_L (EDX, ECX) + MOV_L (width, EBX) + SUB_L (ECX, EBX) + + TEST_L (CONST(1), EDI) + JZ (pwPartial1) + MOVS_B + DEC_L (ECX) + JZ (pwPartial2) +pwPartial1: + SHR_L (CONST(1), ECX) + REP + MOVS_W +pwPartial2: + SUB_L (CONST(0x10000), EDI) + MOV_B (CONTENT(segment), AL) + INC_B (AL) + MOV_B (AL, CONTENT(segment)) + MOV_W (CONST(0x3cd), DX) + OUT1_B (DX) + + MOV_L (EBX, ECX) + SHR_L (CONST(1), ECX) + JZ (pwPartial3) + REP + MOVS_W + JNC (pwPartial4) +pwPartial3: + MOVS_B +pwPartial4: + ADD_L (CONTENT(sOffset), ESI) + ADD_L (CONTENT(dOffset), EDI) + DEC_L (height) + JNZ (pwLoop1) + + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + ALIGNTEXT4 +sPixWin1: +sWinPix1: + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (EDX) + JNZ (sPixWin1) + RET +/********************************/ + ALIGNTEXT4 +sPixWin2: +sWinPix2: + MOVS_W + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (EDX) + JNZ (sPixWin2) + RET +/********************************/ + ALIGNTEXT4 +sPixWin3: +sWinPix3: + TEST_L (CONST(1), EDI) + JNZ (sPixWin31) +sPixWin32: + MOVS_W + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (EDX) + JNZ (sPixWin32) + RET +/********************************/ + ALIGNTEXT4 +sPixWin31: +sWinPix31: + MOVS_B + MOVS_W + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (EDX) + JNZ (sPixWin31) + RET +/********************************/ + ALIGNTEXT4 +sPixWin4: +sWinPix4: + MOVS_L + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (EDX) + JNZ (sPixWin4) + RET +/********************************/ + ALIGNTEXT4 +winPixDone: +pixWinDone: + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET + +/* void WinPix(src, dst, h, w, srcOffset, dstOffset) */ + SEG_DATA + ALIGNDATA4 +sWinPixTable: + D_LONG 0, sWinPix1, sWinPix2, sWinPix3, sWinPix4 +winPixTable: + D_LONG wpM, wpMR, wpLM, wpLMR +/********************************/ + SEG_TEXT + ALIGNTEXT4 + GLOBL GLNAME(WinPix) +GLNAME(WinPix): + MOV_L (REGOFF(12,ESP), EAX) + OR_L (REGOFF(16,ESP), EAX) + JZ (return) + + CLD + PUSH_L (EBP) + MOV_L (ESP, EBP) + PUSH_L (EDI) + PUSH_L (ESI) + PUSH_L (EBX) + + MOV_L (sWidth, EAX) + MOV_L (width, ECX) + SUB_L (ECX, EAX) + MOV_L (EAX, CONTENT(sOffset)) + ADD_L (CONTENT(GLNAME(vgaWriteTop)), EAX) + MOV_L (EAX, CONTENT(speedUpTop)) + + MOV_L (dWidth, EAX) + SUB_L (ECX, EAX) + MOV_L (EAX, CONTENT(dOffset)) + + MOV_L (src, ESI) + MOV_L (dst, EDI) + SUB_L (VGABASE, ESI) + CMP_L (CONST(5), ECX) + JNC (winPix1) + MOV_L (REGDIS(sWinPixTable,ECX,4), EAX) + MOV_L (EAX, CONTENT(func)) + JMP (winPix2) +/********************************/ + ALIGNTEXT4 +winPix1: + MOV_L (ADDR(winPixTable), EAX) + TEST_L (CONST(1), ESI) + JZ (winPix3) + ADD_L (CONST(8), EAX) + DEC_L (ECX) +winPix3: + MOV_L (ECX, EBX) + AND_L (CONST(3), EBX) + JZ (winPix4) + ADD_L (CONST(4), EAX) +winPix4: + MOV_L (REGIND(EAX), EAX) + MOV_L (EAX, CONTENT(func)) + MOV_L (EBX, CONTENT(rCount)) + SHR_L (CONST(2), ECX) + MOV_L (ECX, CONTENT(mCount)) +winPix2: + MOV_L (ESI, EAX) + SHR_L (CONST(16), EAX) + SHL_B (CONST(4), AL) + MOV_B (AL, CONTENT(segment)) + + AND_L (CONST(0xffff), ESI) + ADD_L (CONTENT(GLNAME(vgaWriteBottom)), ESI) + JMP (wpLoop3) +/********************************/ + ALIGNTEXT4 +wpLoop: + CMP_L (CONTENT(GLNAME(vgaWriteTop)), ESI) + JC (wpLoop1) + SUB_L (CONST(0x10000), ESI) + MOV_B (CONTENT(segment), AL) + ADD_B (CONST(16), AL) + MOV_B (AL, CONTENT(segment)) +wpLoop3: + MOV_W (CONST(0x3cd), DX) + OUT1_B (DX) +wpLoop1: + MOV_L (CONTENT(speedUpTop), EAX) + SUB_L (ESI, EAX) + XOR_L (EDX, EDX) + DIV_L (sWidth) + + OR_L (EAX, EAX) + JZ (wpPartial) + + MOV_L (height, EBX) + CMP_L (EBX, EAX) + JC (wpLoop2) + MOV_L (EBX, EAX) +wpLoop2: + MOV_L (EAX, CONTENT(allowance)) + MOV_L (EAX, EDX) + MOV_L (CONTENT(sOffset), EAX) + MOV_L (CONTENT(dOffset), EBX) + + CALL (VARINDIRECT(func)) + + MOV_L (height, EAX) + SUB_L (CONTENT(allowance), EAX) + MOV_L (EAX, height) + JNZ (wpLoop) + + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ +wpPartial: + SUB_L (CONTENT(sOffset), EDX) + MOV_L (EDX, ECX) + MOV_L (width, EBX) + SUB_L (ECX, EBX) + + TEST_L (CONST(1), ESI) + JZ (wpPartial1) + MOVS_B + DEC_L (ECX) + JZ (wpPartial2) +wpPartial1: + SHR_L (CONST(1), ECX) + REP + MOVS_W +wpPartial2: + SUB_L (CONST(0x10000), ESI) + MOV_B (CONTENT(segment), AL) + ADD_B (CONST(16), AL) + MOV_B (AL, CONTENT(segment)) + MOV_W (CONST(0x3cd), DX) + OUT1_B (DX) + + MOV_L (EBX, ECX) + SHR_L (CONST(1), ECX) + JZ (wpPartial3) + REP + MOVS_W + JNC (wpPartial4) +wpPartial3: + MOVS_B +wpPartial4: + ADD_L (CONTENT(sOffset), ESI) + ADD_L (CONTENT(dOffset), EDI) + DEC_L (height) + JNZ (wpLoop1) + + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + SEG_DATA + ALIGNDATA4 +sPixPixTable: + D_LONG 0, sPixPix1, sPixPix2, sPixPix3, sPixPix4 +/********************************/ + SEG_TEXT + ALIGNTEXT4 +/* void PixPix(src, dst, h, w, srcOffset, dstOffset, ydir) */ + GLOBL GLNAME(PixPix) +GLNAME(PixPix): + MOV_L (REGOFF(12,ESP), EAX) + OR_L (REGOFF(16,ESP), EAX) + JZ (return) + PUSH_L (EBP) + MOV_L (ESP, EBP) + PUSH_L (EDI) + PUSH_L (ESI) + PUSH_L (EBX) + MOV_L (REGOFF(8,EBP), ESI) + MOV_L (REGOFF(12,EBP), EDI) + CMP_L (ESI, EDI) + JZ (pixPixDone) + MOV_L (REGOFF(20,EBP), EDX) + MOV_L (REGOFF(28,EBP), EBX) + CMP_L (CONST(4), EDX) + JLE (sPixPix) + MOV_L (REGOFF(16,EBP), EAX) + MOV_L (EAX, CONTENT(heightCount)) + CMP_L (CONST(1), REGOFF(32,EBP)) + JNE (pixPixRL) + CLD + MOV_L (ESI, EAX) + ADD_L (CONST(3), EAX) + AND_L (CONST(0xfffffffc), EAX) + SUB_L (ESI, EAX) + MOV_L (EAX, CONTENT(lCount)) + SUB_L (EAX, EDX) + MOV_L (EDX, EAX) + SAR_L (CONST(2), EDX) + JZ (pixPixLRLR) + AND_L (CONST(3), EAX) + JZ (pixPixLRLMorM) + MOV_L (EAX, CONTENT(rCount)) + MOV_L (REGOFF(24,EBP), EAX) + CMP_L (CONST(0), CONTENT(lCount)) + JE (pixPixLRMR) +/********************************/ +pixPixLRLMR: + MOV_L (CONTENT(lCount), ECX) + REP + MOVS_B + MOV_L (EDX, ECX) + REP + MOVS_L + MOV_L (CONTENT(rCount), ECX) + REP + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixLRLMR) +pixPixDone: + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + ALIGNTEXT4 +pixPixLRMR: + MOV_L (EDX, ECX) + REP + MOVS_L + MOV_L (CONTENT(rCount), ECX) + REP + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixLRMR) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + ALIGNTEXT4 +pixPixLRLMorM: + MOV_L (REGOFF(24,EBP), EAX) + CMP_L (CONST(0), CONTENT(lCount)) + JE (pixPixLRM) +pixPixLRLM: + MOV_L (CONTENT(lCount), ECX) + REP + MOVS_B + MOV_L (EDX, ECX) + REP + MOVS_L + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixLRLM) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + ALIGNTEXT4 +pixPixLRM: + MOV_L (EDX, ECX) + REP + MOVS_L + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixLRM) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + ALIGNTEXT4 +pixPixLRLR: + MOV_L (REGOFF(24,EBP), EAX) + MOV_L (REGOFF(20,EBP), EDX) + SUB_L (CONST(4), EDX) +pixPixLRLR1: + MOVS_L + MOV_L (EDX, ECX) + REP + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixLRLR1) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********0************************/ + ALIGNTEXT4 +pixPixRL: + STD + MOV_L (ESI, EAX) + INC_L (EAX) + AND_L (CONST(3), EAX) + MOV_L (EAX, CONTENT(rCount)) + SUB_L (EAX, EDX) + MOV_L (EDX, EAX) + SAR_L (CONST(2), EDX) + JZ (pixPixRLLR) + AND_L (CONST(3), EAX) + JZ (pixPixRLMRorM) + MOV_L (EAX, CONTENT(lCount)) + MOV_L (REGOFF(24,EBP), EAX) + CMP_L (CONST(0), CONTENT(rCount)) + JE (pixPixRLLM) +pixPixRLLMR: + MOV_L (CONTENT(rCount), ECX) + REP + MOVS_B + SUB_L (CONST(3), ESI) + SUB_L (CONST(3), EDI) + MOV_L (EDX, ECX) + REP + MOVS_L + ADD_L (CONST(3), ESI) + ADD_L (CONST(3), EDI) + MOV_L (CONTENT(lCount), ECX) + REP + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixRLLMR) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + CLD + LEAVE + RET +/********************************/ + ALIGNTEXT4 +pixPixRLLM: + SUB_L (CONST(3), ESI) + SUB_L (CONST(3), EDI) + SUB_L (CONST(3), EAX) + SUB_L (CONST(3), EBX) +pixPixRLLM1: + MOV_L (EDX, ECX) + REP + MOVS_L + MOV_L (CONTENT(lCount), ECX) + ADD_L (CONST(3), ESI) + ADD_L (CONST(3), EDI) + REP + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixRLLM1) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + CLD + LEAVE + RET +/********************************/ + ALIGNTEXT4 +pixPixRLMRorM: + MOV_L (REGOFF(24,EBP), EAX) + CMP_L (CONST(0), CONTENT(rCount)) + JE (pixPixRLM) + ADD_L (CONST(3), EAX) + ADD_L (CONST(3), EBX) +pixPixRLMR: + MOV_L (CONTENT(rCount), ECX) + REP + MOVS_B + SUB_L (CONST(3), ESI) + SUB_L (CONST(3), EDI) + MOV_L (EDX, ECX) + REP + MOVS_L + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixRLMR) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + CLD + LEAVE + RET +/********************************/ + ALIGNTEXT4 +pixPixRLM: + SUB_L (CONST(3), ESI) + SUB_L (CONST(3), EDI) +pixPixRLM1: + MOV_L (EDX, ECX) + REP + MOVS_L + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixRLM1) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + CLD + LEAVE + RET +/********************************/ + ALIGNTEXT4 +pixPixRLLR: + MOV_L (REGOFF(24,EBP), EAX) + MOV_L (REGOFF(20,EBP), EDX) +pixPixRLLR1: + MOV_L (EDX, ECX) + REP + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (CONTENT(heightCount)) + JNZ (pixPixRLLR1) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + CLD + LEAVE + RET +/********************************/ + ALIGNTEXT4 +sPixPix: + CLD + MOV_L (REGOFF(16,EBP), ECX) + MOV_L (REGOFF(24,EBP), EAX) + JMP (CODEPTR(REGDIS(sPixPixTable,EDX,4))) +/********************************/ + ALIGNTEXT4 +sPixPix4: + MOVS_L + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (ECX) + JNZ (sPixPix4) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + ALIGNTEXT4 +sPixPix3: + TEST_L (CONST(1), ESI) + JNZ (sPixPix3U) + INC_L (EAX) + INC_L (EBX) +sPixPix31: + MOV_B (REGOFF(2,ESI), DL) + MOVS_W + MOV_B (DL, REGIND(EDI)) + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (ECX) + JNZ (sPixPix31) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + ALIGNTEXT4 +sPixPix3U: + ADD_L (CONST(2), EAX) + ADD_L (CONST(2), EBX) +sPixPix3U1: + MOV_W (REGOFF(1,ESI), DX) + MOVS_B + MOV_W (DX, REGIND(EDI)) + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (ECX) + JNZ (sPixPix3U1) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + ALIGNTEXT4 +sPixPix2: + MOVS_W + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (ECX) + JNZ (sPixPix2) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET +/********************************/ + ALIGNTEXT4 +sPixPix1: + MOVS_B + ADD_L (EAX, ESI) + ADD_L (EBX, EDI) + DEC_L (ECX) + JNZ (sPixPix1) + POP_L (EBX) + POP_L (ESI) + POP_L (EDI) + LEAVE + RET diff --git a/xc/programs/Xserver/hw/xfree86/vga256/vga/vgapwinS.c b/xc/programs/Xserver/hw/xfree86/vga256/vga/vgapwinS.c new file mode 100644 index 000000000..ef9193c6c --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/vga256/vga/vgapwinS.c @@ -0,0 +1,82 @@ +/* $XConsortium: cfbpntwin.c,v 1.2 94/04/17 20:32:22 dpw Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/vga/vgapwinS.c,v 3.0 1994/07/24 11:59:07 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 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 "vga256.h" + +void +speedupvga256FillBoxSolid (pDrawable, nBox, pBox, pixel1, pixel2, alu) + DrawablePtr pDrawable; + int nBox; + BoxPtr pBox; + unsigned long pixel1; + unsigned long pixel2; + int alu; +{ + unsigned long *pdstBase; + register unsigned char *pdstb; + int widthDst; + int h; + unsigned long fill1; + int m; + int w; + + cfbGetLongWidthAndPointer(pDrawable, widthDst, pdstBase); + fill1 = PFILL(pixel1); + for (; nBox; nBox--, pBox++) + { + + pdstb = (unsigned char*)(pdstBase+pBox->y1*widthDst)+pBox->x1; + + h = pBox->y2 - pBox->y1; + w = pBox->x2 - pBox->x1; + + SpeedUpBox(pdstb, fill1, h, w, widthDst << 2); + } +} |