]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/direct3d.c
Factorized Direct3DLockSurface/DirectXLock.
[vlc] / modules / video_output / msw / direct3d.c
index e374587a13ab94980b9d997f5d5b9835d53cf463..161693748e347c6cddb1782fd186f365bccb89de 100644 (file)
@@ -73,9 +73,6 @@ vlc_module_begin ()
     add_shortcut("direct3d")
     set_callbacks(OpenVideoVista, Close)
 
-    /* FIXME: Hack to avoid unregistering our window class */
-    cannot_unload_broken_library()
-
     add_submodule()
         set_description(N_("Direct3D video output (XP)"))
         set_capability("vout display", 70)
@@ -84,14 +81,6 @@ vlc_module_begin ()
 
 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.
  *****************************************************************************/
@@ -165,8 +154,9 @@ static int Open(vlc_object_t *object)
     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 */
     vlc_mutex_init(&sys->lock);
@@ -194,7 +184,10 @@ static int Open(vlc_object_t *object)
 
     return VLC_SUCCESS;
 error:
-    Close(VLC_OBJECT(vd));
+    Direct3DClose(vd);
+    CommonClean(vd);
+    Direct3DDestroy(vd);
+    free(vd->sys);
     return VLC_EGENERIC;
 }
 
@@ -768,29 +761,7 @@ static int Direct3DLockSurface(picture_t *picture)
         return VLC_EGENERIC;
     }
 
-    /* fill in buffer info in first plane */
-    picture->p->p_pixels = d3drect.pBits;
-    picture->p->i_pitch  = d3drect.Pitch;
-
-    /*  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) {
-
-        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  = d3drect.Pitch / 2;
-        }
-        /* The d3d 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, d3drect.pBits, d3drect.Pitch);
     return VLC_SUCCESS;
 }
 /**