set_capability("vout display", 100)
add_shortcut("directx")
set_callbacks(Open, Close)
-
- /* FIXME: Hack to avoid unregistering our window class */
- cannot_unload_broken_library()
vlc_module_end()
-#if 0 /* FIXME */
- /* check if we registered a window class because we need to
- * unregister it */
- WNDCLASS wndclass;
- if (GetClassInfo(GetModuleHandle(NULL), "VLC DirectX", &wndclass))
- UnregisterClass("VLC DirectX", GetModuleHandle(NULL));
-#endif
-
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
struct picture_sys_t {
LPDIRECTDRAWSURFACE2 surface;
LPDIRECTDRAWSURFACE2 front_surface;
+ picture_t *fallback;
};
/*****************************************************************************
sys->use_wallpaper = var_CreateGetBool(vd, "video-wallpaper");
/* FIXME */
sys->use_overlay = false;//var_CreateGetBool(vd, "overlay"); /* FIXME */
+ sys->restore_overlay = false;
var_Create(vd, "directx-device", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
/* Initialisation */
vout_display_info_t info = vd->info;
info.is_slow = true;
info.has_double_click = true;
- info.has_hide_mouse = true;
+ info.has_hide_mouse = false;
info.has_pictures_invalid = true;
+ info.has_event_thread = true;
/* Interaction TODO support starting with wallpaper mode */
vlc_mutex_init(&sys->lock);
return VLC_SUCCESS;
error:
- Close(VLC_OBJECT(vd));
+ DirectXClose(vd);
+ CommonClean(vd);
+ if (sys->hddraw_dll)
+ FreeLibrary(sys->hddraw_dll);
+ free(sys);
return VLC_EGENERIC;
}
DirectXUpdateOverlay(vd, NULL);
}
}
+ if (sys->restore_overlay)
+ DirectXUpdateOverlay(vd, NULL);
/* */
DirectXUnlock(picture);
if (ch_wallpaper)
WallpaperChange(vd, wallpaper_requested);
+
+ /* */
+ if (sys->restore_overlay)
+ DirectXUpdateOverlay(vd, NULL);
}
/* */
picture_resource_t *rsc = &sys->resource;
rsc->p_sys->front_surface = front_surface;
rsc->p_sys->surface = surface;
+ rsc->p_sys->fallback = NULL;
return VLC_SUCCESS;
}
static int DirectXCreatePictureResourceYuv(vout_display_t *vd,
picture_resource_t *rsc = &sys->resource;
rsc->p_sys->front_surface = surface;
rsc->p_sys->surface = surface;
+ rsc->p_sys->fallback = NULL;
return VLC_SUCCESS;
}
static int DirectXCreatePictureResourceRgb(vout_display_t *vd,
picture_resource_t *rsc = &sys->resource;
rsc->p_sys->front_surface = surface;
rsc->p_sys->surface = surface;
+ rsc->p_sys->fallback = NULL;
return VLC_SUCCESS;
}
{
vout_display_sys_t *sys = vd->sys;
+ if (sys->resource.p_sys->front_surface != sys->resource.p_sys->surface)
+ DirectXDestroySurface(sys->resource.p_sys->surface);
DirectXDestroySurface(sys->resource.p_sys->front_surface);
+ if (sys->resource.p_sys->fallback)
+ picture_Release(sys->resource.p_sys->fallback);
}
static int DirectXLock(picture_t *picture)
DDSURFACEDESC ddsd;
if (DirectXLockSurface(picture->p_sys->front_surface,
picture->p_sys->surface, &ddsd))
- return VLC_EGENERIC;
-
- /* fill in buffer info in first plane */
- picture->p->p_pixels = ddsd.lpSurface;
- picture->p->i_pitch = ddsd.lPitch;
- picture->p->i_lines = picture->format.i_height;
-
- /* Fill chroma planes for planar YUV */
- if (picture->format.i_chroma == VLC_CODEC_I420 ||
- picture->format.i_chroma == VLC_CODEC_J420 ||
- picture->format.i_chroma == VLC_CODEC_YV12) {
+ return CommonUpdatePicture(picture, &picture->p_sys->fallback, NULL, 0);
- for (int n = 1; n < picture->i_planes; n++) {
- const plane_t *o = &picture->p[n-1];
- plane_t *p = &picture->p[n];
-
- p->p_pixels = o->p_pixels + o->i_lines * o->i_pitch;
- p->i_pitch = ddsd.lPitch / 2;
- p->i_lines = picture->format.i_height / 2;
- }
- /* The dx buffer is always allocated as YV12 */
- if (vlc_fourcc_AreUVPlanesSwapped(picture->format.i_chroma, VLC_CODEC_YV12)) {
- uint8_t *p_tmp = picture->p[1].p_pixels;
- picture->p[1].p_pixels = picture->p[2].p_pixels;
- picture->p[2].p_pixels = p_tmp;
- }
- }
+ CommonUpdatePicture(picture, NULL, ddsd.lpSurface, ddsd.lPitch);
return VLC_SUCCESS;
}
static void DirectXUnlock(picture_t *picture)
HRESULT hr = IDirectDrawSurface2_UpdateOverlay(surface,
&src, sys->display, &dst,
DDOVER_SHOW | DDOVER_KEYDESTOVERRIDE, &ddofx);
+ sys->restore_overlay = hr != DD_OK;
+
if (hr != DD_OK) {
msg_Warn(vd, "DirectDrawUpdateOverlay cannot move/resize overlay");
return VLC_EGENERIC;