ReactOS 0.4.16-dev-297-gc569aee
ddenable.c
Go to the documentation of this file.
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#include "framebuf.h"
22
25{
26 PPDEV ppdev = (PPDEV)dhpdev;
27 ppdev->bDDInitialized = FALSE;
28 /* Add Clean up code here if we need it
29 when we shout down directx interface */
30}
31
34 IN DHPDEV dhpdev,
38{
39 PPDEV ppdev = (PPDEV)dhpdev;
40
41 if (ppdev->bDDInitialized)
42 {
43 return TRUE;
44 }
45
46 /* Setup pixel format */
47 ppdev->ddpfDisplay.dwSize = sizeof( DDPIXELFORMAT );
48 ppdev->ddpfDisplay.dwFourCC = 0;
49
50 ppdev->ddpfDisplay.dwRBitMask = ppdev->RedMask;
51 ppdev->ddpfDisplay.dwGBitMask = ppdev->GreenMask;
52 ppdev->ddpfDisplay.dwBBitMask = ppdev->BlueMask;
53
57
58 ppdev->pvmList = NULL;
59
60 switch(ppdev->iDitherFormat)
61 {
62 case BMF_8BPP:
64 break;
65
66 case BMF_16BPP:
67 switch(ppdev->RedMask)
68 {
69 case 0x7C00:
70 ppdev->ddpfDisplay.dwRGBAlphaBitMask = 0x8000;
71 break;
72
73 default:
74 break;
75 }
76 break;
77
78 case BMF_24BPP:
79 break;
80
81 case BMF_32BPP:
82 ppdev->ddpfDisplay.dwRGBAlphaBitMask = 0xff000000;
83 break;
84
85 default:
86 /* FIXME unknown pixel bits */
88 break;
89 }
90
91 if (pCallBacks != NULL)
92 {
94
95 /* FILL pCallBacks with hal stuff */
96 pCallBacks->dwSize = sizeof(DDHAL_DDCALLBACKS);
99
100 /* Fill in the HAL Callback flags */
102 }
103
104 if (pSurfaceCallBacks != NULL)
105 {
107
108 /* FILL pSurfaceCallBacks with hal stuff */
109 // pSurfaceCallBacks.dwSize = sizeof(DDHAL_DDSURFACECALLBACKS);
110 // pSurfaceCallBacks.DestroySurface = DdDestroySurface;
111 // pSurfaceCallBacks.Lock = DdLock;
112 // pSurfaceCallBacks.Blt = DdBlt;
113
114 // pSurfaceCallBacks->dwFlags = DDHAL_SURFCB32_DESTROYSURFACE | DDHAL_SURFCB32_LOCK | DDHAL_SURFCB32_BLT ;
115 }
116
117 if (pPaletteCallBacks != NULL)
118 {
120 /* FILL pPaletteCallBacks with hal stuff */
121 /* We will not support this callback in the framebuf.dll */
122 }
123
124
125 /* Fixme fill the ppdev->dxHalInfo with the info we need */
126 ppdev->bDDInitialized = TRUE;
127 return ppdev->bDDInitialized;
128}
129
132 IN DHPDEV dhpdev,
138{
139 PPDEV ppdev = (PPDEV)dhpdev;
140 LONG i;
141 DWORD heap = 1; /* we always alloc one heap */
142 BOOL bDDrawHeap = FALSE;
143
144 if (ppdev == NULL)
145 return FALSE;
146
147 /* check so pHalInfo, pdwNumHeaps, pdwNumFourCCCodes is not NULL
148 pdwFourCC and pvmList can be null
149 */
150
151 if (pHalInfo == NULL)
152 return FALSE;
153
154 if (pdwNumHeaps == NULL)
155 return FALSE;
156
157 if (pdwNumFourCCCodes == NULL)
158 return FALSE;
159
160 /* Setup heap */
161 if ( (ppdev->ScreenWidth < ppdev->MemWidth) || (ppdev->ScreenHeight < ppdev->MemHeight))
162 {
163 bDDrawHeap = TRUE;
164 heap++;
165 }
166
167 ppdev->dwHeap = heap;
168 *pdwNumHeaps = heap;
169
170 /* We do not support other fourcc */
172
173
174 /*
175 check see if pvmList and pdwFourCC are frist call
176 or frist. Secon call we fill in pHalInfo info
177 */
178
179 if(!(pvmList && pdwFourCC))
180 {
181
183 pHalInfo->dwSize = sizeof(DD_HALINFO);
184
187
193
195
197
199
200 pHalInfo->ddCaps.dwSVBCaps = DDCAPS_BLT;
201 pHalInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM | DDSCAPS_NONLOCALVIDMEM;
202
203 /* Calc how much memmory is left on the video cards memmory */
204 pHalInfo->ddCaps.dwVidMemTotal = (ppdev->MemHeight - ppdev->ScreenHeight) * ppdev->ScreenDelta;
205
206 /* fill in some basic info that we need */
207 pHalInfo->vmiData.pvPrimary = ppdev->ScreenPtr;
208 pHalInfo->vmiData.dwDisplayWidth = ppdev->ScreenWidth;
209 pHalInfo->vmiData.dwDisplayHeight = ppdev->ScreenHeight;
210 pHalInfo->vmiData.lDisplayPitch = ppdev->ScreenDelta;
211 pHalInfo->vmiData.ddpfDisplay.dwSize = sizeof(DDPIXELFORMAT);
212 pHalInfo->vmiData.ddpfDisplay.dwFlags = DDPF_RGB;
213 pHalInfo->vmiData.ddpfDisplay.dwRGBBitCount = ppdev->BitsPerPixel;
214 pHalInfo->vmiData.ddpfDisplay.dwRBitMask = ppdev->RedMask;
215 pHalInfo->vmiData.ddpfDisplay.dwGBitMask = ppdev->GreenMask;
216 pHalInfo->vmiData.ddpfDisplay.dwBBitMask = ppdev->BlueMask;
217 pHalInfo->vmiData.dwOffscreenAlign = 4;
218
219 if ( ppdev->BitsPerPixel == 8 )
220 {
221 pHalInfo->vmiData.ddpfDisplay.dwFlags |= DDPF_PALETTEINDEXED8;
222 }
223
224 /* FIXME
225 Config the rops we do not doing that yet
226 for we need write the rops table
227 */
228 for(i=0;i<DD_ROP_SPACE;i++ )
229 {
230 // pHALInfo->ddCaps.dwSVBRops[i] = rops[i];
231 // pHALInfo->ddCaps.dwRops[i] = rops[i];
232 }
233 }
234
235 /* Now build pvmList info */
236 if(pvmList)
237 {
238 ppdev->pvmList = pvmList;
239
240 if (bDDrawHeap)
241 {
243 pvmList->fpStart = ppdev->ScreenHeight * ppdev->ScreenDelta;
244 pvmList->fpEnd = ppdev->MemHeight * ppdev->ScreenDelta - 1;
245 pvmList->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
246 pvmList++;
247 }
248
249 pvmList->fpStart = 0;
250 pvmList->fpEnd = (ppdev->MemHeight * ppdev->ScreenDelta) - 1;
253 pvmList->ddsCapsAlt.dwCaps = DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER;
254
255 pvmList = ppdev->pvmList;
256 }
257
258 return TRUE;
259}
#define VIDMEM_ISWC
Definition: ddrawi.h:212
#define VIDMEM_ISLINEAR
Definition: ddrawi.h:208
#define DDHAL_CB32_CANCREATESURFACE
Definition: ddrawi.h:658
#define VIDMEM_ISNONLOCAL
Definition: ddrawi.h:211
struct _DDHAL_DDCALLBACKS DDHAL_DDCALLBACKS
#define DDHAL_CB32_CREATESURFACE
Definition: ddrawi.h:654
DWORD(WINAPI * PDD_CREATESURFACE)(PDD_CREATESURFACEDATA)
Definition: ddrawint.h:432
struct _DD_HALINFO DD_HALINFO
DWORD(WINAPI * PDD_CANCREATESURFACE)(PDD_CANCREATESURFACEDATA)
Definition: ddrawint.h:462
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define APIENTRY
Definition: api.h:79
DWORD CALLBACK DdCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA pccsd)
Definition: dd.c:26
DWORD CALLBACK DdCreateSurface(PDD_CREATESURFACEDATA pcsd)
Definition: dd.c:70
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _PDEV * PPDEV
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
#define DDSCAPS_FRONTBUFFER
Definition: ddraw.h:254
#define DDFXCAPS_BLTSHRINKYN
Definition: ddraw.h:416
#define DDCAPS_BLT
Definition: ddraw.h:335
#define DDFXCAPS_BLTSHRINKX
Definition: ddraw.h:413
#define DDCAPS_BLTQUEUE
Definition: ddraw.h:336
#define DDCAPS2_NONLOCALVIDMEM
Definition: ddraw.h:371
#define DDSCAPS_PRIMARYSURFACE
Definition: ddraw.h:258
#define DDFXCAPS_BLTSTRETCHYN
Definition: ddraw.h:420
#define DDFXCAPS_BLTMIRRORLEFTRIGHT
Definition: ddraw.h:409
#define DDCAPS_CANBLTSYSMEM
Definition: ddraw.h:360
#define DDCAPS_READSCANLINE
Definition: ddraw.h:346
#define DDFXCAPS_BLTMIRRORUPDOWN
Definition: ddraw.h:410
#define DDSCAPS_NONLOCALVIDMEM
Definition: ddraw.h:277
#define DDCAPS2_NONLOCALVIDMEMCAPS
Definition: ddraw.h:372
struct _DDPIXELFORMAT DDPIXELFORMAT
#define DDCAPS_BLTSTRETCH
Definition: ddraw.h:338
#define DDFXCAPS_BLTSTRETCHXN
Definition: ddraw.h:418
#define DDCKEYCAPS_SRCBLT
Definition: ddraw.h:490
#define DDFXCAPS_BLTSTRETCHY
Definition: ddraw.h:419
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define DDPF_RGB
Definition: ddraw.h:507
#define DDFXCAPS_BLTSHRINKXN
Definition: ddraw.h:414
#define DDCAPS_BLTCOLORFILL
Definition: ddraw.h:355
#define DDFXCAPS_BLTSTRETCHX
Definition: ddraw.h:417
#define DDSCAPS_FLIP
Definition: ddraw.h:253
#define DDPF_PALETTEINDEXED8
Definition: ddraw.h:506
#define DDSCAPS_BACKBUFFER
Definition: ddraw.h:251
#define DDCAPS_COLORKEY
Definition: ddraw.h:351
#define DD_ROP_SPACE
Definition: ddraw.h:200
#define DDSCAPS_LOCALVIDMEM
Definition: ddraw.h:276
#define DDCKEYCAPS_SRCBLTCLRSPACE
Definition: ddraw.h:491
#define DDFXCAPS_BLTSHRINKY
Definition: ddraw.h:415
static HANDLE heap
Definition: heap.c:65
#define memset(x, y, z)
Definition: compat.h:39
DWORD dwBBitMask
Definition: ddraw.h:1106
DWORD dwSize
Definition: ddraw.h:1070
DWORD dwFourCC
Definition: ddraw.h:1072
DWORD dwRGBBitCount
Definition: ddraw.h:1075
DWORD dwRBitMask
Definition: ddraw.h:1085
DWORD dwGBitMask
Definition: ddraw.h:1094
DWORD dwFlags
Definition: ddraw.h:1071
DWORD dwRGBAlphaBitMask
Definition: ddraw.h:1113
DWORD dwFlags
Definition: ddrawint.h:1128
Definition: framebuf.h:34
ULONG ScreenDelta
Definition: framebuf.h:41
ULONG ScreenWidth
Definition: framebuf.h:39
ULONG GreenMask
Definition: framebuf.h:44
DWORD dwHeap
Definition: framebuf.h:64
DWORD iDitherFormat
Definition: framebuf.h:61
ULONG BlueMask
Definition: framebuf.h:45
ULONG ScreenHeight
Definition: framebuf.h:40
PVOID ScreenPtr
Definition: framebuf.h:47
ULONG RedMask
Definition: framebuf.h:43
DDPIXELFORMAT ddpfDisplay
Definition: framebuf.h:67
BYTE BitsPerPixel
Definition: framebuf.h:42
VIDEOMEMORY * pvmList
Definition: framebuf.h:65
ULONG MemWidth
Definition: framebuf.h:63
BOOL bDDInitialized
Definition: framebuf.h:66
ULONG MemHeight
Definition: framebuf.h:62
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
#define BMF_16BPP
Definition: winddi.h:358
#define BMF_8BPP
Definition: winddi.h:357
typedef DHPDEV(APIENTRY FN_DrvEnablePDEV)(_In_ DEVMODEW *pdm
FN_DrvDisableDirectDraw DrvDisableDirectDraw
_Out_ DD_HALINFO _Out_ DWORD _Out_ VIDEOMEMORY _Out_ DWORD _Out_ DWORD * pdwFourCC
Definition: winddi.h:4230
#define BMF_24BPP
Definition: winddi.h:359
_Out_ DD_HALINFO _Out_ DWORD _Out_ VIDEOMEMORY _Out_ DWORD * pdwNumFourCCCodes
Definition: winddi.h:4229
#define BMF_32BPP
Definition: winddi.h:360
_Out_ DD_HALINFO _Out_ DWORD * pdwNumHeaps
Definition: winddi.h:4227
_Out_ DD_HALINFO * pHalInfo
Definition: winddi.h:4226
_Out_ DD_CALLBACKS _Out_ DD_SURFACECALLBACKS * pSurfaceCallBacks
Definition: winddi.h:4218
_Out_ DD_HALINFO _Out_ DWORD _Out_ VIDEOMEMORY * pvmList
Definition: winddi.h:4228
FN_DrvEnableDirectDraw DrvEnableDirectDraw
_Out_ DD_CALLBACKS * pCallBacks
Definition: winddi.h:4217
_Out_ DD_CALLBACKS _Out_ DD_SURFACECALLBACKS _Out_ DD_PALETTECALLBACKS * pPaletteCallBacks
Definition: winddi.h:4219
FN_DrvGetDirectDrawInfo DrvGetDirectDrawInfo