diff --git a/dlls/ddraw/d3ddevice/mesa.c b/dlls/ddraw/d3ddevice/mesa.c index 12e2a72784d..de9e888a8fb 100644 --- a/dlls/ddraw/d3ddevice/mesa.c +++ b/dlls/ddraw/d3ddevice/mesa.c @@ -28,7 +28,7 @@ ICOM_VTABLE(IDirect3DDevice) OpenGL_vtable_dx3; #undef HAVE_BUGGY_MESAGL #define D3DDPRIVATE(x) mesa_d3dd_private *odev=((mesa_d3dd_private*)x->private) -#define DDPRIVATE(x) x11_dd_private *ddpriv=((x11_dd_private*)(x)->private) +#define DDPRIVATE(x) x11_dd_private *ddpriv=((x11_dd_private*)(x)->d->private) static const float id_mat[16] = { 1.0, 0.0, 0.0, 0.0, diff --git a/dlls/ddraw/ddraw/dga.c b/dlls/ddraw/ddraw/dga.c index a7b6b6aea3c..1a985479fbe 100644 --- a/dlls/ddraw/ddraw/dga.c +++ b/dlls/ddraw/ddraw/dga.c @@ -51,7 +51,7 @@ struct ICOM_VTABLE(IDirectDraw4) dga_dd4vt; static XF86VidModeModeInfo *orig_mode = NULL; #endif -#define DDPRIVATE(x) dga_dd_private *ddpriv = ((dga_dd_private*)(x)->private) +#define DDPRIVATE(x) dga_dd_private *ddpriv = ((dga_dd_private*)(x)->d->private) #define DPPRIVATE(x) dga_dp_private *dppriv = ((dga_dp_private*)(x)->private) /******************************************************************************* @@ -99,9 +99,9 @@ HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface_with_VT( dsurf->s.surface_desc = *lpddsd; if (!(lpddsd->dwFlags & DDSD_WIDTH)) - dsurf->s.surface_desc.dwWidth = This->d.width; + dsurf->s.surface_desc.dwWidth = This->d->width; if (!(lpddsd->dwFlags & DDSD_HEIGHT)) - dsurf->s.surface_desc.dwHeight = This->d.height; + dsurf->s.surface_desc.dwHeight = This->d->height; dsurf->s.surface_desc.dwFlags |= DDSD_WIDTH|DDSD_HEIGHT; @@ -118,7 +118,7 @@ HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface_with_VT( /* if i == 32 or maximum ... return error */ ddpriv->vpmask|=(1<lPitch = dsurf->s.surface_desc.lPitch = - ddpriv->fb_width*PFGET_BPP(This->d.directdraw_pixelformat); + ddpriv->fb_width*PFGET_BPP(This->d->directdraw_pixelformat); dsurf->s.surface_desc.u1.lpSurface = ddpriv->fb_addr + i*fbheight*lpddsd->lPitch; @@ -127,12 +127,12 @@ HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface_with_VT( /* Add flags if there were not present */ dsurf->s.surface_desc.dwFlags |= DDSD_WIDTH|DDSD_HEIGHT|DDSD_PITCH|DDSD_LPSURFACE|DDSD_PIXELFORMAT; - dsurf->s.surface_desc.dwWidth = This->d.width; - dsurf->s.surface_desc.dwHeight = This->d.height; - TRACE("primary surface: dwWidth=%ld, dwHeight=%ld, lPitch=%ld\n",This->d.width,This->d.height,lpddsd->lPitch); + dsurf->s.surface_desc.dwWidth = This->d->width; + dsurf->s.surface_desc.dwHeight = This->d->height; + TRACE("primary surface: dwWidth=%ld, dwHeight=%ld, lPitch=%ld\n",This->d->width,This->d->height,lpddsd->lPitch); /* We put our surface always in video memory */ SDDSCAPS(dsurf) |= DDSCAPS_VISIBLE|DDSCAPS_VIDEOMEMORY; - dsurf->s.surface_desc.ddpfPixelFormat = This->d.directdraw_pixelformat; + dsurf->s.surface_desc.ddpfPixelFormat = This->d->directdraw_pixelformat; dsurf->s.chain = NULL; if (lpddsd->dwFlags & DDSD_BACKBUFFERCOUNT) { @@ -221,12 +221,12 @@ static HRESULT WINAPI DGA_IDirectDrawImpl_SetDisplayMode( return DDERR_UNSUPPORTEDMODE; } - if (This->d.width < width) { - ERR("SetDisplayMode(w=%ld,h=%ld,d=%ld), width %ld exceeds framebuffer width %ld\n",width,height,depth,width,This->d.width); + if (This->d->width < width) { + ERR("SetDisplayMode(w=%ld,h=%ld,d=%ld), width %ld exceeds framebuffer width %ld\n",width,height,depth,width,This->d->width); return DDERR_UNSUPPORTEDMODE; } - This->d.width = width; - This->d.height = height; + This->d->width = width; + This->d->height = height; /* adjust fb_height, so we don't overlap */ if (ddpriv->fb_height < height) @@ -373,7 +373,7 @@ static HRESULT WINAPI DGA_IDirectDraw2Impl_CreatePalette( dppriv = (dga_dp_private*)ddpal->private; ICOM_VTBL(ddpal)= &dga_ddpalvt; - if (This->d.directdraw_pixelformat.u.dwRGBBitCount<=8) { + if (This->d->directdraw_pixelformat.u.dwRGBBitCount<=8) { dppriv->cm = TSXCreateColormap(display,DefaultRootWindow(display),DefaultVisualOfScreen(X11DRV_GetXScreen()),AllocAll); } else { ERR("why are we doing CreatePalette in hi/truecolor?\n"); @@ -411,29 +411,32 @@ static ULONG WINAPI DGA_IDirectDraw2Impl_Release(LPDIRECTDRAW2 iface) { TRACE("(%p)->() decrementing from %lu.\n", This, This->ref ); if (!--(This->ref)) { - VirtualFree(ddpriv->fb_addr, 0, MEM_RELEASE); - TSXF86DGADirectVideo(display,DefaultScreen(display),0); - if (This->d.window && GetPropA(This->d.window,ddProp)) - DestroyWindow(This->d.window); + if (!--(This->d->ref)) { + VirtualFree(ddpriv->fb_addr, 0, MEM_RELEASE); + TSXF86DGADirectVideo(display,DefaultScreen(display),0); + if (This->d->window && GetPropA(This->d->window,ddProp)) + DestroyWindow(This->d->window); #ifdef HAVE_LIBXXF86VM - if (orig_mode) { - TSXF86VidModeSwitchToMode( - display, - DefaultScreen(display), - orig_mode - ); - if (orig_mode->privsize) - TSXFree(orig_mode->private); - free(orig_mode); - orig_mode = NULL; - } + if (orig_mode) { + TSXF86VidModeSwitchToMode( + display, + DefaultScreen(display), + orig_mode + ); + if (orig_mode->privsize) + TSXFree(orig_mode->private); + free(orig_mode); + orig_mode = NULL; + } #endif - + #ifdef RESTORE_SIGNALS - SIGNAL_Init(); + SIGNAL_Init(); #endif - HeapFree(GetProcessHeap(),0,This); - return S_OK; + HeapFree(GetProcessHeap(),0,This->d); + } + HeapFree(GetProcessHeap(),0,This); + return S_OK; } return This->ref; } @@ -453,30 +456,31 @@ HRESULT WINAPI DGA_IDirectDraw2Impl_QueryInterface( return S_OK; } if ( IsEqualGUID( &IID_IDirectDraw, refiid ) ) { - ICOM_VTBL(This) = (ICOM_VTABLE(IDirectDraw2)*)&dga_ddvt; - IDirectDraw2_AddRef(iface); - *obj = This; + IDirectDrawImpl *dd = HeapAlloc(GetProcessHeap(),0,sizeof(*dd)); + ICOM_VTBL(dd) = &dga_ddvt;dd->ref = 1;dd->d = This->d;This->d++; + *obj = dd; + IDirectDraw2_AddRef(iface); TRACE(" Creating IDirectDraw interface (%p)\n", *obj); return S_OK; } if ( IsEqualGUID( &IID_IDirectDraw2, refiid ) ) { - ICOM_VTBL(This) = (ICOM_VTABLE(IDirectDraw2)*)&dga_dd2vt; + IDirectDraw2Impl *dd = HeapAlloc(GetProcessHeap(),0,sizeof(*dd)); + ICOM_VTBL(dd) = &dga_dd2vt;dd->ref = 1;dd->d = This->d;This->d++; + *obj = dd; + IDirectDraw2_AddRef(iface); - *obj = This; - TRACE(" Creating IDirectDraw2 interface (%p)\n", *obj); - return S_OK; } if ( IsEqualGUID( &IID_IDirectDraw4, refiid ) ) { - ICOM_VTBL(This) = (ICOM_VTABLE(IDirectDraw2)*)&dga_dd4vt; + IDirectDraw2Impl *dd = HeapAlloc(GetProcessHeap(),0,sizeof(*dd)); + ICOM_VTBL(dd) = &dga_dd2vt;dd->ref = 1;dd->d = This->d;This->d++; + *obj = dd; + IDirectDraw2_AddRef(iface); - *obj = This; - TRACE(" Creating IDirectDraw4 interface (%p)\n", *obj); - return S_OK; } FIXME("(%p):interface for IID %s _NOT_ found!\n",This,debugstr_guid(refiid)); @@ -579,13 +583,13 @@ HRESULT WINAPI DGA_IDirectDraw2Impl_GetDisplayMode( TRACE("(%p)->(%p)\n",This,lpddsfd); lpddsfd->dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PITCH|DDSD_BACKBUFFERCOUNT|DDSD_PIXELFORMAT|DDSD_CAPS; - lpddsfd->dwHeight = This->d.height; - lpddsfd->dwWidth = This->d.width; - lpddsfd->lPitch = ddpriv->fb_width*PFGET_BPP(This->d.directdraw_pixelformat); + lpddsfd->dwHeight = This->d->height; + lpddsfd->dwWidth = This->d->width; + lpddsfd->lPitch = ddpriv->fb_width*PFGET_BPP(This->d->directdraw_pixelformat); lpddsfd->dwBackBufferCount = 2; lpddsfd->u.dwRefreshRate = 60; lpddsfd->ddsCaps.dwCaps = DDSCAPS_PALETTE; - lpddsfd->ddpfPixelFormat = This->d.directdraw_pixelformat; + lpddsfd->ddpfPixelFormat = This->d->directdraw_pixelformat; if (TRACE_ON(ddraw)) _dump_surface_desc(lpddsfd); return DD_OK; diff --git a/dlls/ddraw/ddraw/dga2.c b/dlls/ddraw/ddraw/dga2.c index bb5cc9cf20e..2c60201b2fd 100644 --- a/dlls/ddraw/ddraw/dga2.c +++ b/dlls/ddraw/ddraw/dga2.c @@ -29,7 +29,7 @@ struct ICOM_VTABLE(IDirectDraw) dga2_ddvt; struct ICOM_VTABLE(IDirectDraw2) dga2_dd2vt; struct ICOM_VTABLE(IDirectDraw4) dga2_dd4vt; -#define DDPRIVATE(x) dga2_dd_private *ddpriv = ((dga2_dd_private*)(x)->private) +#define DDPRIVATE(x) dga2_dd_private *ddpriv = ((dga2_dd_private*)(x)->d->private) #define DPPRIVATE(x) dga2_dp_private *dppriv = ((dga2_dp_private*)(x)->private) /******************************************************************************* @@ -69,7 +69,7 @@ static HRESULT WINAPI DGA2_IDirectDraw2Impl_SetCooperativeLevel( } void _DGA2_Initialize_FrameBuffer(IDirectDrawImpl *This, int mode) { - DDPIXELFORMAT *pf = &(This->d.directdraw_pixelformat); + DDPIXELFORMAT *pf = &(This->d->directdraw_pixelformat); DDPRIVATE(This); /* Now, get the device / mode description */ @@ -89,8 +89,8 @@ void _DGA2_Initialize_FrameBuffer(IDirectDrawImpl *This, int mode) { /* Get the screen dimensions as seen by Wine. * In that case, it may be better to ignore the -desktop mode and return the * real screen size => print a warning */ - This->d.height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor); - This->d.width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor); + This->d->height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor); + This->d->width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor); ddpriv->DGA.fb_addr = ddpriv->dev->data; ddpriv->DGA.fb_memsize = (ddpriv->dev->mode.imageWidth * ddpriv->dev->mode.imageHeight * @@ -113,7 +113,7 @@ void _DGA2_Initialize_FrameBuffer(IDirectDrawImpl *This, int mode) { pf->u3.dwBBitMask = ddpriv->dev->mode.blueMask; } pf->u4.dwRGBAlphaBitMask= 0; - This->d.screen_pixelformat = *pf; + This->d->screen_pixelformat = *pf; } static HRESULT WINAPI DGA2_IDirectDrawImpl_SetDisplayMode( @@ -185,7 +185,7 @@ static HRESULT WINAPI DGA2_IDirectDraw2Impl_CreatePalette( dppriv = (dga_dp_private*)ddpal->private; ICOM_VTBL(ddpal)= &dga_ddpalvt; - if (This->d.directdraw_pixelformat.u.dwRGBBitCount<=8) { + if (This->d->directdraw_pixelformat.u.dwRGBBitCount<=8) { dppriv->cm = TSXDGACreateColormap(display,DefaultScreen(display), ddpriv->dev, AllocAll); } else { ERR("why are we doing CreatePalette in hi/truecolor?\n"); @@ -223,23 +223,25 @@ static ULONG WINAPI DGA2_IDirectDraw2Impl_Release(LPDIRECTDRAW2 iface) { TRACE("(%p)->() decrementing from %lu.\n", This, This->ref ); if (!--(This->ref)) { - TRACE("Closing access to the FrameBuffer\n"); - VirtualFree(ddpriv->DGA.fb_addr, 0, MEM_RELEASE); - TSXDGACloseFramebuffer(display, DefaultScreen(display)); - TRACE("Going back to normal X mode of operation\n"); - TSXDGASetMode(display, DefaultScreen(display), 0); - - /* Set the input handling back to absolute */ - X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_ABSOLUTE); - - /* Remove the handling of DGA2 events */ - X11DRV_EVENT_SetDGAStatus(0, -1); - - /* Free the modes list */ - TSXFree(ddpriv->modes); + if (!--(This->d->ref)) { + TRACE("Closing access to the FrameBuffer\n"); + VirtualFree(ddpriv->DGA.fb_addr, 0, MEM_RELEASE); + TSXDGACloseFramebuffer(display, DefaultScreen(display)); + TRACE("Going back to normal X mode of operation\n"); + TSXDGASetMode(display, DefaultScreen(display), 0); + /* Set the input handling back to absolute */ + X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_ABSOLUTE); + + /* Remove the handling of DGA2 events */ + X11DRV_EVENT_SetDGAStatus(0, -1); + + /* Free the modes list */ + TSXFree(ddpriv->modes); + HeapFree(GetProcessHeap(),0,This->d); + } HeapFree(GetProcessHeap(),0,This); - return S_OK; + return 0; } return This->ref; } diff --git a/dlls/ddraw/ddraw/main.c b/dlls/ddraw/ddraw/main.c index 93dbe810637..ec4861e434c 100644 --- a/dlls/ddraw/ddraw/main.c +++ b/dlls/ddraw/ddraw/main.c @@ -46,7 +46,7 @@ HRESULT WINAPI IDirectDraw2Impl_SetCooperativeLevel( FIXME("(%p)->(%08lx,%08lx)\n",This,(DWORD)hwnd,cooplevel); _dump_cooperativelevel(cooplevel); - This->d.mainWindow = hwnd; + This->d->mainWindow = hwnd; return DD_OK; } @@ -60,45 +60,45 @@ void _common_IDirectDrawImpl_SetDisplayMode(IDirectDrawImpl* This) { RECT rect; /* Do destroy only our window */ - if (This->d.window && GetPropA(This->d.window,ddProp)) { - DestroyWindow(This->d.window); - This->d.window = 0; + if (This->d->window && GetPropA(This->d->window,ddProp)) { + DestroyWindow(This->d->window); + This->d->window = 0; } /* Sanity check cooperative window before assigning it to drawing. */ - if (IsWindow(This->d.mainWindow) && - IsWindowVisible(This->d.mainWindow) + if (IsWindow(This->d->mainWindow) && + IsWindowVisible(This->d->mainWindow) ) { - GetWindowRect(This->d.mainWindow,&rect); - if ((((rect.right-rect.left) >= This->d.width) && - ((rect.bottom-rect.top) >= This->d.height)) + GetWindowRect(This->d->mainWindow,&rect); + if ((((rect.right-rect.left) >= This->d->width) && + ((rect.bottom-rect.top) >= This->d->height)) ) { - This->d.window = This->d.mainWindow; + This->d->window = This->d->mainWindow; /* FIXME: resizing is not windows compatible behaviour, need test */ - /* SetWindowPos(This->d.mainWindow,HWND_TOPMOST,0,0,This->d.width,This->d.height,SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOOWNERZORDER); */ - This->d.paintable = 1; /* don't wait for WM_PAINT */ + /* SetWindowPos(This->d->mainWindow,HWND_TOPMOST,0,0,This->d->width,This->d->height,SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOOWNERZORDER); */ + This->d->paintable = 1; /* don't wait for WM_PAINT */ } } /* ... failed, create new one. */ - if (!This->d.window) { - This->d.window = CreateWindowExA( + if (!This->d->window) { + This->d->window = CreateWindowExA( 0, "WINE_DirectDraw", "WINE_DirectDraw", WS_POPUP, 0,0, - This->d.width, - This->d.height, + This->d->width, + This->d->height, 0, 0, 0, NULL ); /*Store THIS with the window. We'll use it in the window procedure*/ - SetPropA(This->d.window,ddProp,(LONG)This); - ShowWindow(This->d.window,TRUE); - UpdateWindow(This->d.window); + SetPropA(This->d->window,ddProp,(LONG)This); + ShowWindow(This->d->window,TRUE); + UpdateWindow(This->d->window); } - SetFocus(This->d.window); + SetFocus(This->d->window); } HRESULT WINAPI IDirectDrawImpl_SetDisplayMode( @@ -107,8 +107,8 @@ HRESULT WINAPI IDirectDrawImpl_SetDisplayMode( ICOM_THIS(IDirectDrawImpl,iface); FIXME("(%p)->SetDisplayMode(%ld,%ld,%ld), needs to be implemented for your display adapter!\n",This,width,height,depth); - This->d.width = width; - This->d.height = height; + This->d->width = width; + This->d->height = height; _common_IDirectDrawImpl_SetDisplayMode(This); return DD_OK; } @@ -192,7 +192,7 @@ HRESULT WINAPI common_IDirectDraw2Impl_CreatePalette( ERR("unhandled palette format\n"); *psize = size; - if (This->d.palette_convert == NULL) { + if (This->d->palette_convert == NULL) { /* No depth conversion - create 8<->8 identity map */ int ent; for (ent=0; ent<256; ent++) @@ -200,11 +200,11 @@ HRESULT WINAPI common_IDirectDraw2Impl_CreatePalette( } if (palent) { /* Now, if we are in depth conversion mode, create the screen palette */ - if (This->d.palette_convert != NULL) - This->d.palette_convert(palent,(*lpddpal)->screen_palents,0,size); + if (This->d->palette_convert != NULL) + This->d->palette_convert(palent,(*lpddpal)->screen_palents,0,size); memcpy((*lpddpal)->palents, palent, size * sizeof(PALETTEENTRY)); - } else if (This->d.palette_convert != NULL) { + } else if (This->d->palette_convert != NULL) { /* In that case, put all 0xFF */ memset((*lpddpal)->screen_palents, 0xFF, 256 * sizeof(int)); } @@ -253,8 +253,11 @@ ULONG WINAPI IDirectDraw2Impl_Release(LPDIRECTDRAW2 iface) { TRACE("(%p)->() decrementing from %lu.\n", This, This->ref ); if (!--(This->ref)) { - if (This->d.window && GetPropA(This->d.window,ddProp)) - DestroyWindow(This->d.window); + if (!--(This->d->ref)) { + if (This->d->window && GetPropA(This->d->window,ddProp)) + DestroyWindow(This->d->window); + HeapFree(GetProcessHeap(),0,This->d); + } HeapFree(GetProcessHeap(),0,This); return S_OK; } @@ -379,13 +382,13 @@ HRESULT WINAPI IDirectDraw2Impl_GetDisplayMode( ICOM_THIS(IDirectDraw2Impl,iface); TRACE("(%p)->GetDisplayMode(%p)\n",This,lpddsfd); lpddsfd->dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PITCH|DDSD_BACKBUFFERCOUNT|DDSD_PIXELFORMAT|DDSD_CAPS; - lpddsfd->dwHeight = This->d.height; - lpddsfd->dwWidth = This->d.width; - lpddsfd->lPitch =lpddsfd->dwWidth*PFGET_BPP(This->d.directdraw_pixelformat); + lpddsfd->dwHeight = This->d->height; + lpddsfd->dwWidth = This->d->width; + lpddsfd->lPitch =lpddsfd->dwWidth*PFGET_BPP(This->d->directdraw_pixelformat); lpddsfd->dwBackBufferCount = 2; lpddsfd->u.dwRefreshRate = 60; lpddsfd->ddsCaps.dwCaps = DDSCAPS_PALETTE; - lpddsfd->ddpfPixelFormat = This->d.directdraw_pixelformat; + lpddsfd->ddpfPixelFormat = This->d->directdraw_pixelformat; if (TRACE_ON(ddraw)) _dump_surface_desc(lpddsfd); return DD_OK; @@ -444,7 +447,7 @@ HRESULT WINAPI IDirectDraw2Impl_GetScanLine( FIXME("(%p)->(%p)\n", This, lpdwScanLine); if (lpdwScanLine) - *lpdwScanLine = 0; + *lpdwScanLine = 1; return DD_OK; } @@ -543,7 +546,7 @@ HRESULT common_off_screen_CreateSurface( /* This is a standard image */ if (!(lpdsf->s.surface_desc.dwFlags & DDSD_PIXELFORMAT)) { /* No pixel format => use DirectDraw's format */ - lpdsf->s.surface_desc.ddpfPixelFormat = This->d.directdraw_pixelformat; + lpdsf->s.surface_desc.ddpfPixelFormat = This->d->directdraw_pixelformat; lpdsf->s.surface_desc.dwFlags |= DDSD_PIXELFORMAT; } bpp = GET_BPP(lpdsf->s.surface_desc); diff --git a/dlls/ddraw/ddraw/x11.c b/dlls/ddraw/ddraw/x11.c index 569666846cf..41f525b1b35 100644 --- a/dlls/ddraw/ddraw/x11.c +++ b/dlls/ddraw/ddraw/x11.c @@ -29,7 +29,7 @@ DEFAULT_DEBUG_CHANNEL(ddraw); #include "x11_private.h" -#define DDPRIVATE(x) x11_dd_private *ddpriv = ((x11_dd_private*)(x)->private) +#define DDPRIVATE(x) x11_dd_private *ddpriv = ((x11_dd_private*)(x)->d->private) #define DPPRIVATE(x) x11_dp_private *dppriv = ((x11_dp_private*)(x)->private) #define DSPRIVATE(x) x11_ds_private *dspriv = ((x11_ds_private*)(x)->private) @@ -46,11 +46,11 @@ int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw) int nvisuals, npixmap, i; int match = 0; int index = -2; - DDPIXELFORMAT *pixelformat = &(This->d.directdraw_pixelformat); - DDPIXELFORMAT *screen_pixelformat = &(This->d.screen_pixelformat); + DDPIXELFORMAT *pixelformat = &(This->d->directdraw_pixelformat); + DDPIXELFORMAT *screen_pixelformat = &(This->d->screen_pixelformat); - This->d.pixel_convert = NULL; - This->d.palette_convert = NULL; + This->d->pixel_convert = NULL; + This->d->palette_convert = NULL; vi = TSXGetVisualInfo(display, VisualNoMask, &vt, &nvisuals); pf = TSXListPixmapFormats(display, &npixmap); @@ -76,17 +76,14 @@ int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw) pixelformat->dwFourCC = 0; pixelformat->u.dwRGBBitCount = pf[i].bits_per_pixel; pixelformat->u4.dwRGBAlphaBitMask= 0; - *screen_pixelformat = *pixelformat; - - This->d.pixmap_depth = vi[j].depth; - + This->d->pixmap_depth = depth; match = 1; index = -1; goto clean_up_and_exit; } } - WARN("No visual corresponding to pixmap format !\n"); + FIXME("No visual corresponding to pixmap format (depth=%ld)!\n",depth); } } @@ -131,19 +128,19 @@ int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw) pixelformat->u3.dwBBitMask = ModeEmulations[c].dest.bmask; } pixelformat->u4.dwRGBAlphaBitMask= 0; - This->d.pixmap_depth = vi[j].depth; + This->d->pixmap_depth = vi[j].depth; match = 2; index = c; - This->d.pixel_convert =ModeEmulations[c].funcs.pixel_convert; - This->d.palette_convert=ModeEmulations[c].funcs.palette_convert; + This->d->pixel_convert =ModeEmulations[c].funcs.pixel_convert; + This->d->palette_convert=ModeEmulations[c].funcs.palette_convert; goto clean_up_and_exit; } - ERR("No visual corresponding to pixmap format !\n"); } } } } } + ERR("No emulation found for depth %ld!\n",depth); } clean_up_and_exit: @@ -173,7 +170,7 @@ static XImage *create_xshmimage( img = TSXShmCreateImage(display, DefaultVisualOfScreen(X11DRV_GetXScreen()), - This->d.pixmap_depth, + This->d->pixmap_depth, ZPixmap, NULL, &(dspriv->shminfo), @@ -188,6 +185,7 @@ static XImage *create_xshmimage( } dspriv->shminfo.shmid = shmget( IPC_PRIVATE, img->bytes_per_line * img->height, IPC_CREAT|0777 ); + if (dspriv->shminfo.shmid < 0) { FIXME("Couldn't create shared memory segment (due to X11 remote display or failure).\nReverting to standard X images !\n"); ddpriv->xshm_active = 0; @@ -247,8 +245,8 @@ static XImage *create_xshmimage( shmctl(dspriv->shminfo.shmid, IPC_RMID, 0); - if (This->d.pixel_convert != NULL) { - int bpp = PFGET_BPP(This->d.directdraw_pixelformat); + if (This->d->pixel_convert != NULL) { + int bpp = PFGET_BPP(This->d->directdraw_pixelformat); lpdsf->s.surface_desc.u1.lpSurface = VirtualAlloc( NULL, lpdsf->s.surface_desc.dwWidth * @@ -269,8 +267,8 @@ static XImage *create_ximage(IDirectDraw2Impl* This, IDirectDrawSurface4Impl* lp XImage *img = NULL; DDPRIVATE(This); void *img_data; - int bpp = PFGET_BPP(This->d.directdraw_pixelformat); - int screen_bpp = PFGET_BPP(This->d.screen_pixelformat); + int bpp = PFGET_BPP(This->d->directdraw_pixelformat); + int screen_bpp = PFGET_BPP(This->d->screen_pixelformat); #ifdef HAVE_LIBXXSHM if (ddpriv->xshm_active) @@ -288,7 +286,7 @@ static XImage *create_ximage(IDirectDraw2Impl* This, IDirectDrawSurface4Impl* lp PAGE_READWRITE ); - if (This->d.pixel_convert != NULL) + if (This->d->pixel_convert != NULL) img_data = VirtualAlloc( NULL, lpdsf->s.surface_desc.dwWidth * @@ -303,7 +301,7 @@ static XImage *create_ximage(IDirectDraw2Impl* This, IDirectDrawSurface4Impl* lp /* In this case, create an XImage */ img = TSXCreateImage(display, DefaultVisualOfScreen(X11DRV_GetXScreen()), - This->d.pixmap_depth, + This->d->pixmap_depth, ZPixmap, 0, img_data, @@ -315,7 +313,7 @@ static XImage *create_ximage(IDirectDraw2Impl* This, IDirectDrawSurface4Impl* lp #ifdef HAVE_LIBXXSHM } #endif - if (This->d.pixel_convert != NULL) + if (This->d->pixel_convert != NULL) lpdsf->s.surface_desc.lPitch = bpp*lpdsf->s.surface_desc.dwWidth; else lpdsf->s.surface_desc.lPitch = img->bytes_per_line; @@ -360,9 +358,9 @@ static HRESULT WINAPI Xlib_IDirectDraw2Impl_CreateSurface( dsurf->s.surface_desc = *lpddsd; if (!(lpddsd->dwFlags & DDSD_WIDTH)) - dsurf->s.surface_desc.dwWidth = This->d.width; + dsurf->s.surface_desc.dwWidth = This->d->width; if (!(lpddsd->dwFlags & DDSD_HEIGHT)) - dsurf->s.surface_desc.dwHeight = This->d.height; + dsurf->s.surface_desc.dwHeight = This->d->height; dsurf->s.surface_desc.dwFlags |= DDSD_WIDTH|DDSD_HEIGHT; /* Check if this a 'primary surface' or not */ @@ -371,6 +369,13 @@ static HRESULT WINAPI Xlib_IDirectDraw2Impl_CreateSurface( ) { XImage *img; + /* Add flags if there were not present */ + dsurf->s.surface_desc.dwFlags |= DDSD_WIDTH|DDSD_HEIGHT|DDSD_PITCH|DDSD_LPSURFACE|DDSD_PIXELFORMAT; + dsurf->s.surface_desc.dwWidth = This->d->width; + dsurf->s.surface_desc.dwHeight = This->d->height; + dsurf->s.surface_desc.ddsCaps.dwCaps |= DDSCAPS_VISIBLE|DDSCAPS_VIDEOMEMORY; + dsurf->s.surface_desc.ddpfPixelFormat = This->d->directdraw_pixelformat; + TRACE("using standard XImage for a primary surface (%p)\n", dsurf); /* Create the XImage */ img = create_ximage(This,(IDirectDrawSurface4Impl*)dsurf); @@ -378,13 +383,6 @@ static HRESULT WINAPI Xlib_IDirectDraw2Impl_CreateSurface( return DDERR_OUTOFMEMORY; dspriv->image = img; - /* Add flags if there were not present */ - dsurf->s.surface_desc.dwFlags |= DDSD_WIDTH|DDSD_HEIGHT|DDSD_PITCH|DDSD_LPSURFACE|DDSD_PIXELFORMAT; - dsurf->s.surface_desc.dwWidth = This->d.width; - dsurf->s.surface_desc.dwHeight = This->d.height; - dsurf->s.surface_desc.ddsCaps.dwCaps |= DDSCAPS_VISIBLE|DDSCAPS_VIDEOMEMORY; - dsurf->s.surface_desc.ddpfPixelFormat = This->d.directdraw_pixelformat; - /* Check for backbuffers */ if (lpddsd->dwFlags & DDSD_BACKBUFFERCOUNT) { IDirectDrawSurface4Impl* back; @@ -457,7 +455,7 @@ static HRESULT WINAPI Xlib_IDirectDraw2Impl_SetCooperativeLevel( FIXME("(%p)->(%08lx,%08lx)\n",This,(DWORD)hwnd,cooplevel); if (TRACE_ON(ddraw)) _dump_cooperativelevel(cooplevel); - This->d.mainWindow = hwnd; + This->d->mainWindow = hwnd; /* This will be overwritten in the case of Full Screen mode. Windowed games could work with that :-) */ @@ -499,13 +497,13 @@ static HRESULT WINAPI Xlib_IDirectDrawImpl_SetDisplayMode( DPRINTF("DirectDraw warning: running in depth-conversion mode %d. Should run using a %ld depth for optimal performances.\n", c,depth); } - This->d.width = width; - This->d.height = height; + This->d->width = width; + This->d->height = height; _common_IDirectDrawImpl_SetDisplayMode(This); - tmpWnd = WIN_FindWndPtr(This->d.window); - This->d.paintable = 1; + tmpWnd = WIN_FindWndPtr(This->d->window); + This->d->paintable = 1; ddpriv->drawable = ((X11DRV_WND_DATA *) tmpWnd->pDriverData)->window; WIN_ReleaseWndPtr(tmpWnd); @@ -593,20 +591,6 @@ static HRESULT WINAPI Xlib_IDirectDraw2Impl_CreatePalette( return DD_OK; } -static ULONG WINAPI Xlib_IDirectDraw2Impl_Release(LPDIRECTDRAW2 iface) { - ICOM_THIS(IDirectDraw2Impl,iface); - TRACE("(%p)->() decrementing from %lu.\n", This, This->ref ); - - if (!--(This->ref)) { - if (This->d.window && GetPropA(This->d.window,ddProp)) - DestroyWindow(This->d.window); - HeapFree(GetProcessHeap(),0,This); - return S_OK; - } - /* FIXME: destroy window ... */ - return This->ref; -} - static HRESULT WINAPI Xlib_IDirectDraw2Impl_QueryInterface( LPDIRECTDRAW2 iface,REFIID refiid,LPVOID *obj ) { @@ -622,30 +606,32 @@ static HRESULT WINAPI Xlib_IDirectDraw2Impl_QueryInterface( return S_OK; } if ( IsEqualGUID( &IID_IDirectDraw, refiid ) ) { - ICOM_VTBL(This) = (ICOM_VTABLE(IDirectDraw2)*)&xlib_ddvt; + IDirectDrawImpl *dd = HeapAlloc(GetProcessHeap(),0,sizeof(*dd)); IDirectDraw2_AddRef(iface); - *obj = This; + + dd->ref = 1;ICOM_VTBL(dd) = &xlib_ddvt;dd->d = This->d;This->d->ref++; + *obj = dd; TRACE(" Creating IDirectDraw interface (%p)\n", *obj); - return S_OK; } if ( IsEqualGUID( &IID_IDirectDraw2, refiid ) ) { - ICOM_VTBL(This) = (ICOM_VTABLE(IDirectDraw2)*)&xlib_dd2vt; + IDirectDraw2Impl *dd = HeapAlloc(GetProcessHeap(),0,sizeof(*dd)); IDirectDraw2_AddRef(iface); - *obj = This; + + dd->ref = 1;ICOM_VTBL(dd) = &xlib_dd2vt;dd->d = This->d;This->d->ref++; + *obj = dd; TRACE(" Creating IDirectDraw2 interface (%p)\n", *obj); - return S_OK; } if ( IsEqualGUID( &IID_IDirectDraw4, refiid ) ) { - ICOM_VTBL(This) = (ICOM_VTABLE(IDirectDraw2)*)&xlib_dd4vt; + IDirectDraw4Impl *dd = HeapAlloc(GetProcessHeap(),0,sizeof(*dd)); + dd->ref = 1;ICOM_VTBL(dd) = &xlib_dd4vt;dd->d = This->d;This->d->ref++; + *obj = dd; + IDirectDraw2_AddRef(iface); - *obj = This; - TRACE(" Creating IDirectDraw4 interface (%p)\n", *obj); - return S_OK; } #ifdef HAVE_OPENGL @@ -851,24 +837,6 @@ static HRESULT WINAPI Xlib_IDirectDraw2Impl_EnumDisplayModes( return DD_OK; } -static HRESULT WINAPI Xlib_IDirectDraw2Impl_GetDisplayMode( - LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsfd -) { - ICOM_THIS(IDirectDraw2Impl,iface); - TRACE("(%p)->GetDisplayMode(%p)\n",This,lpddsfd); - lpddsfd->dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PITCH|DDSD_BACKBUFFERCOUNT|DDSD_PIXELFORMAT|DDSD_CAPS; - lpddsfd->dwHeight = This->d.height; - lpddsfd->dwWidth = This->d.width; - lpddsfd->lPitch = lpddsfd->dwWidth * PFGET_BPP(This->d.directdraw_pixelformat); - lpddsfd->dwBackBufferCount = 2; - lpddsfd->u.dwRefreshRate = 60; - lpddsfd->ddsCaps.dwCaps = DDSCAPS_PALETTE; - lpddsfd->ddpfPixelFormat = This->d.directdraw_pixelformat; - if (TRACE_ON(ddraw)) - _dump_surface_desc(lpddsfd); - return DD_OK; -} - /* Note: Hack so we can reuse the old functions without compiler warnings */ #if !defined(__STRICT_ANSI__) && defined(__GNUC__) # define XCAST(fun) (typeof(xlib_ddvt.fn##fun)) @@ -880,7 +848,7 @@ ICOM_VTABLE(IDirectDraw) xlib_ddvt = { ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE XCAST(QueryInterface)Xlib_IDirectDraw2Impl_QueryInterface, XCAST(AddRef)IDirectDraw2Impl_AddRef, - XCAST(Release)Xlib_IDirectDraw2Impl_Release, + XCAST(Release)IDirectDraw2Impl_Release, XCAST(Compact)IDirectDraw2Impl_Compact, XCAST(CreateClipper)IDirectDraw2Impl_CreateClipper, XCAST(CreatePalette)Xlib_IDirectDraw2Impl_CreatePalette, @@ -890,7 +858,7 @@ ICOM_VTABLE(IDirectDraw) xlib_ddvt = { XCAST(EnumSurfaces)IDirectDraw2Impl_EnumSurfaces, XCAST(FlipToGDISurface)IDirectDraw2Impl_FlipToGDISurface, XCAST(GetCaps)Xlib_IDirectDraw2Impl_GetCaps, - XCAST(GetDisplayMode)Xlib_IDirectDraw2Impl_GetDisplayMode, + XCAST(GetDisplayMode)IDirectDraw2Impl_GetDisplayMode, XCAST(GetFourCCCodes)IDirectDraw2Impl_GetFourCCCodes, XCAST(GetGDISurface)IDirectDraw2Impl_GetGDISurface, XCAST(GetMonitorFrequency)IDirectDraw2Impl_GetMonitorFrequency, @@ -931,7 +899,7 @@ ICOM_VTABLE(IDirectDraw2) xlib_dd2vt = { ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE Xlib_IDirectDraw2Impl_QueryInterface, IDirectDraw2Impl_AddRef, - Xlib_IDirectDraw2Impl_Release, + IDirectDraw2Impl_Release, IDirectDraw2Impl_Compact, IDirectDraw2Impl_CreateClipper, Xlib_IDirectDraw2Impl_CreatePalette, @@ -941,7 +909,7 @@ ICOM_VTABLE(IDirectDraw2) xlib_dd2vt = { IDirectDraw2Impl_EnumSurfaces, IDirectDraw2Impl_FlipToGDISurface, Xlib_IDirectDraw2Impl_GetCaps, - Xlib_IDirectDraw2Impl_GetDisplayMode, + IDirectDraw2Impl_GetDisplayMode, IDirectDraw2Impl_GetFourCCCodes, IDirectDraw2Impl_GetGDISurface, IDirectDraw2Impl_GetMonitorFrequency, @@ -965,7 +933,7 @@ ICOM_VTABLE(IDirectDraw4) xlib_dd4vt = { ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE XCAST(QueryInterface)Xlib_IDirectDraw2Impl_QueryInterface, XCAST(AddRef)IDirectDraw2Impl_AddRef, - XCAST(Release)Xlib_IDirectDraw2Impl_Release, + XCAST(Release)IDirectDraw2Impl_Release, XCAST(Compact)IDirectDraw2Impl_Compact, XCAST(CreateClipper)IDirectDraw2Impl_CreateClipper, XCAST(CreatePalette)Xlib_IDirectDraw2Impl_CreatePalette, @@ -975,7 +943,7 @@ ICOM_VTABLE(IDirectDraw4) xlib_dd4vt = { XCAST(EnumSurfaces)IDirectDraw2Impl_EnumSurfaces, XCAST(FlipToGDISurface)IDirectDraw2Impl_FlipToGDISurface, XCAST(GetCaps)Xlib_IDirectDraw2Impl_GetCaps, - XCAST(GetDisplayMode)Xlib_IDirectDraw2Impl_GetDisplayMode, + XCAST(GetDisplayMode)IDirectDraw2Impl_GetDisplayMode, XCAST(GetFourCCCodes)IDirectDraw2Impl_GetFourCCCodes, XCAST(GetGDISurface)IDirectDraw2Impl_GetGDISurface, XCAST(GetMonitorFrequency)IDirectDraw2Impl_GetMonitorFrequency, diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 57e4b57cf06..e51de5043f0 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -52,6 +52,7 @@ extern struct ICOM_VTABLE(IDirectDrawPalette) ddraw_ddpalvt; */ struct _common_directdrawdata { + int ref; /* for this structure, only once per obj */ DDPIXELFORMAT directdraw_pixelformat; DDPIXELFORMAT screen_pixelformat; @@ -66,6 +67,7 @@ struct _common_directdrawdata HWND window; PAINTSTRUCT ps; int paintable; + LPVOID private; }; /***************************************************************************** @@ -79,26 +81,25 @@ struct IDirectDrawImpl /* IUnknown fields */ ICOM_VFIELD(IDirectDraw); DWORD ref; + /* IDirectDraw fields */ - struct _common_directdrawdata d; - LPVOID private; + struct _common_directdrawdata *d; }; -extern HRESULT WINAPI IDirectDrawImpl_SetDisplayMode( - LPDIRECTDRAW iface,DWORD width,DWORD height,DWORD depth -); -/* - * IDirectDraw2 implementation structure - */ + struct IDirectDraw2Impl { /* IUnknown fields */ ICOM_VFIELD(IDirectDraw2); DWORD ref; - /* IDirectDraw2 fields */ - struct _common_directdrawdata d; - LPVOID private; + /* IDirectDraw fields */ + struct _common_directdrawdata *d; }; + +extern HRESULT WINAPI IDirectDrawImpl_SetDisplayMode( + LPDIRECTDRAW iface,DWORD width,DWORD height,DWORD depth +); + extern HRESULT WINAPI IDirectDraw2Impl_DuplicateSurface( LPDIRECTDRAW2 iface,LPDIRECTDRAWSURFACE src,LPDIRECTDRAWSURFACE *dst ); @@ -175,9 +176,9 @@ struct IDirectDraw4Impl ICOM_VFIELD(IDirectDraw4); DWORD ref; /* IDirectDraw4 fields */ - struct _common_directdrawdata d; - LPVOID private; + struct _common_directdrawdata *d; }; + extern HRESULT WINAPI IDirectDraw4Impl_GetSurfaceFromDC( LPDIRECTDRAW4 iface, HDC hdc, LPDIRECTDRAWSURFACE *lpDDS ); diff --git a/dlls/ddraw/dga.c b/dlls/ddraw/dga.c index 6464b4bf002..d5fbae8fc8e 100644 --- a/dlls/ddraw/dga.c +++ b/dlls/ddraw/dga.c @@ -123,10 +123,10 @@ DGA_Create( LPDIRECTDRAW *lplpDD ) { *lplpDD = (LPDIRECTDRAW)ddraw; ddraw->ref = 1; ICOM_VTBL(ddraw) = &dga_ddvt; - - ddraw->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(dga_dd_private)); - - dgpriv = (dga_dd_private*)ddraw->private; + ddraw->d = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*(ddraw->d))); + ddraw->d->ref = 1; + ddraw->d->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(dga_dd_private)); + dgpriv = (dga_dd_private*)ddraw->d->private; TSXF86DGAQueryVersion(display,&major,&minor); TRACE("XF86DGA is version %d.%d\n",major,minor); @@ -147,9 +147,9 @@ DGA_Create( LPDIRECTDRAW *lplpDD ) { * In that case, it may be better to ignore the -desktop mode and * return the real screen size => print a warning */ - ddraw->d.height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor); - ddraw->d.width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor); - if ((ddraw->d.height != height) || (ddraw->d.width != width)) + ddraw->d->height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor); + ddraw->d->width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor); + if ((ddraw->d->height != height) || (ddraw->d->width != width)) WARN("You seem to be running in -desktop mode. This may prove dangerous in DGA mode...\n"); dgpriv->fb_addr = addr; dgpriv->fb_memsize = memsize; diff --git a/dlls/ddraw/dga2.c b/dlls/ddraw/dga2.c index ea0f4c76d49..496440257e8 100644 --- a/dlls/ddraw/dga2.c +++ b/dlls/ddraw/dga2.c @@ -101,10 +101,12 @@ DGA2_Create( LPDIRECTDRAW *lplpDD ) { *lplpDD = (LPDIRECTDRAW)ddraw; ddraw->ref = 1; ICOM_VTBL(ddraw) = &dga2_ddvt; - - ddraw->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(dga2_dd_private)); - dgpriv = (dga2_dd_private*)ddraw->private; + ddraw->d = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*(ddraw->d))); + ddraw->d->ref = 1; + ddraw->d->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(dga2_dd_private)); + + dgpriv = (dga2_dd_private*)ddraw->d->private; TSXDGAQueryVersion(display,&major,&minor); TRACE("XDGA is version %d.%d\n",major,minor); @@ -157,7 +159,7 @@ DGA2_Create( LPDIRECTDRAW *lplpDD ) { /* Initialize the frame buffer */ _DGA2_Initialize_FrameBuffer(ddraw, mode_to_use); - /* Register frame buffer with the kernel, it is as a potential DIB section */ + /* Register frame buffer with the kernel, it is a potential DIB section */ VirtualAlloc(dgpriv->DGA.fb_addr, dgpriv->DGA.fb_memsize, MEM_RESERVE|MEM_SYSTEM, PAGE_READWRITE); /* Set the input handling for relative mouse movements */ diff --git a/dlls/ddraw/dpalette/dga.c b/dlls/ddraw/dpalette/dga.c index 698a491e289..411c8001c9f 100644 --- a/dlls/ddraw/dpalette/dga.c +++ b/dlls/ddraw/dpalette/dga.c @@ -19,7 +19,7 @@ DEFAULT_DEBUG_CHANNEL(ddraw); #define DPPRIVATE(x) dga_dp_private *dppriv = ((dga_dp_private*)(x)->private) -#define DDPRIVATE(x) dga_dd_private *ddpriv = ((dga_dd_private*)(x)->private) +#define DDPRIVATE(x) dga_dd_private *ddpriv = ((dga_dd_private*)(x)->d->private) HRESULT WINAPI DGA_IDirectDrawPaletteImpl_SetEntries( LPDIRECTDRAWPALETTE iface,DWORD x,DWORD start,DWORD count,LPPALETTEENTRY palent diff --git a/dlls/ddraw/dpalette/main.c b/dlls/ddraw/dpalette/main.c index c7ce5dc1e25..12b2dba9cf1 100644 --- a/dlls/ddraw/dpalette/main.c +++ b/dlls/ddraw/dpalette/main.c @@ -52,8 +52,8 @@ HRESULT WINAPI IDirectDrawPaletteImpl_SetEntries( /* Now, if we are in 'depth conversion mode', update the screen palette */ /* FIXME: we need to update the image or we won't get palette fading. */ - if (This->ddraw->d.palette_convert != NULL) - This->ddraw->d.palette_convert(palent,This->screen_palents,start,count); + if (This->ddraw->d->palette_convert != NULL) + This->ddraw->d->palette_convert(palent,This->screen_palents,start,count); return DD_OK; } diff --git a/dlls/ddraw/dpalette/x11.c b/dlls/ddraw/dpalette/x11.c index 704518da9d2..bebe6986790 100644 --- a/dlls/ddraw/dpalette/x11.c +++ b/dlls/ddraw/dpalette/x11.c @@ -51,8 +51,8 @@ HRESULT WINAPI Xlib_IDirectDrawPaletteImpl_SetEntries( /* Now, if we are in 'depth conversion mode', update the screen palette */ /* FIXME: we need to update the image or we won't get palette fading. */ - if (This->ddraw->d.palette_convert != NULL) { - This->ddraw->d.palette_convert(palent,This->screen_palents,start,count); + if (This->ddraw->d->palette_convert != NULL) { + This->ddraw->d->palette_convert(palent,This->screen_palents,start,count); } return DD_OK; } diff --git a/dlls/ddraw/dsurface/dga.c b/dlls/ddraw/dsurface/dga.c index 486db6d75ae..df8a37798d3 100644 --- a/dlls/ddraw/dsurface/dga.c +++ b/dlls/ddraw/dsurface/dga.c @@ -19,7 +19,7 @@ DEFAULT_DEBUG_CHANNEL(ddraw); -#define DDPRIVATE(x) dga_dd_private *ddpriv = ((dga_dd_private*)(x)->private) +#define DDPRIVATE(x) dga_dd_private *ddpriv = ((dga_dd_private*)(x)->d->private) #define DPPRIVATE(x) dga_dp_private *dppriv = ((dga_dp_private*)(x)->private) #define DSPRIVATE(x) dga_ds_private *dspriv = ((dga_ds_private*)(x)->private) diff --git a/dlls/ddraw/dsurface/dga2.c b/dlls/ddraw/dsurface/dga2.c index e208035d234..0e7ae8dd50e 100644 --- a/dlls/ddraw/dsurface/dga2.c +++ b/dlls/ddraw/dsurface/dga2.c @@ -17,7 +17,7 @@ DEFAULT_DEBUG_CHANNEL(ddraw); -#define DDPRIVATE(x) dga2_dd_private *ddpriv = ((dga2_dd_private*)(x)->private) +#define DDPRIVATE(x) dga2_dd_private *ddpriv = ((dga2_dd_private*)(x)->d->private) #define DPPRIVATE(x) dga2_dp_private *dppriv = ((dga2_dp_private*)(x)->private) #define DSPRIVATE(x) dga2_ds_private *dspriv = ((dga2_ds_private*)(x)->private) diff --git a/dlls/ddraw/dsurface/x11.c b/dlls/ddraw/dsurface/x11.c index 07a5bdbae90..7dbdf3d65d2 100644 --- a/dlls/ddraw/dsurface/x11.c +++ b/dlls/ddraw/dsurface/x11.c @@ -28,7 +28,7 @@ DEFAULT_DEBUG_CHANNEL(ddraw); #define VISIBLE(x) (SDDSCAPS(x) & (DDSCAPS_VISIBLE|DDSCAPS_PRIMARYSURFACE)) -#define DDPRIVATE(x) x11_dd_private *ddpriv = ((x11_dd_private*)(x)->private) +#define DDPRIVATE(x) x11_dd_private *ddpriv = ((x11_dd_private*)(x)->d->private) #define DPPRIVATE(x) x11_dp_private *dppriv = ((x11_dp_private*)(x)->private) #define DSPRIVATE(x) x11_ds_private *dspriv = ((x11_ds_private*)(x)->private) @@ -93,10 +93,10 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Lock( ICOM_THIS(IDirectDrawSurface4Impl,iface); DSPRIVATE(This); DDPRIVATE(This->s.ddraw); - + /* DO NOT AddRef the surface! Lock/Unlock are NOT guaranteed to come in * matched pairs! - Marcus Meissner 20000509 */ - TRACE("(%p)->Lock(%p,%p,%08lx,%08lx)\n",This,lprect,lpddsd,flags,(DWORD)hnd); + TRACE("(%p)->Lock(%p,%p,%08lx,%08lx) ret=%p\n",This,lprect,lpddsd,flags,(DWORD)hnd,__builtin_return_address(0)); if (flags & ~(DDLOCK_WAIT|DDLOCK_READONLY|DDLOCK_WRITEONLY)) WARN("(%p)->Lock(%p,%p,%08lx,%08lx)\n", This,lprect,lpddsd,flags,(DWORD)hnd); @@ -159,7 +159,6 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Lock( static void Xlib_copy_surface_on_screen(IDirectDrawSurface4Impl* This) { DSPRIVATE(This); DDPRIVATE(This->s.ddraw); - Drawable drawable = ddpriv->drawable; POINT adjust[2] = {{0, 0}, {0, 0}}; SIZE imgsiz; @@ -194,8 +193,8 @@ static void Xlib_copy_surface_on_screen(IDirectDrawSurface4Impl* This) { WIN_ReleaseWndPtr(wndPtr); } - if (This->s.ddraw->d.pixel_convert != NULL) - This->s.ddraw->d.pixel_convert(This->s.surface_desc.u1.lpSurface, + if (This->s.ddraw->d->pixel_convert != NULL) + This->s.ddraw->d->pixel_convert(This->s.surface_desc.u1.lpSurface, dspriv->image->data, This->s.surface_desc.dwWidth, This->s.surface_desc.dwHeight, @@ -272,7 +271,7 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Flip( IDirectDrawSurface4Impl* iflipto=(IDirectDrawSurface4Impl*)flipto; TRACE("(%p)->Flip(%p,%08lx)\n",This,iflipto,dwFlags); - if (!This->s.ddraw->d.paintable) + if (!This->s.ddraw->d->paintable) return DD_OK; iflipto = _common_find_flipto(This,iflipto); @@ -339,7 +338,7 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_SetPalette( dppriv = (x11_dp_private*)ipal->private; if (!dppriv->cm && - (This->s.ddraw->d.screen_pixelformat.u.dwRGBBitCount<=8) + (This->s.ddraw->d->screen_pixelformat.u.dwRGBBitCount<=8) ) { dppriv->cm = TSXCreateColormap( display, diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index ffc878a3682..251ffd9401a 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -213,29 +213,29 @@ static LRESULT WINAPI DDWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) if( ddraw ) { /* Perform any special direct draw functions */ if (msg==WM_PAINT) - ddraw->d.paintable = 1; + ddraw->d->paintable = 1; /* Now let the application deal with the rest of this */ - if( ddraw->d.mainWindow ) { + if( ddraw->d->mainWindow ) { /* Don't think that we actually need to call this but... * might as well be on the safe side of things... */ - /* I changed hwnd to ddraw->d.mainWindow as I did not see why + /* I changed hwnd to ddraw->d->mainWindow as I did not see why * it should be the procedures of our fake window that gets called * instead of those of the window provided by the application. * And with this patch, mouse clicks work with Monkey Island III * - Lionel */ - ret = DefWindowProcA( ddraw->d.mainWindow, msg, wParam, lParam ); + ret = DefWindowProcA( ddraw->d->mainWindow, msg, wParam, lParam ); if( !ret ) { - WND *tmpWnd =WIN_FindWndPtr(ddraw->d.mainWindow); + WND *tmpWnd =WIN_FindWndPtr(ddraw->d->mainWindow); /* We didn't handle the message - give it to the application */ - if (ddraw && ddraw->d.mainWindow && tmpWnd) + if (ddraw && ddraw->d->mainWindow && tmpWnd) ret = CallWindowProcA(tmpWnd->winproc, - ddraw->d.mainWindow, msg, wParam, lParam ); + ddraw->d->mainWindow, msg, wParam, lParam ); WIN_ReleaseWndPtr(tmpWnd); } return ret; @@ -320,7 +320,7 @@ HRESULT WINAPI DirectDrawCreate( wc.hbrBackground = NULL_BRUSH; wc.lpszMenuName = 0; wc.lpszClassName = "WINE_DirectDraw"; - (*ilplpDD)->d.winclass = RegisterClassA(&wc); + (*ilplpDD)->d->winclass = RegisterClassA(&wc); return ret; } diff --git a/dlls/ddraw/x11.c b/dlls/ddraw/x11.c index 117604c5cb6..4fd2039e0db 100644 --- a/dlls/ddraw/x11.c +++ b/dlls/ddraw/x11.c @@ -61,12 +61,15 @@ static HRESULT X11_Create( LPDIRECTDRAW *lplpDD ) { ddraw = (IDirectDrawImpl*)*lplpDD; ICOM_VTBL(ddraw)= &xlib_ddvt; ddraw->ref = 1; - ddraw->private = HeapAlloc( + + ddraw->d = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*(ddraw->d))); + ddraw->d->ref = 1; + ddraw->d->private = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(x11_dd_private) ); - x11priv = (x11_dd_private*)ddraw->private; + x11priv = (x11_dd_private*)ddraw->d->private; /* At DirectDraw creation, the depth is the default depth */ depth = DefaultDepthOfScreen(X11DRV_GetXScreen()); @@ -77,8 +80,8 @@ static HRESULT X11_Create( LPDIRECTDRAW *lplpDD ) { case 0: MESSAGE("Conversion needed from %d.\n",depth); break; } - ddraw->d.height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor); - ddraw->d.width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor); + ddraw->d->height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor); + ddraw->d->width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor); #ifdef HAVE_LIBXXSHM /* Test if XShm is available. */ if ((x11priv->xshm_active = DDRAW_XSHM_Available())) {