Code refactoring.
authorArmin Novak <armin.novak@thincast.com>
Thu, 14 Jul 2016 10:42:24 +0000 (12:42 +0200)
committerArmin Novak <armin.novak@thincast.com>
Thu, 6 Oct 2016 11:43:01 +0000 (13:43 +0200)
libfreerdp/gdi/bitmap.c
libfreerdp/gdi/brush.c
libfreerdp/gdi/gdi.c
libfreerdp/gdi/graphics.c

index 37d6bcb..521bda0 100644 (file)
@@ -415,13 +415,13 @@ static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 
                        if (srcp && dstp)
                        {
-                               UINT32 color;
+                               UINT32 dstColor;
                                UINT32 colorA = ReadColor(srcp, hdcSrc->format);
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
                                colorA = ConvertColor(colorA, hdcSrc->format,
                                                      hdcDest->format, palette);
-                               color = (colorA & color) | (~colorA & colorB);
-                               WriteColor(dstp, hdcDest->format, color);
+                               dstColor = (colorA & color) | (~colorA & colorB);
+                               WriteColor(dstp, hdcDest->format, dstColor);
                        }
                }
        }
@@ -799,9 +799,7 @@ BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                                 hdcSrc, nXSrc, nYSrc, palette);
 
                default:
-                       break;
+                       WLog_ERR(TAG,  "BitBlt: unknown rop: 0x%08X", rop);
+                       return FALSE;
        }
-
-       WLog_ERR(TAG,  "BitBlt: unknown rop: 0x%08X", rop);
-       return FALSE;
 }
index d213cc6..3e5ac14 100644 (file)
@@ -563,7 +563,7 @@ static BOOL BitBlt_WHITENESS(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                              UINT32 nWidth, UINT32 nHeight)
 {
        UINT32 x, y;
-       UINT32 color = GetColor(hdcDest->format, 0, 0, 0, 0);
+       UINT32 color = GetColor(hdcDest->format, 0xFF, 0xFF, 0xFF, 0xFF);
 
        for (y = 0; y < nHeight; y++)
        {
index f0051a9..d11b8c2 100644 (file)
@@ -308,7 +308,7 @@ static const DWORD rop3_code_table[] =
 };
 
 /* Hatch Patterns as monochrome data */
-static BYTE GDI_BS_HATCHED_PATTERNS[] =
+static const 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 */
@@ -319,7 +319,6 @@ static BYTE GDI_BS_HATCHED_PATTERNS[] =
 };
 
 /* GDI Helper Functions */
-
 INLINE DWORD gdi_rop3_code(BYTE code)
 {
        return rop3_code_table[code];
@@ -368,8 +367,8 @@ BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, UINT32 x, UINT32 y)
        else
        {
                WLog_ERR(TAG,
-                        "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d",
-                        x, y, hBmp->width, hBmp->height);
+                        "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d",
+                        x, y, hBmp->width, hBmp->height);
                return 0;
        }
 }
@@ -403,7 +402,7 @@ BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
                                y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) %
                                    hBmpBrush->height;
                                p = hBmpBrush->data + (y * hBmpBrush->scanline) + (x * GetBytesPerPixel(
-                                           hBmpBrush->format));
+                                           hBmpBrush->format));
                                return p;
                        }
                }
@@ -414,7 +413,7 @@ BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
 }
 
 gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp,
-                            BYTE* data)
+                             BYTE* data)
 {
        gdiBitmap* bitmap;
        bitmap = (gdiBitmap*) calloc(1, sizeof(gdiBitmap));
@@ -458,7 +457,7 @@ void gdi_bitmap_free_ex(gdiBitmap* bitmap)
 }
 
 static BOOL gdi_bitmap_update(rdpContext* context,
-                             const BITMAP_UPDATE* bitmapUpdate)
+                              const BITMAP_UPDATE* bitmapUpdate)
 {
        int status;
        UINT32 index;
@@ -484,29 +483,31 @@ static BOOL gdi_bitmap_update(rdpContext* context,
                        if (bitsPerPixel < 32)
                        {
                                if (!freerdp_client_codecs_prepare(codecs,
-                                                             FREERDP_CODEC_INTERLEAVED,
-                                                             gdi->width, gdi->height))
+                                                                  FREERDP_CODEC_INTERLEAVED,
+                                                                  gdi->width, gdi->height))
                                        return FALSE;
+
                                status = interleaved_decompress(codecs->interleaved,
-                                                               pSrcData, SrcSize,
-                                                               bitsPerPixel,
-                                                               gdi->primary_buffer,
-                                                               gdi->dstFormat,
-                                                               gdi->stride, nXDst, nYDst,
-                                                               nWidth, nHeight,
-                                                               &gdi->palette);
+                                                               pSrcData, SrcSize,
+                                                               bitsPerPixel,
+                                                               gdi->primary_buffer,
+                                                               gdi->dstFormat,
+                                                               gdi->stride, nXDst, nYDst,
+                                                               nWidth, nHeight,
+                                                               &gdi->palette);
                        }
                        else
                        {
                                if (!freerdp_client_codecs_prepare(codecs,
-                                                             FREERDP_CODEC_PLANAR,
-                                                             gdi->width, gdi->height))
+                                                                  FREERDP_CODEC_PLANAR,
+                                                                  gdi->width, gdi->height))
                                        return FALSE;
