2014-09-12 22:57:44 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* GDI Graphics Pipeline
|
|
|
|
*
|
|
|
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2016-04-11 15:14:17 +03:00
|
|
|
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
|
|
|
|
* Copyright 2016 Thincast Technologies GmbH
|
2014-09-12 22:57:44 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-09-15 11:01:05 +04:00
|
|
|
#include <freerdp/log.h>
|
2014-09-12 22:57:44 +04:00
|
|
|
#include <freerdp/gdi/gfx.h>
|
|
|
|
#include <freerdp/gdi/region.h>
|
|
|
|
|
2014-09-15 11:01:05 +04:00
|
|
|
#define TAG FREERDP_TAG("gdi")
|
|
|
|
|
2016-10-31 09:56:10 +03:00
|
|
|
static DWORD gfx_align_scanline(DWORD widthInBytes, DWORD alignment)
|
|
|
|
{
|
|
|
|
const UINT32 align = 16;
|
|
|
|
const UINT32 pad = align - (widthInBytes % alignment);
|
|
|
|
UINT32 scanline = widthInBytes;
|
|
|
|
|
|
|
|
if (align != pad)
|
|
|
|
scanline += pad;
|
|
|
|
|
|
|
|
return scanline;
|
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_ResetGraphics(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_RESET_GRAPHICS_PDU* resetGraphics)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT32 index;
|
2015-10-13 22:50:39 +03:00
|
|
|
UINT16 count;
|
2014-09-26 06:08:10 +04:00
|
|
|
UINT32 DesktopWidth;
|
|
|
|
UINT32 DesktopHeight;
|
2015-10-13 22:50:39 +03:00
|
|
|
gdiGfxSurface* surface;
|
|
|
|
UINT16* pSurfaceIds = NULL;
|
2014-09-12 22:57:44 +04:00
|
|
|
rdpGdi* gdi = (rdpGdi*) context->custom;
|
2014-09-26 06:08:10 +04:00
|
|
|
rdpUpdate* update = gdi->context->update;
|
|
|
|
rdpSettings* settings = gdi->context->settings;
|
|
|
|
DesktopWidth = resetGraphics->width;
|
|
|
|
DesktopHeight = resetGraphics->height;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2017-12-08 12:45:50 +03:00
|
|
|
if ((DesktopWidth != settings->DesktopWidth) || (DesktopHeight != settings->DesktopHeight))
|
2014-09-26 06:08:10 +04:00
|
|
|
{
|
|
|
|
settings->DesktopWidth = DesktopWidth;
|
|
|
|
settings->DesktopHeight = DesktopHeight;
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
update->DesktopResize(gdi->context);
|
|
|
|
}
|
|
|
|
|
2015-10-13 22:50:39 +03:00
|
|
|
context->GetSurfaceIds(context, &pSurfaceIds, &count);
|
|
|
|
|
|
|
|
for (index = 0; index < count; index++)
|
|
|
|
{
|
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, pSurfaceIds[index]);
|
|
|
|
|
|
|
|
if (!surface || !surface->outputMapped)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
region16_clear(&surface->invalidRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(pSurfaceIds);
|
|
|
|
|
2016-07-13 17:06:59 +03:00
|
|
|
if (!freerdp_client_codecs_reset(gdi->context->codecs, FREERDP_CODEC_ALL,
|
2016-07-14 17:08:06 +03:00
|
|
|
gdi->width, gdi->height))
|
2016-03-01 18:17:28 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
gdi->graphicsReset = TRUE;
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT32 nXDst, nYDst;
|
|
|
|
UINT32 nXSrc, nYSrc;
|
2015-10-13 22:50:39 +03:00
|
|
|
UINT16 width, height;
|
|
|
|
UINT32 surfaceX, surfaceY;
|
2014-09-12 22:57:44 +04:00
|
|
|
RECTANGLE_16 surfaceRect;
|
2017-03-30 16:42:13 +03:00
|
|
|
const RECTANGLE_16* rects;
|
|
|
|
UINT32 i, nbRects;
|
2014-09-12 22:57:44 +04:00
|
|
|
rdpUpdate* update = gdi->context->update;
|
2015-10-13 22:50:39 +03:00
|
|
|
surfaceX = surface->outputOriginX;
|
|
|
|
surfaceY = surface->outputOriginY;
|
2014-09-12 22:57:44 +04:00
|
|
|
surfaceRect.left = 0;
|
|
|
|
surfaceRect.top = 0;
|
2015-10-13 22:50:39 +03:00
|
|
|
surfaceRect.right = surface->width;
|
|
|
|
surfaceRect.bottom = surface->height;
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_intersect_rect(&(surface->invalidRegion),
|
2016-07-14 17:08:06 +03:00
|
|
|
&(surface->invalidRegion), &surfaceRect);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2017-03-30 16:42:13 +03:00
|
|
|
if (!(rects = region16_rects(&surface->invalidRegion, &nbRects)) || !nbRects)
|
2017-04-19 14:00:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2017-03-30 16:42:13 +03:00
|
|
|
|
|
|
|
update->BeginPaint(gdi->context);
|
|
|
|
|
|
|
|
for (i = 0; i < nbRects; i++)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2017-03-30 16:42:13 +03:00
|
|
|
nXSrc = rects[i].left;
|
|
|
|
nYSrc = rects[i].top;
|
|
|
|
nXDst = surfaceX + nXSrc;
|
|
|
|
nYDst = surfaceY + nYSrc;
|
|
|
|
width = rects[i].right - rects[i].left;
|
|
|
|
height = rects[i].bottom - rects[i].top;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
|
|
|
if (!freerdp_image_copy(gdi->primary_buffer, gdi->primary->hdc->format,
|
|
|
|
gdi->stride,
|
|
|
|
nXDst, nYDst, width, height,
|
|
|
|
surface->data, surface->format,
|
2016-10-14 11:01:02 +03:00
|
|
|
surface->scanline, nXSrc, nYSrc, NULL, FREERDP_FLIP_NONE))
|
2016-07-18 12:16:36 +03:00
|
|
|
return CHANNEL_RC_NULL_DATA;
|
|
|
|
|
2015-10-13 22:50:39 +03:00
|
|
|
gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, width, height);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2017-03-30 16:42:13 +03:00
|
|
|
update->EndPaint(gdi->context);
|
2017-04-19 14:00:26 +03:00
|
|
|
|
2015-10-13 22:50:39 +03:00
|
|
|
region16_clear(&(surface->invalidRegion));
|
2016-04-11 15:14:17 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_UpdateSurfaces(RdpgfxClientContext* context)
|
2015-10-13 22:50:39 +03:00
|
|
|
{
|
|
|
|
UINT16 count;
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT16 index;
|
|
|
|
UINT status = CHANNEL_RC_OK;
|
2015-10-13 22:50:39 +03:00
|
|
|
gdiGfxSurface* surface;
|
|
|
|
UINT16* pSurfaceIds = NULL;
|
2016-04-11 15:14:17 +03:00
|
|
|
rdpGdi* gdi = (rdpGdi*)context->custom;
|
2015-10-13 22:50:39 +03:00
|
|
|
|
|
|
|
if (!gdi->graphicsReset)
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2015-10-13 22:50:39 +03:00
|
|
|
|
|
|
|
context->GetSurfaceIds(context, &pSurfaceIds, &count);
|
|
|
|
|
|
|
|
for (index = 0; index < count; index++)
|
|
|
|
{
|
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, pSurfaceIds[index]);
|
|
|
|
|
|
|
|
if (!surface || !surface->outputMapped)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
status = gdi_OutputUpdate(gdi, surface);
|
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
if (status != CHANNEL_RC_OK)
|
2015-10-13 22:50:39 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(pSurfaceIds);
|
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_StartFrame(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_START_FRAME_PDU* startFrame)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
|
|
|
rdpGdi* gdi = (rdpGdi*) context->custom;
|
|
|
|
gdi->inGfxFrame = TRUE;
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_EndFrame(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_END_FRAME_PDU* endFrame)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_NOT_INITIALIZED;
|
2014-09-12 22:57:44 +04:00
|
|
|
rdpGdi* gdi = (rdpGdi*) context->custom;
|
2016-04-11 15:14:17 +03:00
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
gdi->inGfxFrame = FALSE;
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceCommand_Uncompressed(rdpGdi* gdi,
|
2016-07-14 17:08:06 +03:00
|
|
|
RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
gdiGfxSurface* surface;
|
|
|
|
RECTANGLE_16 invalidRect;
|
2017-04-10 18:16:57 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2017-04-19 14:00:26 +03:00
|
|
|
WLog_ERR(TAG, "%s: unable to retrieve surfaceData for surfaceId=%"PRIu32"", __FUNCTION__, cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
if (!freerdp_image_copy(surface->data, surface->format, surface->scanline,
|
2016-07-14 17:08:06 +03:00
|
|
|
cmd->left, cmd->top, cmd->width, cmd->height,
|
2016-10-14 11:01:02 +03:00
|
|
|
cmd->data, cmd->format, 0, 0, 0, NULL, FREERDP_FLIP_NONE))
|
2016-04-11 15:14:17 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
invalidRect.left = cmd->left;
|
|
|
|
invalidRect.top = cmd->top;
|
|
|
|
invalidRect.right = cmd->right;
|
|
|
|
invalidRect.bottom = cmd->bottom;
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
2016-07-14 17:08:06 +03:00
|
|
|
&invalidRect);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2017-04-19 15:43:06 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId, 1, &invalidRect);
|
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!gdi->inGfxFrame)
|
2016-04-11 15:14:17 +03:00
|
|
|
{
|
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceCommand_RemoteFX(rdpGdi* gdi,
|
2016-07-14 17:08:06 +03:00
|
|
|
RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
gdiGfxSurface* surface;
|
2017-04-19 14:00:26 +03:00
|
|
|
REGION16 invalidRegion;
|
|
|
|
const RECTANGLE_16* rects;
|
|
|
|
UINT32 nrRects, x;
|
2017-04-10 18:16:57 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2017-04-19 14:00:26 +03:00
|
|
|
WLog_ERR(TAG, "%s: unable to retrieve surfaceData for surfaceId=%"PRIu32"", __FUNCTION__, cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-12-01 19:21:06 +03:00
|
|
|
rfx_context_set_pixel_format(surface->codecs->rfx, cmd->format);
|
2016-12-06 18:44:00 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
region16_init(&invalidRegion);
|
2016-12-01 19:21:06 +03:00
|
|
|
if (!rfx_process_message(surface->codecs->rfx, cmd->data, cmd->length,
|
2016-07-14 17:08:06 +03:00
|
|
|
cmd->left, cmd->top,
|
|
|
|
surface->data, surface->format, surface->scanline,
|
2017-04-19 14:00:26 +03:00
|
|
|
surface->height, &invalidRegion))
|
2015-04-23 16:42:21 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to process RemoteFX message");
|
2017-04-19 14:00:26 +03:00
|
|
|
region16_uninit(&invalidRegion);
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2015-04-23 16:42:21 +03:00
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
rects = region16_rects(&invalidRegion, &nrRects);
|
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId, nrRects, rects);
|
|
|
|
|
|
|
|
for (x=0; x<nrRects; x++)
|
|
|
|
region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &rects[x]);
|
2017-04-19 15:43:06 +03:00
|
|
|
|
|
|
|
region16_uninit(&invalidRegion);
|
2016-04-11 15:14:17 +03:00
|
|
|
if (!gdi->inGfxFrame)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceCommand_ClearCodec(rdpGdi* gdi,
|
2016-07-14 17:08:06 +03:00
|
|
|
RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
INT32 rc;
|
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
gdiGfxSurface* surface;
|
|
|
|
RECTANGLE_16 invalidRect;
|
2017-04-10 18:16:57 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2017-04-19 14:00:26 +03:00
|
|
|
WLog_ERR(TAG, "%s: unable to retrieve surfaceData for surfaceId=%"PRIu32"", __FUNCTION__, cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-07-13 15:58:11 +03:00
|
|
|
rc = clear_decompress(surface->codecs->clear, cmd->data, cmd->length,
|
2016-07-14 17:08:06 +03:00
|
|
|
cmd->width, cmd->height,
|
|
|
|
surface->data, surface->format,
|
|
|
|
surface->scanline, cmd->left, cmd->top,
|
|
|
|
surface->width, surface->height, &gdi->palette);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
if (rc < 0)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "clear_decompress failure: %"PRId32"", rc);
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
invalidRect.left = cmd->left;
|
|
|
|
invalidRect.top = cmd->top;
|
|
|
|
invalidRect.right = cmd->right;
|
|
|
|
invalidRect.bottom = cmd->bottom;
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
2016-07-14 17:08:06 +03:00
|
|
|
&invalidRect);
|
2017-04-19 15:43:06 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId, 1, &invalidRect);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!gdi->inGfxFrame)
|
2016-04-11 15:14:17 +03:00
|
|
|
{
|
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceCommand_Planar(rdpGdi* gdi, RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
BYTE* DstData = NULL;
|
|
|
|
gdiGfxSurface* surface;
|
|
|
|
RECTANGLE_16 invalidRect;
|
2017-04-10 18:16:57 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2017-04-19 14:00:26 +03:00
|
|
|
WLog_ERR(TAG, "%s: unable to retrieve surfaceData for surfaceId=%"PRIu32"", __FUNCTION__, cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
DstData = surface->data;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
|
|
|
if (!planar_decompress(surface->codecs->planar, cmd->data, cmd->length,
|
2016-07-19 17:15:38 +03:00
|
|
|
cmd->width, cmd->height,
|
2016-07-14 17:08:06 +03:00
|
|
|
DstData, surface->format,
|
|
|
|
surface->scanline, cmd->left, cmd->top,
|
2016-07-18 12:16:36 +03:00
|
|
|
cmd->width, cmd->height, FALSE))
|
2016-04-11 15:14:17 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
invalidRect.left = cmd->left;
|
|
|
|
invalidRect.top = cmd->top;
|
|
|
|
invalidRect.right = cmd->right;
|
|
|
|
invalidRect.bottom = cmd->bottom;
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
2016-07-14 17:08:06 +03:00
|
|
|
&invalidRect);
|
2017-04-19 15:43:06 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId, 1, &invalidRect);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!gdi->inGfxFrame)
|
2016-04-11 15:14:17 +03:00
|
|
|
{
|
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi,
|
2016-07-14 17:08:06 +03:00
|
|
|
RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2017-07-17 11:37:15 +03:00
|
|
|
#ifdef WITH_GFX_H264
|
2016-04-11 15:14:17 +03:00
|
|
|
INT32 rc;
|
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
UINT32 i;
|
|
|
|
gdiGfxSurface* surface;
|
|
|
|
RDPGFX_H264_METABLOCK* meta;
|
2016-03-02 17:16:49 +03:00
|
|
|
RDPGFX_AVC420_BITMAP_STREAM* bs;
|
2017-04-10 18:16:57 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
|
2015-10-13 22:50:39 +03:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2017-04-19 14:00:26 +03:00
|
|
|
WLog_ERR(TAG, "%s: unable to retrieve surfaceData for surfaceId=%"PRIu32"", __FUNCTION__, cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2017-05-01 23:39:52 +03:00
|
|
|
if (!surface->h264)
|
|
|
|
{
|
|
|
|
surface->h264 = h264_context_new(FALSE);
|
|
|
|
if (!surface->h264)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s: unable to create h264 context", __FUNCTION__);
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
}
|
2017-05-10 13:36:08 +03:00
|
|
|
|
|
|
|
if (!h264_context_reset(surface->h264, surface->width, surface->height))
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
2017-05-01 23:39:52 +03:00
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2017-05-01 23:39:52 +03:00
|
|
|
bs = (RDPGFX_AVC420_BITMAP_STREAM*) cmd->extra;
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!bs)
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
meta = &(bs->meta);
|
2017-05-01 23:39:52 +03:00
|
|
|
rc = avc420_decompress(surface->h264, bs->data, bs->length, surface->data, surface->format,
|
2016-07-14 17:08:06 +03:00
|
|
|
surface->scanline, surface->width,
|
|
|
|
surface->height, meta->regionRects,
|
|
|
|
meta->numRegionRects);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
if (rc < 0)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_WARN(TAG, "avc420_decompress failure: %"PRIu32", ignoring update.", status);
|
2015-09-03 13:05:02 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < meta->numRegionRects; i++)
|
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
2016-07-14 17:08:06 +03:00
|
|
|
(RECTANGLE_16*) & (meta->regionRects[i]));
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
2017-04-19 14:00:26 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
meta->numRegionRects, meta->regionRects);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!gdi->inGfxFrame)
|
2016-04-11 15:14:17 +03:00
|
|
|
{
|
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2017-07-17 11:37:15 +03:00
|
|
|
#else
|
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
#endif
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2016-03-02 17:16:49 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2016-03-02 17:16:49 +03:00
|
|
|
{
|
2017-07-17 11:37:15 +03:00
|
|
|
#ifdef WITH_GFX_H264
|
2016-04-11 15:14:17 +03:00
|
|
|
INT32 rc;
|
|
|
|
UINT status = CHANNEL_RC_OK;
|
2016-03-02 17:16:49 +03:00
|
|
|
UINT32 i;
|
|
|
|
gdiGfxSurface* surface;
|
|
|
|
RDPGFX_AVC444_BITMAP_STREAM* bs;
|
|
|
|
RDPGFX_AVC420_BITMAP_STREAM* avc1;
|
|
|
|
RDPGFX_H264_METABLOCK* meta1;
|
|
|
|
RDPGFX_AVC420_BITMAP_STREAM* avc2;
|
|
|
|
RDPGFX_H264_METABLOCK* meta2;
|
|
|
|
RECTANGLE_16* regionRects = NULL;
|
2017-04-10 18:16:57 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
|
2016-03-02 17:16:49 +03:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2017-04-19 14:00:26 +03:00
|
|
|
WLog_ERR(TAG, "%s: unable to retrieve surfaceData for surfaceId=%"PRIu32"", __FUNCTION__, cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2016-03-02 17:16:49 +03:00
|
|
|
|
2017-05-01 23:39:52 +03:00
|
|
|
if (!surface->h264)
|
|
|
|
{
|
|
|
|
surface->h264 = h264_context_new(FALSE);
|
|
|
|
if (!surface->h264)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s: unable to create h264 context", __FUNCTION__);
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
}
|
2017-05-10 13:36:08 +03:00
|
|
|
|
|
|
|
if (!h264_context_reset(surface->h264, surface->width, surface->height))
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
2017-05-01 23:39:52 +03:00
|
|
|
}
|
|
|
|
|
2016-03-02 17:16:49 +03:00
|
|
|
bs = (RDPGFX_AVC444_BITMAP_STREAM*) cmd->extra;
|
|
|
|
|
|
|
|
if (!bs)
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
|
|
|
|
avc1 = &bs->bitstream[0];
|
|
|
|
avc2 = &bs->bitstream[1];
|
|
|
|
meta1 = &avc1->meta;
|
|
|
|
meta2 = &avc2->meta;
|
2017-05-01 23:39:52 +03:00
|
|
|
rc = avc444_decompress(surface->h264, bs->LC,
|
2016-07-14 17:08:06 +03:00
|
|
|
meta1->regionRects, meta1->numRegionRects,
|
|
|
|
avc1->data, avc1->length,
|
|
|
|
meta2->regionRects, meta2->numRegionRects,
|
|
|
|
avc2->data, avc2->length,
|
|
|
|
surface->data, surface->format,
|
|
|
|
surface->scanline, surface->width,
|
2017-04-10 18:16:57 +03:00
|
|
|
surface->height, cmd->codecId);
|
2016-03-02 17:16:49 +03:00
|
|
|
|
2016-04-14 00:18:55 +03:00
|
|
|
if (rc < 0)
|
2016-03-02 17:16:49 +03:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_WARN(TAG, "avc444_decompress failure: %"PRIu32", ignoring update.", status);
|
2016-03-02 17:16:49 +03:00
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < meta1->numRegionRects; i++)
|
|
|
|
{
|
2017-05-01 23:39:52 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &(meta1->regionRects[i]));
|
2016-03-02 17:16:49 +03:00
|
|
|
}
|
2017-04-19 14:00:26 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
meta1->numRegionRects, meta1->regionRects);
|
2016-03-02 17:16:49 +03:00
|
|
|
|
|
|
|
for (i = 0; i < meta2->numRegionRects; i++)
|
|
|
|
{
|
2017-05-01 23:39:52 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &(meta2->regionRects[i]));
|
2016-03-02 17:16:49 +03:00
|
|
|
}
|
2017-04-19 14:00:26 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
meta2->numRegionRects, meta2->regionRects);
|
2016-03-02 17:16:49 +03:00
|
|
|
|
|
|
|
if (!gdi->inGfxFrame)
|
2016-04-11 15:14:17 +03:00
|
|
|
{
|
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
|
|
|
}
|
2016-03-02 17:16:49 +03:00
|
|
|
|
|
|
|
free(regionRects);
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2017-07-17 11:37:15 +03:00
|
|
|
#else
|
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
#endif
|
2016-03-02 17:16:49 +03:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceCommand_Alpha(rdpGdi* gdi, RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2017-01-11 15:15:28 +03:00
|
|
|
UINT32 color;
|
2014-09-12 22:57:44 +04:00
|
|
|
gdiGfxSurface* surface;
|
|
|
|
RECTANGLE_16 invalidRect;
|
2017-04-10 18:16:57 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2017-04-19 14:00:26 +03:00
|
|
|
WLog_ERR(TAG, "%s: unable to retrieve surfaceData for surfaceId=%"PRIu32"", __FUNCTION__, cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_WARN(TAG, "TODO gdi_SurfaceCommand_Alpha: status: %"PRIu32"", status);
|
2014-09-12 22:57:44 +04:00
|
|
|
/* fill with green for now to distinguish from the rest */
|
2017-11-24 15:19:48 +03:00
|
|
|
color = FreeRDPGetColor(surface->format, 0x00, 0xFF, 0x00, 0xFF);
|
2017-01-11 15:15:28 +03:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
if (!freerdp_image_fill(surface->data, surface->format, surface->scanline,
|
2017-01-11 15:15:28 +03:00
|
|
|
cmd->left, cmd->top, cmd->width, cmd->height, color))
|
2016-04-11 15:14:17 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
invalidRect.left = cmd->left;
|
|
|
|
invalidRect.top = cmd->top;
|
|
|
|
invalidRect.right = cmd->right;
|
|
|
|
invalidRect.bottom = cmd->bottom;
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
2016-07-14 17:08:06 +03:00
|
|
|
&invalidRect);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId, 1, &invalidRect);
|
2017-04-19 15:43:06 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!gdi->inGfxFrame)
|
2016-04-11 15:14:17 +03:00
|
|
|
{
|
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceCommand_Progressive(rdpGdi* gdi,
|
2016-07-14 17:08:06 +03:00
|
|
|
RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
INT32 rc;
|
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
gdiGfxSurface* surface;
|
2017-04-19 14:00:26 +03:00
|
|
|
REGION16 invalidRegion;
|
|
|
|
const RECTANGLE_16* rects;
|
|
|
|
UINT32 nrRects, x;
|
|
|
|
|
2017-04-03 19:59:58 +03:00
|
|
|
/**
|
|
|
|
* Note: Since this comes via a Wire-To-Surface-2 PDU the
|
|
|
|
* cmd's top/left/right/bottom/width/height members are always zero!
|
|
|
|
* The update region is determined during decompression.
|
|
|
|
*/
|
2017-04-10 18:16:57 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2017-04-19 14:00:26 +03:00
|
|
|
WLog_ERR(TAG, "%s: unable to retrieve surfaceData for surfaceId=%"PRIu32"", __FUNCTION__, cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
rc = progressive_create_surface_context(surface->codecs->progressive,
|
2016-07-14 17:08:06 +03:00
|
|
|
cmd->surfaceId,
|
|
|
|
surface->width, surface->height);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-14 00:18:55 +03:00
|
|
|
if (rc < 0)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "progressive_create_surface_context failure: %"PRId32"", rc);
|
2016-04-14 00:18:55 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
}
|
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
region16_init(&invalidRegion);
|
2016-04-14 00:18:55 +03:00
|
|
|
rc = progressive_decompress(surface->codecs->progressive, cmd->data,
|
2016-07-14 17:08:06 +03:00
|
|
|
cmd->length, surface->data, surface->format,
|
|
|
|
surface->scanline, cmd->left, cmd->top,
|
2017-04-19 14:00:26 +03:00
|
|
|
&invalidRegion, cmd->surfaceId);
|
2016-04-14 00:18:55 +03:00
|
|
|
|
|
|
|
if (rc < 0)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "progressive_decompress failure: %"PRId32"", rc);
|
2017-04-19 14:00:26 +03:00
|
|
|
region16_uninit(&invalidRegion);
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
2017-04-19 15:43:06 +03:00
|
|
|
|
2017-04-19 14:00:26 +03:00
|
|
|
rects = region16_rects(&invalidRegion, &nrRects);
|
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId, nrRects, rects);
|
|
|
|
|
|
|
|
for (x=0; x<nrRects; x++)
|
|
|
|
region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &rects[x]);
|
2017-04-19 15:43:06 +03:00
|
|
|
region16_uninit(&invalidRegion);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
if (!gdi->inGfxFrame)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceCommand(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
rdpGdi* gdi = (rdpGdi*) context->custom;
|
|
|
|
|
2016-08-04 17:14:12 +03:00
|
|
|
if (!context || !cmd)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
WLog_Print(gdi->log, WLOG_TRACE,
|
2016-12-14 00:47:08 +03:00
|
|
|
"surfaceId=%"PRIu32", codec=%"PRIu32", contextId=%"PRIu32", format=%s, "
|
|
|
|
"left=%"PRIu32", top=%"PRIu32", right=%"PRIu32", bottom=%"PRIu32", width=%"PRIu32", height=%"PRIu32" "
|
|
|
|
"length=%"PRIu32", data=%p, extra=%p",
|
2016-08-04 17:14:12 +03:00
|
|
|
cmd->surfaceId, cmd->codecId, cmd->contextId,
|
2017-11-24 15:19:48 +03:00
|
|
|
FreeRDPGetColorFormatName(cmd->format), cmd->left, cmd->top, cmd->right,
|
2016-12-14 00:47:08 +03:00
|
|
|
cmd->bottom, cmd->width, cmd->height, cmd->length, (void*) cmd->data, (void*) cmd->extra);
|
2016-08-04 17:14:12 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
switch (cmd->codecId)
|
|
|
|
{
|
|
|
|
case RDPGFX_CODECID_UNCOMPRESSED:
|
|
|
|
status = gdi_SurfaceCommand_Uncompressed(gdi, context, cmd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CODECID_CAVIDEO:
|
|
|
|
status = gdi_SurfaceCommand_RemoteFX(gdi, context, cmd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CODECID_CLEARCODEC:
|
|
|
|
status = gdi_SurfaceCommand_ClearCodec(gdi, context, cmd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CODECID_PLANAR:
|
|
|
|
status = gdi_SurfaceCommand_Planar(gdi, context, cmd);
|
|
|
|
break;
|
|
|
|
|
2016-03-02 17:16:49 +03:00
|
|
|
case RDPGFX_CODECID_AVC420:
|
|
|
|
status = gdi_SurfaceCommand_AVC420(gdi, context, cmd);
|
|
|
|
break;
|
|
|
|
|
2017-04-25 14:58:23 +03:00
|
|
|
case RDPGFX_CODECID_AVC444v2:
|
2016-03-02 17:16:49 +03:00
|
|
|
case RDPGFX_CODECID_AVC444:
|
|
|
|
status = gdi_SurfaceCommand_AVC444(gdi, context, cmd);
|
2014-09-12 22:57:44 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CODECID_ALPHA:
|
|
|
|
status = gdi_SurfaceCommand_Alpha(gdi, context, cmd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CODECID_CAPROGRESSIVE:
|
|
|
|
status = gdi_SurfaceCommand_Progressive(gdi, context, cmd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CODECID_CAPROGRESSIVE_V2:
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_WARN(TAG, "SurfaceCommand 0x%08"PRIX32" not implemented", cmd->codecId);
|
2016-03-01 18:39:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_WARN(TAG, "Invalid SurfaceCommand 0x%08"PRIX32"", cmd->codecId);
|
2014-09-12 22:57:44 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-06-09 16:22:26 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_DeleteEncodingContext(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_DELETE_ENCODING_CONTEXT_PDU* deleteEncodingContext)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_CreateSurface(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_CREATE_SURFACE_PDU* createSurface)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
|
|
|
gdiGfxSurface* surface;
|
2017-05-30 11:46:43 +03:00
|
|
|
rdpGdi* gdi = (rdpGdi*) context->custom;
|
2014-09-12 22:57:44 +04:00
|
|
|
surface = (gdiGfxSurface*) calloc(1, sizeof(gdiGfxSurface));
|
|
|
|
|
|
|
|
if (!surface)
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-12-06 18:44:00 +03:00
|
|
|
surface->codecs = gdi->context->codecs;
|
2015-10-13 22:50:39 +03:00
|
|
|
|
|
|
|
if (!surface->codecs)
|
2016-01-14 17:36:34 +03:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
free(surface);
|
2015-10-13 22:50:39 +03:00
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2016-01-14 17:36:34 +03:00
|
|
|
}
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
surface->surfaceId = createSurface->surfaceId;
|
|
|
|
surface->width = (UINT32) createSurface->width;
|
|
|
|
surface->height = (UINT32) createSurface->height;
|
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
switch (createSurface->pixelFormat)
|
|
|
|
{
|
2016-07-13 15:58:11 +03:00
|
|
|
case GFX_PIXEL_FORMAT_ARGB_8888:
|
2016-04-11 15:14:17 +03:00
|
|
|
surface->format = PIXEL_FORMAT_BGRA32;
|
|
|
|
break;
|
|
|
|
|
2016-07-13 15:58:11 +03:00
|
|
|
case GFX_PIXEL_FORMAT_XRGB_8888:
|
2016-04-11 15:14:17 +03:00
|
|
|
surface->format = PIXEL_FORMAT_BGRX32;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
free(surface);
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
}
|
2014-09-17 00:55:47 +04:00
|
|
|
|
2016-10-31 09:56:10 +03:00
|
|
|
surface->scanline = gfx_align_scanline(surface->width * 4, 16);
|
2017-02-14 14:12:24 +03:00
|
|
|
surface->data = (BYTE*) _aligned_malloc(surface->scanline * surface->height, 16);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!surface->data)
|
2014-11-17 01:00:13 +03:00
|
|
|
{
|
2015-10-13 22:50:39 +03:00
|
|
|
free(surface);
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-11-17 01:00:13 +03:00
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2015-10-13 22:50:39 +03:00
|
|
|
surface->outputMapped = FALSE;
|
|
|
|
region16_init(&surface->invalidRegion);
|
2014-09-12 22:57:44 +04:00
|
|
|
context->SetSurfaceData(context, surface->surfaceId, (void*) surface);
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_DeleteSurface(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_DELETE_SURFACE_PDU* deleteSurface)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2015-10-13 22:50:39 +03:00
|
|
|
rdpCodecs* codecs = NULL;
|
|
|
|
gdiGfxSurface* surface = NULL;
|
2017-05-01 23:39:52 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, deleteSurface->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (surface)
|
|
|
|
{
|
2017-07-17 11:37:15 +03:00
|
|
|
#ifdef WITH_GFX_H264
|
2017-05-01 23:39:52 +03:00
|
|
|
h264_context_free(surface->h264);
|
2017-07-17 11:37:15 +03:00
|
|
|
#endif
|
2015-10-13 22:50:39 +03:00
|
|
|
region16_uninit(&surface->invalidRegion);
|
|
|
|
codecs = surface->codecs;
|
2017-02-14 14:12:24 +03:00
|
|
|
_aligned_free(surface->data);
|
2014-09-12 22:57:44 +04:00
|
|
|
free(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
context->SetSurfaceData(context, deleteSurface->surfaceId, NULL);
|
|
|
|
|
2015-10-13 22:50:39 +03:00
|
|
|
if (codecs && codecs->progressive)
|
2017-05-01 23:39:52 +03:00
|
|
|
progressive_delete_surface_context(codecs->progressive, deleteSurface->surfaceId);
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SolidFill(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_SOLID_FILL_PDU* solidFill)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
UINT16 index;
|
|
|
|
UINT32 color;
|
|
|
|
BYTE a, r, g, b;
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT32 nWidth, nHeight;
|
2016-03-02 16:39:36 +03:00
|
|
|
RECTANGLE_16* rect;
|
2014-09-12 22:57:44 +04:00
|
|
|
gdiGfxSurface* surface;
|
|
|
|
RECTANGLE_16 invalidRect;
|
|
|
|
rdpGdi* gdi = (rdpGdi*) context->custom;
|
2016-04-11 15:14:17 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context,
|
2016-07-14 17:08:06 +03:00
|
|
|
solidFill->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!surface)
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
b = solidFill->fillPixel.B;
|
|
|
|
g = solidFill->fillPixel.G;
|
|
|
|
r = solidFill->fillPixel.R;
|
2017-01-11 15:15:28 +03:00
|
|
|
/* a = solidFill->fillPixel.XA;
|
|
|
|
* Ignore alpha channel, this is a solid fill. */
|
|
|
|
a = 0xFF;
|
2017-11-24 15:19:48 +03:00
|
|
|
color = FreeRDPGetColor(surface->format, r, g, b, a);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
for (index = 0; index < solidFill->fillRectCount; index++)
|
|
|
|
{
|
|
|
|
rect = &(solidFill->fillRects[index]);
|
|
|
|
nWidth = rect->right - rect->left;
|
|
|
|
nHeight = rect->bottom - rect->top;
|
|
|
|
invalidRect.left = rect->left;
|
|
|
|
invalidRect.top = rect->top;
|
|
|
|
invalidRect.right = rect->right;
|
|
|
|
invalidRect.bottom = rect->bottom;
|
2017-01-11 15:15:28 +03:00
|
|
|
|
|
|
|
if (!freerdp_image_fill(surface->data, surface->format, surface->scanline,
|
|
|
|
rect->left, rect->top, nWidth, nHeight, color))
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
2016-07-14 17:08:06 +03:00
|
|
|
&invalidRect);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
2017-04-25 14:58:23 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
solidFill->fillRectCount, solidFill->fillRects);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!gdi->inGfxFrame)
|
2016-04-11 15:14:17 +03:00
|
|
|
{
|
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceToSurface(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_SURFACE_TO_SURFACE_PDU* surfaceToSurface)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
UINT16 index;
|
2014-09-17 01:41:24 +04:00
|
|
|
BOOL sameSurface;
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT32 nWidth, nHeight;
|
|
|
|
const RECTANGLE_16* rectSrc;
|
2014-09-12 22:57:44 +04:00
|
|
|
RDPGFX_POINT16* destPt;
|
|
|
|
RECTANGLE_16 invalidRect;
|
|
|
|
gdiGfxSurface* surfaceSrc;
|
|
|
|
gdiGfxSurface* surfaceDst;
|
|
|
|
rdpGdi* gdi = (rdpGdi*) context->custom;
|
|
|
|
rectSrc = &(surfaceToSurface->rectSrc);
|
2016-04-11 15:14:17 +03:00
|
|
|
surfaceSrc = (gdiGfxSurface*) context->GetSurfaceData(context,
|
2016-07-14 17:08:06 +03:00
|
|
|
surfaceToSurface->surfaceIdSrc);
|
2016-04-11 15:14:17 +03:00
|
|
|
sameSurface = (surfaceToSurface->surfaceIdSrc ==
|
2016-07-14 17:08:06 +03:00
|
|
|
surfaceToSurface->surfaceIdDest) ? TRUE : FALSE;
|
2014-09-17 01:41:24 +04:00
|
|
|
|
|
|
|
if (!sameSurface)
|
2016-04-11 15:14:17 +03:00
|
|
|
surfaceDst = (gdiGfxSurface*) context->GetSurfaceData(context,
|
2016-07-14 17:08:06 +03:00
|
|
|
surfaceToSurface->surfaceIdDest);
|
2014-09-12 22:57:44 +04:00
|
|
|
else
|
|
|
|
surfaceDst = surfaceSrc;
|
|
|
|
|
|
|
|
if (!surfaceSrc || !surfaceDst)
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
nWidth = rectSrc->right - rectSrc->left;
|
|
|
|
nHeight = rectSrc->bottom - rectSrc->top;
|
|
|
|
|
|
|
|
for (index = 0; index < surfaceToSurface->destPtsCount; index++)
|
|
|
|
{
|
|
|
|
destPt = &surfaceToSurface->destPts[index];
|
2017-01-11 15:15:28 +03:00
|
|
|
|
|
|
|
if (!freerdp_image_copy(surfaceDst->data, surfaceDst->format,
|
|
|
|
surfaceDst->scanline,
|
|
|
|
destPt->x, destPt->y, nWidth, nHeight,
|
|
|
|
surfaceSrc->data, surfaceSrc->format,
|
|
|
|
surfaceSrc->scanline,
|
|
|
|
rectSrc->left, rectSrc->top, NULL, FREERDP_FLIP_NONE))
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
invalidRect.left = destPt->x;
|
|
|
|
invalidRect.top = destPt->y;
|
|
|
|
invalidRect.right = destPt->x + rectSrc->right;
|
|
|
|
invalidRect.bottom = destPt->y + rectSrc->bottom;
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_union_rect(&surfaceDst->invalidRegion, &surfaceDst->invalidRegion,
|
2016-07-14 17:08:06 +03:00
|
|
|
&invalidRect);
|
2017-04-25 14:58:23 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surfaceDst->surfaceId, 1, &invalidRect);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!gdi->inGfxFrame)
|
2016-04-11 15:14:17 +03:00
|
|
|
{
|
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_SurfaceToCache(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_SURFACE_TO_CACHE_PDU* surfaceToCache)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
const RECTANGLE_16* rect;
|
2014-09-12 22:57:44 +04:00
|
|
|
gdiGfxSurface* surface;
|
|
|
|
gdiGfxCacheEntry* cacheEntry;
|
2017-10-10 18:12:16 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
rect = &(surfaceToCache->rectSrc);
|
|
|
|
|
2017-10-10 18:12:16 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, surfaceToCache->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
cacheEntry = (gdiGfxCacheEntry*) calloc(1, sizeof(gdiGfxCacheEntry));
|
|
|
|
if (!cacheEntry)
|
2017-10-10 18:12:16 +03:00
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
cacheEntry->width = (UINT32)(rect->right - rect->left);
|
|
|
|
cacheEntry->height = (UINT32)(rect->bottom - rect->top);
|
|
|
|
cacheEntry->format = surface->format;
|
2016-10-31 09:56:10 +03:00
|
|
|
cacheEntry->scanline = gfx_align_scanline(cacheEntry->width * 4, 16);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2017-10-10 18:12:16 +03:00
|
|
|
cacheEntry->data = (BYTE*) calloc(cacheEntry->height, cacheEntry->scanline);
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!cacheEntry->data)
|
2014-11-17 01:00:13 +03:00
|
|
|
{
|
2015-10-13 22:50:39 +03:00
|
|
|
free(cacheEntry);
|
2017-10-10 18:12:16 +03:00
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2014-11-17 01:00:13 +03:00
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2017-01-11 15:15:28 +03:00
|
|
|
if (!freerdp_image_copy(cacheEntry->data, cacheEntry->format, cacheEntry->scanline,
|
|
|
|
0, 0, cacheEntry->width, cacheEntry->height, surface->data,
|
|
|
|
surface->format, surface->scanline, rect->left, rect->top, NULL, FREERDP_FLIP_NONE))
|
|
|
|
{
|
|
|
|
free(cacheEntry);
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
}
|
|
|
|
|
2017-10-10 18:12:16 +03:00
|
|
|
return context->SetCacheSlotData(context, surfaceToCache->cacheSlot, (void*) cacheEntry);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_CacheToSurface(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_CACHE_TO_SURFACE_PDU* cacheToSurface)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
UINT16 index;
|
|
|
|
RDPGFX_POINT16* destPt;
|
|
|
|
gdiGfxSurface* surface;
|
|
|
|
gdiGfxCacheEntry* cacheEntry;
|
|
|
|
RECTANGLE_16 invalidRect;
|
|
|
|
rdpGdi* gdi = (rdpGdi*) context->custom;
|
2017-10-10 18:12:16 +03:00
|
|
|
|
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cacheToSurface->surfaceId);
|
|
|
|
cacheEntry = (gdiGfxCacheEntry*) context->GetCacheSlotData(context, cacheToSurface->cacheSlot);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!surface || !cacheEntry)
|
2015-06-09 16:22:26 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
for (index = 0; index < cacheToSurface->destPtsCount; index++)
|
|
|
|
{
|
|
|
|
destPt = &cacheToSurface->destPts[index];
|
2017-01-11 15:15:28 +03:00
|
|
|
|
|
|
|
if (!freerdp_image_copy(surface->data, surface->format, surface->scanline,
|
|
|
|
destPt->x, destPt->y, cacheEntry->width, cacheEntry->height,
|
|
|
|
cacheEntry->data, cacheEntry->format, cacheEntry->scanline,
|
|
|
|
0, 0, NULL, FREERDP_FLIP_NONE))
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
invalidRect.left = destPt->x;
|
|
|
|
invalidRect.top = destPt->y;
|
2017-03-31 13:06:21 +03:00
|
|
|
invalidRect.right = destPt->x + cacheEntry->width;
|
|
|
|
invalidRect.bottom = destPt->y + cacheEntry->height;
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_union_rect(&surface->invalidRegion, &surface->invalidRegion,
|
2016-07-14 17:08:06 +03:00
|
|
|
&invalidRect);
|
2017-04-25 14:58:23 +03:00
|
|
|
IFCALL(context->UpdateSurfaceArea, context, surface->surfaceId, 1, &invalidRect);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!gdi->inGfxFrame)
|
2016-04-11 15:14:17 +03:00
|
|
|
{
|
|
|
|
status = CHANNEL_RC_NOT_INITIALIZED;
|
|
|
|
IFCALLRET(context->UpdateSurfaces, status, context);
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_CacheImportReply(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_CACHE_IMPORT_REPLY_PDU* cacheImportReply)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_EvictCacheEntry(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_EVICT_CACHE_ENTRY_PDU* evictCacheEntry)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
|
|
|
gdiGfxCacheEntry* cacheEntry;
|
2016-04-11 15:14:17 +03:00
|
|
|
cacheEntry = (gdiGfxCacheEntry*) context->GetCacheSlotData(context,
|
2016-07-14 17:08:06 +03:00
|
|
|
evictCacheEntry->cacheSlot);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (cacheEntry)
|
|
|
|
{
|
|
|
|
free(cacheEntry->data);
|
|
|
|
free(cacheEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
context->SetCacheSlotData(context, evictCacheEntry->cacheSlot, NULL);
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_MapSurfaceToOutput(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU* surfaceToOutput)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2015-10-13 22:50:39 +03:00
|
|
|
gdiGfxSurface* surface;
|
2016-04-11 15:14:17 +03:00
|
|
|
surface = (gdiGfxSurface*) context->GetSurfaceData(context,
|
2016-07-14 17:08:06 +03:00
|
|
|
surfaceToOutput->surfaceId);
|
2015-10-13 22:50:39 +03:00
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
|
|
|
|
surface->outputMapped = TRUE;
|
|
|
|
surface->outputOriginX = surfaceToOutput->outputOriginX;
|
|
|
|
surface->outputOriginY = surfaceToOutput->outputOriginY;
|
|
|
|
region16_clear(&surface->invalidRegion);
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_MapSurfaceToWindow(RdpgfxClientContext* context,
|
2016-07-14 17:08:06 +03:00
|
|
|
const RDPGFX_MAP_SURFACE_TO_WINDOW_PDU* surfaceToWindow)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void gdi_graphics_pipeline_init(rdpGdi* gdi, RdpgfxClientContext* gfx)
|
|
|
|
{
|
|
|
|
gdi->gfx = gfx;
|
|
|
|
gfx->custom = (void*) gdi;
|
|
|
|
gfx->ResetGraphics = gdi_ResetGraphics;
|
|
|
|
gfx->StartFrame = gdi_StartFrame;
|
|
|
|
gfx->EndFrame = gdi_EndFrame;
|
|
|
|
gfx->SurfaceCommand = gdi_SurfaceCommand;
|
|
|
|
gfx->DeleteEncodingContext = gdi_DeleteEncodingContext;
|
|
|
|
gfx->CreateSurface = gdi_CreateSurface;
|
|
|
|
gfx->DeleteSurface = gdi_DeleteSurface;
|
|
|
|
gfx->SolidFill = gdi_SolidFill;
|
|
|
|
gfx->SurfaceToSurface = gdi_SurfaceToSurface;
|
|
|
|
gfx->SurfaceToCache = gdi_SurfaceToCache;
|
|
|
|
gfx->CacheToSurface = gdi_CacheToSurface;
|
|
|
|
gfx->CacheImportReply = gdi_CacheImportReply;
|
|
|
|
gfx->EvictCacheEntry = gdi_EvictCacheEntry;
|
|
|
|
gfx->MapSurfaceToOutput = gdi_MapSurfaceToOutput;
|
|
|
|
gfx->MapSurfaceToWindow = gdi_MapSurfaceToWindow;
|
2016-04-11 15:14:17 +03:00
|
|
|
gfx->UpdateSurfaces = gdi_UpdateSurfaces;
|
2017-02-15 17:34:50 +03:00
|
|
|
PROFILER_CREATE(gfx->SurfaceProfiler, "GFX-PROFILER");
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void gdi_graphics_pipeline_uninit(rdpGdi* gdi, RdpgfxClientContext* gfx)
|
|
|
|
{
|
|
|
|
gdi->gfx = NULL;
|
|
|
|
gfx->custom = NULL;
|
2017-02-15 17:34:50 +03:00
|
|
|
PROFILER_PRINT_HEADER;
|
|
|
|
PROFILER_PRINT(gfx->SurfaceProfiler);
|
|
|
|
PROFILER_PRINT_FOOTER;
|
|
|
|
PROFILER_FREE(gfx->SurfaceProfiler);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|