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.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2019-04-11 16:30:05 +03:00
|
|
|
#include "../core/update.h"
|
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
#include <freerdp/api.h>
|
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>
|
2022-12-16 16:43:46 +03:00
|
|
|
#include <freerdp/utils/gfx.h>
|
2024-01-23 18:49:54 +03:00
|
|
|
#include <math.h>
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2014-09-15 11:01:05 +04:00
|
|
|
#define TAG FREERDP_TAG("gdi")
|
|
|
|
|
2020-07-03 11:29:13 +03:00
|
|
|
static BOOL is_rect_valid(const RECTANGLE_16* rect, size_t width, size_t height)
|
|
|
|
{
|
|
|
|
if (!rect)
|
|
|
|
return FALSE;
|
|
|
|
if ((rect->left > rect->right) || (rect->right > width))
|
|
|
|
return FALSE;
|
|
|
|
if ((rect->top > rect->bottom) || (rect->bottom > height))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-03-12 11:12:28 +03:00
|
|
|
static BOOL is_within_surface(const gdiGfxSurface* surface, const RDPGFX_SURFACE_COMMAND* cmd)
|
|
|
|
{
|
|
|
|
RECTANGLE_16 rect;
|
|
|
|
if (!surface || !cmd)
|
|
|
|
return FALSE;
|
2022-11-08 11:07:38 +03:00
|
|
|
rect.left = (UINT16)MIN(UINT16_MAX, cmd->left);
|
|
|
|
rect.top = (UINT16)MIN(UINT16_MAX, cmd->top);
|
|
|
|
rect.right = (UINT16)MIN(UINT16_MAX, cmd->right);
|
|
|
|
rect.bottom = (UINT16)MIN(UINT16_MAX, cmd->bottom);
|
2021-03-12 11:12:28 +03:00
|
|
|
if (!is_rect_valid(&rect, surface->width, surface->height))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG,
|
2023-07-25 11:30:37 +03:00
|
|
|
"Command rect %" PRIu32 "x%" PRIu32 "-%" PRIu32 "x%" PRIu32
|
|
|
|
" not within bounds of %" PRIu32 "x%" PRIu32,
|
2023-01-23 14:03:18 +03:00
|
|
|
rect.left, rect.top, cmd->width, cmd->height, surface->width, surface->height);
|
2021-03-12 11:12:28 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
2021-06-28 13:28:50 +03:00
|
|
|
|
2021-03-12 11:12:28 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-10-31 09:56:10 +03:00
|
|
|
static DWORD gfx_align_scanline(DWORD widthInBytes, DWORD alignment)
|
|
|
|
{
|
2019-05-08 11:32:01 +03:00
|
|
|
const UINT32 align = alignment;
|
2016-10-31 09:56:10 +03:00
|
|
|
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
|
|
|
{
|
2018-10-23 12:52:06 +03:00
|
|
|
UINT rc = ERROR_INTERNAL_ERROR;
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 count = 0;
|
|
|
|
UINT32 DesktopWidth = 0;
|
|
|
|
UINT32 DesktopHeight = 0;
|
2015-10-13 22:50:39 +03:00
|
|
|
UINT16* pSurfaceIds = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpGdi* gdi = NULL;
|
|
|
|
rdpUpdate* update = NULL;
|
|
|
|
rdpSettings* settings = NULL;
|
2021-09-17 09:59:10 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(resetGraphics);
|
|
|
|
|
|
|
|
gdi = (rdpGdi*)context->custom;
|
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
|
|
|
|
update = gdi->context->update;
|
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
|
|
|
settings = gdi->context->settings;
|
|
|
|
WINPR_ASSERT(settings);
|
2018-10-23 12:52:06 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2014-09-26 06:08:10 +04:00
|
|
|
DesktopWidth = resetGraphics->width;
|
|
|
|
DesktopHeight = resetGraphics->height;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2022-05-02 11:55:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, DesktopWidth))
|
|
|
|
goto fail;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, DesktopHeight))
|
|
|
|
goto fail;
|
2014-09-26 06:08:10 +04:00
|
|
|
|
2020-12-22 15:00:54 +03:00
|
|
|
if (update)
|
2021-09-10 10:06:35 +03:00
|
|
|
{
|
|
|
|
WINPR_ASSERT(update->DesktopResize);
|
2020-12-22 15:00:54 +03:00
|
|
|
update->DesktopResize(gdi->context);
|
2021-09-10 10:06:35 +03:00
|
|
|
}
|
2014-09-26 06:08:10 +04:00
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->GetSurfaceIds);
|
2015-10-13 22:50:39 +03:00
|
|
|
context->GetSurfaceIds(context, &pSurfaceIds, &count);
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 index = 0; index < count; index++)
|
2015-10-13 22:50:39 +03:00
|
|
|
{
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
|
|
|
gdiGfxSurface* surface =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, pSurfaceIds[index]);
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2021-06-01 13:20:08 +03:00
|
|
|
if (!surface)
|
|
|
|
continue;
|
|
|
|
|
2021-06-02 18:04:32 +03:00
|
|
|
memset(surface->data, 0xFF, (size_t)surface->scanline * surface->height);
|
2015-10-13 22:50:39 +03:00
|
|
|
region16_clear(&surface->invalidRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(pSurfaceIds);
|
|
|
|
|
2021-09-21 10:56:56 +03:00
|
|
|
if (!freerdp_settings_get_bool(gdi->context->settings, FreeRDP_DeactivateClientDecoding))
|
2021-03-12 18:54:45 +03:00
|
|
|
{
|
2022-11-17 17:21:33 +03:00
|
|
|
const UINT32 width = (UINT32)MAX(0, gdi->width);
|
|
|
|
const UINT32 height = (UINT32)MAX(0, gdi->height);
|
2022-11-08 11:07:38 +03:00
|
|
|
|
|
|
|
if (!freerdp_client_codecs_reset(
|
|
|
|
context->codecs, freerdp_settings_get_codecs_flags(settings), width, height))
|
2022-10-21 10:32:15 +03:00
|
|
|
{
|
|
|
|
goto fail;
|
|
|
|
}
|
2022-11-08 11:07:38 +03:00
|
|
|
if (!freerdp_client_codecs_reset(
|
|
|
|
gdi->context->codecs, freerdp_settings_get_codecs_flags(settings), width, height))
|
2021-09-21 10:56:56 +03:00
|
|
|
{
|
|
|
|
goto fail;
|
|
|
|
}
|
2021-03-12 18:54:45 +03:00
|
|
|
}
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
rc = CHANNEL_RC_OK;
|
|
|
|
fail:
|
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
return rc;
|
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
|
|
|
{
|
2018-09-24 10:38:01 +03:00
|
|
|
UINT rc = ERROR_INTERNAL_ERROR;
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32 surfaceX = 0;
|
|
|
|
UINT32 surfaceY = 0;
|
2014-09-12 22:57:44 +04:00
|
|
|
RECTANGLE_16 surfaceRect;
|
2024-01-23 18:49:54 +03:00
|
|
|
const RECTANGLE_16* rects = NULL;
|
|
|
|
UINT32 nbRects = 0;
|
|
|
|
rdpUpdate* update = NULL;
|
2021-09-17 09:59:10 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(gdi->context);
|
|
|
|
WINPR_ASSERT(surface);
|
|
|
|
|
|
|
|
update = gdi->context->update;
|
|
|
|
WINPR_ASSERT(update);
|
2018-02-08 12:34:49 +03:00
|
|
|
|
|
|
|
if (gdi->suppressOutput)
|
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
|
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;
|
2022-11-08 11:07:38 +03:00
|
|
|
surfaceRect.right = (UINT16)MIN(UINT16_MAX, surface->mappedWidth);
|
|
|
|
surfaceRect.bottom = (UINT16)MIN(UINT16_MAX, surface->mappedHeight);
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion), &surfaceRect);
|
2024-09-02 15:57:55 +03:00
|
|
|
const double sx = surface->outputTargetWidth / (double)surface->mappedWidth;
|
|
|
|
const double sy = surface->outputTargetHeight / (double)surface->mappedHeight;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2017-03-30 16:42:13 +03:00
|
|
|
if (!(rects = region16_rects(&surface->invalidRegion, &nbRects)) || !nbRects)
|
2018-02-08 13:55:57 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2017-03-30 16:42:13 +03:00
|
|
|
|
2019-04-11 16:30:05 +03:00
|
|
|
if (!update_begin_paint(update))
|
2018-09-24 10:38:01 +03:00
|
|
|
goto fail;
|
2017-03-30 16:42:13 +03:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < nbRects; i++)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2019-05-07 11:22:02 +03:00
|
|
|
const UINT32 nXSrc = rects[i].left;
|
|
|
|
const UINT32 nYSrc = rects[i].top;
|
2019-10-25 13:57:32 +03:00
|
|
|
const UINT32 nXDst = (UINT32)MIN(surfaceX + nXSrc * sx, gdi->width - 1);
|
|
|
|
const UINT32 nYDst = (UINT32)MIN(surfaceY + nYSrc * sy, gdi->height - 1);
|
2019-05-07 11:22:02 +03:00
|
|
|
const UINT32 swidth = rects[i].right - rects[i].left;
|
|
|
|
const UINT32 sheight = rects[i].bottom - rects[i].top;
|
2019-10-25 13:57:32 +03:00
|
|
|
const UINT32 dwidth = MIN((UINT32)(swidth * sx), (UINT32)gdi->width - nXDst);
|
|
|
|
const UINT32 dheight = MIN((UINT32)(sheight * sy), (UINT32)gdi->height - nYDst);
|
2019-05-07 11:22:02 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!freerdp_image_scale(gdi->primary_buffer, gdi->dstFormat, gdi->stride, nXDst, nYDst,
|
|
|
|
dwidth, dheight, surface->data, surface->format, surface->scanline,
|
|
|
|
nXSrc, nYSrc, swidth, sheight))
|
2020-05-28 09:32:17 +03:00
|
|
|
{
|
|
|
|
rc = CHANNEL_RC_NULL_DATA;
|
|
|
|
goto fail;
|
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
gdi_InvalidateRegion(gdi->primary->hdc, (INT32)nXDst, (INT32)nYDst, (INT32)dwidth,
|
|
|
|
(INT32)dheight);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2018-09-24 10:38:01 +03:00
|
|
|
rc = CHANNEL_RC_OK;
|
|
|
|
fail:
|
2019-04-11 16:30:05 +03:00
|
|
|
|
|
|
|
if (!update_end_paint(update))
|
|
|
|
rc = ERROR_INTERNAL_ERROR;
|
|
|
|
|
2015-10-13 22:50:39 +03:00
|
|
|
region16_clear(&(surface->invalidRegion));
|
2018-09-24 10:38:01 +03:00
|
|
|
return rc;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
static UINT gdi_WindowUpdate(RdpgfxClientContext* context, gdiGfxSurface* surface)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(surface);
|
|
|
|
return IFCALLRESULT(CHANNEL_RC_OK, context->UpdateWindowFromSurface, context, surface);
|
|
|
|
}
|
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
static UINT gdi_UpdateSurfaces(RdpgfxClientContext* context)
|
2015-10-13 22:50:39 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 count = 0;
|
2018-10-23 12:52:06 +03:00
|
|
|
UINT status = ERROR_INTERNAL_ERROR;
|
2015-10-13 22:50:39 +03:00
|
|
|
UINT16* pSurfaceIds = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpGdi* gdi = NULL;
|
2021-09-17 09:59:10 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
|
|
|
|
gdi = (rdpGdi*)context->custom;
|
|
|
|
WINPR_ASSERT(gdi);
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2018-12-04 18:56:22 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceIds);
|
2015-10-13 22:50:39 +03:00
|
|
|
context->GetSurfaceIds(context, &pSurfaceIds, &count);
|
2018-10-23 12:52:06 +03:00
|
|
|
status = CHANNEL_RC_OK;
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 index = 0; index < count; index++)
|
2015-10-13 22:50:39 +03:00
|
|
|
{
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
|
|
|
gdiGfxSurface* surface =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, pSurfaceIds[index]);
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2019-05-07 11:22:02 +03:00
|
|
|
if (!surface)
|
2015-10-13 22:50:39 +03:00
|
|
|
continue;
|
|
|
|
|
2019-05-07 11:22:02 +03:00
|
|
|
/* Already handled in UpdateSurfaceArea callbacks */
|
|
|
|
if (context->UpdateSurfaceArea)
|
|
|
|
{
|
2022-11-08 11:07:38 +03:00
|
|
|
if (surface->handleInUpdateSurfaceArea)
|
2019-05-07 11:22:02 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
if (surface->outputMapped)
|
|
|
|
status = gdi_OutputUpdate(gdi, surface);
|
|
|
|
else if (surface->windowMapped)
|
|
|
|
status = gdi_WindowUpdate(context, surface);
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2016-04-11 15:14:17 +03:00
|
|
|
if (status != CHANNEL_RC_OK)
|
2015-10-13 22:50:39 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(pSurfaceIds);
|
2018-12-04 18:56:22 +03:00
|
|
|
LeaveCriticalSection(&context->mux);
|
2015-10-13 22:50:39 +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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT gdi_StartFrame(RdpgfxClientContext* context, const RDPGFX_START_FRAME_PDU* startFrame)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpGdi* gdi = NULL;
|
2021-09-17 09:59:10 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(startFrame);
|
|
|
|
|
|
|
|
gdi = (rdpGdi*)context->custom;
|
|
|
|
WINPR_ASSERT(gdi);
|
2014-09-12 22:57:44 +04:00
|
|
|
gdi->inGfxFrame = TRUE;
|
2021-02-04 08:01:38 +03:00
|
|
|
gdi->frameId = startFrame->frameId;
|
2015-06-09 16:22:26 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
static UINT gdi_call_update_surfaces(RdpgfxClientContext* context)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
return IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaces, context);
|
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT gdi_EndFrame(RdpgfxClientContext* context, const RDPGFX_END_FRAME_PDU* endFrame)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2021-09-10 10:06:35 +03:00
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(endFrame);
|
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
rdpGdi* gdi = (rdpGdi*)context->custom;
|
2021-09-10 10:06:35 +03:00
|
|
|
WINPR_ASSERT(gdi);
|
2024-05-23 10:10:59 +03:00
|
|
|
const UINT status = gdi_call_update_surfaces(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
|
|
|
}
|
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
static UINT gdi_interFrameUpdate(rdpGdi* gdi, RdpgfxClientContext* context)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
UINT status = CHANNEL_RC_OK;
|
|
|
|
if (!gdi->inGfxFrame)
|
|
|
|
status = gdi_call_update_surfaces(context);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT gdi_SurfaceCommand_Uncompressed(rdpGdi* gdi, 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;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
2014-09-12 22:57:44 +04:00
|
|
|
RECTANGLE_16 invalidRect;
|
2024-01-23 18:49:54 +03:00
|
|
|
DWORD bpp = 0;
|
|
|
|
size_t size = 0;
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cmd);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2022-11-08 11:07:38 +03:00
|
|
|
surface =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, (UINT16)MIN(UINT16_MAX, cmd->surfaceId));
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to retrieve surfaceData for surfaceId=%" PRIu32 "", cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2021-03-12 11:12:28 +03:00
|
|
|
if (!is_within_surface(surface, cmd))
|
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2022-04-28 06:43:31 +03:00
|
|
|
bpp = FreeRDPGetBytesPerPixel(cmd->format);
|
2023-08-22 10:41:28 +03:00
|
|
|
size = 1ull * bpp * cmd->width * cmd->height;
|
2021-06-28 13:28:50 +03:00
|
|
|
if (cmd->length < size)
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "Not enough data, got %" PRIu32 ", expected %" PRIuz, cmd->length, size);
|
2021-06-28 13:28:50 +03:00
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
}
|
|
|
|
|
2024-05-23 11:07:14 +03:00
|
|
|
if (!freerdp_image_copy_no_overlap(surface->data, surface->format, surface->scanline, cmd->left,
|
|
|
|
cmd->top, cmd->width, cmd->height, 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
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
invalidRect.left = (UINT16)MIN(UINT16_MAX, cmd->left);
|
|
|
|
invalidRect.top = (UINT16)MIN(UINT16_MAX, cmd->top);
|
|
|
|
invalidRect.right = (UINT16)MIN(UINT16_MAX, cmd->right);
|
|
|
|
invalidRect.bottom = (UINT16)MIN(UINT16_MAX, cmd->bottom);
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId, 1,
|
|
|
|
&invalidRect);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2017-04-19 15:43:06 +03:00
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
status = gdi_interFrameUpdate(gdi, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT gdi_SurfaceCommand_RemoteFX(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
|
|
|
{
|
2018-10-23 12:52:06 +03:00
|
|
|
UINT status = ERROR_INTERNAL_ERROR;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
2017-04-19 14:00:26 +03:00
|
|
|
REGION16 invalidRegion;
|
2024-01-23 18:49:54 +03:00
|
|
|
const RECTANGLE_16* rects = NULL;
|
|
|
|
UINT32 nrRects = 0;
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cmd);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2022-11-08 11:07:38 +03:00
|
|
|
surface =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, (UINT16)MIN(UINT16_MAX, cmd->surfaceId));
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to retrieve surfaceData for surfaceId=%" PRIu32 "", cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(surface->codecs);
|
2016-12-01 19:21:06 +03:00
|
|
|
rfx_context_set_pixel_format(surface->codecs->rfx, cmd->format);
|
2017-04-19 14:00:26 +03:00
|
|
|
region16_init(&invalidRegion);
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!rfx_process_message(surface->codecs->rfx, cmd->data, cmd->length, cmd->left, cmd->top,
|
|
|
|
surface->data, surface->format, surface->scanline, surface->height,
|
|
|
|
&invalidRegion))
|
2015-04-23 16:42:21 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to process RemoteFX message");
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
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);
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
nrRects, rects);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2017-04-19 14:00:26 +03:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 x = 0; x < nrRects; x++)
|
2017-04-19 14:00:26 +03:00
|
|
|
region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &rects[x]);
|
2017-04-19 15:43:06 +03:00
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
status = gdi_interFrameUpdate(gdi, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
|
|
|
region16_uninit(&invalidRegion);
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT gdi_SurfaceCommand_ClearCodec(rdpGdi* gdi, RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
INT32 rc = 0;
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
2014-09-12 22:57:44 +04:00
|
|
|
RECTANGLE_16 invalidRect;
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cmd);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2022-11-08 11:07:38 +03:00
|
|
|
surface =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, (UINT16)MIN(UINT16_MAX, cmd->surfaceId));
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to retrieve surfaceData for surfaceId=%" PRIu32 "", cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(surface->codecs);
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = clear_decompress(surface->codecs->clear, cmd->data, cmd->length, cmd->width, cmd->height,
|
|
|
|
surface->data, surface->format, surface->scanline, cmd->left, cmd->top,
|
2016-07-14 17:08:06 +03:00
|
|
|
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
|
|
|
{
|
2019-11-06 17:24:51 +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
|
|
|
}
|
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
invalidRect.left = (UINT16)MIN(UINT16_MAX, cmd->left);
|
|
|
|
invalidRect.top = (UINT16)MIN(UINT16_MAX, cmd->top);
|
|
|
|
invalidRect.right = (UINT16)MIN(UINT16_MAX, cmd->right);
|
|
|
|
invalidRect.bottom = (UINT16)MIN(UINT16_MAX, cmd->bottom);
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId, 1,
|
|
|
|
&invalidRect);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
status = gdi_interFrameUpdate(gdi, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
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;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
2014-09-12 22:57:44 +04:00
|
|
|
RECTANGLE_16 invalidRect;
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cmd);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2022-11-08 11:07:38 +03:00
|
|
|
surface =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, (UINT16)MIN(UINT16_MAX, cmd->surfaceId));
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to retrieve surfaceData for surfaceId=%" PRIu32 "", 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
|
|
|
|
2021-03-12 11:12:28 +03:00
|
|
|
if (!is_within_surface(surface, cmd))
|
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!planar_decompress(surface->codecs->planar, cmd->data, cmd->length, cmd->width, cmd->height,
|
|
|
|
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
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
invalidRect.left = (UINT16)MIN(UINT16_MAX, cmd->left);
|
|
|
|
invalidRect.top = (UINT16)MIN(UINT16_MAX, cmd->top);
|
|
|
|
invalidRect.right = (UINT16)MIN(UINT16_MAX, cmd->right);
|
|
|
|
invalidRect.bottom = (UINT16)MIN(UINT16_MAX, cmd->bottom);
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId, 1,
|
|
|
|
&invalidRect);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
status = gdi_interFrameUpdate(gdi, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT gdi_SurfaceCommand_AVC420(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
|
|
|
{
|
2017-07-17 11:37:15 +03:00
|
|
|
#ifdef WITH_GFX_H264
|
2024-01-23 18:49:54 +03:00
|
|
|
INT32 rc = 0;
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
|
|
|
RDPGFX_H264_METABLOCK* meta = NULL;
|
|
|
|
RDPGFX_AVC420_BITMAP_STREAM* bs = NULL;
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cmd);
|
2019-10-07 10:31:20 +03:00
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2022-11-08 11:07:38 +03:00
|
|
|
surface =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, (UINT16)MIN(UINT16_MAX, cmd->surfaceId));
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2015-10-13 22:50:39 +03:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to retrieve surfaceData for surfaceId=%" PRIu32 "", 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);
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2017-05-01 23:39:52 +03:00
|
|
|
if (!surface->h264)
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to create h264 context");
|
2017-05-01 23:39:52 +03:00
|
|
|
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
|
|
|
|
2019-10-07 10:31:20 +03:00
|
|
|
if (!surface->h264)
|
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
bs = (RDPGFX_AVC420_BITMAP_STREAM*)cmd->extra;
|
2018-02-08 13:55:57 +03:00
|
|
|
|
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,
|
2019-11-06 17:24:51 +03:00
|
|
|
surface->scanline, surface->width, surface->height, meta->regionRects,
|
2016-07-14 17:08:06 +03:00
|
|
|
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
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "avc420_decompress failure: %" PRId32 ", ignoring update.", rc);
|
2015-09-03 13:05:02 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < meta->numRegionRects; i++)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2016-04-11 15:14:17 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
2024-08-29 12:11:11 +03:00
|
|
|
&(meta->regionRects[i]));
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
meta->numRegionRects, meta->regionRects);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
status = gdi_interFrameUpdate(gdi, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
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
|
2024-01-23 18:49:54 +03:00
|
|
|
INT32 rc = 0;
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2022-11-08 11:07:38 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
|
|
|
RDPGFX_AVC444_BITMAP_STREAM* bs = NULL;
|
|
|
|
RDPGFX_AVC420_BITMAP_STREAM* avc1 = NULL;
|
|
|
|
RDPGFX_H264_METABLOCK* meta1 = NULL;
|
|
|
|
RDPGFX_AVC420_BITMAP_STREAM* avc2 = NULL;
|
|
|
|
RDPGFX_H264_METABLOCK* meta2 = NULL;
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cmd);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2022-11-08 11:07:38 +03:00
|
|
|
surface =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, (UINT16)MIN(UINT16_MAX, cmd->surfaceId));
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2016-03-02 17:16:49 +03:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to retrieve surfaceData for surfaceId=%" PRIu32 "", 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);
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2017-05-01 23:39:52 +03:00
|
|
|
if (!surface->h264)
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to create h264 context");
|
2017-05-01 23:39:52 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-10-07 10:31:20 +03:00
|
|
|
if (!surface->h264)
|
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
bs = (RDPGFX_AVC444_BITMAP_STREAM*)cmd->extra;
|
2016-03-02 17:16:49 +03:00
|
|
|
|
|
|
|
if (!bs)
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
|
|
|
|
avc1 = &bs->bitstream[0];
|
|
|
|
avc2 = &bs->bitstream[1];
|
|
|
|
meta1 = &avc1->meta;
|
|
|
|
meta2 = &avc2->meta;
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = avc444_decompress(surface->h264, bs->LC, meta1->regionRects, meta1->numRegionRects,
|
|
|
|
avc1->data, avc1->length, meta2->regionRects, meta2->numRegionRects,
|
|
|
|
avc2->data, avc2->length, surface->data, surface->format,
|
|
|
|
surface->scanline, surface->width, 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
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "avc444_decompress failure: %" PRIu32 ", ignoring update.", status);
|
2016-03-02 17:16:49 +03:00
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
}
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < meta1->numRegionRects; i++)
|
2016-03-02 17:16:49 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
|
|
|
&(meta1->regionRects[i]));
|
2016-03-02 17:16:49 +03:00
|
|
|
}
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
meta1->numRegionRects, meta1->regionRects);
|
2016-03-02 17:16:49 +03:00
|
|
|
|
2019-02-07 16:18:28 +03:00
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < meta2->numRegionRects; i++)
|
2016-03-02 17:16:49 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
|
|
|
|
&(meta2->regionRects[i]));
|
2016-03-02 17:16:49 +03:00
|
|
|
}
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
meta2->numRegionRects, meta2->regionRects);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2016-03-02 17:16:49 +03:00
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
status = gdi_interFrameUpdate(gdi, context);
|
2016-03-02 17:16:49 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
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
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL gdi_apply_alpha(BYTE* data, UINT32 format, UINT32 stride, RECTANGLE_16* rect,
|
|
|
|
UINT32 startOffsetX, UINT32 count, BYTE a)
|
2019-05-07 11:22:02 +03:00
|
|
|
{
|
|
|
|
UINT32 written = 0;
|
|
|
|
BOOL first = TRUE;
|
2022-04-28 06:43:31 +03:00
|
|
|
const UINT32 bpp = FreeRDPGetBytesPerPixel(format);
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(rect);
|
2019-05-07 11:22:02 +03:00
|
|
|
|
2024-08-26 17:33:59 +03:00
|
|
|
for (size_t y = rect->top; y < rect->bottom; y++)
|
2019-05-07 11:22:02 +03:00
|
|
|
{
|
2024-08-26 17:33:59 +03:00
|
|
|
BYTE* line = &data[y * stride];
|
2019-05-07 11:22:02 +03:00
|
|
|
|
2024-08-26 17:33:59 +03:00
|
|
|
for (size_t x = first ? rect->left + startOffsetX : rect->left; x < rect->right; x++)
|
2019-05-07 11:22:02 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE r = 0;
|
|
|
|
BYTE g = 0;
|
|
|
|
BYTE b = 0;
|
2019-05-07 11:22:02 +03:00
|
|
|
|
|
|
|
if (written == count)
|
|
|
|
return TRUE;
|
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
BYTE* src = &line[x * bpp];
|
|
|
|
UINT32 color = FreeRDPReadColor(src, format);
|
2022-04-28 06:43:31 +03:00
|
|
|
FreeRDPSplitColor(color, format, &r, &g, &b, NULL, NULL);
|
2019-05-07 11:22:02 +03:00
|
|
|
color = FreeRDPGetColor(format, r, g, b, a);
|
2022-04-28 06:43:31 +03:00
|
|
|
FreeRDPWriteColor(src, format, color);
|
2019-11-06 17:24:51 +03:00
|
|
|
written++;
|
2019-05-07 11:22:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
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;
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 alphaSig = 0;
|
|
|
|
UINT16 compressed = 0;
|
|
|
|
gdiGfxSurface* surface = NULL;
|
2014-09-12 22:57:44 +04:00
|
|
|
RECTANGLE_16 invalidRect;
|
2021-10-14 09:42:49 +03:00
|
|
|
wStream buffer;
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cmd);
|
2019-05-07 11:22:02 +03:00
|
|
|
|
2021-10-14 09:42:49 +03:00
|
|
|
s = Stream_StaticConstInit(&buffer, cmd->data, cmd->length);
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2019-05-07 11:22:02 +03:00
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2022-11-08 11:07:38 +03:00
|
|
|
surface =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, (UINT16)MIN(UINT16_MAX, cmd->surfaceId));
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to retrieve surfaceData for surfaceId=%" PRIu32 "", cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2021-03-12 11:12:28 +03:00
|
|
|
if (!is_within_surface(surface, cmd))
|
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2021-10-14 09:42:49 +03:00
|
|
|
Stream_Read_UINT16(s, alphaSig);
|
|
|
|
Stream_Read_UINT16(s, compressed);
|
2017-01-11 15:15:28 +03:00
|
|
|
|
2019-05-07 11:22:02 +03:00
|
|
|
if (alphaSig != 0x414C)
|
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
|
|
|
if (compressed == 0)
|
|
|
|
{
|
2023-01-24 16:53:36 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, cmd->height, cmd->width))
|
2019-05-07 11:22:02 +03:00
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2024-08-26 17:33:59 +03:00
|
|
|
for (size_t y = cmd->top; y < cmd->top + cmd->height; y++)
|
2019-05-07 11:22:02 +03:00
|
|
|
{
|
2024-08-26 17:33:59 +03:00
|
|
|
BYTE* line = &surface->data[y * surface->scanline];
|
2019-05-07 11:22:02 +03:00
|
|
|
|
2024-08-26 17:33:59 +03:00
|
|
|
for (size_t x = cmd->left; x < cmd->left + cmd->width; x++)
|
2019-05-07 11:22:02 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32 color = 0;
|
|
|
|
BYTE r = 0;
|
|
|
|
BYTE g = 0;
|
|
|
|
BYTE b = 0;
|
|
|
|
BYTE a = 0;
|
2022-04-28 06:43:31 +03:00
|
|
|
BYTE* src = &line[x * FreeRDPGetBytesPerPixel(surface->format)];
|
2021-10-14 09:42:49 +03:00
|
|
|
Stream_Read_UINT8(s, a);
|
2022-04-28 06:43:31 +03:00
|
|
|
color = FreeRDPReadColor(src, surface->format);
|
|
|
|
FreeRDPSplitColor(color, surface->format, &r, &g, &b, NULL, NULL);
|
2019-05-07 11:22:02 +03:00
|
|
|
color = FreeRDPGetColor(surface->format, r, g, b, a);
|
2022-04-28 06:43:31 +03:00
|
|
|
FreeRDPWriteColor(src, surface->format, color);
|
2019-05-07 11:22:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UINT32 startOffsetX = 0;
|
2022-11-08 11:07:38 +03:00
|
|
|
RECTANGLE_16 rect = { 0 };
|
|
|
|
rect.left = (UINT16)MIN(UINT16_MAX, cmd->left);
|
|
|
|
rect.top = (UINT16)MIN(UINT16_MAX, cmd->top);
|
|
|
|
rect.right = (UINT16)MIN(UINT16_MAX, cmd->left + cmd->width);
|
|
|
|
rect.bottom = (UINT16)MIN(UINT16_MAX, cmd->top + cmd->height);
|
2019-05-07 11:22:02 +03:00
|
|
|
|
|
|
|
while (rect.top < rect.bottom)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32 count = 0;
|
|
|
|
BYTE a = 0;
|
2019-05-07 11:22:02 +03:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2019-05-07 11:22:02 +03:00
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2021-10-14 09:42:49 +03:00
|
|
|
Stream_Read_UINT8(s, a);
|
|
|
|
Stream_Read_UINT8(s, count);
|
2019-05-07 11:22:02 +03:00
|
|
|
|
|
|
|
if (count >= 0xFF)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2019-05-07 11:22:02 +03:00
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2021-10-14 09:42:49 +03:00
|
|
|
Stream_Read_UINT16(s, count);
|
2019-05-07 11:22:02 +03:00
|
|
|
|
|
|
|
if (count >= 0xFFFF)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2019-05-07 11:22:02 +03:00
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2021-10-14 09:42:49 +03:00
|
|
|
Stream_Read_UINT32(s, count);
|
2019-05-07 11:22:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!gdi_apply_alpha(surface->data, surface->format, surface->scanline, &rect,
|
|
|
|
startOffsetX, count, a))
|
2019-05-07 11:22:02 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
|
|
|
|
startOffsetX += count;
|
|
|
|
|
|
|
|
while (startOffsetX >= cmd->width)
|
|
|
|
{
|
|
|
|
startOffsetX -= cmd->width;
|
|
|
|
rect.top++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
invalidRect.left = (UINT16)MIN(UINT16_MAX, cmd->left);
|
|
|
|
invalidRect.top = (UINT16)MIN(UINT16_MAX, cmd->top);
|
|
|
|
invalidRect.right = (UINT16)MIN(UINT16_MAX, cmd->right);
|
|
|
|
invalidRect.bottom = (UINT16)MIN(UINT16_MAX, cmd->bottom);
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId, 1,
|
|
|
|
&invalidRect);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2017-04-19 15:43:06 +03:00
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
status = gdi_interFrameUpdate(gdi, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2024-05-30 00:49:02 +03:00
|
|
|
#if defined(WITH_GFX_FRAME_DUMP)
|
|
|
|
static void dump_cmd(const RDPGFX_SURFACE_COMMAND* cmd, UINT32 frameId)
|
|
|
|
{
|
|
|
|
static UINT64 xxx = 0;
|
|
|
|
const char* path = "/tmp/dump/";
|
|
|
|
WINPR_ASSERT(cmd);
|
2024-06-06 00:15:22 +03:00
|
|
|
char fname[1024] = { 0 };
|
2024-05-30 00:49:02 +03:00
|
|
|
|
2024-06-06 00:15:22 +03:00
|
|
|
snprintf(fname, sizeof(fname), "%s/%08" PRIx64 ".raw", path, xxx++);
|
2024-05-30 00:49:02 +03:00
|
|
|
FILE* fp = fopen(fname, "w");
|
|
|
|
if (!fp)
|
|
|
|
return;
|
2024-09-06 09:56:12 +03:00
|
|
|
(void)fprintf(fp, "frameid: %" PRIu32 "\n", frameId);
|
|
|
|
(void)fprintf(fp, "surfaceId: %" PRIu32 "\n", cmd->surfaceId);
|
|
|
|
(void)fprintf(fp, "codecId: %" PRIu32 "\n", cmd->codecId);
|
|
|
|
(void)fprintf(fp, "contextId: %" PRIu32 "\n", cmd->contextId);
|
|
|
|
(void)fprintf(fp, "format: %" PRIu32 "\n", cmd->format);
|
|
|
|
(void)fprintf(fp, "left: %" PRIu32 "\n", cmd->left);
|
|
|
|
(void)fprintf(fp, "top: %" PRIu32 "\n", cmd->top);
|
|
|
|
(void)fprintf(fp, "right: %" PRIu32 "\n", cmd->right);
|
|
|
|
(void)fprintf(fp, "bottom: %" PRIu32 "\n", cmd->bottom);
|
|
|
|
(void)fprintf(fp, "width: %" PRIu32 "\n", cmd->width);
|
|
|
|
(void)fprintf(fp, "height: %" PRIu32 "\n", cmd->height);
|
|
|
|
(void)fprintf(fp, "length: %" PRIu32 "\n", cmd->length);
|
2024-05-30 00:49:02 +03:00
|
|
|
|
|
|
|
char* bdata = crypto_base64_encode_ex(cmd->data, cmd->length, FALSE);
|
2024-09-06 09:56:12 +03:00
|
|
|
(void)fprintf(fp, "data: %s\n", bdata);
|
2024-05-30 00:49:02 +03:00
|
|
|
free(bdata);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT gdi_SurfaceCommand_Progressive(rdpGdi* gdi, RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_SURFACE_COMMAND* cmd)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
INT32 rc = 0;
|
2016-04-11 15:14:17 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
2017-04-19 14:00:26 +03:00
|
|
|
REGION16 invalidRegion;
|
2024-01-23 18:49:54 +03:00
|
|
|
const RECTANGLE_16* rects = NULL;
|
|
|
|
UINT32 nrRects = 0;
|
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.
|
|
|
|
*/
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cmd);
|
2022-11-08 11:07:38 +03:00
|
|
|
const UINT16 surfaceId = (UINT16)MIN(UINT16_MAX, cmd->surfaceId);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2022-11-08 11:07:38 +03:00
|
|
|
surface = (gdiGfxSurface*)context->GetSurfaceData(context, surfaceId);
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2017-02-16 16:46:20 +03:00
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "unable to retrieve surfaceData for surfaceId=%" PRIu32 "", cmd->surfaceId);
|
2017-02-16 16:46:20 +03:00
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2021-03-12 11:12:28 +03:00
|
|
|
if (!is_within_surface(surface, cmd))
|
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(surface->codecs);
|
2022-11-08 11:07:38 +03:00
|
|
|
rc = progressive_create_surface_context(surface->codecs->progressive, surfaceId, surface->width,
|
|
|
|
surface->height);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-04-14 00:18:55 +03:00
|
|
|
if (rc < 0)
|
|
|
|
{
|
2019-11-06 17:24:51 +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);
|
2021-06-01 13:20:08 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = progressive_decompress(surface->codecs->progressive, cmd->data, cmd->length, surface->data,
|
|
|
|
surface->format, surface->scanline, cmd->left, cmd->top,
|
2022-11-08 11:07:38 +03:00
|
|
|
&invalidRegion, surfaceId, gdi->frameId);
|
2016-04-14 00:18:55 +03:00
|
|
|
|
|
|
|
if (rc < 0)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +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);
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
nrRects, rects);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2017-04-19 14:00:26 +03:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 x = 0; x < nrRects; x++)
|
2017-04-19 14:00:26 +03:00
|
|
|
region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &rects[x]);
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2017-04-19 15:43:06 +03:00
|
|
|
region16_uninit(&invalidRegion);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
status = gdi_interFrameUpdate(gdi, context);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT gdi_SurfaceCommand(RdpgfxClientContext* context, 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;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpGdi* gdi = NULL;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2016-08-04 17:14:12 +03:00
|
|
|
if (!context || !cmd)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
gdi = (rdpGdi*)context->custom;
|
2019-10-16 19:49:24 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2016-08-04 17:14:12 +03:00
|
|
|
WLog_Print(gdi->log, WLOG_TRACE,
|
2022-12-16 16:43:46 +03:00
|
|
|
"surfaceId=%" PRIu32 ", codec=%s [%" PRIu32 "], contextId=%" PRIu32 ", format=%s, "
|
2019-11-06 17:24:51 +03:00
|
|
|
"left=%" PRIu32 ", top=%" PRIu32 ", right=%" PRIu32 ", bottom=%" PRIu32
|
|
|
|
", width=%" PRIu32 ", height=%" PRIu32 " "
|
|
|
|
"length=%" PRIu32 ", data=%p, extra=%p",
|
2022-12-16 16:43:46 +03:00
|
|
|
cmd->surfaceId, rdpgfx_get_codec_id_string(cmd->codecId), cmd->codecId,
|
|
|
|
cmd->contextId, FreeRDPGetColorFormatName(cmd->format), cmd->left, cmd->top,
|
|
|
|
cmd->right, cmd->bottom, cmd->width, cmd->height, cmd->length, (void*)cmd->data,
|
|
|
|
(void*)cmd->extra);
|
2024-05-30 00:49:02 +03:00
|
|
|
#if defined(WITH_GFX_FRAME_DUMP)
|
|
|
|
dump_cmd(cmd, gdi->frameId);
|
|
|
|
#endif
|
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:
|
2022-12-16 16:43:46 +03:00
|
|
|
WLog_WARN(TAG, "SurfaceCommand %s [0x%08" PRIX32 "] not implemented",
|
|
|
|
rdpgfx_get_codec_id_string(cmd->codecId), cmd->codecId);
|
2016-03-01 18:39:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-12-16 16:43:46 +03:00
|
|
|
WLog_WARN(TAG, "Invalid SurfaceCommand %s [0x%08" PRIX32 "]",
|
|
|
|
rdpgfx_get_codec_id_string(cmd->codecId), cmd->codecId);
|
2014-09-12 22:57:44 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
LeaveCriticalSection(&context->mux);
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT
|
|
|
|
gdi_DeleteEncodingContext(RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_DELETE_ENCODING_CONTEXT_PDU* deleteEncodingContext)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2022-11-08 11:07:38 +03:00
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(deleteEncodingContext);
|
|
|
|
WINPR_UNUSED(context);
|
|
|
|
WINPR_UNUSED(deleteEncodingContext);
|
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
|
|
|
{
|
2018-10-23 12:52:06 +03:00
|
|
|
UINT rc = ERROR_INTERNAL_ERROR;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
|
|
|
rdpGdi* gdi = NULL;
|
2021-09-17 09:59:10 +03:00
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(createSurface);
|
2021-09-21 10:56:56 +03:00
|
|
|
gdi = (rdpGdi*)context->custom;
|
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
WINPR_ASSERT(gdi->context);
|
2018-10-23 12:52:06 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2019-11-06 17:24:51 +03:00
|
|
|
surface = (gdiGfxSurface*)calloc(1, sizeof(gdiGfxSurface));
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!surface)
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2021-09-21 10:56:56 +03:00
|
|
|
if (!freerdp_settings_get_bool(gdi->context->settings, FreeRDP_DeactivateClientDecoding))
|
2016-01-14 17:36:34 +03:00
|
|
|
{
|
2021-09-21 10:56:56 +03:00
|
|
|
WINPR_ASSERT(context->codecs);
|
|
|
|
surface->codecs = context->codecs;
|
|
|
|
|
|
|
|
if (!surface->codecs)
|
|
|
|
{
|
|
|
|
free(surface);
|
|
|
|
goto fail;
|
|
|
|
}
|
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;
|
2019-05-08 11:32:01 +03:00
|
|
|
surface->width = gfx_align_scanline(createSurface->width, 16);
|
|
|
|
surface->height = gfx_align_scanline(createSurface->height, 16);
|
|
|
|
surface->mappedWidth = createSurface->width;
|
|
|
|
surface->mappedHeight = createSurface->height;
|
|
|
|
surface->outputTargetWidth = createSurface->width;
|
|
|
|
surface->outputTargetHeight = createSurface->height;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
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);
|
2019-10-16 19:49:24 +03:00
|
|
|
goto fail;
|
2016-04-11 15:14:17 +03:00
|
|
|
}
|
2014-09-17 00:55:47 +04:00
|
|
|
|
2021-01-25 12:06:01 +03:00
|
|
|
surface->scanline = gfx_align_scanline(surface->width * 4UL, 16);
|
2023-08-22 10:41:28 +03:00
|
|
|
surface->data = (BYTE*)winpr_aligned_malloc(1ull * 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);
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2014-11-17 01:00:13 +03:00
|
|
|
}
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2021-06-02 18:04:32 +03:00
|
|
|
memset(surface->data, 0xFF, (size_t)surface->scanline * surface->height);
|
2015-10-13 22:50:39 +03:00
|
|
|
region16_init(&surface->invalidRegion);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->SetSurfaceData);
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = context->SetSurfaceData(context, surface->surfaceId, (void*)surface);
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
return rc;
|
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
|
|
|
{
|
2022-04-28 14:11:23 +03:00
|
|
|
UINT rc = CHANNEL_RC_OK;
|
2022-04-28 11:49:42 +03:00
|
|
|
UINT res = ERROR_INTERNAL_ERROR;
|
2015-10-13 22:50:39 +03:00
|
|
|
rdpCodecs* codecs = NULL;
|
|
|
|
gdiGfxSurface* surface = NULL;
|
2018-10-23 12:52:06 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2019-11-06 17:24:51 +03:00
|
|
|
surface = (gdiGfxSurface*)context->GetSurfaceData(context, deleteSurface->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (surface)
|
|
|
|
{
|
2022-11-08 11:07:38 +03:00
|
|
|
if (surface->windowMapped)
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = IFCALLRESULT(CHANNEL_RC_OK, context->UnmapWindowForSurface, context,
|
|
|
|
surface->windowId);
|
2019-05-07 11:22:02 +03:00
|
|
|
|
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;
|
2022-05-11 12:28:55 +03:00
|
|
|
winpr_aligned_free(surface->data);
|
2014-09-12 22:57:44 +04:00
|
|
|
free(surface);
|
|
|
|
}
|
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->SetSurfaceData);
|
2022-04-28 11:49:42 +03:00
|
|
|
res = context->SetSurfaceData(context, deleteSurface->surfaceId, NULL);
|
|
|
|
if (res)
|
|
|
|
rc = res;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
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
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
return rc;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2023-05-22 11:03:54 +03:00
|
|
|
static BOOL intersect_rect(const RECTANGLE_16* rect, const gdiGfxSurface* surface,
|
|
|
|
RECTANGLE_16* prect)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(rect);
|
|
|
|
WINPR_ASSERT(surface);
|
|
|
|
WINPR_ASSERT(prect);
|
|
|
|
|
|
|
|
if (rect->left > rect->right)
|
|
|
|
return FALSE;
|
|
|
|
if (rect->left > surface->width)
|
|
|
|
return FALSE;
|
|
|
|
if (rect->top > rect->bottom)
|
|
|
|
return FALSE;
|
|
|
|
if (rect->top > surface->height)
|
|
|
|
return FALSE;
|
|
|
|
prect->left = rect->left;
|
|
|
|
prect->top = rect->top;
|
|
|
|
prect->right = MIN(rect->right, surface->width);
|
|
|
|
prect->bottom = MIN(rect->bottom, surface->height);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT gdi_SolidFill(RdpgfxClientContext* context, const RDPGFX_SOLID_FILL_PDU* solidFill)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2018-10-23 12:52:06 +03:00
|
|
|
UINT status = ERROR_INTERNAL_ERROR;
|
2024-08-21 16:13:26 +03:00
|
|
|
BYTE a = 0xff;
|
2023-05-22 11:03:54 +03:00
|
|
|
RECTANGLE_16 invalidRect = { 0 };
|
2019-11-06 17:24:51 +03:00
|
|
|
rdpGdi* gdi = (rdpGdi*)context->custom;
|
2023-05-22 11:03:54 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2023-05-22 11:03:54 +03:00
|
|
|
gdiGfxSurface* surface = (gdiGfxSurface*)context->GetSurfaceData(context, solidFill->surfaceId);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!surface)
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2023-05-22 11:03:54 +03:00
|
|
|
const BYTE b = solidFill->fillPixel.B;
|
|
|
|
const BYTE g = solidFill->fillPixel.G;
|
|
|
|
const BYTE r = solidFill->fillPixel.R;
|
2024-08-21 16:13:26 +03:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* [MS-RDPEGFX] 3.3.5.4 Processing an RDPGFX_SOLIDFILL_PDU message
|
|
|
|
* https://learn.microsoft.com/en-us/windows/win32/gdi/binary-raster-operations
|
|
|
|
*
|
|
|
|
* this sounds like the alpha value is always ignored.
|
|
|
|
*/
|
2023-01-09 10:12:52 +03:00
|
|
|
if (FreeRDPColorHasAlpha(surface->format))
|
|
|
|
a = solidFill->fillPixel.XA;
|
2024-08-21 16:13:26 +03:00
|
|
|
#endif
|
|
|
|
|
2023-05-22 11:03:54 +03:00
|
|
|
const UINT32 color = FreeRDPGetColor(surface->format, r, g, b, a);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2023-05-22 11:03:54 +03:00
|
|
|
for (UINT16 index = 0; index < solidFill->fillRectCount; index++)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2023-05-22 11:03:54 +03:00
|
|
|
const RECTANGLE_16* rect = &(solidFill->fillRects[index]);
|
|
|
|
|
|
|
|
if (!intersect_rect(rect, surface, &invalidRect))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
const UINT32 nWidth = invalidRect.right - invalidRect.left;
|
|
|
|
const UINT32 nHeight = invalidRect.bottom - invalidRect.top;
|
|
|
|
|
|
|
|
if (!freerdp_image_fill(surface->data, surface->format, surface->scanline, invalidRect.left,
|
|
|
|
invalidRect.top, nWidth, nHeight, color))
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2017-01-11 15:15:28 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context, surface->surfaceId,
|
|
|
|
solidFill->fillRectCount, solidFill->fillRects);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2018-12-04 18:56:22 +03:00
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
return gdi_interFrameUpdate(gdi, context);
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
|
|
|
LeaveCriticalSection(&context->mux);
|
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
|
|
|
{
|
2018-10-23 12:52:06 +03:00
|
|
|
UINT status = ERROR_INTERNAL_ERROR;
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL sameSurface = 0;
|
|
|
|
UINT32 nWidth = 0;
|
|
|
|
UINT32 nHeight = 0;
|
|
|
|
const RECTANGLE_16* rectSrc = NULL;
|
2014-09-12 22:57:44 +04:00
|
|
|
RECTANGLE_16 invalidRect;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surfaceSrc = NULL;
|
|
|
|
gdiGfxSurface* surfaceDst = NULL;
|
2019-11-06 17:24:51 +03:00
|
|
|
rdpGdi* gdi = (rdpGdi*)context->custom;
|
2018-10-23 12:52:06 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2014-09-12 22:57:44 +04:00
|
|
|
rectSrc = &(surfaceToSurface->rectSrc);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2019-11-06 17:24:51 +03:00
|
|
|
surfaceSrc = (gdiGfxSurface*)context->GetSurfaceData(context, surfaceToSurface->surfaceIdSrc);
|
|
|
|
sameSurface =
|
|
|
|
(surfaceToSurface->surfaceIdSrc == surfaceToSurface->surfaceIdDest) ? TRUE : FALSE;
|
2014-09-17 01:41:24 +04:00
|
|
|
|
|
|
|
if (!sameSurface)
|
2019-11-06 17:24:51 +03:00
|
|
|
surfaceDst =
|
|
|
|
(gdiGfxSurface*)context->GetSurfaceData(context, surfaceToSurface->surfaceIdDest);
|
2014-09-12 22:57:44 +04:00
|
|
|
else
|
|
|
|
surfaceDst = surfaceSrc;
|
|
|
|
|
|
|
|
if (!surfaceSrc || !surfaceDst)
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2020-07-03 11:29:13 +03:00
|
|
|
if (!is_rect_valid(rectSrc, surfaceSrc->width, surfaceSrc->height))
|
|
|
|
goto fail;
|
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
nWidth = rectSrc->right - rectSrc->left;
|
|
|
|
nHeight = rectSrc->bottom - rectSrc->top;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT16 index = 0; index < surfaceToSurface->destPtsCount; index++)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2020-07-03 11:29:13 +03:00
|
|
|
const RDPGFX_POINT16* destPt = &surfaceToSurface->destPts[index];
|
2022-11-08 11:07:38 +03:00
|
|
|
const RECTANGLE_16 rect = { destPt->x, destPt->y,
|
|
|
|
(UINT16)MIN(UINT16_MAX, destPt->x + nWidth),
|
|
|
|
(UINT16)MIN(UINT16_MAX, destPt->y + nHeight) };
|
2020-07-03 11:29:13 +03:00
|
|
|
if (!is_rect_valid(&rect, surfaceDst->width, surfaceDst->height))
|
|
|
|
goto fail;
|
2017-01-11 15:15:28 +03:00
|
|
|
|
2024-10-10 17:39:57 +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))
|
|
|
|
goto fail;
|
2017-01-11 15:15:28 +03:00
|
|
|
|
2021-01-25 14:00:05 +03:00
|
|
|
invalidRect = rect;
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_union_rect(&surfaceDst->invalidRegion, &surfaceDst->invalidRegion, &invalidRect);
|
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context,
|
|
|
|
surfaceDst->surfaceId, 1, &invalidRect);
|
2018-10-23 12:52:06 +03:00
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 18:56:22 +03:00
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
return gdi_interFrameUpdate(gdi, context);
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
|
|
|
LeaveCriticalSection(&context->mux);
|
2016-04-11 15:14:17 +03:00
|
|
|
return status;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
static void gdi_GfxCacheEntryFree(gdiGfxCacheEntry* entry)
|
|
|
|
{
|
|
|
|
if (!entry)
|
|
|
|
return;
|
|
|
|
free(entry->data);
|
|
|
|
free(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gdiGfxCacheEntry* gdi_GfxCacheEntryNew(UINT64 cacheKey, UINT32 width, UINT32 height,
|
|
|
|
UINT32 format)
|
|
|
|
{
|
|
|
|
gdiGfxCacheEntry* cacheEntry = (gdiGfxCacheEntry*)calloc(1, sizeof(gdiGfxCacheEntry));
|
|
|
|
if (!cacheEntry)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
cacheEntry->cacheKey = cacheKey;
|
|
|
|
cacheEntry->width = width;
|
|
|
|
cacheEntry->height = height;
|
|
|
|
cacheEntry->format = format;
|
|
|
|
cacheEntry->scanline = gfx_align_scanline(cacheEntry->width * 4, 16);
|
|
|
|
|
|
|
|
if ((cacheEntry->width > 0) && (cacheEntry->height > 0))
|
|
|
|
{
|
|
|
|
cacheEntry->data = (BYTE*)calloc(cacheEntry->height, cacheEntry->scanline);
|
|
|
|
|
|
|
|
if (!cacheEntry->data)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
return cacheEntry;
|
|
|
|
fail:
|
|
|
|
gdi_GfxCacheEntryFree(cacheEntry);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
const RECTANGLE_16* rect = NULL;
|
|
|
|
gdiGfxSurface* surface = NULL;
|
2022-11-18 13:32:33 +03:00
|
|
|
gdiGfxCacheEntry* cacheEntry = NULL;
|
2018-10-23 12:52:06 +03:00
|
|
|
UINT rc = ERROR_INTERNAL_ERROR;
|
|
|
|
EnterCriticalSection(&context->mux);
|
2014-09-12 22:57:44 +04:00
|
|
|
rect = &(surfaceToCache->rectSrc);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2019-11-06 17:24:51 +03:00
|
|
|
surface = (gdiGfxSurface*)context->GetSurfaceData(context, surfaceToCache->surfaceId);
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!surface)
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2020-07-03 11:29:13 +03:00
|
|
|
if (!is_rect_valid(rect, surface->width, surface->height))
|
|
|
|
goto fail;
|
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
cacheEntry = gdi_GfxCacheEntryNew(surfaceToCache->cacheKey, (UINT32)(rect->right - rect->left),
|
|
|
|
(UINT32)(rect->bottom - rect->top), surface->format);
|
2018-02-08 13:55:57 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
if (!cacheEntry)
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!cacheEntry->data)
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2024-05-23 11:07:14 +03:00
|
|
|
if (!freerdp_image_copy_no_overlap(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))
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2017-01-11 15:15:28 +03:00
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
RDPGFX_EVICT_CACHE_ENTRY_PDU evict = { surfaceToCache->cacheSlot };
|
|
|
|
WINPR_ASSERT(context->EvictCacheEntry);
|
|
|
|
context->EvictCacheEntry(context, &evict);
|
|
|
|
|
|
|
|
WINPR_ASSERT(context->SetCacheSlotData);
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = context->SetCacheSlotData(context, surfaceToCache->cacheSlot, (void*)cacheEntry);
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
2022-11-18 13:32:33 +03:00
|
|
|
if (rc != CHANNEL_RC_OK)
|
|
|
|
gdi_GfxCacheEntryFree(cacheEntry);
|
2018-10-23 12:52:06 +03:00
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
return rc;
|
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
|
|
|
{
|
2018-10-23 12:52:06 +03:00
|
|
|
UINT status = ERROR_INTERNAL_ERROR;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
|
|
|
gdiGfxCacheEntry* cacheEntry = NULL;
|
2014-09-12 22:57:44 +04:00
|
|
|
RECTANGLE_16 invalidRect;
|
2019-11-06 17:24:51 +03:00
|
|
|
rdpGdi* gdi = (rdpGdi*)context->custom;
|
2022-09-14 14:53:27 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2019-11-06 17:24:51 +03:00
|
|
|
surface = (gdiGfxSurface*)context->GetSurfaceData(context, cacheToSurface->surfaceId);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetCacheSlotData);
|
2019-11-06 17:24:51 +03:00
|
|
|
cacheEntry = (gdiGfxCacheEntry*)context->GetCacheSlotData(context, cacheToSurface->cacheSlot);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
|
|
|
if (!surface || !cacheEntry)
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT16 index = 0; index < cacheToSurface->destPtsCount; index++)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2020-07-03 11:29:13 +03:00
|
|
|
const RDPGFX_POINT16* destPt = &cacheToSurface->destPts[index];
|
2022-11-08 11:07:38 +03:00
|
|
|
const RECTANGLE_16 rect = { destPt->x, destPt->y,
|
|
|
|
(UINT16)MIN(UINT16_MAX, destPt->x + cacheEntry->width),
|
|
|
|
(UINT16)MIN(UINT16_MAX, destPt->y + cacheEntry->height) };
|
2020-07-03 11:29:13 +03:00
|
|
|
|
2022-10-21 10:36:46 +03:00
|
|
|
if (rectangle_is_empty(&rect))
|
|
|
|
continue;
|
|
|
|
|
2020-07-03 11:29:13 +03:00
|
|
|
if (!is_rect_valid(&rect, surface->width, surface->height))
|
|
|
|
goto fail;
|
2017-01-11 15:15:28 +03:00
|
|
|
|
2024-05-23 11:07:14 +03:00
|
|
|
if (!freerdp_image_copy_no_overlap(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))
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2017-01-11 15:15:28 +03:00
|
|
|
|
2021-01-25 14:00:05 +03:00
|
|
|
invalidRect = rect;
|
2019-11-06 17:24:51 +03:00
|
|
|
region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &invalidRect);
|
|
|
|
status = IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaceArea, context,
|
|
|
|
surface->surfaceId, 1, &invalidRect);
|
2018-10-23 12:52:06 +03:00
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2018-12-04 18:56:22 +03:00
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
|
2024-05-23 10:10:59 +03:00
|
|
|
return gdi_interFrameUpdate(gdi, context);
|
2022-09-14 14:53:27 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
fail:
|
|
|
|
LeaveCriticalSection(&context->mux);
|
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
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 count = 0;
|
|
|
|
const UINT16* slots = NULL;
|
2022-05-30 23:32:23 +03:00
|
|
|
UINT error = CHANNEL_RC_OK;
|
|
|
|
|
|
|
|
slots = cacheImportReply->cacheSlots;
|
|
|
|
count = cacheImportReply->importedEntriesCount;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT16 index = 0; index < count; index++)
|
2022-05-30 23:32:23 +03:00
|
|
|
{
|
|
|
|
UINT16 cacheSlot = slots[index];
|
|
|
|
|
|
|
|
if (cacheSlot == 0)
|
|
|
|
continue;
|
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->GetCacheSlotData);
|
|
|
|
gdiGfxCacheEntry* cacheEntry =
|
|
|
|
(gdiGfxCacheEntry*)context->GetCacheSlotData(context, cacheSlot);
|
2022-05-30 23:32:23 +03:00
|
|
|
|
|
|
|
if (cacheEntry)
|
|
|
|
continue;
|
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
cacheEntry = gdi_GfxCacheEntryNew(cacheSlot, 0, 0, PIXEL_FORMAT_BGRX32);
|
2022-05-30 23:32:23 +03:00
|
|
|
|
|
|
|
if (!cacheEntry)
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->SetCacheSlotData);
|
2022-05-30 23:32:23 +03:00
|
|
|
error = context->SetCacheSlotData(context, cacheSlot, (void*)cacheEntry);
|
|
|
|
|
2022-06-23 08:57:38 +03:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "CacheImportReply: SetCacheSlotData failed with error %" PRIu32 "",
|
|
|
|
error);
|
2022-11-18 13:32:33 +03:00
|
|
|
gdi_GfxCacheEntryFree(cacheEntry);
|
2022-05-30 23:32:23 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2022-06-20 16:54:46 +03:00
|
|
|
static UINT gdi_ImportCacheEntry(RdpgfxClientContext* context, UINT16 cacheSlot,
|
2024-01-24 09:58:22 +03:00
|
|
|
const PERSISTENT_CACHE_ENTRY* importCacheEntry)
|
2022-05-30 23:32:23 +03:00
|
|
|
{
|
2022-11-18 13:32:33 +03:00
|
|
|
UINT error = ERROR_INTERNAL_ERROR;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxCacheEntry* cacheEntry = NULL;
|
2022-05-30 23:32:23 +03:00
|
|
|
|
|
|
|
if (cacheSlot == 0)
|
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
cacheEntry = gdi_GfxCacheEntryNew(importCacheEntry->key64, importCacheEntry->width,
|
|
|
|
importCacheEntry->height, PIXEL_FORMAT_BGRX32);
|
2022-05-30 23:32:23 +03:00
|
|
|
|
|
|
|
if (!cacheEntry)
|
2022-11-18 13:32:33 +03:00
|
|
|
goto fail;
|
2022-05-30 23:32:23 +03:00
|
|
|
|
2024-05-23 11:07:14 +03:00
|
|
|
if (!freerdp_image_copy_no_overlap(cacheEntry->data, cacheEntry->format, cacheEntry->scanline,
|
|
|
|
0, 0, cacheEntry->width, cacheEntry->height,
|
|
|
|
importCacheEntry->data, PIXEL_FORMAT_BGRX32, 0, 0, 0, NULL,
|
|
|
|
FREERDP_FLIP_NONE))
|
2022-11-18 13:32:33 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
RDPGFX_EVICT_CACHE_ENTRY_PDU evict = { cacheSlot };
|
|
|
|
WINPR_ASSERT(context->EvictCacheEntry);
|
|
|
|
error = context->EvictCacheEntry(context, &evict);
|
|
|
|
if (error != CHANNEL_RC_OK)
|
|
|
|
goto fail;
|
2022-05-30 23:32:23 +03:00
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->SetCacheSlotData);
|
2022-05-30 23:32:23 +03:00
|
|
|
error = context->SetCacheSlotData(context, cacheSlot, (void*)cacheEntry);
|
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
fail:
|
2022-05-30 23:32:23 +03:00
|
|
|
if (error)
|
2022-11-18 13:32:33 +03:00
|
|
|
{
|
|
|
|
gdi_GfxCacheEntryFree(cacheEntry);
|
2022-05-30 23:32:23 +03:00
|
|
|
WLog_ERR(TAG, "ImportCacheEntry: SetCacheSlotData failed with error %" PRIu32 "", error);
|
2022-11-18 13:32:33 +03:00
|
|
|
}
|
2022-05-30 23:32:23 +03:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2022-06-20 16:54:46 +03:00
|
|
|
static UINT gdi_ExportCacheEntry(RdpgfxClientContext* context, UINT16 cacheSlot,
|
|
|
|
PERSISTENT_CACHE_ENTRY* exportCacheEntry)
|
2022-05-30 23:32:23 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxCacheEntry* cacheEntry = NULL;
|
2022-05-30 23:32:23 +03:00
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->GetCacheSlotData);
|
2022-05-30 23:32:23 +03:00
|
|
|
cacheEntry = (gdiGfxCacheEntry*)context->GetCacheSlotData(context, cacheSlot);
|
|
|
|
|
|
|
|
if (cacheEntry)
|
|
|
|
{
|
|
|
|
exportCacheEntry->key64 = cacheEntry->cacheKey;
|
2022-11-08 11:07:38 +03:00
|
|
|
exportCacheEntry->width = (UINT16)MIN(UINT16_MAX, cacheEntry->width);
|
|
|
|
exportCacheEntry->height = (UINT16)MIN(UINT16_MAX, cacheEntry->height);
|
2022-05-30 23:32:23 +03:00
|
|
|
exportCacheEntry->size = cacheEntry->width * cacheEntry->height * 4;
|
|
|
|
exportCacheEntry->flags = 0;
|
|
|
|
exportCacheEntry->data = cacheEntry->data;
|
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxCacheEntry* cacheEntry = NULL;
|
2020-03-03 20:18:00 +03:00
|
|
|
UINT rc = ERROR_NOT_FOUND;
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(evictCacheEntry);
|
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetCacheSlotData);
|
2019-11-06 17:24:51 +03:00
|
|
|
cacheEntry = (gdiGfxCacheEntry*)context->GetCacheSlotData(context, evictCacheEntry->cacheSlot);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
gdi_GfxCacheEntryFree(cacheEntry);
|
2014-09-12 22:57:44 +04:00
|
|
|
|
2022-11-18 13:32:33 +03:00
|
|
|
WINPR_ASSERT(context->SetCacheSlotData);
|
2022-05-30 23:32:23 +03:00
|
|
|
rc = context->SetCacheSlotData(context, evictCacheEntry->cacheSlot, NULL);
|
2018-10-23 12:52:06 +03:00
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
return rc;
|
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
|
|
|
{
|
2018-10-23 12:52:06 +03:00
|
|
|
UINT rc = ERROR_INTERNAL_ERROR;
|
2022-11-08 11:07:38 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
2018-10-23 12:52:06 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2019-11-06 17:24:51 +03:00
|
|
|
surface = (gdiGfxSurface*)context->GetSurfaceData(context, surfaceToOutput->surfaceId);
|
2015-10-13 22:50:39 +03:00
|
|
|
|
|
|
|
if (!surface)
|
2018-10-23 12:52:06 +03:00
|
|
|
goto fail;
|
2015-10-13 22:50:39 +03:00
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
if (surface->windowMapped)
|
2022-11-11 08:00:21 +03:00
|
|
|
{
|
2024-07-03 16:44:59 +03:00
|
|
|
WLog_WARN(TAG, "surface already windowMapped when trying to set outputMapped");
|
2022-11-08 11:07:38 +03:00
|
|
|
goto fail;
|
2022-11-11 08:00:21 +03:00
|
|
|
}
|
2022-11-08 11:07:38 +03:00
|
|
|
|
2015-10-13 22:50:39 +03:00
|
|
|
surface->outputMapped = TRUE;
|
|
|
|
surface->outputOriginX = surfaceToOutput->outputOriginX;
|
|
|
|
surface->outputOriginY = surfaceToOutput->outputOriginY;
|
2019-05-08 11:32:01 +03:00
|
|
|
surface->outputTargetWidth = surface->mappedWidth;
|
|
|
|
surface->outputTargetHeight = surface->mappedHeight;
|
2015-10-13 22:50:39 +03:00
|
|
|
region16_clear(&surface->invalidRegion);
|
2018-10-23 12:52:06 +03:00
|
|
|
rc = CHANNEL_RC_OK;
|
|
|
|
fail:
|
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
return rc;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT
|
|
|
|
gdi_MapSurfaceToScaledOutput(RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU* surfaceToOutput)
|
2019-02-27 18:36:15 +03:00
|
|
|
{
|
|
|
|
UINT rc = ERROR_INTERNAL_ERROR;
|
2022-11-08 11:07:38 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
2019-02-27 18:36:15 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2019-11-06 17:24:51 +03:00
|
|
|
surface = (gdiGfxSurface*)context->GetSurfaceData(context, surfaceToOutput->surfaceId);
|
2019-02-27 18:36:15 +03:00
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
goto fail;
|
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
if (surface->windowMapped)
|
2022-11-11 08:00:21 +03:00
|
|
|
{
|
2024-07-03 16:44:59 +03:00
|
|
|
WLog_WARN(TAG, "surface already windowMapped when trying to set outputMapped");
|
2022-11-08 11:07:38 +03:00
|
|
|
goto fail;
|
2022-11-11 08:00:21 +03:00
|
|
|
}
|
|
|
|
|
2019-02-27 18:36:15 +03:00
|
|
|
surface->outputMapped = TRUE;
|
|
|
|
surface->outputOriginX = surfaceToOutput->outputOriginX;
|
|
|
|
surface->outputOriginY = surfaceToOutput->outputOriginY;
|
2019-05-07 11:22:02 +03:00
|
|
|
surface->outputTargetWidth = surfaceToOutput->targetWidth;
|
|
|
|
surface->outputTargetHeight = surfaceToOutput->targetHeight;
|
2019-02-27 18:36:15 +03:00
|
|
|
region16_clear(&surface->invalidRegion);
|
|
|
|
rc = CHANNEL_RC_OK;
|
|
|
|
fail:
|
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2019-05-07 11:22:02 +03:00
|
|
|
UINT rc = ERROR_INTERNAL_ERROR;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
2019-05-07 11:22:02 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2019-11-06 17:24:51 +03:00
|
|
|
surface = (gdiGfxSurface*)context->GetSurfaceData(context, surfaceToWindow->surfaceId);
|
2019-05-07 11:22:02 +03:00
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
goto fail;
|
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
if (surface->outputMapped)
|
2022-11-11 08:00:21 +03:00
|
|
|
{
|
2024-07-03 16:44:59 +03:00
|
|
|
WLog_WARN(TAG, "surface already outputMapped when trying to set windowMapped");
|
2022-11-08 11:07:38 +03:00
|
|
|
goto fail;
|
2022-11-11 08:00:21 +03:00
|
|
|
}
|
2022-11-08 11:07:38 +03:00
|
|
|
|
|
|
|
if (surface->windowMapped)
|
2019-05-07 11:22:02 +03:00
|
|
|
{
|
|
|
|
if (surface->windowId != surfaceToWindow->windowId)
|
2022-11-11 08:00:21 +03:00
|
|
|
{
|
2024-07-03 16:44:59 +03:00
|
|
|
WLog_WARN(TAG, "surface windowId mismatch, has %" PRIu64 ", expected %" PRIu64,
|
2023-01-23 14:03:18 +03:00
|
|
|
surface->windowId, surfaceToWindow->windowId);
|
2019-05-07 11:22:02 +03:00
|
|
|
goto fail;
|
2022-11-11 08:00:21 +03:00
|
|
|
}
|
2019-05-07 11:22:02 +03:00
|
|
|
}
|
2022-11-08 11:07:38 +03:00
|
|
|
surface->windowMapped = TRUE;
|
2019-05-07 11:22:02 +03:00
|
|
|
|
|
|
|
surface->windowId = surfaceToWindow->windowId;
|
2019-05-08 11:32:01 +03:00
|
|
|
surface->mappedWidth = surfaceToWindow->mappedWidth;
|
|
|
|
surface->mappedHeight = surfaceToWindow->mappedHeight;
|
2019-05-07 11:22:02 +03:00
|
|
|
surface->outputTargetWidth = surfaceToWindow->mappedWidth;
|
|
|
|
surface->outputTargetHeight = surfaceToWindow->mappedHeight;
|
|
|
|
rc = IFCALLRESULT(CHANNEL_RC_OK, context->MapWindowForSurface, context,
|
2019-11-06 17:24:51 +03:00
|
|
|
surfaceToWindow->surfaceId, surfaceToWindow->windowId);
|
2019-05-07 11:22:02 +03:00
|
|
|
fail:
|
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
return rc;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT
|
|
|
|
gdi_MapSurfaceToScaledWindow(RdpgfxClientContext* context,
|
|
|
|
const RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU* surfaceToWindow)
|
2019-02-27 18:36:15 +03:00
|
|
|
{
|
2019-05-07 11:22:02 +03:00
|
|
|
UINT rc = ERROR_INTERNAL_ERROR;
|
2024-01-23 18:49:54 +03:00
|
|
|
gdiGfxSurface* surface = NULL;
|
2019-05-07 11:22:02 +03:00
|
|
|
EnterCriticalSection(&context->mux);
|
2022-11-18 13:32:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context->GetSurfaceData);
|
2019-11-06 17:24:51 +03:00
|
|
|
surface = (gdiGfxSurface*)context->GetSurfaceData(context, surfaceToWindow->surfaceId);
|
2019-05-07 11:22:02 +03:00
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
goto fail;
|
|
|
|
|
2022-11-08 11:07:38 +03:00
|
|
|
if (surface->outputMapped)
|
2022-11-11 08:00:21 +03:00
|
|
|
{
|
2024-07-03 16:44:59 +03:00
|
|
|
WLog_WARN(TAG, "surface already outputMapped when trying to set windowMapped");
|
2022-11-08 11:07:38 +03:00
|
|
|
goto fail;
|
2022-11-11 08:00:21 +03:00
|
|
|
}
|
2022-11-08 11:07:38 +03:00
|
|
|
|
|
|
|
if (surface->windowMapped)
|
2019-05-07 11:22:02 +03:00
|
|
|
{
|
|
|
|
if (surface->windowId != surfaceToWindow->windowId)
|
2022-11-11 08:00:21 +03:00
|
|
|
{
|
2024-07-03 16:44:59 +03:00
|
|
|
WLog_WARN(TAG, "surface windowId mismatch, has %" PRIu64 ", expected %" PRIu64,
|
2023-01-23 14:03:18 +03:00
|
|
|
surface->windowId, surfaceToWindow->windowId);
|
2019-05-07 11:22:02 +03:00
|
|
|
goto fail;
|
2022-11-11 08:00:21 +03:00
|
|
|
}
|
2019-05-07 11:22:02 +03:00
|
|
|
}
|
2022-11-08 11:07:38 +03:00
|
|
|
surface->windowMapped = TRUE;
|
2019-05-07 11:22:02 +03:00
|
|
|
|
|
|
|
surface->windowId = surfaceToWindow->windowId;
|
2019-05-08 11:32:01 +03:00
|
|
|
surface->mappedWidth = surfaceToWindow->mappedWidth;
|
|
|
|
surface->mappedHeight = surfaceToWindow->mappedHeight;
|
2019-05-07 11:22:02 +03:00
|
|
|
surface->outputTargetWidth = surfaceToWindow->targetWidth;
|
|
|
|
surface->outputTargetHeight = surfaceToWindow->targetHeight;
|
|
|
|
rc = IFCALLRESULT(CHANNEL_RC_OK, context->MapWindowForSurface, context,
|
2019-11-06 17:24:51 +03:00
|
|
|
surfaceToWindow->surfaceId, surfaceToWindow->windowId);
|
2019-05-07 11:22:02 +03:00
|
|
|
fail:
|
|
|
|
LeaveCriticalSection(&context->mux);
|
|
|
|
return rc;
|
2019-02-27 18:36:15 +03:00
|
|
|
}
|
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
BOOL gdi_graphics_pipeline_init(rdpGdi* gdi, RdpgfxClientContext* gfx)
|
2019-05-07 11:22:02 +03:00
|
|
|
{
|
|
|
|
return gdi_graphics_pipeline_init_ex(gdi, gfx, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL gdi_graphics_pipeline_init_ex(rdpGdi* gdi, RdpgfxClientContext* gfx,
|
|
|
|
pcRdpgfxMapWindowForSurface map,
|
|
|
|
pcRdpgfxUnmapWindowForSurface unmap,
|
|
|
|
pcRdpgfxUpdateSurfaceArea update)
|
2014-09-12 22:57:44 +04:00
|
|
|
{
|
2020-12-01 14:35:38 +03:00
|
|
|
if (!gdi || !gfx || !gdi->context || !gdi->context->settings)
|
2018-10-23 12:52:06 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2024-07-23 10:14:04 +03:00
|
|
|
rdpContext* context = gdi->context;
|
|
|
|
rdpSettings* settings = context->settings;
|
2020-12-01 14:35:38 +03:00
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
gdi->gfx = gfx;
|
2019-11-06 17:24:51 +03:00
|
|
|
gfx->custom = (void*)gdi;
|
2014-09-12 22:57:44 +04:00
|
|
|
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;
|
2022-05-30 23:32:23 +03:00
|
|
|
gfx->ImportCacheEntry = gdi_ImportCacheEntry;
|
|
|
|
gfx->ExportCacheEntry = gdi_ExportCacheEntry;
|
2014-09-12 22:57:44 +04:00
|
|
|
gfx->EvictCacheEntry = gdi_EvictCacheEntry;
|
|
|
|
gfx->MapSurfaceToOutput = gdi_MapSurfaceToOutput;
|
|
|
|
gfx->MapSurfaceToWindow = gdi_MapSurfaceToWindow;
|
2019-02-27 18:36:15 +03:00
|
|
|
gfx->MapSurfaceToScaledOutput = gdi_MapSurfaceToScaledOutput;
|
|
|
|
gfx->MapSurfaceToScaledWindow = gdi_MapSurfaceToScaledWindow;
|
2016-04-11 15:14:17 +03:00
|
|
|
gfx->UpdateSurfaces = gdi_UpdateSurfaces;
|
2019-05-07 11:22:02 +03:00
|
|
|
gfx->MapWindowForSurface = map;
|
|
|
|
gfx->UnmapWindowForSurface = unmap;
|
|
|
|
gfx->UpdateSurfaceArea = update;
|
2021-02-08 11:35:44 +03:00
|
|
|
|
2021-09-17 09:59:10 +03:00
|
|
|
if (!freerdp_settings_get_bool(settings, FreeRDP_DeactivateClientDecoding))
|
|
|
|
{
|
2022-05-02 11:55:44 +03:00
|
|
|
const UINT32 w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
|
|
|
|
const UINT32 h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
2024-05-29 14:39:17 +03:00
|
|
|
const UINT32 flags = freerdp_settings_get_uint32(settings, FreeRDP_ThreadingFlags);
|
2022-05-02 11:55:44 +03:00
|
|
|
|
2024-05-29 14:39:17 +03:00
|
|
|
gfx->codecs = freerdp_client_codecs_new(flags);
|
2021-09-17 09:59:10 +03:00
|
|
|
if (!gfx->codecs)
|
|
|
|
return FALSE;
|
2022-05-02 11:55:44 +03:00
|
|
|
if (!freerdp_client_codecs_prepare(gfx->codecs, FREERDP_CODEC_ALL, w, h))
|
2021-09-17 09:59:10 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
2018-10-23 12:52:06 +03:00
|
|
|
InitializeCriticalSection(&gfx->mux);
|
2021-06-18 10:58:46 +03:00
|
|
|
PROFILER_CREATE(gfx->SurfaceProfiler, "GFX-PROFILER")
|
2020-02-26 14:24:21 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdi->graphicsReset will be removed in FreeRDP v3 from public headers,
|
|
|
|
* since the EGFX Reset Graphics PDU seems to be optional.
|
|
|
|
* There are still some clients that expect and check it and therefore
|
|
|
|
* we simply initialize it with TRUE here for now.
|
|
|
|
*/
|
|
|
|
gdi->graphicsReset = TRUE;
|
2021-09-17 09:59:10 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_DeactivateClientDecoding))
|
|
|
|
{
|
|
|
|
gfx->UpdateSurfaceArea = NULL;
|
|
|
|
gfx->UpdateSurfaces = NULL;
|
|
|
|
gfx->SurfaceCommand = NULL;
|
|
|
|
}
|
2020-02-26 14:24:21 +03:00
|
|
|
|
2018-10-23 12:52:06 +03:00
|
|
|
return TRUE;
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void gdi_graphics_pipeline_uninit(rdpGdi* gdi, RdpgfxClientContext* gfx)
|
|
|
|
{
|
2018-10-23 12:52:06 +03:00
|
|
|
if (gdi)
|
|
|
|
gdi->gfx = NULL;
|
|
|
|
|
|
|
|
if (!gfx)
|
|
|
|
return;
|
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
gfx->custom = NULL;
|
2024-05-29 14:39:17 +03:00
|
|
|
freerdp_client_codecs_free(gfx->codecs);
|
2021-06-30 09:52:52 +03:00
|
|
|
gfx->codecs = NULL;
|
2018-10-23 12:52:06 +03:00
|
|
|
DeleteCriticalSection(&gfx->mux);
|
2018-02-15 12:19:15 +03:00
|
|
|
PROFILER_PRINT_HEADER
|
|
|
|
PROFILER_PRINT(gfx->SurfaceProfiler)
|
|
|
|
PROFILER_PRINT_FOOTER
|
|
|
|
PROFILER_FREE(gfx->SurfaceProfiler)
|
2014-09-12 22:57:44 +04:00
|
|
|
}
|
2024-09-06 09:37:52 +03:00
|
|
|
|
|
|
|
const char* rdpgfx_caps_version_str(UINT32 capsVersion)
|
|
|
|
{
|
|
|
|
switch (capsVersion)
|
|
|
|
{
|
|
|
|
case RDPGFX_CAPVERSION_8:
|
|
|
|
return "RDPGFX_CAPVERSION_8";
|
|
|
|
case RDPGFX_CAPVERSION_81:
|
|
|
|
return "RDPGFX_CAPVERSION_81";
|
|
|
|
case RDPGFX_CAPVERSION_10:
|
|
|
|
return "RDPGFX_CAPVERSION_10";
|
|
|
|
case RDPGFX_CAPVERSION_101:
|
|
|
|
return "RDPGFX_CAPVERSION_101";
|
|
|
|
case RDPGFX_CAPVERSION_102:
|
|
|
|
return "RDPGFX_CAPVERSION_102";
|
|
|
|
case RDPGFX_CAPVERSION_103:
|
|
|
|
return "RDPGFX_CAPVERSION_103";
|
|
|
|
case RDPGFX_CAPVERSION_104:
|
|
|
|
return "RDPGFX_CAPVERSION_104";
|
|
|
|
case RDPGFX_CAPVERSION_105:
|
|
|
|
return "RDPGFX_CAPVERSION_105";
|
|
|
|
case RDPGFX_CAPVERSION_106:
|
|
|
|
return "RDPGFX_CAPVERSION_106";
|
|
|
|
case RDPGFX_CAPVERSION_106_ERR:
|
|
|
|
return "RDPGFX_CAPVERSION_106_ERR";
|
|
|
|
case RDPGFX_CAPVERSION_107:
|
|
|
|
return "RDPGFX_CAPVERSION_107";
|
|
|
|
default:
|
|
|
|
return "RDPGFX_CAPVERSION_UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|