Handle correctly DDSD_LINEARSIZE flag for FOURCC textures.

This commit is contained in:
Christian Costa 2005-01-03 14:41:08 +00:00 committed by Alexandre Julliard
parent d6cf14d7b6
commit 65a4775b30
2 changed files with 22 additions and 18 deletions

View File

@ -408,21 +408,22 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
}
#endif
if (!(ddsd.dwFlags & DDSD_PITCH))
if ((ddsd.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) && !(ddsd.dwFlags & DDSD_LINEARSIZE))
{
if (ddsd.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) {
int size = 0;
int width = ddsd.dwWidth;
int height = ddsd.dwHeight;
switch(ddsd.u4.ddpfPixelFormat.dwFourCC) {
case MAKE_FOURCC('D','X','T','1'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 8; break;
case MAKE_FOURCC('D','X','T','3'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 16; break;
case MAKE_FOURCC('D','X','T','5'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 16; break;
default: FIXME("FOURCC not supported\n"); break;
}
ddsd.u1.dwLinearSize = size;
} else
ddsd.u1.lPitch = DDRAW_width_bpp_to_pitch(ddsd.dwWidth, GET_BPP(ddsd)*8);
int size = 0;
int width = ddsd.dwWidth;
int height = ddsd.dwHeight;
switch(ddsd.u4.ddpfPixelFormat.dwFourCC) {
case MAKE_FOURCC('D','X','T','1'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 8; break;
case MAKE_FOURCC('D','X','T','3'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 16; break;
case MAKE_FOURCC('D','X','T','5'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 16; break;
default: FIXME("FOURCC not supported\n"); break;
}
ddsd.u1.dwLinearSize = size;
ddsd.dwFlags |= DDSD_LINEARSIZE;
} else if (!(ddsd.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) && !(ddsd.dwFlags & DDSD_PITCH)) {
ddsd.u1.lPitch = DDRAW_width_bpp_to_pitch(ddsd.dwWidth, GET_BPP(ddsd)*8);
ddsd.dwFlags |= DDSD_PITCH;
}
/* Check also for the MIPMAP / MIPMAPCOUNT flags.
@ -433,7 +434,7 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
ddsd.u2.dwMipMapCount = 1;
}
ddsd.dwFlags |= DDSD_PITCH | DDSD_PIXELFORMAT;
ddsd.dwFlags |= DDSD_PIXELFORMAT;
hr = This->create_texture(This, &ddsd, ppSurf, pUnkOuter, mipmap_level);
if (FAILED(hr)) return hr;

View File

@ -253,17 +253,20 @@ HRESULT DIB_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
}
/* XXX else: how should lPitch be verified? */
This->surface_desc.dwFlags |= DDSD_PITCH|DDSD_LPSURFACE;
This->surface_desc.dwFlags |= DDSD_LPSURFACE;
if (This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC)
if (This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) {
This->surface_desc.lpSurface
= VirtualAlloc(NULL, This->surface_desc.u1.dwLinearSize, MEM_COMMIT, PAGE_READWRITE);
else
This->surface_desc.dwFlags |= DDSD_LINEARSIZE;
} else {
This->surface_desc.lpSurface
= VirtualAlloc(NULL, This->surface_desc.u1.lPitch
* This->surface_desc.dwHeight + 4, /* The + 4 here is for dumb games reading after the end of the surface
when reading the last byte / half using word access */
MEM_COMMIT, PAGE_READWRITE);
This->surface_desc.dwFlags |= DDSD_PITCH;
}
if (This->surface_desc.lpSurface == NULL)
{