DDRAW: Fix reference counting
Stefan Dösinger
stefandoesinger at gmx.at
Mon Sep 19 09:35:23 CDT 2005
Hello,
> In that case, it would be really beneficial with a unit test.
> Both as documentation and to see what Windows does.
Excuse my ignorance, but what exactly is meant with 'unit test'? As far as
I've learned, it's a small piece of code which uses this functionality and
checks the results. My patch includes such a test:
--- /dev/null 2005-09-01 15:22:32.000000000 +0200
+++ dlls/ddraw/tests/refcount.c 2005-09-18 21:57:52.000000000 +0200
<...>
+ /* Create a Texture. Increases the refcount by 2!!!*/
+ memset(&ddsd, 0, sizeof(ddsd));
+ ddsd.dwSize = sizeof(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
<...>
+ rc = IDirectDraw7_CreateSurface( lpDD, &ddsd, &lpDDS, NULL );
+ ok(rc == DD_OK, "CreateSurface for a mipmap surface returned %lx\n", rc);
+ if(rc == DD_OK)
+ {
+ newref = IDirectDraw_AddRef(lpDD) - 1;
+ IDirectDraw_Release(lpDD);
+ ok( (newref - oldref) == 2, "DD reference count increased by %d
during creation of a mipmap surface\n", newref - oldref);
+ oldref = newref;
+
+ newref = IDirectDrawSurface_AddRef(lpDDS) - 1;
+ IDirectDrawSurface_Release(lpDDS);
+ ok(newref == 1, "Initial surface reference count of a mipmap surface
is %d\n", newref);
+
+ /* Release the surface */
+ IDirectDrawSurface_Release(lpDDS);
+
+ newref = IDirectDraw_AddRef(lpDD) - 1;
+ IDirectDraw_Release(lpDD);
+ ok( (newref - oldref) == -2, "DD reference count decreased by %d
during releasing a mipmap surface\n", newref - oldref);
+ }
Is that enought? This test succeeds in Windows 2000 and Windows 95.
Stefan
More information about the wine-devel
mailing list