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 DWORD CALLBACK 26 DdCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA pccsd) 27 { 28 29 /* We do not support 3d buffer so we fail here */ 30 if ((pccsd->lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER) && 31 (pccsd->lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) 32 { 33 pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT; 34 return DDHAL_DRIVER_HANDLED; 35 } 36 37 38 /* Check if another pixel format or not, we fail for now */ 39 if (pccsd->bIsDifferentPixelFormat) 40 { 41 /* check the fourcc diffent FOURCC, but we only support BMP for now */ 42 //if(pccsd->lpDDSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_FOURCC) 43 //{ 44 // /* We do not support other pixel format */ 45 // switch (pccsd->lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC) 46 // { 47 // default: 48 // pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT; 49 // return DDHAL_DRIVER_HANDLED; 50 // } 51 //} 52 // /* check the texture support, we do not support testure for now */ 53 //else if((pccsd->lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)) 54 //{ 55 // /* We do not support texture surface */ 56 // pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT; 57 // return DDHAL_DRIVER_HANDLED; 58 //} 59 60 /* Fail */ 61 pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT; 62 return DDHAL_DRIVER_HANDLED; 63 } 64 65 pccsd->ddRVal = DD_OK; 66 return DDHAL_DRIVER_HANDLED; 67 } 68 69 DWORD CALLBACK 70 DdCreateSurface(PDD_CREATESURFACEDATA pcsd) 71 { 72 int i; 73 74 if (pcsd->dwSCnt < 1) 75 { 76 pcsd->ddRVal = DDERR_GENERIC; 77 return DDHAL_DRIVER_NOTHANDLED; 78 } 79 80 81 for (i=0; i<(int)pcsd->dwSCnt; i++) 82 { 83 pcsd->lplpSList[i]->lpGbl->lPitch = (DWORD)(pcsd->lplpSList[i]->lpGbl->wWidth * 84 (pcsd->lplpSList[i]->lpGbl->ddpfSurface.dwRGBBitCount / 8)); 85 86 pcsd->lplpSList[i]->lpGbl->dwBlockSizeX = pcsd->lplpSList[i]->lpGbl->lPitch * 87 (DWORD)(pcsd->lplpSList[i]->lpGbl->wHeight); 88 89 pcsd->lplpSList[i]->lpGbl->dwBlockSizeY = 1; 90 91 if ( pcsd->lplpSList[i] ->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) 92 { 93 /* We maybe should alloc it with EngAlloc 94 for now we trusting ddraw alloc it */ 95 pcsd->lplpSList[i]->lpGbl->fpVidMem = 0; 96 } 97 else 98 { 99 100 /* We maybe should alloc it with EngAlloc 101 for now we trusting ddraw alloc it */ 102 pcsd->lplpSList[i]->lpGbl->fpVidMem = DDHAL_PLEASEALLOC_BLOCKSIZE; 103 } 104 105 pcsd->lpDDSurfaceDesc->lPitch = pcsd->lplpSList[i]->lpGbl->lPitch; 106 pcsd->lpDDSurfaceDesc->dwFlags |= DDSD_PITCH; 107 108 } // for i 109 110 111 112 pcsd->ddRVal = DD_OK; 113 return DDHAL_DRIVER_HANDLED; 114 } 115