1 /* DirectDrawSurface Xlib implementation
3 * Copyright 1997-2000 Marcus Meissner
4 * Copyright 1998-2000 Lionel Ulmer (most of Direct3D stuff)
17 #include "debugtools.h"
18 #include "x11_private.h"
24 /* for d3d texture stuff */
25 # include "mesa_private.h"
28 DEFAULT_DEBUG_CHANNEL(ddraw);
30 #define VISIBLE(x) (SDDSCAPS(x) & (DDSCAPS_VISIBLE|DDSCAPS_PRIMARYSURFACE))
32 #define DDPRIVATE(x) x11_dd_private *ddpriv = ((x11_dd_private*)(x)->d->private)
33 #define DPPRIVATE(x) x11_dp_private *dppriv = ((x11_dp_private*)(x)->private)
34 #define DSPRIVATE(x) x11_ds_private *dspriv = ((x11_ds_private*)(x)->private)
36 static BYTE Xlib_TouchData(LPVOID data)
38 /* this is a function so it doesn't get optimized out */
42 /******************************************************************************
43 * IDirectDrawSurface methods
45 * Since DDS3 and DDS2 are supersets of DDS, we implement DDS3 and let
46 * DDS and DDS2 use those functions. (Function calls did not change (except
47 * using different DirectDrawSurfaceX version), just added flags and functions)
49 HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_QueryInterface(
50 LPDIRECTDRAWSURFACE4 iface,REFIID refiid,LPVOID *obj
52 ICOM_THIS(IDirectDrawSurface4Impl,iface);
54 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
56 /* All DirectDrawSurface versions (1, 2, 3 and 4) use
57 * the same interface. And IUnknown does that too of course.
59 if ( IsEqualGUID( &IID_IDirectDrawSurface4, refiid ) ||
60 IsEqualGUID( &IID_IDirectDrawSurface3, refiid ) ||
61 IsEqualGUID( &IID_IDirectDrawSurface2, refiid ) ||
62 IsEqualGUID( &IID_IDirectDrawSurface, refiid ) ||
63 IsEqualGUID( &IID_IUnknown, refiid )
66 IDirectDrawSurface4_AddRef(iface);
68 TRACE(" Creating IDirectDrawSurface interface (%p)\n", *obj);
72 if ( IsEqualGUID( &IID_IDirect3DTexture2, refiid ) ) {
73 /* Texture interface */
74 *obj = d3dtexture2_create(This);
75 IDirectDrawSurface4_AddRef(iface);
76 TRACE(" Creating IDirect3DTexture2 interface (%p)\n", *obj);
79 if ( IsEqualGUID( &IID_IDirect3DTexture, refiid ) ) {
80 /* Texture interface */
81 *obj = d3dtexture_create(This);
82 IDirectDrawSurface4_AddRef(iface);
83 TRACE(" Creating IDirect3DTexture interface (%p)\n", *obj);
87 if ( IsEqualGUID( &IID_IDirect3DTexture2, refiid ) ||
88 IsEqualGUID( &IID_IDirect3DTexture, refiid )
91 ERR( "Cannot provide 3D support without OpenGL/Mesa installed\n" );
93 #endif /* HAVE_OPENGL */
94 FIXME("(%p):interface for IID %s NOT found!\n",This,debugstr_guid(refiid));
95 return OLE_E_ENUM_NOMORE;
98 HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Lock(
99 LPDIRECTDRAWSURFACE4 iface,LPRECT lprect,LPDDSURFACEDESC lpddsd,DWORD flags, HANDLE hnd
101 ICOM_THIS(IDirectDrawSurface4Impl,iface);
103 DDPRIVATE(This->s.ddraw);
105 /* DO NOT AddRef the surface! Lock/Unlock are NOT guaranteed to come in
106 * matched pairs! - Marcus Meissner 20000509 */
107 TRACE("(%p)->Lock(%p,%p,%08lx,%08lx) ret=%p\n",This,lprect,lpddsd,flags,(DWORD)hnd,__builtin_return_address(0));
108 if (flags & ~(DDLOCK_WAIT|DDLOCK_READONLY|DDLOCK_WRITEONLY))
109 WARN("(%p)->Lock(%p,%p,%08lx,%08lx)\n",
110 This,lprect,lpddsd,flags,(DWORD)hnd);
112 /* First, copy the Surface description */
113 *lpddsd = This->s.surface_desc;
114 TRACE("locked surface: height=%ld, width=%ld, pitch=%ld\n",
115 lpddsd->dwHeight,lpddsd->dwWidth,lpddsd->lPitch);
117 /* If asked only for a part, change the surface pointer */
119 TRACE(" lprect: %dx%d-%dx%d\n",
120 lprect->top,lprect->left,lprect->bottom,lprect->right
122 if ((lprect->top < 0) ||
123 (lprect->left < 0) ||
124 (lprect->bottom < 0) ||
125 (lprect->right < 0)) {
126 ERR(" Negative values in LPRECT !!!\n");
127 return DDERR_INVALIDPARAMS;
129 lpddsd->u1.lpSurface=(LPVOID)((char*)This->s.surface_desc.u1.lpSurface+
130 (lprect->top*This->s.surface_desc.lPitch) +
131 lprect->left*GET_BPP(This->s.surface_desc));
133 assert(This->s.surface_desc.u1.lpSurface);
134 /* wait for any previous operations to complete */
136 if (dspriv->info.image && VISIBLE(This) && ddpriv->xshm_active) {
138 int compl = InterlockedExchange( &(ddpriv->xshm_compl), 0 );
139 if (compl) X11DRV_EVENT_WaitShmCompletion( compl );
141 X11DRV_EVENT_WaitShmCompletions( ddpriv->drawable );
145 /* If part of a visible 'clipped' surface, copy what is seen on the
146 screen to the surface */
147 if ((dspriv->info.image && VISIBLE(This)) &&
148 (This->s.lpClipper)) {
149 HWND hWnd = ((IDirectDrawClipperImpl *) This->s.lpClipper)->hWnd;
150 WND *wndPtr = WIN_FindWndPtr(hWnd);
151 Drawable drawable = X11DRV_WND_GetXWindow(wndPtr);
152 int width = wndPtr->rectClient.right - wndPtr->rectClient.left;
153 int height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
154 /* Now, get the source / destination coordinates */
155 int dest_x = wndPtr->rectClient.left;
156 int dest_y = wndPtr->rectClient.top;
158 if (!drawable) { /* we are running in -desktop mode */
159 drawable = X11DRV_WND_GetXWindow(WIN_GetDesktop());
160 /* FIXME: not sure whether these are the right offsets */
161 dest_x+=wndPtr->rectWindow.left;
162 dest_y+=wndPtr->rectWindow.top;
163 WIN_ReleaseDesktop();
166 TSXGetSubImage(display, drawable, 0, 0, width, height, 0xFFFFFFFF,
167 ZPixmap, dspriv->info.image, dest_x, dest_y);
169 WIN_ReleaseWndPtr(wndPtr);
175 static void Xlib_copy_surface_on_screen(IDirectDrawSurface4Impl* This) {
177 DDPRIVATE(This->s.ddraw);
178 Drawable drawable = ddpriv->drawable;
179 POINT adjust[2] = {{0, 0}, {0, 0}};
182 /* Get XImage size */
183 imgsiz.cx = dspriv->info.image->width;
184 imgsiz.cy = dspriv->info.image->height;
186 if (This->s.lpClipper) {
187 HWND hWnd = ((IDirectDrawClipperImpl *) This->s.lpClipper)->hWnd;
189 WND *wndPtr = WIN_FindWndPtr(hWnd);
190 drawable = X11DRV_WND_GetXWindow(wndPtr);
192 MapWindowPoints(hWnd, 0, adjust, 2);
194 imgsiz.cx -= adjust[0].x;
195 imgsiz.cy -= adjust[0].y;
196 /* (note: the rectWindow here should be the X window's interior rect, in
197 * case anyone thinks otherwise while rewriting managed mode) */
198 adjust[1].x -= wndPtr->rectWindow.left;
199 adjust[1].y -= wndPtr->rectWindow.top;
200 csiz.cx = wndPtr->rectClient.right - wndPtr->rectClient.left;
201 csiz.cy = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
202 if (csiz.cx < imgsiz.cx) imgsiz.cx = csiz.cx;
203 if (csiz.cy < imgsiz.cy) imgsiz.cy = csiz.cy;
205 TRACE("adjust: hwnd=%08x, surface %ldx%ld, drawable %ldx%ld\n", hWnd,
206 adjust[0].x, adjust[0].y,
207 adjust[1].x,adjust[1].y);
209 WIN_ReleaseWndPtr(wndPtr);
213 WND *tmpWnd = WIN_FindWndPtr(This->s.ddraw->d->window);
214 drawable = X11DRV_WND_GetXWindow(tmpWnd);
215 WIN_ReleaseWndPtr(tmpWnd);
217 /* We don't have a context for this window. Host off the desktop */
219 FIXME("Have to use Desktop Root Window??? Bummer.\n");
220 drawable = X11DRV_WND_GetXWindow(WIN_GetDesktop());
221 WIN_ReleaseDesktop();
223 ddpriv->drawable = drawable;
226 if (This->s.ddraw->d->pixel_convert != NULL)
227 This->s.ddraw->d->pixel_convert(This->s.surface_desc.u1.lpSurface,
228 dspriv->info.image->data,
229 This->s.surface_desc.dwWidth,
230 This->s.surface_desc.dwHeight,
231 This->s.surface_desc.lPitch,
234 /* if the DIB section is in GdiMod state, we must
235 * touch the surface to get any updates from the DIB */
236 Xlib_TouchData(dspriv->info.image->data);
238 if (ddpriv->xshm_active) {
240 X11DRV_EVENT_WaitReplaceShmCompletion( &(ddpriv->xshm_compl), This->s.ddraw->d.drawable );
242 /* let WaitShmCompletions track 'em for now */
243 /* (you may want to track it again whenever you implement DX7's partial
244 * surface locking, where threads have concurrent access) */
245 X11DRV_EVENT_PrepareShmCompletion( ddpriv->drawable );
246 TSXShmPutImage(display,
248 DefaultGCOfScreen(X11DRV_GetXScreen()),
250 adjust[0].x, adjust[0].y, adjust[1].x, adjust[1].y,
251 imgsiz.cx, imgsiz.cy,
254 /* make sure the image is transferred ASAP */
260 DefaultGCOfScreen(X11DRV_GetXScreen()),
262 adjust[0].x, adjust[0].y, adjust[1].x, adjust[1].y,
267 HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Unlock(
268 LPDIRECTDRAWSURFACE4 iface,LPVOID surface
270 ICOM_THIS(IDirectDrawSurface4Impl,iface);
271 DDPRIVATE(This->s.ddraw);
273 TRACE("(%p)->Unlock(%p)\n",This,surface);
275 /*if (!This->s.ddraw->d.paintable)
278 /* Only redraw the screen when unlocking the buffer that is on screen */
279 if (dspriv->info.image && VISIBLE(This)) {
280 Xlib_copy_surface_on_screen(This);
281 if (This->s.palette) {
282 DPPRIVATE(This->s.palette);
284 TSXSetWindowColormap(display,ddpriv->drawable,dppriv->cm);
287 /* DO NOT Release the surface! Lock/Unlock are NOT guaranteed to come in
288 * matched pairs! - Marcus Meissner 20000509 */
293 static void Xlib_copy_overlay_on_screen(IDirectDrawSurface4Impl* This) {
295 DDPRIVATE(This->s.ddraw);
296 Drawable drawable = ddpriv->drawable;
299 WND *tmpWnd = WIN_FindWndPtr(This->s.ddraw->d->window);
300 drawable = X11DRV_WND_GetXWindow(tmpWnd);
301 WIN_ReleaseWndPtr(tmpWnd);
303 /* We don't have a context for this window. Host off the desktop */
305 FIXME("Have to use Desktop Root Window??? Bummer.\n");
306 drawable = X11DRV_WND_GetXWindow(WIN_GetDesktop());
307 WIN_ReleaseDesktop();
309 ddpriv->drawable = drawable;
313 if (ddpriv->xshm_active) {
314 /* let WaitShmCompletions track 'em for now */
315 /* (you may want to track it again whenever you implement DX7's partial
316 * surface locking, where threads have concurrent access) */
317 X11DRV_EVENT_PrepareShmCompletion( ddpriv->drawable );
318 TSXvShmPutImage(display, ddpriv->port_id, drawable, DefaultGCOfScreen(X11DRV_GetXScreen()),
319 dspriv->info.overlay.image,
320 dspriv->info.overlay.src_rect.left, dspriv->info.overlay.src_rect.top,
321 dspriv->info.overlay.src_rect.right - dspriv->info.overlay.src_rect.left,
322 dspriv->info.overlay.src_rect.bottom - dspriv->info.overlay.src_rect.top,
323 dspriv->info.overlay.dst_rect.left, dspriv->info.overlay.dst_rect.top,
324 dspriv->info.overlay.dst_rect.right - dspriv->info.overlay.dst_rect.left,
325 dspriv->info.overlay.dst_rect.bottom - dspriv->info.overlay.dst_rect.top,
327 /* make sure the image is transferred ASAP */
331 TSXvPutImage(display, ddpriv->port_id, drawable, DefaultGCOfScreen(X11DRV_GetXScreen()),
332 dspriv->info.overlay.image,
333 dspriv->info.overlay.src_rect.left, dspriv->info.overlay.src_rect.top,
334 dspriv->info.overlay.src_rect.right - dspriv->info.overlay.src_rect.left,
335 dspriv->info.overlay.src_rect.bottom - dspriv->info.overlay.src_rect.top,
336 dspriv->info.overlay.dst_rect.left, dspriv->info.overlay.dst_rect.top,
337 dspriv->info.overlay.dst_rect.right - dspriv->info.overlay.dst_rect.left,
338 dspriv->info.overlay.dst_rect.bottom - dspriv->info.overlay.dst_rect.top);
342 HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Flip(
343 LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWSURFACE4 flipto,DWORD dwFlags
345 ICOM_THIS(IDirectDrawSurface4Impl,iface);
347 DDPRIVATE(This->s.ddraw);
349 x11_ds_private *fspriv;
351 IDirectDrawSurface4Impl* iflipto=(IDirectDrawSurface4Impl*)flipto;
353 TRACE("(%p)->Flip(%p,%08lx)\n",This,iflipto,dwFlags);
354 if ((!This->s.ddraw->d->paintable) && (dspriv->is_overlay == FALSE))
357 iflipto = _common_find_flipto(This,iflipto);
358 fspriv = (x11_ds_private*)iflipto->private;
360 /* We need to switch the lowlevel surfaces, for xlib this is: */
361 /* The surface pointer */
362 surf = This->s.surface_desc.u1.lpSurface;
363 This->s.surface_desc.u1.lpSurface = iflipto->s.surface_desc.u1.lpSurface;
364 iflipto->s.surface_desc.u1.lpSurface = surf;
366 /* the associated ximage
368 NOTE : for XVideo, the pointer to the XvImage is at the same position
369 in memory than the standard XImage. This means that this code
372 image = dspriv->info.image;
373 dspriv->info.image = fspriv->info.image;
374 fspriv->info.image = image;
376 if (dspriv->opengl_flip) {
379 glXSwapBuffers(display, ddpriv->drawable);
382 } else if (dspriv->is_overlay) {
384 if (dspriv->info.overlay.shown)
385 Xlib_copy_overlay_on_screen(This);
387 ERR("Why was this code activated WITHOUT XVideo support ?\n");
391 if (ddpriv->xshm_active) {
393 int compl = InterlockedExchange( &(ddpriv->xshm_compl), 0 );
394 if (compl) X11DRV_EVENT_WaitShmCompletion( compl );
396 X11DRV_EVENT_WaitShmCompletions( ddpriv->drawable );
399 Xlib_copy_surface_on_screen(This);
400 if (iflipto->s.palette) {
401 DPPRIVATE(iflipto->s.palette);
403 TSXSetWindowColormap(display,ddpriv->drawable,dppriv->cm);
409 /* The IDirectDrawSurface4::SetPalette method attaches the specified
410 * DirectDrawPalette object to a surface. The surface uses this palette for all
411 * subsequent operations. The palette change takes place immediately.
413 HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_SetPalette(
414 LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWPALETTE pal
416 ICOM_THIS(IDirectDrawSurface4Impl,iface);
417 DDPRIVATE(This->s.ddraw);
418 IDirectDrawPaletteImpl* ipal=(IDirectDrawPaletteImpl*)pal;
419 x11_dp_private *dppriv;
422 TRACE("(%p)->(%p)\n",This,ipal);
425 if( This->s.palette != NULL )
426 IDirectDrawPalette_Release((IDirectDrawPalette*)This->s.palette);
427 This->s.palette = ipal;
430 dppriv = (x11_dp_private*)ipal->private;
433 (This->s.ddraw->d->screen_pixelformat.u.dwRGBBitCount<=8)
435 dppriv->cm = TSXCreateColormap(
438 DefaultVisualOfScreen(X11DRV_GetXScreen()),
441 if (!Options.managed)
442 TSXInstallColormap(display,dppriv->cm);
444 for (i=0;i<256;i++) {
447 xc.red = ipal->palents[i].peRed<<8;
448 xc.blue = ipal->palents[i].peBlue<<8;
449 xc.green = ipal->palents[i].peGreen<<8;
450 xc.flags = DoRed|DoBlue|DoGreen;
452 TSXStoreColor(display,dppriv->cm,&xc);
454 TSXInstallColormap(display,dppriv->cm);
456 /* According to spec, we are only supposed to
457 * AddRef if this is not the same palette.
459 if ( This->s.palette != ipal ) {
461 IDirectDrawPalette_AddRef( (IDirectDrawPalette*)ipal );
462 if( This->s.palette != NULL )
463 IDirectDrawPalette_Release( (IDirectDrawPalette*)This->s.palette );
464 This->s.palette = ipal;
465 /* Perform the refresh, only if a palette was created */
467 TSXSetWindowColormap(display,ddpriv->drawable,dppriv->cm);
469 if (This->s.hdc != 0) {
470 /* hack: set the DIBsection color map */
471 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
472 X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
473 dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
474 GDI_ReleaseObj(This->s.DIBsection);
480 ULONG WINAPI Xlib_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
481 ICOM_THIS(IDirectDrawSurface4Impl,iface);
483 DDPRIVATE(This->s.ddraw);
485 TRACE( "(%p)->() decrementing from %lu.\n", This, This->ref );
489 IDirectDraw2_Release((IDirectDraw2*)This->s.ddraw);
491 /* This frees the program-side surface. In some cases it had been
492 * allocated with MEM_SYSTEM, so it does not get 'really' freed
494 VirtualFree(This->s.surface_desc.u1.lpSurface, 0, MEM_RELEASE);
496 /* Now free the XImages and the respective screen-side surfaces */
497 if (dspriv->info.image != NULL) {
498 if (dspriv->info.image->data != This->s.surface_desc.u1.lpSurface)
499 VirtualFree(dspriv->info.image->data, 0, MEM_RELEASE);
501 if (ddpriv->xshm_active) {
502 TSXShmDetach(display, &(dspriv->shminfo));
503 if (This->s.surface_desc.ddsCaps.dwCaps & DDSCAPS_OVERLAY) {
504 TSXFree(dspriv->info.image);
506 TSXDestroyImage(dspriv->info.image);
508 shmdt(dspriv->shminfo.shmaddr);
512 if (This->s.surface_desc.ddsCaps.dwCaps & DDSCAPS_OVERLAY) {
513 TSXFree(dspriv->info.image);
515 /* normal X Image memory was never allocated by X, but always by
516 * ourselves -> Don't let X free our imagedata.
518 dspriv->info.image->data = NULL;
519 TSXDestroyImage(dspriv->info.image);
522 dspriv->info.image = 0;
526 IDirectDrawPalette_Release((IDirectDrawPalette*)This->s.palette);
528 /* Free the DIBSection (if any) */
529 if (This->s.hdc != 0) {
530 /* hack: restore the original DIBsection color map */
531 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
532 X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
533 dib->colorMap = dspriv->oldDIBmap;
534 GDI_ReleaseObj(This->s.DIBsection);
536 SelectObject(This->s.hdc, This->s.holdbitmap);
537 DeleteDC(This->s.hdc);
538 DeleteObject(This->s.DIBsection);
541 /* Free the clipper if present */
542 if(This->s.lpClipper)
543 IDirectDrawClipper_Release(This->s.lpClipper);
544 HeapFree(GetProcessHeap(),0,This->private);
545 HeapFree(GetProcessHeap(),0,This);
549 HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_GetDC(LPDIRECTDRAWSURFACE4 iface,HDC* lphdc) {
550 ICOM_THIS(IDirectDrawSurface4Impl,iface);
552 int was_ok = This->s.hdc != 0;
553 HRESULT result = IDirectDrawSurface4Impl_GetDC(iface,lphdc);
554 if (This->s.hdc && !was_ok) {
555 /* hack: take over the DIBsection color map */
556 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
557 X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
558 dspriv->oldDIBmap = dib->colorMap;
559 dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
560 GDI_ReleaseObj(This->s.DIBsection);
570 LPDIRECTDRAWSURFACE dest_surface;
571 } UpdateOverlayEnumerate;
573 static HRESULT WINAPI enum_func(LPDIRECTDRAWSURFACE lpDDSurface,
574 LPDDSURFACEDESC lpDDSurfaceDesc,
576 ICOM_THIS(IDirectDrawSurface4Impl,lpDDSurface);
578 UpdateOverlayEnumerate *ctx = (UpdateOverlayEnumerate *) lpContext;
580 if ((lpDDSurfaceDesc->ddsCaps.dwCaps) & DDSCAPS_BACKBUFFER) {
581 TRACE("Upgrading surface %p\n", lpDDSurface);
584 dspriv->info.overlay.shown = TRUE;
585 dspriv->info.overlay.src_rect = *(ctx->src_rect);
586 dspriv->info.overlay.dst_rect = *(ctx->dst_rect);
587 dspriv->info.overlay.dest_surface = ctx->dest_surface;
589 dspriv->info.overlay.shown = FALSE;
597 HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_UpdateOverlay(
598 LPDIRECTDRAWSURFACE4 iface, LPRECT lpSrcRect,
599 LPDIRECTDRAWSURFACE4 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags,
600 LPDDOVERLAYFX lpDDOverlayFx
602 ICOM_THIS(IDirectDrawSurface4Impl,iface);
605 DDPRIVATE(This->s.ddraw);
607 if (ddpriv->xvideo_active) {
608 TRACE("(%p)->(%p,%p,%p,0x%08lx,%p)\n", This,
609 lpSrcRect, lpDDDestSurface, lpDestRect, dwFlags, lpDDOverlayFx );
611 if (TRACE_ON(ddraw)) {
612 DPRINTF(" - dwFlags : ");
613 _dump_DDOVERLAY(dwFlags);
615 if (lpSrcRect) DPRINTF(" - src rectangle :%dx%d-%dx%d\n",lpSrcRect->left,lpSrcRect->top,
616 lpSrcRect->right,lpSrcRect->bottom);
617 if (lpDestRect) DPRINTF(" - dest rectangle :%dx%d-%dx%d\n",lpDestRect->left,lpDestRect->top,
618 lpDestRect->right,lpDestRect->bottom);
621 if (dwFlags & DDOVER_SHOW) {
622 UpdateOverlayEnumerate ctx;
624 dwFlags &= ~DDOVER_SHOW;
626 if ((lpSrcRect == NULL) || (lpDestRect == NULL)) {
627 FIXME("This is NOT supported yet...\n");
631 /* Set the shown BOOL to TRUE and update the rectangles */
632 dspriv->info.overlay.shown = TRUE;
633 dspriv->info.overlay.src_rect = *lpSrcRect;
634 dspriv->info.overlay.dst_rect = *lpDestRect;
635 dspriv->info.overlay.dest_surface = (LPDIRECTDRAWSURFACE) lpDDDestSurface;
637 /* Now the same for the backbuffers */
639 ctx.src_rect = lpSrcRect;
640 ctx.dst_rect = lpDestRect;
641 ctx.dest_surface = (LPDIRECTDRAWSURFACE) lpDDDestSurface;
643 IDirectDrawSurface4Impl_EnumAttachedSurfaces(iface, &ctx, enum_func);
644 } else if (dwFlags & DDOVER_HIDE) {
645 UpdateOverlayEnumerate ctx;
647 dwFlags &= ~DDOVER_HIDE;
649 /* Set the shown BOOL to FALSE for all overlays */
650 dspriv->info.overlay.shown = FALSE;
652 IDirectDrawSurface4Impl_EnumAttachedSurfaces(iface, &ctx, enum_func);
655 if (dwFlags && TRACE_ON(ddraw)) {
656 WARN("Unsupported flags : ");
657 _dump_DDOVERLAY(dwFlags);
661 FIXME("(%p)->(%p,%p,%p,0x%08lx,%p) not supported without XVideo !\n", This,
662 lpSrcRect, lpDDDestSurface, lpDestRect, dwFlags, lpDDOverlayFx );
667 ICOM_VTABLE(IDirectDrawSurface4) xlib_dds4vt =
669 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
670 Xlib_IDirectDrawSurface4Impl_QueryInterface,
671 IDirectDrawSurface4Impl_AddRef,
672 Xlib_IDirectDrawSurface4Impl_Release,
673 IDirectDrawSurface4Impl_AddAttachedSurface,
674 IDirectDrawSurface4Impl_AddOverlayDirtyRect,
675 IDirectDrawSurface4Impl_Blt,
676 IDirectDrawSurface4Impl_BltBatch,
677 IDirectDrawSurface4Impl_BltFast,
678 IDirectDrawSurface4Impl_DeleteAttachedSurface,
679 IDirectDrawSurface4Impl_EnumAttachedSurfaces,
680 IDirectDrawSurface4Impl_EnumOverlayZOrders,
681 Xlib_IDirectDrawSurface4Impl_Flip,
682 IDirectDrawSurface4Impl_GetAttachedSurface,
683 IDirectDrawSurface4Impl_GetBltStatus,
684 IDirectDrawSurface4Impl_GetCaps,
685 IDirectDrawSurface4Impl_GetClipper,
686 IDirectDrawSurface4Impl_GetColorKey,
687 Xlib_IDirectDrawSurface4Impl_GetDC,
688 IDirectDrawSurface4Impl_GetFlipStatus,
689 IDirectDrawSurface4Impl_GetOverlayPosition,
690 IDirectDrawSurface4Impl_GetPalette,
691 IDirectDrawSurface4Impl_GetPixelFormat,
692 IDirectDrawSurface4Impl_GetSurfaceDesc,
693 IDirectDrawSurface4Impl_Initialize,
694 IDirectDrawSurface4Impl_IsLost,
695 Xlib_IDirectDrawSurface4Impl_Lock,
696 IDirectDrawSurface4Impl_ReleaseDC,
697 IDirectDrawSurface4Impl_Restore,
698 IDirectDrawSurface4Impl_SetClipper,
699 IDirectDrawSurface4Impl_SetColorKey,
700 IDirectDrawSurface4Impl_SetOverlayPosition,
701 Xlib_IDirectDrawSurface4Impl_SetPalette,
702 Xlib_IDirectDrawSurface4Impl_Unlock,
703 Xlib_IDirectDrawSurface4Impl_UpdateOverlay,
704 IDirectDrawSurface4Impl_UpdateOverlayDisplay,
705 IDirectDrawSurface4Impl_UpdateOverlayZOrder,
706 IDirectDrawSurface4Impl_GetDDInterface,
707 IDirectDrawSurface4Impl_PageLock,
708 IDirectDrawSurface4Impl_PageUnlock,
709 IDirectDrawSurface4Impl_SetSurfaceDesc,
710 IDirectDrawSurface4Impl_SetPrivateData,
711 IDirectDrawSurface4Impl_GetPrivateData,
712 IDirectDrawSurface4Impl_FreePrivateData,
713 IDirectDrawSurface4Impl_GetUniquenessValue,
714 IDirectDrawSurface4Impl_ChangeUniquenessValue