|
Packit |
1fb8d4 |
/**
|
|
Packit |
1fb8d4 |
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
Packit |
1fb8d4 |
* Video Optimized Remoting Virtual Channel Extension for X11
|
|
Packit |
1fb8d4 |
*
|
|
Packit |
1fb8d4 |
* Copyright 2017 David Fort <contact@hardening-consulting.com>
|
|
Packit |
1fb8d4 |
*
|
|
Packit |
1fb8d4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit |
1fb8d4 |
* you may not use this file except in compliance with the License.
|
|
Packit |
1fb8d4 |
* You may obtain a copy of the License at
|
|
Packit |
1fb8d4 |
*
|
|
Packit |
1fb8d4 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
1fb8d4 |
*
|
|
Packit |
1fb8d4 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
1fb8d4 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
1fb8d4 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
1fb8d4 |
* See the License for the specific language governing permissions and
|
|
Packit |
1fb8d4 |
* limitations under the License.
|
|
Packit |
1fb8d4 |
*/
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
#include <freerdp/client/geometry.h>
|
|
Packit |
1fb8d4 |
#include <freerdp/client/video.h>
|
|
Packit |
1fb8d4 |
#include <freerdp/gdi/video.h>
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
#include "xf_video.h"
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
#define TAG CLIENT_TAG("video")
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
typedef struct
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
VideoSurface base;
|
|
Packit |
1fb8d4 |
XImage* image;
|
|
Packit |
1fb8d4 |
} xfVideoSurface;
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
static VideoSurface* xfVideoCreateSurface(VideoClientContext* video, BYTE* data, UINT32 x, UINT32 y,
|
|
Packit Service |
5a9772 |
UINT32 width, UINT32 height)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
xfContext* xfc = (xfContext*)video->custom;
|
|
Packit |
1fb8d4 |
xfVideoSurface* ret = calloc(1, sizeof(*ret));
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
if (!ret)
|
|
Packit |
1fb8d4 |
return NULL;
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
ret->base.data = data;
|
|
Packit |
1fb8d4 |
ret->base.x = x;
|
|
Packit |
1fb8d4 |
ret->base.y = y;
|
|
Packit |
1fb8d4 |
ret->base.w = width;
|
|
Packit |
1fb8d4 |
ret->base.h = height;
|
|
Packit Service |
5a9772 |
ret->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*)data, width,
|
|
Packit Service |
5a9772 |
height, 8, width * 4);
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
if (!ret->image)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
WLog_ERR(TAG, "unable to create surface image");
|
|
Packit |
1fb8d4 |
free(ret);
|
|
Packit |
1fb8d4 |
return NULL;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
return &ret->base;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
static BOOL xfVideoShowSurface(VideoClientContext* video, VideoSurface* surface)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
xfVideoSurface* xfSurface = (xfVideoSurface*)surface;
|
|
Packit |
1fb8d4 |
xfContext* xfc = video->custom;
|
|
Packit |
1fb8d4 |
#ifdef WITH_XRENDER
|
|
Packit |
1fb8d4 |
|
|
Packit Service |
5a9772 |
if (xfc->context.settings->SmartSizing || xfc->context.settings->MultiTouchGestures)
|
|
Packit |
1fb8d4 |
{
|
|
Packit Service |
5a9772 |
XPutImage(xfc->display, xfc->primary, xfc->gc, xfSurface->image, 0, 0, surface->x,
|
|
Packit Service |
5a9772 |
surface->y, surface->w, surface->h);
|
|
Packit |
1fb8d4 |
xf_draw_screen(xfc, surface->x, surface->y, surface->w, surface->h);
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
else
|
|
Packit |
1fb8d4 |
#endif
|
|
Packit |
1fb8d4 |
{
|
|
Packit Service |
5a9772 |
XPutImage(xfc->display, xfc->drawable, xfc->gc, xfSurface->image, 0, 0, surface->x,
|
|
Packit Service |
5a9772 |
surface->y, surface->w, surface->h);
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
return TRUE;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
static BOOL xfVideoDeleteSurface(VideoClientContext* video, VideoSurface* surface)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
xfVideoSurface* xfSurface = (xfVideoSurface*)surface;
|
|
Packit |
1fb8d4 |
|
|
Packit Service |
5a9772 |
WINPR_UNUSED(video);
|
|
Packit Service |
5a9772 |
|
|
Packit |
1fb8d4 |
if (xfSurface)
|
|
Packit |
1fb8d4 |
XFree(xfSurface->image);
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
free(surface);
|
|
Packit |
1fb8d4 |
return TRUE;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
void xf_video_control_init(xfContext* xfc, VideoClientContext* video)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
gdi_video_control_init(xfc->context.gdi, video);
|
|
Packit |
1fb8d4 |
video->custom = xfc;
|
|
Packit |
1fb8d4 |
video->createSurface = xfVideoCreateSurface;
|
|
Packit |
1fb8d4 |
video->showSurface = xfVideoShowSurface;
|
|
Packit |
1fb8d4 |
video->deleteSurface = xfVideoDeleteSurface;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
void xf_video_control_uninit(xfContext* xfc, VideoClientContext* video)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
gdi_video_control_uninit(xfc->context.gdi, video);
|
|
Packit |
1fb8d4 |
}
|