+
                                status = planar_decompress(codecs->planar, pSrcData,
-                                                          SrcSize, gdi->primary_buffer,
-                                                          gdi->dstFormat,
-                                                          gdi->stride,
-                                                          nXDst, nYDst, nWidth, nHeight, TRUE);
+                                                          SrcSize, gdi->primary_buffer,
+                                                          gdi->dstFormat,
+                                                          gdi->stride,
+                                                          nXDst, nYDst, nWidth, nHeight, TRUE);
                        }
 
                        if (status < 0)
@@ -520,19 +521,19 @@ static BOOL gdi_bitmap_update(rdpContext* context,
                        UINT32 SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE);
                        UINT32 nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
                        nWidth = MIN(bitmap->destRight,
-                                    gdi->width - 1) - bitmap->destLeft + 1; /* clip width */
+                                    gdi->width - 1) - bitmap->destLeft + 1; /* clip width */
                        nHeight = MIN(bitmap->destBottom,
-                                     gdi->height - 1) - bitmap->destTop + 1; /* clip height */
+                                     gdi->height - 1) - bitmap->destTop + 1; /* clip height */
 
                        if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
-                                               nXDst, nYDst, nWidth, nHeight,
-                                               pSrcData, SrcFormat, nSrcStep,
-                                               nXSrc, nYSrc, &gdi->palette))
+                                               nXDst, nYDst, nWidth, nHeight,
+                                               pSrcData, SrcFormat, nSrcStep,
+                                               nXSrc, nYSrc, &gdi->palette))
                                return FALSE;
                }
 
                if (!gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst,
-                                         nWidth, nHeight))
+                                         nWidth, nHeight))
                        return FALSE;
        }
 
@@ -540,16 +541,15 @@ static BOOL gdi_bitmap_update(rdpContext* context,
 }
 
 static BOOL gdi_palette_update(rdpContext* context,
-                              const PALETTE_UPDATE* palette)
+                               const PALETTE_UPDATE* palette)
 {
-       int index;
-       const PALETTE_ENTRY* pe;
+       UINT32 index;
        rdpGdi* gdi = context->gdi;
        gdi->palette.format = gdi->dstFormat;
 
-       for (index = 0; index < (int) palette->number; index++)
+       for (index = 0; index < palette->number; index++)
        {
-               pe = &(palette->entries[index]);
+               const PALETTE_ENTRY* pe = &(palette->entries[index]);
                gdi->palette.palette[index] =
                    GetColor(gdi->dstFormat, pe->red, pe->green, pe->blue, 0xFF);
        }
@@ -564,12 +564,10 @@ static BOOL gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
        if (bounds)
        {
                gdi_SetClipRgn(gdi->drawing->hdc, bounds->left, bounds->top,
-                              bounds->right - bounds->left + 1, bounds->bottom - bounds->top + 1);
+                              bounds->right - bounds->left + 1, bounds->bottom - bounds->top + 1);
        }
        else
-       {
                gdi_SetNullClipRgn(gdi->drawing->hdc);
-       }
 
        return TRUE;
 }
@@ -578,13 +576,12 @@ static BOOL gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
 {
        rdpGdi* gdi = context->gdi;
        return gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
-                         dstblt->nWidth, dstblt->nHeight, NULL, 0, 0,
-                         gdi_rop3_code(dstblt->bRop), &gdi->palette);
+                         dstblt->nWidth, dstblt->nHeight, NULL, 0, 0,
+                         gdi_rop3_code(dstblt->bRop), &gdi->palette);
 }
 
 static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
 {
-       BYTE* data;
        const rdpBrush* brush = &patblt->brush;
        UINT32 foreColor;
        UINT32 backColor;
@@ -597,152 +594,157 @@ static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
        UINT32 nXSrc = 0;
        UINT32 nYSrc = 0;
        foreColor = ConvertColor(patblt->foreColor, SrcFormat,
-                                gdi->dstFormat, &gdi->palette);
+                                gdi->dstFormat, &gdi->palette);
        backColor = ConvertColor(patblt->backColor, SrcFormat,
-                                gdi->dstFormat, &gdi->palette);
+                                gdi->dstFormat, &gdi->palette);
        originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
 
-       if (brush->style == GDI_BS_SOLID)
+       switch (brush->style)
        {
-               originalBrush = gdi->drawing->hdc->brush;
-               gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
-
-               if (!gdi->drawing->hdc->brush)
-               {
-                       ret = FALSE;
-                       goto out_error;
-               }
+               case GDI_BS_SOLID:
+                       originalBrush = gdi->drawing->hdc->brush;
+                       gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
 
-               if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
-                               patblt->nWidth, patblt->nHeight, rop,
-                               gdi->primary->hdc, nXSrc, nYSrc))
-               {
-                       ret = FALSE;
-               }
+                       if (!gdi->drawing->hdc->brush)
+                       {
+                               ret = FALSE;
+                               goto out_error;
+                       }
 
