xfreerdp: remove dependency on clrconv
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Wed, 22 Oct 2014 02:19:11 +0000 (22:19 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Wed, 22 Oct 2014 02:19:11 +0000 (22:19 -0400)
client/X11/xf_client.c
client/X11/xf_gdi.c
client/X11/xf_rail.c
client/X11/xfreerdp.h
include/freerdp/gdi/dc.h
include/freerdp/gdi/gdi.h
libfreerdp/gdi/dc.c
libfreerdp/gdi/gdi.c

index 121b7fc..7ca8c1a 100644 (file)
@@ -611,38 +611,48 @@ BOOL xf_get_pixmap_info(xfContext *xfc)
        XPixmapFormatValues *pfs;
        XWindowAttributes window_attributes;
        pfs = XListPixmapFormats(xfc->display, &pf_count);
-       if(pfs == NULL)
+
+       if (pfs == NULL)
        {
                WLog_ERR(TAG,  "XListPixmapFormats failed");
                return 1;
        }
-       for(i = 0; i < pf_count; i++)
+
+       for (i = 0; i < pf_count; i++)
        {
                pf = pfs + i;
-               if(pf->depth == xfc->depth)
+
+               if (pf->depth == xfc->depth)
                {
                        xfc->bpp = pf->bits_per_pixel;
                        xfc->scanline_pad = pf->scanline_pad;
                        break;
                }
        }
+
        XFree(pfs);
+
        ZeroMemory(&template, sizeof(template));
        template.class = TrueColor;
        template.screen = xfc->screen_number;
-       if(XGetWindowAttributes(xfc->display, RootWindowOfScreen(xfc->screen), &window_attributes) == 0)
+
+       if (XGetWindowAttributes(xfc->display, RootWindowOfScreen(xfc->screen), &window_attributes) == 0)
        {
                WLog_ERR(TAG,  "XGetWindowAttributes failed");
                return FALSE;
        }
+
        vis = XGetVisualInfo(xfc->display, VisualClassMask | VisualScreenMask, &template, &vi_count);
-       if(vis == NULL)
+
+       if (vis == NULL)
        {
                WLog_ERR(TAG,  "XGetVisualInfo failed");
                return FALSE;
        }
+
        vi = NULL;
-       for(i = 0; i < vi_count; i++)
+
+       for (i = 0; i < vi_count; i++)
        {
                vi = vis + i;
                if(vi->visual == window_attributes.visual)
@@ -651,22 +661,26 @@ BOOL xf_get_pixmap_info(xfContext *xfc)
                        break;
                }
        }
-       if(vi)
+
+       if (vi)
        {
                /*
                 * Detect if the server visual has an inverted colormap
                 * (BGR vs RGB, or red being the least significant byte)
                 */
-               if(vi->red_mask & 0xFF)
+               if (vi->red_mask & 0xFF)
                {
-                       xfc->clrconv->invert = TRUE;
+                       xfc->invert = TRUE;
                }
        }
+
        XFree(vis);
-       if((xfc->visual == NULL) || (xfc->scanline_pad == 0))
+
+       if ((xfc->visual == NULL) || (xfc->scanline_pad == 0))
        {
                return FALSE;
        }
+
        return TRUE;
 }
 
@@ -859,7 +873,6 @@ BOOL xf_pre_connect(freerdp* instance)
 
        xf_keyboard_init(xfc);
 
-       xfc->clrconv = freerdp_clrconv_new(CLRCONV_ALPHA);
        instance->context->cache = cache_new(instance->settings);
 
        xfc->xfds = ConnectionNumber(xfc->display);
@@ -899,6 +912,7 @@ BOOL xf_pre_connect(freerdp* instance)
  */
 BOOL xf_post_connect(freerdp *instance)
 {
+       UINT32 flags;
        XGCValues gcv;
        rdpCache* cache;
        rdpChannels* channels;
@@ -915,16 +929,16 @@ BOOL xf_post_connect(freerdp *instance)
 
        xf_register_graphics(instance->context->graphics);
 
+       flags = CLRCONV_ALPHA;
+
+       if (xfc->bpp > 16)
+               flags |= CLRBUF_32BPP;
+       else
+               flags |= CLRBUF_16BPP;
+
        if (settings->SoftwareGdi)
        {
                rdpGdi* gdi;
-               UINT32 flags;
-               flags = CLRCONV_ALPHA;
-
-               if (xfc->bpp > 16)
-                       flags |= CLRBUF_32BPP;
-               else
-                       flags |= CLRBUF_16BPP;
 
                gdi_init(instance, flags, NULL);
 
@@ -935,7 +949,7 @@ BOOL xf_post_connect(freerdp *instance)
        {
                xfc->srcBpp = settings->ColorDepth;
                xf_gdi_register_update_callbacks(instance->update);
-               xfc->hdc = gdi_CreateDC(xfc->clrconv, xfc->bpp);
+               xfc->hdc = gdi_CreateDC(flags, xfc->bpp);
        }
 
        xfc->originalWidth = settings->DesktopWidth;
@@ -1174,12 +1188,6 @@ void xf_window_free(xfContext *xfc)
                context->rail = NULL;
        }
 
-       if (xfc->clrconv)
-       {
-               freerdp_clrconv_free(xfc->clrconv);
-               xfc->clrconv = NULL;
-       }
-
        if (xfc->hdc)
        {
                gdi_DeleteDC(xfc->hdc);
index acb3d7a..7fc9d59 100644 (file)
@@ -413,8 +413,6 @@ void xf_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette)
 
        xf_lock_x11(xfc, FALSE);
 
-       CopyMemory(xfc->clrconv->palette, palette, sizeof(rdpPalette));
-
        palette32 = (UINT32*) xfc->palette;
 
        for (index = 0; index < palette->number; index++)
index 8e78c4a..712ea96 100644 (file)
@@ -186,7 +186,7 @@ static void xf_rail_SetWindowIcon(rdpRail* rail, rdpWindow* window, rdpIcon* ico
        xfc = (xfContext*) rail->extra;
        xfw = (xfWindow*) window->extra;
        icon->extra = freerdp_icon_convert(icon->entry->bitsColor, NULL, icon->entry->bitsMask,
-                                                                          icon->entry->width, icon->entry->height, icon->entry->bpp, rail->clrconv);
+                       icon->entry->width, icon->entry->height, icon->entry->bpp, rail->clrconv);
        xf_SetWindowIcon(xfc, xfw, icon);
 }
 
