]> git.sesse.net Git - vlc/commitdiff
* modules/video_output/directx/*: take care of hardware overlay alignment constraints.
authorGildas Bazin <gbazin@videolan.org>
Tue, 9 Mar 2004 14:50:46 +0000 (14:50 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 9 Mar 2004 14:50:46 +0000 (14:50 +0000)
modules/video_output/directx/directx.c
modules/video_output/directx/events.c
modules/video_output/directx/vout.h

index 8794f9e9500ec8734d87e54f94120d7e96512e57..dfde34ad1c6f36244e0554b8baf9890655563dd8 100644 (file)
@@ -2,7 +2,7 @@
  * vout.c: Windows DirectX video output display method
  *****************************************************************************
  * Copyright (C) 2001-2004 VideoLAN
- * $Id: directx.c,v 1.36 2004/02/26 13:58:23 gbazin Exp $
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -172,6 +172,7 @@ static int OpenVideo( vlc_object_t *p_this )
         msg_Err( p_vout, "out of memory" );
         return VLC_ENOMEM;
     }
+    memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
 
     /* Initialisations */
     p_vout->pf_init = Init;
@@ -1597,34 +1598,59 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout )
     }
     else
     {
-        BOOL bHasOverlay, bHasOverlayFourCC, bCanDeinterlace,
-             bHasColorKey, bCanStretch, bCanBltFourcc;
+        vlc_bool_t bHasOverlay, bHasOverlayFourCC, bCanDeinterlace,
+             bHasColorKey, bCanStretch, bCanBltFourcc,
+             bAlignBoundarySrc, bAlignBoundaryDest,
+             bAlignSizeSrc, bAlignSizeDest;
 
         /* Determine if the hardware supports overlay surfaces */
-        bHasOverlay = ((ddcaps.dwCaps & DDCAPS_OVERLAY) ==
-                       DDCAPS_OVERLAY) ? TRUE : FALSE;
+        bHasOverlay = (ddcaps.dwCaps & DDCAPS_OVERLAY) ? 1 : 0;
         /* Determine if the hardware supports overlay surfaces */
-        bHasOverlayFourCC = ((ddcaps.dwCaps & DDCAPS_OVERLAYFOURCC) ==
-                       DDCAPS_OVERLAYFOURCC) ? TRUE : FALSE;
+        bHasOverlayFourCC = (ddcaps.dwCaps & DDCAPS_OVERLAYFOURCC) ? 1 : 0;
         /* Determine if the hardware supports overlay deinterlacing */
-        bCanDeinterlace = ((ddcaps.dwCaps & DDCAPS2_CANFLIPODDEVEN) ==
-                       0 ) ? TRUE : FALSE;
+        bCanDeinterlace = (ddcaps.dwCaps & DDCAPS2_CANFLIPODDEVEN) ? 1 : 0;
         /* Determine if the hardware supports colorkeying */
-        bHasColorKey = ((ddcaps.dwCaps & DDCAPS_COLORKEY) ==
-                        DDCAPS_COLORKEY) ? TRUE : FALSE;
+        bHasColorKey = (ddcaps.dwCaps & DDCAPS_COLORKEY) ? 1 : 0;
         /* Determine if the hardware supports scaling of the overlay surface */
-        bCanStretch = ((ddcaps.dwCaps & DDCAPS_OVERLAYSTRETCH) ==
-                       DDCAPS_OVERLAYSTRETCH) ? TRUE : FALSE;
+        bCanStretch = (ddcaps.dwCaps & DDCAPS_OVERLAYSTRETCH) ? 1 : 0;
         /* Determine if the hardware supports color conversion during a blit */
-        bCanBltFourcc = ((ddcaps.dwCaps & DDCAPS_BLTFOURCC ) ==
-                        DDCAPS_BLTFOURCC) ? TRUE : FALSE;
-
+        bCanBltFourcc = (ddcaps.dwCaps & DDCAPS_BLTFOURCC) ? 1 : 0;
+        /* Determine overlay source boundary alignment */
+        bAlignBoundarySrc = (ddcaps.dwCaps & DDCAPS_ALIGNBOUNDARYSRC) ? 1 : 0;
+        /* Determine overlay destination boundary alignment */
+        bAlignBoundaryDest = (ddcaps.dwCaps & DDCAPS_ALIGNBOUNDARYDEST) ? 1:0;
+        /* Determine overlay destination size alignment */
+        bAlignSizeSrc = (ddcaps.dwCaps & DDCAPS_ALIGNSIZESRC) ? 1 : 0;
+        /* Determine overlay destination size alignment */
+        bAlignSizeDest = (ddcaps.dwCaps & DDCAPS_ALIGNSIZEDEST) ? 1 : 0;
         msg_Dbg( p_vout, "DirectDraw Capabilities: overlay=%i yuvoverlay=%i "
                          "can_deinterlace_overlay=%i colorkey=%i stretch=%i "
                          "bltfourcc=%i",
                          bHasOverlay, bHasOverlayFourCC, bCanDeinterlace,
                          bHasColorKey, bCanStretch, bCanBltFourcc );
 
+        if( bAlignBoundarySrc || bAlignBoundaryDest ||
+            bAlignSizeSrc || bAlignSizeDest )
+        {
+            if( bAlignBoundarySrc ) p_vout->p_sys->i_align_src_boundary =
+                ddcaps.dwAlignBoundarySrc;
+            if( bAlignBoundaryDest ) p_vout->p_sys->i_align_dest_boundary =
+                ddcaps.dwAlignBoundaryDest;
+            if( bAlignSizeDest ) p_vout->p_sys->i_align_src_size =
+                ddcaps.dwAlignSizeSrc;
+            if( bAlignSizeDest ) p_vout->p_sys->i_align_dest_size =
+                ddcaps.dwAlignSizeDest;
+
+            msg_Dbg( p_vout, "align_boundary_src=%i,%i "
+                     "align_boundary_dest=%i,%i "
+                     "align_size_src=%i,%i align_size_dest=%i,%i",
+                     bAlignBoundarySrc, p_vout->p_sys->i_align_src_boundary,
+                     bAlignBoundaryDest, p_vout->p_sys->i_align_dest_boundary,
+                     bAlignSizeSrc, p_vout->p_sys->i_align_src_size,
+                     bAlignSizeDest, p_vout->p_sys->i_align_dest_size );
+        }
+
         /* Don't ask for troubles */
         if( !bCanBltFourcc ) p_vout->p_sys->b_hw_yuv = FALSE;
     }
