From 65d7e17d4cc9ab363cad58129fd04c9ea71326f9 Mon Sep 17 00:00:00 2001 From: Martin Haimberger Date: Wed, 15 Jan 2014 05:52:48 -0800 Subject: [PATCH 1/4] improved WLog childlogger use per default now a WLOG_LEVEL_INHERIT level so the loglevel is taken from the first parent which has another level set. --- winpr/include/winpr/wlog.h | 9 +-- winpr/libwinpr/utils/wlog/BinaryAppender.c | 3 - winpr/libwinpr/utils/wlog/ConsoleAppender.c | 3 - winpr/libwinpr/utils/wlog/FileAppender.c | 3 - winpr/libwinpr/utils/wlog/wlog.c | 71 +++++++++++---------- 5 files changed, 43 insertions(+), 46 deletions(-) diff --git a/winpr/include/winpr/wlog.h b/winpr/include/winpr/wlog.h index 87b79c8a2..eda5e60a3 100644 --- a/winpr/include/winpr/wlog.h +++ b/winpr/include/winpr/wlog.h @@ -48,6 +48,7 @@ typedef struct _wLogAppender wLogAppender; #define WLOG_ERROR 4 #define WLOG_FATAL 5 #define WLOG_OFF 6 +#define WLOG_LEVEL_INHERIT 0xFFFF /** * Log Message @@ -198,7 +199,7 @@ struct _wLog WINPR_API void WLog_PrintMessage(wLog* log, wLogMessage* message, ...); #define WLog_Print(_log, _log_level, _fmt, ...) \ - if (_log_level >= _log->Level) { \ + if (_log_level >= WLog_GetLogLevel(_log)) { \ wLogMessage _log_message; \ _log_message.Type = WLOG_MESSAGE_TEXT; \ _log_message.Level = _log_level; \ @@ -210,7 +211,7 @@ WINPR_API void WLog_PrintMessage(wLog* log, wLogMessage* message, ...); } #define WLog_Data(_log, _log_level, ...) \ - if (_log_level >= _log->Level) { \ + if (_log_level >= WLog_GetLogLevel(_log)) { \ wLogMessage _log_message; \ _log_message.Type = WLOG_MESSAGE_DATA; \ _log_message.Level = _log_level; \ @@ -222,7 +223,7 @@ WINPR_API void WLog_PrintMessage(wLog* log, wLogMessage* message, ...); } #define WLog_Image(_log, _log_level, ...) \ - if (_log_level >= _log->Level) { \ + if (_log_level >= WLog_GetLogLevel(_log)) { \ wLogMessage _log_message; \ _log_message.Type = WLOG_MESSAGE_IMAGE; \ _log_message.Level = _log_level; \ @@ -234,7 +235,7 @@ WINPR_API void WLog_PrintMessage(wLog* log, wLogMessage* message, ...); } #define WLog_Packet(_log, _log_level, ...) \ - if (_log_level >= _log->Level) { \ + if (_log_level >= WLog_GetLogLevel(_log)) { \ wLogMessage _log_message; \ _log_message.Type = WLOG_MESSAGE_PACKET; \ _log_message.Level = _log_level; \ diff --git a/winpr/libwinpr/utils/wlog/BinaryAppender.c b/winpr/libwinpr/utils/wlog/BinaryAppender.c index f77b99dbb..f0bd1ba5f 100644 --- a/winpr/libwinpr/utils/wlog/BinaryAppender.c +++ b/winpr/libwinpr/utils/wlog/BinaryAppender.c @@ -122,9 +122,6 @@ int WLog_BinaryAppender_WriteMessage(wLog* log, wLogBinaryAppender* appender, wL int FunctionNameLength; int TextStringLength; - if (message->Level > log->Level) - return 0; - fp = appender->FileDescriptor; if (!fp) diff --git a/winpr/libwinpr/utils/wlog/ConsoleAppender.c b/winpr/libwinpr/utils/wlog/ConsoleAppender.c index 0b4375a3e..c9ed6bc66 100644 --- a/winpr/libwinpr/utils/wlog/ConsoleAppender.c +++ b/winpr/libwinpr/utils/wlog/ConsoleAppender.c @@ -68,9 +68,6 @@ int WLog_ConsoleAppender_WriteMessage(wLog* log, wLogConsoleAppender* appender, FILE* fp; char prefix[WLOG_MAX_PREFIX_SIZE]; - if (message->Level < log->Level) - return 0; - fp = (appender->outputStream == WLOG_CONSOLE_STDERR) ? stderr : stdout; message->PrefixString = prefix; diff --git a/winpr/libwinpr/utils/wlog/FileAppender.c b/winpr/libwinpr/utils/wlog/FileAppender.c index 5acb75256..8904310cb 100644 --- a/winpr/libwinpr/utils/wlog/FileAppender.c +++ b/winpr/libwinpr/utils/wlog/FileAppender.c @@ -117,9 +117,6 @@ int WLog_FileAppender_WriteMessage(wLog* log, wLogFileAppender* appender, wLogMe FILE* fp; char prefix[WLOG_MAX_PREFIX_SIZE]; - if (message->Level > log->Level) - return 0; - fp = appender->FileDescriptor; if (!fp) diff --git a/winpr/libwinpr/utils/wlog/wlog.c b/winpr/libwinpr/utils/wlog/wlog.c index 6df27a5ea..d6a2a9ac4 100644 --- a/winpr/libwinpr/utils/wlog/wlog.c +++ b/winpr/libwinpr/utils/wlog/wlog.c @@ -216,14 +216,20 @@ void WLog_PrintMessage(wLog* log, wLogMessage* message, ...) DWORD WLog_GetLogLevel(wLog* log) { - return log->Level; + if (log->Level == WLOG_LEVEL_INHERIT) { + return WLog_GetLogLevel(log->Parent); + } else { + return log->Level; + } } void WLog_SetLogLevel(wLog* log, DWORD logLevel) { - if (logLevel > WLOG_OFF) - logLevel = WLOG_OFF; + if ((logLevel > WLOG_OFF) && (logLevel != WLOG_LEVEL_INHERIT)) + { + logLevel = WLOG_OFF; + } log->Level = logLevel; } @@ -276,7 +282,7 @@ wLog* WLog_New(LPCSTR name , wLog* rootLogger) log->Name = _strdup(name); WLog_ParseName(log, name); - log->Parent = NULL; + log->Parent = rootLogger; log->ChildrenCount = 0; log->ChildrenSize = 16; @@ -285,41 +291,40 @@ wLog* WLog_New(LPCSTR name , wLog* rootLogger) log->Appender = NULL; if (rootLogger) { - log->Level = rootLogger->Level; + log->Level = WLOG_LEVEL_INHERIT; } else { log->Level = WLOG_WARN; - } + nSize = GetEnvironmentVariableA("WLOG_LEVEL", NULL, 0); - nSize = GetEnvironmentVariableA("WLOG_LEVEL", NULL, 0); - - if (nSize) - { - env = (LPSTR) malloc(nSize); - nSize = GetEnvironmentVariableA("WLOG_LEVEL", env, nSize); - - if (env) + if (nSize) { - if (_stricmp(env, "TRACE") == 0) - log->Level = WLOG_TRACE; - else if (_stricmp(env, "DEBUG") == 0) - log->Level = WLOG_DEBUG; - else if (_stricmp(env, "INFO") == 0) - log->Level = WLOG_INFO; - else if (_stricmp(env, "WARN") == 0) - log->Level = WLOG_WARN; - else if (_stricmp(env, "ERROR") == 0) - log->Level = WLOG_ERROR; - else if (_stricmp(env, "FATAL") == 0) - log->Level = WLOG_FATAL; - else if (_stricmp(env, "OFF") == 0) - log->Level = WLOG_OFF; - else if (_strnicmp(env, "0x", 2) == 0) - { - /* TODO: read custom hex value */ - } + env = (LPSTR) malloc(nSize); + nSize = GetEnvironmentVariableA("WLOG_LEVEL", env, nSize); - free(env); + if (env) + { + if (_stricmp(env, "TRACE") == 0) + log->Level = WLOG_TRACE; + else if (_stricmp(env, "DEBUG") == 0) + log->Level = WLOG_DEBUG; + else if (_stricmp(env, "INFO") == 0) + log->Level = WLOG_INFO; + else if (_stricmp(env, "WARN") == 0) + log->Level = WLOG_WARN; + else if (_stricmp(env, "ERROR") == 0) + log->Level = WLOG_ERROR; + else if (_stricmp(env, "FATAL") == 0) + log->Level = WLOG_FATAL; + else if (_stricmp(env, "OFF") == 0) + log->Level = WLOG_OFF; + else if (_strnicmp(env, "0x", 2) == 0) + { + /* TODO: read custom hex value */ + } + + free(env); + } } } } From 24ee27354099b2e275b802f9ccc86ac10d1fd75a Mon Sep 17 00:00:00 2001 From: Martin Haimberger Date: Wed, 15 Jan 2014 06:15:18 -0800 Subject: [PATCH 2/4] fixed compiler warning --- winpr/include/winpr/cmdline.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winpr/include/winpr/cmdline.h b/winpr/include/winpr/cmdline.h index e38f8fec4..6c5f605db 100644 --- a/winpr/include/winpr/cmdline.h +++ b/winpr/include/winpr/cmdline.h @@ -93,7 +93,7 @@ struct _COMMAND_LINE_ARGUMENT_A LPCSTR Name; DWORD Flags; LPCSTR Format; - LPSTR Default; + LPCSTR Default; LPSTR Value; LONG Index; LPCSTR Alias; From f4140abd2c5b8c53d50b0237f8e579234b3d200d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Moreau?= Date: Wed, 12 Feb 2014 11:51:57 -0500 Subject: [PATCH 3/4] cmake: remove unused FindNPP.cmake --- CMakeLists.txt | 5 -- cmake/FindNPP.cmake | 119 -------------------------------------------- 2 files changed, 124 deletions(-) delete mode 100644 cmake/FindNPP.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 13265f13b..85132055b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -377,10 +377,6 @@ set(IPP_FEATURE_TYPE "OPTIONAL") set(IPP_FEATURE_PURPOSE "performance") set(IPP_FEATURE_DESCRIPTION "Intel Integrated Performance Primitives library") -set(NPP_FEATURE_TYPE "OPTIONAL") -set(NPP_FEATURE_PURPOSE "performance") -set(NPP_FEATURE_DESCRIPTION "NVIDIA Performance Primitives library") - set(JPEG_FEATURE_TYPE "OPTIONAL") set(JPEG_FEATURE_PURPOSE "codec") set(JPEG_FEATURE_DESCRIPTION "use JPEG library") @@ -458,7 +454,6 @@ if(TARGET_ARCH MATCHES "x86|x64") # Intel Performance Primitives find_feature(IPP ${IPP_FEATURE_TYPE} ${IPP_FEATURE_PURPOSE} ${IPP_FEATURE_DESCRIPTION}) endif() - find_feature(NPP ${NPP_FEATURE_TYPE} ${NPP_FEATURE_PURPOSE} ${NPP_FEATURE_DESCRIPTION}) endif() # Path to put FreeRDP data diff --git a/cmake/FindNPP.cmake b/cmake/FindNPP.cmake deleted file mode 100644 index 7b04ee43a..000000000 --- a/cmake/FindNPP.cmake +++ /dev/null @@ -1,119 +0,0 @@ -############################################################################### -# -# FindNPP.cmake -# -# NPP_LIBRARY_ROOT_DIR -- Path to the NPP dorectory. -# NPP_INCLUDES -- NPP Include directories. -# NPP_LIBRARIES -- NPP libraries. -# NPP_VERSION -- NPP version in format "major.minor.build". -# -# If not found automatically, please set NPP_LIBRARY_ROOT_DIR -# in CMake or set enviroment varivabe $NPP_ROOT -# -# Author: Anatoly Baksheev, Itseez Ltd. -# -# The MIT License -# -# License for the specific language governing rights and limitations under -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -############################################################################### - -cmake_policy(PUSH) -cmake_minimum_required(VERSION 2.8.0) -cmake_policy(POP) - -if(NOT "${NPP_LIBRARY_ROOT_DIR}" STREQUAL "${NPP_LIBRARY_ROOT_DIR_INTERNAL}") - unset(NPP_INCLUDES CACHE) - unset(NPP_LIBRARIES CACHE) -endif() - -if(CMAKE_SIZEOF_VOID_P EQUAL 4) - if (UNIX OR APPLE) - set(NPP_SUFFIX "32") - else() - set(NPP_SUFFIX "-mt") - endif() -else(CMAKE_SIZEOF_VOID_P EQUAL 4) - if (UNIX OR APPLE) - set(NPP_SUFFIX "64") - else() - set(NPP_SUFFIX "-mt-x64") - endif() -endif(CMAKE_SIZEOF_VOID_P EQUAL 4) - -find_path(CUDA_ROOT_DIR "doc/CUDA_Toolkit_Release_Notes.txt" - PATHS "/Developer/NVIDIA" - PATH_SUFFIXES "CUDA-5.0" - DOC "CUDA root directory") - -find_path(NPP_INCLUDES "npp.h" - PATHS "${CUDA_ROOT_DIR}" - PATH_SUFFIXES "include" - DOC "NPP include directory") -mark_as_advanced(NPP_INCLUDES) - -find_library(NPP_LIBRARIES - NAMES "npp" "libnpp" "npp${NPP_SUFFIX}" "libnpp${NPP_SUFFIX}" - PATHS "${CUDA_ROOT_DIR}" - PATH_SUFFIXES "lib" - DOC "NPP library") -mark_as_advanced(NPP_LIBRARIES) - -if(EXISTS ${NPP_INCLUDES}/nppversion.h) - file(STRINGS ${NPP_INCLUDES}/nppversion.h npp_major REGEX "#define NPP_VERSION_MAJOR.*") - file(STRINGS ${NPP_INCLUDES}/nppversion.h npp_minor REGEX "#define NPP_VERSION_MINOR.*") - file(STRINGS ${NPP_INCLUDES}/nppversion.h npp_build REGEX "#define NPP_VERSION_BUILD.*") - - string(REGEX REPLACE "#define NPP_VERSION_MAJOR[ \t]+|//.*" "" npp_major ${npp_major}) - string(REGEX REPLACE "#define NPP_VERSION_MINOR[ \t]+|//.*" "" npp_minor ${npp_minor}) - string(REGEX REPLACE "#define NPP_VERSION_BUILD[ \t]+|//.*" "" npp_build ${npp_build}) - - string(REGEX MATCH "[0-9]+" npp_major ${npp_major}) - string(REGEX MATCH "[0-9]+" npp_minor ${npp_minor}) - string(REGEX MATCH "[0-9]+" npp_build ${npp_build}) - set(NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}") -endif() - -if(NOT EXISTS ${NPP_LIBRARIES} OR NOT EXISTS ${NPP_INCLUDES}/npp.h) - set(NPP_FOUND FALSE) - message(WARNING "NPP headers/libraries are not found. Please specify NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR.") -endif() - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args(NPP - REQUIRED_VARS - NPP_INCLUDES - NPP_LIBRARIES - NPP_VERSION) - -if(APPLE) - # We need to add the path to cudart to the linker using rpath, since the library name for the cuda libraries is prepended with @rpath. - get_filename_component(_cuda_path_to_npp "${NPP_LIBRARIES}" PATH) - if(_cuda_path_to_npp) - list(APPEND NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}") - endif() -endif() - -set(NPP_FOUND TRUE) - -set(NPP_LIBRARY_ROOT_DIR_INTERNAL "${NPP_LIBRARY_ROOT_DIR}" CACHE INTERNAL - "This is the value of the last time NPP_LIBRARY_ROOT_DIR was set successfully." FORCE) - From 35a1aeac99ed962c5844c30ec7a4006ca8e2189e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 13 Feb 2014 11:59:05 -0500 Subject: [PATCH 4/4] libfreerdp-gdi: minor cleanup, set text color on PatBlt --- libfreerdp/gdi/gdi.c | 44 +++++++++++++++++++++++---------------- libfreerdp/gdi/graphics.c | 31 ++++++++++++++++----------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/libfreerdp/gdi/gdi.c b/libfreerdp/gdi/gdi.c index 2454a16ce..2bc0091b4 100644 --- a/libfreerdp/gdi/gdi.c +++ b/libfreerdp/gdi/gdi.c @@ -313,7 +313,7 @@ static const UINT32 rop3_code_table[] = }; /* Hatch Patterns as monochrome data */ -static BYTE GDI_BS_HACHTED_PATTERNS[] = +static BYTE GDI_BS_HATCHED_PATTERNS[] = { 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, /* HS_HORIZONTAL */ 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, /* HS_VERTICAL */ @@ -438,7 +438,7 @@ gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp, BYTE* void gdi_bitmap_free_ex(gdiBitmap* bitmap) { - if (bitmap != NULL) + if (bitmap) { gdi_SelectObject(bitmap->hdc, (HGDIOBJECT) bitmap->org_bitmap); gdi_DeleteObject((HGDIOBJECT) bitmap->bitmap); @@ -457,7 +457,7 @@ void gdi_set_bounds(rdpContext* context, rdpBounds* bounds) { rdpGdi* gdi = context->gdi; - if (bounds != NULL) + if (bounds) { gdi_SetClipRgn(gdi->drawing->hdc, bounds->left, bounds->top, bounds->right - bounds->left + 1, bounds->bottom - bounds->top + 1); @@ -480,18 +480,24 @@ void gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { BYTE* data; rdpBrush* brush; + UINT32 foreColor; + UINT32 backColor; + GDI_COLOR originalColor; HGDI_BRUSH originalBrush; rdpGdi* gdi = context->gdi; brush = &patblt->brush; + foreColor = freerdp_color_convert_rgb(patblt->foreColor, gdi->srcBpp, 24, gdi->clrconv); + backColor = freerdp_color_convert_rgb(patblt->backColor, gdi->srcBpp, 24, gdi->clrconv); + + originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor); + if (brush->style == GDI_BS_SOLID) { - UINT32 color; originalBrush = gdi->drawing->hdc->brush; - color = freerdp_color_convert_rgb(patblt->foreColor, gdi->srcBpp, 32, gdi->clrconv); - gdi->drawing->hdc->brush = gdi_CreateSolidBrush(color); + gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor); gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)); @@ -503,7 +509,7 @@ void gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { HGDI_BITMAP hBmp; - data = freerdp_mono_image_convert(GDI_BS_HACHTED_PATTERNS + 8 * brush->hatch, 8, 8, 1, + data = freerdp_mono_image_convert(GDI_BS_HATCHED_PATTERNS + 8 * brush->hatch, 8, 8, 1, gdi->dstBpp, patblt->backColor, patblt->foreColor, gdi->clrconv); hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->bitsPerPixel, data); @@ -546,6 +552,8 @@ void gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { fprintf(stderr, "unimplemented brush style:%d\n", brush->style); } + + gdi_SetTextColor(gdi->drawing->hdc, originalColor); } void gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) @@ -562,7 +570,7 @@ void gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) GDI_RECT rect; HGDI_BRUSH hBrush; UINT32 brush_color; - rdpGdi *gdi = context->gdi; + rdpGdi* gdi = context->gdi; gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight, &rect); @@ -582,7 +590,7 @@ void gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_o HGDI_BRUSH hBrush; UINT32 brush_color; DELTA_RECT* rectangle; - rdpGdi *gdi = context->gdi; + rdpGdi* gdi = context->gdi; for (i = 1; i < (int) multi_opaque_rect->numRectangles + 1; i++) { @@ -600,19 +608,19 @@ void gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_o } } -void gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to) +void gdi_line_to(rdpContext* context, LINE_TO_ORDER* lineTo) { UINT32 color; HGDI_PEN hPen; - rdpGdi *gdi = context->gdi; + rdpGdi* gdi = context->gdi; - color = freerdp_color_convert_rgb(line_to->penColor, gdi->srcBpp, 32, gdi->clrconv); - hPen = gdi_CreatePen(line_to->penStyle, line_to->penWidth, (GDI_COLOR) color); + color = freerdp_color_convert_rgb(lineTo->penColor, gdi->srcBpp, 32, gdi->clrconv); + hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, (GDI_COLOR) color); gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen); - gdi_SetROP2(gdi->drawing->hdc, line_to->bRop2); + gdi_SetROP2(gdi->drawing->hdc, lineTo->bRop2); - gdi_MoveToEx(gdi->drawing->hdc, line_to->nXStart, line_to->nYStart, NULL); - gdi_LineTo(gdi->drawing->hdc, line_to->nXEnd, line_to->nYEnd); + gdi_MoveToEx(gdi->drawing->hdc, lineTo->nXStart, lineTo->nYStart, NULL); + gdi_LineTo(gdi->drawing->hdc, lineTo->nXEnd, lineTo->nYEnd); gdi_DeleteObject((HGDIOBJECT) hPen); } @@ -620,12 +628,12 @@ void gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to) void gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline) { int i; + INT32 x; + INT32 y; UINT32 color; HGDI_PEN hPen; DELTA_POINT* points; rdpGdi* gdi = context->gdi; - INT32 x; - INT32 y; color = freerdp_color_convert_rgb(polyline->penColor, gdi->srcBpp, 32, gdi->clrconv); hPen = gdi_CreatePen(GDI_PS_SOLID, 1, (GDI_COLOR) color); diff --git a/libfreerdp/gdi/graphics.c b/libfreerdp/gdi/graphics.c index 2be36a50a..084c1b17c 100644 --- a/libfreerdp/gdi/graphics.c +++ b/libfreerdp/gdi/graphics.c @@ -96,36 +96,37 @@ void gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap) void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, BYTE* data, int width, int height, int bpp, int length, - BOOL compressed, int codec_id) + BOOL compressed, int codecId) { + BOOL status; UINT16 size; - RFX_MESSAGE* msg; BYTE* src; BYTE* dst; int yindex; int xindex; rdpGdi* gdi; - BOOL status; + RFX_MESSAGE* msg; size = width * height * ((bpp + 7) / 8); - if (bitmap->data == NULL) + if (!bitmap->data) bitmap->data = (BYTE*) malloc(size); else bitmap->data = (BYTE*) realloc(bitmap->data, size); - switch (codec_id) + switch (codecId) { case RDP_CODEC_ID_NSCODEC: gdi = context->gdi; nsc_process_message(gdi->nsc_context, bpp, width, height, data, length); - freerdp_image_flip(((NSC_CONTEXT*)gdi->nsc_context)->BitmapData, bitmap->data, width, height, bpp); + freerdp_image_flip(((NSC_CONTEXT*) gdi->nsc_context)->BitmapData, bitmap->data, width, height, bpp); break; + case RDP_CODEC_ID_REMOTEFX: gdi = context->gdi; rfx_context_set_pixel_format(gdi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); msg = rfx_process_message(gdi->rfx_context, data, length); - if (msg == NULL) + if (!msg) { fprintf(stderr, "gdi_Bitmap_Decompress: rfx Decompression Failed\n"); } @@ -159,7 +160,7 @@ void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, { status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp); - if (status == FALSE) + if (!status) { fprintf(stderr, "gdi_Bitmap_Decompress: Bitmap Decompression Failed\n"); } @@ -268,8 +269,11 @@ void gdi_register_graphics(rdpGraphics* graphics) rdpBitmap* bitmap; rdpGlyph* glyph; - bitmap = (rdpBitmap*) malloc(sizeof(rdpBitmap)); - ZeroMemory(bitmap, sizeof(rdpBitmap)); + bitmap = (rdpBitmap*) calloc(1, sizeof(rdpBitmap)); + + if (!bitmap) + return; + bitmap->size = sizeof(gdiBitmap); bitmap->New = gdi_Bitmap_New; @@ -281,8 +285,11 @@ void gdi_register_graphics(rdpGraphics* graphics) graphics_register_bitmap(graphics, bitmap); free(bitmap); - glyph = (rdpGlyph*) malloc(sizeof(rdpGlyph)); - ZeroMemory(glyph, sizeof(rdpGlyph)); + glyph = (rdpGlyph*) calloc(1, sizeof(rdpGlyph)); + + if (!glyph) + return; + glyph->size = sizeof(gdiGlyph); glyph->New = gdi_Glyph_New;