index da5de82..bb222a9 100644 (file)
@@ -111,7 +111,6 @@ struct xf_context
        int current_desktop;
        BOOL remote_app;
        BOOL disconnect;
-       HCLRCONV clrconv;
        HANDLE mutex;
        BOOL UseXThreads;
        BOOL cursorHidden;
index 1e3616e..ed6963e 100644 (file)
@@ -24,7 +24,7 @@
 #include <freerdp/gdi/gdi.h>
 
 FREERDP_API HGDI_DC gdi_GetDC(void);
-FREERDP_API HGDI_DC gdi_CreateDC(HCLRCONV clrconv, int bpp);
+FREERDP_API HGDI_DC gdi_CreateDC(UINT32 flags, int bpp);
 FREERDP_API HGDI_DC gdi_CreateCompatibleDC(HGDI_DC hdc);
 FREERDP_API HGDIOBJECT gdi_SelectObject(HGDI_DC hdc, HGDIOBJECT hgdiobject);
 FREERDP_API int gdi_DeleteObject(HGDIOBJECT hgdiobject);
index b1450cd..2ae8056 100644 (file)
@@ -287,7 +287,6 @@ struct rdp_gdi
        BOOL invert;
        HGDI_DC hdc;
        UINT32 format;
-       HCLRCONV clrconv;
        gdiBitmap* primary;
        gdiBitmap* drawing;
        UINT32 bitmap_size;
index 1f96a14..8928fef 100644 (file)
@@ -59,7 +59,7 @@ HGDI_DC gdi_GetDC()
  * @return new device context
  */
 
-HGDI_DC gdi_CreateDC(HCLRCONV clrconv, int bpp)
+HGDI_DC gdi_CreateDC(UINT32 flags, int bpp)
 {
        HGDI_DC hDC = (HGDI_DC) malloc(sizeof(GDI_DC));
 
@@ -71,9 +71,9 @@ HGDI_DC gdi_CreateDC(HCLRCONV clrconv, int bpp)
        hDC->bitsPerPixel = bpp;
        hDC->bytesPerPixel = bpp / 8;
 
-       hDC->alpha = clrconv->alpha;
-       hDC->invert = clrconv->invert;
-       hDC->rgb555 = clrconv->rgb555;
+       hDC->alpha = (flags & CLRCONV_ALPHA) ? TRUE : FALSE;
+       hDC->invert = (flags & CLRCONV_INVERT) ? TRUE : FALSE;
+       hDC->rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE;
 
        hDC->hwnd = (HGDI_WND) malloc(sizeof(GDI_WND));
        hDC->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0);
index 3122746..3599b38 100644 (file)
@@ -550,8 +550,6 @@ static void gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette)
        UINT32* palette32;
        rdpGdi* gdi = context->gdi;
 
-       CopyMemory(gdi->clrconv->palette, palette, sizeof(rdpPalette));
-
        palette32 = (UINT32*) gdi->palette;
 
        for (index = 0; index < palette->number; index++)
@@ -1201,22 +1199,9 @@ int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer)
        gdi->hdc->bitsPerPixel = gdi->dstBpp;
        gdi->hdc->bytesPerPixel = gdi->bytesPerPixel;
 
-       gdi->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
-
-       if (!gdi->clrconv)
-               return -1;
-
-       gdi->clrconv->alpha = (flags & CLRCONV_ALPHA) ? TRUE : FALSE;
-       gdi->clrconv->invert = (flags & CLRCONV_INVERT) ? TRUE : FALSE;
-       gdi->clrconv->rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE;
-       gdi->clrconv->palette = (rdpPalette*) malloc(sizeof(rdpPalette));
-
-       if (!gdi->clrconv->palette)
-               return -1;
-
-       gdi->hdc->alpha = gdi->clrconv->alpha;
-       gdi->hdc->invert = gdi->clrconv->invert;
-       gdi->hdc->rgb555 = gdi->clrconv->rgb555;
+       gdi->hdc->alpha = (flags & CLRCONV_ALPHA) ? TRUE : FALSE;
+       gdi->hdc->invert = (flags & CLRCONV_INVERT) ? TRUE : FALSE;
+       gdi->hdc->rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE;
 
        gdi_init_primary(gdi);
 
@@ -1255,8 +1240,6 @@ void gdi_free(freerdp* instance)
                gdi_bitmap_free_ex(gdi->image);
                gdi_DeleteDC(gdi->hdc);
                _aligned_free(gdi->bitmap_buffer);
-               free(gdi->clrconv->palette);
-               free(gdi->clrconv);
                free(gdi);
        }