Fixed scaled drawing of video content.

This commit is contained in:
Armin Novak 2018-02-08 07:49:50 +01:00 committed by David Fort
parent 73bef4ca23
commit 11f11a8763

View File

@ -28,25 +28,27 @@
typedef struct
{
VideoSurface base;
XImage *image;
XImage* image;
} xfVideoSurface;
void xf_video_geometry_init(xfContext *xfc, GeometryClientContext *geom)
void xf_video_geometry_init(xfContext* xfc, GeometryClientContext* geom)
{
xfc->geometry = geom;
if (xfc->video)
{
VideoClientContext *video = xfc->video;
VideoClientContext* video = xfc->video;
video->setGeometry(video, xfc->geometry);
}
}
static VideoSurface *xfVideoCreateSurface(VideoClientContext *video, BYTE *data, UINT32 x, UINT32 y,
UINT32 width, UINT32 height)
static VideoSurface* xfVideoCreateSurface(VideoClientContext* video, BYTE* data, UINT32 x, UINT32 y,
UINT32 width, UINT32 height)
{
xfContext *xfc = (xfContext *)video->custom;
xfVideoSurface *ret = calloc(1, sizeof(*ret));
xfContext* xfc = (xfContext*)video->custom;
xfVideoSurface* ret = calloc(1, sizeof(*ret));
if (!ret)
return NULL;
@ -55,41 +57,53 @@ static VideoSurface *xfVideoCreateSurface(VideoClientContext *video, BYTE *data,
ret->base.y = y;
ret->base.w = width;
ret->base.h = height;
ret->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
(char *)data, width, height, 8, width * 4);
(char*)data, width, height, 8, width * 4);
if (!ret->image)
{
WLog_ERR(TAG, "unable to create surface image");
free(ret);
return NULL;
}
return &ret->base;
}
static BOOL xfVideoShowSurface(VideoClientContext *video, xfVideoSurface *surface)
static BOOL xfVideoShowSurface(VideoClientContext* video, xfVideoSurface* surface)
{
xfContext *xfc = video->custom;
xfContext* xfc = video->custom;
#ifdef WITH_XRENDER
if (xfc->context.settings->SmartSizing
|| xfc->context.settings->MultiTouchGestures)
{
XPutImage(xfc->display, xfc->primary, xfc->gc, surface->image,
0, 0, surface->base.x, surface->base.y, surface->base.w, surface->base.h);
xf_draw_screen(xfc, surface->base.x, surface->base.y, surface->base.w, surface->base.h);
}
else
#endif
{
XPutImage(xfc->display, xfc->drawable, xfc->gc, surface->image,
0, 0,
surface->base.x, surface->base.y, surface->base.w, surface->base.h);
}
XPutImage(xfc->display, xfc->drawable, xfc->gc, surface->image,
0, 0,
surface->base.x, surface->base.y, surface->base.w, surface->base.h);
return TRUE;
}
static BOOL xfVideoDeleteSurface(VideoClientContext *video, xfVideoSurface *surface)
static BOOL xfVideoDeleteSurface(VideoClientContext* video, xfVideoSurface* surface)
{
XFree(surface->image);
free(surface);
return TRUE;
}
void xf_video_control_init(xfContext *xfc, VideoClientContext *video)
void xf_video_control_init(xfContext* xfc, VideoClientContext* video)
{
xfc->video = video;
video->custom = xfc;
video->createSurface = xfVideoCreateSurface;
video->showSurface = (pcVideoShowSurface)xfVideoShowSurface;
video->deleteSurface = (pcVideoDeleteSurface)xfVideoDeleteSurface;
@ -97,21 +111,21 @@ void xf_video_control_init(xfContext *xfc, VideoClientContext *video)
}
void xf_video_control_uninit(xfContext *xfc, VideoClientContext *video)
void xf_video_control_uninit(xfContext* xfc, VideoClientContext* video)
{
}
static void xf_video_timer(xfContext *xfc, TimerEventArgs *timer)
static void xf_video_timer(xfContext* xfc, TimerEventArgs* timer)
{
xfc->video->timer(xfc->video, timer->now);
}
void xf_video_data_init(xfContext *xfc, VideoClientContext *video)
void xf_video_data_init(xfContext* xfc, VideoClientContext* video)
{
PubSub_SubscribeTimer(xfc->context.pubSub, (pTimerEventHandler)xf_video_timer);
}
void xf_video_data_uninit(xfContext *xfc, VideoClientContext *context)
void xf_video_data_uninit(xfContext* xfc, VideoClientContext* context)
{
PubSub_UnsubscribeTimer(xfc->context.pubSub, (pTimerEventHandler)xf_video_timer);
}