EXPORT void CALL angrylionRomClosed (void)
{
    rdp_close();
#ifdef HAVE_DIRECTDRAW
    if (lpddsback)
    {
        IDirectDrawSurface_Release(lpddsback);
        lpddsback = 0;
    }
    if (lpddsprimary)
    {
        IDirectDrawSurface_Release(lpddsprimary);
        lpddsprimary = 0;
    }
    if (lpdd)
    {
        IDirectDraw_Release(lpdd);
        lpdd = 0;
    }
#else
    if (blitter_buf)
       free(blitter_buf);
#endif

    SaveLoaded = 1;
    command_counter = 0;
}
Exemple #2
0
//
// Release DirectDraw stuff before display mode change
//
VOID ReleaseChtuff (VOID)
{
	if (!DDr2)
		return;
	if (windclip)
	{
		IDirectDrawClipper_Release(windclip);
		windclip = NULL;
	}
	if (DDPalette)
	{
		IDirectDrawPalette_Release(DDPalette);
		DDPalette = NULL;
	}
	// If the app is fullscreen, the back buffer is attached to the
	// primary. Releasing the primary buffer will also release any
	// attached buffers, so explicitly releasing the back buffer is not
	// necessary.

	if (!bAppFullScreen && ScreenVirtual)
	{
		IDirectDrawSurface_Release(ScreenVirtual);   // release hidden surface
		ScreenVirtual = NULL;
	}
	if (ScreenReal)
	{
		IDirectDrawSurface_Release(ScreenReal);                      // and attached backbuffers for bAppFullScreen mode
		ScreenReal = NULL;
	}
}
Exemple #3
0
void DDKillScreen()
{
	if (_lpDDClipper) IDirectDrawClipper_Release(_lpDDClipper);
	if (_lpDDPalette) IDirectDrawPalette_Release(_lpDDPalette);
	if (_lpDDSBack) IDirectDrawSurface_Release(_lpDDSBack);
	if (_lpDDSPrimary) {

		if (!GRMODEINFO(modex)) {
			DDBLTFX ddbltfx;
			HRESULT ddresult;

			memset(&ddbltfx, 0, sizeof(DDBLTFX));
	   	ddbltfx.dwSize = sizeof( ddbltfx );
		   ddbltfx.dwFillColor = (WORD)(BM_XRGB(0,0,0));

	   	ddresult = IDirectDrawSurface_Blt(
                            _lpDDSPrimary,  			// dest surface
                            NULL,                 	// dest rect
                            NULL,                  // src surface
                            NULL,                  // src rect
                            DDBLT_COLORFILL | DDBLT_WAIT,
                            &ddbltfx);
		}

		IDirectDrawSurface_Release(_lpDDSPrimary);
	}

	_lpDDClipper = NULL;
	_lpDDPalette = NULL;
	_lpDDSBack = NULL;
	_lpDDSPrimary = NULL;
}	
Exemple #4
0
Fichier : init.c Projet : btb/d2x
static void finiObjects()
{
	if(lpDD!=NULL)
	{
		if(lpDDSPrimary!=NULL)
		{           
			IDirectDrawSurface_Release(lpDDSPrimary);
			lpDDSPrimary=NULL;
		}
		if(lpDDSOne!=NULL)
		{
			IDirectDrawSurface_Unlock(lpDDSOne,NULL);
			IDirectDrawSurface_Release(lpDDSOne);
			lpDDSOne=NULL;
		}
		if(lpDDPal!=NULL)
		{
			IDirectDrawSurface_Release(lpDDPal);
			lpDDPal=NULL;
		}
		IDirectDrawSurface_Release(lpDD);
		lpDD=NULL;
	}
   if(mouse_hidden)
    ShowCursor(TRUE);
} 
Exemple #5
0
/* uninitialize DirectX */
static void DeInitDD(void)
{
    if (captured)
	ReleaseCapture(), captured = 0;	// free mouse

    // free DirectX objects
    if (lpSurfaces[0])
	IDirectDrawSurface_Release(lpSurfaces[0]);
    lpSurfaces[0] = NULL;
    if (BackSurface[0])
	IDirectDrawSurface_Release(BackSurface[0]);
    BackSurface[0] = NULL;
    if (BackSurface[1])
	IDirectDrawSurface_Release(BackSurface[1]);
    BackSurface[1] = NULL;
    if (dxPalette)
	IDirectDrawPalette_Release(dxPalette);
    dxPalette = NULL;
    if (lpDD2)
	IDirectDraw2_Release(lpDD2);
    lpDD2 = NULL;
    if (lpDD)
	IDirectDraw_Release(lpDD);
    lpDD = NULL;
    DeInitWindow();
    if (hModule != NULL)
	FreeLibrary(hModule), hModule = NULL;
    hWnd = NULL;
    directX = 0;
}
Exemple #6
0
static int vo_dx_uninit(void)
{
    if (NULL != g_lpddclipper) {
        g_lpddclipper->lpVtbl->Release(g_lpddclipper);
    }
    g_lpddclipper = NULL;
    av_log(NULL, AV_LOG_INFO, "vo_directx: clipper released\n");

    if (NULL != g_lpddsBack) {
        IDirectDrawSurface_Release(g_lpddsBack);
    }
    g_lpddsBack = NULL;
    av_log(NULL, AV_LOG_INFO, "vo_directx: back surface released\n");

    if (g_lpddsOverlay != NULL) {
        IDirectDrawSurface_Release(g_lpddsOverlay);
    }
    g_lpddsOverlay = NULL;
    av_log(NULL, AV_LOG_INFO, "vo_directx: overlay surface released\n");

    if (g_lpddsPrimary != NULL) {
        IDirectDrawSurface_Release(g_lpddsPrimary);
    }
    g_lpddsPrimary = NULL;
    av_log(NULL, AV_LOG_INFO, "vo_directx: primary released\n");

    if (g_fs_hwnd) {
        DestroyWindow(g_fs_hwnd);
    }
    g_fs_hwnd = NULL;

    if (g_hwnd) {
        DestroyWindow(g_hwnd);
    }
    g_hwnd = NULL;
    av_log(NULL, AV_LOG_INFO, "vo_directx: window destroyed\n");

    UnregisterClass(WND_CLASSNAME, GetModuleHandle(NULL));
    UnregisterClass(FS_CLASSNAME, GetModuleHandle(NULL));

    if (g_lpdd != NULL) {
        IDirectDraw_Release(g_lpdd);
        g_lpdd = NULL;
    }

    if (hddraw_dll) {
        FreeLibrary(hddraw_dll);
        hddraw_dll = NULL;
    }

    return 0;
}
Exemple #7
0
static void dx_free_buffers(char *b1, char *b2)
{
    IDirectDrawSurface_Unlock(BackSurface[0], surface[0].lpSurface);
    IDirectDrawSurface_Unlock(BackSurface[1], surface[1].lpSurface);
    if (BackSurface[0])
	IDirectDrawSurface_Release(BackSurface[0]);
    if (BackSurface[1])
	IDirectDrawSurface_Release(BackSurface[1]);
    BackSurface[0] = NULL;
    BackSurface[1] = NULL;
    initialized = 0;
    buffer1 = buffer2 = NULL;
}
Exemple #8
0
HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw, IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface)
{
    DDSURFACEDESC surface_desc;
    IDirectDrawSurface *primary_surface, *render_target;
    HWND window;
    HRESULT hr;

    hr = IDirectDrawClipper_GetHWnd(clipper, &window);
    if (FAILED(hr))
        return hr;

    hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
    if (FAILED(hr))
        return hr;

    memset(&surface_desc, 0, sizeof(surface_desc));
    surface_desc.dwSize = sizeof(surface_desc);
    surface_desc.dwFlags = DDSD_CAPS;
    surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
    hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary_surface, NULL);
    if (FAILED(hr))
        return hr;
    hr = IDirectDrawSurface_SetClipper(primary_surface, clipper);
    if (FAILED(hr))
    {
        IDirectDrawSurface_Release(primary_surface);
        return hr;
    }

    memset(&surface_desc, 0, sizeof(surface_desc));
    surface_desc.dwSize = sizeof(surface_desc);
    surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
    surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
    surface_desc.dwWidth = width;
    surface_desc.dwHeight = height;

    hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &render_target, NULL);
    if (FAILED(hr))
    {
        IDirectDrawSurface_Release(primary_surface);
        return hr;
    }

    object->primary_surface = primary_surface;
    object->clipper = clipper;
    IDirectDrawClipper_AddRef(clipper);
    *surface = render_target;

    return D3DRM_OK;
}
Exemple #9
0
static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3D *d3d, IDirect3DDevice *d3d_device)
{
    IDirectDraw *ddraw;
    IDirectDrawSurface *surface;
    IDirect3DDevice2 *d3d_device2 = NULL;
    DDSURFACEDESC desc;
    HRESULT hr;

    /* AddRef these interfaces beforehand for the intentional leak on reinitialization. */
    if (FAILED(hr = IDirect3D_QueryInterface(d3d, &IID_IDirectDraw, (void **)&ddraw)))
        return hr;
    IDirect3DRM_AddRef(device->d3drm);
    IDirect3DDevice_AddRef(d3d_device);

    /* Fetch render target and get width/height from there */
    if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirectDrawSurface, (void **)&surface)))
    {
        if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirect3DDevice2, (void **)&d3d_device2)))
            return hr;
        hr = IDirect3DDevice2_GetRenderTarget(d3d_device2, &surface);
        IDirect3DDevice2_Release(d3d_device2);
        if (FAILED(hr))
            return hr;
    }

    if (device->ddraw)
    {
        if (d3d_device2)
            IDirectDrawSurface_Release(surface);
        return D3DRMERR_BADOBJECT;
    }

    desc.dwSize = sizeof(desc);
    hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
    if (FAILED(hr))
    {
        IDirectDrawSurface_Release(surface);
        return hr;
    }

    device->ddraw = ddraw;
    device->width = desc.dwWidth;
    device->height = desc.dwHeight;
    device->device = d3d_device;
    device->render_target = surface;

    return hr;
}
Exemple #10
0
static void destroysurface(void)
{
    if( lpDDSPrimary != NULL )
    {
        IDirectDrawSurface_Release(lpDDSPrimary);
        lpDDSPrimary = NULL;
    }
}
Exemple #11
0
static void Destroy( win32_driver_t * win32_driver )
{
  if( win32_driver->ddclipper )
    IDirectDrawClipper_Release( win32_driver->ddclipper );

  if( win32_driver->primary )
    IDirectDrawSurface_Release( win32_driver->primary );

  if( win32_driver->secondary )
    IDirectDrawSurface_Release( win32_driver->secondary );

  if( win32_driver->ddobj )
    IDirectDraw_Release( win32_driver->ddobj );

  _x_alphablend_free(&win32_driver->alphablend_extra_data);

  free( win32_driver );
}
Exemple #12
0
static void WINAPI VGA_DoExit(ULONG_PTR arg)
{
    VGA_DeinstallTimer();
    IDirectDrawSurface_SetPalette(lpddsurf,NULL);
    IDirectDrawSurface_Release(lpddsurf);
    lpddsurf=NULL;
    IDirectDrawPalette_Release(lpddpal);
    lpddpal=NULL;
    IDirectDraw_Release(lpddraw);
    lpddraw=NULL;
}
Exemple #13
0
//	DDFreeSurface
//	----------------------------------------------------------------------------
void DDFreeSurface(LPDIRECTDRAWSURFACE lpdds)
{
	HRESULT ddresult;

	Assert(lpdds != NULL);

	ddresult = IDirectDrawSurface_Release(lpdds);
	if (ddresult != DD_OK) {
		logentry("DDRAW::FreeSurface err: %x\n", ddresult);		
		Error("DDFreeSurface: Unable to free surface.");
	}
}
EXPORT void CALL RomClosed (void)
{
	rdp_close();
	if (lpddsback)
	{
		IDirectDrawSurface_Release(lpddsback);
		lpddsback = 0;
	}
	if (lpddsprimary)
	{
		IDirectDrawSurface_Release(lpddsprimary);
		lpddsprimary = 0;
	}
	if (lpdd)
	{
		IDirectDraw_Release(lpdd);
		lpdd = 0;
	}

	SaveLoaded = 1;
	command_counter = 0;
}
Exemple #15
0
void d3drm_device_destroy(struct d3drm_device *device)
{
    d3drm_object_cleanup((IDirect3DRMObject *)&device->IDirect3DRMDevice_iface, &device->obj);
    if (device->device)
    {
        TRACE("Releasing attached ddraw interfaces.\n");
        IDirect3DDevice_Release(device->device);
    }
    if (device->render_target)
        IDirectDrawSurface_Release(device->render_target);
    if (device->primary_surface)
    {
        TRACE("Releasing primary surface and attached clipper.\n");
        IDirectDrawSurface_Release(device->primary_surface);
        IDirectDrawClipper_Release(device->clipper);
    }
    if (device->ddraw)
    {
        IDirectDraw_Release(device->ddraw);
        IDirect3DRM_Release(device->d3drm);
    }
    HeapFree(GetProcessHeap(), 0, device);
}
Exemple #16
0
Fichier : ddgfx.c Projet : btb/d2x
int dd_gfx_destroybitmap2D(unsigned short handle)
{
	if (!dd_gfx_initialized) return 0;

	if (handle == 0) return 1;
	handle--;									// Convert to valid handle

	if (gfxBitmap[handle].lpdds) {
		IDirectDrawSurface_Release(gfxBitmap[handle].lpdds);
		gfxBitmap[handle].lpdds = NULL;
		return 0;
	}
	else return 1;
}		
void
DDReleaseSurface ( LPDIRECTDRAWSURFACE *ppOldSurface1, LPDIRECTDRAWSURFACE2 *ppOldSurface2 )
{
	Assert ( ppOldSurface1 != NULL );
	Assert ( ppOldSurface2 != NULL );
	Assert ( *ppOldSurface1 != NULL );
	Assert ( *ppOldSurface2 != NULL );

	ATTEMPT ( IDirectDrawSurface2_Release ( *ppOldSurface2 ) );
	ATTEMPT ( IDirectDrawSurface_Release ( *ppOldSurface1 ) );

	*ppOldSurface1 = NULL;
	*ppOldSurface2 = NULL;
}
Exemple #18
0
static void
DDDestroySurface(directx_priv *priv)
{
	int i;
	if (priv->lpddp != NULL) {
		IDirectDrawPalette_Release(priv->lpddp);
		priv->lpddp = NULL;
	}
	for (i = 0; i < GGI_DISPLAY_DIRECTX_FRAMES; ++i) {
		if (priv->lpbdds[i] != NULL) {
			IDirectDrawSurface_Release(priv->lpbdds[i]);
			priv->lpbdds[i] = NULL;
		}
	}
	if (priv->lppdds != NULL) {
		IDirectDrawSurface_Release(priv->lppdds);
		priv->lppdds = NULL;
	}
	if (priv->fullscreen) {
		IDirectDraw2_RestoreDisplayMode(priv->lpddext);
		IDirectDraw2_SetCooperativeLevel(priv->lpddext, priv->hWnd,
						DDSCL_NORMAL);
	}
}
Exemple #19
0
Err GE2DLibClose()
{
	if (DDPrimary) 
	{ 
		IDirectDrawSurface_Release(DDPrimary); 
		DDPrimary = NULL;
	}
	if (DD)
	{
		IDirectDraw_Release(DD);
		DD = NULL;
	}
	if (Module)
		FreeLibrary(Module);
	return errNone;
}
Exemple #20
0
Fichier : ddgfx.c Projet : btb/d2x
int dd_gfx_close()
{
	int i;

	if (!dd_gfx_initialized) return 1;

	for (i = 0; i < MAX_GFX_BITMAPS; i++)
	{
		if (gfxBitmap[i].lpdds)
			IDirectDrawSurface_Release(gfxBitmap[i].lpdds);
	}
	
	dd_gfx_initialized =0;

	return 0;
}
Exemple #21
0
static ULONG WINAPI IDirectDrawStreamSampleImpl_Release(IDirectDrawStreamSample *iface)
{
    IDirectDrawStreamSampleImpl *This = impl_from_IDirectDrawStreamSample(iface);
    ULONG ref = InterlockedDecrement(&This->ref);

    TRACE("(%p)->(): new ref = %u\n", iface, ref);

    if (!ref)
    {
        if (This->surface)
            IDirectDrawSurface_Release(This->surface);
        IMediaStream_Release(This->parent);
        HeapFree(GetProcessHeap(), 0, This);
    }

    return ref;
}
Exemple #22
0
Err GE2DHideOverlay()
{
	if (Thread)
	{
		ThreadRun = 0;
		if (Thread && WaitForSingleObject(Thread,5000) == WAIT_TIMEOUT)
			TerminateThread(Thread,0);
		Thread = NULL;
	}

	if (DDBuffer)
	{
		IDirectDrawSurface_UpdateOverlay(DDBuffer,&DDSrc,DDPrimary,&DDDst,DDOVER_HIDE,NULL);
		IDirectDrawSurface_Release(DDBuffer); 
		DDBuffer = NULL;
	}

	return 0;
}
Exemple #23
0
static int DxCreatePrimarySurface(void)
{
    DDSURFACEDESC2 ddsd;

    if (g_lpddsPrimary) {
        IDirectDrawSurface_Release(g_lpddsPrimary);
        g_lpddsPrimary = NULL;
    }

    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS;
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

    if (IDirectDraw_CreateSurface(g_lpdd, &ddsd, &g_lpddsPrimary, NULL) == DD_OK) {
        return TRUE;
    }
    return FALSE;
}
/**
 * Create and initialize display according to preferences specified in the vout
 * thread fields.
 */
