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