|
|
1.1 root 1: /***********************************************************
2: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
3: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
4:
5: All Rights Reserved
6:
7: Permission to use, copy, modify, and distribute this software and its
8: documentation for any purpose and without fee is hereby granted,
9: provided that the above copyright notice appear in all copies and that
10: both that copyright notice and this permission notice appear in
11: supporting documentation, and that the names of Digital or MIT not be
12: used in advertising or publicity pertaining to distribution of the
13: software without specific, written prior permission.
14:
15: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21: SOFTWARE.
22:
23: ******************************************************************/
24: /* $Header: mfb.h,v 1.6 87/09/02 00:30:58 toddb Exp $ */
25: /* Monochrome Frame Buffer definitions
26: written by drewry, september 1986
27: */
28: #include "pixmap.h"
29: #include "region.h"
30: #include "gc.h"
31: #include "colormap.h"
32: #include "miscstruct.h"
33:
34: extern int InverseAlu[];
35:
36: extern Bool mfbScreenInit();
37: extern void mfbQueryBestSize();
38: extern Bool mfbCreateWindow();
39: extern Bool mfbPositionWindow();
40: extern Bool mfbChangeWindowAttributes();
41: extern Bool mfbMapWindow();
42: extern Bool mfbUnmapWindow();
43: extern Bool mfbDestroyWindow();
44:
45: extern Bool mfbRealizeFont();
46: extern Bool mfbUnrealizeFont();
47: extern Bool mfbRealizeCursor();
48: extern Bool mfbUnrealizeCursor();
49: extern Bool mfbScreenSaver();
50: extern Bool mfbCreateGC();
51:
52: extern PixmapPtr mfbCreatePixmap();
53: extern Bool mfbDestroyPixmap();
54:
55: extern void mfbCopyWindow();
56:
57: /* window painters */
58: extern void mfbPaintWindowNone();
59: extern void mfbPaintWindowPR();
60: extern void mfbPaintWindowSolid();
61: extern void mfbPaintWindow32();
62:
63: /* rectangle painters */
64: extern void mfbSolidWhiteArea();
65: extern void mfbStippleWhiteArea();
66: extern void mfbSolidBlackArea();
67: extern void mfbStippleBlackArea();
68: extern void mfbSolidInvertArea();
69: extern void mfbStippleInvertArea();
70: extern void mfbTileArea32();
71:
72:
73: extern void mfbPolyFillRect();
74: extern void mfbCopyArea();
75: extern void mfbPolyPoint();
76: extern void mfbCopyPlane();
77:
78: extern void mfbDestroyGC();
79: extern void mfbValidateGC();
80:
81: extern void mfbSetSpans();
82: extern unsigned int *mfbGetSpans();
83: extern void mfbWhiteSolidFS();
84: extern void mfbBlackSolidFS();
85: extern void mfbInvertSolidFS();
86: extern void mfbWhiteStippleFS();
87: extern void mfbBlackStippleFS();
88: extern void mfbInvertStippleFS();
89: extern void mfbTileFS();
90: extern void mfbUnnaturalTileFS();
91: extern void mfbUnnaturalStippleFS();
92:
93: extern void mfbGetImage();
94: extern void mfbPutImage();
95:
96: extern void mfbLineSS(); /* solid single-pixel wide line */
97: /* calls mfb{Bres|Horz|Vert}S() */
98: extern void mfbDashLine(); /* dashed zero-width line */
99: extern void mfbImageText8();
100: extern void mfbImageText16();
101: extern int mfbPolyText16();
102: extern int mfbPolyText8();
103: extern PixmapPtr mfbCopyPixmap();
104: extern RegionPtr mfbPixmapToRegion();
105: extern void mfbPushPixels();
106:
107: /* text for glyphs <= 32 bits wide */
108: extern void mfbImageGlyphBltWhite();
109: extern void mfbImageGlyphBltBlack();
110: extern void mfbPolyGlyphBltWhite();
111: extern void mfbPolyGlyphBltBlack();
112: extern void mfbPolyGlyphBltInvert();
113:
114: /* text for terminal emulator fonts */
115: extern void mfbTEGlyphBltWhite(); /* fg = 1, bg = 0 */
116: extern void mfbTEGlyphBltBlack(); /* fg = 0, bg = 1 */
117:
118: extern void mfbChangeClip();
119: extern void mfbDestroyClip();
120: extern void mfbCopyClip();
121:
122: extern int mfbListInstalledColormaps();
123: extern void mfbInstallColormap();
124: extern void mfbUninstallColormap();
125:
126: extern void mfbResolveColor();
127:
128: extern void mfbCopyGCDest();
129:
130: /*
131: private filed of pixmap
132: pixmap.devPrivate = (unsigned int *)pointer_to_bits
133: pixmap.devKind = width_of_pixmap_in_bytes
134:
135: private field of screen
136: a pixmap, for which we allocate storage. devPrivate is a pointer to
137: the bits in the hardware framebuffer. note that devKind can be poked to
138: make the code work for framebuffers that are wider than their
139: displayable screen (e.g. the early vsII, which displayed 960 pixels
140: across, but was 1024 in the hardware.) this is left to the
141: code that calls mfbScreenInit(), rather than having mfbScreenInit()
142: take yet another parameter.
143:
144: private field of GC
145: pAbsClientRegion is always a real region, although perhaps
146: an empty one.
147: Freeing pCompositeClip is done based on the value of
148: freeCompClip; if freeCompClip is not carefully maintained, we will end
149: up losing storage or freeing something that isn't ours.
150: */
151:
152: typedef struct {
153: unsigned char rop; /* reduction of rasterop to 1 of 3 */
154: unsigned char ropOpStip; /* rop for opaque stipple */
155: unsigned char ropFillArea; /* == alu, rop, or ropOpStip */
156: short fExpose; /* callexposure handling ? */
157: short freeCompClip;
158: PixmapPtr pRotatedTile; /* tile/stipple rotated to align */
159: PixmapPtr pRotatedStipple; /* with window and using offsets */
160: RegionPtr pAbsClientRegion; /* client region in screen coords */
161: RegionPtr pCompositeClip; /* free this based on freeCompClip
162: flag rather than NULLness */
163: void (* FillArea)(); /* fills regions; look at the code */
164: PixmapPtr *ppPixmap; /* points to the pixmapPtr to
165: use for tiles and stipples */
166: } mfbPrivGC;
167: typedef mfbPrivGC *mfbPrivGCPtr;
168:
169: /* freeCompositeClip values */
170: #define REPLACE_CC 0 /* compsite clip is a copy of a
171: pointer, so it doesn't need to
172: be freed; just overwrite it.
173: this happens if there is no
174: client clip and the gc has
175: ClipByChildren in it.
176: */
177: #define FREE_CC 1 /* composite clip is a real
178: region that we need to free
179: */
180:
181: /* private field of window */
182: typedef struct {
183: int fastBorder; /* non-zero if border tile is 32 bits wide */
184: int fastBackground;
185: DDXPointRec oldRotate;
186: PixmapPtr pRotatedBackground;
187: PixmapPtr pRotatedBorder;
188: } mfbPrivWin;
189:
190: /* precomputed information about each glyph for GlyphBlt code.
191: this saves recalculating the per glyph information for each
192: box.
193: */
194: typedef struct _pos{
195: int xpos; /* xposition of glyph's origin */
196: int xchar; /* x position mod 32 */
197: int leftEdge;
198: int rightEdge;
199: int topEdge;
200: int bottomEdge;
201: unsigned int *pdstBase; /* longword with character origin */
202: int widthGlyph; /* width in bytes of this glyph */
203: } TEXTPOS;
204:
205: /* reduced raster ops for mfb */
206: #define RROP_BLACK GXclear
207: #define RROP_WHITE GXset
208: #define RROP_NOP GXnoop
209: #define RROP_INVERT GXinvert
210:
211: /* out of clip region codes */
212: #define OUT_LEFT 0x08
213: #define OUT_RIGHT 0x04
214: #define OUT_ABOVE 0x02
215: #define OUT_BELOW 0x01
216:
217: /* major axis for bresenham's line */
218: #define X_AXIS 0
219: #define Y_AXIS 1
220:
221: /* optimization codes for FONT's devPrivate field */
222: #define FT_VARPITCH 0
223: #define FT_SMALLPITCH 1
224: #define FT_FIXPITCH 2
225:
226: /* macros for mfbbitblt.c, mfbfillsp.c
227: these let the code do one switch on the rop per call, rather
228: than a switch on the rop per item (span or rectangle.)
229: */
230:
231: #define fnCLEAR(src, dst) (0)
232: #define fnAND(src, dst) (src & dst)
233: #define fnANDREVERSE(src, dst) (src & ~dst)
234: #define fnCOPY(src, dst) (src)
235: #define fnANDINVERTED(src, dst) (~src & dst)
236: #define fnNOOP(src, dst) (dst)
237: #define fnXOR(src, dst) (src ^ dst)
238: #define fnOR(src, dst) (src | dst)
239: #define fnNOR(src, dst) (~(src | dst))
240: #define fnEQUIV(src, dst) (~src ^ dst)
241: #define fnINVERT(src, dst) (~dst)
242: #define fnORREVERSE(src, dst) (src | ~dst)
243: #define fnCOPYINVERTED(src, dst)(~src)
244: #define fnORINVERTED(src, dst) (~src | dst)
245: #define fnNAND(src, dst) (~(src & dst))
246: #define fnSET(src, dst) (~0)
247:
248: /* Binary search to figure out what to do for the raster op. It may
249: * do 5 comparisons, but at least it does no function calls
250: * Special cases copy because it's so frequent
251: */
252: #define DoRop(alu, src, dst) \
253: ( ((alu) == GXcopy) ? (src) : \
254: (((alu) >= GXnor) ? \
255: (((alu) >= GXcopyInverted) ? \
256: (((alu) >= GXnand) ? \
257: (((alu) == GXnand) ? ~((src) & (dst)) : ~0) : \
258: (((alu) == GXcopyInverted) ? ~(src) : (~(src) | (dst)))) : \
259: (((alu) >= GXinvert) ? \
260: (((alu) == GXinvert) ? ~(dst) : ((src) | ~(dst))) : \
261: (((alu) == GXnor) ? ~((src) | (dst)) : (~(src) ^ (dst)))) ) : \
262: (((alu) >= GXandInverted) ? \
263: (((alu) >= GXxor) ? \
264: (((alu) == GXxor) ? ((src) ^ (dst)) : ((src) | (dst))) : \
265: (((alu) == GXnoop) ? (dst) : (~(src) & (dst)))) : \
266: (((alu) >= GXandReverse) ? \
267: (((alu) == GXandReverse) ? ((src) & ~(dst)) : (src)) : \
268: (((alu) == GXand) ? ((src) & (dst)) : 0))) ) )
269:
270:
271: #define DoRRop(alu, src, dst) \
272: (((alu) == RROP_BLACK) ? ((dst) & ~(src)) : \
273: ((alu) == RROP_WHITE) ? ((dst) | (src)) : \
274: ((alu) == RROP_INVERT) ? ((dst) ^ (src)) : \
275: (dst))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.