fbcmap_mi.c revision b2450a3a
16747b715Smrg/* 29ace9065Smrg * Copyright (c) 1987, Oracle and/or its affiliates. All rights reserved. 36747b715Smrg * 46747b715Smrg * Permission is hereby granted, free of charge, to any person obtaining a 56747b715Smrg * copy of this software and associated documentation files (the "Software"), 66747b715Smrg * to deal in the Software without restriction, including without limitation 76747b715Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 86747b715Smrg * and/or sell copies of the Software, and to permit persons to whom the 96747b715Smrg * Software is furnished to do so, subject to the following conditions: 106747b715Smrg * 116747b715Smrg * The above copyright notice and this permission notice (including the next 126747b715Smrg * paragraph) shall be included in all copies or substantial portions of the 136747b715Smrg * Software. 146747b715Smrg * 156747b715Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 166747b715Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 176747b715Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 186747b715Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 196747b715Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 206747b715Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 216747b715Smrg * DEALINGS IN THE SOFTWARE. 226747b715Smrg */ 2305b261ecSmrg 2405b261ecSmrg/** 2505b261ecSmrg * This version of fbcmap.c is implemented in terms of mi functions. 2605b261ecSmrg * These functions used to be in fbcmap.c and depended upon the symbol 2705b261ecSmrg * XFree86Server being defined. 2805b261ecSmrg */ 2905b261ecSmrg 3005b261ecSmrg#ifdef HAVE_DIX_CONFIG_H 3105b261ecSmrg#include <dix-config.h> 3205b261ecSmrg#endif 3305b261ecSmrg 3405b261ecSmrg#include <X11/X.h> 3505b261ecSmrg#include "fb.h" 3605b261ecSmrg#include "micmap.h" 3705b261ecSmrg 3805b261ecSmrgint 3935c4bbdfSmrgfbListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps) 4005b261ecSmrg{ 4105b261ecSmrg return miListInstalledColormaps(pScreen, pmaps); 4205b261ecSmrg} 4305b261ecSmrg 4405b261ecSmrgvoid 4505b261ecSmrgfbInstallColormap(ColormapPtr pmap) 4605b261ecSmrg{ 4705b261ecSmrg miInstallColormap(pmap); 4805b261ecSmrg} 4905b261ecSmrg 5005b261ecSmrgvoid 5105b261ecSmrgfbUninstallColormap(ColormapPtr pmap) 5205b261ecSmrg{ 5305b261ecSmrg miUninstallColormap(pmap); 5405b261ecSmrg} 5505b261ecSmrg 5605b261ecSmrgvoid 5735c4bbdfSmrgfbResolveColor(unsigned short *pred, 5835c4bbdfSmrg unsigned short *pgreen, unsigned short *pblue, VisualPtr pVisual) 5905b261ecSmrg{ 6005b261ecSmrg miResolveColor(pred, pgreen, pblue, pVisual); 6105b261ecSmrg} 6205b261ecSmrg 6305b261ecSmrgBool 6405b261ecSmrgfbInitializeColormap(ColormapPtr pmap) 6505b261ecSmrg{ 6605b261ecSmrg return miInitializeColormap(pmap); 6705b261ecSmrg} 6805b261ecSmrg 69b2450a3aStsutsuiBool 70b2450a3aStsutsuimfbCreateColormap(ColormapPtr pmap) 71b2450a3aStsutsui{ 72b2450a3aStsutsui ScreenPtr pScreen; 73b2450a3aStsutsui unsigned short red0, green0, blue0; 74b2450a3aStsutsui unsigned short red1, green1, blue1; 75b2450a3aStsutsui Pixel pix; 76b2450a3aStsutsui 77b2450a3aStsutsui pScreen = pmap->pScreen; 78b2450a3aStsutsui if (pScreen->whitePixel == 0) 79b2450a3aStsutsui { 80b2450a3aStsutsui red0 = green0 = blue0 = ~0; 81b2450a3aStsutsui red1 = green1 = blue1 = 0; 82b2450a3aStsutsui } 83b2450a3aStsutsui else 84b2450a3aStsutsui { 85b2450a3aStsutsui red0 = green0 = blue0 = 0; 86b2450a3aStsutsui red1 = green1 = blue1 = ~0; 87b2450a3aStsutsui } 88b2450a3aStsutsui 89b2450a3aStsutsui /* this is a monochrome colormap, it only has two entries, just fill 90b2450a3aStsutsui * them in by hand. If it were a more complex static map, it would be 91b2450a3aStsutsui * worth writing a for loop or three to initialize it */ 92b2450a3aStsutsui 93b2450a3aStsutsui /* this will be pixel 0 */ 94b2450a3aStsutsui pix = 0; 95b2450a3aStsutsui if (AllocColor(pmap, &red0, &green0, &blue0, &pix, 0) != Success) 96b2450a3aStsutsui return FALSE; 97b2450a3aStsutsui 98b2450a3aStsutsui /* this will be pixel 1 */ 99b2450a3aStsutsui if (AllocColor(pmap, &red1, &green1, &blue1, &pix, 0) != Success) 100b2450a3aStsutsui return FALSE; 101b2450a3aStsutsui return TRUE; 102b2450a3aStsutsui} 103b2450a3aStsutsui 10405b261ecSmrgint 10535c4bbdfSmrgfbExpandDirectColors(ColormapPtr pmap, 10635c4bbdfSmrg int ndef, xColorItem * indefs, xColorItem * outdefs) 10705b261ecSmrg{ 10805b261ecSmrg return miExpandDirectColors(pmap, ndef, indefs, outdefs); 10905b261ecSmrg} 11005b261ecSmrg 11105b261ecSmrgBool 11205b261ecSmrgfbCreateDefColormap(ScreenPtr pScreen) 11305b261ecSmrg{ 11405b261ecSmrg return miCreateDefColormap(pScreen); 11505b261ecSmrg} 11605b261ecSmrg 11705b261ecSmrgvoid 11805b261ecSmrgfbClearVisualTypes(void) 11905b261ecSmrg{ 12005b261ecSmrg miClearVisualTypes(); 12105b261ecSmrg} 12205b261ecSmrg 12305b261ecSmrgBool 12435c4bbdfSmrgfbSetVisualTypes(int depth, int visuals, int bitsPerRGB) 12505b261ecSmrg{ 12605b261ecSmrg return miSetVisualTypes(depth, visuals, bitsPerRGB, -1); 12705b261ecSmrg} 12805b261ecSmrg 1294642e01fSmrgBool 13035c4bbdfSmrgfbSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, 13135c4bbdfSmrg Pixel redMask, Pixel greenMask, Pixel blueMask) 1324642e01fSmrg{ 1334642e01fSmrg return miSetVisualTypesAndMasks(depth, visuals, bitsPerRGB, -1, 1344642e01fSmrg redMask, greenMask, blueMask); 1354642e01fSmrg} 1364642e01fSmrg 13705b261ecSmrg/* 13805b261ecSmrg * Given a list of formats for a screen, create a list 13905b261ecSmrg * of visuals and depths for the screen which coorespond to 14005b261ecSmrg * the set which can be used with this version of fb. 14105b261ecSmrg */ 14205b261ecSmrgBool 14335c4bbdfSmrgfbInitVisuals(VisualPtr * visualp, 14435c4bbdfSmrg DepthPtr * depthp, 14535c4bbdfSmrg int *nvisualp, 14635c4bbdfSmrg int *ndepthp, 14735c4bbdfSmrg int *rootDepthp, 14835c4bbdfSmrg VisualID * defaultVisp, unsigned long sizes, int bitsPerRGB) 14905b261ecSmrg{ 15005b261ecSmrg return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp, 15135c4bbdfSmrg defaultVisp, sizes, bitsPerRGB, -1); 15205b261ecSmrg} 153