Added the ability to see names of the virtual key codes.
[wine] / graphics / bitblt.c
1 /*
2  * GDI bit-blit operations
3  *
4  * Copyright 1993, 1994  Alexandre Julliard
5  */
6
7 #include "gdi.h"
8 #include "debugtools.h"
9
10 DEFAULT_DEBUG_CHANNEL(bitblt);
11
12
13 /***********************************************************************
14  *           PatBlt16    (GDI.29)
15  */
16 BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
17                         INT16 width, INT16 height, DWORD rop)
18 {
19     return PatBlt( hdc, left, top, width, height, rop );
20 }
21
22
23 /***********************************************************************
24  *           PatBlt    (GDI32.260)
25  */
26 BOOL WINAPI PatBlt( HDC hdc, INT left, INT top,
27                         INT width, INT height, DWORD rop)
28 {
29     DC * dc = DC_GetDCUpdate( hdc );
30     BOOL bRet = FALSE;
31
32     if (!dc) return FALSE;
33
34     if (dc->funcs->pPatBlt)
35     {
36         TRACE("%04x %d,%d %dx%d %06lx\n", hdc, left, top, width, height, rop );
37         bRet = dc->funcs->pPatBlt( dc, left, top, width, height, rop );
38     }
39     GDI_ReleaseObj( hdc );
40     return bRet;
41 }
42
43
44 /***********************************************************************
45  *           BitBlt16    (GDI.34)
46  */
47 BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
48                         INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
49                         DWORD rop )
50 {
51     return BitBlt( hdcDst, xDst, yDst, width, height, hdcSrc, xSrc, ySrc, rop );
52 }
53
54
55 /***********************************************************************
56  *           BitBlt    (GDI32.10)
57  */
58 BOOL WINAPI BitBlt( HDC hdcDst, INT xDst, INT yDst, INT width,
59                     INT height, HDC hdcSrc, INT xSrc, INT ySrc, DWORD rop )
60 {
61     BOOL ret = FALSE;
62     DC *dcDst, *dcSrc;
63
64     if ((dcSrc = DC_GetDCUpdate( hdcSrc ))) GDI_ReleaseObj( hdcSrc );
65     /* FIXME: there is a race condition here */
66     if ((dcDst = DC_GetDCUpdate( hdcDst )))
67     {
68         dcSrc = DC_GetDCPtr( hdcSrc );
69         TRACE("hdcSrc=%04x %d,%d %d bpp->hdcDest=%04x %d,%d %dx%dx%d rop=%06lx\n",
70               hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->bitsPerPixel : 0,
71               hdcDst, xDst, yDst, width, height, dcDst->bitsPerPixel, rop);
72         if (dcDst->funcs->pBitBlt)
73             ret = dcDst->funcs->pBitBlt( dcDst, xDst, yDst, width, height,
74                                          dcSrc, xSrc, ySrc, rop );
75         if (dcSrc) GDI_ReleaseObj( hdcSrc );
76         GDI_ReleaseObj( hdcDst );
77     }
78     return ret;
79 }
80
81
82 /***********************************************************************
83  *           StretchBlt16    (GDI.35)
84  */
85 BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
86                             INT16 widthDst, INT16 heightDst,
87                             HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
88                             INT16 widthSrc, INT16 heightSrc, DWORD rop )
89 {
90     return StretchBlt( hdcDst, xDst, yDst, widthDst, heightDst,
91                        hdcSrc, xSrc, ySrc, widthSrc, heightSrc, rop );
92 }
93
94
95 /***********************************************************************
96  *           StretchBlt    (GDI32.350)
97  */
98 BOOL WINAPI StretchBlt( HDC hdcDst, INT xDst, INT yDst,
99                             INT widthDst, INT heightDst,
100                             HDC hdcSrc, INT xSrc, INT ySrc,
101                             INT widthSrc, INT heightSrc, 
102                         DWORD rop )
103 {
104     BOOL ret = FALSE;
105     DC *dcDst, *dcSrc;
106
107     if ((dcSrc = DC_GetDCUpdate( hdcSrc ))) GDI_ReleaseObj( hdcSrc );
108     /* FIXME: there is a race condition here */
109     if ((dcDst = DC_GetDCUpdate( hdcDst )))
110     {
111         dcSrc = DC_GetDCPtr( hdcSrc );
112
113         TRACE("%04x %d,%d %dx%dx%d -> %04x %d,%d %dx%dx%d rop=%06lx\n",
114               hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
115               dcSrc ? dcSrc->bitsPerPixel : 0, hdcDst, xDst, yDst,
116               widthDst, heightDst, dcDst->bitsPerPixel, rop );
117
118         if (dcSrc) {
119             if (dcDst->funcs->pStretchBlt)
120                 ret = dcDst->funcs->pStretchBlt( dcDst, xDst, yDst, widthDst, heightDst,
121                                                  dcSrc, xSrc, ySrc, widthSrc, heightSrc, rop );
122             GDI_ReleaseObj( hdcSrc );
123         }
124         GDI_ReleaseObj( hdcDst );
125     }
126     return ret;
127 }
128
129
130 /***********************************************************************
131  *           FastWindowFrame    (GDI.400)
132  */
133 BOOL16 WINAPI FastWindowFrame16( HDC16 hdc, const RECT16 *rect,
134                                INT16 width, INT16 height, DWORD rop )
135 {
136     HBRUSH hbrush = SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
137     PatBlt( hdc, rect->left, rect->top,
138               rect->right - rect->left - width, height, rop );
139     PatBlt( hdc, rect->left, rect->top + height, width,
140               rect->bottom - rect->top - height, rop );
141     PatBlt( hdc, rect->left + width, rect->bottom - 1,
142               rect->right - rect->left - width, -height, rop );
143     PatBlt( hdc, rect->right - 1, rect->top, -width,
144               rect->bottom - rect->top - height, rop );
145     SelectObject( hdc, hbrush );
146     return TRUE;
147
148 }
149
150
151 /***********************************************************************
152  *           MaskBlt [GDI32.252]
153  */
154 BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest,
155                         INT nWidth, INT nHeight, HDC hdcSource,
156                         INT nXSrc, INT nYSrc, HBITMAP hbmMask,
157                         INT xMask, INT yMask, DWORD dwRop)
158 {
159     FIXME("(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%ld): stub\n",
160              hdcDest,nXDest,nYDest,nWidth,nHeight,hdcSource,nXSrc,nYSrc,
161              hbmMask,xMask,yMask,dwRop);
162     return 1;
163 }
164   
165 /*********************************************************************
166  *      PlgBlt [GDI.267]
167  *
168  */
169 BOOL WINAPI PlgBlt( HDC hdcDest, const POINT *lpPoint,
170                         HDC hdcSrc, INT nXDest, INT nYDest, INT nWidth,
171                         INT nHeight, HBITMAP hbmMask, INT xMask, INT yMask)
172 {
173     FIXME("PlgBlt, stub\n");
174         return 1;
175 }
176