Am 20.05.2014 um 14:27 schrieb Henri Verbeet hverbeet@gmail.com:
On 20 May 2014 13:09, Stefan Dösinger stefan@codeweavers.com wrote:
@@ -3372,7 +3301,7 @@ static BOOL color_in_range(const struct wined3d_color_key *color_key, DWORD colo
void d3dfmt_p8_init_palette(const struct wined3d_surface *surface, BYTE table[256][4]) {
- const struct wined3d_palette *pal = surface->palette;
const struct wined3d_palette *pal = surface->swapchain ? surface->swapchain->palette : NULL; unsigned int i;
if (!pal)
This function is a bit silly. I think all callers should be able to just use palette->colors[], and avoid the extra copy.
Yes, except for setting color[i].alpha = i. This should eventually be handled by the caller, and in the case of the ARB blitter, the shader. That’s a topic for a different patch though.
I'd guess that if no palette is set on the swapchain it should use the system palette, but perhaps it's ok to leave that undefined for now.
Yes, but it’s not as easy as as calling GetSytemPaletteEntries because we’re not actually in P8 mode. I think the best we can do is create a wined3d default palette that contains the fixed entries of the Windows system palette and sets the other colors to black / white / pink whatever. If there's an application that modifies the system palette via gdi and then uses ddraw with an undefined palette we'll need a more elaborate paletteindexed mode emulation scheme that probably involves winex11.drv/winemac.drv.
This is problematic in wined3d, because you can have multiple swapchains using the same palette. In practice that never happens, but that depends on knowing about everything that calls wined3d. If you really need this kind of scheme you'd have to make "palette->changed" a counter, and then iterate over all swapchains on wrap,
A previous (unsent) version kept the flag in the swapchain and iterated over all attached swapchains similar to what swapchain_realize_palette was doing. That would handle multiple swapchains, but I'd prefer to keep it in the palette because eventually the palette should maintain the P8 blit texture and will need the dirty flag for this purpose.
but couldn't you just create a GDI palette for the wined3d palette, and then select that into the DC for the blit?
I'm not entirely sure what the relation between the DIB color table and the device context's palette is. I read plenty of documentation and experimented with this on Windows when I wrote the getdc palette tests. I couldn't make the HPALETTE attached to a DC from a surface do anything on Windows. I'll see if it magically does something in x11_copy_to_screen.
Or just always update the palette, which is pretty much what we do now in the GL case.
Sure, that's always a fallback option, but I'd prefer to avoid it.