2011-07-01 05:23:36 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-01 05:23:36 +04:00
|
|
|
* GDI Library
|
|
|
|
*
|
|
|
|
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2016-04-05 18:07:45 +03:00
|
|
|
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
|
|
|
|
* Copyright 2016 Thincast Technologies GmbH
|
2011-07-01 05:23:36 +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
|
|
|
|
*
|
2011-10-02 23:16:22 +04:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-07-01 05:23:36 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2012-08-15 01:09:01 +04:00
|
|
|
|
2012-11-22 04:22:41 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
2011-08-31 12:35:50 +04:00
|
|
|
#include <freerdp/api.h>
|
2014-09-12 16:36:29 +04:00
|
|
|
#include <freerdp/log.h>
|
2011-07-01 05:23:36 +04:00
|
|
|
#include <freerdp/freerdp.h>
|
|
|
|
|
2018-02-08 12:34:49 +03:00
|
|
|
#include <freerdp/gdi/gdi.h>
|
2011-08-22 21:08:01 +04:00
|
|
|
#include <freerdp/gdi/dc.h>
|
|
|
|
#include <freerdp/gdi/pen.h>
|
|
|
|
#include <freerdp/gdi/shape.h>
|
|
|
|
#include <freerdp/gdi/region.h>
|
|
|
|
#include <freerdp/gdi/bitmap.h>
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
#include "drawing.h"
|
|
|
|
#include "clipping.h"
|
|
|
|
#include "brush.h"
|
|
|
|
#include "line.h"
|
2011-10-21 01:28:59 +04:00
|
|
|
#include "gdi.h"
|
2016-10-10 11:38:54 +03:00
|
|
|
#include "../core/graphics.h"
|
2011-10-21 01:28:59 +04:00
|
|
|
|
2014-09-12 16:36:29 +04:00
|
|
|
#define TAG FREERDP_TAG("gdi")
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
/* Ternary Raster Operation Table */
|
2017-12-22 12:25:05 +03:00
|
|
|
typedef struct
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2017-12-22 12:25:05 +03:00
|
|
|
DWORD code;
|
|
|
|
const char* name;
|
|
|
|
} rop_table_entry;
|
|
|
|
|
|
|
|
static const rop_table_entry rop3_code_table[] =
|
|
|
|
{
|
|
|
|
{ GDI_BLACKNESS, "0" },
|
|
|
|
{ GDI_DPSoon, "DPSoon" },
|
|
|
|
{ GDI_DPSona, "DPSona" },
|
|
|
|
{ GDI_PSon, "PSon" },
|
|
|
|
{ GDI_SDPona, "SDPona" },
|
|
|
|
{ GDI_DPon, "DPon" },
|
|
|
|
{ GDI_PDSxnon, "PDSxnon" },
|
|
|
|
{ GDI_PDSaon, "PDSaon" },
|
|
|
|
{ GDI_SDPnaa, "SDPnaa" },
|
|
|
|
{ GDI_PDSxon, "PDSxon" },
|
|
|
|
{ GDI_DPna, "DPna" },
|
|
|
|
{ GDI_PSDnaon, "PSDnaon" },
|
|
|
|
{ GDI_SPna, "SPna" },
|
|
|
|
{ GDI_PDSnaon, "PDSnaon" },
|
|
|
|
{ GDI_PDSonon, "PDSonon" },
|
|
|
|
{ GDI_Pn , "Pn" },
|
|
|
|
{ GDI_PDSona, "PDSona" },
|
|
|
|
{ GDI_NOTSRCERASE, "DSon" },
|
|
|
|
{ GDI_SDPxnon, "SDPxnon" },
|
|
|
|
{ GDI_SDPaon, "SDPaon" },
|
|
|
|
{ GDI_DPSxnon, "DPSxnon" },
|
|
|
|
{ GDI_DPSaon, "DPSaon" },
|
|
|
|
{ GDI_PSDPSanaxx, "PSDPSanaxx" },
|
|
|
|
{ GDI_SSPxDSxaxn, "SSPxDSxaxn" },
|
|
|
|
{ GDI_SPxPDxa, "SPxPDxa" },
|
|
|
|
{ GDI_SDPSanaxn, "SDPSanaxn" },
|
|
|
|
{ GDI_PDSPaox, "PDSPaox" },
|
|
|
|
{ GDI_SDPSxaxn, "SDPSxaxn" },
|
|
|
|
{ GDI_PSDPaox, "PSDPaox" },
|
|
|
|
{ GDI_DSPDxaxn, "DSPDxaxn" },
|
|
|
|
{ GDI_PDSox, "PDSox" },
|
|
|
|
{ GDI_PDSoan, "PDSoan" },
|
|
|
|
{ GDI_DPSnaa, "DPSnaa" },
|
|
|
|
{ GDI_SDPxon, "SDPxon" },
|
|
|
|
{ GDI_DSna, "DSna" },
|
|
|
|
{ GDI_SPDnaon, "SPDnaon" },
|
|
|
|
{ GDI_SPxDSxa, "SPxDSxa" },
|
|
|
|
{ GDI_PDSPanaxn, "PDSPanaxn" },
|
|
|
|
{ GDI_SDPSaox, "SDPSaox" },
|
|
|
|
{ GDI_SDPSxnox, "SDPSxnox" },
|
|
|
|
{ GDI_DPSxa, "DPSxa" },
|
|
|
|
{ GDI_PSDPSaoxxn, "PSDPSaoxxn" },
|
|
|
|
{ GDI_DPSana, "DPSana" },
|
|
|
|
{ GDI_SSPxPDxaxn, "SSPxPDxaxn" },
|
|
|
|
{ GDI_SPDSoax, "SPDSoax" },
|
|
|
|
{ GDI_PSDnox, "PSDnox" },
|
|
|
|
{ GDI_PSDPxox, "PSDPxox" },
|
|
|
|
{ GDI_PSDnoan, "PSDnoan" },
|
|
|
|
{ GDI_PSna, "PSna" },
|
|
|
|
{ GDI_SDPnaon, "SDPnaon" },
|
|
|
|
{ GDI_SDPSoox, "SDPSoox" },
|
|
|
|
{ GDI_NOTSRCCOPY, "Sn" },
|
|
|
|
{ GDI_SPDSaox, "SPDSaox" },
|
|
|
|
{ GDI_SPDSxnox, "SPDSxnox" },
|
|
|
|
{ GDI_SDPox, "SDPox" },
|
|
|
|
{ GDI_SDPoan, "SDPoan" },
|
|
|
|
{ GDI_PSDPoax, "PSDPoax" },
|
|
|
|
{ GDI_SPDnox, "SPDnox" },
|
|
|
|
{ GDI_SPDSxox, "SPDSxox" },
|
|
|
|
{ GDI_SPDnoan, "SPDnoan" },
|
|
|
|
{ GDI_PSx , "PSx" },
|
|
|
|
{ GDI_SPDSonox, "SPDSonox" },
|
|
|
|
{ GDI_SPDSnaox, "SPDSnaox" },
|
|
|
|
{ GDI_PSan, "PSan" },
|
|
|
|
{ GDI_PSDnaa, "PSDnaa" },
|
|
|
|
{ GDI_DPSxon, "DPSxon" },
|
|
|
|
{ GDI_SDxPDxa, "SDxPDxa" },
|
|
|
|
{ GDI_SPDSanaxn, "SPDSanaxn" },
|
|
|
|
{ GDI_SRCERASE, "SDna" },
|
|
|
|
{ GDI_DPSnaon, "DPSnaon" },
|
|
|
|
{ GDI_DSPDaox, "DSPDaox" },
|
|
|
|
{ GDI_PSDPxaxn, "PSDPxaxn" },
|
|
|
|
{ GDI_SDPxa, "SDPxa" },
|
|
|
|
{ GDI_PDSPDaoxxn, "PDSPDaoxxn" },
|
|
|
|
{ GDI_DPSDoax, "DPSDoax" },
|
|
|
|
{ GDI_PDSnox, "PDSnox" },
|
|
|
|
{ GDI_SDPana, "SDPana" },
|
|
|
|
{ GDI_SSPxDSxoxn, "SSPxDSxoxn" },
|
|
|
|
{ GDI_PDSPxox, "PDSPxox" },
|
|
|
|
{ GDI_PDSnoan, "PDSnoan" },
|
|
|
|
{ GDI_PDna, "PDna" },
|
|
|
|
{ GDI_DSPnaon, "DSPnaon" },
|
|
|
|
{ GDI_DPSDaox, "DPSDaox" },
|
|
|
|
{ GDI_SPDSxaxn, "SPDSxaxn" },
|
|
|
|
{ GDI_DPSonon, "DPSonon" },
|
|
|
|
{ GDI_DSTINVERT, "Dn" },
|
|
|
|
{ GDI_DPSox, "DPSox" },
|
|
|
|
{ GDI_DPSoan, "DPSoan" },
|
|
|
|
{ GDI_PDSPoax, "PDSPoax" },
|
|
|
|
{ GDI_DPSnox, "DPSnox" },
|
|
|
|
{ GDI_PATINVERT, "DPx" },
|
|
|
|
{ GDI_DPSDonox, "DPSDonox" },
|
|
|
|
{ GDI_DPSDxox, "DPSDxox" },
|
|
|
|
{ GDI_DPSnoan, "DPSnoan" },
|
|
|
|
{ GDI_DPSDnaox, "DPSDnaox" },
|
|
|
|
{ GDI_DPan, "DPan" },
|
|
|
|
{ GDI_PDSxa, "PDSxa" },
|
|
|
|
{ GDI_DSPDSaoxxn, "DSPDSaoxxn" },
|
|
|
|
{ GDI_DSPDoax, "DSPDoax" },
|
|
|
|
{ GDI_SDPnox, "SDPnox" },
|
|
|
|
{ GDI_SDPSoax, "SDPSoax" },
|
|
|
|
{ GDI_DSPnox, "DSPnox" },
|
|
|
|
{ GDI_SRCINVERT, "DSx" },
|
|
|
|
{ GDI_SDPSonox, "SDPSonox" },
|
|
|
|
{ GDI_DSPDSonoxxn, "DSPDSonoxxn" },
|
|
|
|
{ GDI_PDSxxn, "PDSxxn" },
|
|
|
|
{ GDI_DPSax, "DPSax" },
|
|
|
|
{ GDI_PSDPSoaxxn, "PSDPSoaxxn" },
|
|
|
|
{ GDI_SDPax, "SDPax" },
|
|
|
|
{ GDI_PDSPDoaxxn, "PDSPDoaxxn" },
|
|
|
|
{ GDI_SDPSnoax, "SDPSnoax" },
|
|
|
|
{ GDI_PDSxnan, "PDSxnan" },
|
|
|
|
{ GDI_PDSana, "PDSana" },
|
|
|
|
{ GDI_SSDxPDxaxn, "SSDxPDxaxn" },
|
|
|
|
{ GDI_SDPSxox, "SDPSxox" },
|
|
|
|
{ GDI_SDPnoan, "SDPnoan" },
|
|
|
|
{ GDI_DSPDxox, "DSPDxox" },
|
|
|
|
{ GDI_DSPnoan, "DSPnoan" },
|
|
|
|
{ GDI_SDPSnaox, "SDPSnaox" },
|
|
|
|
{ GDI_DSan, "DSan" },
|
|
|
|
{ GDI_PDSax, "PDSax" },
|
|
|
|
{ GDI_DSPDSoaxxn, "DSPDSoaxxn" },
|
|
|
|
{ GDI_DPSDnoax, "DPSDnoax" },
|
|
|
|
{ GDI_SDPxnan, "SDPxnan" },
|
|
|
|
{ GDI_SPDSnoax, "SPDSnoax" },
|
|
|
|
{ GDI_DPSxnan, "DPSxnan" },
|
|
|
|
{ GDI_SPxDSxo, "SPxDSxo" },
|
|
|
|
{ GDI_DPSaan, "DPSaan" },
|
|
|
|
{ GDI_DPSaa, "DPSaa" },
|
|
|
|
{ GDI_SPxDSxon, "SPxDSxon" },
|
|
|
|
{ GDI_DPSxna, "DPSxna" },
|
|
|
|
{ GDI_SPDSnoaxn, "SPDSnoaxn" },
|
|
|
|
{ GDI_SDPxna, "SDPxna" },
|
|
|
|
{ GDI_PDSPnoaxn, "PDSPnoaxn" },
|
|
|
|
{ GDI_DSPDSoaxx, "DSPDSoaxx" },
|
|
|
|
{ GDI_PDSaxn, "PDSaxn" },
|
|
|
|
{ GDI_SRCAND, "DSa" },
|
|
|
|
{ GDI_SDPSnaoxn, "SDPSnaoxn" },
|
|
|
|
{ GDI_DSPnoa, "DSPnoa" },
|
|
|
|
{ GDI_DSPDxoxn, "DSPDxoxn" },
|
|
|
|
{ GDI_SDPnoa, "SDPnoa" },
|
|
|
|
{ GDI_SDPSxoxn, "SDPSxoxn" },
|
|
|
|
{ GDI_SSDxPDxax, "SSDxPDxax" },
|
|
|
|
{ GDI_PDSanan, "PDSanan" },
|
|
|
|
{ GDI_PDSxna, "PDSxna" },
|
|
|
|
{ GDI_SDPSnoaxn, "SDPSnoaxn" },
|
|
|
|
{ GDI_DPSDPoaxx, "DPSDPoaxx" },
|
|
|
|
{ GDI_SPDaxn, "SPDaxn" },
|
|
|
|
{ GDI_PSDPSoaxx, "PSDPSoaxx" },
|
|
|
|
{ GDI_DPSaxn, "DPSaxn" },
|
|
|
|
{ GDI_DPSxx, "DPSxx" },
|
|
|
|
{ GDI_PSDPSonoxx, "PSDPSonoxx" },
|
|
|
|
{ GDI_SDPSonoxn, "SDPSonoxn" },
|
|
|
|
{ GDI_DSxn, "DSxn" },
|
|
|
|
{ GDI_DPSnax, "DPSnax" },
|
|
|
|
{ GDI_SDPSoaxn, "SDPSoaxn" },
|
|
|
|
{ GDI_SPDnax, "SPDnax" },
|
|
|
|
{ GDI_DSPDoaxn, "DSPDoaxn" },
|
|
|
|
{ GDI_DSPDSaoxx, "DSPDSaoxx" },
|
|
|
|
{ GDI_PDSxan, "PDSxan" },
|
|
|
|
{ GDI_DPa , "DPa" },
|
|
|
|
{ GDI_PDSPnaoxn, "PDSPnaoxn" },
|
|
|
|
{ GDI_DPSnoa, "DPSnoa" },
|
|
|
|
{ GDI_DPSDxoxn, "DPSDxoxn" },
|
|
|
|
{ GDI_PDSPonoxn, "PDSPonoxn" },
|
|
|
|
{ GDI_PDxn, "PDxn" },
|
|
|
|
{ GDI_DSPnax, "DSPnax" },
|
|
|
|
{ GDI_PDSPoaxn, "PDSPoaxn" },
|
|
|
|
{ GDI_DPSoa, "DPSoa" },
|
|
|
|
{ GDI_DPSoxn, "DPSoxn" },
|
|
|
|
{ GDI_DSTCOPY, "D" },
|
|
|
|
{ GDI_DPSono, "DPSono" },
|
|
|
|
{ GDI_SPDSxax, "SPDSxax" },
|
|
|
|
{ GDI_DPSDaoxn, "DPSDaoxn" },
|
|
|
|
{ GDI_DSPnao, "DSPnao" },
|
|
|
|
{ GDI_DPno, "DPno" },
|
|
|
|
{ GDI_PDSnoa, "PDSnoa" },
|
|
|
|
{ GDI_PDSPxoxn, "PDSPxoxn" },
|
|
|
|
{ GDI_SSPxDSxox, "SSPxDSxox" },
|
|
|
|
{ GDI_SDPanan, "SDPanan" },
|
|
|
|
{ GDI_PSDnax, "PSDnax" },
|
|
|
|
{ GDI_DPSDoaxn, "DPSDoaxn" },
|
|
|
|
{ GDI_DPSDPaoxx, "DPSDPaoxx" },
|
|
|
|
{ GDI_SDPxan, "SDPxan" },
|
|
|
|
{ GDI_PSDPxax, "PSDPxax" },
|
|
|
|
{ GDI_DSPDaoxn, "DSPDaoxn" },
|
|
|
|
{ GDI_DPSnao, "DPSnao" },
|
|
|
|
{ GDI_MERGEPAINT, "DSno" },
|
|
|
|
{ GDI_SPDSanax, "SPDSanax" },
|
|
|
|
{ GDI_SDxPDxan, "SDxPDxan" },
|
|
|
|
{ GDI_DPSxo, "DPSxo" },
|
|
|
|
{ GDI_DPSano, "DPSano" },
|
|
|
|
{ GDI_MERGECOPY, "PSa" },
|
|
|
|
{ GDI_SPDSnaoxn, "SPDSnaoxn" },
|
|
|
|
{ GDI_SPDSonoxn, "SPDSonoxn" },
|
|
|
|
{ GDI_PSxn, "PSxn" },
|
|
|
|
{ GDI_SPDnoa, "SPDnoa" },
|
|
|
|
{ GDI_SPDSxoxn, "SPDSxoxn" },
|
|
|
|
{ GDI_SDPnax, "SDPnax" },
|
|
|
|
{ GDI_PSDPoaxn, "PSDPoaxn" },
|
|
|
|
{ GDI_SDPoa, "SDPoa" },
|
|
|
|
{ GDI_SPDoxn, "SPDoxn" },
|
|
|
|
{ GDI_DPSDxax, "DPSDxax" },
|
|
|
|
{ GDI_SPDSaoxn, "SPDSaoxn" },
|
|
|
|
{ GDI_SRCCOPY, "S" },
|
|
|
|
{ GDI_SDPono, "SDPono" },
|
|
|
|
{ GDI_SDPnao, "SDPnao" },
|
|
|
|
{ GDI_SPno, "SPno" },
|
|
|
|
{ GDI_PSDnoa, "PSDnoa" },
|
|
|
|
{ GDI_PSDPxoxn, "PSDPxoxn" },
|
|
|
|
{ GDI_PDSnax, "PDSnax" },
|
|
|
|
{ GDI_SPDSoaxn, "SPDSoaxn" },
|
|
|
|
{ GDI_SSPxPDxax, "SSPxPDxax" },
|
|
|
|
{ GDI_DPSanan, "DPSanan" },
|
|
|
|
{ GDI_PSDPSaoxx, "PSDPSaoxx" },
|
|
|
|
{ GDI_DPSxan, "DPSxan" },
|
|
|
|
{ GDI_PDSPxax, "PDSPxax" },
|
|
|
|
{ GDI_SDPSaoxn, "SDPSaoxn" },
|
|
|
|
{ GDI_DPSDanax, "DPSDanax" },
|
|
|
|
{ GDI_SPxDSxan, "SPxDSxan" },
|
|
|
|
{ GDI_SPDnao, "SPDnao" },
|
|
|
|
{ GDI_SDno, "SDno" },
|
|
|
|
{ GDI_SDPxo, "SDPxo" },
|
|
|
|
{ GDI_SDPano, "SDPano" },
|
|
|
|
{ GDI_PDSoa, "PDSoa" },
|
|
|
|
{ GDI_PDSoxn, "PDSoxn" },
|
|
|
|
{ GDI_DSPDxax, "DSPDxax" },
|
|
|
|
{ GDI_PSDPaoxn, "PSDPaoxn" },
|
|
|
|
{ GDI_SDPSxax, "SDPSxax" },
|
|
|
|
{ GDI_PDSPaoxn, "PDSPaoxn" },
|
|
|
|
{ GDI_SDPSanax, "SDPSanax" },
|
|
|
|
{ GDI_SPxPDxan, "SPxPDxan" },
|
|
|
|
{ GDI_SSPxDSxax, "SSPxDSxax" },
|
|
|
|
{ GDI_DSPDSanaxxn, "DSPDSanaxxn" },
|
|
|
|
{ GDI_DPSao, "DPSao" },
|
|
|
|
{ GDI_DPSxno, "DPSxno" },
|
|
|
|
{ GDI_SDPao, "SDPao" },
|
|
|
|
{ GDI_SDPxno, "SDPxno" },
|
|
|
|
{ GDI_SRCPAINT, "DSo" },
|
|
|
|
{ GDI_SDPnoo, "SDPnoo" },
|
|
|
|
{ GDI_PATCOPY, "P" },
|
|
|
|
{ GDI_PDSono, "PDSono" },
|
|
|
|
{ GDI_PDSnao, "PDSnao" },
|
|
|
|
{ GDI_PSno, "PSno" },
|
|
|
|
{ GDI_PSDnao, "PSDnao" },
|
|
|
|
{ GDI_PDno, "PDno" },
|
|
|
|
{ GDI_PDSxo, "PDSxo" },
|
|
|
|
{ GDI_PDSano, "PDSano" },
|
|
|
|
{ GDI_PDSao, "PDSao" },
|
|
|
|
{ GDI_PDSxno, "PDSxno" },
|
|
|
|
{ GDI_DPo , "DPo" },
|
|
|
|
{ GDI_PATPAINT, "DPSnoo" },
|
|
|
|
{ GDI_PSo , "PSo" },
|
|
|
|
{ GDI_PSDnoo, "PSDnoo" },
|
|
|
|
{ GDI_DPSoo, "DPSoo" },
|
|
|
|
{ GDI_WHITENESS, "1" }
|
2011-07-01 05:23:36 +04:00
|
|
|
};
|
|
|
|
|
2013-02-04 18:58:22 +04:00
|
|
|
/* Hatch Patterns as monochrome data */
|
2016-07-14 13:42:24 +03:00
|
|
|
static const BYTE GDI_BS_HATCHED_PATTERNS[] =
|
2014-01-29 06:46:47 +04:00
|
|
|
{
|
2013-02-04 18:58:22 +04:00
|
|
|
0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, /* HS_HORIZONTAL */
|
|
|
|
0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, /* HS_VERTICAL */
|
|
|
|
0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F, /* HS_FDIAGONAL */
|
|
|
|
0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE, /* HS_BDIAGONAL */
|
|
|
|
0xF7, 0xF7, 0xF7, 0x00, 0xF7, 0xF7, 0xF7, 0xF7, /* HS_CROSS */
|
|
|
|
0x7E, 0xBD, 0xDB, 0xE7, 0xE7, 0xDB, 0xBD, 0x7E /* HS_DIACROSS */
|
|
|
|
};
|
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
INLINE BOOL gdi_decode_color(rdpGdi* gdi, const UINT32 srcColor,
|
2016-08-04 17:58:07 +03:00
|
|
|
UINT32* color, UINT32* format)
|
2016-07-18 12:16:36 +03:00
|
|
|
{
|
2017-02-01 13:00:24 +03:00
|
|
|
UINT32 SrcFormat;
|
|
|
|
UINT32 ColorDepth;
|
|
|
|
|
|
|
|
if (!gdi || !color || !gdi->context || !gdi->context->settings)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ColorDepth = gdi->context->settings->ColorDepth;
|
|
|
|
|
|
|
|
switch (ColorDepth)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
case 24:
|
|
|
|
SrcFormat = PIXEL_FORMAT_BGR24;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
SrcFormat = PIXEL_FORMAT_RGB16;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
SrcFormat = PIXEL_FORMAT_RGB15;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
SrcFormat = PIXEL_FORMAT_RGB8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
|
|
|
|
if (format)
|
2017-02-01 13:00:24 +03:00
|
|
|
*format = gdi->dstFormat;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2017-11-24 15:19:48 +03:00
|
|
|
*color = FreeRDPConvertColor(srcColor, SrcFormat, gdi->dstFormat, &gdi->palette);
|
2016-07-18 12:16:36 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
/* GDI Helper Functions */
|
2017-12-22 12:25:05 +03:00
|
|
|
DWORD gdi_rop3_code(BYTE code)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2017-12-22 12:25:05 +03:00
|
|
|
return rop3_code_table[code].code;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* gdi_rop3_code_string(BYTE code)
|
|
|
|
{
|
|
|
|
return rop3_code_table[code].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* gdi_rop3_string(DWORD rop)
|
|
|
|
{
|
|
|
|
const size_t count = sizeof(rop3_code_table) / sizeof(rop3_code_table[0]);
|
|
|
|
size_t x;
|
|
|
|
|
|
|
|
for (x = 0; x < count; x++)
|
|
|
|
{
|
|
|
|
if (rop3_code_table[x].code == rop)
|
|
|
|
return rop3_code_table[x].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "UNKNOWN";
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
|
2016-10-14 11:01:02 +03:00
|
|
|
UINT32 gdi_get_pixel_format(UINT32 bitsPerPixel)
|
2014-09-12 04:46:15 +04:00
|
|
|
{
|
2017-02-01 13:00:24 +03:00
|
|
|
UINT32 format;
|
2014-09-12 04:46:15 +04:00
|
|
|
|
|
|
|
switch (bitsPerPixel)
|
|
|
|
{
|
|
|
|
case 32:
|
2017-02-01 13:00:24 +03:00
|
|
|
format = PIXEL_FORMAT_BGRA32;
|
2014-09-12 04:46:15 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
2016-10-14 11:01:02 +03:00
|
|
|
format = PIXEL_FORMAT_BGR24;
|
2014-09-12 04:46:15 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 16:
|
2016-10-14 11:01:02 +03:00
|
|
|
format = PIXEL_FORMAT_RGB16;
|
2014-09-12 04:46:15 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
2016-10-14 11:01:02 +03:00
|
|
|
format = PIXEL_FORMAT_RGB15;
|
2014-09-12 04:46:15 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
2016-10-14 11:01:02 +03:00
|
|
|
format = PIXEL_FORMAT_RGB8;
|
2014-09-12 04:46:15 +04:00
|
|
|
break;
|
2017-02-01 13:00:24 +03:00
|
|
|
|
|
|
|
default:
|
2017-02-06 12:31:43 +03:00
|
|
|
WLog_ERR(TAG, "Unsupported color depth %"PRIu32, bitsPerPixel);
|
2017-02-01 13:00:24 +03:00
|
|
|
format = 0;
|
|
|
|
break;
|
2014-09-12 04:46:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp,
|
2016-08-04 17:58:07 +03:00
|
|
|
BYTE* data)
|
2011-07-28 09:34:53 +04:00
|
|
|
{
|
2011-10-21 01:28:59 +04:00
|
|
|
gdiBitmap* bitmap;
|
2015-08-12 11:49:59 +03:00
|
|
|
bitmap = (gdiBitmap*) calloc(1, sizeof(gdiBitmap));
|
2014-07-08 23:07:19 +04:00
|
|
|
|
|
|
|
if (!bitmap)
|
2015-05-08 22:39:23 +03:00
|
|
|
goto fail_bitmap;
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!(bitmap->hdc = gdi_CreateCompatibleDC(gdi->hdc)))
|
|
|
|
goto fail_hdc;
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2016-07-19 14:02:08 +03:00
|
|
|
WLog_Print(gdi->log, WLOG_DEBUG, "gdi_bitmap_new: width:%d height:%d bpp:%d",
|
2016-08-04 17:58:07 +03:00
|
|
|
width, height, bpp);
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!data)
|
2011-10-21 01:28:59 +04:00
|
|
|
bitmap->bitmap = gdi_CreateCompatibleBitmap(gdi->hdc, width, height);
|
|
|
|
else
|
|
|
|
bitmap->bitmap = gdi_create_bitmap(gdi, width, height, bpp, data);
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!bitmap->bitmap)
|
|
|
|
goto fail_bitmap_bitmap;
|
|
|
|
|
2011-10-21 01:28:59 +04:00
|
|
|
gdi_SelectObject(bitmap->hdc, (HGDIOBJECT) bitmap->bitmap);
|
|
|
|
bitmap->org_bitmap = NULL;
|
|
|
|
return bitmap;
|
2015-05-08 22:39:23 +03:00
|
|
|
fail_bitmap_bitmap:
|
|
|
|
gdi_DeleteDC(bitmap->hdc);
|
|
|
|
fail_hdc:
|
|
|
|
free(bitmap);
|
|
|
|
fail_bitmap:
|
|
|
|
return NULL;
|
2011-10-21 01:28:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void gdi_bitmap_free_ex(gdiBitmap* bitmap)
|
|
|
|
{
|
2014-02-13 20:59:05 +04:00
|
|
|
if (bitmap)
|
2011-10-21 01:28:59 +04:00
|
|
|
{
|
|
|
|
gdi_SelectObject(bitmap->hdc, (HGDIOBJECT) bitmap->org_bitmap);
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) bitmap->bitmap);
|
|
|
|
gdi_DeleteDC(bitmap->hdc);
|
|
|
|
free(bitmap);
|
2011-07-28 09:34:53 +04:00
|
|
|
}
|
2011-07-28 22:32:16 +04:00
|
|
|
}
|
2011-07-28 09:34:53 +04:00
|
|
|
|
2016-07-21 11:07:42 +03:00
|
|
|
BOOL gdi_bitmap_update(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const BITMAP_UPDATE* bitmapUpdate)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
|
|
|
UINT32 index;
|
2016-07-18 18:45:30 +03:00
|
|
|
|
|
|
|
if (!context || !bitmapUpdate || !context->gdi || !context->codecs)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
for (index = 0; index < bitmapUpdate->number; index++)
|
|
|
|
{
|
2016-07-20 17:50:20 +03:00
|
|
|
const BITMAP_DATA* bitmap = &(bitmapUpdate->rectangles[index]);
|
2016-07-21 10:24:09 +03:00
|
|
|
rdpBitmap* bmp = Bitmap_Alloc(context);
|
|
|
|
|
|
|
|
if (!bmp)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Bitmap_SetDimensions(bmp, bitmap->width, bitmap->height);
|
2016-07-21 11:07:42 +03:00
|
|
|
Bitmap_SetRectangle(bmp, bitmap->destLeft, bitmap->destTop, bitmap->destRight,
|
2016-08-04 17:58:07 +03:00
|
|
|
bitmap->destBottom);
|
2016-07-21 10:24:09 +03:00
|
|
|
|
|
|
|
if (!bmp->Decompress(context, bmp, bitmap->bitmapDataStream,
|
2016-08-04 17:58:07 +03:00
|
|
|
bitmap->width, bitmap->height, bitmap->bitsPerPixel,
|
|
|
|
bitmap->bitmapLength, bitmap->compressed,
|
|
|
|
RDP_CODEC_ID_NONE))
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2016-10-10 11:38:54 +03:00
|
|
|
Bitmap_Free(context, bmp);
|
2016-07-20 16:34:06 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
2016-07-21 10:24:09 +03:00
|
|
|
|
|
|
|
if (!bmp->New(context, bmp))
|
2016-07-20 16:34:06 +03:00
|
|
|
{
|
2016-10-10 11:38:54 +03:00
|
|
|
Bitmap_Free(context, bmp);
|
2016-07-20 16:34:06 +03:00
|
|
|
return FALSE;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2016-07-21 10:24:09 +03:00
|
|
|
|
2016-07-21 11:07:42 +03:00
|
|
|
if (!bmp->Paint(context, bmp))
|
2016-04-19 23:11:12 +03:00
|
|
|
{
|
2016-10-10 11:38:54 +03:00
|
|
|
Bitmap_Free(context, bmp);
|
2016-07-20 16:34:06 +03:00
|
|
|
return FALSE;
|
2015-10-18 12:53:22 +03:00
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-10-10 11:38:54 +03:00
|
|
|
Bitmap_Free(context, bmp);
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_palette_update(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const PALETTE_UPDATE* palette)
|
2011-07-28 22:32:16 +04:00
|
|
|
{
|
2016-07-14 13:42:24 +03:00
|
|
|
UINT32 index;
|
2016-07-18 18:45:30 +03:00
|
|
|
rdpGdi* gdi;
|
|
|
|
|
|
|
|
if (!context || !palette)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gdi = context->gdi;
|
2016-04-23 12:25:55 +03:00
|
|
|
gdi->palette.format = gdi->dstFormat;
|
2014-09-18 02:30:09 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
for (index = 0; index < palette->number; index++)
|
2014-09-18 02:30:09 +04:00
|
|
|
{
|
2016-07-14 13:42:24 +03:00
|
|
|
const PALETTE_ENTRY* pe = &(palette->entries[index]);
|
2016-04-19 23:11:12 +03:00
|
|
|
gdi->palette.palette[index] =
|
2017-11-24 15:19:48 +03:00
|
|
|
FreeRDPGetColor(gdi->dstFormat, pe->red, pe->green, pe->blue, 0xFF);
|
2014-09-18 02:30:09 +04:00
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-07-28 22:32:16 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
|
2011-07-28 22:32:16 +04:00
|
|
|
{
|
2016-07-18 18:45:30 +03:00
|
|
|
rdpGdi* gdi;
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gdi = context->gdi;
|
2011-07-28 22:32:16 +04:00
|
|
|
|
2014-02-13 20:59:05 +04:00
|
|
|
if (bounds)
|
2011-07-28 22:32:16 +04:00
|
|
|
{
|
|
|
|
gdi_SetClipRgn(gdi->drawing->hdc, bounds->left, bounds->top,
|
2016-08-04 17:58:07 +03:00
|
|
|
bounds->right - bounds->left + 1, bounds->bottom - bounds->top + 1);
|
2011-07-28 22:32:16 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
gdi_SetNullClipRgn(gdi->drawing->hdc);
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-07-28 22:32:16 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2016-07-18 13:36:22 +03:00
|
|
|
rdpGdi* gdi;
|
|
|
|
|
|
|
|
if (!context || !dstblt)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gdi = context->gdi;
|
2015-06-26 15:32:38 +03:00
|
|
|
return gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
|
2016-08-04 17:58:07 +03:00
|
|
|
dstblt->nWidth, dstblt->nHeight, NULL, 0, 0,
|
|
|
|
gdi_rop3_code(dstblt->bRop), &gdi->palette);
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
|
|
|
|
2018-10-18 10:09:30 +03:00
|
|
|
static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2016-04-25 10:42:59 +03:00
|
|
|
const rdpBrush* brush = &patblt->brush;
|
2014-02-13 20:59:05 +04:00
|
|
|
UINT32 foreColor;
|
|
|
|
UINT32 backColor;
|
2016-04-05 18:07:45 +03:00
|
|
|
UINT32 originalColor;
|
2016-08-02 15:16:49 +03:00
|
|
|
HGDI_BRUSH originalBrush, hbrush = NULL;
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2016-08-02 15:16:49 +03:00
|
|
|
BOOL ret = FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
const DWORD rop = gdi_rop3_code(patblt->bRop);
|
2018-11-13 19:06:09 +03:00
|
|
|
INT32 nXSrc = 0;
|
|
|
|
INT32 nYSrc = 0;
|
2016-08-02 15:16:49 +03:00
|
|
|
BYTE data[8 * 8 * 4];
|
|
|
|
HGDI_BITMAP hBmp = NULL;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
if (!gdi_decode_color(gdi, patblt->foreColor, &foreColor, NULL))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
if (!gdi_decode_color(gdi, patblt->backColor, &backColor, NULL))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2014-02-13 20:59:05 +04:00
|
|
|
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
|
2016-08-02 15:16:49 +03:00
|
|
|
originalBrush = gdi->drawing->hdc->brush;
|
2014-02-13 20:59:05 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
switch (brush->style)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2016-07-14 13:42:24 +03:00
|
|
|
case GDI_BS_SOLID:
|
2016-08-02 15:16:49 +03:00
|
|
|
hbrush = gdi_CreateSolidBrush(foreColor);
|
2016-07-14 13:42:24 +03:00
|
|
|
break;
|
2014-10-22 05:56:10 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
case GDI_BS_HATCHED:
|
|
|
|
{
|
|
|
|
const BYTE* hatched;
|
|
|
|
hatched = GDI_BS_HATCHED_PATTERNS + (8 * brush->hatch);
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-08-02 15:16:49 +03:00
|
|
|
if (!freerdp_image_copy_from_monochrome(data, gdi->drawing->hdc->format, 0, 0,
|
2016-08-04 17:58:07 +03:00
|
|
|
0, 8, 8,
|
|
|
|
hatched, backColor, foreColor, &gdi->palette))
|
2016-07-14 13:42:24 +03:00
|
|
|
goto out_error;
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-08-02 15:16:49 +03:00
|
|
|
hBmp = gdi_CreateBitmapEx(8, 8, gdi->drawing->hdc->format, 0, data, NULL);
|
2013-02-04 18:58:22 +04:00
|
|
|
|
2016-08-02 15:16:49 +03:00
|
|
|
if (!hBmp)
|
2016-07-14 13:42:24 +03:00
|
|
|
goto out_error;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2016-08-02 15:16:49 +03:00
|
|
|
hbrush = gdi_CreateHatchBrush(hBmp);
|
2015-04-14 11:14:23 +03:00
|
|
|
}
|
2016-07-14 13:42:24 +03:00
|
|
|
break;
|
2014-10-22 05:56:10 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
case GDI_BS_PATTERN:
|
2016-04-23 12:25:55 +03:00
|
|
|
{
|
2016-07-14 13:42:24 +03:00
|
|
|
UINT32 brushFormat;
|
2014-10-22 05:56:10 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
if (brush->bpp > 1)
|
|
|
|
{
|
2017-11-20 17:00:09 +03:00
|
|
|
UINT32 bpp = brush->bpp;
|
|
|
|
|
|
|
|
if ((bpp == 16) && (context->settings->ColorDepth == 15))
|
|
|
|
bpp = 15;
|
|
|
|
|
|
|
|
brushFormat = gdi_get_pixel_format(bpp);
|
2016-07-14 13:42:24 +03:00
|
|
|
|
2016-07-15 17:23:00 +03:00
|
|
|
if (!freerdp_image_copy(data, gdi->drawing->hdc->format, 0, 0, 0,
|
2016-08-04 17:58:07 +03:00
|
|
|
8, 8, brush->data, brushFormat, 0, 0, 0,
|
2016-10-14 11:01:02 +03:00
|
|
|
&gdi->palette, FREERDP_FLIP_NONE))
|
2016-07-14 13:42:24 +03:00
|
|
|
goto out_error;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-15 17:23:00 +03:00
|
|
|
if (!freerdp_image_copy_from_monochrome(data, gdi->drawing->hdc->format, 0, 0,
|
2016-08-04 17:58:07 +03:00
|
|
|
0, 8, 8,
|
|
|
|
brush->data, backColor, foreColor, &gdi->palette))
|
2016-07-14 13:42:24 +03:00
|
|
|
goto out_error;
|
|
|
|
}
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2016-08-02 15:16:49 +03:00
|
|
|
hBmp = gdi_CreateBitmapEx(8, 8, gdi->drawing->hdc->format, 0, data, NULL);
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
if (!hBmp)
|
|
|
|
goto out_error;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2016-08-02 15:16:49 +03:00
|
|
|
hbrush = gdi_CreatePatternBrush(hBmp);
|
2016-07-14 13:42:24 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "unimplemented brush style:%"PRIu32"", brush->style);
|
2016-07-14 13:42:24 +03:00
|
|
|
break;
|
2011-08-04 11:39:10 +04:00
|
|
|
}
|
2014-02-13 20:59:05 +04:00
|
|
|
|
2018-10-16 09:45:06 +03:00
|
|
|
if (hbrush)
|
2016-08-02 15:16:49 +03:00
|
|
|
{
|
|
|
|
hbrush->nXOrg = brush->x;
|
|
|
|
hbrush->nYOrg = brush->y;
|
|
|
|
gdi->drawing->hdc->brush = hbrush;
|
2016-08-05 20:38:46 +03:00
|
|
|
ret = gdi_BitBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
|
|
|
|
patblt->nWidth, patblt->nHeight,
|
|
|
|
gdi->primary->hdc, nXSrc, nYSrc, rop, &gdi->palette);
|
2016-08-02 15:16:49 +03:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
out_error:
|
2018-10-16 09:45:06 +03:00
|
|
|
gdi_DeleteObject((HGDIOBJECT) hBmp);
|
2016-08-02 15:16:49 +03:00
|
|
|
gdi_DeleteObject((HGDIOBJECT) hbrush);
|
|
|
|
gdi->drawing->hdc->brush = originalBrush;
|
2014-02-13 20:59:05 +04:00
|
|
|
gdi_SetTextColor(gdi->drawing->hdc, originalColor);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2016-07-18 18:45:30 +03:00
|
|
|
rdpGdi* gdi;
|
|
|
|
|
|
|
|
if (!context || !context->gdi)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gdi = context->gdi;
|
2015-06-26 15:32:38 +03:00
|
|
|
return gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
|
2016-08-04 17:58:07 +03:00
|
|
|
scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
|
|
|
|
scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop),
|
|
|
|
&gdi->palette);
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_opaque_rect(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const OPAQUE_RECT_ORDER* opaque_rect)
|
2011-07-28 22:32:16 +04:00
|
|
|
{
|
|
|
|
GDI_RECT rect;
|
|
|
|
HGDI_BRUSH hBrush;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 brush_color;
|
2014-02-13 20:59:05 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2015-06-26 15:32:38 +03:00
|
|
|
BOOL ret;
|
2018-10-22 15:12:22 +03:00
|
|
|
INT32 x = opaque_rect->nLeftRect;
|
|
|
|
INT32 y = opaque_rect->nTopRect;
|
|
|
|
INT32 w = opaque_rect->nWidth;
|
|
|
|
INT32 h = opaque_rect->nHeight;
|
|
|
|
gdi_ClipCoords(gdi->drawing->hdc, &x, &y, &w, &h, NULL, NULL);
|
|
|
|
gdi_CRgnToRect(x, y, w, h, &rect);
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
if (!gdi_decode_color(gdi, opaque_rect->color, &brush_color, NULL))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
2011-07-28 22:32:16 +04:00
|
|
|
|
2015-06-26 15:32:38 +03:00
|
|
|
if (!(hBrush = gdi_CreateSolidBrush(brush_color)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ret = gdi_FillRect(gdi->drawing->hdc, &rect, hBrush);
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) hBrush);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-07-28 09:34:53 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_multi_opaque_rect(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
UINT32 i;
|
2011-08-04 01:09:12 +04:00
|
|
|
GDI_RECT rect;
|
|
|
|
HGDI_BRUSH hBrush;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 brush_color;
|
2014-02-13 20:59:05 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = TRUE;
|
2011-08-04 01:09:12 +04:00
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
if (!gdi_decode_color(gdi, multi_opaque_rect->color, &brush_color, NULL))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hBrush = gdi_CreateSolidBrush(brush_color);
|
|
|
|
|
|
|
|
if (!hBrush)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-07-19 14:02:08 +03:00
|
|
|
for (i = 0; i < multi_opaque_rect->numRectangles; i++)
|
2011-08-04 01:09:12 +04:00
|
|
|
{
|
2016-07-18 12:16:36 +03:00
|
|
|
const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i];
|
2018-10-22 15:12:22 +03:00
|
|
|
INT32 x = rectangle->left;
|
|
|
|
INT32 y = rectangle->top;
|
|
|
|
INT32 w = rectangle->width;
|
|
|
|
INT32 h = rectangle->height;
|
|
|
|
gdi_ClipCoords(gdi->drawing->hdc, &x, &y, &w, &h, NULL, NULL);
|
|
|
|
gdi_CRgnToRect(x, y, w, h, &rect);
|
2016-07-19 14:02:08 +03:00
|
|
|
ret = gdi_FillRect(gdi->drawing->hdc, &rect, hBrush);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
break;
|
2011-08-13 12:52:05 +04:00
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-07-18 12:16:36 +03:00
|
|
|
gdi_DeleteObject((HGDIOBJECT) hBrush);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_line_to(rdpContext* context, const LINE_TO_ORDER* lineTo)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 color;
|
2011-08-03 11:29:56 +04:00
|
|
|
HGDI_PEN hPen;
|
2014-02-13 20:59:05 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2018-11-19 19:24:24 +03:00
|
|
|
INT32 xStart = lineTo->nXStart;
|
|
|
|
INT32 yStart = lineTo->nYStart;
|
|
|
|
INT32 xEnd = lineTo->nXEnd;
|
|
|
|
INT32 yEnd = lineTo->nYEnd;
|
|
|
|
INT32 w = 0;
|
|
|
|
INT32 h = 0;
|
|
|
|
gdi_ClipCoords(gdi->drawing->hdc, &xStart, &yStart, &w, &h, NULL, NULL);
|
|
|
|
gdi_ClipCoords(gdi->drawing->hdc, &xEnd, &yEnd, &w, &h, NULL, NULL);
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2017-01-09 18:35:34 +03:00
|
|
|
if (!gdi_decode_color(gdi, lineTo->penColor, &color, NULL))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
if (!(hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, color,
|
2016-11-14 11:36:16 +03:00
|
|
|
gdi->drawing->hdc->format, &gdi->palette)))
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
2015-06-26 15:32:38 +03:00
|
|
|
|
2015-04-26 23:28:49 +03:00
|
|
|
gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
|
2014-02-13 20:59:05 +04:00
|
|
|
gdi_SetROP2(gdi->drawing->hdc, lineTo->bRop2);
|
|
|
|
gdi_MoveToEx(gdi->drawing->hdc, lineTo->nXStart, lineTo->nYStart, NULL);
|
|
|
|
gdi_LineTo(gdi->drawing->hdc, lineTo->nXEnd, lineTo->nYEnd);
|
2011-08-03 11:29:56 +04:00
|
|
|
gdi_DeleteObject((HGDIOBJECT) hPen);
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
|
2011-08-05 00:22:15 +04:00
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
UINT32 i;
|
2014-02-13 20:59:05 +04:00
|
|
|
INT32 x;
|
|
|
|
INT32 y;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 color;
|
2011-08-05 00:22:15 +04:00
|
|
|
HGDI_PEN hPen;
|
|
|
|
DELTA_POINT* points;
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2018-11-19 19:24:24 +03:00
|
|
|
INT32 w = 0, h = 0;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2016-11-14 11:36:16 +03:00
|
|
|
if (!gdi_decode_color(gdi, polyline->penColor, &color, NULL))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
2011-08-05 00:22:15 +04:00
|
|
|
|
2016-11-14 11:36:16 +03:00
|
|
|
if (!(hPen = gdi_CreatePen(GDI_PS_SOLID, 1, color, gdi->drawing->hdc->format,
|
|
|
|
&gdi->palette)))
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
2015-06-26 15:32:38 +03:00
|
|
|
|
2011-08-05 00:22:15 +04:00
|
|
|
gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
|
|
|
|
gdi_SetROP2(gdi->drawing->hdc, polyline->bRop2);
|
2011-12-02 07:59:23 +04:00
|
|
|
x = polyline->xStart;
|
|
|
|
y = polyline->yStart;
|
2018-11-19 19:24:24 +03:00
|
|
|
gdi_ClipCoords(gdi->drawing->hdc, &x, &y, &w, &h, NULL, NULL);
|
2011-12-02 07:59:23 +04:00
|
|
|
gdi_MoveToEx(gdi->drawing->hdc, x, y, NULL);
|
2011-08-05 00:22:15 +04:00
|
|
|
points = polyline->points;
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-07-19 14:02:08 +03:00
|
|
|
for (i = 0; i < polyline->numDeltaEntries; i++)
|
2011-08-05 00:22:15 +04:00
|
|
|
{
|
2011-12-02 07:59:23 +04:00
|
|
|
x += points[i].x;
|
|
|
|
y += points[i].y;
|
2018-11-19 19:24:24 +03:00
|
|
|
gdi_ClipCoords(gdi->drawing->hdc, &x, &y, &w, &h, NULL, NULL);
|
2011-12-02 07:59:23 +04:00
|
|
|
gdi_LineTo(gdi->drawing->hdc, x, y);
|
|
|
|
gdi_MoveToEx(gdi->drawing->hdc, x, y, NULL);
|
2011-08-05 00:22:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) hPen);
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-08-05 00:22:15 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
|
2011-10-05 05:29:01 +04:00
|
|
|
{
|
2016-07-18 18:45:30 +03:00
|
|
|
gdiBitmap* bitmap;
|
|
|
|
rdpGdi* gdi;
|
|
|
|
|
|
|
|
if (!context || !memblt || !context->gdi || !memblt->bitmap)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
bitmap = (gdiBitmap*) memblt->bitmap;
|
|
|
|
gdi = context->gdi;
|
2015-06-26 15:32:38 +03:00
|
|
|
return gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
|
2016-08-04 17:58:07 +03:00
|
|
|
memblt->nWidth, memblt->nHeight, bitmap->hdc,
|
|
|
|
memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop),
|
|
|
|
&gdi->palette);
|
2011-10-05 05:29:01 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
|
2011-10-05 05:29:01 +04:00
|
|
|
{
|
2012-02-13 04:41:39 +04:00
|
|
|
HGDI_BRUSH originalBrush;
|
|
|
|
rdpGdi* gdi = context->gdi;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = TRUE;
|
2016-07-14 13:42:24 +03:00
|
|
|
const rdpBrush* brush = &mem3blt->brush;
|
|
|
|
gdiBitmap* bitmap = (gdiBitmap*) mem3blt->bitmap;
|
2016-07-18 12:16:36 +03:00
|
|
|
UINT32 foreColor;
|
|
|
|
UINT32 backColor;
|
|
|
|
UINT32 originalColor;
|
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
if (!gdi_decode_color(gdi, mem3blt->foreColor, &foreColor, NULL))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
if (!gdi_decode_color(gdi, mem3blt->backColor, &backColor, NULL))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
|
2016-07-14 13:42:24 +03:00
|
|
|
|
|
|
|
switch (brush->style)
|
2013-02-04 20:40:40 +04:00
|
|
|
{
|
2016-07-14 13:42:24 +03:00
|
|
|
case GDI_BS_SOLID:
|
|
|
|
originalBrush = gdi->drawing->hdc->brush;
|
|
|
|
gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
|
2013-02-04 20:40:40 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
if (!gdi->drawing->hdc->brush)
|
2015-04-14 11:14:23 +03:00
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2014-10-22 05:56:10 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
ret = gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
|
2016-08-04 17:58:07 +03:00
|
|
|
mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
|
|
|
|
mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
|
|
|
|
&gdi->palette);
|
2016-07-14 13:42:24 +03:00
|
|
|
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
|
|
|
|
gdi->drawing->hdc->brush = originalBrush;
|
|
|
|
break;
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
case GDI_BS_PATTERN:
|
2015-04-14 11:14:23 +03:00
|
|
|
{
|
2016-07-14 13:42:24 +03:00
|
|
|
HGDI_BITMAP hBmp;
|
|
|
|
UINT32 brushFormat;
|
2016-07-18 12:16:36 +03:00
|
|
|
BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(
|
2016-08-04 17:58:07 +03:00
|
|
|
gdi->drawing->hdc->format),
|
|
|
|
16);
|
2014-10-22 05:56:10 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2013-02-04 20:40:40 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
if (brush->bpp > 1)
|
|
|
|
{
|
2017-11-20 17:00:09 +03:00
|
|
|
UINT32 bpp = brush->bpp;
|
|
|
|
|
|
|
|
if ((bpp == 16) && (context->settings->ColorDepth == 15))
|
|
|
|
bpp = 15;
|
|
|
|
|
|
|
|
brushFormat = gdi_get_pixel_format(bpp);
|
2016-07-14 13:42:24 +03:00
|
|
|
|
2016-07-18 12:16:36 +03:00
|
|
|
if (!freerdp_image_copy(data, gdi->drawing->hdc->format, 0, 0, 0,
|
2016-08-04 17:58:07 +03:00
|
|
|
8, 8, brush->data, brushFormat,
|
2016-10-14 11:01:02 +03:00
|
|
|
0, 0, 0, &gdi->palette, FREERDP_FLIP_NONE))
|
2016-07-14 13:42:24 +03:00
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
_aligned_free(data);
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-18 12:16:36 +03:00
|
|
|
if (!freerdp_image_copy_from_monochrome(data, gdi->drawing->hdc->format, 0, 0,
|
2016-08-04 17:58:07 +03:00
|
|
|
0, 8, 8,
|
|
|
|
brush->data, backColor, foreColor,
|
|
|
|
&gdi->palette))
|
2016-07-14 13:42:24 +03:00
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
_aligned_free(data);
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
|
2013-02-04 20:40:40 +04:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
if (!hBmp)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
_aligned_free(data);
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
originalBrush = gdi->drawing->hdc->brush;
|
|
|
|
gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-07-14 13:42:24 +03:00
|
|
|
if (!gdi->drawing->hdc->brush)
|
|
|
|
{
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) hBmp);
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdi->drawing->hdc->brush->nXOrg = brush->x;
|
|
|
|
gdi->drawing->hdc->brush->nYOrg = brush->y;
|
|
|
|
ret = gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
|
2016-08-04 17:58:07 +03:00
|
|
|
mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
|
|
|
|
mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
|
|
|
|
&gdi->palette);
|
2016-07-14 13:42:24 +03:00
|
|
|
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
|
2018-10-16 09:45:06 +03:00
|
|
|
gdi_DeleteObject((HGDIOBJECT) hBmp);
|
2016-07-14 13:42:24 +03:00
|
|
|
gdi->drawing->hdc->brush = originalBrush;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%"PRIu32"", brush->style);
|
2016-07-14 13:42:24 +03:00
|
|
|
break;
|
2012-02-13 04:41:39 +04:00
|
|
|
}
|
2014-02-12 03:02:26 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
out_fail:
|
2014-02-12 03:02:26 +04:00
|
|
|
gdi_SetTextColor(gdi->drawing->hdc, originalColor);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2012-02-13 00:21:08 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_polygon_sc(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const POLYGON_SC_ORDER* polygon_sc)
|
2012-02-13 00:21:08 +04:00
|
|
|
{
|
2016-07-19 14:02:08 +03:00
|
|
|
WLog_WARN(TAG, "%s: not implemented", __FUNCTION__);
|
|
|
|
return FALSE;
|
2012-02-13 00:21:08 +04:00
|
|
|
}
|
2011-10-05 05:29:01 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
|
2012-02-13 00:21:08 +04:00
|
|
|
{
|
2016-07-19 14:02:08 +03:00
|
|
|
WLog_WARN(TAG, "%s: not implemented", __FUNCTION__);
|
|
|
|
return FALSE;
|
2012-02-13 00:21:08 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_ellipse_sc(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const ELLIPSE_SC_ORDER* ellipse_sc)
|
2012-02-13 00:21:08 +04:00
|
|
|
{
|
2016-07-19 14:02:08 +03:00
|
|
|
WLog_WARN(TAG, "%s: not implemented", __FUNCTION__);
|
|
|
|
return FALSE;
|
2012-02-13 00:21:08 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_ellipse_cb(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const ELLIPSE_CB_ORDER* ellipse_cb)
|
2012-02-13 00:21:08 +04:00
|
|
|
{
|
2016-07-19 14:02:08 +03:00
|
|
|
WLog_WARN(TAG, "%s: not implemented", __FUNCTION__);
|
|
|
|
return FALSE;
|
2011-10-05 05:29:01 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_frame_marker(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const FRAME_MARKER_ORDER* frameMarker)
|
2014-09-06 00:06:19 +04:00
|
|
|
{
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2014-09-06 00:06:19 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
BOOL gdi_surface_frame_marker(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const SURFACE_FRAME_MARKER* surfaceFrameMarker)
|
2013-07-15 17:00:18 +04:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_Print(context->gdi->log, WLOG_DEBUG, "frameId %"PRIu32" frameAction %"PRIu32"",
|
2016-08-04 17:58:07 +03:00
|
|
|
surfaceFrameMarker->frameId,
|
|
|
|
surfaceFrameMarker->frameAction);
|
2013-07-15 17:00:18 +04:00
|
|
|
|
2014-09-19 22:45:58 +04:00
|
|
|
switch (surfaceFrameMarker->frameAction)
|
2013-07-15 17:00:18 +04:00
|
|
|
{
|
|
|
|
case SURFACECMD_FRAMEACTION_BEGIN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SURFACECMD_FRAMEACTION_END:
|
2014-09-19 22:45:58 +04:00
|
|
|
if (context->settings->FrameAcknowledge > 0)
|
2013-07-15 17:00:18 +04:00
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
IFCALL(context->update->SurfaceFrameAcknowledge, context,
|
2016-04-25 10:42:59 +03:00
|
|
|
surfaceFrameMarker->frameId);
|
2013-07-15 17:00:18 +04:00
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2013-07-15 17:00:18 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-07-15 17:00:18 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL gdi_surface_bits(rdpContext* context,
|
2016-08-04 17:58:07 +03:00
|
|
|
const SURFACE_BITS_COMMAND* cmd)
|
2011-08-10 18:51:55 +04:00
|
|
|
{
|
2017-03-27 10:00:27 +03:00
|
|
|
BOOL result = FALSE;
|
2016-10-11 19:44:50 +03:00
|
|
|
DWORD format;
|
2016-08-04 17:58:07 +03:00
|
|
|
rdpGdi* gdi;
|
2017-03-27 10:00:27 +03:00
|
|
|
REGION16 region;
|
|
|
|
RECTANGLE_16 cmdRect;
|
|
|
|
UINT32 i, nbRects;
|
|
|
|
const RECTANGLE_16* rects;
|
2016-08-04 17:58:07 +03:00
|
|
|
|
|
|
|
if (!context || !cmd)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gdi = context->gdi;
|
2016-07-19 14:02:08 +03:00
|
|
|
WLog_Print(gdi->log, WLOG_DEBUG,
|
2016-12-14 00:47:08 +03:00
|
|
|
"destLeft %"PRIu32" destTop %"PRIu32" destRight %"PRIu32" destBottom %"PRIu32" "
|
2018-02-28 12:10:09 +03:00
|
|
|
"bpp %"PRIu8" flags %"PRIx8" codecID %"PRIu16" width %"PRIu16" height %"PRIu16" length %"PRIu32"",
|
2016-08-04 17:58:07 +03:00
|
|
|
cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
|
2018-09-19 13:03:07 +03:00
|
|
|
cmd->bmp.bpp, cmd->bmp.flags, cmd->bmp.codecID, cmd->bmp.width, cmd->bmp.height,
|
|
|
|
cmd->bmp.bitmapDataLength);
|
2017-03-27 10:00:27 +03:00
|
|
|
region16_init(®ion);
|
|
|
|
cmdRect.left = cmd->destLeft;
|
|
|
|
cmdRect.top = cmd->destTop;
|
2018-02-28 12:10:09 +03:00
|
|
|
cmdRect.right = cmdRect.left + cmd->bmp.width;
|
|
|
|
cmdRect.bottom = cmdRect.top + cmd->bmp.height;
|
2017-03-27 10:00:27 +03:00
|
|
|
|
2018-02-28 12:10:09 +03:00
|
|
|
switch (cmd->bmp.codecID)
|
2016-04-11 18:30:29 +03:00
|
|
|
{
|
2016-04-25 10:42:59 +03:00
|
|
|
case RDP_CODEC_ID_REMOTEFX:
|
2018-02-28 12:10:09 +03:00
|
|
|
if (!rfx_process_message(context->codecs->rfx, cmd->bmp.bitmapData,
|
2018-09-19 13:03:07 +03:00
|
|
|
cmd->bmp.bitmapDataLength,
|
2016-10-11 19:44:50 +03:00
|
|
|
cmd->destLeft, cmd->destTop,
|
|
|
|
gdi->primary_buffer, gdi->dstFormat,
|
2017-03-27 10:00:27 +03:00
|
|
|
gdi->stride, gdi->height, ®ion))
|
2016-04-25 10:42:59 +03:00
|
|
|
{
|
2016-10-11 19:44:50 +03:00
|
|
|
WLog_ERR(TAG, "Failed to process RemoteFX message");
|
2017-03-27 10:00:27 +03:00
|
|
|
goto out;
|
2016-04-25 10:42:59 +03:00
|
|
|
}
|
2017-11-20 17:00:09 +03:00
|
|
|
|
2016-04-25 10:42:59 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDP_CODEC_ID_NSCODEC:
|
2016-10-14 11:01:02 +03:00
|
|
|
format = gdi->dstFormat;
|
2016-10-11 19:44:50 +03:00
|
|
|
|
2018-02-28 12:10:09 +03:00
|
|
|
if (!nsc_process_message(context->codecs->nsc, cmd->bmp.bpp, cmd->bmp.width,
|
2018-09-19 13:03:07 +03:00
|
|
|
cmd->bmp.height, cmd->bmp.bitmapData,
|
|
|
|
cmd->bmp.bitmapDataLength, gdi->primary_buffer,
|
2016-10-11 19:44:50 +03:00
|
|
|
format, gdi->stride, cmd->destLeft, cmd->destTop,
|
2018-09-19 13:03:07 +03:00
|
|
|
cmd->bmp.width, cmd->bmp.height, FREERDP_FLIP_VERTICAL))
|
2017-03-27 10:00:27 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to process NSCodec message");
|
|
|
|
goto out;
|
|
|
|
}
|
2017-11-20 17:00:09 +03:00
|
|
|
|
2017-03-27 10:00:27 +03:00
|
|
|
region16_union_rect(®ion, ®ion, &cmdRect);
|
2016-04-25 10:42:59 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDP_CODEC_ID_NONE:
|
2018-02-28 12:10:09 +03:00
|
|
|
format = gdi_get_pixel_format(cmd->bmp.bpp);
|
2016-10-11 19:44:50 +03:00
|
|
|
|
|
|
|
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
|
2018-09-19 13:03:07 +03:00
|
|
|
cmd->destLeft, cmd->destTop, cmd->bmp.width, cmd->bmp.height,
|
|
|
|
cmd->bmp.bitmapData, format, 0, 0, 0,
|
2016-10-14 11:01:02 +03:00
|
|
|
&gdi->palette, FREERDP_FLIP_VERTICAL))
|
2017-03-27 10:00:27 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to process nocodec message");
|
|
|
|
goto out;
|
|
|
|
}
|
2017-11-20 17:00:09 +03:00
|
|
|
|
2017-03-27 10:00:27 +03:00
|
|
|
region16_union_rect(®ion, ®ion, &cmdRect);
|
2016-04-25 10:42:59 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-02-28 12:10:09 +03:00
|
|
|
WLog_ERR(TAG, "Unsupported codecID %"PRIu32"", cmd->bmp.codecID);
|
2016-04-25 10:42:59 +03:00
|
|
|
break;
|
2011-08-10 18:51:55 +04:00
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2017-03-27 10:00:27 +03:00
|
|
|
if (!(rects = region16_rects(®ion, &nbRects)))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
for (i = 0; i < nbRects; i++)
|
2016-10-10 20:39:08 +03:00
|
|
|
{
|
2017-03-27 10:00:27 +03:00
|
|
|
UINT32 left = rects[i].left;
|
|
|
|
UINT32 top = rects[i].top;
|
|
|
|
UINT32 width = rects[i].right - rects[i].left;
|
|
|
|
UINT32 height = rects[i].bottom - rects[i].top;
|
|
|
|
|
|
|
|
if (!gdi_InvalidateRegion(gdi->primary->hdc, left, top, width, height))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to update invalid region");
|
|
|
|
goto out;
|
|
|
|
}
|
2016-10-10 20:39:08 +03:00
|
|
|
}
|
|
|
|
|
2017-03-27 10:00:27 +03:00
|
|
|
result = TRUE;
|
|
|
|
out:
|
|
|
|
region16_uninit(®ion);
|
|
|
|
return result;
|
2011-08-10 18:51:55 +04:00
|
|
|
}
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
/**
|
2011-08-05 00:22:15 +04:00
|
|
|
* Register GDI callbacks with libfreerdp-core.
|
2011-07-01 05:23:36 +04:00
|
|
|
* @param inst current instance
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
|
2016-07-18 15:16:13 +03:00
|
|
|
static void gdi_register_update_callbacks(rdpUpdate* update)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpPrimaryUpdate* primary = update->primary;
|
2011-07-28 22:32:16 +04:00
|
|
|
update->Palette = gdi_palette_update;
|
|
|
|
update->SetBounds = gdi_set_bounds;
|
2011-11-22 03:11:43 +04:00
|
|
|
primary->DstBlt = gdi_dstblt;
|
|
|
|
primary->PatBlt = gdi_patblt;
|
|
|
|
primary->ScrBlt = gdi_scrblt;
|
|
|
|
primary->OpaqueRect = gdi_opaque_rect;
|
|
|
|
primary->DrawNineGrid = NULL;
|
|
|
|
primary->MultiDstBlt = NULL;
|
|
|
|
primary->MultiPatBlt = NULL;
|
|
|
|
primary->MultiScrBlt = NULL;
|
|
|
|
primary->MultiOpaqueRect = gdi_multi_opaque_rect;
|
|
|
|
primary->MultiDrawNineGrid = NULL;
|
|
|
|
primary->LineTo = gdi_line_to;
|
2011-12-02 07:59:23 +04:00
|
|
|
primary->Polyline = gdi_polyline;
|
2011-11-22 03:11:43 +04:00
|
|
|
primary->MemBlt = gdi_memblt;
|
|
|
|
primary->Mem3Blt = gdi_mem3blt;
|
|
|
|
primary->SaveBitmap = NULL;
|
|
|
|
primary->GlyphIndex = NULL;
|
|
|
|
primary->FastIndex = NULL;
|
|
|
|
primary->FastGlyph = NULL;
|
2012-02-13 00:21:08 +04:00
|
|
|
primary->PolygonSC = gdi_polygon_sc;
|
|
|
|
primary->PolygonCB = gdi_polygon_cb;
|
|
|
|
primary->EllipseSC = gdi_ellipse_sc;
|
|
|
|
primary->EllipseCB = gdi_ellipse_cb;
|
2011-08-10 18:51:55 +04:00
|
|
|
update->SurfaceBits = gdi_surface_bits;
|
2013-07-15 17:00:18 +04:00
|
|
|
update->SurfaceFrameMarker = gdi_surface_frame_marker;
|
2014-09-06 00:06:19 +04:00
|
|
|
update->altsec->FrameMarker = gdi_frame_marker;
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, UINT32 format,
|
2016-08-04 17:58:07 +03:00
|
|
|
BYTE* buffer, void (*pfree)(void*))
|
2011-09-07 09:26:17 +04:00
|
|
|
{
|
2015-05-08 22:39:23 +03:00
|
|
|
gdi->primary = (gdiBitmap*) calloc(1, sizeof(gdiBitmap));
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
if (format > 0)
|
|
|
|
gdi->dstFormat = format;
|
|
|
|
|
|
|
|
if (stride > 0)
|
|
|
|
gdi->stride = stride;
|
2017-01-11 17:31:48 +03:00
|
|
|
else
|
|
|
|
gdi->stride = gdi->width * GetBytesPerPixel(gdi->dstFormat);
|
2016-07-18 13:36:22 +03:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!gdi->primary)
|
2015-05-08 22:39:23 +03:00
|
|
|
goto fail_primary;
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!(gdi->primary->hdc = gdi_CreateCompatibleDC(gdi->hdc)))
|
|
|
|
goto fail_hdc;
|
2013-09-04 05:48:26 +04:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
if (!buffer)
|
|
|
|
{
|
|
|
|
gdi->primary->bitmap = gdi_CreateCompatibleBitmap(
|
2016-08-04 17:58:07 +03:00
|
|
|
gdi->hdc, gdi->width, gdi->height);
|
2016-04-05 18:07:45 +03:00
|
|
|
}
|
2013-09-04 05:48:26 +04:00
|
|
|
else
|
2016-08-02 15:16:49 +03:00
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
gdi->primary->bitmap = gdi_CreateBitmapEx(gdi->width, gdi->height,
|
2016-08-04 17:58:07 +03:00
|
|
|
gdi->dstFormat,
|
|
|
|
gdi->stride,
|
|
|
|
buffer, pfree);
|
2016-04-05 18:07:45 +03:00
|
|
|
}
|
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!gdi->primary->bitmap)
|
|
|
|
goto fail_bitmap;
|
|
|
|
|
2017-11-29 13:12:40 +03:00
|
|
|
gdi->stride = gdi->primary->bitmap->scanline;
|
2013-09-04 05:48:26 +04:00
|
|
|
gdi_SelectObject(gdi->primary->hdc, (HGDIOBJECT) gdi->primary->bitmap);
|
|
|
|
gdi->primary->org_bitmap = NULL;
|
2011-09-07 09:26:17 +04:00
|
|
|
gdi->primary_buffer = gdi->primary->bitmap->data;
|
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!(gdi->primary->hdc->hwnd = (HGDI_WND) calloc(1, sizeof(GDI_WND))))
|
|
|
|
goto fail_hwnd;
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!(gdi->primary->hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0)))
|
|
|
|
goto fail_hwnd;
|
2011-09-07 09:26:17 +04:00
|
|
|
|
2016-10-06 14:41:52 +03:00
|
|
|
gdi->primary->hdc->hwnd->invalid->null = TRUE;
|
2011-09-07 09:26:17 +04:00
|
|
|
gdi->primary->hdc->hwnd->count = 32;
|
2016-04-05 18:07:45 +03:00
|
|
|
|
|
|
|
if (!(gdi->primary->hdc->hwnd->cinvalid = (HGDI_RGN) calloc(
|
2016-08-04 17:58:07 +03:00
|
|
|
gdi->primary->hdc->hwnd->count, sizeof(GDI_RGN))))
|
2015-05-08 22:39:23 +03:00
|
|
|
goto fail_hwnd;
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2011-09-07 09:26:17 +04:00
|
|
|
gdi->primary->hdc->hwnd->ninvalid = 0;
|
2015-05-08 22:39:23 +03:00
|
|
|
|
|
|
|
if (!gdi->drawing)
|
|
|
|
gdi->drawing = gdi->primary;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
fail_hwnd:
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) gdi->primary->bitmap);
|
|
|
|
fail_bitmap:
|
|
|
|
gdi_DeleteDC(gdi->primary->hdc);
|
|
|
|
fail_hdc:
|
|
|
|
free(gdi->primary);
|
|
|
|
gdi->primary = NULL;
|
|
|
|
fail_primary:
|
|
|
|
return FALSE;
|
2011-09-07 09:26:17 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
BOOL gdi_resize(rdpGdi* gdi, UINT32 width, UINT32 height)
|
|
|
|
{
|
2016-10-18 16:16:58 +03:00
|
|
|
return gdi_resize_ex(gdi, width, height, 0, 0, NULL, NULL);
|
2016-04-05 18:07:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height,
|
2016-08-04 17:58:07 +03:00
|
|
|
UINT32 stride, UINT32 format, BYTE* buffer,
|
|
|
|
void (*pfree)(void*))
|
2011-09-07 09:26:17 +04:00
|
|
|
{
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!gdi || !gdi->primary)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-02-07 16:18:53 +03:00
|
|
|
if ((width > INT32_MAX) || (height > INT32_MAX))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((gdi->width == (INT32)width) && (gdi->height == (INT32)height) &&
|
|
|
|
(!buffer || (gdi->primary_buffer == buffer)))
|
2015-05-08 22:39:23 +03:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (gdi->drawing == gdi->primary)
|
|
|
|
gdi->drawing = NULL;
|
|
|
|
|
2019-02-07 16:18:53 +03:00
|
|
|
gdi->width = (INT32)width;
|
|
|
|
gdi->height = (INT32)height;
|
2015-05-08 22:39:23 +03:00
|
|
|
gdi_bitmap_free_ex(gdi->primary);
|
|
|
|
gdi->primary = NULL;
|
|
|
|
gdi->primary_buffer = NULL;
|
2016-07-18 13:36:22 +03:00
|
|
|
return gdi_init_primary(gdi, stride, format, buffer, pfree);
|
2011-09-07 09:26:17 +04:00
|
|
|
}
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
/**
|
|
|
|
* Initialize GDI
|
|
|
|
* @param inst current instance
|
|
|
|
* @return
|
|
|
|
*/
|
2016-04-05 18:07:45 +03:00
|
|
|
BOOL gdi_init(freerdp* instance, UINT32 format)
|
|
|
|
{
|
|
|
|
return gdi_init_ex(instance, format, 0, NULL, _aligned_free);
|
|
|
|
}
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
|
2016-08-04 17:58:07 +03:00
|
|
|
void (*pfree)(void*))
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2016-10-14 11:01:02 +03:00
|
|
|
UINT32 SrcFormat = gdi_get_pixel_format(instance->settings->ColorDepth);
|
2016-07-11 12:52:56 +03:00
|
|
|
rdpGdi* gdi = (rdpGdi*) calloc(1, sizeof(rdpGdi));
|
|
|
|
rdpContext* context = instance->context;
|
2014-07-08 23:07:19 +04:00
|
|
|
|
|
|
|
if (!gdi)
|
2016-07-11 12:52:56 +03:00
|
|
|
goto fail;
|
2011-10-16 08:50:10 +04:00
|
|
|
|
2016-08-10 11:29:59 +03:00
|
|
|
instance->context->gdi = gdi;
|
2016-07-19 14:02:08 +03:00
|
|
|
gdi->log = WLog_Get(TAG);
|
|
|
|
|
|
|
|
if (!gdi->log)
|
|
|
|
goto fail;
|
|
|
|
|
2014-09-12 22:57:44 +04:00
|
|
|
gdi->context = instance->context;
|
2012-11-07 19:33:06 +04:00
|
|
|
gdi->width = instance->settings->DesktopWidth;
|
|
|
|
gdi->height = instance->settings->DesktopHeight;
|
2016-04-05 18:07:45 +03:00
|
|
|
gdi->dstFormat = format;
|
2011-07-01 05:23:36 +04:00
|
|
|
/* default internal buffer format */
|
2016-07-19 14:02:08 +03:00
|
|
|
WLog_Print(gdi->log, WLOG_INFO, "Local framebuffer format %s",
|
2017-11-24 15:19:48 +03:00
|
|
|
FreeRDPGetColorFormatName(gdi->dstFormat));
|
2016-07-19 14:02:08 +03:00
|
|
|
WLog_Print(gdi->log, WLOG_INFO, "Remote framebuffer format %s",
|
2017-11-24 15:19:48 +03:00
|
|
|
FreeRDPGetColorFormatName(SrcFormat));
|
2014-09-16 00:08:06 +04:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!(gdi->hdc = gdi_GetDC()))
|
2016-07-11 12:52:56 +03:00
|
|
|
goto fail;
|
2015-05-08 22:39:23 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
gdi->hdc->format = gdi->dstFormat;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2016-07-18 13:36:22 +03:00
|
|
|
if (!gdi_init_primary(gdi, stride, gdi->dstFormat, buffer, pfree))
|
2016-07-11 12:52:56 +03:00
|
|
|
goto fail;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2016-07-15 17:23:00 +03:00
|
|
|
if (!(context->cache = cache_new(instance->settings)))
|
|
|
|
goto fail;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2011-07-28 09:17:17 +04:00
|
|
|
gdi_register_update_callbacks(instance->update);
|
2011-10-21 07:15:18 +04:00
|
|
|
brush_cache_register_callbacks(instance->update);
|
2011-11-09 08:26:44 +04:00
|
|
|
glyph_cache_register_callbacks(instance->update);
|
2011-10-13 23:51:07 +04:00
|
|
|
bitmap_cache_register_callbacks(instance->update);
|
|
|
|
offscreen_cache_register_callbacks(instance->update);
|
2011-11-11 11:07:53 +04:00
|
|
|
palette_cache_register_callbacks(instance->update);
|
2011-10-21 02:18:45 +04:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!gdi_register_graphics(instance->context->graphics))
|
2016-07-11 12:52:56 +03:00
|
|
|
goto fail;
|
2011-08-05 06:43:36 +04:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
return TRUE;
|
2016-07-11 12:52:56 +03:00
|
|
|
fail:
|
|
|
|
gdi_free(instance);
|
2015-05-08 22:39:23 +03:00
|
|
|
WLog_ERR(TAG, "failed to initialize gdi");
|
|
|
|
return FALSE;
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
|
2011-07-28 09:17:17 +04:00
|
|
|
void gdi_free(freerdp* instance)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2016-07-11 12:52:56 +03:00
|
|
|
rdpGdi* gdi;
|
|
|
|
rdpContext* context;
|
|
|
|
|
|
|
|
if (!instance || !instance->context)
|
|
|
|
return;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2016-07-11 12:52:56 +03:00
|
|
|
gdi = instance->context->gdi;
|
2016-07-14 13:42:24 +03:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
if (gdi)
|
|
|
|
{
|
2011-10-13 23:51:07 +04:00
|
|
|
gdi_bitmap_free_ex(gdi->primary);
|
2011-07-27 17:45:44 +04:00
|
|
|
gdi_DeleteDC(gdi->hdc);
|
2011-07-01 05:23:36 +04:00
|
|
|
free(gdi);
|
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2016-07-11 12:52:56 +03:00
|
|
|
context = instance->context;
|
2016-07-15 17:23:00 +03:00
|
|
|
cache_free(context->cache);
|
|
|
|
context->cache = NULL;
|
2011-10-16 08:50:10 +04:00
|
|
|
instance->context->gdi = (rdpGdi*) NULL;
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
2011-07-28 08:38:25 +04:00
|
|
|
|
2018-02-08 12:34:49 +03:00
|
|
|
BOOL gdi_send_suppress_output(rdpGdi* gdi, BOOL suppress)
|
|
|
|
{
|
|
|
|
RECTANGLE_16 rect;
|
|
|
|
rdpSettings* settings;
|
|
|
|
rdpUpdate* update;
|
|
|
|
|
|
|
|
if (!gdi || !gdi->context->settings || !gdi->context->update)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (gdi->suppressOutput == suppress)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
gdi->suppressOutput = suppress;
|
|
|
|
settings = gdi->context->settings;
|
|
|
|
update = gdi->context->update;
|
|
|
|
rect.left = 0;
|
|
|
|
rect.top = 0;
|
|
|
|
rect.right = settings->DesktopWidth;
|
|
|
|
rect.bottom = settings->DesktopHeight;
|
|
|
|
return update->SuppressOutput(gdi->context, !suppress, &rect);
|
|
|
|
}
|
|
|
|
|