Fixed DGA / DGA 2 palette creation.

This commit is contained in:
Lionel Ulmer 2000-09-12 23:35:17 +00:00 committed by Alexandre Julliard
parent 0ca52b2e42
commit 5e14b07961
3 changed files with 84 additions and 14 deletions

View File

@ -26,21 +26,13 @@ HRESULT WINAPI DGA_IDirectDrawPaletteImpl_SetEntries(
) { ) {
ICOM_THIS(IDirectDrawPaletteImpl,iface); ICOM_THIS(IDirectDrawPaletteImpl,iface);
DPPRIVATE(This); DPPRIVATE(This);
DDPRIVATE(This->ddraw);
XColor xc; XColor xc;
Colormap cm;
int i; int i;
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,x,start,count,palent); TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,x,start,count,palent);
if (!dppriv->cm) /* should not happen */ { if (!dppriv->cm) /* should not happen */ {
FIXME("app tried to set colormap in non-palettized mode\n"); TRACE("app tried to set colormap in non-palettized mode\n");
return DDERR_GENERIC;
} }
/* FIXME: free colorcells instead of freeing whole map */
cm = dppriv->cm;
dppriv->cm = TSXCopyColormapAndFree(display,dppriv->cm);
TSXFreeColormap(display,cm);
for (i=0;i<count;i++) { for (i=0;i<count;i++) {
xc.red = palent[i].peRed<<8; xc.red = palent[i].peRed<<8;
xc.blue = palent[i].peBlue<<8; xc.blue = palent[i].peBlue<<8;
@ -48,6 +40,7 @@ HRESULT WINAPI DGA_IDirectDrawPaletteImpl_SetEntries(
xc.flags = DoRed|DoBlue|DoGreen; xc.flags = DoRed|DoBlue|DoGreen;
xc.pixel = i+start; xc.pixel = i+start;
if (dppriv->cm)
TSXStoreColor(display,dppriv->cm,&xc); TSXStoreColor(display,dppriv->cm,&xc);
This->palents[start+i].peRed = palent[i].peRed; This->palents[start+i].peRed = palent[i].peRed;
@ -55,7 +48,7 @@ HRESULT WINAPI DGA_IDirectDrawPaletteImpl_SetEntries(
This->palents[start+i].peGreen = palent[i].peGreen; This->palents[start+i].peGreen = palent[i].peGreen;
This->palents[start+i].peFlags = palent[i].peFlags; This->palents[start+i].peFlags = palent[i].peFlags;
} }
ddpriv->InstallColormap(display,DefaultScreen(display),dppriv->cm); /* Flush the display queue so that palette updates are visible directly */
TSXFlush(display); TSXFlush(display);
return DD_OK; return DD_OK;
} }

View File

@ -100,7 +100,28 @@ HRESULT WINAPI DGA_IDirectDrawSurface4Impl_SetPalette(
IDirectDrawPalette_Release( (IDirectDrawPalette*)This->s.palette ); IDirectDrawPalette_Release( (IDirectDrawPalette*)This->s.palette );
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);
if (!fppriv->cm &&
(This->s.ddraw->d->screen_pixelformat.u.dwRGBBitCount<=8) ) {
int i;
/* Delayed palette creation */
fppriv->cm = TSXCreateColormap(display,DefaultRootWindow(display),
DefaultVisualOfScreen(X11DRV_GetXScreen()),AllocAll);
for (i=0;i<256;i++) {
XColor xc;
xc.red = ipal->palents[i].peRed<<8;
xc.blue = ipal->palents[i].peBlue<<8;
xc.green = ipal->palents[i].peGreen<<8;
xc.flags = DoRed|DoBlue|DoGreen;
xc.pixel = i;
TSXStoreColor(display,fppriv->cm,&xc);
}
}
TSXF86DGAInstallColormap(display,DefaultScreen(display),fppriv->cm);
if (This->s.hdc != 0) { if (This->s.hdc != 0) {
/* hack: set the DIBsection color map */ /* hack: set the DIBsection color map */

View File

@ -14,6 +14,7 @@
#include "debugtools.h" #include "debugtools.h"
#include "dga2_private.h" #include "dga2_private.h"
#include "bitmap.h"
DEFAULT_DEBUG_CHANNEL(ddraw); DEFAULT_DEBUG_CHANNEL(ddraw);
@ -69,6 +70,61 @@ HRESULT WINAPI DGA2_IDirectDrawSurface4Impl_Flip(
return DD_OK; return DD_OK;
} }
HRESULT WINAPI DGA2_IDirectDrawSurface4Impl_SetPalette(
LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWPALETTE pal
) {
ICOM_THIS(IDirectDrawSurface4Impl,iface);
DDPRIVATE(This->s.ddraw);
IDirectDrawPaletteImpl* ipal=(IDirectDrawPaletteImpl*)pal;
TRACE("(%p)->(%p)\n",This,ipal);
/* According to spec, we are only supposed to
* AddRef if this is not the same palette.
*/
if( This->s.palette != ipal ) {
dga_dp_private *fppriv;
if( ipal != NULL )
IDirectDrawPalette_AddRef( (IDirectDrawPalette*)ipal );
if( This->s.palette != NULL )
IDirectDrawPalette_Release( (IDirectDrawPalette*)This->s.palette );
This->s.palette = ipal;
fppriv = (dga_dp_private*)This->s.palette->private;
if (!fppriv->cm &&
(This->s.ddraw->d->screen_pixelformat.u.dwRGBBitCount<=8) ) {
int i;
/* Delayed palette creation */
fppriv->cm = TSXDGACreateColormap(display,DefaultScreen(display), ddpriv->dev, AllocAll);
for (i=0;i<256;i++) {
XColor xc;
xc.red = ipal->palents[i].peRed<<8;
xc.blue = ipal->palents[i].peBlue<<8;
xc.green = ipal->palents[i].peGreen<<8;
xc.flags = DoRed|DoBlue|DoGreen;
xc.pixel = i;
TSXStoreColor(display,fppriv->cm,&xc);
}
}
TSXDGAInstallColormap(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_ReleaseObj(This->s.DIBsection);
}
TSXFlush(display);
}
return DD_OK;
}
ICOM_VTABLE(IDirectDrawSurface4) dga2_dds4vt = ICOM_VTABLE(IDirectDrawSurface4) dga2_dds4vt =
{ {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
@ -103,7 +159,7 @@ ICOM_VTABLE(IDirectDrawSurface4) dga2_dds4vt =
IDirectDrawSurface4Impl_SetClipper, IDirectDrawSurface4Impl_SetClipper,
IDirectDrawSurface4Impl_SetColorKey, IDirectDrawSurface4Impl_SetColorKey,
IDirectDrawSurface4Impl_SetOverlayPosition, IDirectDrawSurface4Impl_SetOverlayPosition,
DGA_IDirectDrawSurface4Impl_SetPalette, DGA2_IDirectDrawSurface4Impl_SetPalette,
DGA_IDirectDrawSurface4Impl_Unlock, DGA_IDirectDrawSurface4Impl_Unlock,
IDirectDrawSurface4Impl_UpdateOverlay, IDirectDrawSurface4Impl_UpdateOverlay,
IDirectDrawSurface4Impl_UpdateOverlayDisplay, IDirectDrawSurface4Impl_UpdateOverlayDisplay,