Commit e04ea111 authored by Gildas Bazin's avatar Gildas Bazin

* modules/video_output/directx/*: take care of hardware overlay alignment constraints.

parent b6769673
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout.c: Windows DirectX video output display method * vout.c: Windows DirectX video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2004 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -172,6 +172,7 @@ static int OpenVideo( vlc_object_t *p_this ) ...@@ -172,6 +172,7 @@ static int OpenVideo( vlc_object_t *p_this )
msg_Err( p_vout, "out of memory" ); msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
/* Initialisations */ /* Initialisations */
p_vout->pf_init = Init; p_vout->pf_init = Init;
...@@ -1597,27 +1598,31 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout ) ...@@ -1597,27 +1598,31 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout )
} }
else else
{ {
BOOL bHasOverlay, bHasOverlayFourCC, bCanDeinterlace, vlc_bool_t bHasOverlay, bHasOverlayFourCC, bCanDeinterlace,
bHasColorKey, bCanStretch, bCanBltFourcc; bHasColorKey, bCanStretch, bCanBltFourcc,
bAlignBoundarySrc, bAlignBoundaryDest,
bAlignSizeSrc, bAlignSizeDest;
/* Determine if the hardware supports overlay surfaces */ /* Determine if the hardware supports overlay surfaces */
bHasOverlay = ((ddcaps.dwCaps & DDCAPS_OVERLAY) == bHasOverlay = (ddcaps.dwCaps & DDCAPS_OVERLAY) ? 1 : 0;
DDCAPS_OVERLAY) ? TRUE : FALSE;
/* Determine if the hardware supports overlay surfaces */ /* Determine if the hardware supports overlay surfaces */
bHasOverlayFourCC = ((ddcaps.dwCaps & DDCAPS_OVERLAYFOURCC) == bHasOverlayFourCC = (ddcaps.dwCaps & DDCAPS_OVERLAYFOURCC) ? 1 : 0;
DDCAPS_OVERLAYFOURCC) ? TRUE : FALSE;
/* Determine if the hardware supports overlay deinterlacing */ /* Determine if the hardware supports overlay deinterlacing */
bCanDeinterlace = ((ddcaps.dwCaps & DDCAPS2_CANFLIPODDEVEN) == bCanDeinterlace = (ddcaps.dwCaps & DDCAPS2_CANFLIPODDEVEN) ? 1 : 0;
0 ) ? TRUE : FALSE;
/* Determine if the hardware supports colorkeying */ /* Determine if the hardware supports colorkeying */
bHasColorKey = ((ddcaps.dwCaps & DDCAPS_COLORKEY) == bHasColorKey = (ddcaps.dwCaps & DDCAPS_COLORKEY) ? 1 : 0;
DDCAPS_COLORKEY) ? TRUE : FALSE;
/* Determine if the hardware supports scaling of the overlay surface */ /* Determine if the hardware supports scaling of the overlay surface */
bCanStretch = ((ddcaps.dwCaps & DDCAPS_OVERLAYSTRETCH) == bCanStretch = (ddcaps.dwCaps & DDCAPS_OVERLAYSTRETCH) ? 1 : 0;
DDCAPS_OVERLAYSTRETCH) ? TRUE : FALSE;
/* Determine if the hardware supports color conversion during a blit */ /* Determine if the hardware supports color conversion during a blit */
bCanBltFourcc = ((ddcaps.dwCaps & DDCAPS_BLTFOURCC ) == bCanBltFourcc = (ddcaps.dwCaps & DDCAPS_BLTFOURCC) ? 1 : 0;
DDCAPS_BLTFOURCC) ? TRUE : FALSE; /* 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 " msg_Dbg( p_vout, "DirectDraw Capabilities: overlay=%i yuvoverlay=%i "
"can_deinterlace_overlay=%i colorkey=%i stretch=%i " "can_deinterlace_overlay=%i colorkey=%i stretch=%i "
...@@ -1625,6 +1630,27 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout ) ...@@ -1625,6 +1630,27 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout )
bHasOverlay, bHasOverlayFourCC, bCanDeinterlace, bHasOverlay, bHasOverlayFourCC, bCanDeinterlace,
bHasColorKey, bCanStretch, bCanBltFourcc ); 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 */ /* Don't ask for troubles */
if( !bCanBltFourcc ) p_vout->p_sys->b_hw_yuv = FALSE; if( !bCanBltFourcc ) p_vout->p_sys->b_hw_yuv = FALSE;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* events.c: Windows DirectX video output events handler * events.c: Windows DirectX video output events handler
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2004 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -508,6 +508,20 @@ void DirectXUpdateRects( vout_thread_t *p_vout, vlc_bool_t b_force ) ...@@ -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.top = point.y + i_y;
rect_dest.bottom = rect_dest.top + i_height; 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 /* UpdateOverlay directdraw function doesn't automatically clip to the
* display size so we need to do it otherwise it will fail */ * 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 ) ...@@ -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_clipped.bottom) * p_vout->render.i_height /
(rect_dest.bottom - rect_dest.top); (rect_dest.bottom - rect_dest.top);
/* The destination coordinates need to be relative to the current /* Apply overlay hardware constraints */
* directdraw primary surface (display) */ if( p_vout->p_sys->b_using_overlay )
rect_dest_clipped.left -= p_vout->p_sys->rect_display.left; {
rect_dest_clipped.right -= p_vout->p_sys->rect_display.left; if( p_vout->p_sys->i_align_src_boundary )
rect_dest_clipped.top -= p_vout->p_sys->rect_display.top; rect_src_clipped.left = ( rect_src_clipped.left +
rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top; 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 #if 0
msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped" msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
...@@ -566,6 +588,13 @@ void DirectXUpdateRects( vout_thread_t *p_vout, vlc_bool_t b_force ) ...@@ -566,6 +588,13 @@ void DirectXUpdateRects( vout_thread_t *p_vout, vlc_bool_t b_force )
rect_src_clipped.right, rect_src_clipped.bottom ); rect_src_clipped.right, rect_src_clipped.bottom );
#endif #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 */ /* Signal the change in size/position */
p_vout->p_sys->i_changes |= DX_POSITION_CHANGE; p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout.h: Windows DirectX video output header file * vout.h: Windows DirectX video output header file
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2004 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -78,6 +78,12 @@ struct vout_sys_t ...@@ -78,6 +78,12 @@ struct vout_sys_t
RECT rect_dest; RECT rect_dest;
RECT rect_dest_clipped; 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 */ /* DDraw capabilities */
int b_caps_overlay_clipping; int b_caps_overlay_clipping;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment