Commit ed06707b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

amstream: Create a surface if it wasn't provided in CreateSample().

parent 91e4394c
......@@ -364,6 +364,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetDirect
HRESULT hr = DirectDrawCreateEx(NULL, (void**)&This->ddraw, &IID_IDirectDraw7, NULL);
if (FAILED(hr))
return hr;
IDirectDraw7_SetCooperativeLevel(This->ddraw, NULL, DDSCL_NORMAL);
}
return IDirectDraw7_QueryInterface(This->ddraw, &IID_IDirectDraw, (void**)ddraw);
......@@ -979,7 +980,39 @@ static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectD
IDirectDrawSurface_AddRef(surface);
}
else
FIXME("create ddraw surface\n");
{
DDSURFACEDESC desc;
IDirectDraw *ddraw;
hr = IDirectDrawMediaStream_GetDirectDraw(parent, &ddraw);
if (FAILED(hr))
{
IDirectDrawStreamSample_Release(&object->IDirectDrawStreamSample_iface);
return hr;
}
desc.dwSize = sizeof(desc);
desc.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT;
desc.dwHeight = 100;
desc.dwWidth = 100;
desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat);
desc.ddpfPixelFormat.dwFlags = DDPF_RGB;
desc.ddpfPixelFormat.dwRGBBitCount = 32;
desc.ddpfPixelFormat.dwRBitMask = 0xff0000;
desc.ddpfPixelFormat.dwGBitMask = 0x00ff00;
desc.ddpfPixelFormat.dwBBitMask = 0x0000ff;
desc.ddpfPixelFormat.dwRGBAlphaBitMask = 0;
desc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN;
hr = IDirectDraw_CreateSurface(ddraw, &desc, &object->surface, NULL);
IDirectDraw_Release(ddraw);
if (FAILED(hr))
{
ERR("failed to create surface, 0x%08x\n", hr);
IDirectDrawStreamSample_Release(&object->IDirectDrawStreamSample_iface);
return hr;
}
}
if (rect)
object->rect = *rect;
......@@ -995,7 +1028,7 @@ static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectD
}
}
*ddraw_stream_sample = (IDirectDrawStreamSample*)&object->IDirectDrawStreamSample_iface;
*ddraw_stream_sample = &object->IDirectDrawStreamSample_iface;
return S_OK;
}
......
......@@ -452,11 +452,13 @@ static void test_media_streams(void)
static void test_IDirectDrawStreamSample(void)
{
DDSURFACEDESC desc = { sizeof(desc) };
IAMMultiMediaStream *pams;
HRESULT hr;
IMediaStream *pvidstream = NULL;
IDirectDrawMediaStream *pddstream = NULL;
IDirectDrawStreamSample *pddsample = NULL;
IDirectDrawSurface7 *surface7;
IDirectDrawSurface *surface, *surface2;
IDirectDraw *ddraw, *ddraw2;
IDirectDraw7 *ddraw7;
......@@ -504,9 +506,18 @@ static void test_IDirectDrawStreamSample(void)
surface = NULL;
hr = IDirectDrawStreamSample_GetSurface(pddsample, &surface, &rect);
ok(hr == S_OK, "got 0x%08x\n", hr);
todo_wine
ok(surface != NULL, "got %p\n", surface);
if (surface)
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void**)&surface7);
ok(hr == S_OK, "got 0x%08x\n", hr);
IDirectDrawSurface7_Release(surface7);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(desc.dwWidth == 100, "width %d\n", desc.dwWidth);
ok(desc.dwHeight == 100, "height %d\n", desc.dwHeight);
ok(desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "format flags %08x\n", desc.ddpfPixelFormat.dwFlags);
ok(desc.ddpfPixelFormat.dwRGBBitCount, "dwRGBBitCount %d\n", desc.ddpfPixelFormat.dwRGBBitCount);
IDirectDrawSurface_Release(surface);
IDirectDrawStreamSample_Release(pddsample);
......
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