Fixed (a lot of) GDI drawing issues.
authorArmin Novak <armin.novak@thincast.com>
Wed, 20 Jul 2016 09:40:30 +0000 (11:40 +0200)
committerArmin Novak <armin.novak@thincast.com>
Thu, 6 Oct 2016 11:43:03 +0000 (13:43 +0200)
client/X11/xf_client.c
libfreerdp/cache/bitmap.c
libfreerdp/gdi/bitmap.c
libfreerdp/gdi/brush.c
libfreerdp/gdi/graphics.c

index f1fc4ac..d99d13e 100644 (file)
@@ -153,7 +153,7 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
                {
                        XSetRegion(xfc->display, xfc->gc, reg1);
                        XFillRectangle(xfc->display, xfc->window->handle, xfc->gc, 0, 0,
-                                      xfc->window->width, xfc->window->height);
+                                      xfc->window->width, xfc->window->height);
                        XSetClipMask(xfc->display, xfc->gc, None);
                }
 
@@ -163,9 +163,9 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
        picFormat = XRenderFindVisualFormat(xfc->display, xfc->visual);
        pa.subwindow_mode = IncludeInferiors;
        primaryPicture = XRenderCreatePicture(xfc->display, xfc->primary, picFormat,
-                                             CPSubwindowMode, &pa);
+                                             CPSubwindowMode, &pa);
        windowPicture = XRenderCreatePicture(xfc->display, xfc->window->handle,
-                                            picFormat, CPSubwindowMode, &pa);
+                                            picFormat, CPSubwindowMode, &pa);
        XRenderSetPictureFilter(xfc->display, primaryPicture, FilterBilinear, 0, 0);
        transform.matrix[0][0] = XDoubleToFixed(xScalingFactor);
        transform.matrix[0][1] = XDoubleToFixed(0.0);
@@ -185,7 +185,7 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
        h = ceil(y2 / yScalingFactor) + 1 - y;
        XRenderSetPictureTransform(xfc->display, primaryPicture, &transform);
        XRenderComposite(xfc->display, PictOpSrc, primaryPicture, 0, windowPicture, x,
-                        y, 0, 0, xfc->offset_x + x, xfc->offset_y + y, w, h);
+                        y, 0, 0, xfc->offset_x + x, xfc->offset_y + y, w, h);
        XRenderFreePicture(xfc->display, primaryPicture);
        XRenderFreePicture(xfc->display, windowPicture);
 }
@@ -223,7 +223,7 @@ void xf_draw_screen(xfContext* xfc, int x, int y, int w, int h)
 
 #endif
        XCopyArea(xfc->display, xfc->primary, xfc->window->handle, xfc->gc, x, y, w, h,
-                 x, y);
+                 x, y);
 }
 
 static BOOL xf_desktop_resize(rdpContext* context)
@@ -238,9 +238,9 @@ static BOOL xf_desktop_resize(rdpContext* context)
                XFreePixmap(xfc->display, xfc->primary);
 
                if (!(xfc->primary = XCreatePixmap(
-                                        xfc->display, xfc->drawable,
-                                        settings->DesktopWidth,
-                                        settings->DesktopHeight, xfc->depth)))
+                                        xfc->display, xfc->drawable,
+                                        settings->DesktopWidth,
+                                        settings->DesktopHeight, xfc->depth)))
                        return FALSE;
 
                if (same)
@@ -260,7 +260,7 @@ static BOOL xf_desktop_resize(rdpContext* context)
        if (!xfc->fullscreen)
        {
                xf_ResizeDesktopWindow(xfc, xfc->window, settings->DesktopWidth,
-                                      settings->DesktopHeight);
+                                      settings->DesktopHeight);
        }
        else
        {
@@ -279,7 +279,7 @@ static BOOL xf_desktop_resize(rdpContext* context)
                XSetFillStyle(xfc->display, xfc->gc, FillSolid);
                XSetForeground(xfc->display, xfc->gc, 0);
                XFillRectangle(xfc->display, xfc->drawable, xfc->gc, 0, 0, xfc->window->width,
-                              xfc->window->height);
+                              xfc->window->height);
        }
 
        return TRUE;
@@ -318,7 +318,7 @@ static BOOL xf_sw_end_paint(rdpContext* context)
 
                        xf_lock_x11(xfc, FALSE);
                        XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image,
-                                 x, y, x, y, w, h);
+                                 x, y, x, y, w, h);
                        xf_draw_screen(xfc, x, y, w, h);
                        xf_unlock_x11(xfc, FALSE);
                }
@@ -336,7 +336,7 @@ static BOOL xf_sw_end_paint(rdpContext* context)
                                w = cinvalid[i].w;
                                h = cinvalid[i].h;
                                XPutImage(xfc->display, xfc->primary, xfc->gc,
-                                         xfc->image, x, y, x, y, w, h);
+                                         xfc->image, x, y, x, y, w, h);
                                xf_draw_screen(xfc, x, y, w, h);
                        }
 
@@ -375,8 +375,8 @@ static BOOL xf_sw_desktop_resize(rdpContext* context)
        }
 
        if (!(xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap,
-                                       0,
-                                       (char*) gdi->primary_buffer, gdi->width, gdi->height, xfc->scanline_pad, 0)))
+                                       0,
+                                       (char*) gdi->primary_buffer, gdi->width, gdi->height, xfc->scanline_pad, 0)))
        {
                goto out;
        }
@@ -537,15 +537,15 @@ BOOL xf_create_window(xfContext* xfc)
                else if (settings->ServerPort == 3389)
                {
                        windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(
-                                                settings->ServerHostname));
+                                                settings->ServerHostname));
                        sprintf(windowTitle, "FreeRDP: %s", settings->ServerHostname);
                }
                else
                {
                        windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(settings->ServerHostname)
-                                            + sizeof(":00000"));
+                                            + sizeof(":00000"));
                        sprintf(windowTitle, "FreeRDP: %s:%i", settings->ServerHostname,
-                               settings->ServerPort);
+                               settings->ServerPort);
                }
 
 #ifdef WITH_XRENDER
@@ -590,8 +590,8 @@ BOOL xf_create_window(xfContext* xfc)
 
        if (!xfc->primary)
                xfc->primary = XCreatePixmap(xfc->display, xfc->drawable,
-                                            settings->DesktopWidth,
-                                            settings->DesktopHeight, xfc->depth);
+                                            settings->DesktopWidth,
+                                            settings->DesktopHeight, xfc->depth);
 
        xfc->drawing = xfc->primary;
 
