- some more code sharing between D3DDevice versions
[wine] / graphics / bitblt.c
1 /*
2  * GDI bit-blit operations
3  *
4  * Copyright 1993, 1994  Alexandre Julliard
5  *
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.
10  *
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.
15  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "gdi.h"
22 #include "wine/debug.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(bitblt);
25
26
27 /***********************************************************************
28  *           PatBlt    (GDI32.@)
29  */
30 BOOL WINAPI PatBlt( HDC hdc, INT left, INT top,
31                         INT width, INT height, DWORD rop)
32 {
33     DC * dc = DC_GetDCUpdate( hdc );
34     BOOL bRet = FALSE;
35
36     if (!dc) return FALSE;
37
38     if (dc->funcs->pPatBlt)
39     {
40         TRACE("%p %d,%d %dx%d %06lx\n", hdc, left, top, width, height, rop );
41         bRet = dc->funcs->pPatBlt( dc->physDev, left, top, width, height, rop );
42     }
43     GDI_ReleaseObj( hdc );
44     return bRet;
45 }
46
47
48 /***********************************************************************
49  *           BitBlt    (GDI32.@)
50  */
51 BOOL WINAPI BitBlt( HDC hdcDst, INT xDst, INT yDst, INT width,
52                     INT height, HDC hdcSrc, INT xSrc, INT ySrc, DWORD rop )
53 {
54     BOOL ret = FALSE;
55     DC *dcDst, *dcSrc;
56
57     if ((dcSrc = DC_GetDCUpdate( hdcSrc ))) GDI_ReleaseObj( hdcSrc );
58     /* FIXME: there is a race condition here */
59     if ((dcDst = DC_GetDCUpdate( hdcDst )))
60     {
61         dcSrc = DC_GetDCPtr( hdcSrc );
62         TRACE("hdcSrc=%p %d,%d %d bpp->hdcDest=%p %d,%d %dx%dx%d rop=%06lx\n",
63               hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->bitsPerPixel : 0,
64               hdcDst, xDst, yDst, width, height, dcDst->bitsPerPixel, rop);
65         if (dcDst->funcs->pBitBlt)
66             ret = dcDst->funcs->pBitBlt( dcDst->physDev, xDst, yDst, width, height,
67                                          dcSrc ? dcSrc->physDev : NULL, xSrc, ySrc, rop );
68         if (dcSrc) GDI_ReleaseObj( hdcSrc );
69         GDI_ReleaseObj( hdcDst );
70     }
71     return ret;
72 }
73
74
75 /***********************************************************************
76  *           StretchBlt    (GDI32.@)
77  */
78 BOOL WINAPI StretchBlt( HDC hdcDst, INT xDst, INT yDst,
79                             INT widthDst, INT heightDst,
80                             HDC hdcSrc, INT xSrc, INT ySrc,
81                             INT widthSrc, INT heightSrc,
82                         DWORD rop )
83 {
84     BOOL ret = FALSE;
85     DC *dcDst, *dcSrc;
86
87     if ((dcSrc = DC_GetDCUpdate( hdcSrc ))) GDI_ReleaseObj( hdcSrc );
88     /* FIXME: there is a race condition here */
89     if ((dcDst = DC_GetDCUpdate( hdcDst )))
90     {
91         dcSrc = DC_GetDCPtr( hdcSrc );
92
93         TRACE("%p %d,%d %dx%dx%d -> %p %d,%d %dx%dx%d rop=%06lx\n",
94               hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
95               dcSrc ? dcSrc->bitsPerPixel : 0, hdcDst, xDst, yDst,
96               widthDst, heightDst, dcDst->bitsPerPixel, rop );
97
98         if (dcSrc) {
99             if (dcDst->funcs->pStretchBlt)
100                 ret = dcDst->funcs->pStretchBlt( dcDst->physDev, xDst, yDst, widthDst, heightDst,
101                                                  dcSrc->physDev, xSrc, ySrc, widthSrc, heightSrc,
102                                                  rop );
103             GDI_ReleaseObj( hdcSrc );
104         }
105         GDI_ReleaseObj( hdcDst );
106     }
107     return ret;
108 }
109
110
111 /***********************************************************************
112  *           MaskBlt [GDI32.@]
113  */
114 BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest,
115                         INT nWidth, INT nHeight, HDC hdcSource,
116                         INT nXSrc, INT nYSrc, HBITMAP hbmMask,
117                         INT xMask, INT yMask, DWORD dwRop)
118 {
119     FIXME("(%p,%d,%d,%d,%d,%p,%d,%d,%p,%d,%d,%ld): stub\n",
120              hdcDest,nXDest,nYDest,nWidth,nHeight,hdcSource,nXSrc,nYSrc,
121              hbmMask,xMask,yMask,dwRop);
122     return 1;
123 }
124
125 /*********************************************************************
126  *      PlgBlt [GDI32.@]
127  *
128  */
129 BOOL WINAPI PlgBlt( HDC hdcDest, const POINT *lpPoint,
130                         HDC hdcSrc, INT nXDest, INT nYDest, INT nWidth,
131                         INT nHeight, HBITMAP hbmMask, INT xMask, INT yMask)
132 {
133     FIXME("PlgBlt, stub\n");
134         return 1;
135 }