Commit 5f7e25c7 authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

amstream: Call ::SetFormat in AMDirectDrawStream::CreateSample.

parent 7d48c528
......@@ -1413,6 +1413,7 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
const RECT *rect, IDirectDrawStreamSample **ddraw_stream_sample)
{
struct ddraw_sample *object;
DDSURFACEDESC desc;
HRESULT hr;
TRACE("(%p)\n", ddraw_stream_sample);
......@@ -1434,7 +1435,6 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
}
else
{
DDSURFACEDESC desc;
IDirectDraw *ddraw;
hr = IDirectDrawMediaStream_GetDirectDraw(&parent->IDirectDrawMediaStream_iface, &ddraw);
......@@ -1475,14 +1475,30 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
}
}
desc.dwSize = sizeof(desc);
hr = IDirectDrawSurface_GetSurfaceDesc(object->surface, &desc);
if (FAILED(hr))
{
IDirectDrawStreamSample_Release(&object->IDirectDrawStreamSample_iface);
return hr;
}
if (rect)
{
object->rect = *rect;
else if (object->surface)
desc.dwWidth = rect->right - rect->left;
desc.dwHeight = rect->bottom - rect->top;
}
else
{
DDSURFACEDESC desc = { sizeof(desc) };
hr = IDirectDrawSurface_GetSurfaceDesc(object->surface, &desc);
if (hr == S_OK)
SetRect(&object->rect, 0, 0, desc.dwWidth, desc.dwHeight);
SetRect(&object->rect, 0, 0, desc.dwWidth, desc.dwHeight);
}
hr = IDirectDrawMediaStream_SetFormat(&parent->IDirectDrawMediaStream_iface, &desc, NULL);
if (FAILED(hr))
{
IDirectDrawStreamSample_Release(&object->IDirectDrawStreamSample_iface);
return hr;
}
*ddraw_stream_sample = &object->IDirectDrawStreamSample_iface;
......
......@@ -6507,6 +6507,7 @@ static void get_ddrawstream_create_sample_desc_(int line, const DDSURFACEDESC *f
static void test_ddrawstream_create_sample(void)
{
IAMMultiMediaStream *mmstream = create_ammultimediastream();
DDSURFACEDESC desc2 = { sizeof(desc2) };
IDirectDrawSurface *surface, *surface2;
DDSURFACEDESC desc = { sizeof(desc) };
IDirectDrawMediaStream *ddraw_stream;
......@@ -6603,11 +6604,74 @@ static void test_ddrawstream_create_sample(void)
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, &rect, 0, &sample);
ok(hr == S_OK, "Got hr %#x.\n", hr);
IDirectDrawMediaStream_Release(ddraw_stream);
ref = IDirectDrawStreamSample_Release(sample);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IDirectDrawSurface_Release(surface);
ok(!ref, "Got outstanding refcount %d.\n", ref);
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS;
desc.dwWidth = 444;
desc.dwHeight = 400;
desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
desc.ddpfPixelFormat.dwRGBBitCount = 32;
desc.ddpfPixelFormat.dwRBitMask = 0xff0000;
desc.ddpfPixelFormat.dwGBitMask = 0x00ff00;
desc.ddpfPixelFormat.dwBBitMask = 0x0000ff;
desc.ddpfPixelFormat.dwRGBAlphaBitMask = 0xff000000;
desc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
SetRect(&rect, 111, 100, 333, 300);
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, &rect, 0, &sample);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ref = IDirectDrawStreamSample_Release(sample);
ok(!ref, "Got outstanding refcount %d.\n", ref);
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &sample);
ok(hr == S_OK, "Got hr %#x.\n", hr);
surface2 = NULL;
hr = IDirectDrawStreamSample_GetSurface(sample, &surface2, &rect);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDirectDrawSurface_GetSurfaceDesc(surface2, &desc2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(desc2.dwWidth == 222, "Got width %u.\n", desc2.dwWidth);
ok(desc2.dwHeight == 200, "Got height %u.\n", desc2.dwHeight);
ok(memcmp(&desc2.ddpfPixelFormat, &desc.ddpfPixelFormat, sizeof(DDPIXELFORMAT)) == 0,
"Pixel format didn't match.\n");
ref = IDirectDrawStreamSample_Release(sample);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IDirectDrawSurface_Release(surface);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IDirectDrawSurface_Release(surface2);
ok(!ref, "Got outstanding refcount %d.\n", ref);
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS;
desc.dwWidth = 444;
desc.dwHeight = 400;
desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED4;
desc.ddpfPixelFormat.dwRGBBitCount = 4;
desc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, NULL, 0, &sample);
ok(hr == DDERR_INVALIDSURFACETYPE, "Got hr %#x.\n", hr);
IDirectDrawMediaStream_Release(ddraw_stream);
ref = IDirectDrawSurface_Release(surface);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IAMMultiMediaStream_Release(mmstream);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IMediaStream_Release(stream);
......
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