Made IDirectDrawSurface::SetPalette set the surface's DIBSection color

map to point to the IDirectDrawPalette's own depth conversion color map.
This commit is contained in:
Ove Kaaven 2000-05-18 00:04:10 +00:00 committed by Alexandre Julliard
parent 9d0abdbcca
commit 561895a937
5 changed files with 68 additions and 3 deletions

View File

@ -28,12 +28,14 @@ typedef x11_dp_private dga_dp_private; /* reuse X11 palette stuff */
typedef struct dga_ds_private { typedef struct dga_ds_private {
DWORD fb_height; DWORD fb_height;
int *oldDIBmap;
} dga_ds_private; } dga_ds_private;
/* For usage in DGA2 */ /* For usage in DGA2 */
extern ULONG WINAPI DGA_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) ; extern ULONG WINAPI DGA_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) ;
extern HRESULT WINAPI DGA_IDirectDrawSurface4Impl_SetPalette(LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWPALETTE pal) ; extern HRESULT WINAPI DGA_IDirectDrawSurface4Impl_SetPalette(LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWPALETTE pal) ;
extern HRESULT WINAPI DGA_IDirectDrawSurface4Impl_Unlock(LPDIRECTDRAWSURFACE4 iface,LPVOID surface) ; extern HRESULT WINAPI DGA_IDirectDrawSurface4Impl_Unlock(LPDIRECTDRAWSURFACE4 iface,LPVOID surface) ;
extern HRESULT WINAPI DGA_IDirectDrawSurface4Impl_GetDC(LPDIRECTDRAWSURFACE4 iface,HDC* lphdc);
extern HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface_no_VT(LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsd, extern HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface_no_VT(LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsd,
LPDIRECTDRAWSURFACE *lpdsf,IUnknown *lpunk) ; LPDIRECTDRAWSURFACE *lpdsf,IUnknown *lpunk) ;

View File