-               gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
-               gdi->drawing->hdc->brush = originalBrush;
-       }
-       else if (brush->style == GDI_BS_HATCHED)
-       {
-               BYTE* hatched;
-               HGDI_BITMAP hBmp;
-               data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
+                       if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
+                                       patblt->nWidth, patblt->nHeight, rop,
+                                       gdi->primary->hdc, nXSrc, nYSrc))
+                       {
+                               ret = FALSE;
+                       }
 
-               if (!data)
-               {
-                       ret = FALSE;
-                       goto out_error;
-               }
+                       gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
+                       gdi->drawing->hdc->brush = originalBrush;
+                       break;
 
-               hatched = GDI_BS_HATCHED_PATTERNS + (8 * brush->hatch);
-               freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
-                                                  hatched, backColor, foreColor, &gdi->palette);
-               hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
+               case GDI_BS_HATCHED:
+                       {
+                               const BYTE* hatched;
+                               HGDI_BITMAP hBmp;
+                               BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat),
+                                                                    16);
 
-               if (!hBmp)
-               {
-                       _aligned_free(data);
-                       ret = FALSE;
-                       goto out_error;
-               }
+                               if (!data)
+                               {
+                                       ret = FALSE;
+                                       goto out_error;
+                               }
 
-               originalBrush = gdi->drawing->hdc->brush;
-               gdi->drawing->hdc->brush = gdi_CreateHatchBrush(hBmp);
+                               hatched = GDI_BS_HATCHED_PATTERNS + (8 * brush->hatch);
+                               freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
+                                                                  hatched, backColor, foreColor, &gdi->palette);
+                               hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
 
-               if (!gdi->drawing->hdc->brush)
-               {
-                       _aligned_free(data);
-                       ret = FALSE;
-                       goto out_error;
-               }
+                               if (!hBmp)
+                               {
+                                       _aligned_free(data);
+                                       ret = FALSE;
+                                       goto out_error;
+                               }
 
-               gdi->drawing->hdc->brush->nXOrg = brush->x;
-               gdi->drawing->hdc->brush->nYOrg = brush->y;
+                               originalBrush = gdi->drawing->hdc->brush;
+                               gdi->drawing->hdc->brush = gdi_CreateHatchBrush(hBmp);
 
-               if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
-                               patblt->nWidth, patblt->nHeight, rop,
-                               gdi->primary->hdc, nXSrc, nYSrc))
-               {
-                       ret = FALSE;
-               }
+                               if (!gdi->drawing->hdc->brush)
+                               {
+                                       ret = FALSE;
+                                       goto out_error;
+                               }
 
-               gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
-               gdi->drawing->hdc->brush = originalBrush;
-       }
-       else if (brush->style == GDI_BS_PATTERN)
-       {
-               HGDI_BITMAP hBmp;
-               UINT32 brushFormat;
+                               gdi->drawing->hdc->brush->nXOrg = brush->x;
+                               gdi->drawing->hdc->brush->nYOrg = brush->y;
 
-               if (brush->bpp > 1)
-               {
-                       brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
-                       data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
+                               if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
+                                               patblt->nWidth, patblt->nHeight, rop,
+                                               gdi->primary->hdc, nXSrc, nYSrc))
+                               {
+                                       ret = FALSE;
+                               }
 
-                       if (!data)
-                       {
-                               ret = FALSE;
-                               goto out_error;
+                               gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
+                               gdi->drawing->hdc->brush = originalBrush;
                        }
+                       break;
 
-                       if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
-                                               8, 8, brush->data, brushFormat, 0, 0, 0,
-                                               &gdi->palette))
+               case GDI_BS_PATTERN:
                        {
-                               ret = FALSE;
-                               goto out_error;
-                       }
-               }
-               else
-               {
-                       data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
+                               HGDI_BITMAP hBmp;
+                               UINT32 brushFormat;
+                               BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat),
+                                                                    16);
 
-                       if (!data)
-                       {
-                               ret = FALSE;
-                               goto out_error;
-                       }
+                               if (!data)
+                               {
+                                       ret = FALSE;
+                                       goto out_error;
+                               }
 
-                       freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
-                                                          brush->data, backColor, foreColor, &gdi->palette);
-               }
+                               if (brush->bpp > 1)
+                               {
+                                       brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
+
+                                       if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
+                                                               8, 8, brush->data, brushFormat, 0, 0, 0,
+                                                               &gdi->palette))
+                                       {
+                                               _aligned_free(data);
+                                               ret = FALSE;
+                                               goto out_error;
+                                       }
+                               }
+                               else
+                               {
+                                       if (!freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
+                                                                               brush->data, backColor, foreColor, &gdi->palette))
+                                       {
+                                               _aligned_free(data);
+                                               ret = FALSE;
+                                               goto out_error;
+                                       }
+                               }
 
-               hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
+                               hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
 
-               if (!hBmp)
-               {
-                       _aligned_free(data);
-                       ret = FALSE;
-                       goto out_error;
-               }
+                               if (!hBmp)
+                               {
+                                       _aligned_free(data);
+                                       ret = FALSE;
+                                       goto out_error;
+                               }
 
