1 /* DirectDraw using DGA or Xlib
3 * Copyright 1997,1998 Marcus Meissner
5 /* When DirectVideo mode is enabled you can no longer use 'normal' X
6 * applications nor can you switch to a virtual console. Also, enabling
7 * only works, if you have switched to the screen where the application
9 * Some ways to debug this stuff are:
10 * - A terminal connected to the serial port. Can be bought used for cheap.
11 * (This is the method I am using.)
12 * - Another machine connected over some kind of network.
14 * FIXME: The Xshm implementation has been temporarily removed. It will be
15 * later reintegrated into the Xlib implementation.
22 #include <sys/signal.h>
26 #include "interfaces.h"
40 #ifdef HAVE_LIBXXF86DGA
41 #include "ts_xf86dga.h"
44 /* define this if you want to play Diablo using XF86DGA. (bug workaround) */
47 /* restore signal handlers overwritten by XF86DGA
48 * this is a define, for it will only work in emulator mode
50 #undef RESTORE_SIGNALS
52 /* Where do these GUIDs come from? mkuuid.
53 * They exist solely to distinguish between the targets Wine support,
54 * and should be different than any other GUIDs in existence.
56 static GUID DGA_DirectDraw_GUID
= { /* e2dcb020-dc60-11d1-8407-9714f5d50802 */
60 {0x84, 0x07, 0x97, 0x14, 0xf5, 0xd5, 0x08, 0x02}
63 static GUID XLIB_DirectDraw_GUID
= { /* 1574a740-dc61-11d1-8407-f7875a7d1879 */
67 {0x84, 0x07, 0xf7, 0x87, 0x5a, 0x7d, 0x18, 0x79}
70 static struct IDirectDrawSurface3_VTable dga_dds3vt
, xlib_dds3vt
;
71 static struct IDirectDraw_VTable dga_ddvt
, xlib_ddvt
;
72 static struct IDirectDraw2_VTable dga_dd2vt
, xlib_dd2vt
;
73 static struct IDirectDrawClipper_VTable ddclipvt
;
74 static struct IDirectDrawPalette_VTable dga_ddpalvt
, xlib_ddpalvt
;
75 static struct IDirect3D_VTable d3dvt
;
76 static struct IDirect3D2_VTable d3d2vt
;
78 void Xlib_MessagePump(HWND32 hwnd
) {
81 while (EVENT_WaitNetEvent(FALSE
,FALSE
)) {
82 while (PeekMessage32A(&msg32
,0,0,0,0)) {
83 GetMessage32A(&msg32
,0,0,0);
84 TranslateMessage32(&msg32
);
85 DispatchMessage32A(&msg32
);
93 #ifdef HAVE_LIBXXF86DGA
95 return (getuid() == 0)&&TSXF86DGAQueryExtension(display
,&evbase
,&evret
);
96 #else /* defined(HAVE_LIBXXF86DGA) */
98 #endif /* defined(HAVE_LIBXXF86DGA) */
102 DirectDrawEnumerate32A(LPDDENUMCALLBACK32A ddenumproc
,LPVOID data
) {
103 if (DDRAW_DGA_Available()) {
104 ddenumproc(&DGA_DirectDraw_GUID
,"WINE with XFree86 DGA","display",data
);
106 ddenumproc(&XLIB_DirectDraw_GUID
,"WINE with Xlib","display",data
);
107 ddenumproc(NULL
,"WINE","display",data
);
111 /* What is this doing here? */
113 DSoundHelp(DWORD x
,DWORD y
,DWORD z
) {
114 FIXME(ddraw
,"(0x%08lx,0x%08lx,0x%08lx),stub!\n",x
,y
,z
);
119 /******************************************************************************
120 * internal helper functions
122 static void _dump_DDBLTFX(DWORD flagmask
) {
128 #define FE(x) { x, #x},
129 FE(DDBLTFX_ARITHSTRETCHY
)
130 FE(DDBLTFX_MIRRORLEFTRIGHT
)
131 FE(DDBLTFX_MIRRORUPDOWN
)
132 FE(DDBLTFX_NOTEARING
)
133 FE(DDBLTFX_ROTATE180
)
134 FE(DDBLTFX_ROTATE270
)
136 FE(DDBLTFX_ZBUFFERRANGE
)
137 FE(DDBLTFX_ZBUFFERBASEDEST
)
139 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
140 if (flags
[i
].mask
& flagmask
) {
141 DUMP("%s ",flags
[i
].name
);
148 static void _dump_DDBLTFAST(DWORD flagmask
) {
154 #define FE(x) { x, #x},
155 FE(DDBLTFAST_NOCOLORKEY
)
156 FE(DDBLTFAST_SRCCOLORKEY
)
157 FE(DDBLTFAST_DESTCOLORKEY
)
160 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
161 if (flags
[i
].mask
& flagmask
)
162 DUMP("%s ",flags
[i
].name
);
166 static void _dump_DDBLT(DWORD flagmask
) {
172 #define FE(x) { x, #x},
174 FE(DDBLT_ALPHADESTCONSTOVERRIDE
)
175 FE(DDBLT_ALPHADESTNEG
)
176 FE(DDBLT_ALPHADESTSURFACEOVERRIDE
)
177 FE(DDBLT_ALPHAEDGEBLEND
)
179 FE(DDBLT_ALPHASRCCONSTOVERRIDE
)
180 FE(DDBLT_ALPHASRCNEG
)
181 FE(DDBLT_ALPHASRCSURFACEOVERRIDE
)
187 FE(DDBLT_KEYDESTOVERRIDE
)
189 FE(DDBLT_KEYSRCOVERRIDE
)
191 FE(DDBLT_ROTATIONANGLE
)
193 FE(DDBLT_ZBUFFERDESTCONSTOVERRIDE
)
194 FE(DDBLT_ZBUFFERDESTOVERRIDE
)
195 FE(DDBLT_ZBUFFERSRCCONSTOVERRIDE
)
196 FE(DDBLT_ZBUFFERSRCOVERRIDE
)
200 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
201 if (flags
[i
].mask
& flagmask
)
202 DUMP("%s ",flags
[i
].name
);
205 static void _dump_DDSCAPS(DWORD flagmask
) {
211 #define FE(x) { x, #x},
212 FE(DDSCAPS_RESERVED1
)
214 FE(DDSCAPS_BACKBUFFER
)
217 FE(DDSCAPS_FRONTBUFFER
)
218 FE(DDSCAPS_OFFSCREENPLAIN
)
221 FE(DDSCAPS_PRIMARYSURFACE
)
222 FE(DDSCAPS_PRIMARYSURFACELEFT
)
223 FE(DDSCAPS_SYSTEMMEMORY
)
226 FE(DDSCAPS_VIDEOMEMORY
)
228 FE(DDSCAPS_WRITEONLY
)
231 FE(DDSCAPS_LIVEVIDEO
)
235 FE(DDSCAPS_RESERVED2
)
236 FE(DDSCAPS_ALLOCONLOAD
)
237 FE(DDSCAPS_VIDEOPORT
)
238 FE(DDSCAPS_LOCALVIDMEM
)
239 FE(DDSCAPS_NONLOCALVIDMEM
)
240 FE(DDSCAPS_STANDARDVGAMODE
)
241 FE(DDSCAPS_OPTIMIZED
)
243 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
244 if (flags
[i
].mask
& flagmask
)
245 DUMP("%s ",flags
[i
].name
);
249 static void _dump_DDSD(DWORD flagmask
) {
259 FE(DDSD_BACKBUFFERCOUNT
)
260 FE(DDSD_ZBUFFERBITDEPTH
)
261 FE(DDSD_ALPHABITDEPTH
)
263 FE(DDSD_CKDESTOVERLAY
)
265 FE(DDSD_CKSRCOVERLAY
)
272 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
273 if (flags
[i
].mask
& flagmask
)
274 DUMP("%s ",flags
[i
].name
);
278 static int _getpixelformat(LPDIRECTDRAW2 ddraw
,LPDDPIXELFORMAT pf
) {
279 static XVisualInfo
*vi
;
284 vi
= TSXGetVisualInfo(display
,VisualNoMask
,&vt
,&nitems
);
287 if (ddraw
->d
.depth
==8) {
288 pf
->dwFlags
= DDPF_RGB
|DDPF_PALETTEINDEXED8
;
289 pf
->x
.dwRGBBitCount
= 8;
290 pf
->y
.dwRBitMask
= 0;
291 pf
->z
.dwGBitMask
= 0;
292 pf
->xx
.dwBBitMask
= 0;
293 pf
->xy
.dwRGBAlphaBitMask
= 0;
296 if (ddraw
->d
.depth
==16) {
297 pf
->dwFlags
= DDPF_RGB
;
298 pf
->x
.dwRGBBitCount
= 16;
299 pf
->y
.dwRBitMask
= vi
[0].red_mask
;
300 pf
->z
.dwGBitMask
= vi
[0].green_mask
;
301 pf
->xx
.dwBBitMask
= vi
[0].blue_mask
;
302 pf
->xy
.dwRGBAlphaBitMask
= 0;
305 FIXME(ddraw
,"_getpixelformat:unknown depth %ld?\n",ddraw
->d
.depth
);
306 return DDERR_GENERIC
;
309 /******************************************************************************
310 * IDirectDrawSurface,IDirectDrawSurface2,IDirectDrawSurface3
312 * Since DDS3 and DDS2 are supersets of DDS, we implement DDS3 and let
313 * DDS and DDS2 use those functions. (Function calls did not change (except
314 * using different DirectDrawSurfaceX version), just added flags and functions)
316 static HRESULT WINAPI
IDirectDrawSurface3_Lock(
317 LPDIRECTDRAWSURFACE3
this,LPRECT32 lprect
,LPDDSURFACEDESC lpddsd
,DWORD flags
, HANDLE32 hnd
319 TRACE(ddraw
, "(%p)->Lock(%p,%p,%08lx,%08lx)\n",
320 this,lprect
,lpddsd
,flags
,(DWORD
)hnd
);
321 if (flags
& ~(DDLOCK_WAIT
|DDLOCK_READONLY
|DDLOCK_WRITEONLY
))
322 WARN(ddraw
, "(%p)->Lock(%p,%p,%08lx,%08lx)\n",
323 this,lprect
,lpddsd
,flags
,(DWORD
)hnd
);
326 FIXME(ddraw
," lprect: %dx%d-%dx%d\n",
327 lprect
->top
,lprect
->left
,lprect
->bottom
,lprect
->right
329 lpddsd
->y
.lpSurface
= this->s
.surface
+
330 (lprect
->top
*this->s
.lpitch
) +
331 (lprect
->left
*(this->s
.ddraw
->d
.depth
/8));
333 assert(this->s
.surface
);
334 lpddsd
->y
.lpSurface
= this->s
.surface
;
336 lpddsd
->dwFlags
= DDSD_WIDTH
|DDSD_HEIGHT
|DDSD_PIXELFORMAT
|DDSD_PITCH
|DDSD_LPSURFACE
;
337 lpddsd
->dwWidth
= this->s
.width
;
338 lpddsd
->dwHeight
= this->s
.height
;
339 lpddsd
->lPitch
= this->s
.lpitch
;
340 _getpixelformat(this->s
.ddraw
,&(lpddsd
->ddpfPixelFormat
));
344 static HRESULT WINAPI
DGA_IDirectDrawSurface3_Unlock(
345 LPDIRECTDRAWSURFACE3
this,LPVOID surface
347 TRACE(ddraw
,"(%p)->Unlock(%p)\n",this,surface
);
351 static HRESULT WINAPI
Xlib_IDirectDrawSurface3_Unlock(
352 LPDIRECTDRAWSURFACE3
this,LPVOID surface
354 /* Xlib_MessagePump(this->s.ddraw->e.xlib.window); */
356 TRACE(ddraw
,"(%p)->Unlock(%p)\n",this,surface
);
358 if (!this->s
.ddraw
->e
.xlib
.paintable
)
363 TSXPutImage( display
,
364 this->s
.ddraw
->e
.xlib
.drawable
,
365 DefaultGCOfScreen(screen
),
368 this->t
.xlib
.image
->width
,
369 this->t
.xlib
.image
->height
371 if (this->s
.palette
&& this->s
.palette
->cm
)
372 TSXSetWindowColormap(display
,this->s
.ddraw
->e
.xlib
.drawable
,this->s
.palette
->cm
);
377 static HRESULT WINAPI
DGA_IDirectDrawSurface3_Flip(
378 LPDIRECTDRAWSURFACE3
this,LPDIRECTDRAWSURFACE3 flipto
,DWORD dwFlags
380 #ifdef HAVE_LIBXXF86DGA
381 TRACE(ddraw
,"(%p)->Flip(%p,%08lx)\n",this,flipto
,dwFlags
);
383 if (this->s
.backbuffer
)
384 flipto
= this->s
.backbuffer
;
388 TSXF86DGASetViewPort(display
,DefaultScreen(display
),0,flipto
->t
.dga
.fb_height
);
390 if (flipto
->s
.palette
&& flipto
->s
.palette
->cm
) {
391 TSXF86DGAInstallColormap(display
,DefaultScreen(display
),flipto
->s
.palette
->cm
);
393 while (!TSXF86DGAViewPortChanged(display
,DefaultScreen(display
),2)) {
399 tmp
= this->t
.dga
.fb_height
;
400 this->t
.dga
.fb_height
= flipto
->t
.dga
.fb_height
;
401 flipto
->t
.dga
.fb_height
= tmp
;
403 ptmp
= this->s
.surface
;
404 this->s
.surface
= flipto
->s
.surface
;
405 flipto
->s
.surface
= ptmp
;
408 #else /* defined(HAVE_LIBXXF86DGA) */
410 #endif /* defined(HAVE_LIBXXF86DGA) */
413 static HRESULT WINAPI
Xlib_IDirectDrawSurface3_Flip(
414 LPDIRECTDRAWSURFACE3
this,LPDIRECTDRAWSURFACE3 flipto
,DWORD dwFlags
416 TRACE(ddraw
,"(%p)->Flip(%p,%08lx)\n",this,flipto
,dwFlags
);
417 /* Xlib_MessagePump(this->s.ddraw->e.xlib.window); */
418 if (!this->s
.ddraw
->e
.xlib
.paintable
)
422 if (this->s
.backbuffer
)
423 flipto
= this->s
.backbuffer
;
429 this->s
.ddraw
->e
.xlib
.drawable
,
430 DefaultGCOfScreen(screen
),
431 flipto
->t
.xlib
.image
,
433 flipto
->t
.xlib
.image
->width
,
434 flipto
->t
.xlib
.image
->height
);
435 TSXSetWindowColormap(display
,this->s
.ddraw
->e
.xlib
.drawable
,this->s
.palette
->cm
);
439 tmp
= this->t
.xlib
.image
;
440 this->t
.xlib
.image
= flipto
->t
.xlib
.image
;
441 flipto
->t
.xlib
.image
= tmp
;
442 surf
= this->s
.surface
;
443 this->s
.surface
= flipto
->s
.surface
;
444 flipto
->s
.surface
= surf
;
449 /* The IDirectDrawSurface3::SetPalette method attaches the specified
450 * DirectDrawPalette object to a surface. The surface uses this palette for all
451 * subsequent operations. The palette change takes place immediately.
453 static HRESULT WINAPI
Xlib_IDirectDrawSurface3_SetPalette(
454 LPDIRECTDRAWSURFACE3
this,LPDIRECTDRAWPALETTE pal
456 TRACE(ddraw
,"(%p)->SetPalette(%p)\n",this,pal
);
457 #ifdef HAVE_LIBXXF86DGA
458 /* According to spec, we are only supposed to
459 * AddRef if this is not the same palette.
461 if( this->s
.palette
!= pal
)
464 pal
->lpvtbl
->fnAddRef( pal
);
465 if( this->s
.palette
!= NULL
)
466 this->s
.palette
->lpvtbl
->fnRelease( this->s
.palette
);
467 this->s
.palette
= pal
;
469 /* I think that we need to attach it to all backbuffers...*/
470 if( this->s
.backbuffer
) {
471 if( this->s
.backbuffer
->s
.palette
)
472 this->s
.backbuffer
->s
.palette
->lpvtbl
->fnRelease(
473 this->s
.backbuffer
->s
.palette
);
474 this->s
.backbuffer
->s
.palette
= pal
;
476 pal
->lpvtbl
->fnAddRef( pal
);
479 /* Perform the refresh */
480 TSXSetWindowColormap(display
,this->s
.ddraw
->e
.xlib
.drawable
,this->s
.palette
->cm
);
484 #else /* defined(HAVE_LIBXXF86DGA) */
486 #endif /* defined(HAVE_LIBXXF86DGA) */
491 static HRESULT WINAPI
DGA_IDirectDrawSurface3_SetPalette(
492 LPDIRECTDRAWSURFACE3
this,LPDIRECTDRAWPALETTE pal
494 TRACE(ddraw
,"(%p)->SetPalette(%p)\n",this,pal
);
495 #ifdef HAVE_LIBXXF86DGA
496 /* According to spec, we are only supposed to
497 * AddRef if this is not the same palette.
499 if( this->s
.palette
!= pal
)
502 pal
->lpvtbl
->fnAddRef( pal
);
503 if( this->s
.palette
!= NULL
)
504 this->s
.palette
->lpvtbl
->fnRelease( this->s
.palette
);
505 this->s
.palette
= pal
;
507 /* I think that we need to attach it to all backbuffers...*/
508 if( this->s
.backbuffer
) {
509 if( this->s
.backbuffer
->s
.palette
)
510 this->s
.backbuffer
->s
.palette
->lpvtbl
->fnRelease(this->s
.backbuffer
->s
.palette
);
511 this->s
.backbuffer
->s
.palette
= pal
;
512 if( pal
) pal
->lpvtbl
->fnAddRef( pal
);
514 TSXF86DGAInstallColormap(display
,DefaultScreen(display
),this->s
.palette
->cm
);
517 #else /* defined(HAVE_LIBXXF86DGA) */
519 #endif /* defined(HAVE_LIBXXF86DGA) */
524 static HRESULT WINAPI
IDirectDrawSurface3_Blt(
525 LPDIRECTDRAWSURFACE3
this,LPRECT32 rdst
,LPDIRECTDRAWSURFACE3 src
,LPRECT32 rsrc
,DWORD dwFlags
,LPDDBLTFX lpbltfx
531 memcpy(&xdst
,rdst
,sizeof(xdst
));
534 xdst
.bottom
= this->s
.height
;
536 xdst
.right
= this->s
.width
;
540 memcpy(&xsrc
,rsrc
,sizeof(xsrc
));
543 xsrc
.bottom
= src
->s
.height
;
545 xsrc
.right
= src
->s
.width
;
548 if (dwFlags
& DDBLT_COLORFILL
) {
549 int bpp
= this->s
.ddraw
->d
.depth
/8;
552 xline
= (LPBYTE
)this->s
.surface
+xdst
.top
*this->s
.lpitch
;
553 for (i
=xdst
.top
;i
<xdst
.bottom
;i
++) {
554 xpixel
= xline
+bpp
*xdst
.left
;
556 for (j
=xdst
.left
;j
<xdst
.right
;j
++) {
557 /* FIXME: this only works on little endian
558 * architectures, where DWORD starts with low
561 memcpy(xpixel
,&(lpbltfx
->b
.dwFillColor
),bpp
);
564 xline
+= this->s
.lpitch
;
566 dwFlags
&= ~(DDBLT_COLORFILL
);
568 dwFlags
&= ~(DDBLT_WAIT
|DDBLT_ASYNC
);/* FIXME: can't handle right now */
569 if ( (xsrc
.top
==0) && (xsrc
.bottom
==this->s
.height
) &&
570 (xsrc
.left
==0) && (xsrc
.right
==this->s
.width
) &&
571 (xdst
.top
==0) && (xdst
.bottom
==this->s
.height
) &&
572 (xdst
.left
==0) && (xdst
.right
==this->s
.width
) &&
575 memcpy(this->s
.surface
,src
->s
.surface
,this->s
.height
*this->s
.lpitch
);
579 FIXME(ddraw
,"(%p)->(%p,%p,%p,%08lx,%p),stub!\n",
580 this,rdst
,src
,rsrc
,dwFlags
,lpbltfx
582 if (rdst
) TRACE(ddraw
," destrect :%dx%d-%dx%d\n",rdst
->left
,rdst
->top
,rdst
->right
,rdst
->bottom
);
583 if (rsrc
) TRACE(ddraw
," srcrect :%dx%d-%dx%d\n",rsrc
->left
,rsrc
->top
,rsrc
->right
,rsrc
->bottom
);
584 TRACE(ddraw
,"\tflags: ");_dump_DDBLT(dwFlags
);fprintf(stderr
,"\n");
586 if (dwFlags
& DDBLT_DDFX
) {
587 TRACE(ddraw
," blitfx: \n");_dump_DDBLTFX(lpbltfx
->dwDDFX
);
592 static HRESULT WINAPI
IDirectDrawSurface3_BltFast(
593 LPDIRECTDRAWSURFACE3
this,DWORD dstx
,DWORD dsty
,LPDIRECTDRAWSURFACE3 src
,LPRECT32 rsrc
,DWORD trans
596 if (TRACE_ON(ddraw
)) {
597 FIXME(ddraw
,"(%p)->(%ld,%ld,%p,%p,%08lx),stub!\n",
598 this,dstx
,dsty
,src
,rsrc
,trans
600 TRACE(ddraw
," trans:");_dump_DDBLTFAST(trans
);fprintf(stderr
,"\n");
601 TRACE(ddraw
," srcrect: %dx%d-%dx%d\n",rsrc
->left
,rsrc
->top
,rsrc
->right
,rsrc
->bottom
);
603 bpp
= this->s
.ddraw
->d
.depth
/8;
604 for (i
=0;i
<rsrc
->bottom
-rsrc
->top
;i
++) {
605 memcpy( this->s
.surface
+((i
+dsty
)*this->s
.width
*bpp
)+dstx
*bpp
,
606 src
->s
.surface
+(rsrc
->top
+i
)*src
->s
.width
*bpp
+rsrc
->left
*bpp
,
607 (rsrc
->right
-rsrc
->left
)*bpp
613 static HRESULT WINAPI
IDirectDrawSurface3_BltBatch(
614 LPDIRECTDRAWSURFACE3
this,LPDDBLTBATCH ddbltbatch
,DWORD x
,DWORD y
616 TRACE(ddraw
,"(%p)->BltBatch(%p,%08lx,%08lx),stub!\n",
622 static HRESULT WINAPI
IDirectDrawSurface3_GetCaps(
623 LPDIRECTDRAWSURFACE3
this,LPDDSCAPS caps
625 TRACE(ddraw
,"(%p)->GetCaps(%p)\n",this,caps
);
626 caps
->dwCaps
= DDCAPS_PALETTE
; /* probably more */
630 static HRESULT WINAPI
IDirectDrawSurface3_GetSurfaceDesc(
631 LPDIRECTDRAWSURFACE3
this,LPDDSURFACEDESC ddsd
633 if (TRACE_ON(ddraw
)) {
634 TRACE(ddraw
, "(%p)->GetSurfaceDesc(%p)\n",
636 fprintf(stderr
," flags: ");
637 _dump_DDSD(ddsd
->dwFlags
);
638 fprintf(stderr
,"\n");
641 ddsd
->dwFlags
|= DDSD_PIXELFORMAT
|DDSD_CAPS
|DDSD_BACKBUFFERCOUNT
|DDSD_HEIGHT
|DDSD_WIDTH
;
642 ddsd
->ddsCaps
.dwCaps
= DDSCAPS_PALETTE
;
643 ddsd
->dwBackBufferCount
= 1;
644 ddsd
->dwHeight
= this->s
.height
;
645 ddsd
->dwWidth
= this->s
.width
;
646 ddsd
->lPitch
= this->s
.lpitch
;
647 if (this->s
.backbuffer
)
648 ddsd
->ddsCaps
.dwCaps
|= DDSCAPS_PRIMARYSURFACE
|DDSCAPS_FLIP
;
649 _getpixelformat(this->s
.ddraw
,&(ddsd
->ddpfPixelFormat
));
654 static ULONG WINAPI
IDirectDrawSurface3_AddRef(LPDIRECTDRAWSURFACE3
this) {
655 TRACE( ddraw
, "(%p)->() incrementing from %lu.\n", this, this->ref
);
657 return ++(this->ref
);
660 static ULONG WINAPI
DGA_IDirectDrawSurface3_Release(LPDIRECTDRAWSURFACE3
this) {
661 TRACE( ddraw
, "(%p)->() decrementing from %lu.\n", this, this->ref
);
663 #ifdef HAVE_LIBXXF86DGA
664 if (!--(this->ref
)) {
665 this->s
.ddraw
->lpvtbl
->fnRelease(this->s
.ddraw
);
666 /* clear out of surface list */
667 if (this->t
.dga
.fb_height
== -1) {
668 HeapFree(GetProcessHeap(),0,this->s
.surface
);
670 this->s
.ddraw
->e
.dga
.vpmask
&= ~(1<<(this->t
.dga
.fb_height
/this->s
.ddraw
->e
.dga
.fb_height
));
672 HeapFree(GetProcessHeap(),0,this);
675 #endif /* defined(HAVE_LIBXXF86DGA) */
679 static ULONG WINAPI
Xlib_IDirectDrawSurface3_Release(LPDIRECTDRAWSURFACE3
this) {
680 TRACE( ddraw
, "(%p)->() decrementing from %lu.\n", this, this->ref
);
682 if (!--(this->ref
)) {
683 this->s
.ddraw
->lpvtbl
->fnRelease(this->s
.ddraw
);
684 HeapFree(GetProcessHeap(),0,this->s
.surface
);
686 if( this->s
.backbuffer
)
688 this->s
.backbuffer
->lpvtbl
->fnRelease(this->s
.backbuffer
);
691 this->t
.xlib
.image
->data
= NULL
;
692 TSXDestroyImage(this->t
.xlib
.image
);
693 this->t
.xlib
.image
= 0;
696 this->s
.palette
->lpvtbl
->fnRelease(this->s
.palette
);
699 HeapFree(GetProcessHeap(),0,this);
705 static HRESULT WINAPI
IDirectDrawSurface3_GetAttachedSurface(
706 LPDIRECTDRAWSURFACE3
this,LPDDSCAPS lpddsd
,LPDIRECTDRAWSURFACE3
*lpdsf
708 TRACE(ddraw
, "(%p)->GetAttachedSurface(%p,%p)\n",
709 this, lpddsd
, lpdsf
);
711 if (TRACE_ON(ddraw
)) {
712 TRACE(ddraw
," caps ");
713 _dump_DDSCAPS(lpddsd
->dwCaps
);
716 if (!(lpddsd
->dwCaps
& DDSCAPS_BACKBUFFER
)) {
717 FIXME(ddraw
,"whoops, can only handle backbuffers for now\n");
721 /* FIXME: should handle more than one backbuffer */
722 *lpdsf
= this->s
.backbuffer
;
724 if( this->s
.backbuffer
)
726 this->s
.backbuffer
->lpvtbl
->fnAddRef( this->s
.backbuffer
);
732 static HRESULT WINAPI
IDirectDrawSurface3_Initialize(
733 LPDIRECTDRAWSURFACE3
this,LPDIRECTDRAW ddraw
,LPDDSURFACEDESC lpdsfd
735 return DDERR_ALREADYINITIALIZED
;
738 static HRESULT WINAPI
IDirectDrawSurface3_GetPixelFormat(
739 LPDIRECTDRAWSURFACE3
this,LPDDPIXELFORMAT pf
741 return _getpixelformat(this->s
.ddraw
,pf
);
744 static HRESULT WINAPI
IDirectDrawSurface3_GetBltStatus(LPDIRECTDRAWSURFACE3
this,DWORD dwFlags
) {
745 FIXME(ddraw
,"(%p)->(0x%08lx),stub!\n",this,dwFlags
);
749 static HRESULT WINAPI
IDirectDrawSurface3_GetOverlayPosition(
750 LPDIRECTDRAWSURFACE3
this,LPLONG x1
,LPLONG x2
752 FIXME(ddraw
,"(%p)->(%p,%p),stub!\n",this,x1
,x2
);
756 static HRESULT WINAPI
IDirectDrawSurface3_SetClipper(
757 LPDIRECTDRAWSURFACE3
this,LPDIRECTDRAWCLIPPER clipper
759 FIXME(ddraw
,"(%p)->(%p),stub!\n",this,clipper
);
763 static HRESULT WINAPI
IDirectDrawSurface3_AddAttachedSurface(
764 LPDIRECTDRAWSURFACE3
this,LPDIRECTDRAWSURFACE3 surf
766 FIXME(ddraw
,"(%p)->(%p),stub!\n",this,surf
);
767 this->s
.backbuffer
= surf
;
771 static HRESULT WINAPI
IDirectDrawSurface3_GetDC(LPDIRECTDRAWSURFACE3
this,HDC32
* lphdc
) {
772 FIXME(ddraw
,"(%p)->GetDC(%p)\n",this,lphdc
);
773 *lphdc
= BeginPaint32(this->s
.ddraw
->e
.xlib
.window
,&this->s
.ddraw
->e
.xlib
.ps
);
777 static HRESULT WINAPI
IDirectDrawSurface3_ReleaseDC(LPDIRECTDRAWSURFACE3
this,HDC32 hdc
) {
778 FIXME(ddraw
,"(%p)->(0x%08lx),stub!\n",this,(long)hdc
);
779 EndPaint32(this->s
.ddraw
->e
.xlib
.window
,&this->s
.ddraw
->e
.xlib
.ps
);
784 static HRESULT WINAPI
IDirectDrawSurface3_QueryInterface(LPDIRECTDRAWSURFACE3
this,REFIID refiid
,LPVOID
*obj
) {
787 WINE_StringFromCLSID((LPCLSID
)refiid
,xrefiid
);
788 TRACE(ddraw
,"(%p)->(%s,%p)\n",this,xrefiid
,obj
);
790 /* DirectDrawSurface,DirectDrawSurface2 and DirectDrawSurface3 use
791 * the same interface. And IUnknown does that too of course.
793 if ( !memcmp(&IID_IDirectDrawSurface3
,refiid
,sizeof(IID
)) ||
794 !memcmp(&IID_IDirectDrawSurface2
,refiid
,sizeof(IID
)) ||
795 !memcmp(&IID_IDirectDrawSurface
,refiid
,sizeof(IID
)) ||
796 !memcmp(&IID_IUnknown
,refiid
,sizeof(IID
))
799 this->lpvtbl
->fnAddRef(this);
802 FIXME(ddraw
,"(%p):interface for IID %s NOT found!\n",this,xrefiid
);
803 return OLE_E_ENUM_NOMORE
;
806 static HRESULT WINAPI
IDirectDrawSurface3_IsLost(LPDIRECTDRAWSURFACE3
this) {
807 TRACE(ddraw
,"(%p)->(), stub!\n",this);
811 static HRESULT WINAPI
IDirectDrawSurface3_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE3
this,LPVOID context
,LPDDENUMSURFACESCALLBACK esfcb
) {
812 FIXME(ddraw
,"(%p)->(%p,%p),stub!\n",this,context
,esfcb
);
816 static HRESULT WINAPI
IDirectDrawSurface3_Restore(LPDIRECTDRAWSURFACE3
this) {
817 FIXME(ddraw
,"(%p)->(),stub!\n",this);
821 static HRESULT WINAPI
IDirectDrawSurface3_SetColorKey(
822 LPDIRECTDRAWSURFACE3
this, DWORD dwFlags
, LPDDCOLORKEY ckey
824 FIXME(ddraw
,"(%p)->(0x%08lx,%p),stub!\n",this,dwFlags
,ckey
);
826 if( dwFlags
& DDCKEY_SRCBLT
)
828 dwFlags
&= ~DDCKEY_SRCBLT
;
833 TRACE( ddraw
, "unhandled dwFlags: %08lx\n", dwFlags
);
839 static HRESULT WINAPI
IDirectDrawSurface3_AddOverlayDirtyRect(
840 LPDIRECTDRAWSURFACE3
this,
843 FIXME(ddraw
,"(%p)->(%p),stub!\n",this,lpRect
);
848 static HRESULT WINAPI
IDirectDrawSurface3_DeleteAttachedSurface(
849 LPDIRECTDRAWSURFACE3
this,
851 LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface
)
853 FIXME(ddraw
,"(%p)->(0x%08lx,%p),stub!\n",this,dwFlags
,lpDDSAttachedSurface
);
858 static HRESULT WINAPI
IDirectDrawSurface3_EnumOverlayZOrders(
859 LPDIRECTDRAWSURFACE3
this,
862 LPDDENUMSURFACESCALLBACK lpfnCallback
)
864 FIXME(ddraw
,"(%p)->(0x%08lx,%p,%p),stub!\n", this,dwFlags
,
865 lpContext
, lpfnCallback
);
870 static HRESULT WINAPI
IDirectDrawSurface3_GetClipper(
871 LPDIRECTDRAWSURFACE3
this,
872 LPDIRECTDRAWCLIPPER
* lplpDDClipper
)
874 FIXME(ddraw
,"(%p)->(%p),stub!\n", this, lplpDDClipper
);
879 static HRESULT WINAPI
IDirectDrawSurface3_GetColorKey(
880 LPDIRECTDRAWSURFACE3
this,
882 LPDDCOLORKEY lpDDColorKey
)
884 FIXME(ddraw
,"(%p)->(0x%08lx,%p),stub!\n", this, dwFlags
, lpDDColorKey
);
889 static HRESULT WINAPI
IDirectDrawSurface3_GetFlipStatus(
890 LPDIRECTDRAWSURFACE3
this,
893 FIXME(ddraw
,"(%p)->(0x%08lx),stub!\n", this, dwFlags
);
898 static HRESULT WINAPI
IDirectDrawSurface3_GetPalette(
899 LPDIRECTDRAWSURFACE3
this,
900 LPDIRECTDRAWPALETTE
* lplpDDPalette
)
902 FIXME(ddraw
,"(%p)->(%p),stub!\n", this, lplpDDPalette
);
907 static HRESULT WINAPI
IDirectDrawSurface3_SetOverlayPosition(
908 LPDIRECTDRAWSURFACE3
this,
912 FIXME(ddraw
,"(%p)->(%ld,%ld),stub!\n", this, lX
, lY
);
917 static HRESULT WINAPI
IDirectDrawSurface3_UpdateOverlay(
918 LPDIRECTDRAWSURFACE3
this,
920 LPDIRECTDRAWSURFACE3 lpDDDestSurface
,
923 LPDDOVERLAYFX lpDDOverlayFx
)
925 FIXME(ddraw
,"(%p)->(%p,%p,%p,0x%08lx,%p),stub!\n", this,
926 lpSrcRect
, lpDDDestSurface
, lpDestRect
, dwFlags
, lpDDOverlayFx
);
931 static HRESULT WINAPI
IDirectDrawSurface3_UpdateOverlayDisplay(
932 LPDIRECTDRAWSURFACE3
this,
935 FIXME(ddraw
,"(%p)->(0x%08lx),stub!\n", this, dwFlags
);
940 static HRESULT WINAPI
IDirectDrawSurface3_UpdateOverlayZOrder(
941 LPDIRECTDRAWSURFACE3
this,
943 LPDIRECTDRAWSURFACE3 lpDDSReference
)
945 FIXME(ddraw
,"(%p)->(0x%08lx,%p),stub!\n", this, dwFlags
, lpDDSReference
);
950 static HRESULT WINAPI
IDirectDrawSurface3_GetDDInterface(
951 LPDIRECTDRAWSURFACE3
this,
954 FIXME(ddraw
,"(%p)->(%p),stub!\n", this, lplpDD
);
959 static HRESULT WINAPI
IDirectDrawSurface3_PageLock(
960 LPDIRECTDRAWSURFACE3
this,
963 FIXME(ddraw
,"(%p)->(0x%08lx),stub!\n", this, dwFlags
);
968 static HRESULT WINAPI
IDirectDrawSurface3_PageUnlock(
969 LPDIRECTDRAWSURFACE3
this,
972 FIXME(ddraw
,"(%p)->(0x%08lx),stub!\n", this, dwFlags
);
977 static HRESULT WINAPI
IDirectDrawSurface3_SetSurfaceDesc(
978 LPDIRECTDRAWSURFACE3
this,
979 LPDDSURFACEDESC lpDDSD
,
982 FIXME(ddraw
,"(%p)->(%p,0x%08lx),stub!\n", this, lpDDSD
, dwFlags
);
987 static struct IDirectDrawSurface3_VTable dga_dds3vt
= {
988 IDirectDrawSurface3_QueryInterface
,
989 IDirectDrawSurface3_AddRef
,
990 DGA_IDirectDrawSurface3_Release
,
991 IDirectDrawSurface3_AddAttachedSurface
,
992 IDirectDrawSurface3_AddOverlayDirtyRect
,
993 IDirectDrawSurface3_Blt
,
994 IDirectDrawSurface3_BltBatch
,
995 IDirectDrawSurface3_BltFast
,
996 IDirectDrawSurface3_DeleteAttachedSurface
,
997 IDirectDrawSurface3_EnumAttachedSurfaces
,
998 IDirectDrawSurface3_EnumOverlayZOrders
,
999 DGA_IDirectDrawSurface3_Flip
,
1000 IDirectDrawSurface3_GetAttachedSurface
,
1001 IDirectDrawSurface3_GetBltStatus
,
1002 IDirectDrawSurface3_GetCaps
,
1003 IDirectDrawSurface3_GetClipper
,
1004 IDirectDrawSurface3_GetColorKey
,
1005 IDirectDrawSurface3_GetDC
,
1006 IDirectDrawSurface3_GetFlipStatus
,
1007 IDirectDrawSurface3_GetOverlayPosition
,
1008 IDirectDrawSurface3_GetPalette
,
1009 IDirectDrawSurface3_GetPixelFormat
,
1010 IDirectDrawSurface3_GetSurfaceDesc
,
1011 IDirectDrawSurface3_Initialize
,
1012 IDirectDrawSurface3_IsLost
,
1013 IDirectDrawSurface3_Lock
,
1014 IDirectDrawSurface3_ReleaseDC
,
1015 IDirectDrawSurface3_Restore
,
1016 IDirectDrawSurface3_SetClipper
,
1017 IDirectDrawSurface3_SetColorKey
,
1018 IDirectDrawSurface3_SetOverlayPosition
,
1019 DGA_IDirectDrawSurface3_SetPalette
,
1020 DGA_IDirectDrawSurface3_Unlock
,
1021 IDirectDrawSurface3_UpdateOverlay
,
1022 IDirectDrawSurface3_UpdateOverlayDisplay
,
1023 IDirectDrawSurface3_UpdateOverlayZOrder
,
1024 IDirectDrawSurface3_GetDDInterface
,
1025 IDirectDrawSurface3_PageLock
,
1026 IDirectDrawSurface3_PageUnlock
,
1027 IDirectDrawSurface3_SetSurfaceDesc
,
1030 static struct IDirectDrawSurface3_VTable xlib_dds3vt
= {
1031 IDirectDrawSurface3_QueryInterface
,
1032 IDirectDrawSurface3_AddRef
,
1033 Xlib_IDirectDrawSurface3_Release
,
1034 IDirectDrawSurface3_AddAttachedSurface
,
1035 IDirectDrawSurface3_AddOverlayDirtyRect
,
1036 IDirectDrawSurface3_Blt
,
1037 IDirectDrawSurface3_BltBatch
,
1038 IDirectDrawSurface3_BltFast
,
1039 IDirectDrawSurface3_DeleteAttachedSurface
,
1040 IDirectDrawSurface3_EnumAttachedSurfaces
,
1041 IDirectDrawSurface3_EnumOverlayZOrders
,
1042 Xlib_IDirectDrawSurface3_Flip
,
1043 IDirectDrawSurface3_GetAttachedSurface
,
1044 IDirectDrawSurface3_GetBltStatus
,
1045 IDirectDrawSurface3_GetCaps
,
1046 IDirectDrawSurface3_GetClipper
,
1047 IDirectDrawSurface3_GetColorKey
,
1048 IDirectDrawSurface3_GetDC
,
1049 IDirectDrawSurface3_GetFlipStatus
,
1050 IDirectDrawSurface3_GetOverlayPosition
,
1051 IDirectDrawSurface3_GetPalette
,
1052 IDirectDrawSurface3_GetPixelFormat
,
1053 IDirectDrawSurface3_GetSurfaceDesc
,
1054 IDirectDrawSurface3_Initialize
,
1055 IDirectDrawSurface3_IsLost
,
1056 IDirectDrawSurface3_Lock
,
1057 IDirectDrawSurface3_ReleaseDC
,
1058 IDirectDrawSurface3_Restore
,
1059 IDirectDrawSurface3_SetClipper
,
1060 IDirectDrawSurface3_SetColorKey
,
1061 IDirectDrawSurface3_SetOverlayPosition
,
1062 Xlib_IDirectDrawSurface3_SetPalette
,
1063 Xlib_IDirectDrawSurface3_Unlock
,
1064 IDirectDrawSurface3_UpdateOverlay
,
1065 IDirectDrawSurface3_UpdateOverlayDisplay
,
1066 IDirectDrawSurface3_UpdateOverlayZOrder
,
1067 IDirectDrawSurface3_GetDDInterface
,
1068 IDirectDrawSurface3_PageLock
,
1069 IDirectDrawSurface3_PageUnlock
,
1070 IDirectDrawSurface3_SetSurfaceDesc
,
1073 /******************************************************************************
1074 * IDirectDrawClipper
1076 static HRESULT WINAPI
IDirectDrawClipper_SetHwnd(
1077 LPDIRECTDRAWCLIPPER
this,DWORD x
,HWND32 hwnd
1079 FIXME(ddraw
,"(%p)->SetHwnd(0x%08lx,0x%08lx),stub!\n",this,x
,(DWORD
)hwnd
);
1083 static ULONG WINAPI
IDirectDrawClipper_Release(LPDIRECTDRAWCLIPPER
this) {
1084 TRACE( ddraw
, "(%p)->() decrementing from %lu.\n", this, this->ref
);
1089 HeapFree(GetProcessHeap(),0,this);
1093 static HRESULT WINAPI
IDirectDrawClipper_GetClipList(
1094 LPDIRECTDRAWCLIPPER
this,LPRECT32 rects
,LPRGNDATA lprgn
,LPDWORD hmm
1096 FIXME(ddraw
,"(%p,%p,%p,%p),stub!\n",this,rects
,lprgn
,hmm
);
1101 static HRESULT WINAPI
IDirectDrawClipper_SetClipList(
1102 LPDIRECTDRAWCLIPPER
this,LPRGNDATA lprgn
,DWORD hmm
1104 FIXME(ddraw
,"(%p,%p,%ld),stub!\n",this,lprgn
,hmm
);
1108 static struct IDirectDrawClipper_VTable ddclipvt
= {
1111 IDirectDrawClipper_Release
,
1112 IDirectDrawClipper_GetClipList
,
1116 IDirectDrawClipper_SetClipList
,
1117 IDirectDrawClipper_SetHwnd
1120 /******************************************************************************
1121 * IDirectDrawPalette
1123 static HRESULT WINAPI
IDirectDrawPalette_GetEntries(
1124 LPDIRECTDRAWPALETTE
this,DWORD x
,DWORD start
,DWORD count
,LPPALETTEENTRY palent
1129 if (!this->cm
) /* should not happen */ {
1130 FIXME(ddraw
,"app tried to read colormap for non-palettized mode\n");
1131 return DDERR_GENERIC
;
1133 for (i
=0;i
<count
;i
++) {
1137 TSXQueryColor(display
,this->cm
,&xc
);
1138 palent
[i
].peRed
= xc
.red
>>8;
1139 palent
[i
].peGreen
= xc
.green
>>8;
1140 palent
[i
].peBlue
= xc
.blue
>>8;
1143 palent
[i
].peRed
= this->palents
[start
+i
].peRed
;
1144 palent
[i
].peBlue
= this->palents
[start
+i
].peBlue
;
1145 palent
[i
].peGreen
= this->palents
[start
+i
].peGreen
;
1146 palent
[i
].peFlags
= this->palents
[start
+i
].peFlags
;
1152 static HRESULT WINAPI
Xlib_IDirectDrawPalette_SetEntries(
1153 LPDIRECTDRAWPALETTE
this,DWORD x
,DWORD start
,DWORD count
,LPPALETTEENTRY palent
1158 TRACE(ddraw
,"(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",
1159 this,x
,start
,count
,palent
1161 if (!this->cm
) /* should not happen */ {
1162 FIXME(ddraw
,"app tried to set colormap in non-palettized mode\n");
1163 return DDERR_GENERIC
;
1165 if (!this->ddraw
->e
.xlib
.paintable
)
1167 for (i
=0;i
<count
;i
++) {
1168 xc
.red
= palent
[i
].peRed
<<8;
1169 xc
.blue
= palent
[i
].peBlue
<<8;
1170 xc
.green
= palent
[i
].peGreen
<<8;
1171 xc
.flags
= DoRed
|DoBlue
|DoGreen
;
1174 TSXStoreColor(display
,this->cm
,&xc
);
1176 this->palents
[start
+i
].peRed
= palent
[i
].peRed
;
1177 this->palents
[start
+i
].peBlue
= palent
[i
].peBlue
;
1178 this->palents
[start
+i
].peGreen
= palent
[i
].peGreen
;
1179 this->palents
[start
+i
].peFlags
= palent
[i
].peFlags
;
1184 static HRESULT WINAPI
DGA_IDirectDrawPalette_SetEntries(
1185 LPDIRECTDRAWPALETTE
this,DWORD x
,DWORD start
,DWORD count
,LPPALETTEENTRY palent
1187 #ifdef HAVE_LIBXXF86DGA
1192 TRACE(ddraw
,"(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",
1193 this,x
,start
,count
,palent
1195 if (!this->cm
) /* should not happen */ {
1196 FIXME(ddraw
,"app tried to set colormap in non-palettized mode\n");
1197 return DDERR_GENERIC
;
1199 /* FIXME: free colorcells instead of freeing whole map */
1201 this->cm
= TSXCopyColormapAndFree(display
,this->cm
);
1202 TSXFreeColormap(display
,cm
);
1204 for (i
=0;i
<count
;i
++) {
1205 xc
.red
= palent
[i
].peRed
<<8;
1206 xc
.blue
= palent
[i
].peBlue
<<8;
1207 xc
.green
= palent
[i
].peGreen
<<8;
1208 xc
.flags
= DoRed
|DoBlue
|DoGreen
;
1211 TSXStoreColor(display
,this->cm
,&xc
);
1213 this->palents
[start
+i
].peRed
= palent
[i
].peRed
;
1214 this->palents
[start
+i
].peBlue
= palent
[i
].peBlue
;
1215 this->palents
[start
+i
].peGreen
= palent
[i
].peGreen
;
1216 this->palents
[start
+i
].peFlags
= palent
[i
].peFlags
;
1218 TSXF86DGAInstallColormap(display
,DefaultScreen(display
),this->cm
);
1220 #else /* defined(HAVE_LIBXXF86DGA) */
1221 return E_UNEXPECTED
;
1222 #endif /* defined(HAVE_LIBXXF86DGA) */
1225 static ULONG WINAPI
IDirectDrawPalette_Release(LPDIRECTDRAWPALETTE
this) {
1226 TRACE( ddraw
, "(%p)->() decrementing from %lu.\n", this, this->ref
);
1227 if (!--(this->ref
)) {
1229 TSXFreeColormap(display
,this->cm
);
1232 HeapFree(GetProcessHeap(),0,this);
1238 static ULONG WINAPI
IDirectDrawPalette_AddRef(LPDIRECTDRAWPALETTE
this) {
1240 TRACE( ddraw
, "(%p)->() incrementing from %lu.\n", this, this->ref
);
1241 return ++(this->ref
);
1244 static HRESULT WINAPI
IDirectDrawPalette_Initialize(
1245 LPDIRECTDRAWPALETTE
this,LPDIRECTDRAW ddraw
,DWORD x
,LPPALETTEENTRY palent
1247 return DDERR_ALREADYINITIALIZED
;
1250 static HRESULT WINAPI
IDirectDrawPalette_GetCaps(
1251 LPDIRECTDRAWPALETTE
this, LPDWORD lpdwCaps
)
1253 FIXME( ddraw
, "(%p)->(%p) stub.\n", this, lpdwCaps
);
1257 static HRESULT WINAPI
IDirectDrawPalette_QueryInterface(
1258 LPDIRECTDRAWPALETTE
this,REFIID refiid
,LPVOID
*obj
)
1262 WINE_StringFromCLSID((LPCLSID
)refiid
,xrefiid
);
1263 FIXME(ddraw
,"(%p)->(%s,%p) stub.\n",this,xrefiid
,obj
);
1268 static struct IDirectDrawPalette_VTable dga_ddpalvt
= {
1269 IDirectDrawPalette_QueryInterface
,
1270 IDirectDrawPalette_AddRef
,
1271 IDirectDrawPalette_Release
,
1272 IDirectDrawPalette_GetCaps
,
1273 IDirectDrawPalette_GetEntries
,
1274 IDirectDrawPalette_Initialize
,
1275 DGA_IDirectDrawPalette_SetEntries
1278 static struct IDirectDrawPalette_VTable xlib_ddpalvt
= {
1279 IDirectDrawPalette_QueryInterface
,
1280 IDirectDrawPalette_AddRef
,
1281 IDirectDrawPalette_Release
,
1282 IDirectDrawPalette_GetCaps
,
1283 IDirectDrawPalette_GetEntries
,
1284 IDirectDrawPalette_Initialize
,
1285 Xlib_IDirectDrawPalette_SetEntries
1288 static HRESULT WINAPI
IDirect3D_QueryInterface(
1289 LPDIRECT3D
this,REFIID refiid
,LPVOID
*obj
1291 /* FIXME: Not sure if this is correct */
1294 WINE_StringFromCLSID((LPCLSID
)refiid
,xrefiid
);
1295 TRACE(ddraw
,"(%p)->(%s,%p)\n",this,xrefiid
,obj
);
1296 if (!memcmp(&IID_IUnknown
,refiid
,sizeof(IID_IUnknown
))) {
1298 this->lpvtbl
->fnAddRef(this);
1301 if (!memcmp(&IID_IDirect3D
,refiid
,sizeof(IID_IDirect3D
))) {
1304 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
1306 d3d
->ddraw
= (LPDIRECTDRAW
)this;
1307 this->lpvtbl
->fnAddRef(this);
1308 d3d
->lpvtbl
= &d3dvt
;
1312 if (!memcmp(&IID_IDirect3D2
,refiid
,sizeof(IID_IDirect3D
))) {
1315 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
1317 d3d
->ddraw
= (LPDIRECTDRAW
)this;
1318 this->lpvtbl
->fnAddRef(this);
1319 d3d
->lpvtbl
= &d3d2vt
;
1323 FIXME(ddraw
,"(%p):interface for IID %s NOT found!\n",this,xrefiid
);
1324 return OLE_E_ENUM_NOMORE
;
1327 static ULONG WINAPI
IDirect3D_AddRef(LPDIRECT3D
this) {
1328 TRACE( ddraw
, "(%p)->() incrementing from %lu.\n", this, this->ref
);
1330 return ++(this->ref
);
1333 static ULONG WINAPI
IDirect3D_Release(LPDIRECT3D
this)
1335 TRACE( ddraw
, "(%p)->() decrementing from %lu.\n", this, this->ref
);
1337 if (!--(this->ref
)) {
1338 this->ddraw
->lpvtbl
->fnRelease(this->ddraw
);
1339 HeapFree(GetProcessHeap(),0,this);
1345 static HRESULT WINAPI
IDirect3D_Initialize(
1346 LPDIRECT3D
this, REFIID refiid
)
1348 /* FIXME: Not sure if this is correct */
1351 WINE_StringFromCLSID((LPCLSID
)refiid
,xrefiid
);
1352 FIXME(ddraw
,"(%p)->(%s):stub.\n",this,xrefiid
);
1354 return DDERR_ALREADYINITIALIZED
;
1357 /*******************************************************************************
1360 static struct IDirect3D_VTable d3dvt
= {
1361 (void*)IDirect3D_QueryInterface
,
1362 (void*)IDirect3D_AddRef
,
1363 (void*)IDirect3D_Release
,
1364 IDirect3D_Initialize
,
1372 /*******************************************************************************
1375 static ULONG WINAPI
IDirect3D2_Release(LPDIRECT3D2
this) {
1376 TRACE( ddraw
, "(%p)->() decrementing from %lu.\n", this, this->ref
);
1378 if (!--(this->ref
)) {
1379 this->ddraw
->lpvtbl
->fnRelease(this->ddraw
);
1380 HeapFree(GetProcessHeap(),0,this);
1386 static HRESULT WINAPI
IDirect3D2_EnumDevices(
1387 LPDIRECT3D2
this,LPD3DENUMDEVICESCALLBACK cb
, LPVOID context
1389 D3DDEVICEDESC d1
,d2
;
1391 FIXME(ddraw
,"(%p)->(%p,%p),stub!\n",this,cb
,context
);
1392 d1
.dwSize
= sizeof(d1
);
1395 d2
.dwSize
= sizeof(d2
);
1397 cb((void*)&IID_IDirect3DHALDevice
,"WINE Direct3D HAL","direct3d",&d1
,&d2
,context
);
1401 static struct IDirect3D2_VTable d3d2vt
= {
1405 IDirect3D2_EnumDevices
,
1413 /*******************************************************************************
1417 /* Used in conjunction with cbWndExtra for storage of the this ptr for the window.
1418 * Please adjust allocation in Xlib_DirectDrawCreate if you store more data here.
1420 static INT32 ddrawXlibThisOffset
= 0;
1422 static HRESULT WINAPI
DGA_IDirectDraw2_CreateSurface(
1423 LPDIRECTDRAW2
this,LPDDSURFACEDESC lpddsd
,LPDIRECTDRAWSURFACE
*lpdsf
,IUnknown
*lpunk
1425 #ifdef HAVE_LIBXXF86DGA
1428 TRACE(ddraw
, "(%p)->(%p,%p,%p)\n",this,lpddsd
,lpdsf
,lpunk
);
1429 if (TRACE_ON(ddraw
)) {
1430 DUMP("[w=%ld,h=%ld,flags ",lpddsd
->dwWidth
,lpddsd
->dwHeight
);
1431 _dump_DDSD(lpddsd
->dwFlags
);
1432 fprintf(stderr
,"caps ");
1433 _dump_DDSCAPS(lpddsd
->ddsCaps
.dwCaps
);
1434 fprintf(stderr
,"]\n");
1437 *lpdsf
= (LPDIRECTDRAWSURFACE
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirectDrawSurface
));
1438 this->lpvtbl
->fnAddRef(this);
1440 (*lpdsf
)->lpvtbl
= (LPDIRECTDRAWSURFACE_VTABLE
)&dga_dds3vt
;
1441 if ( (lpddsd
->dwFlags
& DDSD_CAPS
) &&
1442 (lpddsd
->ddsCaps
.dwCaps
& DDSCAPS_OFFSCREENPLAIN
)
1444 if (!(lpddsd
->dwFlags
& DDSD_WIDTH
))
1445 lpddsd
->dwWidth
= this->e
.dga
.fb_width
;
1446 if (!(lpddsd
->dwFlags
& DDSD_HEIGHT
))
1447 lpddsd
->dwHeight
= this->e
.dga
.fb_height
;
1448 (*lpdsf
)->s
.surface
= (LPBYTE
)HeapAlloc(GetProcessHeap(),0,lpddsd
->dwWidth
*lpddsd
->dwHeight
*this->d
.depth
/8);
1449 (*lpdsf
)->t
.dga
.fb_height
= -1;
1450 (*lpdsf
)->s
.lpitch
= lpddsd
->dwWidth
*this->d
.depth
/8;
1451 TRACE(ddraw
,"using system memory for a primary surface\n");
1454 if (!(this->e
.dga
.vpmask
& (1<<i
)))
1456 TRACE(ddraw
,"using viewport %d for a primary surface\n",i
);
1457 /* if i == 32 or maximum ... return error */
1458 this->e
.dga
.vpmask
|=(1<<i
);
1459 (*lpdsf
)->s
.surface
= this->e
.dga
.fb_addr
+((i
*this->e
.dga
.fb_height
)*this->e
.dga
.fb_width
*this->d
.depth
/8);
1460 (*lpdsf
)->t
.dga
.fb_height
= i
*this->e
.dga
.fb_height
;
1461 (*lpdsf
)->s
.lpitch
= this->e
.dga
.fb_width
*this->d
.depth
/8;
1464 lpddsd
->lPitch
= (*lpdsf
)->s
.lpitch
;
1466 (*lpdsf
)->s
.width
= this->d
.width
;
1467 (*lpdsf
)->s
.height
= this->d
.height
;
1468 (*lpdsf
)->s
.ddraw
= this;
1469 (*lpdsf
)->s
.backbuffer
= NULL
;
1470 if (lpddsd
->dwFlags
& DDSD_BACKBUFFERCOUNT
) {
1471 LPDIRECTDRAWSURFACE3 back
;
1473 if (lpddsd
->dwBackBufferCount
>1)
1474 FIXME(ddraw
,"urks, wants to have more than one backbuffer (%ld)!\n",lpddsd
->dwBackBufferCount
);
1476 (*lpdsf
)->s
.backbuffer
= back
= (LPDIRECTDRAWSURFACE3
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirectDrawSurface3
));
1477 this->lpvtbl
->fnAddRef(this);
1479 back
->lpvtbl
= (LPDIRECTDRAWSURFACE3_VTABLE
)&dga_dds3vt
;
1481 if (!(this->e
.dga
.vpmask
& (1<<i
)))
1483 TRACE(ddraw
,"using viewport %d for backbuffer\n",i
);
1484 /* if i == 32 or maximum ... return error */
1485 this->e
.dga
.vpmask
|=(1<<i
);
1486 back
->s
.surface
= this->e
.dga
.fb_addr
+((i
*this->e
.dga
.fb_height
)*this->e
.dga
.fb_width
*this->d
.depth
/8);
1487 back
->t
.dga
.fb_height
= i
*this->e
.dga
.fb_height
;
1489 back
->s
.width
= this->d
.width
;
1490 back
->s
.height
= this->d
.height
;
1491 back
->s
.ddraw
= this;
1492 back
->s
.lpitch
= this->e
.dga
.fb_width
*this->d
.depth
/8;
1493 back
->s
.backbuffer
= NULL
; /* does not have a backbuffer, it is
1497 #else /* defined(HAVE_LIBXXF86DGA) */
1498 return E_UNEXPECTED
;
1499 #endif /* defined(HAVE_LIBXXF86DGA) */
1502 static HRESULT WINAPI
Xlib_IDirectDraw2_CreateSurface(
1503 LPDIRECTDRAW2
this,LPDDSURFACEDESC lpddsd
,LPDIRECTDRAWSURFACE
*lpdsf
,IUnknown
*lpunk
1507 TRACE(ddraw
, "(%p)->CreateSurface(%p,%p,%p)\n",
1508 this,lpddsd
,lpdsf
,lpunk
);
1510 if (TRACE_ON(ddraw
)) {
1511 fprintf(stderr
,"[w=%ld,h=%ld,flags ",lpddsd
->dwWidth
,lpddsd
->dwHeight
);
1512 _dump_DDSD(lpddsd
->dwFlags
);
1513 fprintf(stderr
,"caps ");
1514 _dump_DDSCAPS(lpddsd
->ddsCaps
.dwCaps
);
1515 fprintf(stderr
,"]\n");
1518 *lpdsf
= (LPDIRECTDRAWSURFACE
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirectDrawSurface
));
1520 this->lpvtbl
->fnAddRef(this);
1521 (*lpdsf
)->s
.ddraw
= this;
1523 (*lpdsf
)->lpvtbl
= (LPDIRECTDRAWSURFACE_VTABLE
)&xlib_dds3vt
;
1525 if ( (lpddsd
->dwFlags
& DDSD_CAPS
) &&
1526 (lpddsd
->ddsCaps
.dwCaps
& DDSCAPS_OFFSCREENPLAIN
)
1528 if (!(lpddsd
->dwFlags
& DDSD_WIDTH
))
1529 lpddsd
->dwWidth
= this->e
.dga
.fb_width
;
1530 if (!(lpddsd
->dwFlags
& DDSD_HEIGHT
))
1531 lpddsd
->dwHeight
= this->e
.dga
.fb_height
;
1532 (*lpdsf
)->s
.surface
= (LPBYTE
)HeapAlloc(GetProcessHeap(),0,lpddsd
->dwWidth
*lpddsd
->dwHeight
*this->d
.depth
/8);
1533 TRACE(ddraw
,"using system memory for a primary surface\n");
1535 TRACE(ddraw
,"using standard XImage for a primary surface\n");
1536 /* FIXME: !8 bit images */
1537 if (!(lpddsd
->dwFlags
& DDSD_WIDTH
))
1538 lpddsd
->dwWidth
= this->d
.width
;
1539 if (!(lpddsd
->dwFlags
& DDSD_HEIGHT
))
1540 lpddsd
->dwHeight
= this->d
.height
;
1542 (*lpdsf
)->s
.surface
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,lpddsd
->dwHeight
*lpddsd
->dwWidth
*this->d
.depth
/8);
1543 (*lpdsf
)->s
.width
= lpddsd
->dwWidth
;
1544 (*lpdsf
)->s
.height
= lpddsd
->dwHeight
;
1547 (*lpdsf
)->t
.xlib
.image
= img
=
1548 TSXCreateImage( display
,
1549 DefaultVisualOfScreen(screen
),
1553 (*lpdsf
)->s
.surface
,
1558 /* FIXME: !8 bit images */
1560 /* END FIXME: Xlib */
1562 (*lpdsf
)->s
.lpitch
= img
->bytes_per_line
;
1563 if (lpddsd
->dwFlags
& DDSD_BACKBUFFERCOUNT
) {
1564 LPDIRECTDRAWSURFACE3 back
;
1566 if (lpddsd
->dwBackBufferCount
>1)
1567 FIXME(ddraw
,"urks, wants to have more than one backbuffer (%ld)!\n",lpddsd
->dwBackBufferCount
);
1569 (*lpdsf
)->s
.backbuffer
= back
= (LPDIRECTDRAWSURFACE3
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirectDrawSurface3
));
1571 this->lpvtbl
->fnAddRef(this);
1572 back
->s
.ddraw
= this;
1575 back
->lpvtbl
= (LPDIRECTDRAWSURFACE3_VTABLE
)&xlib_dds3vt
;
1576 /* FIXME: !8 bit images */
1577 back
->s
.surface
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,
1578 img
->width
*img
->height
1580 back
->t
.xlib
.image
= TSXCreateImage(
1582 DefaultVisualOfScreen(screen
),
1591 /* FIXME: !8 bit images */
1593 back
->s
.width
= this->d
.width
;
1594 back
->s
.height
= this->d
.height
;
1595 back
->s
.lpitch
= back
->t
.xlib
.image
->bytes_per_line
;
1596 back
->s
.backbuffer
= NULL
; /* does not have a backbuffer, it is
1602 static HRESULT WINAPI
IDirectDraw2_DuplicateSurface(
1603 LPDIRECTDRAW2
this,LPDIRECTDRAWSURFACE src
,LPDIRECTDRAWSURFACE
*dst
1605 FIXME(ddraw
,"(%p)->(%p,%p) simply copies\n",this,src
,dst
);
1606 *dst
= src
; /* FIXME */
1610 static HRESULT WINAPI
IDirectDraw2_SetCooperativeLevel(
1611 LPDIRECTDRAW2
this,HWND32 hwnd
,DWORD cooplevel
1618 FE(DDSCL_FULLSCREEN
)
1619 FE(DDSCL_ALLOWREBOOT
)
1620 FE(DDSCL_NOWINDOWCHANGES
)
1622 FE(DDSCL_ALLOWMODEX
)
1624 FE(DDSCL_SETFOCUSWINDOW
)
1625 FE(DDSCL_SETDEVICEWINDOW
)
1626 FE(DDSCL_CREATEDEVICEWINDOW
)
1629 TRACE(ddraw
,"(%p)->(%08lx,%08lx)\n",this,(DWORD
)hwnd
,cooplevel
);
1630 if(TRACE_ON(ddraw
)){
1631 dbg_decl_str(ddraw
, 512);
1632 for (i
=0;i
<sizeof(flagmap
)/sizeof(flagmap
[0]);i
++)
1633 if (flagmap
[i
].mask
& cooplevel
)
1634 dsprintf(ddraw
, "%s ", flagmap
[i
].name
);
1635 TRACE(ddraw
," cooperative level %s\n", dbg_str(ddraw
));
1637 this->d
.mainWindow
= hwnd
;
1642 static HRESULT WINAPI
DGA_IDirectDraw_SetDisplayMode(
1643 LPDIRECTDRAW
this,DWORD width
,DWORD height
,DWORD depth
1645 #ifdef HAVE_LIBXXF86DGA
1646 int i
,*depths
,depcount
;
1648 TRACE(ddraw
, "(%p)->(%ld,%ld,%ld)\n", this, width
, height
, depth
);
1650 depths
= TSXListDepths(display
,DefaultScreen(display
),&depcount
);
1651 for (i
=0;i
<depcount
;i
++)
1652 if (depths
[i
]==depth
)
1655 if (i
==depcount
) {/* not found */
1656 ERR(ddraw
,"(w=%ld,h=%ld,d=%ld), unsupported depth!\n",width
,height
,depth
);
1657 return DDERR_UNSUPPORTEDMODE
;
1659 if (this->d
.width
< width
) {
1660 ERR(ddraw
,"SetDisplayMode(w=%ld,h=%ld,d=%ld), width %ld exceeds framebuffer width %ld\n",width
,height
,depth
,width
,this->d
.width
);
1661 return DDERR_UNSUPPORTEDMODE
;
1663 this->d
.width
= width
;
1664 this->d
.height
= height
;
1665 /* adjust fb_height, so we don't overlap */
1666 if (this->e
.dga
.fb_height
< height
)
1667 this->e
.dga
.fb_height
= height
;
1668 this->d
.depth
= depth
;
1670 /* FIXME: this function OVERWRITES several signal handlers.
1671 * can we save them? and restore them later? In a way that
1672 * it works for the library too?
1674 TSXF86DGADirectVideo(display
,DefaultScreen(display
),XF86DGADirectGraphics
);
1676 TSXF86DGASetViewPort(display
,DefaultScreen(display
),0,this->e
.dga
.fb_height
);
1679 #ifdef RESTORE_SIGNALS
1680 SIGNAL_InitEmulator();
1683 #else /* defined(HAVE_LIBXXF86DGA) */
1684 return E_UNEXPECTED
;
1685 #endif /* defined(HAVE_LIBXXF86DGA) */
1688 static HRESULT WINAPI
Xlib_IDirectDraw_SetDisplayMode(
1689 LPDIRECTDRAW
this,DWORD width
,DWORD height
,DWORD depth
1691 int i
,*depths
,depcount
;
1694 TRACE(ddraw
, "(%p)->SetDisplayMode(%ld,%ld,%ld)\n",
1695 this, width
, height
, depth
);
1697 depths
= TSXListDepths(display
,DefaultScreen(display
),&depcount
);
1698 for (i
=0;i
<depcount
;i
++)
1699 if (depths
[i
]==depth
)
1702 if (i
==depcount
) {/* not found */
1703 sprintf(buf
,"SetDisplayMode(w=%ld,h=%ld,d=%ld), unsupported depth!",width
,height
,depth
);
1704 MessageBox32A(0,buf
,"WINE DirectDraw",MB_OK
|MB_ICONSTOP
);
1705 return DDERR_UNSUPPORTEDMODE
;
1708 if (this->d.width < width) {
1709 sprintf(buf,"SetDisplayMode(w=%ld,h=%ld,d=%ld), width %ld exceeds framebuffer width %ld",width,height,depth,width,this->d.width);
1710 MessageBox32A(0,buf,"WINE DirectDraw",MB_OK|MB_ICONSTOP);
1711 return DDERR_UNSUPPORTEDMODE;
1714 this->e
.xlib
.window
= CreateWindowEx32A(
1718 WS_VISIBLE
|WS_SYSMENU
|WS_THICKFRAME
,
1728 /* Store this with the window. We'll use it for the window procedure */
1729 SetWindowLong32A(this->e
.xlib
.window
,ddrawXlibThisOffset
,(LONG
)this);
1731 this->e
.xlib
.paintable
= 1;
1733 ShowWindow32(this->e
.xlib
.window
,TRUE
);
1734 UpdateWindow32(this->e
.xlib
.window
);
1736 assert(this->e
.xlib
.window
);
1738 this->e
.xlib
.drawable
= WIN_FindWndPtr(this->e
.xlib
.window
)->window
;
1740 /* We don't have a context for this window. Host off the desktop */
1741 if( !this->e
.xlib
.drawable
)
1743 this->e
.xlib
.drawable
= WIN_GetDesktop()->window
;
1746 this->d
.width
= width
;
1747 this->d
.height
= height
;
1749 /* adjust fb_height, so we don't overlap */
1751 if (this->e.dga.fb_height < height)
1752 this->e.dga.fb_height = height;*/
1753 this->d
.depth
= depth
;
1757 static HRESULT WINAPI
DGA_IDirectDraw2_GetCaps(
1758 LPDIRECTDRAW2
this,LPDDCAPS caps1
,LPDDCAPS caps2
1760 #ifdef HAVE_LIBXXF86DGA
1761 TRACE(ddraw
,"(%p)->GetCaps(%p,%p)\n",this,caps1
,caps2
);
1762 caps1
->dwVidMemTotal
= this->e
.dga
.fb_memsize
;
1763 caps1
->dwCaps
= 0xffffffff&~(DDCAPS_BANKSWITCHED
); /* we can do anything */
1764 caps1
->ddsCaps
.dwCaps
= 0xffffffff; /* we can do anything */
1766 caps2
->dwVidMemTotal
= this->e
.dga
.fb_memsize
;
1767 caps2
->dwCaps
= 0xffffffff&~(DDCAPS_BANKSWITCHED
); /* we can do anything */
1768 caps2
->ddsCaps
.dwCaps
= 0xffffffff; /* we can do anything */
1771 #else /* defined(HAVE_LIBXXF86DGA) */
1772 return E_UNEXPECTED
;
1773 #endif /* defined(HAVE_LIBXXF86DGA) */
1776 static HRESULT WINAPI
Xlib_IDirectDraw2_GetCaps(
1777 LPDIRECTDRAW2
this,LPDDCAPS caps1
,LPDDCAPS caps2
1779 TRACE(ddraw
,"(%p)->GetCaps(%p,%p)\n",this,caps1
,caps2
);
1781 caps1
->dwVidMemTotal
= 2048*1024;
1782 caps1
->dwCaps
= 0xffffffff&~(DDCAPS_BANKSWITCHED
); /* we can do anything */
1783 caps1
->ddsCaps
.dwCaps
= 0xffffffff; /* we can do anything */
1785 caps2
->dwVidMemTotal
= 2048*1024;
1786 caps2
->dwCaps
= 0xffffffff&~(DDCAPS_BANKSWITCHED
); /* we can do anything */
1787 caps2
->ddsCaps
.dwCaps
= 0xffffffff; /* we can do anything */
1789 /* END FIXME: Xlib */
1793 static HRESULT WINAPI
IDirectDraw2_CreateClipper(
1794 LPDIRECTDRAW2
this,DWORD x
,LPDIRECTDRAWCLIPPER
*lpddclip
,LPUNKNOWN lpunk
1796 FIXME(ddraw
,"(%p)->(%08lx,%p,%p),stub!\n",
1797 this,x
,lpddclip
,lpunk
1799 *lpddclip
= (LPDIRECTDRAWCLIPPER
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirectDrawClipper
));
1800 (*lpddclip
)->ref
= 1;
1801 (*lpddclip
)->lpvtbl
= &ddclipvt
;
1805 static HRESULT WINAPI
common_IDirectDraw2_CreatePalette(
1806 LPDIRECTDRAW2
this,DWORD x
,LPPALETTEENTRY palent
,LPDIRECTDRAWPALETTE
*lpddpal
,LPUNKNOWN lpunk
1808 *lpddpal
= (LPDIRECTDRAWPALETTE
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirectDrawPalette
));
1809 if (*lpddpal
== NULL
) return E_OUTOFMEMORY
;
1810 (*lpddpal
)->ref
= 1;
1811 (*lpddpal
)->ddraw
= (LPDIRECTDRAW
)this;
1812 (*lpddpal
)->installed
= 0;
1813 if (this->d
.depth
<=8) {
1814 (*lpddpal
)->cm
= TSXCreateColormap(display
,DefaultRootWindow(display
),DefaultVisualOfScreen(screen
),AllocAll
);
1816 /* we don't want palettes in hicolor or truecolor */
1822 static HRESULT WINAPI
DGA_IDirectDraw2_CreatePalette(
1823 LPDIRECTDRAW2
this,DWORD x
,LPPALETTEENTRY palent
,LPDIRECTDRAWPALETTE
*lpddpal
,LPUNKNOWN lpunk
1826 TRACE(ddraw
,"(%p)->(%08lx,%p,%p,%p)\n",this,x
,palent
,lpddpal
,lpunk
);
1827 res
= common_IDirectDraw2_CreatePalette(this,x
,palent
,lpddpal
,lpunk
);
1828 if (res
!= 0) return res
;
1829 (*lpddpal
)->lpvtbl
= &dga_ddpalvt
;
1833 static HRESULT WINAPI
Xlib_IDirectDraw2_CreatePalette(
1834 LPDIRECTDRAW2
this,DWORD x
,LPPALETTEENTRY palent
,LPDIRECTDRAWPALETTE
*lpddpal
,LPUNKNOWN lpunk
1836 TRACE(ddraw
,"(%p)->(%08lx,%p,%p,%p)\n",this,x
,palent
,lpddpal
,lpunk
);
1837 *lpddpal
= (LPDIRECTDRAWPALETTE
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirectDrawPalette
));
1838 if (*lpddpal
== NULL
) return E_OUTOFMEMORY
;
1839 (*lpddpal
)->ref
= 1;
1840 (*lpddpal
)->installed
= 0;
1842 (*lpddpal
)->ddraw
= (LPDIRECTDRAW
)this;
1843 this->lpvtbl
->fnAddRef(this);
1845 if (this->d
.depth
<=8) {
1846 (*lpddpal
)->cm
= TSXCreateColormap(display
,this->e
.xlib
.drawable
,DefaultVisualOfScreen(screen
),AllocAll
);
1847 /* later installed ...
1848 * TSXInstallColormap(display,(*lpddpal)->cm);
1849 * TSXSetWindowColormap(display,this->e.xlib.drawable,(*lpddpal)->cm);
1851 TSXInstallColormap(display
,(*lpddpal
)->cm
);
1855 /* we don't want palettes in hicolor or truecolor */
1859 (*lpddpal
)->lpvtbl
= &xlib_ddpalvt
;
1863 static HRESULT WINAPI
DGA_IDirectDraw2_RestoreDisplayMode(LPDIRECTDRAW2
this) {
1864 #ifdef HAVE_LIBXXF86DGA
1865 TRACE(ddraw
, "(%p)->()\n",this);
1867 TSXF86DGADirectVideo(display
,DefaultScreen(display
),0);
1868 #ifdef RESTORE_SIGNALS
1869 SIGNAL_InitEmulator();
1872 #else /* defined(HAVE_LIBXXF86DGA) */
1873 return E_UNEXPECTED
;
1877 static HRESULT WINAPI
Xlib_IDirectDraw2_RestoreDisplayMode(LPDIRECTDRAW2
this) {
1878 TRACE(ddraw
, "(%p)->RestoreDisplayMode()\n", this);
1883 static HRESULT WINAPI
IDirectDraw2_WaitForVerticalBlank(
1884 LPDIRECTDRAW2
this,DWORD x
,HANDLE32 h
1886 TRACE(ddraw
,"(%p)->(0x%08lx,0x%08x)\n",this,x
,h
);
1890 static ULONG WINAPI
IDirectDraw2_AddRef(LPDIRECTDRAW2
this) {
1891 TRACE( ddraw
, "(%p)->() incrementing from %lu.\n", this, this->ref
);
1893 return ++(this->ref
);
1896 static ULONG WINAPI
DGA_IDirectDraw2_Release(LPDIRECTDRAW2
this) {
1897 TRACE( ddraw
, "(%p)->() decrementing from %lu.\n", this, this->ref
);
1899 #ifdef HAVE_LIBXXF86DGA
1900 if (!--(this->ref
)) {
1901 TSXF86DGADirectVideo(display
,DefaultScreen(display
),0);
1902 #ifdef RESTORE_SIGNALS
1903 SIGNAL_InitEmulator();
1905 HeapFree(GetProcessHeap(),0,this);
1908 #endif /* defined(HAVE_LIBXXF86DGA) */
1912 static ULONG WINAPI
Xlib_IDirectDraw2_Release(LPDIRECTDRAW2
this) {
1913 TRACE( ddraw
, "(%p)->() decrementing from %lu.\n", this, this->ref
);
1915 if (!--(this->ref
)) {
1916 HeapFree(GetProcessHeap(),0,this);
1919 /* FIXME: destroy window ... */
1923 static HRESULT WINAPI
DGA_IDirectDraw2_QueryInterface(
1924 LPDIRECTDRAW2
this,REFIID refiid
,LPVOID
*obj
1928 WINE_StringFromCLSID((LPCLSID
)refiid
,xrefiid
);
1929 TRACE(ddraw
,"(%p)->(%s,%p)\n",this,xrefiid
,obj
);
1930 if (!memcmp(&IID_IUnknown
,refiid
,sizeof(IID_IUnknown
))) {
1932 this->lpvtbl
->fnAddRef(this);
1935 if (!memcmp(&IID_IDirectDraw
,refiid
,sizeof(IID_IDirectDraw
))) {
1936 this->lpvtbl
= (LPDIRECTDRAW2_VTABLE
)&dga_ddvt
;
1937 this->lpvtbl
->fnAddRef(this);
1941 if (!memcmp(&IID_IDirectDraw2
,refiid
,sizeof(IID_IDirectDraw2
))) {
1942 this->lpvtbl
= (LPDIRECTDRAW2_VTABLE
)&dga_dd2vt
;
1943 this->lpvtbl
->fnAddRef(this);
1947 if (!memcmp(&IID_IDirect3D
,refiid
,sizeof(IID_IDirect3D
))) {
1950 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
1952 d3d
->ddraw
= (LPDIRECTDRAW
)this;
1953 this->lpvtbl
->fnAddRef(this);
1954 d3d
->lpvtbl
= &d3dvt
;
1958 if (!memcmp(&IID_IDirect3D2
,refiid
,sizeof(IID_IDirect3D
))) {
1961 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
1963 d3d
->ddraw
= (LPDIRECTDRAW
)this;
1964 this->lpvtbl
->fnAddRef(this);
1965 d3d
->lpvtbl
= &d3d2vt
;
1969 WARN(ddraw
,"(%p):interface for IID %s _NOT_ found!\n",this,xrefiid
);
1970 return OLE_E_ENUM_NOMORE
;
1973 static HRESULT WINAPI
Xlib_IDirectDraw2_QueryInterface(
1974 LPDIRECTDRAW2
this,REFIID refiid
,LPVOID
*obj
1978 WINE_StringFromCLSID((LPCLSID
)refiid
,xrefiid
);
1979 TRACE(ddraw
,"(%p)->(%s,%p)\n",this,xrefiid
,obj
);
1980 if (!memcmp(&IID_IUnknown
,refiid
,sizeof(IID_IUnknown
))) {
1982 this->lpvtbl
->fnAddRef(this);
1985 if (!memcmp(&IID_IDirectDraw
,refiid
,sizeof(IID_IDirectDraw
))) {
1986 this->lpvtbl
= (LPDIRECTDRAW2_VTABLE
)&xlib_ddvt
;
1987 this->lpvtbl
->fnAddRef(this);
1991 if (!memcmp(&IID_IDirectDraw2
,refiid
,sizeof(IID_IDirectDraw2
))) {
1992 this->lpvtbl
= (LPDIRECTDRAW2_VTABLE
)&xlib_dd2vt
;
1993 this->lpvtbl
->fnAddRef(this);
1997 if (!memcmp(&IID_IDirect3D
,refiid
,sizeof(IID_IDirect3D
))) {
2000 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
2002 d3d
->ddraw
= (LPDIRECTDRAW
)this;
2003 this->lpvtbl
->fnAddRef(this);
2004 d3d
->lpvtbl
= &d3dvt
;
2008 if (!memcmp(&IID_IDirect3D2
,refiid
,sizeof(IID_IDirect3D
))) {
2011 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
2013 d3d
->ddraw
= (LPDIRECTDRAW
)this;
2014 this->lpvtbl
->fnAddRef(this);
2015 d3d
->lpvtbl
= &d3d2vt
;
2019 WARN(ddraw
,"(%p):interface for IID %s _NOT_ found!\n",this,xrefiid
);
2020 return OLE_E_ENUM_NOMORE
;
2023 static HRESULT WINAPI
IDirectDraw2_GetVerticalBlankStatus(
2024 LPDIRECTDRAW2
this,BOOL32
*status
2026 TRACE(ddraw
,"(%p)->(%p)\n",this,status
);
2031 static HRESULT WINAPI
IDirectDraw2_EnumDisplayModes(
2032 LPDIRECTDRAW2
this,DWORD dwFlags
,LPDDSURFACEDESC lpddsfd
,LPVOID context
,LPDDENUMMODESCALLBACK modescb
2034 DDSURFACEDESC ddsfd
;
2036 TRACE(ddraw
,"(%p)->(0x%08lx,%p,%p,%p)\n",this,dwFlags
,lpddsfd
,context
,modescb
);
2038 _getpixelformat(this,&(ddsfd
.ddpfPixelFormat
));
2039 ddsfd
.dwSize
= sizeof(ddsfd
);
2040 ddsfd
.dwFlags
= DDSD_HEIGHT
|DDSD_WIDTH
|DDSD_BACKBUFFERCOUNT
|DDSD_PIXELFORMAT
|DDSD_CAPS
;
2041 if (dwFlags
& DDEDM_REFRESHRATES
) {
2042 ddsfd
.dwFlags
|= DDSD_REFRESHRATE
;
2043 ddsfd
.x
.dwRefreshRate
= 60;
2046 ddsfd
.dwWidth
= 640;
2047 ddsfd
.dwHeight
= 480;
2048 ddsfd
.dwBackBufferCount
= 1;
2049 ddsfd
.ddsCaps
.dwCaps
= DDSCAPS_PALETTE
;
2051 if (!modescb(&ddsfd
,context
)) return 0;
2053 ddsfd
.dwWidth
= 800;
2054 ddsfd
.dwHeight
= 600;
2055 if (!modescb(&ddsfd
,context
)) return 0;
2057 if (!(dwFlags
& DDEDM_STANDARDVGAMODES
)) {
2058 /* modeX is not standard VGA */
2060 ddsfd
.dwHeight
= 200;
2061 ddsfd
.dwWidth
= 320;
2062 if (!modescb(&ddsfd
,context
)) return 0;
2067 static HRESULT WINAPI
DGA_IDirectDraw2_GetDisplayMode(
2068 LPDIRECTDRAW2
this,LPDDSURFACEDESC lpddsfd
2070 #ifdef HAVE_LIBXXF86DGA
2071 TRACE(ddraw
,"(%p)->(%p)\n",this,lpddsfd
);
2072 lpddsfd
->dwFlags
= DDSD_HEIGHT
|DDSD_WIDTH
|DDSD_PITCH
|DDSD_BACKBUFFERCOUNT
|DDSD_PIXELFORMAT
|DDSD_CAPS
;
2073 lpddsfd
->dwHeight
= screenHeight
;
2074 lpddsfd
->dwWidth
= screenWidth
;
2075 lpddsfd
->lPitch
= this->e
.dga
.fb_width
*this->d
.depth
/8;
2076 lpddsfd
->dwBackBufferCount
= 1;
2077 lpddsfd
->x
.dwRefreshRate
= 60;
2078 lpddsfd
->ddsCaps
.dwCaps
= DDSCAPS_PALETTE
;
2079 _getpixelformat(this,&(lpddsfd
->ddpfPixelFormat
));
2081 #else /* defined(HAVE_LIBXXF86DGA) */
2082 return E_UNEXPECTED
;
2083 #endif /* defined(HAVE_LIBXXF86DGA) */
2086 static HRESULT WINAPI
Xlib_IDirectDraw2_GetDisplayMode(
2087 LPDIRECTDRAW2
this,LPDDSURFACEDESC lpddsfd
2089 TRACE(ddraw
,"(%p)->GetDisplayMode(%p)\n",this,lpddsfd
);
2090 lpddsfd
->dwFlags
= DDSD_HEIGHT
|DDSD_WIDTH
|DDSD_PITCH
|DDSD_BACKBUFFERCOUNT
|DDSD_PIXELFORMAT
|DDSD_CAPS
;
2091 lpddsfd
->dwHeight
= screenHeight
;
2092 lpddsfd
->dwWidth
= screenWidth
;
2093 /* POOLE FIXME: Xlib */
2094 lpddsfd
->lPitch
= this->e
.dga
.fb_width
*this->d
.depth
/8;
2095 /* END FIXME: Xlib */
2096 lpddsfd
->dwBackBufferCount
= 1;
2097 lpddsfd
->x
.dwRefreshRate
= 60;
2098 lpddsfd
->ddsCaps
.dwCaps
= DDSCAPS_PALETTE
;
2099 _getpixelformat(this,&(lpddsfd
->ddpfPixelFormat
));
2103 static HRESULT WINAPI
IDirectDraw2_FlipToGDISurface(LPDIRECTDRAW2
this) {
2104 TRACE(ddraw
,"(%p)->()\n",this);
2108 static HRESULT WINAPI
IDirectDraw2_GetMonitorFrequency(
2109 LPDIRECTDRAW2
this,LPDWORD freq
2111 FIXME(ddraw
,"(%p)->(%p) returns 60 Hz always\n",this,freq
);
2112 *freq
= 60*100; /* 60 Hz */
2116 /* what can we directly decompress? */
2117 static HRESULT WINAPI
IDirectDraw2_GetFourCCCodes(
2118 LPDIRECTDRAW2
this,LPDWORD x
,LPDWORD y
2120 FIXME(ddraw
,"(%p,%p,%p), stub\n",this,x
,y
);
2124 static HRESULT WINAPI
IDirectDraw2_EnumSurfaces(
2125 LPDIRECTDRAW2
this,DWORD x
,LPDDSURFACEDESC ddsfd
,LPVOID context
,LPDDENUMSURFACESCALLBACK ddsfcb
2127 FIXME(ddraw
,"(%p)->(0x%08lx,%p,%p,%p),stub!\n",this,x
,ddsfd
,context
,ddsfcb
);
2131 static HRESULT WINAPI
IDirectDraw2_Compact(
2132 LPDIRECTDRAW2
this )
2134 FIXME(ddraw
,"(%p)->()\n", this );
2140 /* Note: Hack so we can reuse the old functions without compiler warnings */
2142 # define XCAST(fun) (typeof(dga_ddvt.fn##fun))
2144 # define XCAST(fun) (void*)
2147 static struct IDirectDraw_VTable dga_ddvt
= {
2148 XCAST(QueryInterface
)DGA_IDirectDraw2_QueryInterface
,
2149 XCAST(AddRef
)IDirectDraw2_AddRef
,
2150 XCAST(Release
)DGA_IDirectDraw2_Release
,
2151 XCAST(Compact
)IDirectDraw2_Compact
,
2152 XCAST(CreateClipper
)IDirectDraw2_CreateClipper
,
2153 XCAST(CreatePalette
)DGA_IDirectDraw2_CreatePalette
,
2154 XCAST(CreateSurface
)DGA_IDirectDraw2_CreateSurface
,
2155 XCAST(DuplicateSurface
)IDirectDraw2_DuplicateSurface
,
2156 XCAST(EnumDisplayModes
)IDirectDraw2_EnumDisplayModes
,
2157 XCAST(EnumSurfaces
)IDirectDraw2_EnumSurfaces
,
2158 XCAST(FlipToGDISurface
)IDirectDraw2_FlipToGDISurface
,
2159 XCAST(GetCaps
)DGA_IDirectDraw2_GetCaps
,
2160 XCAST(GetDisplayMode
)DGA_IDirectDraw2_GetDisplayMode
,
2161 XCAST(GetFourCCCodes
)IDirectDraw2_GetFourCCCodes
,
2162 XCAST(GetGDISurface
)15,
2163 XCAST(GetMonitorFrequency
)IDirectDraw2_GetMonitorFrequency
,
2164 XCAST(GetScanLine
)17,
2165 XCAST(GetVerticalBlankStatus
)IDirectDraw2_GetVerticalBlankStatus
,
2166 XCAST(Initialize
)19,
2167 XCAST(RestoreDisplayMode
)DGA_IDirectDraw2_RestoreDisplayMode
,
2168 XCAST(SetCooperativeLevel
)IDirectDraw2_SetCooperativeLevel
,
2169 DGA_IDirectDraw_SetDisplayMode
,
2170 XCAST(WaitForVerticalBlank
)IDirectDraw2_WaitForVerticalBlank
,
2173 static struct IDirectDraw_VTable xlib_ddvt
= {
2174 XCAST(QueryInterface
)Xlib_IDirectDraw2_QueryInterface
,
2175 XCAST(AddRef
)IDirectDraw2_AddRef
,
2176 XCAST(Release
)Xlib_IDirectDraw2_Release
,
2177 XCAST(Compact
)IDirectDraw2_Compact
,
2178 XCAST(CreateClipper
)IDirectDraw2_CreateClipper
,
2179 XCAST(CreatePalette
)Xlib_IDirectDraw2_CreatePalette
,
2180 XCAST(CreateSurface
)Xlib_IDirectDraw2_CreateSurface
,
2181 XCAST(DuplicateSurface
)IDirectDraw2_DuplicateSurface
,
2182 XCAST(EnumDisplayModes
)IDirectDraw2_EnumDisplayModes
,
2183 XCAST(EnumSurfaces
)IDirectDraw2_EnumSurfaces
,
2184 XCAST(FlipToGDISurface
)IDirectDraw2_FlipToGDISurface
,
2185 XCAST(GetCaps
)Xlib_IDirectDraw2_GetCaps
,
2186 XCAST(GetDisplayMode
)Xlib_IDirectDraw2_GetDisplayMode
,
2187 XCAST(GetFourCCCodes
)IDirectDraw2_GetFourCCCodes
,
2188 XCAST(GetGDISurface
)15,
2189 XCAST(GetMonitorFrequency
)IDirectDraw2_GetMonitorFrequency
,
2190 XCAST(GetScanLine
)17,
2191 XCAST(GetVerticalBlankStatus
)IDirectDraw2_GetVerticalBlankStatus
,
2192 XCAST(Initialize
)19,
2193 XCAST(RestoreDisplayMode
)Xlib_IDirectDraw2_RestoreDisplayMode
,
2194 XCAST(SetCooperativeLevel
)IDirectDraw2_SetCooperativeLevel
,
2195 Xlib_IDirectDraw_SetDisplayMode
,
2196 XCAST(WaitForVerticalBlank
)IDirectDraw2_WaitForVerticalBlank
,
2199 /*****************************************************************************
2205 static HRESULT WINAPI
DGA_IDirectDraw2_SetDisplayMode(
2206 LPDIRECTDRAW2
this,DWORD width
,DWORD height
,DWORD depth
,DWORD xx
,DWORD yy
2208 return DGA_IDirectDraw_SetDisplayMode((LPDIRECTDRAW
)this,width
,height
,depth
);
2211 static HRESULT WINAPI
Xlib_IDirectDraw2_SetDisplayMode(
2212 LPDIRECTDRAW2
this,DWORD width
,DWORD height
,DWORD depth
,DWORD xx
,DWORD yy
2214 return Xlib_IDirectDraw_SetDisplayMode((LPDIRECTDRAW
)this,width
,height
,depth
);
2217 static HRESULT WINAPI
DGA_IDirectDraw2_GetAvailableVidMem(
2218 LPDIRECTDRAW2
this,LPDDSCAPS ddscaps
,LPDWORD total
,LPDWORD free
2220 TRACE(ddraw
,"(%p)->(%p,%p,%p)\n",
2221 this,ddscaps
,total
,free
2223 if (total
) *total
= this->e
.dga
.fb_memsize
* 1024;
2224 if (free
) *free
= this->e
.dga
.fb_memsize
* 1024;
2228 static HRESULT WINAPI
Xlib_IDirectDraw2_GetAvailableVidMem(
2229 LPDIRECTDRAW2
this,LPDDSCAPS ddscaps
,LPDWORD total
,LPDWORD free
2231 TRACE(ddraw
,"(%p)->(%p,%p,%p)\n",
2232 this,ddscaps
,total
,free
2234 if (total
) *total
= 2048 * 1024;
2235 if (free
) *free
= 2048 * 1024;
2239 static IDirectDraw2_VTable dga_dd2vt
= {
2240 DGA_IDirectDraw2_QueryInterface
,
2241 IDirectDraw2_AddRef
,
2242 DGA_IDirectDraw2_Release
,
2243 IDirectDraw2_Compact
,
2244 IDirectDraw2_CreateClipper
,
2245 DGA_IDirectDraw2_CreatePalette
,
2246 DGA_IDirectDraw2_CreateSurface
,
2248 IDirectDraw2_EnumDisplayModes
,
2249 IDirectDraw2_EnumSurfaces
,
2250 IDirectDraw2_FlipToGDISurface
,
2251 DGA_IDirectDraw2_GetCaps
,
2252 DGA_IDirectDraw2_GetDisplayMode
,
2253 IDirectDraw2_GetFourCCCodes
,
2255 IDirectDraw2_GetMonitorFrequency
,
2257 IDirectDraw2_GetVerticalBlankStatus
,
2259 DGA_IDirectDraw2_RestoreDisplayMode
,
2260 IDirectDraw2_SetCooperativeLevel
,
2261 DGA_IDirectDraw2_SetDisplayMode
,
2262 IDirectDraw2_WaitForVerticalBlank
,
2263 DGA_IDirectDraw2_GetAvailableVidMem
2266 static struct IDirectDraw2_VTable xlib_dd2vt
= {
2267 Xlib_IDirectDraw2_QueryInterface
,
2268 IDirectDraw2_AddRef
,
2269 Xlib_IDirectDraw2_Release
,
2270 IDirectDraw2_Compact
,
2271 IDirectDraw2_CreateClipper
,
2272 Xlib_IDirectDraw2_CreatePalette
,
2273 Xlib_IDirectDraw2_CreateSurface
,
2275 IDirectDraw2_EnumDisplayModes
,
2276 IDirectDraw2_EnumSurfaces
,
2277 IDirectDraw2_FlipToGDISurface
,
2278 Xlib_IDirectDraw2_GetCaps
,
2279 Xlib_IDirectDraw2_GetDisplayMode
,
2280 IDirectDraw2_GetFourCCCodes
,
2282 IDirectDraw2_GetMonitorFrequency
,
2284 IDirectDraw2_GetVerticalBlankStatus
,
2286 Xlib_IDirectDraw2_RestoreDisplayMode
,
2287 IDirectDraw2_SetCooperativeLevel
,
2288 Xlib_IDirectDraw2_SetDisplayMode
,
2289 IDirectDraw2_WaitForVerticalBlank
,
2290 Xlib_IDirectDraw2_GetAvailableVidMem
2293 /******************************************************************************
2297 HRESULT WINAPI
DGA_DirectDrawCreate( LPDIRECTDRAW
*lplpDD
, LPUNKNOWN pUnkOuter
) {
2298 #ifdef HAVE_LIBXXF86DGA
2299 int memsize
,banksize
,width
,major
,minor
,flags
,height
;
2302 if (getuid() != 0) {
2303 MSG("Must be root to use XF86DGA!\n");
2304 MessageBox32A(0,"Using the XF86DGA extension requires the program to be run using UID 0.","WINE DirectDraw",MB_OK
|MB_ICONSTOP
);
2305 return E_UNEXPECTED
;
2307 if (!DDRAW_DGA_Available()) {
2308 TRACE(ddraw
,"No XF86DGA detected.\n");
2309 return DDERR_GENERIC
;
2311 *lplpDD
= (LPDIRECTDRAW
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirectDraw
));
2312 (*lplpDD
)->lpvtbl
= &dga_ddvt
;
2314 TSXF86DGAQueryVersion(display
,&major
,&minor
);
2315 TRACE(ddraw
,"XF86DGA is version %d.%d\n",major
,minor
);
2316 TSXF86DGAQueryDirectVideo(display
,DefaultScreen(display
),&flags
);
2317 if (!(flags
& XF86DGADirectPresent
))
2318 MSG("direct video is NOT PRESENT.\n");
2319 TSXF86DGAGetVideo(display
,DefaultScreen(display
),&addr
,&width
,&banksize
,&memsize
);
2320 TRACE(ddraw
,"video framebuffer: begin %p, width %d,banksize %d,memsize %d\n",
2321 addr
,width
,banksize
,memsize
2323 (*lplpDD
)->e
.dga
.fb_width
= width
;
2324 (*lplpDD
)->d
.width
= width
;
2325 (*lplpDD
)->e
.dga
.fb_addr
= addr
;
2326 (*lplpDD
)->e
.dga
.fb_memsize
= memsize
;
2327 (*lplpDD
)->e
.dga
.fb_banksize
= banksize
;
2329 TSXF86DGAGetViewPortSize(display
,DefaultScreen(display
),&width
,&height
);
2330 TSXF86DGASetViewPort(display
,DefaultScreen(display
),0,0);
2331 (*lplpDD
)->e
.dga
.fb_height
= screenHeight
;
2333 (*lplpDD
)->e
.dga
.vpmask
= 1;
2335 (*lplpDD
)->e
.dga
.vpmask
= 0;
2338 /* just assume the default depth is the DGA depth too */
2339 (*lplpDD
)->d
.depth
= DefaultDepthOfScreen(screen
);
2340 #ifdef RESTORE_SIGNALS
2341 SIGNAL_InitEmulator();
2344 #else /* defined(HAVE_LIBXXF86DGA) */
2345 return DDERR_INVALIDDIRECTDRAWGUID
;
2346 #endif /* defined(HAVE_LIBXXF86DGA) */
2349 LRESULT WINAPI
Xlib_DDWndProc(HWND32 hwnd
,UINT32 msg
,WPARAM32 wParam
,LPARAM lParam
)
2352 LPDIRECTDRAW ddraw
= NULL
;
2355 /*FIXME(ddraw,"(0x%04x,%s,0x%08lx,0x%08lx),stub!\n",(int)hwnd,SPY_GetMsgName(msg),(long)wParam,(long)lParam); */
2357 SetLastError( ERROR_SUCCESS
);
2358 ddraw
= (LPDIRECTDRAW
)GetWindowLong32A( hwnd
, ddrawXlibThisOffset
);
2360 ( ( lastError
= GetLastError() ) != ERROR_SUCCESS
)
2363 ERR( ddraw
, "Unable to retrieve this ptr from window. Error %08lx\n", lastError
);
2368 /* Perform any special direct draw functions */
2371 ddraw
->e
.xlib
.paintable
= 1;
2374 /* Now let the application deal with the rest of this */
2375 if( ddraw
->d
.mainWindow
)
2378 /* Don't think that we actually need to call this but...
2379 might as well be on the safe side of things... */
2380 ret
= DefWindowProc32A( hwnd
, msg
, wParam
, lParam
);
2384 /* We didn't handle the message - give it to the application */
2385 if (ddraw
&& ddraw
->d
.mainWindow
&& WIN_FindWndPtr(ddraw
->d
.mainWindow
))
2386 ret
= CallWindowProc32A( WIN_FindWndPtr( ddraw
->d
.mainWindow
)->winproc
,
2387 ddraw
->d
.mainWindow
, msg
, wParam
, lParam
);
2393 ret
= DefWindowProc32A( ddraw
->d
.mainWindow
, msg
, wParam
, lParam
);
2399 ret
= DefWindowProc32A(hwnd
,msg
,wParam
,lParam
);
2405 HRESULT WINAPI
Xlib_DirectDrawCreate( LPDIRECTDRAW
*lplpDD
, LPUNKNOWN pUnkOuter
) {
2410 *lplpDD
= (LPDIRECTDRAW
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirectDraw
));
2411 (*lplpDD
)->lpvtbl
= &xlib_ddvt
;
2413 (*lplpDD
)->e
.xlib
.drawable
= 0; /* in SetDisplayMode */
2414 (*lplpDD
)->e
.xlib
.use_xshm
= have_xshm
;
2415 wc
.style
= CS_GLOBALCLASS
;
2416 wc
.lpfnWndProc
= Xlib_DDWndProc
;
2418 wc
.cbWndExtra
= /* Defines extra mem for window. This is used for storing this */
2419 sizeof( LPDIRECTDRAW
); /* ddrawXlibThisOffset */
2421 /* We can be a child of the desktop since we're really important */
2422 pParentWindow
= WIN_GetDesktop();
2423 wc
.hInstance
= pParentWindow
? pParentWindow
->hwndSelf
: 0;
2427 wc
.hCursor
= (HCURSOR32
)IDC_ARROW32A
;
2428 wc
.hbrBackground
= NULL_BRUSH
;
2429 wc
.lpszMenuName
= 0;
2430 wc
.lpszClassName
= "WINE_DirectDraw";
2432 (*lplpDD
)->e
.xlib
.winclass
= RegisterClass32A(&wc
);
2434 (*lplpDD
)->d
.depth
= DefaultDepthOfScreen(screen
);
2435 (*lplpDD
)->d
.height
= screenHeight
;
2436 (*lplpDD
)->d
.width
= screenWidth
;
2440 HRESULT WINAPI
DirectDrawCreate( LPGUID lpGUID
, LPDIRECTDRAW
*lplpDD
, LPUNKNOWN pUnkOuter
) {
2444 WINE_StringFromCLSID(lpGUID
,xclsid
);
2446 sprintf(xclsid
,"<guid-%0x08x>",(int)lpGUID
);
2450 TRACE(ddraw
,"(%s,%p,%p)\n",xclsid
,lplpDD
,pUnkOuter
);
2453 /* if they didn't request a particular interface, use the best
2455 if (DDRAW_DGA_Available())
2456 lpGUID
= &DGA_DirectDraw_GUID
;
2458 lpGUID
= &XLIB_DirectDraw_GUID
;
2461 if (!memcmp(lpGUID
, &DGA_DirectDraw_GUID
, sizeof(GUID
)))
2462 return DGA_DirectDrawCreate(lplpDD
, pUnkOuter
);
2463 else if (!memcmp(lpGUID
, &XLIB_DirectDraw_GUID
, sizeof(GUID
)))
2464 return Xlib_DirectDrawCreate(lplpDD
, pUnkOuter
);
2466 fprintf(stderr
,"DirectDrawCreate(%s,%p,%p): did not recognize requested GUID\n",xclsid
,lplpDD
,pUnkOuter
);
2467 return DDERR_INVALIDDIRECTDRAWGUID
;