@@ -600,24 +600,24 @@ BOOL xf_create_window(xfContext* xfc)
 
        if (!xfc->gc_mono)
                xfc->gc_mono = XCreateGC(xfc->display, xfc->bitmap_mono, GCGraphicsExposures,
-                                        &gcv);
+                                        &gcv);
 
        XSetFunction(xfc->display, xfc->gc, GXcopy);
        XSetFillStyle(xfc->display, xfc->gc, FillSolid);
        XSetForeground(xfc->display, xfc->gc, BlackPixelOfScreen(xfc->screen));
        XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0,
-                      settings->DesktopWidth,
-                      settings->DesktopHeight);
+                      settings->DesktopWidth,
+                      settings->DesktopHeight);
        XFlush(xfc->display);
 
        if (!xfc->image)
        {
                rdpGdi* gdi = xfc->context.gdi;
                xfc->image = XCreateImage(xfc->display, xfc->visual,
-                                         xfc->depth,
-                                         ZPixmap, 0, (char*) gdi->primary_buffer,
-                                         settings->DesktopWidth, settings->DesktopHeight,
-                                         xfc->scanline_pad, 0);
+                                         xfc->depth,
+                                         ZPixmap, 0, (char*) gdi->primary_buffer,
+                                         settings->DesktopWidth, settings->DesktopHeight,
+                                         xfc->scanline_pad, 0);
        }
 
        return TRUE;
@@ -719,7 +719,7 @@ void xf_toggle_control(xfContext* xfc)
  * @return 0 on success, otherwise a Win32 error code
  */
 static UINT xf_encomsp_participant_created(EncomspClientContext* context,
-        ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
+       ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
 {
        return CHANNEL_RC_OK;
 }
@@ -808,14 +808,14 @@ static BOOL xf_get_pixmap_info(xfContext* xfc)
        template.screen = xfc->screen_number;
 
        if (XGetWindowAttributes(xfc->display, RootWindowOfScreen(xfc->screen),
-                                &window_attributes) == 0)
+                                &window_attributes) == 0)
        {
                WLog_ERR(TAG, "XGetWindowAttributes failed");
                return FALSE;
        }
 
        vis = XGetVisualInfo(xfc->display, VisualClassMask | VisualScreenMask,
-                            &template, &vi_count);
+                            &template, &vi_count);
 
        if (!vis)
        {
@@ -850,9 +850,9 @@ static BOOL xf_get_pixmap_info(xfContext* xfc)
                /* calculate color shifts required for rdp order color conversion */
                xf_calculate_color_shifts(vi->red_mask, &xfc->red_shift_r, &xfc->red_shift_l);
                xf_calculate_color_shifts(vi->green_mask, &xfc->green_shift_r,
-                                         &xfc->green_shift_l);
+                                         &xfc->green_shift_l);
                xf_calculate_color_shifts(vi->blue_mask, &xfc->blue_shift_r,
-                                         &xfc->blue_shift_l);
+                                         &xfc->blue_shift_l);
        }
 
        XFree(vis);
@@ -891,7 +891,7 @@ static int _xf_error_handler(Display* d, XErrorEvent* ev)
 }
 
 static BOOL xf_play_sound(rdpContext* context,
-                          const PLAY_SOUND_UPDATE* play_sound)
+                         const PLAY_SOUND_UPDATE* play_sound)
 {
        xfContext* xfc = (xfContext*) context;
        XkbBell(xfc->display, None, 100, 0);
@@ -906,7 +906,7 @@ static void xf_check_extensions(xfContext* context)
 
        if (XkbLibraryVersion(&xkb_major, &xkb_minor)
            && XkbQueryExtension(context->display, &xkb_opcode, &xkb_event,
-                                &xkb_error, &xkb_major, &xkb_minor))
+                                &xkb_error, &xkb_major, &xkb_minor))
        {
                context->xkbAvailable = TRUE;
        }
@@ -917,7 +917,7 @@ static void xf_check_extensions(xfContext* context)
                int xrender_error_base;
 
                if (XRenderQueryExtension(context->display, &xrender_event_base,
-                                         &xrender_error_base))
+                                         &xrender_error_base))
                {
                        context->xrenderAvailable = TRUE;
                }
@@ -1061,7 +1061,7 @@ static void xf_button_map_init(xfContext* xfc)
                else
                {
                        WLog_ERR(TAG, "Mouse physical button %d is mapped to logical button %d",
-                                physical, logical);
+                                physical, logical);
                }
        }
 }
@@ -1119,9 +1119,9 @@ static BOOL xf_pre_connect(freerdp* instance)
        settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
        settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;
        PubSub_SubscribeChannelConnected(instance->context->pubSub,
-                                        (pChannelConnectedEventHandler) xf_OnChannelConnectedEventHandler);
+                                        (pChannelConnectedEventHandler) xf_OnChannelConnectedEventHandler);
        PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
-                                           (pChannelDisconnectedEventHandler) xf_OnChannelDisconnectedEventHandler);
+                                           (pChannelDisconnectedEventHandler) xf_OnChannelDisconnectedEventHandler);
 
        if (!freerdp_client_load_addins(channels, instance->settings))
                return FALSE;
