From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/dcomp/dcomp_private.h | 6 +- dlls/dcomp/device.c | 147 ++++++++++++++++++++++--------------- dlls/dcomp/tests/dcomp.c | 16 +--- 3 files changed, 94 insertions(+), 75 deletions(-)
diff --git a/dlls/dcomp/dcomp_private.h b/dlls/dcomp/dcomp_private.h index 99912ab9156..98e79ad3827 100644 --- a/dlls/dcomp/dcomp_private.h +++ b/dlls/dcomp/dcomp_private.h @@ -23,7 +23,7 @@ struct composition_device { IDCompositionDevice IDCompositionDevice_iface; - IDCompositionDevice2 IDCompositionDevice2_iface; + IDCompositionDesktopDevice IDCompositionDesktopDevice_iface; int version; LONG ref; }; @@ -33,9 +33,9 @@ static inline struct composition_device *impl_from_IDCompositionDevice(IDComposi return CONTAINING_RECORD(iface, struct composition_device, IDCompositionDevice_iface); }
-static inline struct composition_device *impl_from_IDCompositionDevice2(IDCompositionDevice2 *iface) +static inline struct composition_device *impl_from_IDCompositionDesktopDevice(IDCompositionDesktopDevice *iface) { - return CONTAINING_RECORD(iface, struct composition_device, IDCompositionDevice2_iface); + return CONTAINING_RECORD(iface, struct composition_device, IDCompositionDesktopDevice_iface); }
#endif /* __WINE_DCOMP_PRIVATE_H */ diff --git a/dlls/dcomp/device.c b/dlls/dcomp/device.c index 519e5b065bf..c64719c836d 100644 --- a/dlls/dcomp/device.c +++ b/dlls/dcomp/device.c @@ -44,10 +44,12 @@ static HRESULT STDMETHODCALLTYPE device_QueryInterface(IDCompositionDevice *ifac *out = &device->IDCompositionDevice_iface; return S_OK; } - else if (device->version >= 2 && IsEqualGUID(iid, &IID_IDCompositionDevice2)) + else if (device->version >= 2 + && (IsEqualGUID(iid, &IID_IDCompositionDevice2) + || IsEqualGUID(iid, &IID_IDCompositionDesktopDevice))) { - IUnknown_AddRef(&device->IDCompositionDevice2_iface); - *out = &device->IDCompositionDevice2_iface; + IUnknown_AddRef(&device->IDCompositionDesktopDevice_iface); + *out = &device->IDCompositionDesktopDevice_iface; return S_OK; }
@@ -285,61 +287,61 @@ static const struct IDCompositionDeviceVtbl device_vtbl = device_CheckDeviceState, };
-static HRESULT STDMETHODCALLTYPE device2_QueryInterface(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_QueryInterface(IDCompositionDesktopDevice *iface, REFIID iid, void **out) { - struct composition_device *device = impl_from_IDCompositionDevice2(iface); + struct composition_device *device = impl_from_IDCompositionDesktopDevice(iface);
TRACE("iface %p.\n", iface);
return IDCompositionDevice_QueryInterface(&device->IDCompositionDevice_iface, iid, out); }
-static ULONG STDMETHODCALLTYPE device2_AddRef(IDCompositionDevice2 *iface) +static ULONG STDMETHODCALLTYPE desktop_device_AddRef(IDCompositionDesktopDevice *iface) { - struct composition_device *device = impl_from_IDCompositionDevice2(iface); + struct composition_device *device = impl_from_IDCompositionDesktopDevice(iface);
TRACE("iface %p.\n", iface);
return IDCompositionDevice_AddRef(&device->IDCompositionDevice_iface); }
-static ULONG STDMETHODCALLTYPE device2_Release(IDCompositionDevice2 *iface) +static ULONG STDMETHODCALLTYPE desktop_device_Release(IDCompositionDesktopDevice *iface) { - struct composition_device *device = impl_from_IDCompositionDevice2(iface); + struct composition_device *device = impl_from_IDCompositionDesktopDevice(iface);
TRACE("iface %p.\n", iface);
return IDCompositionDevice_Release(&device->IDCompositionDevice_iface); }
-static HRESULT STDMETHODCALLTYPE device2_Commit(IDCompositionDevice2 *iface) +static HRESULT STDMETHODCALLTYPE desktop_device_Commit(IDCompositionDesktopDevice *iface) { FIXME("iface %p stub!\n", iface); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_WaitForCommitCompletion(IDCompositionDevice2 *iface) +static HRESULT STDMETHODCALLTYPE desktop_device_WaitForCommitCompletion(IDCompositionDesktopDevice *iface) { FIXME("iface %p stub!\n", iface); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_GetFrameStatistics(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_GetFrameStatistics(IDCompositionDesktopDevice *iface, DCOMPOSITION_FRAME_STATISTICS *statistics) { FIXME("iface %p, statistics %p stub!\n", iface, statistics); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateVisual(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateVisual(IDCompositionDesktopDevice *iface, IDCompositionVisual2 **visual) { FIXME("iface %p, visual %p stub!\n", iface, visual); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateSurfaceFactory(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateSurfaceFactory(IDCompositionDesktopDevice *iface, IUnknown *rendering_device, IDCompositionSurfaceFactory **surface_factory) { FIXME("iface %p, rendering_device %p, surface_factory %p stub!\n", iface, rendering_device, @@ -347,7 +349,7 @@ static HRESULT STDMETHODCALLTYPE device2_CreateSurfaceFactory(IDCompositionDevic return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateSurface(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateSurface(IDCompositionDesktopDevice *iface, UINT width, UINT height, DXGI_FORMAT pixel_format, DXGI_ALPHA_MODE alpha_mode, IDCompositionSurface **surface) { @@ -356,7 +358,7 @@ static HRESULT STDMETHODCALLTYPE device2_CreateSurface(IDCompositionDevice2 *ifa return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateVirtualSurface(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateVirtualSurface(IDCompositionDesktopDevice *iface, UINT width, UINT height, DXGI_FORMAT pixel_format, DXGI_ALPHA_MODE alpha_mode, IDCompositionVirtualSurface **surface) { @@ -365,79 +367,78 @@ static HRESULT STDMETHODCALLTYPE device2_CreateVirtualSurface(IDCompositionDevic return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateTranslateTransform(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateTranslateTransform(IDCompositionDesktopDevice *iface, IDCompositionTranslateTransform **transform) { FIXME("iface %p, transform %p stub!\n", iface, transform); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateScaleTransform(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateScaleTransform(IDCompositionDesktopDevice *iface, IDCompositionScaleTransform **transform) { FIXME("iface %p, transform %p stub!\n", iface, transform); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateRotateTransform(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateRotateTransform(IDCompositionDesktopDevice *iface, IDCompositionRotateTransform **transform) { FIXME("iface %p, transform %p stub!\n", iface, transform); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateSkewTransform(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateSkewTransform(IDCompositionDesktopDevice *iface, IDCompositionSkewTransform **transform) { FIXME("iface %p, transform %p stub!\n", iface, transform); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateMatrixTransform(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateMatrixTransform(IDCompositionDesktopDevice *iface, IDCompositionMatrixTransform **transform) { FIXME("iface %p, transform %p stub!\n", iface, transform); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateTransformGroup(IDCompositionDevice2 *iface, - IDCompositionTransform **transforms, UINT elements, - IDCompositionTransform **transform_group) +static HRESULT STDMETHODCALLTYPE desktop_device_CreateTransformGroup(IDCompositionDesktopDevice *iface, + IDCompositionTransform **transforms, UINT elements, IDCompositionTransform **transform_group) { FIXME("iface %p, transforms %p, elements %u, transform_group %p stub!\n", iface, transforms, elements, transform_group); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateTranslateTransform3D(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateTranslateTransform3D(IDCompositionDesktopDevice *iface, IDCompositionTranslateTransform3D **transform_3d) { FIXME("iface %p, translate_transform_3d %p stub!\n", iface, transform_3d); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateScaleTransform3D(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateScaleTransform3D(IDCompositionDesktopDevice *iface, IDCompositionScaleTransform3D **transform_3d) { FIXME("iface %p, transform_3d %p stub!\n", iface, transform_3d); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateRotateTransform3D(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateRotateTransform3D(IDCompositionDesktopDevice *iface, IDCompositionRotateTransform3D **transform_3d) { FIXME("iface %p, transform_3d %p stub!\n", iface, transform_3d); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateMatrixTransform3D(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateMatrixTransform3D(IDCompositionDesktopDevice *iface, IDCompositionMatrixTransform3D **transform_3d) { FIXME("iface %p, transform_3d %p stub!\n", iface, transform_3d); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateTransform3DGroup(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateTransform3DGroup(IDCompositionDesktopDevice *iface, IDCompositionTransform3D **transforms_3d, UINT elements, IDCompositionTransform3D **transform_3d_group) { @@ -446,55 +447,80 @@ static HRESULT STDMETHODCALLTYPE device2_CreateTransform3DGroup(IDCompositionDev return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateEffectGroup(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateEffectGroup(IDCompositionDesktopDevice *iface, IDCompositionEffectGroup **effect_group) { FIXME("iface %p, effect_group %p stub!\n", iface, effect_group); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateRectangleClip(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateRectangleClip(IDCompositionDesktopDevice *iface, IDCompositionRectangleClip **clip) { FIXME("iface %p, clip %p stub!\n", iface, clip); return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE device2_CreateAnimation(IDCompositionDevice2 *iface, +static HRESULT STDMETHODCALLTYPE desktop_device_CreateAnimation(IDCompositionDesktopDevice *iface, IDCompositionAnimation **animation) { FIXME("iface %p, animation %p stub!\n", iface, animation); return E_NOTIMPL; }
-static const struct IDCompositionDevice2Vtbl device2_vtbl = +static HRESULT STDMETHODCALLTYPE desktop_device_CreateTargetForHwnd(IDCompositionDesktopDevice *iface, + HWND hwnd, BOOL topmost, IDCompositionTarget **target) +{ + FIXME("iface %p, hwnd %p, topmost %d, target %p stub!\n", iface, hwnd, topmost, target); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE desktop_device_CreateSurfaceFromHandle(IDCompositionDesktopDevice *iface, + HANDLE handle, IUnknown **surface) +{ + FIXME("iface %p, handle %p, surface %p stub!\n", iface, handle, surface); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE desktop_device_CreateSurfaceFromHwnd(IDCompositionDesktopDevice *iface, + HWND hwnd, IUnknown **surface) +{ + FIXME("iface %p, hwnd %p, surface %p stub!\n", iface, hwnd, surface); + return E_NOTIMPL; +} + +static const struct IDCompositionDesktopDeviceVtbl desktop_device_vtbl = { /* IUnknown methods */ - device2_QueryInterface, - device2_AddRef, - device2_Release, + desktop_device_QueryInterface, + desktop_device_AddRef, + desktop_device_Release, /* IDCompositionDevice2 methods */ - device2_Commit, - device2_WaitForCommitCompletion, - device2_GetFrameStatistics, - device2_CreateVisual, - device2_CreateSurfaceFactory, - device2_CreateSurface, - device2_CreateVirtualSurface, - device2_CreateTranslateTransform, - device2_CreateScaleTransform, - device2_CreateRotateTransform, - device2_CreateSkewTransform, - device2_CreateMatrixTransform, - device2_CreateTransformGroup, - device2_CreateTranslateTransform3D, - device2_CreateScaleTransform3D, - device2_CreateRotateTransform3D, - device2_CreateMatrixTransform3D, - device2_CreateTransform3DGroup, - device2_CreateEffectGroup, - device2_CreateRectangleClip, - device2_CreateAnimation, + desktop_device_Commit, + desktop_device_WaitForCommitCompletion, + desktop_device_GetFrameStatistics, + desktop_device_CreateVisual, + desktop_device_CreateSurfaceFactory, + desktop_device_CreateSurface, + desktop_device_CreateVirtualSurface, + desktop_device_CreateTranslateTransform, + desktop_device_CreateScaleTransform, + desktop_device_CreateRotateTransform, + desktop_device_CreateSkewTransform, + desktop_device_CreateMatrixTransform, + desktop_device_CreateTransformGroup, + desktop_device_CreateTranslateTransform3D, + desktop_device_CreateScaleTransform3D, + desktop_device_CreateRotateTransform3D, + desktop_device_CreateMatrixTransform3D, + desktop_device_CreateTransform3DGroup, + desktop_device_CreateEffectGroup, + desktop_device_CreateRectangleClip, + desktop_device_CreateAnimation, + /* IDCompositionDesktopDevice methods */ + desktop_device_CreateTargetForHwnd, + desktop_device_CreateSurfaceFromHandle, + desktop_device_CreateSurfaceFromHwnd, };
static HRESULT create_device(int version, REFIID iid, void **out) @@ -510,7 +536,7 @@ static HRESULT create_device(int version, REFIID iid, void **out) return E_OUTOFMEMORY;
device->IDCompositionDevice_iface.lpVtbl = &device_vtbl; - device->IDCompositionDevice2_iface.lpVtbl = &device2_vtbl; + device->IDCompositionDesktopDevice_iface.lpVtbl = &desktop_device_vtbl; device->version = version; device->ref = 1; hr = IDCompositionDevice_QueryInterface(&device->IDCompositionDevice_iface, iid, out); @@ -530,9 +556,10 @@ HRESULT WINAPI DCompositionCreateDevice(IDXGIDevice *dxgi_device, REFIID iid, vo
HRESULT WINAPI DCompositionCreateDevice2(IUnknown *rendering_device, REFIID iid, void **device) { - FIXME("%p, %s, %p semi-stub!\n", rendering_device, debugstr_guid(iid), device); + TRACE("%p, %s, %p\n", rendering_device, debugstr_guid(iid), device);
- if (!IsEqualIID(iid, &IID_IDCompositionDevice)) + if (!IsEqualIID(iid, &IID_IDCompositionDevice) + && !IsEqualIID(iid, &IID_IDCompositionDesktopDevice)) return E_NOINTERFACE;
return create_device(2, iid, device); diff --git a/dlls/dcomp/tests/dcomp.c b/dlls/dcomp/tests/dcomp.c index 6b731bf7e98..cb14528e303 100644 --- a/dlls/dcomp/tests/dcomp.c +++ b/dlls/dcomp/tests/dcomp.c @@ -157,13 +157,9 @@ static void test_DCompositionCreateDevice2(void)
hr = IDCompositionDevice_QueryInterface(dcomp_device, &IID_IDCompositionDesktopDevice, (void **)&desktop_device); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { - refcount = IDCompositionDesktopDevice_Release(desktop_device); - ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount); - } + refcount = IDCompositionDesktopDevice_Release(desktop_device); + ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
refcount = IDCompositionDevice_Release(dcomp_device); ok(!refcount, "Device has %lu references left.\n", refcount); @@ -188,13 +184,9 @@ static void test_DCompositionCreateDevice2(void)
hr = pDCompositionCreateDevice2((IUnknown *)dxgi_device, &IID_IDCompositionDesktopDevice, (void **)&desktop_device); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { - refcount = IDCompositionDesktopDevice_Release(desktop_device); - ok(!refcount, "Device has %lu references left.\n", refcount); - } + refcount = IDCompositionDesktopDevice_Release(desktop_device); + ok(!refcount, "Device has %lu references left.\n", refcount);
hr = pDCompositionCreateDevice2((IUnknown *)dxgi_device, &IID_IDCompositionDevice, NULL); ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);