Don't return from overlapped ReadFile on EAGAIN and other non-fatal
[wine/gsoc_dplay.git] / dlls / gdi / wing.c
blobd382b8415c9038eee70dc72494b5cb4bee067307
1 /*
2 * WinG support
4 * Started by Robert Pouliot <krynos@clic.net>
5 */
7 #include "config.h"
9 #include "wine/winuser16.h"
10 #include "bitmap.h"
11 #include "debugtools.h"
12 #include "palette.h"
13 #include "windef.h"
15 DEFAULT_DEBUG_CHANNEL(wing);
18 typedef enum WING_DITHER_TYPE
20 WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
21 } WING_DITHER_TYPE;
23 /*
24 * WinG DIB bitmaps can be selected into DC and then scribbled upon
25 * by GDI functions. They can also be changed directly. This gives us
26 * three choices
27 * - use original WinG 16-bit DLL
28 * requires working 16-bit driver interface
29 * - implement DIB graphics driver from scratch
30 * see wing.zip size
31 * - use shared pixmaps
32 * won't work with some videocards and/or videomodes
33 * 961208 - AK
36 /***********************************************************************
37 * WinGCreateDC (WING.1001)
39 HDC16 WINAPI WinGCreateDC16(void)
41 TRACE("(void)\n");
42 return CreateCompatibleDC16(0);
45 /***********************************************************************
46 * WinGRecommendDIBFormat (WING.1002)
48 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
50 HDC hdc;
51 TRACE("(%p)\n", bmpi);
52 if (!bmpi)
53 return FALSE;
55 hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
56 bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
57 bmpi->bmiHeader.biWidth = 320;
58 bmpi->bmiHeader.biHeight = -1;
59 bmpi->bmiHeader.biPlanes = 1;
60 bmpi->bmiHeader.biBitCount = 8;
61 bmpi->bmiHeader.biCompression = BI_RGB;
62 bmpi->bmiHeader.biSizeImage = 0;
63 bmpi->bmiHeader.biXPelsPerMeter = 0;
64 bmpi->bmiHeader.biYPelsPerMeter = 0;
65 bmpi->bmiHeader.biClrUsed = 0;
66 bmpi->bmiHeader.biClrImportant = 0;
67 DeleteDC(hdc);
68 return TRUE;
71 /***********************************************************************
72 * WinGCreateBitmap (WING.1003)
74 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
75 SEGPTR *bits)
77 TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
78 TRACE(": create %ldx%ldx%d bitmap\n", bmpi->bmiHeader.biWidth,
79 bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
80 return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
83 /***********************************************************************
84 * WinGGetDIBPointer (WING.1004)
86 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
88 BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( hWinGBitmap, BITMAP_MAGIC );
89 SEGPTR res = 0;
91 TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
92 if (!bmp) return 0;
94 if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
96 res = bmp->segptr_bits;
97 GDI_ReleaseObj( hWinGBitmap );
98 return res;
101 /***********************************************************************
102 * WinGSetDIBColorTable (WING.1006)
104 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
105 RGBQUAD *colors)
107 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
108 return SetDIBColorTable16(hdc, start, num, colors);
111 /***********************************************************************
112 * WinGGetDIBColorTable (WING.1005)
114 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
115 RGBQUAD *colors)
117 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
118 return GetDIBColorTable16(hdc, start, num, colors);
121 /***********************************************************************
122 * WinGCreateHalfTonePalette (WING.1007)
124 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
126 HDC hdc = CreateCompatibleDC(0);
127 HPALETTE16 ret = CreateHalftonePalette16(hdc);
128 TRACE("(void)\n");
129 DeleteDC(hdc);
130 return ret;
133 /***********************************************************************
134 * WinGCreateHalfToneBrush (WING.1008)
136 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
137 WING_DITHER_TYPE type)
139 TRACE("(%d,%ld,%d)\n", winDC, col, type);
140 return CreateSolidBrush16(col);
143 /***********************************************************************
144 * WinGStretchBlt (WING.1009)
146 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
147 INT16 widDest, INT16 heiDest,
148 HDC16 srcDC, INT16 xSrc, INT16 ySrc,
149 INT16 widSrc, INT16 heiSrc)
151 BOOL16 retval;
152 TRACE("(%d,%d,...)\n", destDC, srcDC);
153 SetStretchBltMode16 ( destDC, COLORONCOLOR );
154 retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
155 xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
156 SetStretchBltMode16 ( destDC, BLACKONWHITE );
157 return retval;
160 /***********************************************************************
161 * WinGBitBlt (WING.1010)
163 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
164 INT16 widDest, INT16 heiDest, HDC16 srcDC,
165 INT16 xSrc, INT16 ySrc)
167 TRACE("(%d,%d,...)\n", destDC, srcDC);
168 return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
169 xSrc, ySrc, SRCCOPY);