@@ -1504,7 +1504,7 @@ static void* xf_client_thread(void* param)
        else
        {
                if (!(inputEvent = freerdp_get_message_queue_event_handle(instance,
-                       FREERDP_INPUT_MESSAGE_QUEUE)))
+                       FREERDP_INPUT_MESSAGE_QUEUE)))
                {
                        WLog_ERR(TAG, "async input: failed to get input event handle");
                        exit_code = XF_EXIT_UNKNOWN;
@@ -1512,7 +1512,7 @@ static void* xf_client_thread(void* param)
                }
 
                if (!(inputThread = CreateThread(NULL, 0,
-                                                (LPTHREAD_START_ROUTINE) xf_input_thread, instance, 0, NULL)))
+                                                (LPTHREAD_START_ROUTINE) xf_input_thread, instance, 0, NULL)))
                {
                        WLog_ERR(TAG, "async input: failed to create input thread");
                        exit_code = XF_EXIT_UNKNOWN;
@@ -1576,7 +1576,7 @@ static void* xf_client_thread(void* param)
                        if (WaitForSingleObject(inputEvent, 0) == WAIT_OBJECT_0)
                        {
                                if (!freerdp_message_queue_process_pending_messages(instance,
-                                       FREERDP_INPUT_MESSAGE_QUEUE))
+                                       FREERDP_INPUT_MESSAGE_QUEUE))
                                {
                                        WLog_INFO(TAG, "User Disconnect");
                                        xfc->disconnect = TRUE;
@@ -1589,7 +1589,7 @@ static void* xf_client_thread(void* param)
        if (settings->AsyncInput)
        {
                wMessageQueue* inputQueue = freerdp_get_message_queue(instance,
-                       FREERDP_INPUT_MESSAGE_QUEUE);
+                       FREERDP_INPUT_MESSAGE_QUEUE);
 
                if (MessageQueue_PostQuit(inputQueue, 0))
                        WaitForSingleObject(inputThread, INFINITE);
@@ -1609,17 +1609,17 @@ disconnect:
 DWORD xf_exit_code_from_disconnect_reason(DWORD reason)
 {
        if (reason == 0 || (reason >= XF_EXIT_PARSE_ARGUMENTS
-                           && reason <= XF_EXIT_AUTH_FAILURE))
+                           && reason <= XF_EXIT_AUTH_FAILURE))
                    return reason;
        /* License error set */
        else if (reason >= 0x100 && reason <= 0x10A)
-                        reason -= 0x100 + XF_EXIT_LICENSE_INTERNAL;
+                        reason -= 0x100 + XF_EXIT_LICENSE_INTERNAL;
        /* RDP protocol error set */
        else if (reason >= 0x10c9 && reason <= 0x1193)
-                        reason = XF_EXIT_RDP;
+                        reason = XF_EXIT_RDP;
        /* There's no need to test protocol-independent codes: they match */
        else if (!(reason <= 0xC))
-                        reason = XF_EXIT_UNKNOWN;
+                        reason = XF_EXIT_UNKNOWN;
 
        return reason;
 }
@@ -1632,7 +1632,7 @@ static void xf_TerminateEventHandler(rdpContext* context, TerminateEventArgs* e)
        if (context->settings->AsyncInput)
        {
                queue = freerdp_get_message_queue(context->instance,
-                                                 FREERDP_INPUT_MESSAGE_QUEUE);
+                                                 FREERDP_INPUT_MESSAGE_QUEUE);
 
                if (queue)
                        MessageQueue_PostQuit(queue, 0);
@@ -1645,7 +1645,7 @@ static void xf_TerminateEventHandler(rdpContext* context, TerminateEventArgs* e)
 
 #ifdef WITH_XRENDER
 static void xf_ZoomingChangeEventHandler(rdpContext* context,
-        ZoomingChangeEventArgs* e)
+       ZoomingChangeEventArgs* e)
 {
        xfContext* xfc = (xfContext*) context;
        rdpSettings* settings = context->settings;
@@ -1670,7 +1670,7 @@ static void xf_ZoomingChangeEventHandler(rdpContext* context,
 }
 
 static void xf_PanningChangeEventHandler(rdpContext* context,
-        PanningChangeEventArgs* e)
+       PanningChangeEventArgs* e)
 {
        xfContext* xfc = (xfContext*) context;
        rdpSettings* settings = context->settings;
@@ -1710,15 +1710,15 @@ static int xfreerdp_client_start(rdpContext* context)
        if (!settings->ServerHostname)
        {
                WLog_ERR(TAG,
-                        "error: server hostname was not specified with /v:<server>[:port]");
+                        "error: server hostname was not specified with /v:<server>[:port]");
                return -1;
        }
 
        xfc->disconnect = FALSE;
 
        if (!(xfc->thread = CreateThread(NULL, 0,
-                                        (LPTHREAD_START_ROUTINE) xf_client_thread,
-                                        context->instance, 0, NULL)))
+                                        (LPTHREAD_START_ROUTINE) xf_client_thread,
+                                        context->instance, 0, NULL)))
        {
                WLog_ERR(TAG, "failed to create client thread");
                return -1;
@@ -1735,7 +1735,7 @@ static int xfreerdp_client_stop(rdpContext* context)
        {
                wMessageQueue* queue;
                queue = freerdp_get_message_queue(context->instance,
-                                                 FREERDP_INPUT_MESSAGE_QUEUE);
+                                                 FREERDP_INPUT_MESSAGE_QUEUE);
 
                if (queue)
                        MessageQueue_PostQuit(queue, 0);
@@ -1780,12 +1780,12 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
        settings = instance->settings;
        xfc->settings = instance->context->settings;
        PubSub_SubscribeTerminate(context->pubSub,
-                                 (pTerminateEventHandler) xf_TerminateEventHandler);
+                                 (pTerminateEventHandler) xf_TerminateEventHandler);
 #ifdef WITH_XRENDER
        PubSub_SubscribeZoomingChange(context->pubSub,
-                                     (pZoomingChangeEventHandler) xf_ZoomingChangeEventHandler);
+                                     (pZoomingChangeEventHandler) xf_ZoomingChangeEventHandler);
        PubSub_SubscribePanningChange(context->pubSub,
-                                     (pPanningChangeEventHandler) xf_PanningChangeEventHandler);
+                                     (pPanningChangeEventHandler) xf_PanningChangeEventHandler);
 #endif
        xfc->UseXThreads = TRUE;
        //xfc->debug = TRUE;
@@ -1805,7 +1805,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
        {
                WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL));
                WLog_ERR(TAG,
-                        "Please check that the $DISPLAY environment variable is properly set.");
+                        "Please check that the $DISPLAY environment variable is properly set.");
                goto fail_open_display;
        }
 
@@ -1820,39 +1820,39 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
        xfc->_NET_WM_ICON = XInternAtom(xfc->display, "_NET_WM_ICON", False);
        xfc->_MOTIF_WM_HINTS = XInternAtom(xfc->display, "_MOTIF_WM_HINTS", False);
        xfc->_NET_CURRENT_DESKTOP = XInternAtom(xfc->display, "_NET_CURRENT_DESKTOP",
-                                               False);
+                                               False);
        xfc->_NET_WORKAREA = XInternAtom(xfc->display, "_NET_WORKAREA", False);
        xfc->_NET_WM_STATE = XInternAtom(xfc->display, "_NET_WM_STATE", False);
        xfc->_NET_WM_STATE_FULLSCREEN = XInternAtom(xfc->display,
-               "_NET_WM_STATE_FULLSCREEN", False);
+               "_NET_WM_STATE_FULLSCREEN", False);
        xfc->_NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom(xfc->display,
-               "_NET_WM_STATE_MAXIMIZED_HORZ", False);
+               "_NET_WM_STATE_MAXIMIZED_HORZ", False);
        xfc->_NET_WM_STATE_MAXIMIZED_VERT = XInternAtom(xfc->display,
-               "_NET_WM_STATE_MAXIMIZED_VERT", False);
+               "_NET_WM_STATE_MAXIMIZED_VERT", False);
        xfc->_NET_WM_FULLSCREEN_MONITORS = XInternAtom(xfc->display,
-               "_NET_WM_FULLSCREEN_MONITORS", False);
+               "_NET_WM_FULLSCREEN_MONITORS", False);
        xfc->_NET_WM_NAME = XInternAtom(xfc->display, "_NET_WM_NAME", False);
        xfc->_NET_WM_PID = XInternAtom(xfc->display, "_NET_WM_PID", False);
        xfc->_NET_WM_WINDOW_TYPE = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE",
-                                              False);
+                                              False);
        xfc->_NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(xfc->display,
-               "_NET_WM_WINDOW_TYPE_NORMAL", False);
+               "_NET_WM_WINDOW_TYPE_NORMAL", False);
        xfc->_NET_WM_WINDOW_TYPE_DIALOG = XInternAtom(xfc->display,
-               "_NET_WM_WINDOW_TYPE_DIALOG", False);
+               "_NET_WM_WINDOW_TYPE_DIALOG", False);
        xfc->_NET_WM_WINDOW_TYPE_POPUP = XInternAtom(xfc->display,
-               "_NET_WM_WINDOW_TYPE_POPUP", False);
+               "_NET_WM_WINDOW_TYPE_POPUP", False);
        xfc->_NET_WM_WINDOW_TYPE_UTILITY = XInternAtom(xfc->display,
-               "_NET_WM_WINDOW_TYPE_UTILITY", False);
+               "_NET_WM_WINDOW_TYPE_UTILITY", False);
        xfc->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU = XInternAtom(xfc->display,
-               "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False);
+               "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False);
        xfc->_NET_WM_STATE_SKIP_TASKBAR = XInternAtom(xfc->display,
-               "_NET_WM_STATE_SKIP_TASKBAR", False);
+               "_NET_WM_STATE_SKIP_TASKBAR", False);
        xfc->_NET_WM_STATE_SKIP_PAGER = XInternAtom(xfc->display,
-               "_NET_WM_STATE_SKIP_PAGER", False);
+               "_NET_WM_STATE_SKIP_PAGER", False);
        xfc->_NET_WM_MOVERESIZE = XInternAtom(xfc->display, "_NET_WM_MOVERESIZE",
-                                             False);
+                                             False);
        xfc->_NET_MOVERESIZE_WINDOW = XInternAtom(xfc->display,
-               "_NET_MOVERESIZE_WINDOW", False);
+               "_NET_MOVERESIZE_WINDOW", False);
        xfc->UTF8_STRING = XInternAtom(xfc->display, "UTF8_STRING", FALSE);
        xfc->WM_PROTOCOLS = XInternAtom(xfc->display, "WM_PROTOCOLS", False);
        xfc->WM_DELETE_WINDOW = XInternAtom(xfc->display, "WM_DELETE_WINDOW", False);
@@ -1865,7 +1865,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
        xfc->invert = (ImageByteOrder(xfc->display) == MSBFirst) ? TRUE : FALSE;
        xfc->complex_regions = TRUE;
        xfc->x11event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfc->xfds,
