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>
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
2011-08-22 21:08:01 +04:00
|
|
|
#include <freerdp/gdi/dc.h>
|
|
|
|
#include <freerdp/gdi/pen.h>
|
|
|
|
#include <freerdp/gdi/line.h>
|
|
|
|
#include <freerdp/gdi/shape.h>
|
|
|
|
#include <freerdp/gdi/brush.h>
|
|
|
|
#include <freerdp/gdi/region.h>
|
|
|
|
#include <freerdp/gdi/bitmap.h>
|
|
|
|
#include <freerdp/gdi/drawing.h>
|
|
|
|
#include <freerdp/gdi/clipping.h>
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2011-10-21 01:28:59 +04:00
|
|
|
#include "gdi.h"
|
|
|
|
|
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 */
|
2012-10-09 11:26:39 +04:00
|
|
|
static const UINT32 rop3_code_table[] =
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
0x00000042, /* 0 */
|
|
|
|
0x00010289, /* DPSoon */
|
|
|
|
0x00020C89, /* DPSona */
|
|
|
|
0x000300AA, /* PSon */
|
|
|
|
0x00040C88, /* SDPona */
|
|
|
|
0x000500A9, /* DPon */
|
|
|
|
0x00060865, /* PDSxnon */
|
|
|
|
0x000702C5, /* PDSaon */
|
|
|
|
0x00080F08, /* SDPnaa */
|
|
|
|
0x00090245, /* PDSxon */
|
|
|
|
0x000A0329, /* DPna */
|
|
|
|
0x000B0B2A, /* PSDnaon */
|
|
|
|
0x000C0324, /* SPna */
|
|
|
|
0x000D0B25, /* PDSnaon */
|
|
|
|
0x000E08A5, /* PDSonon */
|
|
|
|
0x000F0001, /* Pn */
|
|
|
|
0x00100C85, /* PDSona */
|
|
|
|
0x001100A6, /* DSon */
|
|
|
|
0x00120868, /* SDPxnon */
|
|
|
|
0x001302C8, /* SDPaon */
|
|
|
|
0x00140869, /* DPSxnon */
|
|
|
|
0x001502C9, /* DPSaon */
|
|
|
|
0x00165CCA, /* PSDPSanaxx */
|
|
|
|
0x00171D54, /* SSPxDSxaxn */
|
|
|
|
0x00180D59, /* SPxPDxa */
|
|
|
|
0x00191CC8, /* SDPSanaxn */
|
|
|
|
0x001A06C5, /* PDSPaox */
|
|
|
|
0x001B0768, /* SDPSxaxn */
|
|
|
|
0x001C06CA, /* PSDPaox */
|
|
|
|
0x001D0766, /* DSPDxaxn */
|
|
|
|
0x001E01A5, /* PDSox */
|
|
|
|
0x001F0385, /* PDSoan */
|
|
|
|
0x00200F09, /* DPSnaa */
|
|
|
|
0x00210248, /* SDPxon */
|
|
|
|
0x00220326, /* DSna */
|
|
|
|
0x00230B24, /* SPDnaon */
|
|
|
|
0x00240D55, /* SPxDSxa */
|
|
|
|
0x00251CC5, /* PDSPanaxn */
|
|
|
|
0x002606C8, /* SDPSaox */
|
|
|
|
0x00271868, /* SDPSxnox */
|
|
|
|
0x00280369, /* DPSxa */
|
|
|
|
0x002916CA, /* PSDPSaoxxn */
|
|
|
|
0x002A0CC9, /* DPSana */
|
|
|
|
0x002B1D58, /* SSPxPDxaxn */
|
|
|
|
0x002C0784, /* SPDSoax */
|
|
|
|
0x002D060A, /* PSDnox */
|
|
|
|
0x002E064A, /* PSDPxox */
|
|
|
|
0x002F0E2A, /* PSDnoan */
|
|
|
|
0x0030032A, /* PSna */
|
|
|
|
0x00310B28, /* SDPnaon */
|
|
|
|
0x00320688, /* SDPSoox */
|
|
|
|
0x00330008, /* Sn */
|
|
|
|
0x003406C4, /* SPDSaox */
|
|
|
|
0x00351864, /* SPDSxnox */
|
|
|
|
0x003601A8, /* SDPox */
|
|
|
|
0x00370388, /* SDPoan */
|
|
|
|
0x0038078A, /* PSDPoax */
|
|
|
|
0x00390604, /* SPDnox */
|
|
|
|
0x003A0644, /* SPDSxox */
|
|
|
|
0x003B0E24, /* SPDnoan */
|
|
|
|
0x003C004A, /* PSx */
|
|
|
|
0x003D18A4, /* SPDSonox */
|
|
|
|
0x003E1B24, /* SPDSnaox */
|
|
|
|
0x003F00EA, /* PSan */
|
|
|
|
0x00400F0A, /* PSDnaa */
|
|
|
|
0x00410249, /* DPSxon */
|
|
|
|
0x00420D5D, /* SDxPDxa */
|
|
|
|
0x00431CC4, /* SPDSanaxn */
|
|
|
|
0x00440328, /* SDna */
|
|
|
|
0x00450B29, /* DPSnaon */
|
|
|
|
0x004606C6, /* DSPDaox */
|
|
|
|
0x0047076A, /* PSDPxaxn */
|
|
|
|
0x00480368, /* SDPxa */
|
|
|
|
0x004916C5, /* PDSPDaoxxn */
|
|
|
|
0x004A0789, /* DPSDoax */
|
|
|
|
0x004B0605, /* PDSnox */
|
|
|
|
0x004C0CC8, /* SDPana */
|
|
|
|
0x004D1954, /* SSPxDSxoxn */
|
|
|
|
0x004E0645, /* PDSPxox */
|
|
|
|
0x004F0E25, /* PDSnoan */
|
|
|
|
0x00500325, /* PDna */
|
|
|
|
0x00510B26, /* DSPnaon */
|
|
|
|
0x005206C9, /* DPSDaox */
|
|
|
|
0x00530764, /* SPDSxaxn */
|
|
|
|
0x005408A9, /* DPSonon */
|
|
|
|
0x00550009, /* Dn */
|
|
|
|
0x005601A9, /* DPSox */
|
|
|
|
0x00570389, /* DPSoan */
|
|
|
|
0x00580785, /* PDSPoax */
|
|
|
|
0x00590609, /* DPSnox */
|
|
|
|
0x005A0049, /* DPx */
|
|
|
|
0x005B18A9, /* DPSDonox */
|
|
|
|
0x005C0649, /* DPSDxox */
|
|
|
|
0x005D0E29, /* DPSnoan */
|
|
|
|
0x005E1B29, /* DPSDnaox */
|
|
|
|
0x005F00E9, /* DPan */
|
|
|
|
0x00600365, /* PDSxa */
|
|
|
|
0x006116C6, /* DSPDSaoxxn */
|
|
|
|
0x00620786, /* DSPDoax */
|
|
|
|
0x00630608, /* SDPnox */
|
|
|
|
0x00640788, /* SDPSoax */
|
|
|
|
0x00650606, /* DSPnox */
|
|
|
|
0x00660046, /* DSx */
|
|
|
|
0x006718A8, /* SDPSonox */
|
|
|
|
0x006858A6, /* DSPDSonoxxn */
|
|
|
|
0x00690145, /* PDSxxn */
|
|
|
|
0x006A01E9, /* DPSax */
|
|
|
|
0x006B178A, /* PSDPSoaxxn */
|
|
|
|
0x006C01E8, /* SDPax */
|
|
|
|
0x006D1785, /* PDSPDoaxxn */
|
|
|
|
0x006E1E28, /* SDPSnoax */
|
|
|
|
0x006F0C65, /* PDSxnan */
|
|
|
|
0x00700CC5, /* PDSana */
|
|
|
|
0x00711D5C, /* SSDxPDxaxn */
|
|
|
|
0x00720648, /* SDPSxox */
|
|
|
|
0x00730E28, /* SDPnoan */
|
|
|
|
0x00740646, /* DSPDxox */
|
|
|
|
0x00750E26, /* DSPnoan */
|
|
|
|
0x00761B28, /* SDPSnaox */
|
|
|
|
0x007700E6, /* DSan */
|
|
|
|
0x007801E5, /* PDSax */
|
|
|
|
0x00791786, /* DSPDSoaxxn */
|
|
|
|
0x007A1E29, /* DPSDnoax */
|
|
|
|
0x007B0C68, /* SDPxnan */
|
|
|
|
0x007C1E24, /* SPDSnoax */
|
|
|
|
0x007D0C69, /* DPSxnan */
|
|
|
|
0x007E0955, /* SPxDSxo */
|
|
|
|
0x007F03C9, /* DPSaan */
|
|
|
|
0x008003E9, /* DPSaa */
|
|
|
|
0x00810975, /* SPxDSxon */
|
|
|
|
0x00820C49, /* DPSxna */
|
|
|
|
0x00831E04, /* SPDSnoaxn */
|
|
|
|
0x00840C48, /* SDPxna */
|
|
|
|
0x00851E05, /* PDSPnoaxn */
|
|
|
|
0x008617A6, /* DSPDSoaxx */
|
|
|
|
0x008701C5, /* PDSaxn */
|
|
|
|
0x008800C6, /* DSa */
|
|
|
|
0x00891B08, /* SDPSnaoxn */
|
|
|
|
0x008A0E06, /* DSPnoa */
|
|
|
|
0x008B0666, /* DSPDxoxn */
|
|
|
|
0x008C0E08, /* SDPnoa */
|
|
|
|
0x008D0668, /* SDPSxoxn */
|
|
|
|
0x008E1D7C, /* SSDxPDxax */
|
|
|
|
0x008F0CE5, /* PDSanan */
|
|
|
|
0x00900C45, /* PDSxna */
|
|
|
|
0x00911E08, /* SDPSnoaxn */
|
|
|
|
0x009217A9, /* DPSDPoaxx */
|
|
|
|
0x009301C4, /* SPDaxn */
|
|
|
|
0x009417AA, /* PSDPSoaxx */
|
|
|
|
0x009501C9, /* DPSaxn */
|
|
|
|
0x00960169, /* DPSxx */
|
|
|
|
0x0097588A, /* PSDPSonoxx */
|
|
|
|
0x00981888, /* SDPSonoxn */
|
|
|
|
0x00990066, /* DSxn */
|
|
|
|
0x009A0709, /* DPSnax */
|
|
|
|
0x009B07A8, /* SDPSoaxn */
|
|
|
|
0x009C0704, /* SPDnax */
|
|
|
|
0x009D07A6, /* DSPDoaxn */
|
|
|
|
0x009E16E6, /* DSPDSaoxx */
|
|
|
|
0x009F0345, /* PDSxan */
|
|
|
|
0x00A000C9, /* DPa */
|
|
|
|
0x00A11B05, /* PDSPnaoxn */
|
|
|
|
0x00A20E09, /* DPSnoa */
|
|
|
|
0x00A30669, /* DPSDxoxn */
|
|
|
|
0x00A41885, /* PDSPonoxn */
|
|
|
|
0x00A50065, /* PDxn */
|
|
|
|
0x00A60706, /* DSPnax */
|
|
|
|
0x00A707A5, /* PDSPoaxn */
|
|
|
|
0x00A803A9, /* DPSoa */
|
|
|
|
0x00A90189, /* DPSoxn */
|
|
|
|
0x00AA0029, /* D */
|
|
|
|
0x00AB0889, /* DPSono */
|
|
|
|
0x00AC0744, /* SPDSxax */
|
|
|
|
0x00AD06E9, /* DPSDaoxn */
|
|
|
|
0x00AE0B06, /* DSPnao */
|
|
|
|
0x00AF0229, /* DPno */
|
|
|
|
0x00B00E05, /* PDSnoa */
|
|
|
|
0x00B10665, /* PDSPxoxn */
|
|
|
|
0x00B21974, /* SSPxDSxox */
|
|
|
|
0x00B30CE8, /* SDPanan */
|
|
|
|
0x00B4070A, /* PSDnax */
|
|
|
|
0x00B507A9, /* DPSDoaxn */
|
|
|
|
0x00B616E9, /* DPSDPaoxx */
|
|
|
|
0x00B70348, /* SDPxan */
|
|
|
|
0x00B8074A, /* PSDPxax */
|
|
|
|
0x00B906E6, /* DSPDaoxn */
|
|
|
|
0x00BA0B09, /* DPSnao */
|
|
|
|
0x00BB0226, /* DSno */
|
|
|
|
0x00BC1CE4, /* SPDSanax */
|
|
|
|
0x00BD0D7D, /* SDxPDxan */
|
|
|
|
0x00BE0269, /* DPSxo */
|
|
|
|
0x00BF08C9, /* DPSano */
|
|
|
|
0x00C000CA, /* PSa */
|
|
|
|
0x00C11B04, /* SPDSnaoxn */
|
|
|
|
0x00C21884, /* SPDSonoxn */
|
|
|
|
0x00C3006A, /* PSxn */
|
|
|
|
0x00C40E04, /* SPDnoa */
|
|
|
|
0x00C50664, /* SPDSxoxn */
|
|
|
|
0x00C60708, /* SDPnax */
|
|
|
|
0x00C707AA, /* PSDPoaxn */
|
|
|
|
0x00C803A8, /* SDPoa */
|
|
|
|
0x00C90184, /* SPDoxn */
|
|
|
|
0x00CA0749, /* DPSDxax */
|
|
|
|
0x00CB06E4, /* SPDSaoxn */
|
|
|
|
0x00CC0020, /* S */
|
|
|
|
0x00CD0888, /* SDPono */
|
|
|
|
0x00CE0B08, /* SDPnao */
|
|
|
|
0x00CF0224, /* SPno */
|
|
|
|
0x00D00E0A, /* PSDnoa */
|
|
|
|
0x00D1066A, /* PSDPxoxn */
|
|
|
|
0x00D20705, /* PDSnax */
|
|
|
|
0x00D307A4, /* SPDSoaxn */
|
|
|
|
0x00D41D78, /* SSPxPDxax */
|
|
|
|
0x00D50CE9, /* DPSanan */
|
|
|
|
0x00D616EA, /* PSDPSaoxx */
|
|
|
|
0x00D70349, /* DPSxan */
|
|
|
|
0x00D80745, /* PDSPxax */
|
|
|
|
0x00D906E8, /* SDPSaoxn */
|
|
|
|
0x00DA1CE9, /* DPSDanax */
|
|
|
|
0x00DB0D75, /* SPxDSxan */
|
|
|
|
0x00DC0B04, /* SPDnao */
|
|
|
|
0x00DD0228, /* SDno */
|
|
|
|
0x00DE0268, /* SDPxo */
|
|
|
|
0x00DF08C8, /* SDPano */
|
|
|
|
0x00E003A5, /* PDSoa */
|
|
|
|
0x00E10185, /* PDSoxn */
|
|
|
|
0x00E20746, /* DSPDxax */
|
|
|
|
0x00E306EA, /* PSDPaoxn */
|
|
|
|
0x00E40748, /* SDPSxax */
|
|
|
|
0x00E506E5, /* PDSPaoxn */
|
|
|
|
0x00E61CE8, /* SDPSanax */
|
|
|
|
0x00E70D79, /* SPxPDxan */
|
|
|
|
0x00E81D74, /* SSPxDSxax */
|
|
|
|
0x00E95CE6, /* DSPDSanaxxn */
|
|
|
|
0x00EA02E9, /* DPSao */
|
|
|
|
0x00EB0849, /* DPSxno */
|
|
|
|
0x00EC02E8, /* SDPao */
|
|
|
|
0x00ED0848, /* SDPxno */
|
|
|
|
0x00EE0086, /* DSo */
|
|
|
|
0x00EF0A08, /* SDPnoo */
|
|
|
|
0x00F00021, /* P */
|
|
|
|
0x00F10885, /* PDSono */
|
|
|
|
0x00F20B05, /* PDSnao */
|
|
|
|
0x00F3022A, /* PSno */
|
|
|
|
0x00F40B0A, /* PSDnao */
|
|
|
|
0x00F50225, /* PDno */
|
|
|
|
0x00F60265, /* PDSxo */
|
|
|
|
0x00F708C5, /* PDSano */
|
|
|
|
0x00F802E5, /* PDSao */
|
|
|
|
0x00F90845, /* PDSxno */
|
|
|
|
0x00FA0089, /* DPo */
|
|
|
|
0x00FB0A09, /* DPSnoo */
|
|
|
|
0x00FC008A, /* PSo */
|
|
|
|
0x00FD0A0A, /* PSDnoo */
|
|
|
|
0x00FE02A9, /* DPSoo */
|
|
|
|
0x00FF0062 /* 1 */
|
|
|
|
};
|
|
|
|
|
2013-02-04 18:58:22 +04:00
|
|
|
/* Hatch Patterns as monochrome data */
|
2014-02-13 20:59:05 +04:00
|
|
|
static 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 */
|
|
|
|
};
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
/* GDI Helper Functions */
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
INLINE UINT32 gdi_rop3_code(BYTE code)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
return rop3_code_table[code];
|
|
|
|
}
|
|
|
|
|
2014-09-12 04:46:15 +04:00
|
|
|
UINT32 gdi_get_pixel_format(UINT32 bitsPerPixel, BOOL vFlip)
|
|
|
|
{
|
|
|
|
UINT32 format = PIXEL_FORMAT_XRGB32_VF;
|
|
|
|
|
|
|
|
switch (bitsPerPixel)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
format = vFlip ? PIXEL_FORMAT_XRGB32_VF : PIXEL_FORMAT_XRGB32;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
|
|
|
format = vFlip ? PIXEL_FORMAT_RGB24_VF : PIXEL_FORMAT_RGB24;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
format = vFlip ? PIXEL_FORMAT_RGB16_VF : PIXEL_FORMAT_RGB16;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
format = vFlip ? PIXEL_FORMAT_RGB15_VF : PIXEL_FORMAT_RGB15;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
format = vFlip ? PIXEL_FORMAT_RGB8_VF : PIXEL_FORMAT_RGB8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
INLINE BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* p;
|
2011-07-01 05:23:36 +04:00
|
|
|
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdcBmp->selectedObject;
|
|
|
|
|
|
|
|
if (x >= 0 && x < hBmp->width && y >= 0 && y < hBmp->height)
|
|
|
|
{
|
|
|
|
p = hBmp->data + (y * hBmp->width * hdcBmp->bytesPerPixel) + (x * hdcBmp->bytesPerPixel);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d",
|
|
|
|
x, y, hBmp->width, hBmp->height);
|
2011-07-01 05:23:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
INLINE BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, int x, int y)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE * p;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
if (hdcBrush->brush != NULL)
|
|
|
|
{
|
2013-02-04 18:58:22 +04:00
|
|
|
if ((hdcBrush->brush->style == GDI_BS_PATTERN) || (hdcBrush->brush->style == GDI_BS_HATCHED))
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
HGDI_BITMAP hBmpBrush = hdcBrush->brush->pattern;
|
|
|
|
|
|
|
|
if (x >= 0 && y >= 0)
|
|
|
|
{
|
|
|
|
x = x % hBmpBrush->width;
|
|
|
|
y = y % hBmpBrush->height;
|
|
|
|
p = hBmpBrush->data + (y * hBmpBrush->scanline) + (x * hBmpBrush->bytesPerPixel);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
p = (BYTE*) &(hdcBrush->textColor);
|
2011-07-01 05:23:36 +04:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp, BYTE* data)
|
2011-07-28 09:34:53 +04:00
|
|
|
{
|
2011-10-21 01:28:59 +04:00
|
|
|
gdiBitmap* bitmap;
|
2011-07-28 09:34:53 +04:00
|
|
|
|
2012-10-09 07:21:26 +04:00
|
|
|
bitmap = (gdiBitmap*) malloc(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
|
|
|
|
2011-10-21 01:28:59 +04:00
|
|
|
DEBUG_GDI("gdi_bitmap_new: width:%d height:%d bpp:%d", 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
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
int nXDst;
|
|
|
|
int nYDst;
|
|
|
|
int nXSrc;
|
|
|
|
int nYSrc;
|
|
|
|
int nWidth;
|
|
|
|
int nHeight;
|
2014-09-18 03:55:39 +04:00
|
|
|
int nSrcStep;
|
2014-09-12 04:12:32 +04:00
|
|
|
int nDstStep;
|
|
|
|
UINT32 index;
|
|
|
|
BYTE* pSrcData;
|
|
|
|
BYTE* pDstData;
|
|
|
|
UINT32 SrcSize;
|
|
|
|
BOOL compressed;
|
|
|
|
UINT32 SrcFormat;
|
|
|
|
UINT32 bitsPerPixel;
|
|
|
|
BITMAP_DATA* bitmap;
|
|
|
|
rdpGdi* gdi = context->gdi;
|
|
|
|
rdpCodecs* codecs = context->codecs;
|
|
|
|
|
|
|
|
for (index = 0; index < bitmapUpdate->number; index++)
|
|
|
|
{
|
|
|
|
bitmap = &(bitmapUpdate->rectangles[index]);
|
|
|
|
|
|
|
|
nXSrc = 0;
|
|
|
|
nYSrc = 0;
|
|
|
|
|
|
|
|
nXDst = bitmap->destLeft;
|
|
|
|
nYDst = bitmap->destTop;
|
|
|
|
|
|
|
|
nWidth = bitmap->width;
|
|
|
|
nHeight = bitmap->height;
|
|
|
|
|
|
|
|
pSrcData = bitmap->bitmapDataStream;
|
|
|
|
SrcSize = bitmap->bitmapLength;
|
|
|
|
|
|
|
|
compressed = bitmap->compressed;
|
|
|
|
bitsPerPixel = bitmap->bitsPerPixel;
|
|
|
|
|
2015-05-07 21:20:49 +03:00
|
|
|
if (gdi->bitmap_size < (UINT32) (nWidth * nHeight * 4))
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-12 06:29:09 +04:00
|
|
|
gdi->bitmap_size = nWidth * nHeight * 4;
|
2014-09-12 04:46:15 +04:00
|
|
|
gdi->bitmap_buffer = (BYTE*) _aligned_realloc(gdi->bitmap_buffer, gdi->bitmap_size, 16);
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-12 04:46:15 +04:00
|
|
|
if (!gdi->bitmap_buffer)
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (compressed)
|
|
|
|
{
|
2014-09-12 04:46:15 +04:00
|
|
|
pDstData = gdi->bitmap_buffer;
|
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
if (bitsPerPixel < 32)
|
|
|
|
{
|
2015-04-28 18:00:41 +03:00
|
|
|
if (!freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_INTERLEAVED))
|
|
|
|
return FALSE;
|
2014-09-12 04:12:32 +04:00
|
|
|
|
|
|
|
status = interleaved_decompress(codecs->interleaved, pSrcData, SrcSize, bitsPerPixel,
|
2014-09-18 02:30:09 +04:00
|
|
|
&pDstData, gdi->format, -1, 0, 0, nWidth, nHeight, gdi->palette);
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-28 18:00:41 +03:00
|
|
|
if (!freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_PLANAR))
|
|
|
|
return FALSE;
|
2014-09-12 04:12:32 +04:00
|
|
|
|
|
|
|
status = planar_decompress(codecs->planar, pSrcData, SrcSize, &pDstData,
|
2014-09-17 22:55:52 +04:00
|
|
|
gdi->format, -1, 0, 0, nWidth, nHeight, TRUE);
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (status < 0)
|
|
|
|
{
|
2014-09-15 11:01:05 +04:00
|
|
|
WLog_ERR(TAG, "bitmap decompression failure");
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
|
2014-09-12 04:46:15 +04:00
|
|
|
pSrcData = gdi->bitmap_buffer;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2014-09-17 22:55:52 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pDstData = gdi->bitmap_buffer;
|
|
|
|
SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE);
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 22:55:52 +04:00
|
|
|
status = freerdp_image_copy(pDstData, gdi->format, -1, 0, 0,
|
2014-09-18 02:30:09 +04:00
|
|
|
nWidth, nHeight, pSrcData, SrcFormat, -1, 0, 0, gdi->palette);
|
2014-09-17 22:55:52 +04:00
|
|
|
|
|
|
|
pSrcData = gdi->bitmap_buffer;
|
|
|
|
}
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-11-08 01:19:46 +03:00
|
|
|
nSrcStep = nWidth * gdi->bytesPerPixel;
|
2014-09-18 03:55:39 +04:00
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstData = gdi->primary_buffer;
|
2014-09-17 22:55:52 +04:00
|
|
|
nDstStep = gdi->width * gdi->bytesPerPixel;
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-12 04:46:15 +04:00
|
|
|
nWidth = bitmap->destRight - bitmap->destLeft + 1; /* clip width */
|
|
|
|
nHeight = bitmap->destBottom - bitmap->destTop + 1; /* clip height */
|
|
|
|
|
2014-09-16 00:08:06 +04:00
|
|
|
status = freerdp_image_copy(pDstData, gdi->format, nDstStep, nXDst, nYDst,
|
2014-09-18 03:55:39 +04:00
|
|
|
nWidth, nHeight, pSrcData, gdi->format, nSrcStep, nXSrc, nYSrc, gdi->palette);
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2015-04-20 12:43:44 +03:00
|
|
|
if (!gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, nWidth, nHeight))
|
|
|
|
return FALSE;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette)
|
2011-07-28 22:32:16 +04:00
|
|
|
{
|
2014-09-18 02:30:09 +04:00
|
|
|
int index;
|
|
|
|
PALETTE_ENTRY* pe;
|
|
|
|
UINT32* palette32;
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2014-09-18 02:30:09 +04:00
|
|
|
|
|
|
|
palette32 = (UINT32*) gdi->palette;
|
|
|
|
|
2015-05-07 21:20:49 +03:00
|
|
|
for (index = 0; index < (int) palette->number; index++)
|
2014-09-18 02:30:09 +04:00
|
|
|
{
|
|
|
|
pe = &(palette->entries[index]);
|
|
|
|
palette32[index] = RGB32(pe->red, pe->green, pe->blue);
|
|
|
|
}
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-07-28 22:32:16 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_set_bounds(rdpContext* context, rdpBounds* bounds)
|
2011-07-28 22:32:16 +04:00
|
|
|
{
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpGdi* 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,
|
|
|
|
bounds->right - bounds->left + 1, bounds->bottom - bounds->top + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdi_SetNullClipRgn(gdi->drawing->hdc);
|
|
|
|
}
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-07-28 22:32:16 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
|
2015-04-17 17:21:55 +03:00
|
|
|
dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)) == 0)
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* data;
|
2011-10-21 01:28:59 +04:00
|
|
|
rdpBrush* brush;
|
2014-02-13 20:59:05 +04:00
|
|
|
UINT32 foreColor;
|
|
|
|
UINT32 backColor;
|
|
|
|
GDI_COLOR originalColor;
|
2011-08-02 20:59:45 +04:00
|
|
|
HGDI_BRUSH originalBrush;
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = TRUE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2011-08-08 05:12:36 +04:00
|
|
|
brush = &patblt->brush;
|
2011-08-05 21:58:46 +04:00
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
foreColor = freerdp_convert_gdi_order_color(patblt->foreColor, gdi->srcBpp, gdi->format, gdi->palette);
|
|
|
|
backColor = freerdp_convert_gdi_order_color(patblt->backColor, gdi->srcBpp, gdi->format, gdi->palette);
|
2014-02-13 20:59:05 +04:00
|
|
|
|
|
|
|
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
|
|
|
|
|
2011-08-16 23:35:29 +04:00
|
|
|
if (brush->style == GDI_BS_SOLID)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
|
|
|
originalBrush = gdi->drawing->hdc->brush;
|
|
|
|
|
2014-02-13 20:59:05 +04:00
|
|
|
gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!gdi->drawing->hdc->brush)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_error;
|
|
|
|
}
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
|
2015-04-17 17:21:55 +03:00
|
|
|
patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)) == 0)
|
2015-04-14 11:14:23 +03:00
|
|
|
ret = FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
|
|
|
|
gdi->drawing->hdc->brush = originalBrush;
|
|
|
|
}
|
2013-02-04 18:58:22 +04:00
|
|
|
else if (brush->style == GDI_BS_HATCHED)
|
|
|
|
{
|
2014-10-22 05:56:10 +04:00
|
|
|
BYTE* hatched;
|
2013-02-04 18:58:22 +04:00
|
|
|
HGDI_BITMAP hBmp;
|
|
|
|
|
2014-10-22 05:56:10 +04:00
|
|
|
data = (BYTE*) _aligned_malloc(8 * 8 * gdi->bytesPerPixel, 16);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_error;
|
|
|
|
}
|
2014-10-22 05:56:10 +04:00
|
|
|
|
|
|
|
hatched = GDI_BS_HATCHED_PATTERNS + (8 * brush->hatch);
|
|
|
|
|
|
|
|
freerdp_image_copy_from_monochrome(data, gdi->format, -1, 0, 0, 8, 8,
|
|
|
|
hatched, backColor, foreColor, gdi->palette);
|
2013-02-04 18:58:22 +04:00
|
|
|
|
|
|
|
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->bitsPerPixel, data);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!hBmp)
|
|
|
|
{
|
|
|
|
_aligned_free(data);
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_error;
|
|
|
|
}
|
2013-02-04 18:58:22 +04:00
|
|
|
|
|
|
|
originalBrush = gdi->drawing->hdc->brush;
|
|
|
|
gdi->drawing->hdc->brush = gdi_CreateHatchBrush(hBmp);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!gdi->drawing->hdc->brush)
|
|
|
|
{
|
|
|
|
_aligned_free(data);
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_error;
|
|
|
|
}
|
2013-02-04 18:58:22 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
|
2015-04-17 17:21:55 +03:00
|
|
|
patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)) == 0)
|
2015-04-14 11:14:23 +03:00
|
|
|
ret = FALSE;
|
2013-02-04 18:58:22 +04:00
|
|
|
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
|
|
|
|
gdi->drawing->hdc->brush = originalBrush;
|
|
|
|
}
|
2011-08-16 23:35:29 +04:00
|
|
|
else if (brush->style == GDI_BS_PATTERN)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
|
|
|
HGDI_BITMAP hBmp;
|
2014-10-22 05:56:10 +04:00
|
|
|
UINT32 brushFormat;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2011-08-08 05:12:36 +04:00
|
|
|
if (brush->bpp > 1)
|
|
|
|
{
|
2014-10-22 05:56:10 +04:00
|
|
|
brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
|
|
|
|
|
|
|
|
data = (BYTE*) _aligned_malloc(8 * 8 * gdi->bytesPerPixel, 16);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_error;
|
|
|
|
}
|
2014-10-22 05:56:10 +04:00
|
|
|
|
|
|
|
freerdp_image_copy(data, gdi->format, -1, 0, 0,
|
|
|
|
8, 8, brush->data, brushFormat, -1, 0, 0, gdi->palette);
|
2011-08-08 05:12:36 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-22 05:56:10 +04:00
|
|
|
data = (BYTE*) _aligned_malloc(8 * 8 * gdi->bytesPerPixel, 16);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_error;
|
|
|
|
}
|
2014-10-22 05:56:10 +04:00
|
|
|
|
|
|
|
freerdp_image_copy_from_monochrome(data, gdi->format, -1, 0, 0, 8, 8,
|
|
|
|
brush->data, backColor, foreColor, gdi->palette);
|
2011-08-08 05:12:36 +04:00
|
|
|
}
|
2011-08-02 20:59:45 +04:00
|
|
|
|
|
|
|
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->bitsPerPixel, data);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!hBmp)
|
|
|
|
{
|
|
|
|
_aligned_free(data);
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_error;
|
|
|
|
}
|
2011-08-02 20:59:45 +04:00
|
|
|
|
|
|
|
originalBrush = gdi->drawing->hdc->brush;
|
|
|
|
gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!gdi->drawing->hdc->brush)
|
|
|
|
{
|
|
|
|
_aligned_free(data);
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_error;
|
|
|
|
}
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
|
2015-04-17 17:21:55 +03:00
|
|
|
patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)) == 0)
|
2015-04-14 11:14:23 +03:00
|
|
|
ret = FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
|
|
|
|
gdi->drawing->hdc->brush = originalBrush;
|
|
|
|
}
|
2011-08-04 11:39:10 +04:00
|
|
|
else
|
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "unimplemented brush style:%d", brush->style);
|
2011-08-04 11:39:10 +04:00
|
|
|
}
|
2014-02-13 20:59:05 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
out_error:
|
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
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
|
2011-08-02 20:59:45 +04:00
|
|
|
scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
|
2015-04-17 17:21:55 +03:00
|
|
|
scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop)) == 0)
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_opaque_rect(rdpContext* context, 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-04-14 11:14:23 +03:00
|
|
|
BOOL ret = FALSE;
|
2011-07-28 22:32:16 +04:00
|
|
|
|
|
|
|
gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect,
|
|
|
|
opaque_rect->nWidth, opaque_rect->nHeight, &rect);
|
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
brush_color = freerdp_convert_gdi_order_color(opaque_rect->color, gdi->srcBpp, gdi->format, gdi->palette);
|
2011-07-28 22:32:16 +04:00
|
|
|
|
|
|
|
hBrush = gdi_CreateSolidBrush(brush_color);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (hBrush)
|
|
|
|
{
|
|
|
|
if (gdi_FillRect(gdi->drawing->hdc, &rect, hBrush) == 0)
|
|
|
|
ret = TRUE;
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) hBrush);
|
|
|
|
}
|
|
|
|
return ret;
|
2011-07-28 09:34:53 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2011-08-04 01:09:12 +04:00
|
|
|
int i;
|
|
|
|
GDI_RECT rect;
|
|
|
|
HGDI_BRUSH hBrush;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 brush_color;
|
2011-08-04 01:09:12 +04:00
|
|
|
DELTA_RECT* rectangle;
|
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
|
|
|
|
2011-12-04 02:24:18 +04:00
|
|
|
for (i = 1; i < (int) multi_opaque_rect->numRectangles + 1; i++)
|
2011-08-04 01:09:12 +04:00
|
|
|
{
|
|
|
|
rectangle = &multi_opaque_rect->rectangles[i];
|
|
|
|
|
2011-08-04 11:23:53 +04:00
|
|
|
gdi_CRgnToRect(rectangle->left, rectangle->top,
|
|
|
|
rectangle->width, rectangle->height, &rect);
|
2011-08-04 01:09:12 +04:00
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
brush_color = freerdp_convert_gdi_order_color(multi_opaque_rect->color, gdi->srcBpp, gdi->format, gdi->palette);
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2011-08-04 01:09:12 +04:00
|
|
|
hBrush = gdi_CreateSolidBrush(brush_color);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!hBrush)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2011-08-04 01:09:12 +04:00
|
|
|
gdi_FillRect(gdi->drawing->hdc, &rect, hBrush);
|
|
|
|
|
2011-08-13 12:52:05 +04:00
|
|
|
gdi_DeleteObject((HGDIOBJECT) hBrush);
|
|
|
|
}
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_line_to(rdpContext* context, 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;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
color = freerdp_convert_gdi_order_color(lineTo->penColor, gdi->srcBpp, gdi->format, gdi->palette);
|
2014-02-13 20:59:05 +04:00
|
|
|
hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, (GDI_COLOR) color);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!hPen)
|
|
|
|
return FALSE;
|
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);
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2014-02-13 20:59:05 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
|
2011-08-05 00:22:15 +04:00
|
|
|
{
|
|
|
|
int 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;
|
2011-08-05 00:22:15 +04:00
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
color = freerdp_convert_gdi_order_color(polyline->penColor, gdi->srcBpp, gdi->format, gdi->palette);
|
2011-12-02 07:59:23 +04:00
|
|
|
hPen = gdi_CreatePen(GDI_PS_SOLID, 1, (GDI_COLOR) color);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!hPen)
|
|
|
|
return FALSE;
|
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;
|
|
|
|
gdi_MoveToEx(gdi->drawing->hdc, x, y, NULL);
|
2011-09-10 15:32:09 +04:00
|
|
|
|
2011-08-05 00:22:15 +04:00
|
|
|
points = polyline->points;
|
2014-10-09 14:11:38 +04:00
|
|
|
for (i = 0; i < (int) 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;
|
|
|
|
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
|
|
|
{
|
2011-10-13 23:51:07 +04:00
|
|
|
gdiBitmap* bitmap;
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2011-10-05 05:29:01 +04:00
|
|
|
|
2011-10-13 23:51:07 +04:00
|
|
|
bitmap = (gdiBitmap*) memblt->bitmap;
|
2011-10-10 05:23:18 +04:00
|
|
|
|
2015-04-17 17:21:55 +03:00
|
|
|
if (gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
|
2011-10-13 23:51:07 +04:00
|
|
|
memblt->nWidth, memblt->nHeight, bitmap->hdc,
|
2015-04-17 17:21:55 +03:00
|
|
|
memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop)) == 0)
|
|
|
|
return FALSE;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
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
|
|
|
{
|
2013-02-04 20:40:40 +04:00
|
|
|
BYTE* data;
|
2012-02-13 04:41:39 +04:00
|
|
|
rdpBrush* brush;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 foreColor;
|
|
|
|
UINT32 backColor;
|
2012-02-13 04:41:39 +04:00
|
|
|
gdiBitmap* bitmap;
|
2014-02-12 03:02:26 +04:00
|
|
|
GDI_COLOR originalColor;
|
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;
|
2012-02-13 04:41:39 +04:00
|
|
|
|
|
|
|
brush = &mem3blt->brush;
|
|
|
|
bitmap = (gdiBitmap*) mem3blt->bitmap;
|
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
foreColor = freerdp_convert_gdi_order_color(mem3blt->foreColor, gdi->srcBpp, gdi->format, gdi->palette);
|
|
|
|
backColor = freerdp_convert_gdi_order_color(mem3blt->backColor, gdi->srcBpp, gdi->format, gdi->palette);
|
2014-02-12 03:02:26 +04:00
|
|
|
|
|
|
|
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
|
2012-02-13 04:41:39 +04:00
|
|
|
|
|
|
|
if (brush->style == GDI_BS_SOLID)
|
|
|
|
{
|
|
|
|
originalBrush = gdi->drawing->hdc->brush;
|
|
|
|
gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!gdi->drawing->hdc->brush)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2012-02-13 04:41:39 +04:00
|
|
|
|
|
|
|
gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
|
|
|
|
mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
|
|
|
|
mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop));
|
|
|
|
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
|
|
|
|
gdi->drawing->hdc->brush = originalBrush;
|
|
|
|
}
|
2013-02-04 20:40:40 +04:00
|
|
|
else if (brush->style == GDI_BS_PATTERN)
|
|
|
|
{
|
|
|
|
HGDI_BITMAP hBmp;
|
2014-10-22 05:56:10 +04:00
|
|
|
UINT32 brushFormat;
|
2013-02-04 20:40:40 +04:00
|
|
|
|
|
|
|
if (brush->bpp > 1)
|
|
|
|
{
|
2014-10-22 05:56:10 +04:00
|
|
|
brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
|
|
|
|
|
|
|
|
data = (BYTE*) _aligned_malloc(8 * 8 * gdi->bytesPerPixel, 16);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2014-10-22 05:56:10 +04:00
|
|
|
|
|
|
|
freerdp_image_copy(data, gdi->format, -1, 0, 0,
|
|
|
|
8, 8, brush->data, brushFormat, -1, 0, 0, gdi->palette);
|
2013-02-04 20:40:40 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-22 05:56:10 +04:00
|
|
|
data = (BYTE*) _aligned_malloc(8 * 8 * gdi->bytesPerPixel, 16);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2014-10-22 05:56:10 +04:00
|
|
|
|
|
|
|
freerdp_image_copy_from_monochrome(data, gdi->format, -1, 0, 0, 8, 8,
|
|
|
|
brush->data, backColor, foreColor, gdi->palette);
|
2013-02-04 20:40:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->bitsPerPixel, data);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!hBmp)
|
|
|
|
{
|
|
|
|
_aligned_free(data);
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2013-02-04 20:40:40 +04:00
|
|
|
|
|
|
|
originalBrush = gdi->drawing->hdc->brush;
|
|
|
|
gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!gdi->drawing->hdc->brush)
|
|
|
|
{
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) hBmp);
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2013-02-04 20:40:40 +04:00
|
|
|
|
|
|
|
gdi_BitBlt(gdi->drawing->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
|
|
|
|
mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
|
|
|
|
mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop));
|
|
|
|
|
|
|
|
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
|
|
|
|
gdi->drawing->hdc->brush = originalBrush;
|
|
|
|
}
|
2012-02-13 04:41:39 +04:00
|
|
|
else
|
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%d", brush->style);
|
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
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
|
2012-02-13 00:21:08 +04:00
|
|
|
{
|
2014-09-25 10:56:55 +04:00
|
|
|
WLog_VRB(TAG, "not implemented");
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
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
|
|
|
{
|
2014-09-25 10:56:55 +04:00
|
|
|
WLog_VRB(TAG, "not implemented");
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2012-02-13 00:21:08 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_ellipse_sc(rdpContext* context, ELLIPSE_SC_ORDER* ellipse_sc)
|
2012-02-13 00:21:08 +04:00
|
|
|
{
|
2014-09-25 10:56:55 +04:00
|
|
|
WLog_VRB(TAG, "not implemented");
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2012-02-13 00:21:08 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_ellipse_cb(rdpContext* context, ELLIPSE_CB_ORDER* ellipse_cb)
|
2012-02-13 00:21:08 +04:00
|
|
|
{
|
2014-09-25 10:56:55 +04:00
|
|
|
WLog_VRB(TAG, "not implemented");
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-10-05 05:29:01 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_frame_marker(rdpContext* context, 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
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surfaceFrameMarker)
|
2013-07-15 17:00:18 +04:00
|
|
|
{
|
|
|
|
DEBUG_GDI("frameId %d frameAction %d",
|
2014-09-19 22:45:58 +04: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
|
|
|
{
|
2014-09-19 22:45:58 +04:00
|
|
|
IFCALL(context->update->SurfaceFrameAcknowledge, context, surfaceFrameMarker->frameId);
|
2013-07-15 17:00:18 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-07-15 17:00:18 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd)
|
2011-08-10 18:51:55 +04:00
|
|
|
{
|
2011-08-10 19:19:01 +04:00
|
|
|
int i, j;
|
|
|
|
int tx, ty;
|
2014-09-16 00:08:06 +04:00
|
|
|
BYTE* pSrcData;
|
|
|
|
BYTE* pDstData;
|
2011-09-01 04:36:46 +04:00
|
|
|
RFX_MESSAGE* message;
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2011-10-02 23:16:22 +04:00
|
|
|
|
2011-08-10 19:55:47 +04:00
|
|
|
DEBUG_GDI("destLeft %d destTop %d destRight %d destBottom %d "
|
2011-08-10 18:51:55 +04:00
|
|
|
"bpp %d codecID %d width %d height %d length %d",
|
2014-09-17 22:55:52 +04:00
|
|
|
cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
|
|
|
|
cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);
|
2011-08-10 18:51:55 +04:00
|
|
|
|
2014-09-10 08:42:41 +04:00
|
|
|
if (cmd->codecID == RDP_CODEC_ID_REMOTEFX)
|
2011-08-10 18:51:55 +04:00
|
|
|
{
|
2015-04-28 18:00:41 +03:00
|
|
|
if (!freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_REMOTEFX))
|
|
|
|
return FALSE;
|
2014-09-10 08:42:41 +04:00
|
|
|
|
2015-04-23 16:42:21 +03:00
|
|
|
if (!(message = rfx_process_message(gdi->codecs->rfx, cmd->bitmapData, cmd->bitmapDataLength)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to process RemoteFX message");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-10 19:55:47 +04:00
|
|
|
|
2011-09-14 23:09:49 +04:00
|
|
|
/* blit each tile */
|
2013-08-14 01:18:59 +04:00
|
|
|
for (i = 0; i < message->numTiles; i++)
|
2011-08-10 19:19:01 +04:00
|
|
|
{
|
2014-09-10 08:42:41 +04:00
|
|
|
tx = message->tiles[i]->x + cmd->destLeft;
|
|
|
|
ty = message->tiles[i]->y + cmd->destTop;
|
2011-08-10 19:19:01 +04:00
|
|
|
|
2014-09-16 00:08:06 +04:00
|
|
|
pSrcData = message->tiles[i]->data;
|
|
|
|
pDstData = gdi->tile->bitmap->data;
|
|
|
|
|
2014-09-18 03:44:59 +04:00
|
|
|
if (!gdi->invert && (gdi->dstBpp == 32))
|
2014-09-16 00:08:06 +04:00
|
|
|
{
|
|
|
|
gdi->tile->bitmap->data = pSrcData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-17 22:55:52 +04:00
|
|
|
freerdp_image_copy(pDstData, gdi->format, -1, 0, 0,
|
2014-09-18 02:30:09 +04:00
|
|
|
64, 64, pSrcData, PIXEL_FORMAT_XRGB32, -1, 0, 0, gdi->palette);
|
2014-09-16 00:08:06 +04:00
|
|
|
}
|
2011-08-10 19:19:01 +04:00
|
|
|
|
2013-08-14 01:18:59 +04:00
|
|
|
for (j = 0; j < message->numRects; j++)
|
2011-08-10 19:19:01 +04:00
|
|
|
{
|
2011-09-14 23:09:49 +04:00
|
|
|
gdi_SetClipRgn(gdi->primary->hdc,
|
2014-09-10 08:42:41 +04:00
|
|
|
cmd->destLeft + message->rects[j].x,
|
|
|
|
cmd->destTop + message->rects[j].y,
|
2011-09-14 23:09:49 +04:00
|
|
|
message->rects[j].width, message->rects[j].height);
|
2011-09-02 07:00:07 +04:00
|
|
|
|
2011-08-10 19:19:01 +04:00
|
|
|
gdi_BitBlt(gdi->primary->hdc, tx, ty, 64, 64, gdi->tile->hdc, 0, 0, GDI_SRCCOPY);
|
|
|
|
}
|
2014-09-16 00:08:06 +04:00
|
|
|
|
|
|
|
gdi->tile->bitmap->data = pDstData;
|
2011-08-10 19:19:01 +04:00
|
|
|
}
|
|
|
|
|
2011-09-14 23:09:49 +04:00
|
|
|
gdi_SetNullClipRgn(gdi->primary->hdc);
|
2014-09-10 08:42:41 +04:00
|
|
|
rfx_message_free(gdi->codecs->rfx, message);
|
2011-08-10 18:51:55 +04:00
|
|
|
}
|
2014-09-10 08:42:41 +04:00
|
|
|
else if (cmd->codecID == RDP_CODEC_ID_NSCODEC)
|
2011-10-02 23:16:22 +04:00
|
|
|
{
|
2015-04-28 18:00:41 +03:00
|
|
|
if (!freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_NSCODEC))
|
|
|
|
return FALSE;
|
2014-09-10 08:42:41 +04:00
|
|
|
|
2014-09-16 00:08:06 +04:00
|
|
|
nsc_process_message(gdi->codecs->nsc, cmd->bpp, cmd->width, cmd->height, cmd->bitmapData, cmd->bitmapDataLength);
|
|
|
|
|
|
|
|
if (gdi->bitmap_size < (cmd->width * cmd->height * 4))
|
|
|
|
{
|
|
|
|
gdi->bitmap_size = cmd->width * cmd->height * 4;
|
|
|
|
gdi->bitmap_buffer = (BYTE*) _aligned_realloc(gdi->bitmap_buffer, gdi->bitmap_size, 16);
|
|
|
|
|
|
|
|
if (!gdi->bitmap_buffer)
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
2014-09-16 00:08:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
pDstData = gdi->bitmap_buffer;
|
|
|
|
pSrcData = gdi->codecs->nsc->BitmapData;
|
|
|
|
|
2014-09-17 22:55:52 +04:00
|
|
|
freerdp_image_copy(pDstData, gdi->format, -1, 0, 0,
|
2014-09-18 02:30:09 +04:00
|
|
|
cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0, gdi->palette);
|
2014-09-16 00:08:06 +04:00
|
|
|
|
2014-09-10 08:42:41 +04:00
|
|
|
gdi->image->bitmap->width = cmd->width;
|
|
|
|
gdi->image->bitmap->height = cmd->height;
|
|
|
|
gdi->image->bitmap->bitsPerPixel = cmd->bpp;
|
2014-09-16 00:08:06 +04:00
|
|
|
gdi->image->bitmap->bytesPerPixel = cmd->bpp / 8;
|
|
|
|
gdi->image->bitmap->data = gdi->bitmap_buffer;
|
|
|
|
|
2014-09-10 08:42:41 +04:00
|
|
|
gdi_BitBlt(gdi->primary->hdc, cmd->destLeft, cmd->destTop, cmd->width, cmd->height, gdi->image->hdc, 0, 0, GDI_SRCCOPY);
|
2011-10-02 23:16:22 +04:00
|
|
|
}
|
2014-09-10 08:42:41 +04:00
|
|
|
else if (cmd->codecID == RDP_CODEC_ID_NONE)
|
2011-09-01 04:36:46 +04:00
|
|
|
{
|
2014-09-16 00:08:06 +04:00
|
|
|
if (gdi->bitmap_size < (cmd->width * cmd->height * 4))
|
2011-09-01 04:36:46 +04:00
|
|
|
{
|
2014-09-16 00:08:06 +04:00
|
|
|
gdi->bitmap_size = cmd->width * cmd->height * 4;
|
|
|
|
gdi->bitmap_buffer = (BYTE*) _aligned_realloc(gdi->bitmap_buffer, gdi->bitmap_size, 16);
|
2011-10-05 00:05:09 +04:00
|
|
|
|
2014-09-16 00:08:06 +04:00
|
|
|
if (!gdi->bitmap_buffer)
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
2014-09-16 00:08:06 +04:00
|
|
|
}
|
2011-09-01 04:36:46 +04:00
|
|
|
|
2014-09-16 00:08:06 +04:00
|
|
|
pDstData = gdi->bitmap_buffer;
|
|
|
|
pSrcData = cmd->bitmapData;
|
2011-09-01 04:36:46 +04:00
|
|
|
|
2014-09-17 22:55:52 +04:00
|
|
|
freerdp_image_copy(pDstData, gdi->format, -1, 0, 0,
|
2014-09-18 02:30:09 +04:00
|
|
|
cmd->width, cmd->height, pSrcData, PIXEL_FORMAT_XRGB32_VF, -1, 0, 0, gdi->palette);
|
2011-09-01 04:36:46 +04:00
|
|
|
|
2014-09-16 00:08:06 +04:00
|
|
|
gdi->image->bitmap->width = cmd->width;
|
|
|
|
gdi->image->bitmap->height = cmd->height;
|
|
|
|
gdi->image->bitmap->bitsPerPixel = cmd->bpp;
|
|
|
|
gdi->image->bitmap->bytesPerPixel = cmd->bpp / 8;
|
|
|
|
gdi->image->bitmap->data = gdi->bitmap_buffer;
|
|
|
|
|
|
|
|
gdi_BitBlt(gdi->primary->hdc, cmd->destLeft, cmd->destTop, cmd->width, cmd->height, gdi->image->hdc, 0, 0, GDI_SRCCOPY);
|
2011-09-01 04:36:46 +04:00
|
|
|
}
|
2011-08-10 18:51:55 +04:00
|
|
|
else
|
|
|
|
{
|
2014-09-18 03:09:56 +04:00
|
|
|
WLog_ERR(TAG, "Unsupported codecID %d", cmd->codecID);
|
2011-08-10 18:51:55 +04:00
|
|
|
}
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
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
|
|
|
|
*/
|
|
|
|
|
2011-07-28 09:17:17 +04:00
|
|
|
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-05 09:21:32 +04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
BOOL gdi_init_primary(rdpGdi* gdi)
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if (!gdi->primary_buffer)
|
|
|
|
gdi->primary->bitmap = gdi_CreateCompatibleBitmap(gdi->hdc, gdi->width, gdi->height);
|
|
|
|
else
|
|
|
|
gdi->primary->bitmap = gdi_CreateBitmap(gdi->width, gdi->height, gdi->dstBpp, gdi->primary_buffer);
|
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!gdi->primary->bitmap)
|
|
|
|
goto fail_bitmap;
|
|
|
|
|
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;
|
|
|
|
if (!(gdi->primary->hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0)))
|
|
|
|
goto fail_hwnd;
|
2011-09-07 09:26:17 +04:00
|
|
|
gdi->primary->hdc->hwnd->invalid->null = 1;
|
|
|
|
|
|
|
|
gdi->primary->hdc->hwnd->count = 32;
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!(gdi->primary->hdc->hwnd->cinvalid = (HGDI_RGN) calloc(gdi->primary->hdc->hwnd->count, sizeof(GDI_RGN))))
|
|
|
|
goto fail_hwnd;
|
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
|
|
|
}
|
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
BOOL gdi_resize(rdpGdi* gdi, int width, int height)
|
2011-09-07 09:26:17 +04:00
|
|
|
{
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!gdi || !gdi->primary)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (gdi->width == width && gdi->height == height)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (gdi->drawing == gdi->primary)
|
|
|
|
gdi->drawing = NULL;
|
|
|
|
|
|
|
|
gdi->width = width;
|
|
|
|
gdi->height = height;
|
|
|
|
gdi_bitmap_free_ex(gdi->primary);
|
|
|
|
|
|
|
|
gdi->primary = NULL;
|
|
|
|
gdi->primary_buffer = NULL;
|
|
|
|
|
|
|
|
return gdi_init_primary(gdi);
|
2011-09-07 09:26:17 +04:00
|
|
|
}
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
/**
|
|
|
|
* Initialize GDI
|
|
|
|
* @param inst current instance
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
BOOL gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2014-09-18 03:44:59 +04:00
|
|
|
BOOL rgb555;
|
2011-10-16 08:50:10 +04:00
|
|
|
rdpGdi* gdi;
|
2015-05-08 22:39:23 +03:00
|
|
|
rdpCache* cache = NULL;
|
2011-10-16 08:50:10 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
gdi = (rdpGdi*) calloc(1, sizeof(rdpGdi));
|
|
|
|
|
|
|
|
if (!gdi)
|
2015-05-08 22:39:23 +03:00
|
|
|
goto fail_gdi;
|
2011-10-16 08:50:10 +04:00
|
|
|
|
|
|
|
instance->context->gdi = gdi;
|
2014-09-12 22:57:44 +04:00
|
|
|
gdi->context = instance->context;
|
2014-09-10 08:42:41 +04:00
|
|
|
gdi->codecs = instance->context->codecs;
|
2012-11-07 19:33:06 +04:00
|
|
|
gdi->width = instance->settings->DesktopWidth;
|
|
|
|
gdi->height = instance->settings->DesktopHeight;
|
|
|
|
gdi->srcBpp = instance->settings->ColorDepth;
|
2011-10-05 00:05:09 +04:00
|
|
|
gdi->primary_buffer = buffer;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
/* default internal buffer format */
|
|
|
|
gdi->dstBpp = 32;
|
|
|
|
gdi->bytesPerPixel = 4;
|
2014-09-16 00:08:06 +04:00
|
|
|
gdi->format = PIXEL_FORMAT_XRGB32;
|
|
|
|
|
2014-09-18 03:44:59 +04:00
|
|
|
if (flags & CLRCONV_INVERT)
|
|
|
|
gdi->invert = TRUE;
|
|
|
|
|
|
|
|
rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE;
|
2014-09-16 00:08:06 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
if (gdi->srcBpp > 16)
|
|
|
|
{
|
|
|
|
if (flags & CLRBUF_32BPP)
|
|
|
|
{
|
|
|
|
gdi->dstBpp = 32;
|
|
|
|
gdi->bytesPerPixel = 4;
|
|
|
|
}
|
|
|
|
else if (flags & CLRBUF_16BPP)
|
|
|
|
{
|
2014-09-18 03:44:59 +04:00
|
|
|
gdi->dstBpp = rgb555 ? 15 : 16;
|
2011-07-01 05:23:36 +04:00
|
|
|
gdi->bytesPerPixel = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flags & CLRBUF_16BPP)
|
|
|
|
{
|
2014-09-18 03:44:59 +04:00
|
|
|
gdi->dstBpp = rgb555 ? 15 : 16;
|
2011-07-01 05:23:36 +04:00
|
|
|
gdi->bytesPerPixel = 2;
|
|
|
|
}
|
|
|
|
else if (flags & CLRBUF_32BPP)
|
|
|
|
{
|
|
|
|
gdi->dstBpp = 32;
|
|
|
|
gdi->bytesPerPixel = 4;
|
|
|
|
}
|
|
|
|
}
|
2013-02-04 00:16:37 +04:00
|
|
|
|
2014-09-18 03:44:59 +04:00
|
|
|
if (!gdi->invert)
|
2014-09-16 00:08:06 +04:00
|
|
|
{
|
|
|
|
if (gdi->bytesPerPixel == 4)
|
|
|
|
gdi->format = PIXEL_FORMAT_XRGB32;
|
|
|
|
else if ((gdi->bytesPerPixel == 2) && (gdi->dstBpp == 16))
|
|
|
|
gdi->format = PIXEL_FORMAT_RGB565;
|
|
|
|
else if ((gdi->bytesPerPixel == 2) && (gdi->dstBpp == 15))
|
|
|
|
gdi->format = PIXEL_FORMAT_RGB555;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gdi->bytesPerPixel == 4)
|
|
|
|
gdi->format = PIXEL_FORMAT_XBGR32;
|
|
|
|
else if ((gdi->bytesPerPixel == 2) && (gdi->dstBpp == 16))
|
|
|
|
gdi->format = PIXEL_FORMAT_BGR565;
|
|
|
|
else if ((gdi->bytesPerPixel == 2) && (gdi->dstBpp == 15))
|
|
|
|
gdi->format = PIXEL_FORMAT_BGR555;
|
|
|
|
}
|
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!(gdi->hdc = gdi_GetDC()))
|
|
|
|
goto fail_get_hdc;
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
gdi->hdc->bitsPerPixel = gdi->dstBpp;
|
|
|
|
gdi->hdc->bytesPerPixel = gdi->bytesPerPixel;
|
|
|
|
|
2014-10-22 06:19:11 +04:00
|
|
|
gdi->hdc->alpha = (flags & CLRCONV_ALPHA) ? TRUE : FALSE;
|
|
|
|
gdi->hdc->invert = (flags & CLRCONV_INVERT) ? TRUE : FALSE;
|
|
|
|
gdi->hdc->rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!gdi_init_primary(gdi))
|
|
|
|
goto fail_init_primary;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!(gdi->tile = gdi_bitmap_new_ex(gdi, 64, 64, 32, NULL)))
|
|
|
|
goto fail_tile_bitmap;
|
|
|
|
if (!(gdi->image = gdi_bitmap_new_ex(gdi, 64, 64, 32, NULL)))
|
|
|
|
goto fail_image_bitmap;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!instance->context->cache)
|
2011-10-13 23:51:07 +04:00
|
|
|
{
|
2015-05-08 22:39:23 +03:00
|
|
|
if (!(cache = cache_new(instance->settings)))
|
|
|
|
goto fail_cache;
|
|
|
|
|
2011-10-16 08:50:10 +04:00
|
|
|
instance->context->cache = cache;
|
2011-10-13 23:51:07 +04:00
|
|
|
}
|
|
|
|
|
2011-07-28 09:17:17 +04:00
|
|
|
gdi_register_update_callbacks(instance->update);
|
2011-07-01 05:23:36 +04:00
|
|
|
|
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))
|
|
|
|
goto fail_register_graphics;
|
2011-08-05 06:43:36 +04:00
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
instance->update->BitmapUpdate = gdi_bitmap_update;
|
|
|
|
|
2015-05-08 22:39:23 +03:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
fail_register_graphics:
|
2015-05-14 21:33:21 +03:00
|
|
|
if (cache)
|
|
|
|
{
|
|
|
|
instance->context->cache = NULL;
|
|
|
|
free(cache);
|
|
|
|
}
|
2015-05-08 22:39:23 +03:00
|
|
|
fail_cache:
|
|
|
|
gdi_bitmap_free_ex(gdi->image);
|
|
|
|
fail_image_bitmap:
|
|
|
|
gdi_bitmap_free_ex(gdi->tile);
|
|
|
|
fail_tile_bitmap:
|
|
|
|
gdi_bitmap_free_ex(gdi->primary);
|
|
|
|
fail_init_primary:
|
|
|
|
gdi_DeleteDC(gdi->hdc);
|
|
|
|
fail_get_hdc:
|
|
|
|
free(gdi);
|
|
|
|
fail_gdi:
|
|
|
|
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
|
|
|
{
|
2011-10-16 08:50:10 +04:00
|
|
|
rdpGdi* gdi = instance->context->gdi;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
if (gdi)
|
|
|
|
{
|
2011-10-13 23:51:07 +04:00
|
|
|
gdi_bitmap_free_ex(gdi->primary);
|
|
|
|
gdi_bitmap_free_ex(gdi->tile);
|
|
|
|
gdi_bitmap_free_ex(gdi->image);
|
2011-07-27 17:45:44 +04:00
|
|
|
gdi_DeleteDC(gdi->hdc);
|
2014-09-12 04:46:15 +04:00
|
|
|
_aligned_free(gdi->bitmap_buffer);
|
2011-07-01 05:23:36 +04:00
|
|
|
free(gdi);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|