index aacc932537a7baceec9be27dcf707860a2586946..7d561894238f076471b786809b5dee6132617d2b 100644 (file)
@@ -2,7 +2,7 @@
  * events.c: Windows DirectX video output events handler
  *****************************************************************************
  * Copyright (C) 2001-2004 VideoLAN
- * $Id: events.c,v 1.38 2004/02/26 13:58:23 gbazin Exp $
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -508,6 +508,20 @@ void DirectXUpdateRects( vout_thread_t *p_vout, vlc_bool_t b_force )
     rect_dest.top = point.y + i_y;
     rect_dest.bottom = rect_dest.top + i_height;
 
+    /* Apply overlay hardware constraints */
+    if( p_vout->p_sys->b_using_overlay )
+    {
+        if( p_vout->p_sys->i_align_dest_boundary )
+            rect_dest.left = ( rect_dest.left +
+                p_vout->p_sys->i_align_dest_boundary / 2 ) & 
+                ~p_vout->p_sys->i_align_dest_boundary;
+
+        if( p_vout->p_sys->i_align_dest_size )
+            rect_dest.right = (( rect_dest.right - rect_dest.left +
+                p_vout->p_sys->i_align_dest_size / 2 ) & 
+                ~p_vout->p_sys->i_align_dest_size) + rect_dest.left;
+    }
+
     /* UpdateOverlay directdraw function doesn't automatically clip to the
      * display size so we need to do it otherwise it will fail */
 
@@ -552,12 +566,20 @@ void DirectXUpdateRects( vout_thread_t *p_vout, vlc_bool_t b_force )
       (rect_dest.bottom - rect_dest_clipped.bottom) * p_vout->render.i_height /
       (rect_dest.bottom - rect_dest.top);
 
-    /* The destination coordinates need to be relative to the current
-     * directdraw primary surface (display) */
-    rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
-    rect_dest_clipped.right -= p_vout->p_sys->rect_display.left;
-    rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
-    rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
+    /* Apply overlay hardware constraints */
+    if( p_vout->p_sys->b_using_overlay )
+    {
+        if( p_vout->p_sys->i_align_src_boundary )
+            rect_src_clipped.left = ( rect_src_clipped.left +
+                p_vout->p_sys->i_align_src_boundary / 2 ) & 
+                ~p_vout->p_sys->i_align_src_boundary;
+
+        if( p_vout->p_sys->i_align_src_size )
+            rect_src_clipped.right = (( rect_src_clipped.right -
+                rect_src_clipped.left +
+                p_vout->p_sys->i_align_src_size / 2 ) & 
+                ~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left;
+    }
 
 #if 0
     msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
@@ -566,6 +588,13 @@ void DirectXUpdateRects( vout_thread_t *p_vout, vlc_bool_t b_force )
                      rect_src_clipped.right, rect_src_clipped.bottom );
 #endif
 
+    /* The destination coordinates need to be relative to the current
+     * directdraw primary surface (display) */
+    rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
+    rect_dest_clipped.right -= p_vout->p_sys->rect_display.left;
+    rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
+    rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
+
     /* Signal the change in size/position */
     p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
 
index 5bb38f82ea81d13c9d4a5391383ec1588a541fcd..b5833ff861263d00d382275f23cd998a6197ac83 100644 (file)
@@ -2,7 +2,7 @@
  * vout.h: Windows DirectX video output header file
  *****************************************************************************
  * Copyright (C) 2001-2004 VideoLAN
- * $Id: vout.h,v 1.12 2004/01/02 22:17:57 gbazin Exp $
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -78,6 +78,12 @@ struct vout_sys_t
     RECT         rect_dest;
     RECT         rect_dest_clipped;
 
+    /* Overlay alignment restrictions */
+    int          i_align_src_boundary;
+    int          i_align_src_size;
+    int          i_align_dest_boundary;
+    int          i_align_dest_size;
+
     /* DDraw capabilities */
     int          b_caps_overlay_clipping;