-               WINPR_FD_READ);
+               WINPR_FD_READ);
 
        if (!xfc->x11event)
        {
@@ -1887,8 +1887,6 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
        else
                xfc->format = PIXEL_FORMAT_RGBX32;
 
-       xfc->format = PIXEL_FORMAT_RGBX32;
-
        if (xfc->debug)
        {
                WLog_INFO(TAG, "Enabling X11 debug mode.");
index 9583a69..41a0af8 100644 (file)
 #define TAG FREERDP_TAG("cache.bitmap")
 
 static rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id,
-                                   UINT32 index);
+                                  UINT32 index);
 static void bitmap_cache_put(rdpBitmapCache* bitmap_cache, UINT32 id,
-                             UINT32 index, rdpBitmap* bitmap);
+                            UINT32 index, rdpBitmap* bitmap);
 
 static BOOL update_gdi_memblt(rdpContext* context,
-                              MEMBLT_ORDER* memblt)
+                             MEMBLT_ORDER* memblt)
 {
        rdpBitmap* bitmap;
        rdpCache* cache = context->cache;
@@ -50,7 +50,7 @@ static BOOL update_gdi_memblt(rdpContext* context,
                bitmap = offscreen_cache_get(cache->offscreen, memblt->cacheIndex);
        else
                bitmap = bitmap_cache_get(cache->bitmap, (BYTE) memblt->cacheId,
-                                         memblt->cacheIndex);
+                                         memblt->cacheIndex);
 
        /* XP-SP2 servers sometimes ask for cached bitmaps they've never defined. */
        if (bitmap == NULL)
@@ -61,7 +61,7 @@ static BOOL update_gdi_memblt(rdpContext* context,
 }
 
 static BOOL update_gdi_mem3blt(rdpContext* context,
-                               MEM3BLT_ORDER* mem3blt)
+                              MEM3BLT_ORDER* mem3blt)
 {
        BYTE style;
        rdpBitmap* bitmap;
@@ -73,7 +73,7 @@ static BOOL update_gdi_mem3blt(rdpContext* context,
                bitmap = offscreen_cache_get(cache->offscreen, mem3blt->cacheIndex);
        else
                bitmap = bitmap_cache_get(cache->bitmap, (BYTE) mem3blt->cacheId,
-                                         mem3blt->cacheIndex);
+                                         mem3blt->cacheIndex);
 
        /* XP-SP2 servers sometimes ask for cached bitmaps they've never defined. */
        if (!bitmap)
@@ -98,7 +98,7 @@ static BOOL update_gdi_mem3blt(rdpContext* context,
 }
 
 static BOOL update_gdi_cache_bitmap(rdpContext* context,
-                                    const CACHE_BITMAP_ORDER* cacheBitmap)
+                                   const CACHE_BITMAP_ORDER* cacheBitmap)
 {
        rdpBitmap* bitmap;
        rdpBitmap* prevBitmap;
@@ -109,10 +109,10 @@ static BOOL update_gdi_cache_bitmap(rdpContext* context,
                return FALSE;
 
        if (!bitmap->Decompress(context, bitmap,
-                               cacheBitmap->bitmapDataStream, cacheBitmap->bitmapWidth,
-                               cacheBitmap->bitmapHeight,
-                               cacheBitmap->bitmapBpp, cacheBitmap->bitmapLength,
-                               cacheBitmap->compressed, RDP_CODEC_ID_NONE))
+                               cacheBitmap->bitmapDataStream, cacheBitmap->bitmapWidth,
+                               cacheBitmap->bitmapHeight,
+                               cacheBitmap->bitmapBpp, cacheBitmap->bitmapLength,
+                               cacheBitmap->compressed, RDP_CODEC_ID_NONE))
        {
                bitmap->Free(context, bitmap);
                return FALSE;
@@ -125,18 +125,18 @@ static BOOL update_gdi_cache_bitmap(rdpContext* context,
        }
 
        prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmap->cacheId,
-                                     cacheBitmap->cacheIndex);
+                                     cacheBitmap->cacheIndex);
 
        if (prevBitmap != NULL)
                prevBitmap->Free(context, prevBitmap);
 
        bitmap_cache_put(cache->bitmap, cacheBitmap->cacheId, cacheBitmap->cacheIndex,
-                        bitmap);
+                        bitmap);
        return TRUE;
 }
 
 static BOOL update_gdi_cache_bitmap_v2(rdpContext* context,
-                                       CACHE_BITMAP_V2_ORDER* cacheBitmapV2)
+                                      CACHE_BITMAP_V2_ORDER* cacheBitmapV2)
 
 {
        rdpBitmap* bitmap;
@@ -155,20 +155,20 @@ static BOOL update_gdi_cache_bitmap_v2(rdpContext* context,
                cacheBitmapV2->bitmapBpp = settings->ColorDepth;
 
        if (!bitmap->Decompress(context, bitmap,
-                               cacheBitmapV2->bitmapDataStream,
-                               cacheBitmapV2->bitmapWidth,
-                               cacheBitmapV2->bitmapHeight,
-                               cacheBitmapV2->bitmapBpp,
-                               cacheBitmapV2->bitmapLength,
-                               cacheBitmapV2->compressed,
-                               RDP_CODEC_ID_NONE))
+                               cacheBitmapV2->bitmapDataStream,
+                               cacheBitmapV2->bitmapWidth,
+                               cacheBitmapV2->bitmapHeight,
+                               cacheBitmapV2->bitmapBpp,
+                               cacheBitmapV2->bitmapLength,
+                               cacheBitmapV2->compressed,
+                               RDP_CODEC_ID_NONE))
        {
                bitmap->Free(context, bitmap);
                return FALSE;
        }
 
        prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmapV2->cacheId,
-                                     cacheBitmapV2->cacheIndex);
+                                     cacheBitmapV2->cacheIndex);
 
        if (!bitmap->New(context, bitmap))
                return FALSE;
@@ -177,12 +177,12 @@ static BOOL update_gdi_cache_bitmap_v2(rdpContext* context,
                prevBitmap->Free(context, prevBitmap);
 
        bitmap_cache_put(cache->bitmap, cacheBitmapV2->cacheId,
-                        cacheBitmapV2->cacheIndex, bitmap);
+                        cacheBitmapV2->cacheIndex, bitmap);
        return TRUE;
 }
 
 static BOOL update_gdi_cache_bitmap_v3(rdpContext* context,
-                                       CACHE_BITMAP_V3_ORDER* cacheBitmapV3)
+                                      CACHE_BITMAP_V3_ORDER* cacheBitmapV3)
 {
        rdpBitmap* bitmap;
        rdpBitmap* prevBitmap;
@@ -200,26 +200,26 @@ static BOOL update_gdi_cache_bitmap_v3(rdpContext* context,
 
        compressed = (bitmapData->codecID != RDP_CODEC_ID_NONE);
        bitmap->Decompress(context, bitmap,
-                          bitmapData->data, bitmapData->width, bitmapData->height,
-                          bitmapData->bpp, bitmapData->length, compressed,
-                          bitmapData->codecID);
+                          bitmapData->data, bitmapData->width, bitmapData->height,
+                          bitmapData->bpp, bitmapData->length, compressed,
+                          bitmapData->codecID);
 
        if (!bitmap->New(context, bitmap))
                return FALSE;
 
        prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmapV3->cacheId,
-                                     cacheBitmapV3->cacheIndex);
+                                     cacheBitmapV3->cacheIndex);
 
        if (prevBitmap)
                prevBitmap->Free(context, prevBitmap);
 
        bitmap_cache_put(cache->bitmap, cacheBitmapV3->cacheId,
-                        cacheBitmapV3->cacheIndex, bitmap);
+                        cacheBitmapV3->cacheIndex, bitmap);
        return TRUE;
 }
 
 static BOOL update_gdi_bitmap_update(rdpContext* context,
-                                     const BITMAP_UPDATE* bitmapUpdate)
+                                    const BITMAP_UPDATE* bitmapUpdate)
 {
        UINT32 i;
        BOOL reused = TRUE;
@@ -242,16 +242,18 @@ static BOOL update_gdi_bitmap_update(rdpContext* context,
                bitmap->length = bitmapData->bitmapLength;
                bitmap->compressed = bitmapData->compressed;
                Bitmap_SetRectangle(bitmap,
-                                   bitmapData->destLeft, bitmapData->destTop,
-                                   bitmapData->destRight, bitmapData->destBottom);
+                                   bitmapData->destLeft, bitmapData->destTop,
+                                   bitmapData->destRight, bitmapData->destBottom);
+
+               bitmap->Decompress(context, bitmap,
+                                  bitmapData->bitmapDataStream, bitmapData->width, bitmapData->height,
+                                  bitmapData->bitsPerPixel, bitmapData->bitmapLength,
+                                  bitmapData->compressed, RDP_CODEC_ID_NONE);
 
                if (reused)
                        bitmap->Free(context, bitmap);
 
-               bitmap->Decompress(context, bitmap,
-                                  bitmapData->bitmapDataStream, bitmapData->width, bitmapData->height,
-                                  bitmapData->bitsPerPixel, bitmapData->bitmapLength,
-                                  bitmapData->compressed, RDP_CODEC_ID_NONE);
+               reused = TRUE;
 
                if (!bitmap->New(context, bitmap))
                        return FALSE;
@@ -264,7 +266,7 @@ static BOOL update_gdi_bitmap_update(rdpContext* context,
 }
 
 rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id,
-                            UINT32 index)
+                           UINT32 index)
 {
        rdpBitmap* bitmap;
 
@@ -289,7 +291,7 @@ rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id,
 }
 
 void bitmap_cache_put(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index,
-                      rdpBitmap* bitmap)
+                     rdpBitmap* bitmap)
 {
        if (id > bitmapCache->maxCells)
        {
@@ -336,7 +338,7 @@ rdpBitmapCache* bitmap_cache_new(rdpSettings* settings)
                bitmapCache->context = bitmapCache->update->context;
                bitmapCache->maxCells = settings->BitmapCacheV2NumCells;
                bitmapCache->cells = (BITMAP_V2_CELL*) calloc(bitmapCache->maxCells,
-                                    sizeof(BITMAP_V2_CELL));
+                                    sizeof(BITMAP_V2_CELL));
 
                if (!bitmapCache->cells)
                {
@@ -349,7 +351,7 @@ rdpBitmapCache* bitmap_cache_new(rdpSettings* settings)
                        bitmapCache->cells[i].number = settings->BitmapCacheV2CellInfo[i].numEntries;
                        /* allocate an extra entry for BITMAP_CACHE_WAITING_LIST_INDEX */
                        bitmapCache->cells[i].entries = (rdpBitmap**) calloc((
-                                                           bitmapCache->cells[i].number + 1), sizeof(rdpBitmap*));
+                                                           bitmapCache->cells[i].number + 1), sizeof(rdpBitmap*));
                }
        }
 
