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:
parent
9d0abdbcca
commit
561895a937
|
@ -28,12 +28,14 @@ typedef x11_dp_private dga_dp_private; /* reuse X11 palette stuff */
|
|||
|
||||
typedef struct dga_ds_private {
|
||||
DWORD fb_height;
|
||||
int *oldDIBmap;
|
||||
} dga_ds_private;
|
||||
|
||||
/* For usage in DGA2 */
|
||||
extern ULONG WINAPI DGA_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) ;
|
||||
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_GetDC(LPDIRECTDRAWSURFACE4 iface,HDC* lphdc);
|
||||
|
||||
extern HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface_no_VT(LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsd,
|
||||
LPDIRECTDRAWSURFACE *lpdsf,IUnknown *lpunk) ;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "debugtools.h"
|
||||
#include "dga_private.h"
|
||||
#include "bitmap.h"
|
||||
|
||||
DEFAULT_DEBUG_CHANNEL(ddraw);
|
||||
|
||||
|
@ -100,6 +101,14 @@ HRESULT WINAPI DGA_IDirectDrawSurface4Impl_SetPalette(
|
|||
This->s.palette = ipal;
|
||||
fppriv = (dga_dp_private*)This->s.palette->private;
|
||||
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;
|
||||
}
|
||||
|
@ -123,6 +132,12 @@ ULONG WINAPI DGA_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
|
|||
|
||||
/* Free the DIBSection (if any) */
|
||||
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);
|
||||
DeleteDC(This->s.hdc);
|
||||
DeleteObject(This->s.DIBsection);
|
||||
|
@ -146,6 +161,22 @@ HRESULT WINAPI DGA_IDirectDrawSurface4Impl_Unlock(
|
|||
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_MSVTABLE_COMPAT_DummyRTTIVALUE
|
||||
|
@ -166,7 +197,7 @@ ICOM_VTABLE(IDirectDrawSurface4) dga_dds4vt =
|
|||
IDirectDrawSurface4Impl_GetCaps,
|
||||
IDirectDrawSurface4Impl_GetClipper,
|
||||
IDirectDrawSurface4Impl_GetColorKey,
|
||||
IDirectDrawSurface4Impl_GetDC,
|
||||
DGA_IDirectDrawSurface4Impl_GetDC,
|
||||
IDirectDrawSurface4Impl_GetFlipStatus,
|
||||
IDirectDrawSurface4Impl_GetOverlayPosition,
|
||||
IDirectDrawSurface4Impl_GetPalette,
|
||||
|
|
|
@ -89,7 +89,7 @@ ICOM_VTABLE(IDirectDrawSurface4) dga2_dds4vt =
|
|||
IDirectDrawSurface4Impl_GetCaps,
|
||||
IDirectDrawSurface4Impl_GetClipper,
|
||||
IDirectDrawSurface4Impl_GetColorKey,
|
||||
IDirectDrawSurface4Impl_GetDC,
|
||||
DGA_IDirectDrawSurface4Impl_GetDC,
|
||||
IDirectDrawSurface4Impl_GetFlipStatus,
|
||||
IDirectDrawSurface4Impl_GetOverlayPosition,
|
||||
IDirectDrawSurface4Impl_GetPalette,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "options.h"
|
||||
#include "debugtools.h"
|
||||
#include "x11_private.h"
|
||||
#include "bitmap.h"
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
/* for d3d texture stuff */
|
||||
|
@ -313,6 +314,14 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_SetPalette(
|
|||
This->s.palette = ipal;
|
||||
/* Perform the refresh */
|
||||
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;
|
||||
}
|
||||
|
@ -370,6 +379,12 @@ ULONG WINAPI Xlib_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
|
|||
|
||||
/* Free the DIBSection (if any) */
|
||||
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);
|
||||
DeleteDC(This->s.hdc);
|
||||
DeleteObject(This->s.DIBsection);
|
||||
|
@ -383,6 +398,22 @@ ULONG WINAPI Xlib_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
|
|||
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_MSVTABLE_COMPAT_DummyRTTIVALUE
|
||||
|
@ -403,7 +434,7 @@ ICOM_VTABLE(IDirectDrawSurface4) xlib_dds4vt =
|
|||
IDirectDrawSurface4Impl_GetCaps,
|
||||
IDirectDrawSurface4Impl_GetClipper,
|
||||
IDirectDrawSurface4Impl_GetColorKey,
|
||||
IDirectDrawSurface4Impl_GetDC,
|
||||
Xlib_IDirectDrawSurface4Impl_GetDC,
|
||||
IDirectDrawSurface4Impl_GetFlipStatus,
|
||||
IDirectDrawSurface4Impl_GetOverlayPosition,
|
||||
IDirectDrawSurface4Impl_GetPalette,
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef struct x11_ds_private {
|
|||
#ifdef HAVE_LIBXXSHM
|
||||
XShmSegmentInfo shminfo;
|
||||
#endif
|
||||
int *oldDIBmap;
|
||||
} x11_ds_private;
|
||||
|
||||
#ifdef HAVE_LIBXXSHM
|
||||
|
|
Loading…
Reference in New Issue