static int DirectXOpenDisplay(vout_display_t *vd)
{
    vout_display_sys_t *sys = vd->sys;
    HRESULT hr;

    /* Now get the primary surface. This surface is what you actually see
     * on your screen */
    DDSURFACEDESC ddsd;
    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS;
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

    LPDIRECTDRAWSURFACE display;
    hr = IDirectDraw2_CreateSurface(sys->ddobject, &ddsd, &display, NULL);
    if (hr != DD_OK) {
        msg_Err(vd, "cannot get primary surface (error %li)", hr);
        return VLC_EGENERIC;
    }

    void *ptr;
    hr = IDirectDrawSurface_QueryInterface(display, &IID_IDirectDrawSurface2,
                                           &ptr);
    /* Release the old interface */
    IDirectDrawSurface_Release(display);

    if (hr != DD_OK) {
        msg_Err(vd, "cannot query IDirectDrawSurface2 interface (error %li)", hr);
        sys->display = NULL;
        return VLC_EGENERIC;
    }
    sys->display = ptr;

    /* The clipper will be used only in non-overlay mode */
    DirectXCreateClipper(vd);

    /* Make sure the colorkey will be painted */
    sys->i_colorkey = 1;
    sys->i_rgb_colorkey = DirectXFindColorkey(vd, &sys->i_colorkey);

    return VLC_SUCCESS;
}
Exemple #25
0
static int DxCreateOffbuffer(void)
{
    DDSURFACEDESC2 ddsd;

    if (g_lpddsBack) {
        IDirectDrawSurface_Release(g_lpddsBack);
        g_lpddsBack = NULL;
    }

    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
    ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
    ddsd.dwWidth = g_image_width;
    ddsd.dwHeight = g_image_height;

    if (IDirectDraw_CreateSurface(g_lpdd, &ddsd, &g_lpddsBack, 0) != DD_OK) {
        return FALSE;
    }
    return TRUE;
}
Exemple #26
0
static void CapsTest(void)
{
    DDSURFACEDESC ddsd;
    IDirectDraw  *dd1 = createDD();
    IDirectDrawSurface *surf;
    HRESULT hr;

    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
    ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY;
    ddsd.dwWidth = 64;
    ddsd.dwHeight = 64;
    hr = IDirectDraw_CreateSurface(dd1, &ddsd, &surf, NULL);
    if (hr == DDERR_UNSUPPORTEDMODE) {
        win_skip("Unsupported mode\n");
        return;
    }
    ok(hr == DD_OK, "Creating a SYSMEM | VIDMEM surface returned 0x%08x, expected DD_OK\n", hr);
    if(surf) IDirectDrawSurface_Release(surf);

    IDirectDraw_Release(dd1);
}
Exemple #27
0
static void testcooperativelevels_normal(void)
{
    HRESULT rc;
    DDSURFACEDESC surfacedesc;
    IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef;

    memset(&surfacedesc, 0, sizeof(surfacedesc));
    surfacedesc.dwSize = sizeof(surfacedesc);
    surfacedesc.ddpfPixelFormat.dwSize = sizeof(surfacedesc.ddpfPixelFormat);
    surfacedesc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
    surfacedesc.dwBackBufferCount = 1;
    surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;

    /* Do some tests with DDSCL_NORMAL mode */

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_NORMAL);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);

    /* Try creating a double buffered primary in normal mode */
    rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
    ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
    ok(surface == NULL, "Returned surface pointer is %p\n", surface);
    if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);

    /* Set the focus window */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_SETFOCUSWINDOW);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    /* Set the focus window a second time*/
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_SETFOCUSWINDOW);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc);

    /* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    /* This one succeeds */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    /* Set the device window without any other flags. Should give an error */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_SETDEVICEWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);

    /* Set device window with DDSCL_NORMAL */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
 
    /* Also set the focus window. Should give an error */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    /* All done */
}
Exemple #28
0
/**
 * Create an YUV overlay or RGB surface for the video.
 *
 * The best method of display is with an YUV overlay because the YUV->RGB
 * conversion is done in hardware.
 * You can also create a plain RGB surface.
 * (Maybe we could also try an RGB overlay surface, which could have hardware
 * scaling and which would also be faster in window mode because you don't
 * need to do any blitting to the main display...)
 */
