09a0e9b1684c751054c4dbf1aa1abb346e0b0cb2
[reactos.git] / reactos / win32ss / drivers / displays / framebuf / dd.c
1 /*
2 * ReactOS Generic Framebuffer display driver directdraw interface
3 *
4 * Copyright (C) 2006 Magnus Olsen
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 /* Here we put in all 2d api for directdraw and redirect some of them to GDI api */
22
23 #include "framebuf.h"
24
25
26 DWORD CALLBACK
27 DdCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA pccsd)
28 {
29
30 /* We do not support 3d buffer so we fail here */
31 if ((pccsd->lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER) &&
32 (pccsd->lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
33 {
34 pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT;
35 return DDHAL_DRIVER_HANDLED;
36 }
37
38
39 /* Check if another pixel format or not, we fail for now */
40 if (pccsd->bIsDifferentPixelFormat)
41 {
42 /* check the fourcc diffent FOURCC, but we only support BMP for now */
43 //if(pccsd->lpDDSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_FOURCC)
44 //{
45 // /* We do not support other pixel format */
46 // switch (pccsd->lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC)
47 // {
48 // default:
49 // pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT;
50 // return DDHAL_DRIVER_HANDLED;
51 // }
52 //}
53 // /* check the texture support, we do not support testure for now */
54 //else if((pccsd->lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_TEXTURE))
55 //{
56 // /* We do not support texture surface */
57 // pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT;
58 // return DDHAL_DRIVER_HANDLED;
59 //}
60
61 /* Fail */
62 pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT;
63 return DDHAL_DRIVER_HANDLED;
64 }
65
66 pccsd->ddRVal = DD_OK;
67 return DDHAL_DRIVER_HANDLED;
68 }
69
70 DWORD CALLBACK
71 DdCreateSurface(PDD_CREATESURFACEDATA pcsd)
72 {
73 int i;
74
75 if (pcsd->dwSCnt < 1)
76 {
77 pcsd->ddRVal = DDERR_GENERIC;
78 return DDHAL_DRIVER_NOTHANDLED;
79 }
80
81
82 for (i=0; i<(int)pcsd->dwSCnt; i++)
83 {
84 pcsd->lplpSList[i]->lpGbl->lPitch = (DWORD)(pcsd->lplpSList[i]->lpGbl->wWidth *
85 (pcsd->lplpSList[i]->lpGbl->ddpfSurface.dwRGBBitCount / 8));
86
87 pcsd->lplpSList[i]->lpGbl->dwBlockSizeX = pcsd->lplpSList[i]->lpGbl->lPitch *
88 (DWORD)(pcsd->lplpSList[i]->lpGbl->wHeight);
89
90 pcsd->lplpSList[i]->lpGbl->dwBlockSizeY = 1;
91
92 if ( pcsd->lplpSList[i] ->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
93 {
94 /* We maybe should alloc it with EngAlloc
95 for now we trusting ddraw alloc it */
96 pcsd->lplpSList[i]->lpGbl->fpVidMem = 0;
97 }
98 else
99 {
100
101 /* We maybe should alloc it with EngAlloc
102 for now we trusting ddraw alloc it */
103 pcsd->lplpSList[i]->lpGbl->fpVidMem = DDHAL_PLEASEALLOC_BLOCKSIZE;
104 }
105
106 pcsd->lpDDSurfaceDesc->lPitch = pcsd->lplpSList[i]->lpGbl->lPitch;
107 pcsd->lpDDSurfaceDesc->dwFlags |= DDSD_PITCH;
108
109 } // for i
110
111
112
113 pcsd->ddRVal = DD_OK;
114 return DDHAL_DRIVER_HANDLED;
115 }
116