amstream: Call ::SetFormat in AMDirectDrawStream::CreateSample.
Signed-off-by: Anton Baskanov <baskanov@gmail.com> Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7d48c52816
commit
5f7e25c7b1
|
@ -1413,6 +1413,7 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
|
||||||
const RECT *rect, IDirectDrawStreamSample **ddraw_stream_sample)
|
const RECT *rect, IDirectDrawStreamSample **ddraw_stream_sample)
|
||||||
{
|
{
|
||||||
struct ddraw_sample *object;
|
struct ddraw_sample *object;
|
||||||
|
DDSURFACEDESC desc;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("(%p)\n", ddraw_stream_sample);
|
TRACE("(%p)\n", ddraw_stream_sample);
|
||||||
|
@ -1434,7 +1435,6 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DDSURFACEDESC desc;
|
|
||||||
IDirectDraw *ddraw;
|
IDirectDraw *ddraw;
|
||||||
|
|
||||||
hr = IDirectDrawMediaStream_GetDirectDraw(&parent->IDirectDrawMediaStream_iface, &ddraw);
|
hr = IDirectDrawMediaStream_GetDirectDraw(&parent->IDirectDrawMediaStream_iface, &ddraw);
|
||||||
|
@ -1475,14 +1475,30 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rect)
|
desc.dwSize = sizeof(desc);
|
||||||
object->rect = *rect;
|
hr = IDirectDrawSurface_GetSurfaceDesc(object->surface, &desc);
|
||||||
else if (object->surface)
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
DDSURFACEDESC desc = { sizeof(desc) };
|
IDirectDrawStreamSample_Release(&object->IDirectDrawStreamSample_iface);
|
||||||
hr = IDirectDrawSurface_GetSurfaceDesc(object->surface, &desc);
|
return hr;
|
||||||
if (hr == S_OK)
|
}
|
||||||
SetRect(&object->rect, 0, 0, desc.dwWidth, desc.dwHeight);
|
|
||||||
|
if (rect)
|
||||||
|
{
|
||||||
|
object->rect = *rect;
|
||||||
|
desc.dwWidth = rect->right - rect->left;
|
||||||
|
desc.dwHeight = rect->bottom - rect->top;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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;
|
*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)
|
static void test_ddrawstream_create_sample(void)
|
||||||
{
|
{
|
||||||
IAMMultiMediaStream *mmstream = create_ammultimediastream();
|
IAMMultiMediaStream *mmstream = create_ammultimediastream();
|
||||||
|
DDSURFACEDESC desc2 = { sizeof(desc2) };
|
||||||
IDirectDrawSurface *surface, *surface2;
|
IDirectDrawSurface *surface, *surface2;
|
||||||
DDSURFACEDESC desc = { sizeof(desc) };
|
DDSURFACEDESC desc = { sizeof(desc) };
|
||||||
IDirectDrawMediaStream *ddraw_stream;
|
IDirectDrawMediaStream *ddraw_stream;
|
||||||
|
@ -6603,11 +6604,74 @@ static void test_ddrawstream_create_sample(void)
|
||||||
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, &rect, 0, &sample);
|
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, &rect, 0, &sample);
|
||||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
|
||||||
IDirectDrawMediaStream_Release(ddraw_stream);
|
|
||||||
ref = IDirectDrawStreamSample_Release(sample);
|
ref = IDirectDrawStreamSample_Release(sample);
|
||||||
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
||||||
ref = IDirectDrawSurface_Release(surface);
|
ref = IDirectDrawSurface_Release(surface);
|
||||||
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
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);
|
ref = IAMMultiMediaStream_Release(mmstream);
|
||||||
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
||||||
ref = IMediaStream_Release(stream);
|
ref = IMediaStream_Release(stream);
|
||||||
|
|
Loading…
Reference in New Issue