103b705cfSriastradh/* 203b705cfSriastradh * Copyright © 1998 Keith Packard 303b705cfSriastradh * Copyright © 2012 Intel Corporation 403b705cfSriastradh * 503b705cfSriastradh * Permission to use, copy, modify, distribute, and sell this software and its 603b705cfSriastradh * documentation for any purpose is hereby granted without fee, provided that 703b705cfSriastradh * the above copyright notice appear in all copies and that both that 803b705cfSriastradh * copyright notice and this permission notice appear in supporting 903b705cfSriastradh * documentation, and that the name of Keith Packard not be used in 1003b705cfSriastradh * advertising or publicity pertaining to distribution of the software without 1103b705cfSriastradh * specific, written prior permission. Keith Packard makes no 1203b705cfSriastradh * representations about the suitability of this software for any purpose. It 1303b705cfSriastradh * is provided "as is" without express or implied warranty. 1403b705cfSriastradh * 1503b705cfSriastradh * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 1603b705cfSriastradh * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 1703b705cfSriastradh * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 1803b705cfSriastradh * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 1903b705cfSriastradh * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 2003b705cfSriastradh * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 2103b705cfSriastradh * PERFORMANCE OF THIS SOFTWARE. 2203b705cfSriastradh */ 2303b705cfSriastradh 2403b705cfSriastradh#define isClipped(c,ul,lr) (((c) | ((c) - (ul)) | ((lr) - (c))) & 0x80008000) 2503b705cfSriastradh#define RROP(b,a,x) WRITE((b), FbDoRRop (READ(b), (a), (x))) 2603b705cfSriastradh 2703b705cfSriastradh#define WRITE_ADDR1(n) (n) 2803b705cfSriastradh#define WRITE_ADDR2(n) (n) 2903b705cfSriastradh#define WRITE_ADDR4(n) (n) 3003b705cfSriastradh 3103b705cfSriastradh#define WRITE1(d,n,fg) WRITE(d + WRITE_ADDR1(n), (BITS) (fg)) 3203b705cfSriastradh 3303b705cfSriastradh#ifdef BITS2 3403b705cfSriastradh#define WRITE2(d,n,fg) WRITE((BITS2 *) &((d)[WRITE_ADDR2(n)]), (BITS2) (fg)) 3503b705cfSriastradh#else 3603b705cfSriastradh#define WRITE2(d,n,fg) (WRITE1(d,n,fg), WRITE1(d,(n)+1,fg)) 3703b705cfSriastradh#endif 3803b705cfSriastradh 3903b705cfSriastradh#ifdef BITS4 4003b705cfSriastradh#define WRITE4(d,n,fg) WRITE((BITS4 *) &((d)[WRITE_ADDR4(n)]), (BITS4) (fg)) 4103b705cfSriastradh#else 4203b705cfSriastradh#define WRITE4(d,n,fg) (WRITE2(d,n,fg), WRITE2(d,(n)+2,fg)) 4303b705cfSriastradh#endif 4403b705cfSriastradh 4503b705cfSriastradhstatic void 4603b705cfSriastradhGLYPH(FbBits * dstBits, 4703b705cfSriastradh FbStride dstStride, 4803b705cfSriastradh int dstBpp, FbStip * stipple, FbBits fg, int x, int height) 4903b705cfSriastradh{ 5003b705cfSriastradh int lshift; 5103b705cfSriastradh FbStip bits; 5203b705cfSriastradh BITS *dstLine; 5303b705cfSriastradh BITS *dst; 5403b705cfSriastradh int n; 5503b705cfSriastradh int shift; 5603b705cfSriastradh 5703b705cfSriastradh dstLine = (BITS *) dstBits; 5803b705cfSriastradh dstLine += x & ~3; 5903b705cfSriastradh dstStride *= (sizeof(FbBits) / sizeof(BITS)); 6003b705cfSriastradh shift = x & 3; 6103b705cfSriastradh lshift = 4 - shift; 6203b705cfSriastradh while (height--) { 6303b705cfSriastradh bits = *stipple++; 6403b705cfSriastradh dst = (BITS *) dstLine; 6503b705cfSriastradh n = lshift; 6603b705cfSriastradh while (bits) { 6703b705cfSriastradh switch (FbStipMoveLsb(FbLeftStipBits(bits, n), 4, n)) { 6803b705cfSriastradh case 0: 6903b705cfSriastradh break; 7003b705cfSriastradh case 1: 7103b705cfSriastradh WRITE1(dst, 0, fg); 7203b705cfSriastradh break; 7303b705cfSriastradh case 2: 7403b705cfSriastradh WRITE1(dst, 1, fg); 7503b705cfSriastradh break; 7603b705cfSriastradh case 3: 7703b705cfSriastradh WRITE2(dst, 0, fg); 7803b705cfSriastradh break; 7903b705cfSriastradh case 4: 8003b705cfSriastradh WRITE1(dst, 2, fg); 8103b705cfSriastradh break; 8203b705cfSriastradh case 5: 8303b705cfSriastradh WRITE1(dst, 0, fg); 8403b705cfSriastradh WRITE1(dst, 2, fg); 8503b705cfSriastradh break; 8603b705cfSriastradh case 6: 8703b705cfSriastradh WRITE1(dst, 1, fg); 8803b705cfSriastradh WRITE1(dst, 2, fg); 8903b705cfSriastradh break; 9003b705cfSriastradh case 7: 9103b705cfSriastradh WRITE2(dst, 0, fg); 9203b705cfSriastradh WRITE1(dst, 2, fg); 9303b705cfSriastradh break; 9403b705cfSriastradh case 8: 9503b705cfSriastradh WRITE1(dst, 3, fg); 9603b705cfSriastradh break; 9703b705cfSriastradh case 9: 9803b705cfSriastradh WRITE1(dst, 0, fg); 9903b705cfSriastradh WRITE1(dst, 3, fg); 10003b705cfSriastradh break; 10103b705cfSriastradh case 10: 10203b705cfSriastradh WRITE1(dst, 1, fg); 10303b705cfSriastradh WRITE1(dst, 3, fg); 10403b705cfSriastradh break; 10503b705cfSriastradh case 11: 10603b705cfSriastradh WRITE2(dst, 0, fg); 10703b705cfSriastradh WRITE1(dst, 3, fg); 10803b705cfSriastradh break; 10903b705cfSriastradh case 12: 11003b705cfSriastradh WRITE2(dst, 2, fg); 11103b705cfSriastradh break; 11203b705cfSriastradh case 13: 11303b705cfSriastradh WRITE1(dst, 0, fg); 11403b705cfSriastradh WRITE2(dst, 2, fg); 11503b705cfSriastradh break; 11603b705cfSriastradh case 14: 11703b705cfSriastradh WRITE1(dst, 1, fg); 11803b705cfSriastradh WRITE2(dst, 2, fg); 11903b705cfSriastradh break; 12003b705cfSriastradh case 15: 12103b705cfSriastradh WRITE4(dst, 0, fg); 12203b705cfSriastradh break; 12303b705cfSriastradh } 12403b705cfSriastradh bits = FbStipLeft(bits, n); 12503b705cfSriastradh n = 4; 12603b705cfSriastradh dst += 4; 12703b705cfSriastradh } 12803b705cfSriastradh dstLine += dstStride; 12903b705cfSriastradh } 13003b705cfSriastradh} 13103b705cfSriastradh 13203b705cfSriastradh#undef WRITE_ADDR1 13303b705cfSriastradh#undef WRITE_ADDR2 13403b705cfSriastradh#undef WRITE_ADDR4 13503b705cfSriastradh#undef WRITE1 13603b705cfSriastradh#undef WRITE2 13703b705cfSriastradh#undef WRITE4 13803b705cfSriastradh 13903b705cfSriastradh#undef RROP 14003b705cfSriastradh#undef isClipped 141