index dc26b6a..b7969f9 100644 (file)
@@ -185,8 +185,8 @@ static BOOL BitBlt_SRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                return FALSE;
 
        return freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline,
-                               nXDest, nYDest, nWidth, nHeight,
-                               hSrcBmp->data, hSrcBmp->format, hSrcBmp->scanline,
+                                 nXDest, nYDest, nWidth, nHeight,
+                                 hSrcBmp->data, hSrcBmp->format, hSrcBmp->scanline,
                                  nXSrc, nYSrc, palette);
 }
 
@@ -228,6 +228,7 @@ static BOOL BitBlt_SRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y;
 
+       /* SDna */
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
@@ -247,7 +248,7 @@ static BOOL BitBlt_SRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 color;
                                colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format,
                                                      palette);
-                               color = colorA & ~colorB;
+                               color = ~colorA & colorB;
                                WriteColor(dstp, hdcDest->format, color);
                        }
                }
@@ -262,6 +263,7 @@ static BOOL BitBlt_NOTSRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y;
 
+       /* DSon */
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
@@ -281,7 +283,7 @@ static BOOL BitBlt_NOTSRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
                                colorA = ConvertColor(colorA, hdcSrc->format,
                                                      hdcDest->format, palette);
-                               color = ~colorA & ~colorB;
+                               color = ~colorA colorB;
                                WriteColor(dstp, hdcDest->format, color);
                        }
                }
@@ -296,6 +298,7 @@ static BOOL BitBlt_SRCINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y;
 
