Commit 68f458dd authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Unified palette create, do allocate colorcells on init for DGA.

parent 62a8b433
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#ifdef HAVE_LIBXXF86DGA #ifdef HAVE_LIBXXF86DGA
#include "ts_xf86dga.h" #include "ts_xf86dga.h"
#include <sys/mman.h>
#endif #endif
#ifdef HAVE_LIBXXSHM #ifdef HAVE_LIBXXSHM
...@@ -2524,19 +2525,13 @@ static HRESULT WINAPI IDirectDraw2_CreateClipper( ...@@ -2524,19 +2525,13 @@ static HRESULT WINAPI IDirectDraw2_CreateClipper(
} }
static HRESULT WINAPI common_IDirectDraw2_CreatePalette( static HRESULT WINAPI common_IDirectDraw2_CreatePalette(
LPDIRECTDRAW2 this,DWORD dwFlags,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk LPDIRECTDRAW2 this,DWORD dwFlags,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk,int *psize
) { ) {
*lpddpal = (LPDIRECTDRAWPALETTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectDrawPalette)); *lpddpal = (LPDIRECTDRAWPALETTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectDrawPalette));
if (*lpddpal == NULL) return E_OUTOFMEMORY; if (*lpddpal == NULL) return E_OUTOFMEMORY;
(*lpddpal)->ref = 1; (*lpddpal)->ref = 1;
(*lpddpal)->ddraw = (LPDIRECTDRAW)this; (*lpddpal)->ddraw = (LPDIRECTDRAW)this;
(*lpddpal)->installed = 0; (*lpddpal)->installed = 0;
if (this->d.depth<=8) {
(*lpddpal)->cm = TSXCreateColormap(display,DefaultRootWindow(display),DefaultVisualOfScreen(screen),AllocAll);
} else {
/* we don't want palettes in hicolor or truecolor */
(*lpddpal)->cm = 0;
}
if (palent) if (palent)
{ {
...@@ -2554,56 +2549,52 @@ static HRESULT WINAPI common_IDirectDraw2_CreatePalette( ...@@ -2554,56 +2549,52 @@ static HRESULT WINAPI common_IDirectDraw2_CreatePalette(
ERR(ddraw, "unhandled palette format\n"); ERR(ddraw, "unhandled palette format\n");
memcpy((*lpddpal)->palents, palent, size * sizeof(PALETTEENTRY)); memcpy((*lpddpal)->palents, palent, size * sizeof(PALETTEENTRY));
*psize = size;
} }
return DD_OK; return DD_OK;
} }
static HRESULT WINAPI DGA_IDirectDraw2_CreatePalette( static HRESULT WINAPI DGA_IDirectDraw2_CreatePalette(
LPDIRECTDRAW2 this,DWORD x,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk LPDIRECTDRAW2 this,DWORD dwFlags,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk
) { ) {
HRESULT res; HRESULT res;
TRACE(ddraw,"(%p)->(%08lx,%p,%p,%p)\n",this,x,palent,lpddpal,lpunk); int xsize = 0,i;
res = common_IDirectDraw2_CreatePalette(this,x,palent,lpddpal,lpunk);
TRACE(ddraw,"(%p)->(%08lx,%p,%p,%p)\n",this,dwFlags,palent,lpddpal,lpunk);
res = common_IDirectDraw2_CreatePalette(this,dwFlags,palent,lpddpal,lpunk,&xsize);
if (res != 0) return res; if (res != 0) return res;
(*lpddpal)->lpvtbl = &dga_ddpalvt; (*lpddpal)->lpvtbl = &dga_ddpalvt;
if (this->d.depth<=8) {
(*lpddpal)->cm = TSXCreateColormap(display,DefaultRootWindow(display),DefaultVisualOfScreen(screen),AllocAll);
} else {
FIXME(ddraw,"why are we doing CreatePalette in hi/truecolor?\n");
(*lpddpal)->cm = 0;
}
if (((*lpddpal)->cm)&&xsize) {
for (i=0;i<xsize;i++) {
XColor xc;
xc.red = (*lpddpal)->palents[i].peRed<<8;
xc.blue = (*lpddpal)->palents[i].peBlue<<8;
xc.green = (*lpddpal)->palents[i].peGreen<<8;
xc.flags = DoRed|DoBlue|DoGreen;
xc.pixel = i;
TSXStoreColor(display,(*lpddpal)->cm,&xc);
}
}
return DD_OK; return DD_OK;
} }
static HRESULT WINAPI Xlib_IDirectDraw2_CreatePalette( static HRESULT WINAPI Xlib_IDirectDraw2_CreatePalette(
LPDIRECTDRAW2 this,DWORD dwFlags,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk LPDIRECTDRAW2 this,DWORD dwFlags,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk
) { ) {
TRACE(ddraw,"(%p)->(%08lx,%p,%p,%p)\n",this,dwFlags,palent,lpddpal,lpunk); int xsize;
*lpddpal = (LPDIRECTDRAWPALETTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectDrawPalette)); HRESULT res;
TRACE(ddraw, "Palette created : %p\n", *lpddpal);
if (*lpddpal == NULL)
return E_OUTOFMEMORY;
(*lpddpal)->ref = 1; TRACE(ddraw,"(%p)->(%08lx,%p,%p,%p)\n",this,dwFlags,palent,lpddpal,lpunk);
(*lpddpal)->installed = 0; res = common_IDirectDraw2_CreatePalette(this,dwFlags,palent,lpddpal,lpunk,&xsize);
if (res != 0) return res;
(*lpddpal)->lpvtbl = &xlib_ddpalvt; (*lpddpal)->lpvtbl = &xlib_ddpalvt;
(*lpddpal)->ddraw = (LPDIRECTDRAW)this;
this->lpvtbl->fnAddRef(this);
if (palent) {
int size = 0;
if (dwFlags & DDPCAPS_1BIT)
size = 2;
else if (dwFlags & DDPCAPS_2BIT)
size = 4;
else if (dwFlags & DDPCAPS_4BIT)
size = 16;
else if (dwFlags & DDPCAPS_8BIT)
size = 256;
else
ERR(ddraw, "unhandled palette format\n");
memcpy((*lpddpal)->palents, palent, size * sizeof(PALETTEENTRY));
}
return DD_OK; return DD_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment