示例#1
0
文件: cfg.c 项目: Asmodean-/PCSXR
static BOOL WINAPI DirectDrawEnumCallbackEx( GUID FAR* pGUID, LPSTR strDesc,
                                             LPSTR strName, VOID* pV,
                                             HMONITOR hMonitor )
{
 // Use the GUID to create the DirectDraw object, so that information
 // can be extracted from it.

 LPDIRECTDRAW pDD;
 LPDIRECTDRAW4 g_pDD;
 LPDIRECT3D3 pD3D;
 HRESULT (WINAPI *pDDrawCreateFn)(GUID *,LPDIRECTDRAW *,IUnknown *);

 pDDrawCreateFn = (LPVOID)GetProcAddress( hDDrawDLL, "DirectDrawCreate" );

 if( pDDrawCreateFn == NULL || FAILED( pDDrawCreateFn( pGUID, &pDD, 0L ) ) )
  {
   return D3DENUMRET_OK;
  }

 // Query the DirectDraw driver for access to Direct3D.
 if( FAILED(IDirectDraw_QueryInterface(pDD, &IID_IDirectDraw4, (VOID**)&g_pDD)))
  {
   IDirectDraw_Release(pDD);
   return D3DENUMRET_OK;
  }
 IDirectDraw_Release(pDD);

 // Query the DirectDraw driver for access to Direct3D.

 if( FAILED( IDirectDraw4_QueryInterface(g_pDD,&IID_IDirect3D3, (VOID**)&pD3D)))
  {
   IDirectDraw4_Release(g_pDD);
   return D3DENUMRET_OK;
  }

 bDeviceOK=FALSE;

 // Now, enumerate all the 3D devices
 IDirect3D3_EnumDevices(pD3D,Enum3DDevicesCallback,NULL);

 if(bDeviceOK)
  {
   HWND hWC=GetDlgItem(gHWND,IDC_DEVICE);
   int i=ComboBox_AddString(hWC,strDesc);
   GUID * g=(GUID *)malloc(sizeof(GUID));
   if(NULL != pGUID) *g=*pGUID;
   else              memset(g,0,sizeof(GUID));
   ComboBox_SetItemData(hWC,i,g);
  }

 IDirect3D3_Release(pD3D);
 IDirectDraw4_Release(g_pDD);
 return DDENUMRET_OK;
}
示例#2
0
文件: cfg.c 项目: Asmodean-/PCSXR
BOOL bTestModes(void)
{
 LPDIRECTDRAW pDD;
 LPDIRECTDRAW4 g_pDD;
 HRESULT (WINAPI *pDDrawCreateFn)(GUID *,LPDIRECTDRAW *,IUnknown *);

 GUID FAR * guid=0;
 int i;unsigned char * c=(unsigned char *)&guiDev;
 for(i=0;i<sizeof(GUID);i++,c++)
  {if(*c) {guid=&guiDev;break;}}

 bDeviceOK=FALSE;

 pDDrawCreateFn = (LPVOID)GetProcAddress(hDDrawDLL, "DirectDrawCreate");

 if( pDDrawCreateFn == NULL || FAILED( pDDrawCreateFn(guid, &pDD, 0L ) ) )
  {
   return FALSE;
  }

 if(FAILED(IDirectDraw_QueryInterface(pDD, &IID_IDirectDraw4, (VOID**)&g_pDD)))
  {
   IDirectDraw_Release(pDD);
   return FALSE;
  }
 IDirectDraw_Release(pDD);

 IDirectDraw4_EnumDisplayModes(g_pDD,0,NULL,NULL,EnumDisplayModesCallback);

 IDirectDraw4_Release(g_pDD);

 return bDeviceOK;
}
示例#3
0
/*
 * D3DAppTotalVideoMemory
 * Returns the amount of total video memory supported (not free)
 */
