Commit 85107d81 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Remove some unnecessary forward declarations.

parent a1465ba4
......@@ -34,10 +34,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey);
static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES convert);
static void surface_remove_pbo(IWineD3DSurfaceImpl *This);
static void surface_force_reload(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
......@@ -1819,6 +1815,86 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
return WINED3D_OK;
}
static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey)
{
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
IWineD3DPaletteImpl *pal = This->palette;
BOOL index_in_alpha = FALSE;
unsigned int i;
/* Old games like StarCraft, C&C, Red Alert and others use P8 render targets.
* Reading back the RGB output each lockrect (each frame as they lock the whole screen)
* is slow. Further RGB->P8 conversion is not possible because palettes can have
* duplicate entries. Store the color key in the unused alpha component to speed the
* download up and to make conversion unneeded. */
index_in_alpha = primary_render_target_is_p8(device);
if (!pal)
{
UINT dxVersion = ((IWineD3DImpl *)device->wineD3D)->dxVersion;
/* In DirectDraw the palette is a property of the surface, there are no such things as device palettes. */
if (dxVersion <= 7)
{
ERR("This code should never get entered for DirectDraw!, expect problems\n");
if (index_in_alpha)
{
/* Guarantees that memory representation remains correct after sysmem<->texture transfers even if
* there's no palette at this time. */
for (i = 0; i < 256; i++) table[i][3] = i;
}
}
else
{
/* Direct3D >= 8 palette usage style: P8 textures use device palettes, palette entry format is A8R8G8B8,
* alpha is stored in peFlags and may be used by the app if D3DPTEXTURECAPS_ALPHAPALETTE device
* capability flag is present (wine does advertise this capability) */
for (i = 0; i < 256; ++i)
{
table[i][0] = device->palettes[device->currentPalette][i].peRed;
table[i][1] = device->palettes[device->currentPalette][i].peGreen;
table[i][2] = device->palettes[device->currentPalette][i].peBlue;
table[i][3] = device->palettes[device->currentPalette][i].peFlags;
}
}
}
else
{
TRACE("Using surface palette %p\n", pal);
/* Get the surface's palette */
for (i = 0; i < 256; ++i)
{
table[i][0] = pal->palents[i].peRed;
table[i][1] = pal->palents[i].peGreen;
table[i][2] = pal->palents[i].peBlue;
/* When index_in_alpha is set the palette index is stored in the
* alpha component. In case of a readback we can then read
* GL_ALPHA. Color keying is handled in BltOverride using a
* GL_ALPHA_TEST using GL_NOT_EQUAL. In case of index_in_alpha the
* color key itself is passed to glAlphaFunc in other cases the
* alpha component of pixels that should be masked away is set to 0. */
if (index_in_alpha)
{
table[i][3] = i;
}
else if (colorkey && (i >= This->SrcBltCKey.dwColorSpaceLowValue)
&& (i <= This->SrcBltCKey.dwColorSpaceHighValue))
{
table[i][3] = 0x00;
}
else if(pal->Flags & WINEDDPCAPS_ALPHA)
{
table[i][3] = pal->palents[i].peFlags;
}
else
{
table[i][3] = 0xFF;
}
}
}
}
static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UINT width,
UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This)
{
......@@ -2190,65 +2266,6 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
return WINED3D_OK;
}
static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey) {
IWineD3DPaletteImpl* pal = This->palette;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
BOOL index_in_alpha = FALSE;
int dxVersion = ( (IWineD3DImpl *) device->wineD3D)->dxVersion;
unsigned int i;
/* Old games like StarCraft, C&C, Red Alert and others use P8 render targets.
* Reading back the RGB output each lockrect (each frame as they lock the whole screen)
* is slow. Further RGB->P8 conversion is not possible because palettes can have
* duplicate entries. Store the color key in the unused alpha component to speed the
* download up and to make conversion unneeded. */
index_in_alpha = primary_render_target_is_p8(device);
if (pal == NULL) {
/* In DirectDraw the palette is a property of the surface, there are no such things as device palettes. */
if(dxVersion <= 7) {
ERR("This code should never get entered for DirectDraw!, expect problems\n");
if(index_in_alpha) {
/* Guarantees that memory representation remains correct after sysmem<->texture transfers even if
there's no palette at this time. */
for (i = 0; i < 256; i++) table[i][3] = i;
}
} else {
/* Direct3D >= 8 palette usage style: P8 textures use device palettes, palette entry format is A8R8G8B8,
alpha is stored in peFlags and may be used by the app if D3DPTEXTURECAPS_ALPHAPALETTE device
capability flag is present (wine does advertise this capability) */
for (i = 0; i < 256; i++) {
table[i][0] = device->palettes[device->currentPalette][i].peRed;
table[i][1] = device->palettes[device->currentPalette][i].peGreen;
table[i][2] = device->palettes[device->currentPalette][i].peBlue;
table[i][3] = device->palettes[device->currentPalette][i].peFlags;
}
}
} else {
TRACE("Using surface palette %p\n", pal);
/* Get the surface's palette */
for (i = 0; i < 256; i++) {
table[i][0] = pal->palents[i].peRed;
table[i][1] = pal->palents[i].peGreen;
table[i][2] = pal->palents[i].peBlue;
/* When index_in_alpha is the palette index is stored in the alpha component. In case of a readback
we can then read GL_ALPHA. Color keying is handled in BltOverride using a GL_ALPHA_TEST using GL_NOT_EQUAL.
In case of index_in_alpha the color key itself is passed to glAlphaFunc in other cases the alpha component
of pixels that should be masked away is set to 0. */
if(index_in_alpha) {
table[i][3] = i;
} else if(colorkey && (i >= This->SrcBltCKey.dwColorSpaceLowValue) && (i <= This->SrcBltCKey.dwColorSpaceHighValue)) {
table[i][3] = 0x00;
} else if(pal->Flags & WINEDDPCAPS_ALPHA) {
table[i][3] = pal->palents[i].peFlags;
} else {
table[i][3] = 0xFF;
}
}
}
}
/* This function is used in case of 8bit paletted textures to upload the palette.
It supports GL_EXT_paletted_texture and GL_ARB_fragment_program, support for other
extensions like ATI_fragment_shaders is possible.
......
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