-               originalBrush = gdi->drawing->hdc->brush;
-               gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
+                               originalBrush = gdi->drawing->hdc->brush;
+                               gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
 
-               if (!gdi->drawing->hdc->brush)
-               {
-                       _aligned_free(data);
-                       ret = FALSE;
-                       goto out_error;
-               }
+                               if (!gdi->drawing->hdc->brush)
+                               {
+                                       _aligned_free(data);
+                                       ret = FALSE;
+                                       goto out_error;
+                               }
 
-               gdi->drawing->hdc->brush->nXOrg = brush->x;
-               gdi->drawing->hdc->brush->nYOrg = brush->y;
+                               gdi->drawing->hdc->brush->nXOrg = brush->x;
+                               gdi->drawing->hdc->brush->nYOrg = brush->y;
 
-               if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
-                               patblt->nWidth, patblt->nHeight, rop,
-                               gdi->primary->hdc, nXSrc, nYSrc))
-               {
-                       ret = FALSE;
-               }
+                               if (!gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
+                                               patblt->nWidth, patblt->nHeight, rop,
+                                               gdi->primary->hdc, nXSrc, nYSrc))
+                               {
+                                       ret = FALSE;
+                               }
 
-               gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
-               gdi->drawing->hdc->brush = originalBrush;
-       }
-       else
-       {
-               WLog_ERR(TAG,  "unimplemented brush style:%d", brush->style);
+                               gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
+                               gdi->drawing->hdc->brush = originalBrush;
+                       }
+                       break;
+
+               default:
+                       WLog_ERR(TAG,  "unimplemented brush style:%d", brush->style);
+                       break;
        }
 
 out_error:
@@ -754,13 +756,13 @@ static BOOL gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
 {
        rdpGdi* gdi = context->gdi;
        return gdi_BitBlt(gdi->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
-                         scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
-                         scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop),
-                         &gdi->palette);
+                         scrblt->nWidth, scrblt->nHeight, gdi->primary->hdc,
+                         scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop),
+                         &gdi->palette);
 }
 
 static BOOL gdi_opaque_rect(rdpContext* context,
-                           const OPAQUE_RECT_ORDER* opaque_rect)
+                            const OPAQUE_RECT_ORDER* opaque_rect)
 {
        GDI_RECT rect;
        HGDI_BRUSH hBrush;
@@ -769,9 +771,9 @@ static BOOL gdi_opaque_rect(rdpContext* context,
        BOOL ret;
        UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
        gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect,
-                      opaque_rect->nWidth, opaque_rect->nHeight, &rect);
+                      opaque_rect->nWidth, opaque_rect->nHeight, &rect);
        brush_color = ConvertColor(opaque_rect->color, SrcFormat,
-                                  gdi->dstFormat, &gdi->palette);
+                                  gdi->dstFormat, &gdi->palette);
 
        if (!(hBrush = gdi_CreateSolidBrush(brush_color)))
                return FALSE;
@@ -782,7 +784,7 @@ static BOOL gdi_opaque_rect(rdpContext* context,
 }
 
 static BOOL gdi_multi_opaque_rect(rdpContext* context,
-                                 const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
+                                  const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
 {
        UINT32 i;
        GDI_RECT rect;
@@ -797,9 +799,9 @@ static BOOL gdi_multi_opaque_rect(rdpContext* context,
        {
                rectangle = &multi_opaque_rect->rectangles[i];
                gdi_CRgnToRect(rectangle->left, rectangle->top,
-                              rectangle->width, rectangle->height, &rect);
+                              rectangle->width, rectangle->height, &rect);
                brush_color = ConvertColor(multi_opaque_rect->color, SrcFormat,
-                                          gdi->dstFormat, &gdi->palette);
+                                          gdi->dstFormat, &gdi->palette);
                hBrush = gdi_CreateSolidBrush(brush_color);
 
                if (!hBrush)
@@ -824,7 +826,7 @@ static BOOL gdi_line_to(rdpContext* context, const LINE_TO_ORDER* lineTo)
        UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
 
        if (!(hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, color,
-                                  SrcFormat, &gdi->palette)))
+                                  SrcFormat, &gdi->palette)))
                return FALSE;
 
        gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
