DIB Engine: fixes clipping, text and more
[wine/hacks.git] / dlls / winedib.drv / palette.c
bloba1aa64804df770b0f9c6af6bcd7548022e722ac2
1 /*
2 * DIBDRV palette objects
4 * Copyright 2009 Massimo Del Fedele
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include "dibdrv.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv);
28 /***********************************************************************
29 * DIBDRV_RealizePalette
31 UINT DIBDRV_RealizePalette( DIBDRVPHYSDEV *physDev, HPALETTE hpal, BOOL primary )
33 UINT res = 0;
35 MAYBE(TRACE("physDev:%p, hpal:%p, primary:%s\n", physDev, hpal, (primary ? "TRUE" : "FALSE")));
37 if(physDev && physDev->hasDIB)
39 /* DIB section selected in, additional (if needed) engine code */
40 ONCE(FIXME("STUB\n"));
41 res = 0;
43 else
45 /* we should in any case call X11 function, as UnrealizePalette() doesn't
46 * take a physDev parameter */
47 res = _DIBDRV_GetDisplayDriver()->pRealizePalette(physDev ? physDev->X11PhysDev : NULL, hpal, primary);
51 return res;
54 /***********************************************************************
55 * DIBDRV_UnrealizePalette
57 BOOL DIBDRV_UnrealizePalette( HPALETTE hpal )
59 BOOL res;
61 MAYBE(TRACE("hpal:%p\n", hpal));
63 /* we should in any case call X11 function, as UnrealizePalette() doesn't
64 * take a physDev parameter */
65 res = _DIBDRV_GetDisplayDriver()->pUnrealizePalette(hpal);
67 /* additional Engine code here, if needed */
68 ONCE(FIXME("STUB\n"));
70 return res;
73 /***********************************************************************
74 * DIBDRV_GetSystemPaletteEntries
76 UINT DIBDRV_GetSystemPaletteEntries( DIBDRVPHYSDEV *physDev, UINT start, UINT count,
77 LPPALETTEENTRY entries )
79 UINT res;
81 MAYBE(TRACE("physDev:%p, start:%d, count:%d, entries:%p\n", physDev, start, count, entries));
83 if(physDev->hasDIB)
85 /* DIB section selected in, use DIB Engine */
86 ONCE(FIXME("STUB\n"));
87 res = 0;
89 else
91 /* DDB selected in, use X11 driver */
92 res = _DIBDRV_GetDisplayDriver()->pGetSystemPaletteEntries(physDev->X11PhysDev, start, count, entries);
94 return res;
97 /***********************************************************************
98 * DIBDRV_GetNearestColor
100 COLORREF DIBDRV_GetNearestColor( DIBDRVPHYSDEV *physDev, COLORREF color )
102 COLORREF res;
104 MAYBE(TRACE("physDev:%p, color:%x\n", physDev, color));
106 if(physDev->hasDIB)
108 /* DIB section selected in, use DIB Engine */
109 ONCE(FIXME("STUB\n"));
110 res = 0;
112 else
114 /* DDB selected in, use X11 driver */
115 res = _DIBDRV_GetDisplayDriver()->pGetNearestColor(physDev->X11PhysDev, color);
117 return res;
120 /***********************************************************************
121 * DIBDRV_RealizeDefaultPalette
123 UINT DIBDRV_RealizeDefaultPalette( DIBDRVPHYSDEV *physDev )
125 UINT res;
126 #ifdef DIBDRV_ENABLE_MAYBE
127 int i;
128 RGBQUAD *q;
129 #endif
131 MAYBE(TRACE("physDev:%p\n", physDev));
133 if(physDev->hasDIB)
135 /* DIB section selected in, use DIB Engine */
136 ONCE(FIXME("STUB\n"));
137 /* HACK - we can't get the dib color table during SelectBitmap since it hasn't
138 been initialized yet. This is called from DC_InitDC so it's a convenient place
139 to grab the color table. */
140 MAYBE(TRACE("Color table size = %d, Color table = %p\n", physDev->physBitmap.colorTableSize, physDev->physBitmap.colorTable));
141 if(!physDev->physBitmap.colorTableGrabbed)
143 MAYBE(TRACE("Grabbing palette\n"));
144 physDev->physBitmap.colorTable = HeapAlloc(GetProcessHeap(), 0, sizeof(physDev->physBitmap.colorTable[0]) * physDev->physBitmap.colorTableSize);
145 GetDIBColorTable(physDev->hdc, 0, physDev->physBitmap.colorTableSize, physDev->physBitmap.colorTable);
146 #ifdef DIBDRV_ENABLE_MAYBE
147 for(i = 0; i < physDev->physBitmap.colorTableSize; i++)
149 q = physDev->physBitmap.colorTable + i;
150 TRACE(" %03d : R%03d G%03d B%03d\n", i, q->rgbRed, q->rgbGreen, q->rgbBlue);
152 #endif
153 physDev->physBitmap.colorTableGrabbed = TRUE;
155 res = 0;
157 else
159 /* DDB selected in, use X11 driver */
160 res = _DIBDRV_GetDisplayDriver()->pRealizeDefaultPalette(physDev->X11PhysDev);
162 return res;
165 BOOL DIBDRV_GetICMProfile(DIBDRVPHYSDEV *physDev, LPDWORD lpcbName, LPWSTR lpszFilename)
167 BOOL res;
169 MAYBE(TRACE("physDev:%p, lpcpName:%p, lpszFilename:%p\n", physDev, lpcbName, lpszFilename));
171 if(physDev->hasDIB)
173 /* DIB section selected in, use DIB Engine */
174 ONCE(FIXME("STUB\n"));
176 res = 0;
178 else
180 /* DDB selected in, use X11 driver */
181 res = _DIBDRV_GetDisplayDriver()->pGetICMProfile(physDev->X11PhysDev, lpcbName, lpszFilename);
183 return res;