configure: Changes from running autconf after previous patch.
[wine/hacks.git] / dlls / winedib.drv / bitmap.c
blob1562137a5efe1ece77a11cb468b1fde703801e9f
1 /*
2 * DIB driver bitmap 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);
29 /****************************************************************************
30 * SelectBitmap (WINEDIB.DRV.@)
32 HBITMAP DIBDRV_SelectBitmap( DIBDRVPHYSDEV *physDev, HBITMAP hbitmap )
34 DIBSECTION dibSection;
35 HBITMAP res;
37 MAYBE(TRACE("physDev:%p, hbitmap:%p\n", physDev, hbitmap));
39 /* try to get the DIBSECTION data from the bitmap */
40 if(GetObjectW(hbitmap, sizeof(DIBSECTION), &dibSection) != sizeof(DIBSECTION))
42 /* not a DIB section, sets it on physDev and use X11 behaviour */
44 physDev->hasDIB = FALSE;
45 physDev->physBitmap = NULL;
46 res = _DIBDRV_GetDisplayDriver()->pSelectBitmap(physDev->X11PhysDev, hbitmap);
47 if(res)
48 physDev->hbitmap = hbitmap;
50 else
52 /* it's a DIB section, sets it on physDev and use DIB Engine behaviour */
54 /* sets the physical bitmap */
55 if((physDev->physBitmap = _BITMAPLIST_Get(hbitmap)) != NULL)
57 physDev->hasDIB = TRUE;
58 physDev->hbitmap = hbitmap;
59 MAYBE(TRACE("physDev->physBitmap:%p(%s)\n", physDev->physBitmap, _DIBDRVBITMAP_GetFormatName(physDev->physBitmap)));
60 res = hbitmap;
62 else
64 ERR("Physical bitmap %p not found in internal list\n", hbitmap);
65 physDev->hbitmap = GetStockObject(DEFAULT_BITMAP);
66 physDev->hasDIB = FALSE;
67 res = 0;
70 return res;
73 /****************************************************************************
74 * DIBDRV_CreateBitmap
76 BOOL DIBDRV_CreateBitmap( DIBDRVPHYSDEV *physDev, HBITMAP hbitmap, LPVOID bmBits )
78 DIBSECTION dibSection;
79 BOOL res;
81 MAYBE(TRACE("physDev:%p, hbitmap:%p, bmBits:%p\n", physDev, hbitmap, bmBits));
83 /* try to get the DIBSECTION data from the bitmap */
84 if(GetObjectW(hbitmap, sizeof(DIBSECTION), &dibSection) == sizeof(BITMAP))
86 /* not a DIB section, use X11 behaviour */
87 res = _DIBDRV_GetDisplayDriver()->pCreateBitmap(physDev->X11PhysDev, hbitmap, bmBits);
89 else
91 /* it's a DIB section, use DIB Engine behaviour - should not happen, but.... */
92 ERR("CreateBitmap() called for a DIB section - shouldn't happen\n");
93 res = TRUE;
95 return res;
98 /***********************************************************************
99 * DIBDRV_DeleteBitmap
101 BOOL DIBDRV_DeleteBitmap( HBITMAP hbitmap )
103 DIBSECTION dibSection;
104 DIBDRVBITMAP *bmp;
105 BOOL res;
107 MAYBE(TRACE("hbitmap:%p\n", hbitmap));
109 /* try to get the DIBSECTION data from the bitmap */
110 if(GetObjectW(hbitmap, sizeof(DIBSECTION), &dibSection) != sizeof(DIBSECTION))
112 /* not a DIB section, use X11 behaviour */
113 res = _DIBDRV_GetDisplayDriver()->pDeleteBitmap(hbitmap);
115 else
117 /* it's a DIB section, use DIB Engine behaviour */
119 /* do not try to delete stock objects */
120 if(hbitmap == GetStockObject(DEFAULT_BITMAP))
121 res = TRUE;
123 /* locates and frees the physical bitmap */
124 else if((bmp = _BITMAPLIST_Remove(hbitmap)) != NULL)
126 _DIBDRVBITMAP_Free(bmp);
127 res = TRUE;
129 else
131 ERR("Physical bitmap %p not found in internal list\n", hbitmap);
132 res = FALSE;
135 return res;
138 /***********************************************************************
139 * DIBDRV_GetBitmapBits
141 LONG DIBDRV_GetBitmapBits( HBITMAP hbitmap, void *buffer, LONG count )
143 LONG res;
145 MAYBE(TRACE("hbitmap:%p, buffer:%p, count:%d\n", hbitmap, buffer, count));
147 /* GetBitmapBits is only valid for DDBs, so use X11 driver */
148 res = _DIBDRV_GetDisplayDriver()->pGetBitmapBits(hbitmap, buffer, count);
150 return res;
153 /******************************************************************************
154 * DIBDRV_SetBitmapBits
156 LONG DIBDRV_SetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count )
158 LONG res;
160 MAYBE(TRACE("hbitmap:%p, bits:%p, count:%d\n", hbitmap, bits, count));
162 /* SetBitmapBits is only valid for DDBs, so use X11 driver */
163 res = _DIBDRV_GetDisplayDriver()->pSetBitmapBits(hbitmap, bits, count);
165 return res;