DWORD
D3DAppTotalVideoMemory(void)
{
#if 0
    DDCAPS DriverCaps, HELCaps;
    memset (&DriverCaps, 0, sizeof(DDCAPS));
    DriverCaps.dwSize = sizeof(DDCAPS);
    memset (&HELCaps, 0, sizeof(DDCAPS));
    HELCaps.dwSize = sizeof(DDCAPS);
    LastError = d3dappi.lpDD->lpVtbl->GetCaps(d3dappi.lpDD, &DriverCaps,
                                              &HELCaps);
    if (LastError != DD_OK) {
        D3DAppISetErrorString("Getting DD capabilities failed while checking total video memory.\n%s",
                              D3DAppErrorToString(LastError));
        return 0L;
    }
    if (DriverCaps.dwVidMemTotal)
        return DriverCaps.dwVidMemTotal;
    else
        return HELCaps.dwVidMemTotal;
#endif

    LPDIRECTDRAW4 lpdd4;
    DDSCAPS2      ddsCaps2;
    DWORD         dwTotal, dwFree;
    DDSURFACEDESC2 dds2;
    
    // get dd4 ptr...
    IDirectDraw4_QueryInterface( d3dappi.lpDD, &IID_IDirectDraw4, (LPVOID *)&lpdd4 );  

    memset( &ddsCaps2, 0, sizeof( DDSCAPS2 ) );
    ddsCaps2.dwCaps = DDSCAPS_LOCALVIDMEM;

    if ( IDirectDraw4_GetAvailableVidMem( lpdd4, &ddsCaps2, &dwTotal, &dwFree ) != DD_OK )
        dwTotal = 0;

    if ( dwTotal )
    {
        memset( &dds2, 0, sizeof( DDSURFACEDESC2 ) );
        dds2.dwSize = sizeof( DDSURFACEDESC2 );
        if ( IDirectDraw4_GetDisplayMode( lpdd4, &dds2  ) == DD_OK )
        {
            dwTotal += ( dds2.dwHeight * dds2.lPitch  );
        }
    }

    IDirectDraw4_Release( lpdd4 );

    return dwTotal;
}
static void
winFreeFBShadowDDNL(ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;

  /* Free the shadow surface, if there is one */
  if (pScreenPriv->pddsShadow4)
    {
      IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
      free (pScreenInfo->pfb);
      pScreenInfo->pfb = NULL;
      pScreenPriv->pddsShadow4 = NULL;
    }

  /* Detach the clipper from the primary surface and release the primary surface, if there is one */
  winReleasePrimarySurfaceShadowDDNL(pScreen);

  /* Release the clipper object */
  if (pScreenPriv->pddcPrimary)
    {
      IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
      pScreenPriv->pddcPrimary = NULL;
    }

  /* Free the DirectDraw4 object, if there is one */
  if (pScreenPriv->pdd4)
    {
      IDirectDraw4_RestoreDisplayMode (pScreenPriv->pdd4);
      IDirectDraw4_Release (pScreenPriv->pdd4);
      pScreenPriv->pdd4 = NULL;
    }

  /* Free the DirectDraw object, if there is one */
  if (pScreenPriv->pdd)
    {
      IDirectDraw_Release (pScreenPriv->pdd);
      pScreenPriv->pdd = NULL;
    }

  /* Invalidate the ScreenInfo's fb pointer */
  pScreenInfo->pfb = NULL;
}
示例#5
0
文件: surface.c 项目: AlexSteel/wine
static HRESULT WINAPI ddrawex_surface4_Initialize(IDirectDrawSurface4 *iface,
        IDirectDraw *ddraw, DDSURFACEDESC2 *desc)
{
    struct ddrawex_surface *surface = impl_from_IDirectDrawSurface4(iface);
    IDirectDraw4 *outer_DD4;
    IDirectDraw4 *inner_DD4;
    IDirectDraw *inner_DD;
    HRESULT hr;

    TRACE("iface %p, ddraw %p, desc %p.\n", iface, ddraw, desc);

    IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw4, (void **)&outer_DD4);
    inner_DD4 = dd_get_inner(outer_DD4);
    IDirectDraw4_Release(outer_DD4);
    IDirectDraw4_QueryInterface(inner_DD4, &IID_IDirectDraw4, (void **)&inner_DD);
    hr = IDirectDrawSurface4_Initialize(surface->parent, inner_DD, desc);
    IDirectDraw_Release(inner_DD);
    return hr;
}
示例#6
0
static void test_ddraw_objects(void)
{
    HRESULT hr;
    unsigned long ref;
    IDirectDraw7 *DDraw7;
    IDirectDraw4 *DDraw4;
    IDirectDraw2 *DDraw2;
    IDirectDraw  *DDraw1;
    IDirectDrawPalette *palette;
    IDirectDrawSurface7 *surface;
    IDirectDrawSurface *surface1;
    IDirectDrawSurface4 *surface4;
    PALETTEENTRY Table[256];
    DDSURFACEDESC2 ddsd;

    hr = pDirectDrawCreateEx(NULL, (void **) &DDraw7, &IID_IDirectDraw7, NULL);
    ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
    if(!DDraw7)
    {
        trace("Couldn't create DDraw interface, skipping tests\n");
        return;
    }

    hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw4, (void **) &DDraw4);
    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
    hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw2, (void **) &DDraw2);
    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
    hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw, (void **) &DDraw1);
    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);

    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);

    /* Fails without a cooplevel */
    hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "CreatePalette returned %08x\n", hr);

    /* This check is before the cooplevel check */
    hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, (void *) 0xdeadbeef);
    ok(hr == CLASS_E_NOAGGREGATION, "CreatePalette returned %08x\n", hr);

    hr = IDirectDraw7_SetCooperativeLevel(DDraw7, 0, DDSCL_NORMAL);
    ok(hr == DD_OK, "SetCooperativeLevel failed with %08x\n", hr);

    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
    ddsd.dwWidth = 64;
    ddsd.dwHeight = 64;
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
    U4(ddsd).ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
    U1(U4(ddsd).ddpfPixelFormat).dwRGBBitCount = 8;

    hr = IDirectDraw7_CreateSurface(DDraw7, &ddsd, &surface, NULL);
    ok(hr == DD_OK, "CreateSurface failed with %08x\n", hr);

    /* DDraw refcount increased by 1 */
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);

    /* Surface refcount starts with 1 */
    ref = getRefcount( (IUnknown *) surface);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);

    hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);

    /* DDraw refcount increased by 1 */
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 3, "Got refcount %ld, expected 3\n", ref);

    /* Palette starts with 1 */
    ref = getRefcount( (IUnknown *) palette);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);

    /* Test attaching a palette to a surface */
    hr = IDirectDrawSurface7_SetPalette(surface, palette);
    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette failed with %08x\n", hr);

    /* Palette refcount increased, surface stays the same */
    ref = getRefcount( (IUnknown *) palette);
    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
    ref = getRefcount( (IUnknown *) surface);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);

    IDirectDrawSurface7_Release(surface);
    /* Increased before - decrease now */
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);

    /* Releasing the surface detaches the palette */
    ref = getRefcount( (IUnknown *) palette);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);

    IDirectDrawPalette_Release(palette);

    /* Increased before - decrease now */
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);

    /* Not all interfaces are AddRefed when a palette is created */
    hr = IDirectDraw4_CreatePalette(DDraw4, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
    ref = getRefcount( (IUnknown *) DDraw4);
    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
    IDirectDrawPalette_Release(palette);

    /* No addref here */
    hr = IDirectDraw2_CreatePalette(DDraw2, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
    ref = getRefcount( (IUnknown *) DDraw2);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
    IDirectDrawPalette_Release(palette);

    /* No addref here */
    hr = IDirectDraw_CreatePalette(DDraw1, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
    IDirectDrawPalette_Release(palette);

    /* Similar for surfaces */
    hr = IDirectDraw4_CreateSurface(DDraw4, &ddsd, &surface4, NULL);
    ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
    ref = getRefcount( (IUnknown *) DDraw4);
    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
    IDirectDrawSurface4_Release(surface4);

    ddsd.dwSize = sizeof(DDSURFACEDESC);
    hr = IDirectDraw2_CreateSurface(DDraw2, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
    ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
    ref = getRefcount( (IUnknown *) DDraw2);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
    IDirectDrawSurface_Release(surface1);

    hr = IDirectDraw_CreateSurface(DDraw1, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
    ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
    IDirectDrawSurface_Release(surface1);

    IDirectDraw7_Release(DDraw7);
    IDirectDraw4_Release(DDraw4);
    IDirectDraw2_Release(DDraw2);
    IDirectDraw_Release(DDraw1);
}
示例#7
0
static void test_d3d_ifaces(void)
{
    IDirectDraw *DDraw1;
    IDirectDraw2 *DDraw2;
    IDirectDraw4 *DDraw4;
    IDirect3D *D3D1;
    IDirect3D2 *D3D2;
    IDirect3D3 *D3D3;
    IDirect3D7 *D3D7;
    HRESULT hr;
    long ref;

    hr = DirectDrawCreate(NULL, &DDraw1, NULL);
    ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
    if(!DDraw1)
    {
        trace("DirectDrawCreate failed with %08x\n", hr);
        return;
    }

    hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirectDraw2, (void **) &DDraw2);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
    hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirectDraw4, (void **) &DDraw4);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);

    ref = getRefcount( (IUnknown *) DDraw4);
    ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw2);
    ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);

    hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D, (void **) &D3D1);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
    ref = getRefcount( (IUnknown *) DDraw4);
    ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw2);
    ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
    IDirect3D_Release(D3D1);

    hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D2, (void **) &D3D2);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
    ref = getRefcount( (IUnknown *) DDraw4);
    ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw2);
    ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
    IDirect3D2_Release(D3D2);

    hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
    ref = getRefcount( (IUnknown *) DDraw4);
    ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw2);
    ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
    IDirect3D3_Release(D3D3);

    /* Try to AddRef the D3D3 interface that has been released already */
    IDirect3D3_AddRef(D3D3);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) D3D3);
    ok(ref == 2, "IDirect3D3 reference count is %ld\n", ref);
    /* The newer interfaces remain untouched */
    ref = getRefcount( (IUnknown *) DDraw4);
    ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw2);
    ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
    IDirect3D3_Release(D3D3);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);

    /* It is possible to query any IDirect3D interfaces from any IDirectDraw interface,
     * Except IDirect3D7, it can only be returned by IDirectDraw7(which can't return older ifaces)
     */
    hr = IDirectDraw_QueryInterface(DDraw2, &IID_IDirect3D, (void **) &D3D1);
    ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08x\n", hr);
    IDirect3D_Release(D3D1);
    hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D, (void **) &D3D1);
    ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08x\n", hr);
    IDirect3D_Release(D3D1);

    hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D2, (void **) &D3D2);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
    IDirect3D_Release(D3D2);
    hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D2, (void **) &D3D2);
    ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08x\n", hr);
    IDirect3D_Release(D3D2);

    hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D3, (void **) &D3D3);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
    IDirect3D_Release(D3D3);
    hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D3, (void **) &D3D3);
    ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08x\n", hr);
    IDirect3D_Release(D3D3);

    /* This does NOT work */
    hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D7, (void **) &D3D7);
    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08x\n", hr);
    if(D3D7) IDirect3D_Release(D3D7);
    hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D7, (void **) &D3D7);
    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08x\n", hr);
    if(D3D7) IDirect3D_Release(D3D7);
    hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D7, (void **) &D3D7);
    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08x\n", hr);
    if(D3D7) IDirect3D_Release(D3D7);

    /* Release the interfaces */
    IDirectDraw4_Release(DDraw4);
    IDirectDraw2_Release(DDraw2);
    IDirectDraw_Release(DDraw1);
}
示例#8
0
static void test_iface_refcnt(void)
{
    HRESULT hr;
    IDirectDraw  *DDraw1;
    IDirectDraw2 *DDraw2;
    IDirectDraw4 *DDraw4;
    IDirectDraw7 *DDraw7;
    IDirect3D7   *D3D7;
    IDirect3D3   *D3D3;
    IDirect3D2   *D3D2;
    IDirect3D    *D3D1;
    long ref;

    hr = pDirectDrawCreateEx(NULL, (void **) &DDraw7, &IID_IDirectDraw7, NULL);
    ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
    if(!DDraw7)
    {
        trace("Couldn't create DDraw interface, skipping tests\n");
        return;
    }

    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 1, "Initial IDirectDraw7 reference count is %ld\n", ref);

    hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw4, (void **) &DDraw4);
    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
    hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw2, (void **) &DDraw2);
    ok(hr == DD_OK, "IDirectDraw7_QueryInterf&ace returned %08x\n", hr);
    hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw, (void **) &DDraw1);
    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);

    /* All interfaces now have refcount 1! */
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 1, "IDirectDraw7 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 1, "IDirectDraw7 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw4);
    ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw2);
    ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);

    hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D7, (void **) &D3D7);
    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);

    /* Apparently IDirectDrawX and IDirect3DX are linked together */
    ref = getRefcount( (IUnknown *) D3D7);
    ok(ref == 2, "IDirect3D7 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 2, "IDirectDraw7 reference count is %ld\n", ref);

    IDirectDraw7_AddRef(DDraw7);
    ref = getRefcount( (IUnknown *) D3D7);
    ok(ref == 3, "IDirect3D7 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 3, "IDirectDraw7 reference count is %ld\n", ref);

    IDirect3D7_Release(D3D7);
    ref = getRefcount( (IUnknown *) D3D7);
    ok(ref == 2, "IDirect3D7 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 2, "IDirectDraw7 reference count is %ld\n", ref);

    /* Can't get older d3d interfaces. WHY????? */
    hr = IDirectDraw7_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
    if(hr == DD_OK && D3D3) IDirect3D3_Release(D3D3);

    hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08x\n", hr);
    if(hr == DD_OK && D3D3) IDirect3D3_Release(D3D3);

    hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D2, (void **) &D3D2);
    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
    if(hr == DD_OK && D3D2) IDirect3D2_Release(D3D2);

    hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D2, (void **) &D3D2);
    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08x\n", hr);
    if(hr == DD_OK && D3D2) IDirect3D2_Release(D3D2);

    hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D, (void **) &D3D1);
    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
    if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);

    hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D, (void **) &D3D1);
    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08x\n", hr);
    if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);

    hr = IDirect3D7_QueryInterface(D3D7, &IID_IDirect3D, (void **) &D3D1);
    todo_wine ok(hr == E_NOINTERFACE, "IDirect3D7_QueryInterface returned %08x\n", hr);
    if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);

    /* Try an AddRef, it only affects the AddRefed interface */
    IDirectDraw4_AddRef(DDraw4);
    ref = getRefcount( (IUnknown *) DDraw7);
    ok(ref == 2, "IDirectDraw7 reference count is %ld\n", ref); /* <-- From the d3d query */
    ref = getRefcount( (IUnknown *) DDraw4);
    ok(ref == 2, "IDirectDraw4 reference count is %ld\n", ref); /* <-- The AddRef call */
    ref = getRefcount( (IUnknown *) DDraw2);
    ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) DDraw1);
    ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
    ref = getRefcount( (IUnknown *) D3D7);
    ok(ref == 2, "IDirect3D7 reference count is %ld\n", ref); /* <-- From the d3d query */
    IDirectDraw4_Release(DDraw4);

    /* Make sure that they are one object, not different ones */
    hr = IDirectDraw4_SetCooperativeLevel(DDraw4, GetDesktopWindow(), DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
    ok(hr == DD_OK, "IDirectDraw4::SetCooperativeLevel returned %08x\n", hr);
    /* After an window has been set, DDSCL_SETFOCUSWINDOW should return DDERR_HWNDALREADYSET, see the mode test */
    hr = IDirectDraw7_SetCooperativeLevel(DDraw7, NULL, DDSCL_SETFOCUSWINDOW);
    ok(hr == DDERR_HWNDALREADYSET, "IDirectDraw7::SetCooperativeLevel returned %08x\n", hr);

    /* All done, release all interfaces */
    IDirectDraw7_Release(DDraw7);
    IDirectDraw4_Release(DDraw4);
    IDirectDraw2_Release(DDraw2);
    IDirectDraw_Release(DDraw1);
    IDirect3D7_Release(D3D7);
}
示例#9
0
static Bool
winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
  Bool			fReturn;

