DIB Engine: Fork DDB-DIB behaviour
[wine/hacks.git] / dlls / winedib.drv / bitmap.c
blobdf7c03a22d877c52079497cce01575979789f7ff
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 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(BITMAP))
42 /* not a DIB section, sets it on physDev and use X11 behaviour */
43 physDev->hasDIB = FALSE;
44 res = _DIBDRV_GetDisplayDriver()->pSelectBitmap(physDev->X11PhysDev, hbitmap);
45 if(res)
46 physDev->hbitmap = hbitmap;
48 else
50 /* it's a DIB section, sets it on physDev and use DIB Engine behaviour */
51 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
52 physDev->hasDIB = TRUE;
53 res = _DIBDRV_GetDisplayDriver()->pSelectBitmap(physDev->X11PhysDev, hbitmap);
54 if(res)
55 physDev->hbitmap = hbitmap;
57 return res;
61 /****************************************************************************
62 * DIBDRV_CreateBitmap
64 BOOL DIBDRV_CreateBitmap( DIBDRVPHYSDEV *physDev, HBITMAP hbitmap, LPVOID bmBits )
66 DIBSECTION dibSection;
67 BOOL res;
69 TRACE("physDev:%p, hbitmap:%p, bmBits:%p\n", physDev, hbitmap, bmBits);
71 /* try to get the DIBSECTION data from the bitmap */
72 if(GetObjectW(hbitmap, sizeof(DIBSECTION), &dibSection) == sizeof(BITMAP))
74 /* not a DIB section, use X11 behaviour */
75 res = _DIBDRV_GetDisplayDriver()->pCreateBitmap(physDev->X11PhysDev, hbitmap, bmBits);
77 else
79 /* it's a DIB section, use DIB Engine behaviour */
80 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
81 res = _DIBDRV_GetDisplayDriver()->pCreateBitmap(physDev->X11PhysDev, hbitmap, bmBits);
83 return res;
86 /***********************************************************************
87 * DIBDRV_DeleteBitmap
89 BOOL DIBDRV_DeleteBitmap( HBITMAP hbitmap )
91 DIBSECTION dibSection;
92 BOOL res;
94 TRACE("hbitmap:%p\n", hbitmap);
96 /* try to get the DIBSECTION data from the bitmap */
97 if(GetObjectW(hbitmap, sizeof(DIBSECTION), &dibSection) == sizeof(BITMAP))
99 /* not a DIB section, use X11 behaviour */
100 res = _DIBDRV_GetDisplayDriver()->pDeleteBitmap(hbitmap);
102 else
104 /* it's a DIB section, use DIB Engine behaviour */
105 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
106 res = _DIBDRV_GetDisplayDriver()->pDeleteBitmap(hbitmap);
108 return res;
111 /***********************************************************************
112 * DIBDRV_GetBitmapBits
114 LONG DIBDRV_GetBitmapBits( HBITMAP hbitmap, void *buffer, LONG count )
116 LONG res;
118 TRACE("hbitmap:%p, buffer:%p, count:%d\n", hbitmap, buffer, count);
120 /* GetBitmapBits is only valid for DDBs, so use X11 driver */
121 res = _DIBDRV_GetDisplayDriver()->pGetBitmapBits(hbitmap, buffer, count);
123 return res;
126 /******************************************************************************
127 * DIBDRV_SetBitmapBits
129 LONG DIBDRV_SetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count )
131 LONG res;
133 TRACE("hbitmap:%p, bits:%p, count:%d\n", hbitmap, bits, count);
135 /* SetBitmapBits is only valid for DDBs, so use X11 driver */
136 res = _DIBDRV_GetDisplayDriver()->pSetBitmapBits(hbitmap, bits, count);
138 return res;