+       /* DSx */
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
@@ -330,6 +333,7 @@ static BOOL BitBlt_SRCAND(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y;
 
+       /* DSa */
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
@@ -364,6 +368,7 @@ static BOOL BitBlt_SRCPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y;
 
+       /* DSo */
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
@@ -397,32 +402,126 @@ static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                            UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
 {
        UINT32 x, y;
-       UINT32 color;
 
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
-       /* D = (D ^ S) & (P ^ D) */
-       color = hdcDest->textColor;
+       if (hdcDest->brush->style == GDI_BS_SOLID)
+       {
+               UINT32 color = hdcDest->brush->color;
 
-       for (y = 0; y < nHeight; y++)
+               for (y = 0; y < nHeight; y++)
+               {
+                       for (x = 0; x < nWidth; x++)
+                       {
+                               const BYTE* srcp = gdi_get_bitmap_pointer(
+                                                      hdcSrc, nXSrc + x, nYSrc + y);
+                               BYTE* dstp = gdi_get_bitmap_pointer(
+                                                hdcDest, nXDest + x, nYDest + y);
+
+                               if (srcp && dstp)
+                               {
+                                       UINT32 dstColor;
+                                       UINT32 colorA = ReadColor(srcp, hdcSrc->format);
+                                       UINT32 colorB = ReadColor(dstp, hdcDest->format);
+                                       colorA = ConvertColor(colorA, hdcSrc->format,
+                                                             hdcDest->format, palette);
+                                       dstColor = (colorA ^ color) & (colorA ^ colorB);
+                                       WriteColor(dstp, hdcDest->format, dstColor);
+                               }
+                       }
+               }
+       }
+       else
        {
-               for (x = 0; x < nWidth; x++)
+               for (y = 0; y < nHeight; y++)
                {
-                       const BYTE* srcp = gdi_get_bitmap_pointer(
-                                              hdcSrc, nXSrc + x, nYSrc + y);
-                       BYTE* dstp = gdi_get_bitmap_pointer(
-                                        hdcDest, nXDest + x, nYDest + y);
+                       for (x = 0; x < nWidth; x++)
+                       {
+                               const BYTE* patp = gdi_get_brush_pointer(
+                                                      hdcDest, nXDest + x, nYDest + y);
+                               const BYTE* srcp = gdi_get_bitmap_pointer(
+                                                      hdcSrc, nXSrc + x, nYSrc + y);
+                               BYTE* dstp = gdi_get_bitmap_pointer(
+                                                hdcDest, nXDest + x, nYDest + y);
 
-                       if (srcp && dstp)
+                               if (srcp && dstp)
+                               {
+                                       UINT32 dstColor;
+                                       UINT32 color = ReadColor(patp, hdcDest->format);
+                                       UINT32 colorA = ReadColor(srcp, hdcSrc->format);
+                                       UINT32 colorB = ReadColor(dstp, hdcDest->format);
+                                       colorA = ConvertColor(colorA, hdcSrc->format,
+                                                             hdcDest->format, palette);
+                                       dstColor = (colorA ^ color) & (colorA ^ colorB);
+                                       WriteColor(dstp, hdcDest->format, dstColor);
+                               }
+                       }
+               }
+       }
+
+       return TRUE;
+}
+
+static BOOL BitBlt_DSPDxox(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
+                           UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+                           UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
+{
+       UINT32 x, y;
+
+       if (!hdcDest || !hdcSrc)
+               return FALSE;
+
+       if (hdcDest->brush->style == GDI_BS_SOLID)
+       {
+               UINT32 color = hdcDest->textColor;
+
+               for (y = 0; y < nHeight; y++)
+               {
+                       for (x = 0; x < nWidth; x++)
                        {
-                               UINT32 dstColor;
-                               UINT32 colorA = ReadColor(srcp, hdcSrc->format);
-                               UINT32 colorB = ReadColor(dstp, hdcDest->format);
-                               colorA = ConvertColor(colorA, hdcSrc->format,
-                                                     hdcDest->format, palette);
-                               dstColor = (colorA & color) | (~colorA & colorB);
-                               WriteColor(dstp, hdcDest->format, dstColor);
+                               const BYTE* srcp = gdi_get_bitmap_pointer(
+                                                      hdcSrc, nXSrc + x, nYSrc + y);
+                               BYTE* dstp = gdi_get_bitmap_pointer(
+                                                hdcDest, nXDest + x, nYDest + y);
+
+                               if (srcp && dstp)
+                               {
+                                       UINT32 dstColor;
+                                       UINT32 colorA = ReadColor(srcp, hdcSrc->format);
+                                       UINT32 colorB = ReadColor(dstp, hdcDest->format);
+                                       colorA = ConvertColor(colorA, hdcSrc->format,
+                                                             hdcDest->format, palette);
+                                       dstColor = (colorA ^ color) | (colorA ^ colorB);
+                                       WriteColor(dstp, hdcDest->format, dstColor);
+                               }
+                       }
+               }
+       }
+       else
+       {
+               for (y = 0; y < nHeight; y++)
+               {
+                       for (x = 0; x < nWidth; x++)
+                       {
+                               const BYTE* srcp = gdi_get_bitmap_pointer(
+                                                      hdcSrc, nXSrc + x, nYSrc + y);
+                               const BYTE* patp = gdi_get_brush_pointer(
+                                                      hdcDest, nXDest + x, nYDest + y);
+                               BYTE* dstp = gdi_get_bitmap_pointer(
+                                                hdcDest, nXDest + x, nYDest + y);
+
+                               if (srcp && dstp)
+                               {
+                                       UINT32 color;
+                                       UINT32 colorA = ReadColor(srcp, hdcSrc->format);
+                                       UINT32 colorB = ReadColor(dstp, hdcDest->format);
+                                       UINT32 colorC = ReadColor(patp, hdcDest->format);
+                                       colorA = ConvertColor(colorA, hdcSrc->format,
+                                                             hdcDest->format, palette);
+                                       color = (colorA ^ colorB) | (colorA ^ colorC);
+                                       WriteColor(dstp, hdcDest->format, color);
+                               }
                        }
                }
        }
@@ -439,7 +538,6 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
-       /* D = (S & D) | (~S & P) */
        if (hdcDest->brush->style == GDI_BS_SOLID)
        {
                UINT32 colorC = hdcDest->brush->color;
@@ -460,7 +558,7 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                        UINT32 colorB = ReadColor(dstp, hdcDest->format);
                                        colorA = ConvertColor(colorA, hdcSrc->format,
                                                              hdcDest->format, palette);
-                                       color = (colorA & colorB) | (~colorA & colorC);
+                                       color = (colorA ^ colorB) & (colorA ^ colorC);
                                        WriteColor(dstp, hdcDest->format, color);
                                }
                        }
@@ -487,7 +585,7 @@ static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                        UINT32 colorC = ReadColor(patp, hdcDest->format);
                                        colorA = ConvertColor(colorA, hdcSrc->format,
                                                              hdcDest->format, palette);
-                                       color = (colorA & colorB) | (~colorA & colorC);
+                                       color = (colorA ^ colorB) & (colorA ^ colorC);
                                        WriteColor(dstp, hdcDest->format, color);
                                }
                        }
@@ -527,8 +625,8 @@ static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                        UINT32 colorB = ReadColor(dstp, hdcDest->format);
                                        colorA = ConvertColor(colorA, hdcSrc->format,
                                                              hdcDest->format, palette);
-                                       colorD = colorA ^ (color & (colorB ^ colorA));
-                                       WriteColor(dstp, hdcDest->format, color);
+                                       colorD = (colorA ^ color) & (colorB ^ colorA);
+                                       WriteColor(dstp, hdcDest->format, colorD);
                                }
                        }
                }
@@ -554,8 +652,8 @@ static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                        UINT32 color = ReadColor(patp, hdcDest->format);
                                        colorA = ConvertColor(colorA, hdcSrc->format,
                                                              hdcDest->format, palette);
-                                       colorD = colorA ^ (color & (colorB ^ colorA));
-                                       WriteColor(dstp, hdcDest->format, color);
+                                       colorD = (colorA ^ color) & (colorB ^ colorA);
+                                       WriteColor(dstp, hdcDest->format, colorD);
                                }
                        }
                }
