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 init_bit_fields(dib_info *dib, const DWORD *bit_fields)
41 dib->red_mask = bit_fields[0];
42 dib->green_mask = bit_fields[1];
43 dib->blue_mask = bit_fields[2];
46 static BOOL init_dib(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD *bit_fields, void *bits)
48 dib->bit_count = bi->biBitCount;
49 dib->width = bi->biWidth;
50 dib->height = bi->biHeight;
51 dib->stride = ((dib->width * dib->bit_count + 31) >> 3) & ~3;
54 if(dib->height < 0) /* top-down */
56 dib->height = -dib->height;
60 /* bits always points to the top-left corner and the stride is -ve */
61 dib->bits = (BYTE*)dib->bits + (dib->height - 1) * dib->stride;
62 dib->stride = -dib->stride;
65 dib->funcs = &funcs_null;
67 switch(dib->bit_count)
70 init_bit_fields(dib, bit_fields);
71 if(dib->red_mask == 0xff0000 && dib->green_mask == 0x00ff00 && dib->blue_mask == 0x0000ff)
72 dib->funcs = &funcs_8888;
75 TRACE("32 bpp bitmasks not supported, will forward to graphics driver.\n");
81 TRACE("bpp %d not supported, will forward to graphics driver.\n", dib->bit_count);
88 /***********************************************************************
91 static HBITMAP CDECL dibdrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
93 PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectBitmap );
94 dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
95 BITMAPOBJ *bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
96 TRACE("(%p, %p)\n", dev, bitmap);
101 init_dib(&pdev->dib, &bmp->dib->dsBmih, bmp->dib->dsBitfields, bmp->dib->dsBm.bmBits);
103 GDI_ReleaseObj( bitmap );
105 return next->funcs->pSelectBitmap( next, bitmap );
108 const DC_FUNCTIONS dib_driver =
110 NULL, /* pAbortDoc */
111 NULL, /* pAbortPath */
112 NULL, /* pAlphaBlend */
113 NULL, /* pAngleArc */
116 NULL, /* pBeginPath */
117 NULL, /* pChoosePixelFormat */
119 NULL, /* pCloseFigure */
120 NULL, /* pCreateBitmap */
121 NULL, /* pCreateDC */
122 NULL, /* pCreateDIBSection */
123 NULL, /* pDeleteBitmap */
124 dibdrv_DeleteDC, /* pDeleteDC */
125 NULL, /* pDeleteObject */
126 NULL, /* pDescribePixelFormat */
127 NULL, /* pDeviceCapabilities */
132 NULL, /* pEnumDeviceFonts */
133 NULL, /* pEnumICMProfiles */
134 NULL, /* pExcludeClipRect */
135 NULL, /* pExtDeviceMode */
136 NULL, /* pExtEscape */
137 NULL, /* pExtFloodFill */
138 NULL, /* pExtSelectClipRgn */
139 NULL, /* pExtTextOut */
140 NULL, /* pFillPath */
142 NULL, /* pFlattenPath */
143 NULL, /* pFrameRgn */
144 NULL, /* pGdiComment */
145 NULL, /* pGetBitmapBits */
146 NULL, /* pGetCharWidth */
147 NULL, /* pGetDIBits */
148 NULL, /* pGetDeviceCaps */
149 NULL, /* pGetDeviceGammaRamp */
150 NULL, /* pGetICMProfile */
151 NULL, /* pGetNearestColor */
152 NULL, /* pGetPixel */
153 NULL, /* pGetPixelFormat */
154 NULL, /* pGetSystemPaletteEntries */
155 NULL, /* pGetTextExtentExPoint */
156 NULL, /* pGetTextMetrics */
157 NULL, /* pIntersectClipRect */
158 NULL, /* pInvertRgn */
160 NULL, /* pModifyWorldTransform */
162 NULL, /* pOffsetClipRgn */
163 NULL, /* pOffsetViewportOrg */
164 NULL, /* pOffsetWindowOrg */
165 NULL, /* pPaintRgn */
168 NULL, /* pPolyBezier */
169 NULL, /* pPolyBezierTo */
170 NULL, /* pPolyDraw */
171 NULL, /* pPolyPolygon */
172 NULL, /* pPolyPolyline */
174 NULL, /* pPolyline */
175 NULL, /* pPolylineTo */
176 NULL, /* pRealizeDefaultPalette */
177 NULL, /* pRealizePalette */
178 NULL, /* pRectangle */
180 NULL, /* pRestoreDC */
181 NULL, /* pRoundRect */
183 NULL, /* pScaleViewportExt */
184 NULL, /* pScaleWindowExt */
185 dibdrv_SelectBitmap, /* pSelectBitmap */
186 NULL, /* pSelectBrush */
187 NULL, /* pSelectClipPath */
188 NULL, /* pSelectFont */
189 NULL, /* pSelectPalette */
190 NULL, /* pSelectPen */
191 NULL, /* pSetArcDirection */
192 NULL, /* pSetBitmapBits */
193 NULL, /* pSetBkColor */
194 NULL, /* pSetBkMode */
195 NULL, /* pSetDCBrushColor */
196 NULL, /* pSetDCPenColor */
197 NULL, /* pSetDIBColorTable */
198 NULL, /* pSetDIBits */
199 NULL, /* pSetDIBitsToDevice */
200 NULL, /* pSetDeviceClipping */
201 NULL, /* pSetDeviceGammaRamp */
202 NULL, /* pSetLayout */
203 NULL, /* pSetMapMode */
204 NULL, /* pSetMapperFlags */
205 NULL, /* pSetPixel */
206 NULL, /* pSetPixelFormat */
207 NULL, /* pSetPolyFillMode */
209 NULL, /* pSetRelAbs */
210 NULL, /* pSetStretchBltMode */
211 NULL, /* pSetTextAlign */
212 NULL, /* pSetTextCharacterExtra */
213 NULL, /* pSetTextColor */
214 NULL, /* pSetTextJustification */
215 NULL, /* pSetViewportExt */
216 NULL, /* pSetViewportOrg */
217 NULL, /* pSetWindowExt */
218 NULL, /* pSetWindowOrg */
219 NULL, /* pSetWorldTransform */
220 NULL, /* pStartDoc */
221 NULL, /* pStartPage */
222 NULL, /* pStretchBlt */
223 NULL, /* pStretchDIBits */
224 NULL, /* pStrokeAndFillPath */
225 NULL, /* pStrokePath */
226 NULL, /* pSwapBuffers */
227 NULL, /* pUnrealizePalette */
228 NULL, /* pWidenPath */
229 NULL, /* pwglCopyContext */
230 NULL, /* pwglCreateContext */
231 NULL, /* pwglCreateContextAttribsARB */
232 NULL, /* pwglDeleteContext */
233 NULL, /* pwglGetProcAddress */
234 NULL, /* pwglGetPbufferDCARB */
235 NULL, /* pwglMakeCurrent */
236 NULL, /* pwglMakeContextCurrentARB */
237 NULL, /* pwglSetPixelFormatWINE */
238 NULL, /* pwglShareLists */
239 NULL, /* pwglUseFontBitmapsA */
240 NULL /* pwglUseFontBitmapsW */