static int DirectXCreateSurface(vout_display_t *vd,
                                LPDIRECTDRAWSURFACE2 *surface,
                                const video_format_t *fmt,
                                DWORD fourcc,
                                bool use_overlay,
                                bool use_sysmem,
                                int backbuffer_count)
{
    vout_display_sys_t *sys = vd->sys;

    DDSURFACEDESC ddsd;

    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize   = sizeof(ddsd);
    ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
    ddsd.dwFlags  = DDSD_HEIGHT | DDSD_WIDTH;
    ddsd.dwWidth  = fmt->i_width;
    ddsd.dwHeight = fmt->i_height;
    if (fourcc) {
        ddsd.dwFlags |= DDSD_PIXELFORMAT;
        ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
        ddsd.ddpfPixelFormat.dwFourCC = fourcc;
    }
    if (use_overlay) {
        ddsd.dwFlags |= DDSD_CAPS;
        ddsd.ddsCaps.dwCaps = DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY;
        if (backbuffer_count > 0)
            ddsd.ddsCaps.dwCaps |= DDSCAPS_COMPLEX | DDSCAPS_FLIP;

        if (backbuffer_count > 0) {
            ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
            ddsd.dwBackBufferCount = backbuffer_count;
        }
    } else {
        ddsd.dwFlags |= DDSD_CAPS;
        ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
        if (use_sysmem)
            ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
        else
            ddsd.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
    }

    /* Create the video surface */
    LPDIRECTDRAWSURFACE surface_v1;
    if (IDirectDraw2_CreateSurface(sys->ddobject, &ddsd, &surface_v1, NULL) != DD_OK)
        return VLC_EGENERIC;

    /* Now that the surface is created, try to get a newer DirectX interface */
    HRESULT hr = IDirectDrawSurface_QueryInterface(surface_v1,
                 &IID_IDirectDrawSurface2,
                 (LPVOID *)surface);
    IDirectDrawSurface_Release(surface_v1);
    if (hr != DD_OK) {
        msg_Err(vd, "cannot query IDirectDrawSurface2 interface (error %li)", hr);
        return VLC_EGENERIC;
    }

    if (use_overlay) {
        /* Check the overlay is useable as some graphics cards allow creating
         * several overlays but only one can be used at one time. */
        if (DirectXUpdateOverlay(vd, *surface)) {
            IDirectDrawSurface2_Release(*surface);
            msg_Err(vd, "overlay unuseable (might already be in use)");
            return VLC_EGENERIC;
        }
    }

    return VLC_SUCCESS;
}
static void testcooperativelevels_normal(void)
{
    BOOL sfw;
    HRESULT rc;
    DDSURFACEDESC surfacedesc;
    IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef;

    memset(&surfacedesc, 0, sizeof(surfacedesc));
    surfacedesc.dwSize = sizeof(surfacedesc);
    surfacedesc.ddpfPixelFormat.dwSize = sizeof(surfacedesc.ddpfPixelFormat);
    surfacedesc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
    surfacedesc.dwBackBufferCount = 1;
    surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;

    rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);

    /* Do some tests with DDSCL_NORMAL mode */

    /* Fullscreen mode + normal mode + exclusive mode */

    rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
    ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received: %x\n", rc);

    sfw=FALSE;
    if(hwnd2)
        sfw=SetForegroundWindow(hwnd2);
    else
        skip("Failed to create the second window\n");

    rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);

    if(sfw)
        ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);

    /* Try creating a double buffered primary in fullscreen + exclusive + normal mode */
    rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);

    if (rc == DDERR_UNSUPPORTEDMODE)
        skip("Unsupported mode\n");
    else
    {
        ok(rc == DD_OK, "IDirectDraw_CreateSurface returned %08x\n", rc);
        ok(surface!=NULL, "Returned NULL surface pointer\n");
    }
    if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);

    /* Exclusive mode + normal mode */
    rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE | DDSCL_NORMAL);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);

    /* Fullscreen mode + normal mode */

    sfw=FALSE;
    if(hwnd2) sfw=SetForegroundWindow(hwnd2);

    rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc);

    if(sfw)
        ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);

    rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_NORMAL);
    ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);

    /* Try creating a double buffered primary in fullscreen + normal mode */
    rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
    if (rc == DDERR_UNSUPPORTEDMODE)
        skip("Unsupported mode\n");
    else
    {
        ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
        ok(surface == NULL, "Returned surface pointer is %p\n", surface);
    }

    if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);

    /* switching from Fullscreen mode to Normal mode */

    sfw=FALSE;
    if(hwnd2) sfw=SetForegroundWindow(hwnd2);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_NORMAL);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);

    if(sfw)
        ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);

    rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
    ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);

    /* Try creating a double buffered primary in normal mode */
    rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
    if (rc == DDERR_UNSUPPORTEDMODE)
        skip("Unsupported mode\n");
    else
    {
        ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
        ok(surface == NULL, "Returned surface pointer is %p\n", surface);
    }
    if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);

    /* switching from Normal mode to Fullscreen + Normal mode */

    sfw=FALSE;
    if(hwnd2) sfw=SetForegroundWindow(hwnd2);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_NORMAL | DDSCL_FULLSCREEN);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %x\n",rc);

    if(sfw)
        ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);

    rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL | DDSCL_FULLSCREEN);
    ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);

    /* Set the focus window */

    rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_SETFOCUSWINDOW);

    if (rc == DDERR_INVALIDPARAMS)
    {
        win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n");
        return;
    }

    ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_SETFOCUSWINDOW);

    if (rc == DDERR_INVALIDPARAMS)
    {
        win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n");
        return;
    }

    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    /* Set the focus window a second time*/
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_SETFOCUSWINDOW);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc);

    /* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    /* This one succeeds */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    /* Set the device window without any other flags. Should give an error */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_SETDEVICEWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);

    /* Set device window with DDSCL_NORMAL */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW);
    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);

    /* Also set the focus window. Should give an error */
    rc = IDirectDraw_SetCooperativeLevel(lpDD,
        hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW);
    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);

    /* All done */
}
Exemple #30
0
HRESULT __stdcall ddraw_surface_DeleteAttachedSurface(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSurface)
{
    printf("IDirectDrawSurface::DeleteAttachedSurface(This=%p, dwFlags=%d, lpDDSurface=%p)\n", This, (int)dwFlags, lpDDSurface);
    IDirectDrawSurface_Release(lpDDSurface);
    return DD_OK;
}