#if CYGDEBUG
  winDebug ("winCloseScreenShadowDDNL - Freeing screen resources\n");
#endif

  /* Flag that the screen is closed */
  pScreenPriv->fClosed = TRUE;
  pScreenPriv->fActive = FALSE;

  /* Call the wrapped CloseScreen procedure */
  WIN_UNWRAP(CloseScreen);
  fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);

  /* Free the screen DC */
  ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);

  /* Delete the window property */
  RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);

  /* Free the shadow surface, if there is one */
  if (pScreenPriv->pddsShadow4)
    {
      IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
      free (pScreenInfo->pfb);
      pScreenInfo->pfb = NULL;
      pScreenPriv->pddsShadow4 = NULL;
    }

  /* Detach the clipper from the primary surface and release the clipper. */
  if (pScreenPriv->pddcPrimary)
    {
      /* Detach the clipper */
      IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4,
				      NULL);

      /* Release the clipper object */
      IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
      pScreenPriv->pddcPrimary = NULL;
    }

  /* Release the primary surface, if there is one */
  if (pScreenPriv->pddsPrimary4)
    {
      IDirectDrawSurface4_Release (pScreenPriv->pddsPrimary4);
      pScreenPriv->pddsPrimary4 = NULL;
    }

  /* Free the DirectDraw4 object, if there is one */
  if (pScreenPriv->pdd4)
    {
      IDirectDraw4_RestoreDisplayMode (pScreenPriv->pdd4);
      IDirectDraw4_Release (pScreenPriv->pdd4);
      pScreenPriv->pdd4 = NULL;
    }

  /* Free the DirectDraw object, if there is one */
  if (pScreenPriv->pdd)
    {
      IDirectDraw_Release (pScreenPriv->pdd);
      pScreenPriv->pdd = NULL;
    }

  /* Delete tray icon, if we have one */
  if (!pScreenInfo->fNoTrayIcon)
    winDeleteNotifyIcon (pScreenPriv);

  /* Free the exit confirmation dialog box, if it exists */
  if (g_hDlgExit != NULL)
    {
      DestroyWindow (g_hDlgExit);
      g_hDlgExit = NULL;
    }

  /* Kill our window */
  if (pScreenPriv->hwndScreen)
    {
      DestroyWindow (pScreenPriv->hwndScreen);
      pScreenPriv->hwndScreen = NULL;
    }

