2 * DIB driver initialization and DC functions.
4 * Copyright 2011 Huw Davies
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
23 #include "gdi_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(dib);
30 /***********************************************************************
33 static BOOL CDECL dibdrv_DeleteDC( PHYSDEV dev )
39 static void calc_shift_and_len(DWORD mask, int *shift, int *len)
44 while ((mask & 1) == 0)
50 while ((mask & 1) == 1)
59 static void init_bit_fields(dib_info *dib, const DWORD *bit_fields)
61 dib->red_mask = bit_fields[0];
62 dib->green_mask = bit_fields[1];
63 dib->blue_mask = bit_fields[2];
64 calc_shift_and_len(dib->red_mask, &dib->red_shift, &dib->red_len);
65 calc_shift_and_len(dib->green_mask, &dib->green_shift, &dib->green_len);
66 calc_shift_and_len(dib->blue_mask, &dib->blue_shift, &dib->blue_len);
69 static BOOL init_dib(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD *bit_fields, void *bits)
71 dib->bit_count = bi->biBitCount;
72 dib->width = bi->biWidth;
73 dib->height = bi->biHeight;
74 dib->stride = ((dib->width * dib->bit_count + 31) >> 3) & ~3;
77 if(dib->height < 0) /* top-down */
79 dib->height = -dib->height;
83 /* bits always points to the top-left corner and the stride is -ve */
84 dib->bits = (BYTE*)dib->bits + (dib->height - 1) * dib->stride;
85 dib->stride = -dib->stride;
88 dib->funcs = &funcs_null;
90 switch(dib->bit_count)
93 init_bit_fields(dib, bit_fields);
94 if(dib->red_mask == 0xff0000 && dib->green_mask == 0x00ff00 && dib->blue_mask == 0x0000ff)
95 dib->funcs = &funcs_8888;
97 dib->funcs = &funcs_32;
101 TRACE("bpp %d not supported, will forward to graphics driver.\n", dib->bit_count);
108 /***********************************************************************
109 * dibdrv_SelectBitmap
111 static HBITMAP CDECL dibdrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
113 PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectBitmap );
114 dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
115 BITMAPOBJ *bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
116 TRACE("(%p, %p)\n", dev, bitmap);
123 if(!init_dib(&pdev->dib, &bmp->dib->dsBmih, bmp->dib->dsBitfields, bmp->dib->dsBm.bmBits))
124 pdev->defer |= DEFER_FORMAT;
126 GDI_ReleaseObj( bitmap );
128 return next->funcs->pSelectBitmap( next, bitmap );
131 const DC_FUNCTIONS dib_driver =
133 NULL, /* pAbortDoc */
134 NULL, /* pAbortPath */
135 NULL, /* pAlphaBlend */
136 NULL, /* pAngleArc */
139 NULL, /* pBeginPath */
140 NULL, /* pChoosePixelFormat */
142 NULL, /* pCloseFigure */
143 NULL, /* pCreateBitmap */
144 NULL, /* pCreateDC */
145 NULL, /* pCreateDIBSection */
146 NULL, /* pDeleteBitmap */
147 dibdrv_DeleteDC, /* pDeleteDC */
148 NULL, /* pDeleteObject */
149 NULL, /* pDescribePixelFormat */
150 NULL, /* pDeviceCapabilities */
155 NULL, /* pEnumDeviceFonts */
156 NULL, /* pEnumICMProfiles */
157 NULL, /* pExcludeClipRect */
158 NULL, /* pExtDeviceMode */
159 NULL, /* pExtEscape */
160 NULL, /* pExtFloodFill */
161 NULL, /* pExtSelectClipRgn */
162 NULL, /* pExtTextOut */
163 NULL, /* pFillPath */
165 NULL, /* pFlattenPath */
166 NULL, /* pFrameRgn */
167 NULL, /* pGdiComment */
168 NULL, /* pGetBitmapBits */
169 NULL, /* pGetCharWidth */
170 NULL, /* pGetDIBits */
171 NULL, /* pGetDeviceCaps */
172 NULL, /* pGetDeviceGammaRamp */
173 NULL, /* pGetICMProfile */
174 NULL, /* pGetNearestColor */
175 NULL, /* pGetPixel */
176 NULL, /* pGetPixelFormat */
177 NULL, /* pGetSystemPaletteEntries */
178 NULL, /* pGetTextExtentExPoint */
179 NULL, /* pGetTextMetrics */
180 NULL, /* pIntersectClipRect */
181 NULL, /* pInvertRgn */
183 NULL, /* pModifyWorldTransform */
185 NULL, /* pOffsetClipRgn */
186 NULL, /* pOffsetViewportOrg */
187 NULL, /* pOffsetWindowOrg */
188 NULL, /* pPaintRgn */
191 NULL, /* pPolyBezier */
192 NULL, /* pPolyBezierTo */
193 NULL, /* pPolyDraw */
194 NULL, /* pPolyPolygon */
195 NULL, /* pPolyPolyline */
197 NULL, /* pPolyline */
198 NULL, /* pPolylineTo */
199 NULL, /* pRealizeDefaultPalette */
200 NULL, /* pRealizePalette */
201 NULL, /* pRectangle */
203 NULL, /* pRestoreDC */
204 NULL, /* pRoundRect */
206 NULL, /* pScaleViewportExt */
207 NULL, /* pScaleWindowExt */
208 dibdrv_SelectBitmap, /* pSelectBitmap */
209 NULL, /* pSelectBrush */
210 NULL, /* pSelectClipPath */
211 NULL, /* pSelectFont */
212 NULL, /* pSelectPalette */
213 dibdrv_SelectPen, /* pSelectPen */
214 NULL, /* pSetArcDirection */
215 NULL, /* pSetBitmapBits */
216 NULL, /* pSetBkColor */
217 NULL, /* pSetBkMode */
218 NULL, /* pSetDCBrushColor */
219 NULL, /* pSetDCPenColor */
220 NULL, /* pSetDIBColorTable */
221 NULL, /* pSetDIBits */
222 NULL, /* pSetDIBitsToDevice */
223 NULL, /* pSetDeviceClipping */
224 NULL, /* pSetDeviceGammaRamp */
225 NULL, /* pSetLayout */
226 NULL, /* pSetMapMode */
227 NULL, /* pSetMapperFlags */
228 NULL, /* pSetPixel */
229 NULL, /* pSetPixelFormat */
230 NULL, /* pSetPolyFillMode */
232 NULL, /* pSetRelAbs */
233 NULL, /* pSetStretchBltMode */
234 NULL, /* pSetTextAlign */
235 NULL, /* pSetTextCharacterExtra */
236 NULL, /* pSetTextColor */
237 NULL, /* pSetTextJustification */
238 NULL, /* pSetViewportExt */
239 NULL, /* pSetViewportOrg */
240 NULL, /* pSetWindowExt */
241 NULL, /* pSetWindowOrg */
242 NULL, /* pSetWorldTransform */
243 NULL, /* pStartDoc */
244 NULL, /* pStartPage */
245 NULL, /* pStretchBlt */
246 NULL, /* pStretchDIBits */
247 NULL, /* pStrokeAndFillPath */
248 NULL, /* pStrokePath */
249 NULL, /* pSwapBuffers */
250 NULL, /* pUnrealizePalette */
251 NULL, /* pWidenPath */
252 NULL, /* pwglCopyContext */
253 NULL, /* pwglCreateContext */
254 NULL, /* pwglCreateContextAttribsARB */
255 NULL, /* pwglDeleteContext */
256 NULL, /* pwglGetProcAddress */
257 NULL, /* pwglGetPbufferDCARB */
258 NULL, /* pwglMakeCurrent */
259 NULL, /* pwglMakeContextCurrentARB */
260 NULL, /* pwglSetPixelFormatWINE */
261 NULL, /* pwglShareLists */
262 NULL, /* pwglUseFontBitmapsA */
263 NULL /* pwglUseFontBitmapsW */