@@ -573,24 +671,51 @@ static BOOL BitBlt_SPna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
-       for (y = 0; y < nHeight; y++)
+       if (hdcDest->brush->style == GDI_BS_SOLID)
        {
-               for (x = 0; x < nWidth; x++)
+               UINT32 colorB = hdcDest->brush->color;
+
+               for (y = 0; y < nHeight; y++)
                {
-                       const BYTE* srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc + x, nYSrc + y);
-                       const BYTE* patp = gdi_get_brush_pointer(hdcDest, nXDest + x, nYDest + y);
-                       BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
+                       for (x = 0; x < nWidth; x++)
+                       {
+                               const BYTE* srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc + x, nYSrc + y);
+                               BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
 
-                       if (srcp && patp && dstp)
+                               if (srcp && dstp)
+                               {
+                                       UINT32 color;
+                                       UINT32 colorA = ReadColor(srcp, hdcSrc->format);
+                                       colorB = ConvertColor(colorB, hdcDest->format,
+                                                             hdcSrc->format, palette);
+                                       color = ~colorA & colorB;
+                                       color = ConvertColor(color, hdcSrc->format, hdcDest->format, palette);
+                                       WriteColor(dstp, hdcDest->format, color);
+                               }
+                       }
+               }
+       }
+       else
+       {
+               for (y = 0; y < nHeight; y++)
+               {
+                       for (x = 0; x < nWidth; x++)
                        {
-                               UINT32 color;
-                               UINT32 colorA = ReadColor(srcp, hdcSrc->format);
-                               UINT32 colorB = ReadColor(patp, hdcDest->format);
-                               colorB = ConvertColor(colorB, hdcDest->format,
-                                                     hdcSrc->format, palette);
-                               color = colorA & ~colorB;
-                               color = ConvertColor(color, hdcSrc->format, hdcDest->format, palette);
-                               WriteColor(dstp, hdcDest->format, color);
+                               const BYTE* srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc + x, nYSrc + y);
+                               const BYTE* patp = gdi_get_brush_pointer(hdcDest, nXDest + x, nYDest + y);
+                               BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
+
+                               if (srcp && patp && dstp)
+                               {
+                                       UINT32 color;
+                                       UINT32 colorA = ReadColor(srcp, hdcSrc->format);
+                                       UINT32 colorB = ReadColor(patp, hdcDest->format);
+                                       colorB = ConvertColor(colorB, hdcDest->format,
+                                                             hdcSrc->format, palette);
+                                       color = ~colorA & colorB;
+                                       color = ConvertColor(color, hdcSrc->format, hdcDest->format, palette);
+                                       WriteColor(dstp, hdcDest->format, color);
+                               }
                        }
                }
        }
@@ -623,7 +748,7 @@ static BOOL BitBlt_DSna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 colorB = ReadColor(dstp, hdcDest->format);
                                colorA = ConvertColor(colorA, hdcSrc->format,
                                                      hdcDest->format, palette);
-                               color = ~colorA & colorB;
+                               color = colorA & ~colorB;
                                WriteColor(dstp, hdcDest->format, color);
                        }
                }
@@ -640,6 +765,7 @@ static BOOL BitBlt_MERGECOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y;
 
+       /* PSa */
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
@@ -676,6 +802,7 @@ static BOOL BitBlt_MERGEPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y;
 
+       /* DSno */
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
@@ -693,7 +820,7 @@ static BOOL BitBlt_MERGEPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                                UINT32 color;
                                colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format,
                                                      palette);
-                               color = ~colorA | colorB;
+                               color = colorA | ~colorB;
                                WriteColor(dstp, hdcDest->format, color);
                        }
                }
@@ -760,6 +887,10 @@ BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        return BitBlt_DSPDxax(hdcDest, nXDest, nYDest, nWidth, nHeight,
                                              hdcSrc, nXSrc, nYSrc, palette);
 
+               case GDI_DSPDxox:
+                       return BitBlt_DSPDxox(hdcDest, nXDest, nYDest, nWidth, nHeight,
+                                             hdcSrc, nXSrc, nYSrc, palette);
+
                case GDI_PSDPxax:
                        return BitBlt_PSDPxax(hdcDest, nXDest, nYDest, nWidth, nHeight,
                                              hdcSrc, nXSrc, nYSrc, palette);
index 03f2450..7fee455 100644 (file)
@@ -374,7 +374,7 @@ static BOOL BitBlt_PDxn(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
                        {
                                UINT32 colorA = ReadColor(dstp, hdcDest->format);
                                UINT32 colorB = ReadColor(patp, hdcDest->format);
-                               UINT32 color = colorA ^ ~colorB;
+                               UINT32 color = ~colorA ^ colorB;
                                WriteColor(dstp, hdcDest->format, color);
                        }
                }
@@ -388,6 +388,7 @@ static BOOL BitBlt_PATINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y;
 
+       /* DPx */
        if (hdcDest->brush->style == GDI_BS_SOLID)
        {
                UINT32 color = hdcDest->brush->color;
@@ -436,6 +437,7 @@ static BOOL BitBlt_PATPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y;
 
+       /* DPSnoo */
        if (!hdcDest || !hdcSrc)
                return FALSE;
 
@@ -466,6 +468,7 @@ static BOOL BitBlt_PATCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
 {
        UINT32 x, y, xOffset, yOffset;
 
+       /* P */
        if (hdcDest->brush->style == GDI_BS_SOLID)
        {
                UINT32 color = hdcDest->brush->color;
index 5133442..4ec564d 100644 (file)
@@ -271,7 +271,7 @@ static BOOL gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, UINT32 x,
        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_DSPDxox, &context->gdi->palette);
 }
 
 static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
@@ -279,8 +279,6 @@ static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
                                 UINT32 fgcolor, BOOL fOpRedundant)
 {
        rdpGdi* gdi;
-       GDI_RECT rect;
-       HGDI_BRUSH brush;
 
        if (!context || !context->gdi)
                return FALSE;
@@ -296,6 +294,11 @@ static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
        if (!gdi_decode_color(gdi, fgcolor, &fgcolor, NULL))
                return FALSE;
 
+       gdi->drawing->hdc->brush = gdi_CreateSolidBrush(fgcolor);
+
+       if (!gdi->drawing->hdc->brush)
+               return FALSE;
+
        gdi_SetTextColor(gdi->drawing->hdc, fgcolor);
        gdi_SetBkColor(gdi->drawing->hdc, bgcolor);
        return gdi_SetClipRgn(gdi->drawing->hdc, x, y, width, height);
@@ -314,6 +317,7 @@ static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
        if (!gdi->drawing || !gdi->drawing->hdc)
                return FALSE;
 
+       gdi_DeleteObject(gdi->drawing->hdc->brush);
        gdi_SetNullClipRgn(gdi->drawing->hdc);
        return TRUE;
 }