@@ -871,120 +873,119 @@ static BOOL gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
 
 static BOOL gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
 {
-       gdiBitmap* bitmap;
+       gdiBitmap* bitmap = (gdiBitmap*) memblt->bitmap;
        rdpGdi* gdi = context->gdi;
-       bitmap = (gdiBitmap*) memblt->bitmap;
        return gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
-                         memblt->nWidth, memblt->nHeight, bitmap->hdc,
-                         memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop),
-                         &gdi->palette);
+                         memblt->nWidth, memblt->nHeight, bitmap->hdc,
+                         memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop),
+                         &gdi->palette);
 }
 
 static BOOL gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
 {
-       BYTE* data;
-       const rdpBrush* brush;
-       UINT32 foreColor;
-       UINT32 backColor;
-       gdiBitmap* bitmap;
-       UINT32 originalColor;
        HGDI_BRUSH originalBrush;
        rdpGdi* gdi = context->gdi;
        BOOL ret = TRUE;
-       UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
-       brush = &mem3blt->brush;
-       bitmap = (gdiBitmap*) mem3blt->bitmap;
-       foreColor = ConvertColor(mem3blt->foreColor, SrcFormat,
-                                gdi->dstFormat, &gdi->palette);
-       backColor = ConvertColor(mem3blt->backColor, SrcFormat,
-                                gdi->dstFormat, &gdi->palette);
-       originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
-
-       if (brush->style == GDI_BS_SOLID)
-       {
-               originalBrush = gdi->drawing->hdc->brush;
-               gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
-
-               if (!gdi->drawing->hdc->brush)
-               {
-                       ret = FALSE;
-                       goto out_fail;
-               }
-
-               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->palette);
-               gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
-               gdi->drawing->hdc->brush = originalBrush;
-       }
-       else if (brush->style == GDI_BS_PATTERN)
+       const UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth,
+                                FALSE);
+       const rdpBrush* brush = &mem3blt->brush;
+       gdiBitmap* bitmap = (gdiBitmap*) mem3blt->bitmap;
+       const UINT32 foreColor = ConvertColor(mem3blt->foreColor, SrcFormat,
+                                             gdi->dstFormat, &gdi->palette);
+       const UINT32 backColor = ConvertColor(mem3blt->backColor, SrcFormat,
+                                             gdi->dstFormat, &gdi->palette);
+       const UINT32 originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
+
+       switch (brush->style)
        {
-               HGDI_BITMAP hBmp;
-               UINT32 brushFormat;
+               case GDI_BS_SOLID:
+                       originalBrush = gdi->drawing->hdc->brush;
+                       gdi->drawing->hdc->brush = gdi_CreateSolidBrush(foreColor);
 
-               if (brush->bpp > 1)
-               {
-                       brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
-                       data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
-
-                       if (!data)
+                       if (!gdi->drawing->hdc->brush)
                        {
                                ret = FALSE;
                                goto out_fail;
                        }
 
-                       if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
-                                               8, 8, brush->data, brushFormat, 0, 0, 0, &gdi->palette))
-                       {
-                               ret = FALSE;
-                               goto out_fail;
-                       }
-               }
-               else
-               {
-                       data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat), 16);
+                       ret = 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->palette);
+                       gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
+                       gdi->drawing->hdc->brush = originalBrush;
+                       break;
 
-                       if (!data)
+               case GDI_BS_PATTERN:
                        {
-                               ret = FALSE;
-                               goto out_fail;
-                       }
+                               HGDI_BITMAP hBmp;
+                               UINT32 brushFormat;
+                               BYTE* data = (BYTE*) _aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->dstFormat),
+                                                                    16);
 
-                       freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
-                                                          brush->data, backColor, foreColor, &gdi->palette);
-               }
+                               if (!data)
+                               {
+                                       ret = FALSE;
+                                       goto out_fail;
+                               }
 
-               hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
+                               if (brush->bpp > 1)
+                               {
+                                       brushFormat = gdi_get_pixel_format(brush->bpp, FALSE);
+
+                                       if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
+                                                               8, 8, brush->data, brushFormat,
+                                                               0, 0, 0, &gdi->palette))
+                                       {
+                                               ret = FALSE;
+                                               _aligned_free(data);
+                                               goto out_fail;
+                                       }
+                               }
+                               else
+                               {
+                                       if (!freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
+                                                                               brush->data, backColor, foreColor,
+                                                                               &gdi->palette))
+                                       {
+                                               ret = FALSE;
+                                               _aligned_free(data);
+                                               goto out_fail;
+                                       }
+                               }
 
-               if (!hBmp)
-               {
-                       _aligned_free(data);
-                       ret = FALSE;
-                       goto out_fail;
-               }
+                               hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
 
-               originalBrush = gdi->drawing->hdc->brush;
-               gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
+                               if (!hBmp)
+                               {
+                                       ret = FALSE;
+                                       _aligned_free(data);
+                                       goto out_fail;
+                               }
 
-               if (!gdi->drawing->hdc->brush)
-               {
-                       gdi_DeleteObject((HGDIOBJECT) hBmp);
-                       goto out_fail;
-               }
+                               originalBrush = gdi->drawing->hdc->brush;
+                               gdi->drawing->hdc->brush = gdi_CreatePatternBrush(hBmp);
 
-               gdi->drawing->hdc->brush->nXOrg = brush->x;
-               gdi->drawing->hdc->brush->nYOrg = brush->y;
-               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->palette);
-               gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
-               gdi->drawing->hdc->brush = originalBrush;
-       }
-       else
-       {
-               WLog_ERR(TAG,  "Mem3Blt unimplemented brush style:%d", brush->style);
+                               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,
+                                                mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
+                                                mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop),
+                                                &gdi->palette);
+                               gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
+                               gdi->drawing->hdc->brush = originalBrush;
+                       }
+                       break;
+
+               default:
+                       WLog_ERR(TAG,  "Mem3Blt unimplemented brush style:%d", brush->style);
+                       break;
        }
 
 out_fail:
