Commit cfae1ceb authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

d3drm: Correct D3DRMIMAGE validation.

parent e85cab70
......@@ -2724,6 +2724,12 @@ static void test_Texture(void)
TRUE, 0, (void *)0xcafebabe, NULL,
0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
},
testimg_palette =
{
2, 2, 1, 1, 32,
FALSE, 2 * sizeof(DWORD), (void *)0xcafebabe, NULL,
0x00000000, 0x00000000, 0x00000000, 0, 2, (void *)0xcafebabe
},
*d3drm_img = NULL;
DWORD pixel[4] = { 20000, 30000, 10000, 0 };
......@@ -2785,6 +2791,17 @@ static void test_Texture(void)
IDirect3DRMTexture2_Release(texture2);
IDirect3DRMTexture3_Release(texture3);
/* Just palette set */
hr = IDirect3DRM_CreateTexture(d3drm1, &testimg_palette, &texture1);
ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr);
hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg_palette, &texture2);
ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr);
hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg_palette, &texture3);
ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr);
IDirect3DRMTexture_Release(texture1);
IDirect3DRMTexture2_Release(texture2);
IDirect3DRMTexture3_Release(texture3);
initimg.rgb = 0;
texture1 = (IDirect3DRMTexture *)0xdeadbeef;
hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
......
......@@ -52,14 +52,27 @@ static void d3drm_texture_destroy(struct d3drm_texture *texture)
static BOOL d3drm_validate_image(D3DRMIMAGE *image)
{
if (!image
|| !image->red_mask
|| !image->green_mask
|| !image->blue_mask
|| !image->buffer1
|| !(image->rgb || (image->palette && image->palette_size)))
{
if (!image)
return FALSE;
TRACE("size (%d, %d), aspect (%d, %d), depth %d, red %#lx, green %#lx, blue %#lx, "
"buffer1 %p, buffer2 %p, rgb %d, pal %p, size %d\n",
image->width, image->height, image->aspectx, image->aspecty,
image->depth, image->red_mask, image->green_mask, image->blue_mask, image->buffer1,
image->buffer2, image->rgb, image->palette, image->palette_size );
if (!image->buffer1)
return FALSE;
if (image->rgb)
{
if (!image->red_mask || !image->green_mask || !image->blue_mask)
return FALSE;
}
else
{
if (!image->palette || !image->palette_size)
return FALSE;
}
return TRUE;
......
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