|
|
1.1 ! root 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 "X.h" ! 30: #include "Xmd.h" ! 31: #include <servermd.h> ! 32: #include "scrnintstr.h" ! 33: #include "pixmapstr.h" ! 34: #include "resource.h" ! 35: #include "colormap.h" ! 36: #include "colormapst.h" ! 37: #include "cfb.h" ! 38: #include "mi.h" ! 39: #include "mistruct.h" ! 40: #include "dix.h" ! 41: ! 42: extern void miGetImage(); /* XXX should not be needed */ ! 43: extern ColormapPtr CreateStaticColormap(); /* XXX is this needed? */ ! 44: ! 45: static VisualRec visuals[] = { ! 46: /* vid screen class rMask gMask bMask oRed oGreen oBlue bpRGB cmpE nplan */ ! 47: #ifdef notdef ! 48: /* Eventually, we would like to offer this visual too */ ! 49: 0, 0, StaticGray, 0, 0, 0, 0, 0, 0, 1, 2, 1, ! 50: #endif ! 51: #ifdef STATIC_COLOR ! 52: 0, 0, StaticColor,0, 0, 0, 0, 0, 0, 8, 256, 8, ! 53: #else ! 54: 0, 0, PseudoColor,0, 0, 0, 0, 0, 0, 8, 256, 8, ! 55: #endif ! 56: }; ! 57: ! 58: #define NUMVISUALS ((sizeof visuals)/(sizeof visuals[0])) ! 59: #define ROOTVISUAL (NUMVISUALS-1) ! 60: ! 61: static DepthRec depths[] = { ! 62: /* depth numVid vids */ ! 63: 1, 0, NULL, ! 64: 8, 1, NULL, ! 65: }; ! 66: ! 67: static ColormapPtr cfbColorMaps[NUMVISUALS]; /* assume one per visual */ ! 68: #define NUMDEPTHS ((sizeof depths)/(sizeof depths[0])) ! 69: ! 70: /* dts * (inch/dot) * (25.4 mm / inch) = mm */ ! 71: Bool ! 72: cfbScreenInit(index, pScreen, pbits, xsize, ysize, dpi) ! 73: int index; ! 74: register ScreenPtr pScreen; ! 75: pointer pbits; /* pointer to screen bitmap */ ! 76: int xsize, ysize; /* in pixels */ ! 77: int dpi; /* dots per inch */ ! 78: { ! 79: long *pVids; ! 80: register PixmapPtr pPixmap; ! 81: int i; ! 82: void cfbInitialize332Colormap(); ! 83: ! 84: pScreen->myNum = index; ! 85: pScreen->width = xsize; ! 86: pScreen->height = ysize; ! 87: pScreen->mmWidth = (xsize * 254) / (dpi * 10); ! 88: pScreen->mmHeight = (ysize * 254) / (dpi * 10); ! 89: pScreen->numDepths = NUMDEPTHS; ! 90: pScreen->allowedDepths = depths; ! 91: ! 92: pScreen->rootDepth = 8; ! 93: pScreen->minInstalledCmaps = 1; ! 94: pScreen->maxInstalledCmaps = 1; ! 95: pScreen->backingStoreSupport = NotUseful; ! 96: pScreen->saveUnderSupport = NotUseful; ! 97: ! 98: /* cursmin and cursmax are device specific */ ! 99: ! 100: pScreen->numVisuals = NUMVISUALS; ! 101: pScreen->visuals = visuals; ! 102: ! 103: pPixmap = (PixmapPtr )Xalloc(sizeof(PixmapRec)); ! 104: pPixmap->drawable.type = DRAWABLE_PIXMAP; ! 105: pPixmap->drawable.depth = 8; ! 106: pPixmap->drawable.pScreen = pScreen; ! 107: pPixmap->drawable.serialNumber = 0; ! 108: pPixmap->width = xsize; ! 109: pPixmap->height = ysize; ! 110: pPixmap->refcnt = 1; ! 111: pPixmap->devPrivate = pbits; ! 112: pPixmap->devKind = PixmapBytePad(xsize, 8); ! 113: pScreen->devPrivate = (pointer)pPixmap; ! 114: ! 115: /* anything that cfb doesn't know about is assumed to be done ! 116: elsewhere. (we put in no-op only for things that we KNOW ! 117: are really no-op. ! 118: */ ! 119: pScreen->QueryBestSize = cfbQueryBestSize; ! 120: pScreen->CreateWindow = cfbCreateWindow; ! 121: pScreen->DestroyWindow = cfbDestroyWindow; ! 122: pScreen->PositionWindow = cfbPositionWindow; ! 123: pScreen->ChangeWindowAttributes = cfbChangeWindowAttributes; ! 124: pScreen->RealizeWindow = cfbMapWindow; ! 125: pScreen->UnrealizeWindow = cfbUnmapWindow; ! 126: ! 127: pScreen->RealizeFont = mfbRealizeFont; ! 128: pScreen->UnrealizeFont = mfbUnrealizeFont; ! 129: pScreen->GetImage = miGetImage; ! 130: pScreen->GetSpans = cfbGetSpans; /* XXX */ ! 131: pScreen->CreateGC = cfbCreateGC; ! 132: pScreen->CreatePixmap = cfbCreatePixmap; ! 133: pScreen->DestroyPixmap = cfbDestroyPixmap; ! 134: pScreen->ValidateTree = miValidateTree; ! 135: ! 136: #ifdef STATIC_COLOR ! 137: pScreen->InstallColormap = NoopDDA; ! 138: pScreen->UninstallColormap = NoopDDA; ! 139: pScreen->ListInstalledColormaps = cfbListInstalledColormaps; ! 140: #endif ! 141: #ifdef STATIC_COLOR ! 142: pScreen->StoreColors = NoopDDA; ! 143: pScreen->ResolveColor = cfbResolveStaticColor; ! 144: #endif ! 145: ! 146: pScreen->RegionCreate = miRegionCreate; ! 147: pScreen->RegionCopy = miRegionCopy; ! 148: pScreen->RegionDestroy = miRegionDestroy; ! 149: pScreen->Intersect = miIntersect; ! 150: pScreen->Inverse = miInverse; ! 151: pScreen->Union = miUnion; ! 152: pScreen->Subtract = miSubtract; ! 153: pScreen->RegionReset = miRegionReset; ! 154: pScreen->TranslateRegion = miTranslateRegion; ! 155: pScreen->RectIn = miRectIn; ! 156: pScreen->PointInRegion = miPointInRegion; ! 157: pScreen->WindowExposures = miWindowExposures; ! 158: pScreen->RegionNotEmpty = miRegionNotEmpty; ! 159: pScreen->RegionEmpty = miRegionEmpty; ! 160: pScreen->RegionExtents = miRegionExtents; ! 161: ! 162: pScreen->BlockHandler = NoopDDA; ! 163: pScreen->WakeupHandler = NoopDDA; ! 164: pScreen->blockData = (pointer)0; ! 165: pScreen->wakeupData = (pointer)0; ! 166: ! 167: pScreen->CreateColormap = cfbInitialize332Colormap; ! 168: pScreen->DestroyColormap = NoopDDA; ! 169: ! 170: /* Set up the remaining fields in the visuals[] array & make a RT_VISUALID */ ! 171: for (i = 0; i < NUMVISUALS; i++) { ! 172: visuals[i].vid = FakeClientID(0); ! 173: visuals[i].screen = index; ! 174: AddResource(visuals[i].vid, RT_VISUALID, &visuals[i], NoopDDA, RC_CORE); ! 175: switch (visuals[i].class) { ! 176: case StaticGray: ! 177: case StaticColor: ! 178: CreateColormap(FakeClientID(0), pScreen, &visuals[i], ! 179: &cfbColorMaps[i], AllocAll, 0); ! 180: break; ! 181: case PseudoColor: ! 182: case GrayScale: ! 183: CreateColormap(FakeClientID(0), pScreen, &visuals[i], ! 184: &cfbColorMaps[i], AllocNone, 0); ! 185: break; ! 186: case TrueColor: ! 187: case DirectColor: ! 188: FatalError("Bad visual in cfbScreenInit\n"); ! 189: } ! 190: if (!cfbColorMaps[i]) ! 191: FatalError("Can't create colormap in cfbScreenInit\n"); ! 192: } ! 193: pScreen->defColormap = cfbColorMaps[ROOTVISUAL]->mid; ! 194: pScreen->rootVisual = visuals[ROOTVISUAL].vid; ! 195: ! 196: /* Set up the remaining fields in the depths[] array */ ! 197: for (i = 0; i < NUMDEPTHS; i++) { ! 198: if (depths[i].numVids > 0) { ! 199: depths[i].vids = pVids = (long *) Xalloc(sizeof (long) * depths[i].numVids); ! 200: /* XXX - here we offer only the 8-bit visual */ ! 201: pVids[0] = visuals[ROOTVISUAL].vid; ! 202: } ! 203: } ! 204: return( TRUE ); ! 205: } ! 206:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.