@@ -993,7 +994,7 @@ out_fail:
 }
 
 static BOOL gdi_polygon_sc(rdpContext* context,
-                          const POLYGON_SC_ORDER* polygon_sc)
+                           const POLYGON_SC_ORDER* polygon_sc)
 {
        WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
        return TRUE;
@@ -1006,31 +1007,31 @@ static BOOL gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
 }
 
 static BOOL gdi_ellipse_sc(rdpContext* context,
-                          const ELLIPSE_SC_ORDER* ellipse_sc)
+                           const ELLIPSE_SC_ORDER* ellipse_sc)
 {
        WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
        return TRUE;
 }
 
 static BOOL gdi_ellipse_cb(rdpContext* context,
-                          const ELLIPSE_CB_ORDER* ellipse_cb)
+                           const ELLIPSE_CB_ORDER* ellipse_cb)
 {
        WLog_VRB(TAG, "%s: not implemented", __FUNCTION__);
        return TRUE;
 }
 
 static BOOL gdi_frame_marker(rdpContext* context,
-                            const FRAME_MARKER_ORDER* frameMarker)
+                             const FRAME_MARKER_ORDER* frameMarker)
 {
        return TRUE;
 }
 
 BOOL gdi_surface_frame_marker(rdpContext* context,
-                             const SURFACE_FRAME_MARKER* surfaceFrameMarker)
+                              const SURFACE_FRAME_MARKER* surfaceFrameMarker)
 {
        DEBUG_GDI("frameId %d frameAction %d",
-                 surfaceFrameMarker->frameId,
-                 surfaceFrameMarker->frameAction);
+                 surfaceFrameMarker->frameId,
+                 surfaceFrameMarker->frameAction);
 
        switch (surfaceFrameMarker->frameAction)
        {
@@ -1051,25 +1052,25 @@ BOOL gdi_surface_frame_marker(rdpContext* context,
 }
 
 static BOOL gdi_surface_bits(rdpContext* context,
-                            const SURFACE_BITS_COMMAND* cmd)
+                             const SURFACE_BITS_COMMAND* cmd)
 {
        rdpGdi* gdi = context->gdi;
        DEBUG_GDI("destLeft %d destTop %d destRight %d destBottom %d "
-                 "bpp %d codecID %d width %d height %d length %d",
-                 cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
-                 cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);
+                 "bpp %d codecID %d width %d height %d length %d",
+                 cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
+                 cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);
 
        switch (cmd->codecID)
        {
                case RDP_CODEC_ID_REMOTEFX:
                        {
                                if (!rfx_process_message(context->codecs->rfx, cmd->bitmapData,
-                                                        PIXEL_FORMAT_BGRX32,
-                                                        cmd->bitmapDataLength,
-                                                        0, 0,
-                                                        gdi->bitmap_buffer, gdi->dstFormat,
-                                                        cmd->width * GetBytesPerPixel(gdi->dstFormat),
-                                                        cmd->height, NULL))
+                                                        PIXEL_FORMAT_BGRX32,
+                                                        cmd->bitmapDataLength,
+                                                        0, 0,
+                                                        gdi->bitmap_buffer, gdi->dstFormat,
+                                                        cmd->width * GetBytesPerPixel(gdi->dstFormat),
+                                                        cmd->height, NULL))
                                {
                                        WLog_ERR(TAG, "Failed to process RemoteFX message");
                                        return FALSE;
@@ -1080,10 +1081,10 @@ static BOOL gdi_surface_bits(rdpContext* context,
                case RDP_CODEC_ID_NSCODEC:
                        {
                                if (!nsc_process_message(context->codecs->nsc, cmd->bpp, cmd->width,
-                                                        cmd->height, cmd->bitmapData,
-                                                        cmd->bitmapDataLength, gdi->primary_buffer,
-                                                        gdi->dstFormat, gdi->stride, cmd->destLeft, cmd->destTop,
-                                                        cmd->width, cmd->height))
+                                                        cmd->height, cmd->bitmapData,
+                                                        cmd->bitmapDataLength, gdi->primary_buffer,
+                                                        gdi->dstFormat, gdi->stride, cmd->destLeft, cmd->destTop,
+                                                        cmd->width, cmd->height))
                                        return FALSE;
                        }
                        break;
@@ -1091,9 +1092,9 @@ static BOOL gdi_surface_bits(rdpContext* context,
                case RDP_CODEC_ID_NONE:
                        {
                                if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
-                                                       cmd->destLeft, cmd->destTop, cmd->width, cmd->height,
-                                                       cmd->bitmapData, PIXEL_FORMAT_XRGB32_VF, 0, 0, 0,
-                                                       &gdi->palette))
+                                                       cmd->destLeft, cmd->destTop, cmd->width, cmd->height,
+                                                       cmd->bitmapData, PIXEL_FORMAT_XRGB32_VF, 0, 0, 0,
+                                                       &gdi->palette))
                                        return FALSE;
                        }
                        break;
