The DirectDraw reference counting is a bit more complex than it seemed at
first. The unit test in that patch shows that the IDirectDraw,
IDirectDraw2, IDirectDraw4 and IDirectDraw7 interfaces of one object have
their own reference count. The object is the same, the test with
SetCooperativeLevel shows this(Setting a focus window returns an error in
exclusive mode). Interestingly the IDirect3DX interfaces do not have
their own refcount, instead they are linked to a DirectDraw interface
refcount.
This patch splits up the IDirectDrawImpl::ref member in ref7, ref4, ref2
and ref1 and changes the AddRef and Release methods accordingly. Of
course a number of tests to show this behavior are included :-)
I will also send a patch which fixes some reference counting issues with
Palettes, and both patches depend on each other. So please apply either
both patches or none of them if one is wrong.
ChangeLog:
Stefan Dösinger: Split the ddraw refcount
Here is an updated patch, it implements the destroy condition as suggested
by Rob and adds the accidentally dropped SetCooperativeLevel(NULL,
DDSCL_NORMAL) cooplevel and screen mode restoring call.