Anton Baskanov : amstream: Call ::SetFormat in AMDirectDrawStream::CreateSample.
Alexandre Julliard
julliard at winehq.org
Fri Sep 25 14:52:54 CDT 2020
Module: wine
Branch: master
Commit: 5f7e25c7b1d10b1f514540588014831073e27979
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5f7e25c7b1d10b1f514540588014831073e27979
Author: Anton Baskanov <baskanov at gmail.com>
Date: Fri Sep 25 02:07:45 2020 +0700
amstream: Call ::SetFormat in AMDirectDrawStream::CreateSample.
Signed-off-by: Anton Baskanov <baskanov at gmail.com>
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/amstream/ddrawstream.c | 28 ++++++++++++++----
dlls/amstream/tests/amstream.c | 66 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 87 insertions(+), 7 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c
index 0771587552..c3cb2fc49a 100644
--- a/dlls/amstream/ddrawstream.c
+++ b/dlls/amstream/ddrawstream.c
@@ -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;
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c
index 9b25bdd7d1..df9d148493 100644
--- a/dlls/amstream/tests/amstream.c
+++ b/dlls/amstream/tests/amstream.c
@@ -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);
More information about the wine-cvs
mailing list