@@ -1145,7 +1146,7 @@ void gdi_register_update_callbacks(rdpUpdate* update)
 }
 
 static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, BYTE* buffer,
-                            void (*pfree)(void*))
+                             void (*pfree)(void*))
 {
        gdi->primary = (gdiBitmap*) calloc(1, sizeof(gdiBitmap));
 
@@ -1158,14 +1159,14 @@ static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, BYTE* buffer,
        if (!buffer)
        {
                gdi->primary->bitmap = gdi_CreateCompatibleBitmap(
-                                          gdi->hdc, gdi->width, gdi->height);
+                                          gdi->hdc, gdi->width, gdi->height);
        }
        else
        {
                gdi->primary->bitmap = gdi_CreateBitmapEx(gdi->width, gdi->height,
-                                      gdi->dstFormat,
-                                      gdi->stride,
-                                      gdi->primary_buffer, pfree);
+                                      gdi->dstFormat,
+                                      gdi->stride,
+                                      gdi->primary_buffer, pfree);
        }
 
        gdi->stride = gdi->primary->bitmap->scanline;
@@ -1187,7 +1188,7 @@ static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, BYTE* buffer,
        gdi->primary->hdc->hwnd->count = 32;
 
        if (!(gdi->primary->hdc->hwnd->cinvalid = (HGDI_RGN) calloc(
-                   gdi->primary->hdc->hwnd->count, sizeof(GDI_RGN))))
+                   gdi->primary->hdc->hwnd->count, sizeof(GDI_RGN))))
                goto fail_hwnd;
 
        gdi->primary->hdc->hwnd->ninvalid = 0;
@@ -1213,8 +1214,8 @@ BOOL gdi_resize(rdpGdi* gdi, UINT32 width, UINT32 height)
 }
 
 BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height,
-                  INT32 stride, INT32 format, BYTE* buffer,
-                  void (*pfree)(void*))
+                   INT32 stride, INT32 format, BYTE* buffer,
+                   void (*pfree)(void*))
 {
        if (!gdi || !gdi->primary)
                return FALSE;
@@ -1244,7 +1245,7 @@ BOOL gdi_init(freerdp* instance, UINT32 format)
 }
 
 BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
-                void (*pfree)(void*))
+                 void (*pfree)(void*))
 {
        UINT32 SrcFormat = gdi_get_pixel_format(instance->settings->ColorDepth, FALSE);
        rdpGdi* gdi = (rdpGdi*) calloc(1, sizeof(rdpGdi));
@@ -1260,9 +1261,9 @@ BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
        gdi->dstFormat = format;
        /* default internal buffer format */
        WLog_INFO(TAG, "Local framebuffer format  %s",
-                 GetColorFormatName(gdi->dstFormat));
+                 GetColorFormatName(gdi->dstFormat));
        WLog_INFO(TAG, "Remote framebuffer format %s",
-                 GetColorFormatName(SrcFormat));
+                 GetColorFormatName(SrcFormat));
 
        if (!(gdi->hdc = gdi_GetDC()))
                goto fail;
@@ -1279,7 +1280,7 @@ BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
        }
 
        if (!freerdp_client_codecs_reset(context->codecs, FREERDP_CODEC_ALL, gdi->width,
-                                        gdi->height))
+                                        gdi->height))
                goto fail;
 
        gdi_register_update_callbacks(instance->update);
@@ -1309,6 +1310,7 @@ void gdi_free(freerdp* instance)
                return;
 
        gdi = instance->context->gdi;
+
        if (gdi)
        {
                gdi_bitmap_free_ex(gdi->primary);
@@ -1317,6 +1319,7 @@ void gdi_free(freerdp* instance)
        }
 
        context = instance->context;
+
        if (context->cache)
        {
                cache_free(context->cache);
index 024f068..4d624ea 100644 (file)
@@ -39,7 +39,7 @@
 /* Bitmap Class */
 
 HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
-                                                         UINT32 SrcFormat, BYTE* data)
+                              UINT32 SrcFormat, BYTE* data)
 {
        UINT32 nSrcStep;
        UINT32 nDstStep;
@@ -56,8 +56,8 @@ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
        nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
 
        if (!freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0,
-                               nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0,
-                               &gdi->palette))
+                               nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0,
+                               &gdi->palette))
        {
                _aligned_free(pDstData);
                return NULL;
@@ -79,15 +79,14 @@ static BOOL gdi_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
 
        if (!bitmap->data)
                gdi_bitmap->bitmap = gdi_CreateCompatibleBitmap(
-                                                                gdi->hdc, bitmap->width,
-                                                                bitmap->height);
+                                        gdi->hdc, bitmap->width,
+                                        bitmap->height);
        else
        {
                UINT32 format = bitmap->format;
-
                gdi_bitmap->bitmap = gdi_create_bitmap(gdi, bitmap->width,
-                                                                                          bitmap->height,
-                                                                                          format, bitmap->data);
+                                                      bitmap->height,
+                                                      format, bitmap->data);
        }
 
        if (!gdi_bitmap->bitmap)
