access: screen: move the win32 cursor blending code in the GDI code

This commit is contained in:
Steve Lhomme 2022-03-10 14:11:09 +01:00 committed by François Cartegnie
parent 73895883a7
commit 3fe7d92e6e
3 changed files with 81 additions and 77 deletions

View File

@ -35,6 +35,9 @@
#include <vlc_filter.h>
#include <vlc_url.h>
#include "screen.h"
#ifdef SCREEN_MOUSE
# include <vlc_image.h>
#endif
/*****************************************************************************
* Module descriptor
@ -261,12 +264,6 @@ static void Close( vlc_object_t *p_this )
#ifdef SCREEN_MOUSE
if( p_sys->p_mouse )
picture_Release( p_sys->p_mouse );
if( p_sys->p_blend )
{
filter_Close( p_sys->p_blend );
module_unneed( p_sys->p_blend, p_sys->p_blend->p_module );
vlc_object_delete(p_sys->p_blend);
}
#endif
free( p_sys );
}
@ -356,66 +353,3 @@ void FollowMouse( demux_sys_t *p_sys, int i_x, int i_y )
p_sys->i_screen_height - p_sys->i_height );
}
#endif
#ifdef SCREEN_MOUSE
void RenderCursor( demux_t *p_demux, int i_x, int i_y,
uint8_t *p_dst )
{
demux_sys_t *p_sys = p_demux->p_sys;
if( !p_sys->dst.i_planes )
picture_Setup( &p_sys->dst, &p_sys->fmt.video );
if( !p_sys->dst.i_planes )
return;
#ifdef _WIN32
/* Bitmaps here created by CreateDIBSection: stride rounded up to the nearest DWORD */
p_sys->dst.p[ 0 ].i_pitch = p_sys->dst.p[ 0 ].i_visible_pitch =
( ( ( ( p_sys->fmt.video.i_width * p_sys->fmt.video.i_bits_per_pixel ) + 31 ) & ~31 ) >> 3 );
#endif
if( !p_sys->p_blend )
{
p_sys->p_blend = vlc_object_create( p_demux, sizeof(filter_t) );
if( p_sys->p_blend )
{
es_format_Init( &p_sys->p_blend->fmt_in, VIDEO_ES,
VLC_CODEC_RGBA );
p_sys->p_blend->fmt_in.video = p_sys->p_mouse->format;
p_sys->p_blend->fmt_out = p_sys->fmt;
p_sys->p_blend->p_module =
module_need( p_sys->p_blend, "video blending", NULL, false );
if( !p_sys->p_blend->p_module )
{
msg_Err( p_demux, "Could not load video blending module" );
vlc_object_delete(p_sys->p_blend);
p_sys->p_blend = NULL;
}
assert( p_sys->p_blend->ops != NULL );
}
}
if( p_sys->p_blend )
{
p_sys->dst.p->p_pixels = p_dst;
p_sys->p_blend->ops->blend_video( p_sys->p_blend,
&p_sys->dst,
p_sys->p_mouse,
#ifdef SCREEN_SUBSCREEN
i_x-p_sys->i_left,
#else
i_x,
#endif
#ifdef SCREEN_SUBSCREEN
i_y-p_sys->i_top,
#else
i_y,
#endif
255 );
}
else
{
picture_Release( p_sys->p_mouse );
p_sys->p_mouse = NULL;
}
}
#endif

View File

@ -32,10 +32,6 @@
#define SCREEN_SUBSCREEN
#define SCREEN_MOUSE
#ifdef SCREEN_MOUSE
# include <vlc_image.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -72,7 +68,6 @@ typedef struct
#ifdef SCREEN_MOUSE
picture_t *p_mouse;
filter_t *p_blend;
picture_t dst;
#endif
@ -93,9 +88,6 @@ int screen_InitCaptureGDI ( demux_t * );
#ifdef SCREEN_SUBSCREEN
void FollowMouse( demux_sys_t *, int, int );
#endif
#ifdef SCREEN_MOUSE
void RenderCursor( demux_t *, int, int, uint8_t * );
#endif
#ifdef __cplusplus
}

View File

@ -29,6 +29,9 @@
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_modules.h> /* module_need for "video blending" */
#include <vlc_filter.h>
#include "screen.h"
@ -48,6 +51,10 @@ struct screen_data_t
int i_fragment_size;
int i_fragment;
block_t *p_block;
#ifdef SCREEN_MOUSE
filter_t *p_blend;
#endif
};
/*
@ -183,6 +190,16 @@ void screen_CloseCapture( screen_data_t *p_data )
DeleteDC( p_data->hdc_dst );
ReleaseDC( 0, p_data->hdc_src );
#ifdef SCREEN_MOUSE
if( p_data->p_blend )
{
filter_Close( p_data->p_blend );
module_unneed( p_data->p_blend, p_data->p_blend->p_module );
vlc_object_delete(p_data->p_blend);
}
#endif
free( p_data );
}
@ -279,6 +296,65 @@ error:
return NULL;
}
#ifdef SCREEN_MOUSE
static void RenderCursor( demux_t *p_demux, int i_x, int i_y,
uint8_t *p_dst )
{
demux_sys_t *p_sys = p_demux->p_sys;
screen_data_t *p_data = p_sys->p_data;
if( !p_sys->dst.i_planes )
picture_Setup( &p_sys->dst, &p_sys->fmt.video );
if( !p_sys->dst.i_planes )
return;
/* Bitmaps here created by CreateDIBSection: stride rounded up to the nearest DWORD */
p_sys->dst.p[ 0 ].i_pitch = p_sys->dst.p[ 0 ].i_visible_pitch =
( ( ( ( p_sys->fmt.video.i_width * p_sys->fmt.video.i_bits_per_pixel ) + 31 ) & ~31 ) >> 3 );
if( !p_data->p_blend )
{
p_data->p_blend = vlc_object_create( p_demux, sizeof(filter_t) );
if( p_data->p_blend )
{
es_format_Init( &p_data->p_blend->fmt_in, VIDEO_ES,
VLC_CODEC_RGBA );
p_data->p_blend->fmt_in.video = p_sys->p_mouse->format;
p_data->p_blend->fmt_out = p_sys->fmt;
p_data->p_blend->p_module =
module_need( p_data->p_blend, "video blending", NULL, false );
if( !p_data->p_blend->p_module )
{
msg_Err( p_demux, "Could not load video blending module" );
vlc_object_delete(p_data->p_blend);
p_data->p_blend = NULL;
picture_Release( p_sys->p_mouse );
p_sys->p_mouse = NULL;
}
assert( p_data->p_blend->ops != NULL );
}
}
if( p_data->p_blend )
{
p_sys->dst.p->p_pixels = p_dst;
p_data->p_blend->ops->blend_video( p_data->p_blend,
&p_sys->dst,
p_sys->p_mouse,
#ifdef SCREEN_SUBSCREEN
i_x-p_sys->i_left,
#else
i_x,
#endif
#ifdef SCREEN_SUBSCREEN
i_y-p_sys->i_top,
#else
i_y,
#endif
255 );
}
}
#endif
block_t *screen_Capture( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
@ -324,6 +400,7 @@ block_t *screen_Capture( demux_t *p_demux )
p_data->i_fragment = 0;
p_data->p_block = 0;
#ifdef SCREEN_MOUSE
if( p_sys->p_mouse )
{
POINT pos;
@ -333,6 +410,7 @@ block_t *screen_Capture( demux_t *p_demux )
RenderCursor( p_demux, pos.x, pos.y,
p_block->p_buffer );
}
#endif
return p_block;
}