#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
  /* Destroy the thread startup mutex */
  pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
#endif

  /* Kill our screeninfo's pointer to the screen */
  pScreenInfo->pScreen = NULL;

  /* Invalidate the ScreenInfo's fb pointer */
  pScreenInfo->pfb = NULL;

  /* Free the screen privates for this screen */
  free ((pointer) pScreenPriv);

  return fReturn;
}
示例#10
0
/*
 * D3DAppICreateDD
 * Creates the DirectDraw device and saves the current palette. If a 3D 
 * capable DD driver is available, use it as the DD device, otherwise, use
 * the HEL.  It is assumed that a 3D capable DD hardware driver is not the
 * primary device and hence cannot operate in a window (ie it's a fullscreen
 * only device displaying on a second monitor).  Valid flags:
 *     D3DAPP_ONLYDDEMULATION    Always use the DirectDraw HEL
 */
BOOL
D3DAppICreateDD(DWORD flags)
{
    HDC hdc;
    int i;
    LPDIRECTDRAW lpDD = NULL;
    DDCAPS DriverCaps, HELCaps, ddcaps;
    LPDIRECTDRAW4 pdd4 = NULL;

    /*
     * If we aren't forced to use the DirectDraw HEL, search for a 3D capable
     * DirectDraw hardware driver and create it.
     */
    if (!(flags & D3DAPP_ONLYDDEMULATION))
    {
        ddcount3d = 0;
        LastError = DirectDrawEnumerate(D3DAppIDDEnumCallback, &lpDD);
        if (LastError != DD_OK) 
        {
            D3DAppISetErrorString("DirectDrawEnumerate failed.\n%s",
                                  D3DAppErrorToString(LastError));
            return FALSE;
        }
    }
    if (!lpDD)
    {
        /*
         * If we haven't created a hardware DD device by now, resort to HEL
         */
        d3dappi.bIsPrimary = TRUE;
        LastError = DirectDrawCreate(NULL, &d3dappi.lpDD, NULL);
        if (LastError != DD_OK) 
        {
            D3DAppISetErrorString("DirectDrawCreate failed.\n%s",
                                  D3DAppErrorToString(LastError));
            return FALSE;
        }
    } else 
    {
        d3dappi.lpDD = lpDD;

        memset (&DriverCaps, 0, sizeof(DDCAPS));
        DriverCaps.dwSize = sizeof(DDCAPS);
        memset (&HELCaps, 0, sizeof(DDCAPS));
        HELCaps.dwSize = sizeof(DDCAPS);

        d3dappi.lpDD->lpVtbl->GetCaps(d3dappi.lpDD, &DriverCaps, &HELCaps);

        if (!((DriverCaps.dwCaps & DDCAPS_BLTSTRETCH) || (HELCaps.dwCaps & DDCAPS_BLTSTRETCH)))
        {
            CanDoStrechBlt = FALSE;
        }
    }

    // find out if current driver can do windowed mode ( need dx6 interface )

    // query for IDirectDraw4 ptr
    IDirectDraw_QueryInterface( d3dappi.lpDD, &IID_IDirectDraw4, (LPVOID *)&pdd4 );

    if ( pdd4 )
    {
        // get caps
        memset( &ddcaps, 0, sizeof( DDCAPS ) );
        ddcaps.dwSize = sizeof( DDCAPS );
        IDirectDraw4_GetCaps( pdd4, &ddcaps, NULL );

        // can do windowed??
        if( ddcaps.dwCaps2 & DDCAPS2_CANRENDERWINDOWED )
            CanRenderWindowed = TRUE;
        else
            CanRenderWindowed = FALSE;

        // release dd4 interface
        IDirectDraw4_Release( pdd4 );
    }

    /*
     * Save the original palette for when we are paused.  Just in case we
     * start in a fullscreen mode, put them in ppe.
     */
    hdc = GetDC(NULL);
    GetSystemPaletteEntries(hdc, 0, (1 << 8),
                            (LPPALETTEENTRY)(&Originalppe[0]));
    for (i = 0; i < 256; i++)
        ppe[i] = Originalppe[i];
    ReleaseDC(NULL, hdc);
    return TRUE;
}
示例#11
0
Bool
winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
  Bool			fReturn;

