--- .empty Thu Jan 1 00:00:00 1970 +++ NEW/xc/programs/Xserver/hw/cg14.2screen/cg14-8.c Thu Jan 1 00:00:00 1970 @@ -0,0 +1,124 @@ +#include + +#include "vars.h" +#include "cg14.h" +#include "cg14-8.h" + +#define PSZ 8 +#include + +static Bool savescreen_8(ScreenRec *s, int op) +{ + switch (op) + { case SCREEN_SAVER_FORCER: + break; + case SCREEN_SAVER_ON: + break; + case SCREEN_SAVER_OFF: + break; + default: + return(FALSE); + break; + } + return(TRUE); +} + +static Bool closescreen_8(int scrno, ScreenRec *s) +{ + Bool rv; + + s->CloseScreen = cfbCloseScreen; + rv = cfbCloseScreen(scrno,s); + savescreen_8(s,SCREEN_SAVER_OFF); + return(rv); +} + +static void install_8(ColormapRec *cm) +{ + int i; + + if (cm == instmap_8) return; + if (instmap_8) WalkTree(instmap_8->pScreen,TellLostMap,&instmap_8->mid); + if ((cm->pVisual->class | DynamicClass) == DirectColor) + { for (i=0;i<256;i++) + { +#define MAP(col,Col) \ + (cm->col[(i&cm->pVisual->col##Mask)>>cm->pVisual->offset##Col].co.local.col>>8) + clut1->lut[i] = (MAP(blue,Blue) << 16) | (MAP(green,Green) << 8) | MAP(red,Red); +#undef MAP + } + } + else + { Entry *e; + e = &cm->red[0]; + for (i=0;i<256;i++,e++) + { if (e->fShared) + { clut1->lut[i] = ((e->co.shco.blue ->color >> 8) << 16) | + ((e->co.shco.green->color >> 8) << 8) | + ((e->co.shco.red ->color >> 8) ); + } + else if (e->refcnt) + { clut1->lut[i] = ((e->co.local.blue >> 8) << 16) | + ((e->co.local.green >> 8) << 8) | + ((e->co.local.red >> 8) ); + } + } + } + instmap_8 = cm; + WalkTree(cm->pScreen,TellGainedMap,&cm->mid); +} + +static void uninstall_8(ColormapRec *cm) +{ + if (cm == instmap_8) + { Colormap defid; + defid = cm->pScreen->defColormap; + if (cm->mid != defid) + { ColormapRec *defmap; + defmap = LookupIDByType(defid,RT_COLORMAP); + if (defmap) + { (*cm->pScreen->InstallColormap)(defmap); + } + else + { ErrorF("can't find default colormap\n"); + } + } + } +} + +static int list_8(ScreenRec *s __attribute__((__unused__)), Colormap *list) +{ + *list = instmap_8->mid; + return(1); +} + +static void store_8(ColormapRec *cm, int n, xColorItem *vals) +{ + xColorItem expanded[256]; + + if (instmap_8 && (instmap_8 != cm)) return; + if ((cm->pVisual->class | DynamicClass) == DirectColor) + { n = cfbExpandDirectColors(cm,n,vals,&expanded[0]); + vals = &expanded[0]; + } + for (;n>0;n--,vals++) + { clut1->lut[vals->pixel] = ((vals->blue >> 8) << 16) | + ((vals->green >> 8) << 8) | + ((vals->red >> 8) ); + } +} + +Bool cg14_init8(int scrno, ScreenRec *s, int ac __attribute__((__unused__)), char **av __attribute__((__unused__))) +{ + if (! cfbScreenInit(s,vram_px32,1152,900,85,85,1152)) return(FALSE); + s->InstallColormap = install_8; + s->UninstallColormap = uninstall_8; + s->ListInstalledColormaps = list_8; + s->StoreColors = store_8; + instmap_8 = 0; + s->CloseScreen = closescreen_8; + s->SaveScreen = savescreen_8; + /* set up autorepeat stuff in BlockHandler and WakeupHandler */ + miDCInitialize(s,&cg14_psfuncs); + return(cfbCreateDefColormap(s)); +}