1 /************************************************************ 2 Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. 3 4 All Rights Reserved 5 6 Permission to use, copy, modify, and distribute this 7 software and its documentation for any purpose and without 8 fee is hereby granted, provided that the above copyright no- 9 tice appear in all copies and that both that copyright no- 10 tice and this permission notice appear in supporting docu- 11 mentation, and that the names of Sun or MIT not be used in 12 advertising or publicity pertaining to distribution of the 13 software without specific prior written permission. Sun and 14 M.I.T. make no representations about the suitability of this 15 software for any purpose. It is provided "as is" without any 16 express or implied warranty. 17 18 SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 19 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- 20 NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- 21 ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 22 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 23 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 24 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH 25 THE USE OR PERFORMANCE OF THIS SOFTWARE. 26 27 ********************************************************/ 28 29 #include "pixmap.h" 30 #include "region.h" 31 #include "gc.h" 32 #include "colormap.h" 33 #include "miscstruct.h" 34 #include "servermd.h" 35 #include "mfb.h" 36 37 extern Bool cfbScreenInit(); 38 extern void cfbQueryBestSize(); 39 extern Bool cfbCreateWindow(); 40 extern Bool cfbPositionWindow(); 41 extern Bool cfbChangeWindowAttributes(); 42 extern Bool cfbMapWindow(); 43 extern Bool cfbUnmapWindow(); 44 extern Bool cfbDestroyWindow(); 45 46 extern Bool cfbRealizeFont(); 47 extern Bool cfbUnrealizeFont(); 48 extern Bool cfbRealizeCursor(); 49 extern Bool cfbUnrealizeCursor(); 50 extern Bool cfbScreenSaver(); 51 extern Bool cfbCreateGC(); 52 53 extern PixmapPtr cfbCreatePixmap(); 54 extern Bool cfbDestroyPixmap(); 55 56 extern void cfbCopyWindow(); 57 extern void cfbPaintWindow(); 58 59 extern void miPolyFillRect(); 60 extern void cfbPolyFillRect(); 61 extern void miPolyFillArc(); 62 extern void cfbZeroPolyArcSS8Copy(), cfbZeroPolyArcSS8Xor(); 63 extern void cfbZeroPolyArcSS8General(); 64 extern void cfbLineSS(), cfbLineSD(), cfbSegmentSS(), cfbSegmentSD(); 65 extern void cfb8LineSS1Rect(), cfb8SegmentSS1Rect (); 66 extern RegionPtr cfbCopyPlane(); 67 extern void cfbPolyFillArcSolidCopy(),cfbPolyFillArcSolidXor(); 68 extern void cfbPolyFillArcSolidGeneral(); 69 extern RegionPtr cfbCopyArea(); 70 extern void cfbFillPoly1RectCopy(), cfbFillPoly1RectGeneral(); 71 72 extern void cfbPushPixels8(); 73 extern void cfbSetSpans(); 74 extern void cfbGetSpans(); 75 extern void cfbSolidSpansCopy(), cfbSolidSpansXor(), cfbSolidSpansGeneral(); 76 extern void cfbUnnaturalTileFS(); 77 extern void cfbUnnaturalStippleFS(); 78 extern void cfbTile32FSCopy(), cfbTile32FSGeneral(); 79 extern void cfb8Stipple32FS(), cfb8OpaqueStipple32FS(); 80 extern void cfbFillBoxTileOdd(); 81 extern void cfbFillBoxTile32(); 82 extern void cfbFillBoxSolid(); 83 84 extern void cfbTEGlyphBlt(); 85 extern void cfbTEGlyphBlt8(); 86 extern void cfbPolyGlyphBlt8(); 87 extern void cfbPolyGlyphRop8(); 88 extern void cfbImageGlyphBlt8(); 89 90 extern void cfbSaveAreas(); 91 extern void cfbRestoreAreas(); 92 93 /* included from mfb.h; we can't include mfb.h directly because of other 94 * conflicts */ 95 extern void mfbPushPixels(); 96 extern void mfbSetSpans(); 97 extern void mfbGetSpans(); 98 extern void mfbUnnaturalTileFS(); 99 extern void mfbUnnaturalStippleFS(); 100 extern Bool mfbRealizeFont(); 101 extern Bool mfbUnrealizeFont(); 102 extern void mfbQueryBestSize(); 103 extern RegionPtr mfbPixmapToRegion(); 104 extern void mfbCopyRotatePixmap(); 105 106 extern PixmapPtr cfbCopyPixmap(); 107 extern void cfbConvertRects(); 108 extern void miPolyArc(); 109 extern void miFillPolyArc(); 110 111 extern void cfbPutImage(); 112 extern void cfbGetImage(); 113 extern RegionPtr miCopyArea(); 114 extern RegionPtr miCopyPlane(); 115 extern void cfbPolyPoint(); 116 extern void miPushPixels(); 117 118 #ifdef STATIC_COLOR 119 extern void cfbInstallColormap(); 120 extern void cfbUninstallColormap(); 121 extern int cfbListInstalledColormaps(); 122 #endif 123 extern void cfbResolveColor(); 124 extern Bool cfbInitializeColormap(); 125 extern Bool cfbCreateDefColormap(); 126 127 extern void cfbCopyRotatePixmap(); 128 extern void cfbYRotatePixmap(); 129 extern void cfbXRotatePixmap(); 130 extern void cfbPadPixmap(); 131 132 /* 133 private filed of pixmap 134 pixmap.devPrivate = (unsigned int *)pointer_to_bits 135 pixmap.devKind = width_of_pixmap_in_bytes 136 */ 137 138 extern int cfbGCPrivateIndex; 139 extern int cfbWindowPrivateIndex; 140 141 /* private field of GC */ 142 typedef struct { 143 unsigned char rop; /* special case rop values */ 144 /* next two values unused in cfb, included for compatibility with mfb */ 145 unsigned char ropOpStip; /* rop for opaque stipple */ 146 /* this value is ropFillArea in mfb, usurped for cfb */ 147 unsigned char oneRect; /* drawable has one clip rect */ 148 unsigned fExpose:1; /* callexposure handling ? */ 149 unsigned freeCompClip:1; 150 PixmapPtr pRotatedPixmap; 151 RegionPtr pCompositeClip; /* FREE_CC or REPLACE_CC */ 152 unsigned long xor, and; /* reduced rop values */ 153 } cfbPrivGC; 154 155 typedef cfbPrivGC *cfbPrivGCPtr; 156 157 #define cfbGetGCPrivate(pGC) ((cfbPrivGCPtr)\ 158 (pGC)->devPrivates[cfbGCPrivateIndex].ptr) 159 160 /* way to carry RROP info around */ 161 typedef struct { 162 unsigned char rop; 163 unsigned long xor, and; 164 } cfbRRopRec, *cfbRRopPtr; 165 166 /* private field of window */ 167 typedef struct { 168 unsigned char fastBorder; /* non-zero if border is 32 bits wide */ 169 unsigned char fastBackground; 170 unsigned short unused; /* pad for alignment with Sun compiler */ 171 DDXPointRec oldRotate; 172 PixmapPtr pRotatedBackground; 173 PixmapPtr pRotatedBorder; 174 } cfbPrivWin; 175 176 /* Common macros for extracting drawing information */ 177 178 #define cfbGetTypedWidth(pDrawable,wtype) (\ 179 (((pDrawable)->type == DRAWABLE_WINDOW) ? \ 180 (int) (((PixmapPtr)((pDrawable)->pScreen->devPrivate))->devKind) : \ 181 (int)(((PixmapPtr)pDrawable)->devKind)) / sizeof (wtype)) 182 183 #define cfbGetByteWidth(pDrawable) cfbGetTypedWidth(pDrawable, unsigned char) 184 185 #define cfbGetLongWidth(pDrawable) cfbGetTypedWidth(pDrawable, unsigned long) 186 187 #define cfbGetTypedWidthAndPointer(pDrawable, width, pointer, wtype, ptype) {\ 188 PixmapPtr _pPix; \ 189 if ((pDrawable)->type == DRAWABLE_WINDOW) \ 190 _pPix = (PixmapPtr) (pDrawable)->pScreen->devPrivate; \ 191 else \ 192 _pPix = (PixmapPtr) (pDrawable); \ 193 (pointer) = (ptype *) _pPix->devPrivate.ptr; \ 194 (width) = ((int) _pPix->devKind) / sizeof (wtype); \ 195 } 196 197 #define cfbGetByteWidthAndPointer(pDrawable, width, pointer) \ 198 cfbGetTypedWidthAndPointer(pDrawable, width, pointer, unsigned char, unsigned char) 199 200 #define cfbGetLongWidthAndPointer(pDrawable, width, pointer) \ 201 cfbGetTypedWidthAndPointer(pDrawable, width, pointer, unsigned long, unsigned long) 202 203 #define cfbGetWindowTypedWidthAndPointer(pWin, width, pointer, wtype, ptype) {\ 204 PixmapPtr _pPix = (PixmapPtr) (pWin)->drawable.pScreen->devPrivate; \ 205 (pointer) = (ptype *) _pPix->devPrivate.ptr; \ 206 (width) = ((int) _pPix->devKind) / sizeof (wtype); \ 207 } 208 209 #define cfbGetWindowLongWidthAndPointer(pWin, width, pointer) \ 210 cfbGetWindowTypedWidthAndPointer(pWin, width, pointer, unsigned long, unsigned long) 211 212 #define cfbGetWindowByteWidthAndPointer(pWin, width, pointer) \ 213 cfbGetWindowTypedWidthAndPointer(pWin, width, pointer, unsigned char, unsigned char) 214 215 /* Macros which handle a coordinate in a single register */ 216 217 /* Most compilers will convert divide by 65536 into a shift, if signed 218 * shifts exist. If your machine does arithmetic shifts and your compiler 219 * can't get it right, add to this line. 220 */ 221 222 /* mips compiler - what a joke - it CSEs the 65536 constant into a reg 223 * forcing as to use div instead of shift. Let's be explicit. 224 */ 225 226 #if defined(mips) || defined(sparc) 227 #define GetHighWord(x) (((int) (x)) >> 16) 228 #else 229 #define GetHighWord(x) (((int) (x)) / 65536) 230 #endif 231 232 #if IMAGE_BYTE_ORDER == MSBFirst 233 #define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int) ((short) (i)))) 234 #define coordToInt(x,y) (((x) << 16) | (y)) 235 #define intToX(i) (GetHighWord(i)) 236 #define intToY(i) ((int) ((short) i)) 237 #else 238 #define intToCoord(i,x,y) (((x) = (int) ((short) (i))), ((y) = GetHighWord(i))) 239 #define coordToInt(x,y) (((y) << 16) | (x)) 240 #define intToX(i) ((int) ((short) (i))) 241 #define intToY(i) (GetHighWord(i)) 242 #endif 243