#if CYGDEBUG
  ErrorF ("winCloseScreenShadowDDNL - Freeing screen resources\n");
#endif

  /* Flag that the screen is closed */
  pScreenPriv->fClosed = TRUE;
  pScreenPriv->fActive = FALSE;

  /* Call the wrapped CloseScreen procedure */
  pScreen->CloseScreen = pScreenPriv->CloseScreen;
  fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);

  /* Free the screen DC */
  ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);

  /* Delete the window property */
  RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);

  /* Free the shadow surface, if there is one */
  if (pScreenPriv->pddsShadow4)
    {
      IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
      free (pScreenInfo->pfb);
      pScreenInfo->pfb = NULL;
      pScreenPriv->pddsShadow4 = NULL;
    }

  /* Detach the clipper from the primary surface and release the clipper. */
  if (pScreenPriv->pddcPrimary)
    {
      /* Detach the clipper */
      IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4,
				      NULL);

      /* Release the clipper object */
      IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
      pScreenPriv->pddcPrimary = NULL;
    }

  /* Release the primary surface, if there is one */
  if (pScreenPriv->pddsPrimary4)
    {
      IDirectDrawSurface4_Release (pScreenPriv->pddsPrimary4);
      pScreenPriv->pddsPrimary4 = NULL;
    }

  /* Free the DirectDraw4 object, if there is one */
  if (pScreenPriv->pdd4)
    {
      IDirectDraw4_RestoreDisplayMode (pScreenPriv->pdd4);
      IDirectDraw4_Release (pScreenPriv->pdd4);
      pScreenPriv->pdd4 = NULL;
    }

  /* Free the DirectDraw object, if there is one */
  if (pScreenPriv->pdd)
    {
      IDirectDraw_Release (pScreenPriv->pdd);
      pScreenPriv->pdd = NULL;
    }

  /* Kill our window */
  if (pScreenPriv->hwndScreen)
    {
      DestroyWindow (pScreenPriv->hwndScreen);
      pScreenPriv->hwndScreen = NULL;
    }

  /* Destroy the thread startup mutex */
  pthread_mutex_destroy (&pScreenPriv->pmServerStarted);

  /* Kill our screeninfo's pointer to the screen */
  pScreenInfo->pScreen = NULL;

  /* Invalidate the ScreenInfo's fb pointer */
  pScreenInfo->pfb = NULL;

  /* Free the screen privates for this screen */
  free ((pointer) pScreenPriv);

  return fReturn;
}
示例#12
0
文件: surface.c 项目: YokoZar/wine
static void GetDCTest_main(DDSURFACEDESC *ddsd, DDSURFACEDESC2 *ddsd2, void (*testfunc)(IDirectDrawSurface *surf, int ddsdver))
{
    IDirectDrawSurface *surf;
    IDirectDrawSurface2 *surf2;
    IDirectDrawSurface2 *surf3;
    IDirectDrawSurface4 *surf4;
    HRESULT hr;
    IDirectDraw  *dd1 = createDD();
    IDirectDraw2 *dd2;
    IDirectDraw3 *dd3;
    IDirectDraw4 *dd4;

    hr = IDirectDraw_CreateSurface(dd1, ddsd, &surf, NULL);
    if (hr == DDERR_UNSUPPORTEDMODE) {
        win_skip("Unsupported mode\n");
        return;
    }
    ok(hr == DD_OK, "IDirectDraw_CreateSurface failed: 0x%08x\n", hr);
    testfunc(surf, 1);
    IDirectDrawSurface_Release(surf);

    hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw2, (void **) &dd2);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);

    hr = IDirectDraw2_CreateSurface(dd2, ddsd, &surf, NULL);
    ok(hr == DD_OK, "IDirectDraw2_CreateSurface failed: 0x%08x\n", hr);
    testfunc(surf, 1);

    hr = IDirectDrawSurface_QueryInterface(surf, &IID_IDirectDrawSurface2, (void **) &surf2);
    ok(hr == DD_OK, "IDirectDrawSurface_QueryInterface failed: 0x%08x\n", hr);
    testfunc((IDirectDrawSurface *) surf2, 1);

    IDirectDrawSurface2_Release(surf2);
    IDirectDrawSurface_Release(surf);
    IDirectDraw2_Release(dd2);

    hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw3, (void **) &dd3);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);

    hr = IDirectDraw3_CreateSurface(dd3, ddsd, &surf, NULL);
    ok(hr == DD_OK, "IDirectDraw3_CreateSurface failed: 0x%08x\n", hr);
    testfunc(surf, 1);

    hr = IDirectDrawSurface_QueryInterface(surf, &IID_IDirectDrawSurface3, (void **) &surf3);
    ok(hr == DD_OK, "IDirectDrawSurface_QueryInterface failed: 0x%08x\n", hr);
    testfunc((IDirectDrawSurface *) surf3, 1);

    IDirectDrawSurface3_Release(surf3);
    IDirectDrawSurface_Release(surf);
    IDirectDraw3_Release(dd3);

    hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw4, (void **) &dd4);
    ok(hr == DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);

    surf = NULL;
    hr = IDirectDraw4_CreateSurface(dd4, ddsd2, &surf4, NULL);
    ok(hr == DD_OK, "IDirectDraw4_CreateSurface failed: 0x%08x\n", hr);
    testfunc((IDirectDrawSurface *) surf4, 2);

    IDirectDrawSurface4_Release(surf4);
    IDirectDraw4_Release(dd4);

    IDirectDraw_Release(dd1);
}
示例#13
0
文件: surface.c 项目: YokoZar/wine
static void test_surface_from_dc4(void)
{
    IDirectDrawSurface4 *surf4;
    IDirectDrawSurface *surf1;
    DDSURFACEDESC2 ddsd2;
    IUnknown *tmp, *tmp2;
    IDirectDraw4 *dd4;
    IDirectDraw *dd1;
    DWORD priv, size;
    HRESULT hr;
    HDC dc;

    dd1 = createDD();
    hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw4, (void **)&dd4);
    if (hr == E_NOINTERFACE) {
        win_skip("DirectDraw4 is not supported\n");
        IDirectDraw_Release(dd1);
        return;
    }
    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed, hr %#x.\n", hr);
    IDirectDraw_Release(dd1);

    memset(&ddsd2, 0, sizeof(ddsd2));
    ddsd2.dwSize = sizeof(ddsd2);
    ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
    ddsd2.dwWidth = 64;
    ddsd2.dwHeight = 64;
    ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;

    hr = IDirectDraw4_CreateSurface(dd4, &ddsd2, &surf4, NULL);
    if (hr == DDERR_UNSUPPORTEDMODE) {
        win_skip("Unsupported mode\n");
        IDirectDraw3_Release(dd4);
        return;
    }
    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#x.\n", hr);

    hr = IDirectDrawSurface4_QueryInterface(surf4, &IID_IDirectDrawSurface, (void **)&surf1);
    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);

    priv = 0xdeadbeef;
    size = sizeof(priv);
    hr = IDirectDrawSurface4_SetPrivateData(surf4, &guid, &priv, size, 0);
    ok(SUCCEEDED(hr), "SetPrivateData failed, hr %#x.\n", hr);

    priv = 0;
    hr = IDirectDrawSurface4_GetPrivateData(surf4, &guid, &priv, &size);
    ok(SUCCEEDED(hr), "GetPrivateData failed, hr %#x.\n", hr);
    ok(priv == 0xdeadbeef, "Expected private data 0xdeadbeef, got %#x.\n", priv);

    hr = IDirectDrawSurface4_GetDC(surf4, &dc);
    ok(SUCCEEDED(hr), "GetDC failed, hr %#x.\n", hr);

    hr = IDirectDraw4_GetSurfaceFromDC(dd4, dc, NULL);
    ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %#x.\n", hr);

    hr = IDirectDraw4_GetSurfaceFromDC(dd4, dc, (IDirectDrawSurface4 **)&tmp);
    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#x.\n", hr);
    ok((IDirectDrawSurface4 *)tmp != surf4, "Expected surface != %p.\n", surf4);

    hr = IUnknown_QueryInterface(tmp, &IID_IDirectDrawSurface, (void **)&tmp2);
    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
    ok(tmp2 == tmp, "Expected %p, got %p.\n", tmp, tmp2);
    ok((IDirectDrawSurface *)tmp2 != surf1, "Expected surface != %p.\n", surf1);
    IUnknown_Release(tmp2);

    hr = IUnknown_QueryInterface(tmp, &IID_IDirectDrawSurface4, (void **)&tmp2);
    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
    ok((IDirectDrawSurface4 *)tmp2 != surf4, "Expected surface != %p.\n", surf4);

    priv = 0;
    hr = IDirectDrawSurface4_GetPrivateData((IDirectDrawSurface4 *)tmp2, &guid, &priv, &size);
    ok(SUCCEEDED(hr), "GetPrivateData failed, hr %#x.\n", hr);
    ok(priv == 0xdeadbeef, "Expected private data 0xdeadbeef, got %#x.\n", priv);
    IUnknown_Release(tmp2);

    IUnknown_Release(tmp);

    hr = IDirectDrawSurface4_ReleaseDC(surf4, dc);
    ok(SUCCEEDED(hr), "ReleaseDC failed, hr %#x.\n", hr);

    dc = CreateCompatibleDC(NULL);
    ok(!!dc, "CreateCompatibleDC failed.\n");

    tmp = (IUnknown *)0xdeadbeef;
    hr = IDirectDraw4_GetSurfaceFromDC(dd4, dc, (IDirectDrawSurface4 **)&tmp);
    ok(hr == DDERR_NOTFOUND, "Expected DDERR_NOTFOUND, got %#x.\n", hr);
    ok(!tmp, "Expected surface NULL, got %p.\n", tmp);

    ok(DeleteDC(dc), "DeleteDC failed.\n");

    tmp = (IUnknown *)0xdeadbeef;
    hr = IDirectDraw4_GetSurfaceFromDC(dd4, NULL, (IDirectDrawSurface4 **)&tmp);
    ok(hr == DDERR_NOTFOUND, "Expected DDERR_NOTFOUND, got %#x.\n", hr);
    ok(!tmp, "Expected surface NULL, got %p.\n", tmp);

    IDirectDrawSurface_Release(surf1);
    IDirectDrawSurface4_Release(surf4);
    IDirectDraw4_Release(dd4);
}