@ -15,6 +15,7 @@
#include "debugtools.h" #include "debugtools.h"
#include "dga_private.h" #include "dga_private.h"
#include "bitmap.h"
DEFAULT_DEBUG_CHANNEL(ddraw); DEFAULT_DEBUG_CHANNEL(ddraw);
@ -100,6 +101,14 @@ HRESULT WINAPI DGA_IDirectDrawSurface4Impl_SetPalette(
This->s.palette = ipal; This->s.palette = ipal;
fppriv = (dga_dp_private*)This->s.palette->private; fppriv = (dga_dp_private*)This->s.palette->private;
ddpriv->InstallColormap(display,DefaultScreen(display),fppriv->cm); ddpriv->InstallColormap(display,DefaultScreen(display),fppriv->cm);
if (This->s.hdc != 0) {
/* hack: set the DIBsection color map */
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_HEAP_UNLOCK(This->s.DIBsection);
}
} }
return DD_OK; return DD_OK;
} }
@ -123,6 +132,12 @@ ULONG WINAPI DGA_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
/* Free the DIBSection (if any) */ /* Free the DIBSection (if any) */
if (This->s.hdc != 0) { if (This->s.hdc != 0) {
/* hack: restore the original DIBsection color map */
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = dspriv->oldDIBmap;
GDI_HEAP_UNLOCK(This->s.DIBsection);
SelectObject(This->s.hdc, This->s.holdbitmap); SelectObject(This->s.hdc, This->s.holdbitmap);
DeleteDC(This->s.hdc); DeleteDC(This->s.hdc);
DeleteObject(This->s.DIBsection); DeleteObject(This->s.DIBsection);
@ -146,6 +161,22 @@ HRESULT WINAPI DGA_IDirectDrawSurface4Impl_Unlock(
return DD_OK; return DD_OK;
} }
HRESULT WINAPI DGA_IDirectDrawSurface4Impl_GetDC(LPDIRECTDRAWSURFACE4 iface,HDC* lphdc) {
ICOM_THIS(IDirectDrawSurface4Impl,iface);
DSPRIVATE(This);
int was_ok = This->s.hdc != 0;
HRESULT result = IDirectDrawSurface4Impl_GetDC(iface,lphdc);
if (This->s.hdc && !was_ok) {
/* hack: take over the DIBsection color map */
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dspriv->oldDIBmap = dib->colorMap;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_HEAP_UNLOCK(This->s.DIBsection);
}
return result;
}
ICOM_VTABLE(IDirectDrawSurface4) dga_dds4vt = ICOM_VTABLE(IDirectDrawSurface4) dga_dds4vt =
{ {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
@ -166,7 +197,7 @@ ICOM_VTABLE(IDirectDrawSurface4) dga_dds4vt =
IDirectDrawSurface4Impl_GetCaps, IDirectDrawSurface4Impl_GetCaps,
IDirectDrawSurface4Impl_GetClipper, IDirectDrawSurface4Impl_GetClipper,
IDirectDrawSurface4Impl_GetColorKey, IDirectDrawSurface4Impl_GetColorKey,
IDirectDrawSurface4Impl_GetDC, DGA_IDirectDrawSurface4Impl_GetDC,
IDirectDrawSurface4Impl_GetFlipStatus, IDirectDrawSurface4Impl_GetFlipStatus,
IDirectDrawSurface4Impl_GetOverlayPosition, IDirectDrawSurface4Impl_GetOverlayPosition,
IDirectDrawSurface4Impl_GetPalette, IDirectDrawSurface4Impl_GetPalette,

View File

@ -89,7 +89,7 @@ ICOM_VTABLE(IDirectDrawSurface4) dga2_dds4vt =
IDirectDrawSurface4Impl_GetCaps, IDirectDrawSurface4Impl_GetCaps,
IDirectDrawSurface4Impl_GetClipper, IDirectDrawSurface4Impl_GetClipper,
IDirectDrawSurface4Impl_GetColorKey, IDirectDrawSurface4Impl_GetColorKey,
IDirectDrawSurface4Impl_GetDC, DGA_IDirectDrawSurface4Impl_GetDC,
IDirectDrawSurface4Impl_GetFlipStatus, IDirectDrawSurface4Impl_GetFlipStatus,
IDirectDrawSurface4Impl_GetOverlayPosition, IDirectDrawSurface4Impl_GetOverlayPosition,
IDirectDrawSurface4Impl_GetPalette, IDirectDrawSurface4Impl_GetPalette,

View File

@ -16,6 +16,7 @@
#include "options.h" #include "options.h"
#include "debugtools.h" #include "debugtools.h"
#include "x11_private.h" #include "x11_private.h"
#include "bitmap.h"
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
/* for d3d texture stuff */ /* for d3d texture stuff */
@ -313,6 +314,14 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_SetPalette(
This->s.palette = ipal; This->s.palette = ipal;
/* Perform the refresh */ /* Perform the refresh */
TSXSetWindowColormap(display,ddpriv->drawable,dppriv->cm); TSXSetWindowColormap(display,ddpriv->drawable,dppriv->cm);
if (This->s.hdc != 0) {
/* hack: set the DIBsection color map */
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_HEAP_UNLOCK(This->s.DIBsection);
}
} }
return DD_OK; return DD_OK;
} }
@ -370,6 +379,12 @@ ULONG WINAPI Xlib_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
/* Free the DIBSection (if any) */ /* Free the DIBSection (if any) */
if (This->s.hdc != 0) { if (This->s.hdc != 0) {
/* hack: restore the original DIBsection color map */
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = dspriv->oldDIBmap;
GDI_HEAP_UNLOCK(This->s.DIBsection);
SelectObject(This->s.hdc, This->s.holdbitmap); SelectObject(This->s.hdc, This->s.holdbitmap);
DeleteDC(This->s.hdc); DeleteDC(This->s.hdc);
DeleteObject(This->s.DIBsection); DeleteObject(This->s.DIBsection);
@ -383,6 +398,22 @@ ULONG WINAPI Xlib_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
return S_OK; return S_OK;
} }
HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_GetDC(LPDIRECTDRAWSURFACE4 iface,HDC* lphdc) {
ICOM_THIS(IDirectDrawSurface4Impl,iface);
DSPRIVATE(This);
int was_ok = This->s.hdc != 0;
HRESULT result = IDirectDrawSurface4Impl_GetDC(iface,lphdc);
if (This->s.hdc && !was_ok) {
/* hack: take over the DIBsection color map */
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dspriv->oldDIBmap = dib->colorMap;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_HEAP_UNLOCK(This->s.DIBsection);
}
return result;
}
ICOM_VTABLE(IDirectDrawSurface4) xlib_dds4vt = ICOM_VTABLE(IDirectDrawSurface4) xlib_dds4vt =
{ {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
@ -403,7 +434,7 @@ ICOM_VTABLE(IDirectDrawSurface4) xlib_dds4vt =
IDirectDrawSurface4Impl_GetCaps, IDirectDrawSurface4Impl_GetCaps,
IDirectDrawSurface4Impl_GetClipper, IDirectDrawSurface4Impl_GetClipper,
IDirectDrawSurface4Impl_GetColorKey, IDirectDrawSurface4Impl_GetColorKey,
IDirectDrawSurface4Impl_GetDC, Xlib_IDirectDrawSurface4Impl_GetDC,
IDirectDrawSurface4Impl_GetFlipStatus, IDirectDrawSurface4Impl_GetFlipStatus,
IDirectDrawSurface4Impl_GetOverlayPosition, IDirectDrawSurface4Impl_GetOverlayPosition,
IDirectDrawSurface4Impl_GetPalette, IDirectDrawSurface4Impl_GetPalette,

View File

@ -50,6 +50,7 @@ typedef struct x11_ds_private {
#ifdef HAVE_LIBXXSHM #ifdef HAVE_LIBXXSHM
XShmSegmentInfo shminfo; XShmSegmentInfo shminfo;
#endif #endif
int *oldDIBmap;
} x11_ds_private; } x11_ds_private;
#ifdef HAVE_LIBXXSHM #ifdef HAVE_LIBXXSHM