@@ -115,20 +114,19 @@ static void gdi_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
 
 static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
 {
-       int width, height;
        gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;
-       width = bitmap->right - bitmap->left + 1;
-       height = bitmap->bottom - bitmap->top + 1;
+       UINT32 width = bitmap->right - bitmap->left + 1;
+       UINT32 height = bitmap->bottom - bitmap->top + 1;
        return gdi_BitBlt(context->gdi->primary->hdc,
-                         bitmap->left, bitmap->top,
-                         width, height, gdi_bitmap->hdc,
-                         0, 0, GDI_SRCCOPY, &context->gdi->palette);
+                         bitmap->left, bitmap->top,
+                         width, height, gdi_bitmap->hdc,
+                         0, 0, GDI_SRCCOPY, &context->gdi->palette);
 }
 
 static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
-                                                                 const BYTE* data, UINT32 width, UINT32 height,
-                                                                 UINT32 bpp, UINT32 length, BOOL compressed,
-                                                                 UINT32 codecId)
+                                  const BYTE* data, UINT32 width, UINT32 height,
+                                  UINT32 bpp, UINT32 length, BOOL compressed,
+                                  UINT32 codecId)
 {
        int status;
        UINT16 size;
@@ -150,25 +148,27 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
                if (bpp < 32)
                {
                        if (!freerdp_client_codecs_prepare(context->codecs,
-                                                     FREERDP_CODEC_INTERLEAVED,
-                                                     gdi->width, gdi->height))
+                                                          FREERDP_CODEC_INTERLEAVED,
+                                                          gdi->width, gdi->height))
                                return FALSE;
+
                        status = interleaved_decompress(context->codecs->interleaved,
-                                                       pSrcData, SrcSize,
-                                                       bpp,
-                                                       pDstData, gdi->dstFormat,
-                                                       0, 0, 0, width, height,
-                                                       &gdi->palette);
+                                                       pSrcData, SrcSize,
+                                                       bpp,
+                                                       pDstData, gdi->dstFormat,
+                                                       0, 0, 0, width, height,
+                                                       &gdi->palette);
                }
                else
                {
                        if (!freerdp_client_codecs_prepare(context->codecs,
-                                                     FREERDP_CODEC_PLANAR,
-                                                     gdi->width, gdi->height))
+                                                          FREERDP_CODEC_PLANAR,
+                                                          gdi->width, gdi->height))
                                return FALSE;
+
                        status = planar_decompress(context->codecs->planar, pSrcData, SrcSize,
-                                                                          pDstData, gdi->dstFormat, 0, 0, 0,
-                                                                          width, height, TRUE);
+                                                  pDstData, gdi->dstFormat, 0, 0, 0,
+                                                  width, height, TRUE);
                }
 
                if (status < 0)
@@ -181,8 +181,8 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
        {
                SrcFormat = gdi_get_pixel_format(bpp, FALSE);
                status = freerdp_image_copy(pDstData, gdi->dstFormat, 0, 0, 0,
-                                           width, height, pSrcData, SrcFormat,
-                                           0, 0, 0, &gdi->palette);
+                                           width, height, pSrcData, SrcFormat,
+                                           0, 0, 0, &gdi->palette);
        }
 
        bitmap->compressed = FALSE;
@@ -192,7 +192,7 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
 }
 
 static BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
-                                                                 BOOL primary)
+                                  BOOL primary)
 {
        rdpGdi* gdi = context->gdi;
 
@@ -225,7 +225,7 @@ static BOOL gdi_Glyph_New(rdpContext* context, rdpGlyph* glyph)
        }
 
        gdi_glyph->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, PIXEL_FORMAT_MONO,
-                                                                                data);
+                                            data);
 
        if (!gdi_glyph->bitmap)
        {
@@ -254,19 +254,19 @@ static void gdi_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
 }
 
 static BOOL gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, UINT32 x,
-                                                  UINT32 y)
+                           UINT32 y)
 {
        gdiGlyph* gdi_glyph;
        rdpGdi* gdi = context->gdi;
        gdi_glyph = (gdiGlyph*) glyph;
        return gdi_BitBlt(gdi->drawing->hdc, x, y, gdi_glyph->bitmap->width,
-                         gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0,
-                         GDI_DSPDxax, &context->gdi->palette);
+                         gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0,
+                         GDI_DSPDxax, &context->gdi->palette);
 }
 
 static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
-                                                               UINT32 width, UINT32 height, UINT32 bgcolor,
-                                                               UINT32 fgcolor, BOOL fOpRedundant)
+                                UINT32 width, UINT32 height, UINT32 bgcolor,
+                                UINT32 fgcolor, BOOL fOpRedundant)
 {
        GDI_RECT rect;
        HGDI_BRUSH brush;
@@ -289,12 +289,12 @@ out:
 }
 
 static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
-                                                         UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
+                              UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
 {
        rdpGdi* gdi = context->gdi;
        UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
        bgcolor = ConvertColor(bgcolor, SrcFormat,
-                              gdi->dstFormat, &gdi->palette);
+                              gdi->dstFormat, &gdi->palette);
        gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
        return TRUE;
 }