Xcmsint.h revision 1ab64890
1/* $Xorg: Xcmsint.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */ 2 3/* 4 * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc. 5 * All Rights Reserved 6 * 7 * This file is a component of an X Window System-specific implementation 8 * of Xcms based on the TekColor Color Management System. Permission is 9 * hereby granted to use, copy, modify, sell, and otherwise distribute this 10 * software and its documentation for any purpose and without fee, provided 11 * that this copyright, permission, and disclaimer notice is reproduced in 12 * all copies of this software and in supporting documentation. TekColor 13 * is a trademark of Tektronix, Inc. 14 * 15 * Tektronix makes no representation about the suitability of this software 16 * for any purpose. It is provided "as is" and with all faults. 17 * 18 * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE, 19 * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY 21 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 22 * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF 23 * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 24 * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE. 25 * 26 * 27 * DESCRIPTION 28 * Private include file for Color Management System. 29 * (i.e., for API internal use only) 30 * 31 */ 32/* $XFree86: xc/lib/X11/Xcmsint.h,v 3.3 2001/07/25 15:04:44 dawes Exp $ */ 33 34#ifndef _XCMSINT_H_ 35#define _XCMSINT_H_ 36 37#include <X11/Xcms.h> 38 39/* 40 * DEFINES 41 */ 42 43 /* 44 * Private Status Value 45 */ 46#define _XCMS_NEWNAME -1 47 48 /* 49 * Color Space ID's are of XcmsColorFormat type. 50 * 51 * bit 31 52 * 0 == Device-Independent 53 * 1 == Device-Dependent 54 * 55 * bit 30: 56 * 0 == Registered with X Consortium 57 * 1 == Unregistered 58 */ 59#define XCMS_DD_ID(id) ((id) & (XcmsColorFormat)0x80000000) 60#define XCMS_DI_ID(id) (!((id) & (XcmsColorFormat)0x80000000)) 61#define XCMS_UNREG_ID(id) ((id) & (XcmsColorFormat)0x40000000) 62#define XCMS_REG_ID(id) (!((id) & (XcmsColorFormat)0x40000000)) 63#define XCMS_FIRST_REG_DI_ID (XcmsColorFormat)0x00000001 64#define XCMS_FIRST_UNREG_DI_ID (XcmsColorFormat)0x40000000 65#define XCMS_FIRST_REG_DD_ID (XcmsColorFormat)0x80000000 66#define XCMS_FIRST_UNREG_DD_ID (XcmsColorFormat)0xc0000000 67 68/* 69 * TYPEDEFS 70 */ 71 72 /* 73 * Structure for caching Colormap info. 74 * This is provided for the Xlib modifications to: 75 * XAllocNamedColor() 76 * XLookupColor() 77 * XParseColor() 78 * XStoreNamedColor() 79 */ 80typedef struct _XcmsCmapRec { 81 Colormap cmapID; 82 Display *dpy; 83 Window windowID; 84 Visual *visual; 85 struct _XcmsCCC *ccc; 86 struct _XcmsCmapRec *pNext; 87} XcmsCmapRec; 88 89 /* 90 * Intensity Record (i.e., value / intensity tuple) 91 */ 92typedef struct _IntensityRec { 93 unsigned short value; 94 XcmsFloat intensity; 95} IntensityRec; 96 97 /* 98 * Intensity Table 99 */ 100typedef struct _IntensityTbl { 101 IntensityRec *pBase; 102 unsigned int nEntries; 103} IntensityTbl; 104 105 /* 106 * Structure for storing per-Visual Intensity Tables (aka gamma maps). 107 */ 108typedef struct _XcmsIntensityMap { 109 VisualID visualID; 110 XPointer screenData; /* pointer to corresponding Screen Color*/ 111 /* Characterization Data */ 112 void (*pFreeScreenData)(XPointer pScreenDataTemp); /* Function that frees a Screen */ 113 /* structure. */ 114 struct _XcmsIntensityMap *pNext; 115} XcmsIntensityMap; 116 117 118 /* 119 * Structure for storing "registered" color space prefix/ID 120 */ 121typedef struct _XcmsRegColorSpaceEntry { 122 const char *prefix; /* Color Space prefix (e.g., "CIEXYZ:") */ 123 XcmsColorFormat id; /* Color Space ID (e.g., XcmsCIEXYZFormat) */ 124} XcmsRegColorSpaceEntry; 125 126 127 /* 128 * Xcms Per Display (i.e. connection) related data 129 */ 130typedef struct _XcmsPerDpyInfo { 131 132 XcmsCCC paDefaultCCC; /* based on default visual of screen */ 133 /* 134 * Pointer to an array of XcmsCCC structures, one for 135 * each screen. 136 */ 137 XcmsCmapRec *pClientCmaps; /* Pointer to linked list of XcmsCmapRec's */ 138 139} XcmsPerDpyInfo, *XcmsPerDpyInfoPtr; 140 141/* 142 * DEFINES 143 */ 144 145#define XDCCC_NUMBER 0x8000000L /* 2**27 per XDCCC */ 146 147#ifdef GRAY 148#define XDCCC_SCREENWHITEPT_ATOM_NAME "XDCCC_GRAY_SCREENWHITEPOINT" 149#define XDCCC_GRAY_CORRECT_ATOM_NAME "XDCCC_GRAY_CORRECTION" 150#endif /* GRAY */ 151 152#ifndef _ConversionValues 153typedef struct _ConversionValues { 154 IntensityTbl IntensityTbl; 155} ConversionValues; 156#endif 157 158#ifdef GRAY 159typedef struct { 160 IntensityTbl *IntensityTbl; 161} GRAY_SCCData; 162#endif /* GRAY */ 163 164/* 165 * DEFINES 166 */ 167 168#define XDCCC_MATRIX_ATOM_NAME "XDCCC_LINEAR_RGB_MATRICES" 169#define XDCCC_CORRECT_ATOM_NAME "XDCCC_LINEAR_RGB_CORRECTION" 170 171typedef struct { 172 XcmsFloat XYZtoRGBmatrix[3][3]; 173 XcmsFloat RGBtoXYZmatrix[3][3]; 174 IntensityTbl *pRedTbl; 175 IntensityTbl *pGreenTbl; 176 IntensityTbl *pBlueTbl; 177} LINEAR_RGB_SCCData; 178 179/* function prototypes */ 180extern XcmsCmapRec * 181_XcmsAddCmapRec( 182 Display *dpy, 183 Colormap cmap, 184 Window windowID, 185 Visual *visual); 186extern void 187_XcmsRGB_to_XColor( 188 XcmsColor *pColors, 189 XColor *pXColors, 190 unsigned int nColors); 191extern Status 192_XcmsResolveColorString ( 193 XcmsCCC ccc, 194 const char **color_string, 195 XcmsColor *pColor_exact_return, 196 XcmsColorFormat result_format); 197extern void 198_XUnresolveColor( 199 XcmsCCC ccc, 200 XColor *pXColor); 201/* 202 * DESCRIPTION 203 * Include file for defining the math macros used in the 204 * XCMS source. Instead of using math library routines 205 * directly, XCMS uses macros so that based on the 206 * definitions here, vendors and sites can specify exactly 207 * what routine will be called (those from libm.a or their 208 * custom routines). If not defined to math library routines 209 * (e.g., sqrt in libm.a), then the client is not forced to 210 * be linked with -lm. 211 */ 212 213#define XCMS_ATAN(x) _XcmsArcTangent(x) 214#define XCMS_COS(x) _XcmsCosine(x) 215#define XCMS_CUBEROOT(x) _XcmsCubeRoot(x) 216#define XCMS_FABS(x) ((x) < 0.0 ? -(x) : (x)) 217#define XCMS_SIN(x) _XcmsSine(x) 218#define XCMS_SQRT(x) _XcmsSquareRoot(x) 219#define XCMS_TAN(x) (XCMS_SIN(x) / XCMS_COS(x)) 220 221double _XcmsArcTangent(double a); 222double _XcmsCosine(double a); 223double _XcmsCubeRoot(double a); 224double _XcmsSine(double a); 225double _XcmsSquareRoot(double a); 226 227/* 228 * DEFINES FOR GAMUT COMPRESSION AND QUERY ROUTINES 229 */ 230#ifndef PI 231# ifdef M_PI 232# define PI M_PI 233# else 234# define PI 3.14159265358979323846264338327950 235# endif /* M_PI */ 236#endif /* PI */ 237#ifndef degrees 238# define degrees(r) ((XcmsFloat)(r) * 180.0 / PI) 239#endif /* degrees */ 240#ifndef radians 241# define radians(d) ((XcmsFloat)(d) * PI / 180.0) 242#endif /* radians */ 243 244#define XCMS_CIEUSTAROFHUE(h,c) \ 245((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \ 246((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT((XCMS_TAN(h) * XCMS_TAN(h)) + \ 247(XcmsFloat)1.0))) 248#define XCMS_CIEVSTAROFHUE(h,c) \ 249((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \ 250((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT(((XcmsFloat)1.0 / \ 251(XcmsFloat)(XCMS_TAN(h) * XCMS_TAN(h))) + (XcmsFloat)1.0))) 252/* this hue is returned in radians */ 253#define XCMS_CIELUV_PMETRIC_HUE(u,v) \ 254(((u) != 0.0) ? XCMS_ATAN( (v) / (u)) : ((v >= 0.0) ? PI / 2 : -(PI / 2))) 255#define XCMS_CIELUV_PMETRIC_CHROMA(u,v) XCMS_SQRT(((u)*(u)) + ((v)*(v))) 256 257#define XCMS_CIEASTAROFHUE(h,c) XCMS_CIEUSTAROFHUE((h), (c)) 258#define XCMS_CIEBSTAROFHUE(h,c) XCMS_CIEVSTAROFHUE((h), (c)) 259#define XCMS_CIELAB_PMETRIC_HUE(a,b) XCMS_CIELUV_PMETRIC_HUE((a), (b)) 260#define XCMS_CIELAB_PMETRIC_CHROMA(a,b) XCMS_CIELUV_PMETRIC_CHROMA((a), (b)) 261 262#endif /* _XCMSINT_H_ */ 263