Fix GDI return values and other fixes
authorBernhard Miklautz <bernhard.miklautz@thincast.com>
Fri, 17 Apr 2015 14:21:55 +0000 (16:21 +0200)
committerBernhard Miklautz <bernhard.miklautz@thincast.com>
Tue, 21 Apr 2015 12:18:07 +0000 (14:18 +0200)
* top level GDI functions return 0 on error and != 0 otherwise but the
  low level functions (16bpp.c, 8bpp.c 32bpp.c) which are called did it
exactly the other way around. Those were adapted.
* change gdi_InvalidateRegion to BOOL and check calls where appropriate
* integrate comments from pull request

21 files changed:
client/X11/xf_gdi.c
client/X11/xf_graphics.c
client/X11/xf_keyboard.c
include/freerdp/api.h
include/freerdp/gdi/region.h
libfreerdp/cache/bitmap.c
libfreerdp/cache/brush.c
libfreerdp/cache/nine_grid.c
libfreerdp/core/fastpath.c
libfreerdp/core/graphics.c
libfreerdp/core/input.c
libfreerdp/core/update.c
libfreerdp/gdi/16bpp.c
libfreerdp/gdi/32bpp.c
libfreerdp/gdi/8bpp.c
libfreerdp/gdi/bitmap.c
libfreerdp/gdi/gdi.c
libfreerdp/gdi/graphics.c
libfreerdp/gdi/include/line.c
libfreerdp/gdi/region.c
libfreerdp/gdi/test/TestGdiCreate.c

index fdb1004..dfc66f8 100644 (file)
@@ -346,6 +346,7 @@ BOOL xf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate)
        BITMAP_DATA* bitmap;
        rdpCodecs* codecs = context->codecs;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        for (index = 0; index < bitmapUpdate->number; index++)
        {
@@ -430,11 +431,11 @@ BOOL xf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate)
 
                XFree(image);
 
-               gdi_InvalidateRegion(xfc->hdc, nXDst, nYDst, nWidth, nHeight);
+               ret = gdi_InvalidateRegion(xfc->hdc, nXDst, nYDst, nWidth, nHeight);
 
                xf_unlock_x11(xfc, FALSE);
        }
-       return TRUE;
+       return ret;
 }
 
 static BOOL xf_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette)
@@ -485,6 +486,7 @@ static BOOL xf_gdi_set_bounds(rdpContext* context, rdpBounds* bounds)
 static BOOL xf_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
 {
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -496,14 +498,12 @@ static BOOL xf_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
                        dstblt->nWidth, dstblt->nHeight);
 
        if (xfc->drawing == xfc->primary)
-       {
-               gdi_InvalidateRegion(xfc->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight);
-       }
+               ret = gdi_InvalidateRegion(xfc->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight);
 
        XSetFunction(xfc->display, xfc->gc, GXcopy);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
@@ -513,6 +513,7 @@ static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
        UINT32 foreColor;
        UINT32 backColor;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -584,19 +585,18 @@ static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
        }
 
        if (xfc->drawing == xfc->primary)
-       {
-               gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
-       }
+               ret = gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
 
        XSetFunction(xfc->display, xfc->gc, GXcopy);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 static BOOL xf_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
 {
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -606,20 +606,19 @@ static BOOL xf_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
                        scrblt->nWidth, scrblt->nHeight, scrblt->nLeftRect, scrblt->nTopRect);
 
        if (xfc->drawing == xfc->primary)
-       {
-               gdi_InvalidateRegion(xfc->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight);
-       }
+               ret = gdi_InvalidateRegion(xfc->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight);
 
        XSetFunction(xfc->display, xfc->gc, GXcopy);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 BOOL xf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
 {
        UINT32 color;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -634,13 +633,11 @@ BOOL xf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
                        opaque_rect->nWidth, opaque_rect->nHeight);
 
        if (xfc->drawing == xfc->primary)
-       {
-               gdi_InvalidateRegion(xfc->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
+               ret = gdi_InvalidateRegion(xfc->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
                                opaque_rect->nWidth, opaque_rect->nHeight);
-       }
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 BOOL xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
@@ -649,6 +646,7 @@ BOOL xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* mult
        UINT32 color;
        DELTA_RECT* rectangle;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -667,13 +665,11 @@ BOOL xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* mult
                                rectangle->width, rectangle->height);
 
                if (xfc->drawing == xfc->primary)
-               {
-                       gdi_InvalidateRegion(xfc->hdc, rectangle->left, rectangle->top, rectangle->width, rectangle->height);
-               }
+                       ret = gdi_InvalidateRegion(xfc->hdc, rectangle->left, rectangle->top, rectangle->width, rectangle->height);
        }
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 void xf_gdi_draw_nine_grid(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_grid)
@@ -685,6 +681,7 @@ BOOL xf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to)
 {
        UINT32 color;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -707,18 +704,19 @@ BOOL xf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to)
                w = abs(line_to->nXEnd - line_to->nXStart) + 1;
                h = abs(line_to->nYEnd - line_to->nYStart) + 1;
 
-               gdi_InvalidateRegion(xfc->hdc, x, y, w, h);
+               ret = gdi_InvalidateRegion(xfc->hdc, x, y, w, h);
        }
 
        XSetFunction(xfc->display, xfc->gc, GXcopy);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
-static void xf_gdi_invalidate_poly_region(xfContext* xfc, XPoint* points, int npoints, BOOL autoclose)
+static BOOL xf_gdi_invalidate_poly_region(xfContext* xfc, XPoint* points, int npoints, BOOL autoclose)
 {
        int i, x, y, x1, y1, x2, y2, w, h;
+       BOOL ret = TRUE;
 
        x1 = points[0].x;
        y1 = points[0].y;
@@ -751,8 +749,9 @@ static void xf_gdi_invalidate_poly_region(xfContext* xfc, XPoint* points, int np
                x1 = x2;
                y1 = y2;
 
-               gdi_InvalidateRegion(xfc->hdc, x, y, w, h);
+               ret = gdi_InvalidateRegion(xfc->hdc, x, y, w, h);
        }
+       return ret;
 }
 
 BOOL xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
@@ -762,6 +761,7 @@ BOOL xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
        UINT32 color;
        XPoint* points;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -792,20 +792,22 @@ BOOL xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
 
        if (xfc->drawing == xfc->primary)
        {
-               xf_gdi_invalidate_poly_region(xfc, points, npoints, FALSE);
+               if (!xf_gdi_invalidate_poly_region(xfc, points, npoints, FALSE))
+                       ret = FALSE;
        }
 
        XSetFunction(xfc->display, xfc->gc, GXcopy);
        free(points);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 BOOL xf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
 {
        xfBitmap* bitmap;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -817,14 +819,12 @@ BOOL xf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
                        memblt->nLeftRect, memblt->nTopRect);
 
        if (xfc->drawing == xfc->primary)
-       {
-               gdi_InvalidateRegion(xfc->hdc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, memblt->nHeight);
-       }
+               ret = gdi_InvalidateRegion(xfc->hdc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, memblt->nHeight);
 
        XSetFunction(xfc->display, xfc->gc, GXcopy);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
@@ -835,6 +835,7 @@ BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
        UINT32 backColor;
        Pixmap pattern = 0;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -883,9 +884,7 @@ BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
                        mem3blt->nLeftRect, mem3blt->nTopRect);
 
        if (xfc->drawing == xfc->primary)
-       {
-               gdi_InvalidateRegion(xfc->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight);
-       }
+               ret = gdi_InvalidateRegion(xfc->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight);
 
        XSetFillStyle(xfc->display, xfc->gc, FillSolid);
        XSetTSOrigin(xfc->display, xfc->gc, 0, 0);
@@ -896,7 +895,7 @@ BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
        XSetFunction(xfc->display, xfc->gc, GXcopy);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 BOOL xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
@@ -905,6 +904,7 @@ BOOL xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
        XPoint* points;
        UINT32 brush_color;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -951,14 +951,15 @@ BOOL xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
 
        if (xfc->drawing == xfc->primary)
        {
-               xf_gdi_invalidate_poly_region(xfc, points, npoints, TRUE);
+               if (!xf_gdi_invalidate_poly_region(xfc, points, npoints, TRUE))
+                       ret = FALSE;
        }
 
        XSetFunction(xfc->display, xfc->gc, GXcopy);
        free(points);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
@@ -970,6 +971,7 @@ BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
        UINT32 foreColor;
        UINT32 backColor;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -1045,7 +1047,8 @@ BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
 
                if (xfc->drawing == xfc->primary)
                {
-                       xf_gdi_invalidate_poly_region(xfc, points, npoints, TRUE);
+                       if (!xf_gdi_invalidate_poly_region(xfc, points, npoints, TRUE))
+                               ret = FALSE;
                }
        }
        else
@@ -1057,7 +1060,7 @@ BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
        free(points);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 BOOL xf_gdi_ellipse_sc(rdpContext* context, ELLIPSE_SC_ORDER* ellipse_sc)
@@ -1081,9 +1084,11 @@ BOOL xf_gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surf
 {
        rdpSettings* settings;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        settings = xfc->instance->settings;
 
+
        xf_lock_x11(xfc, FALSE);
 
        switch (surface_frame_marker->frameAction)
@@ -1099,10 +1104,8 @@ BOOL xf_gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surf
                case SURFACECMD_FRAMEACTION_END:
                        xfc->frame_begin = FALSE;
                        if ((xfc->frame_x2 > xfc->frame_x1) && (xfc->frame_y2 > xfc->frame_y1))
-                       {
-                               gdi_InvalidateRegion(xfc->hdc, xfc->frame_x1, xfc->frame_y1,
+                               ret = gdi_InvalidateRegion(xfc->hdc, xfc->frame_x1, xfc->frame_y1,
                                        xfc->frame_x2 - xfc->frame_x1, xfc->frame_y2 - xfc->frame_y1);
-                       }
                        if (settings->FrameAcknowledge > 0)
                        {
                                IFCALL(xfc->instance->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId);
@@ -1111,11 +1114,12 @@ BOOL xf_gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surf
        }
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
-static void xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty, UINT16 width, UINT16 height)
+static BOOL xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty, UINT16 width, UINT16 height)
 {
+       BOOL ret = TRUE;
        if (!xfc->remote_app)
        {
                if (xfc->frame_begin)
@@ -1137,13 +1141,14 @@ static void xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty, UI
                }
                else
                {
-                       gdi_InvalidateRegion(xfc->hdc, tx, ty, width, height);
+                       ret = gdi_InvalidateRegion(xfc->hdc, tx, ty, width, height);
                }
        }
        else
        {
-               gdi_InvalidateRegion(xfc->hdc, tx, ty, width, height);
+               ret = gdi_InvalidateRegion(xfc->hdc, tx, ty, width, height);
        }
+       return ret;
 }
 
 BOOL xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd)
@@ -1154,6 +1159,7 @@ BOOL xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd)
        BYTE* pDstData;
        RFX_MESSAGE* message;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
@@ -1208,7 +1214,11 @@ BOOL xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd)
                        tx = message->rects[i].x + cmd->destLeft;
                        ty = message->rects[i].y + cmd->destTop;
 
-                       xf_gdi_surface_update_frame(xfc, tx, ty, message->rects[i].width, message->rects[i].height);
+                       if (!xf_gdi_surface_update_frame(xfc, tx, ty, message->rects[i].width, message->rects[i].height))
+                       {
+                               ret = FALSE;
+                               break;
+                       }
                }
 
                XSetClipMask(xfc->display, xfc->gc, None);
@@ -1246,7 +1256,7 @@ BOOL xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd)
 
                XFree(image);
 
-               xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width, cmd->height);
+               ret = xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width, cmd->height);
 
                XSetClipMask(xfc->display, xfc->gc, None);
        }
@@ -1278,7 +1288,7 @@ BOOL xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd)
                                cmd->width, cmd->height);
                XFree(image);
 
-               xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width, cmd->height);
+               ret = xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width, cmd->height);
 
                XSetClipMask(xfc->display, xfc->gc, None);
        }
@@ -1288,7 +1298,7 @@ BOOL xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd)
        }
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 void xf_gdi_register_update_callbacks(rdpUpdate* update)
index 48ed758..c7c292f 100644 (file)
@@ -111,6 +111,7 @@ BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
        XImage* image;
        int width, height;
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        width = bitmap->right - bitmap->left + 1;
        height = bitmap->bottom - bitmap->top + 1;
@@ -127,7 +128,7 @@ BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
 
        XFree(image);
 
-       gdi_InvalidateRegion(xfc->hdc, bitmap->left, bitmap->top, width, height);
+       ret = gdi_InvalidateRegion(xfc->hdc, bitmap->left, bitmap->top, width, height);
 
        xf_unlock_x11(xfc, FALSE);
        return TRUE;
@@ -451,16 +452,15 @@ BOOL xf_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height
 BOOL xf_Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor)
 {
        xfContext* xfc = (xfContext*) context;
+       BOOL ret = TRUE;
 
        xf_lock_x11(xfc, FALSE);
 
        if (xfc->drawing == xfc->primary)
-       {
-               gdi_InvalidateRegion(xfc->hdc, x, y, width, height);
-       }
+               ret = gdi_InvalidateRegion(xfc->hdc, x, y, width, height);
 
        xf_unlock_x11(xfc, FALSE);
-       return TRUE;
+       return ret;
 }
 
 /* Graphics Module */
index c538da6..6258e7d 100644 (file)
@@ -550,7 +550,7 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym)
        }
 #endif /* WITH_XRENDER defined */
 #endif /* pinch/zoom/pan simulation */
-       return TRUE;
+       return FALSE;
 }
 
 BOOL xf_keyboard_set_indicators(rdpContext* context, UINT16 led_flags)
index 24a2ee3..b18a75c 100644 (file)
@@ -66,6 +66,6 @@
 
 #define IFCALL(_cb, ...) do { if (_cb != NULL) { _cb( __VA_ARGS__ ); } } while (0)
 #define IFCALLRET(_cb, _ret, ...) do { if (_cb != NULL) { _ret = _cb( __VA_ARGS__ ); } } while (0)
-#define IFCALLRETURN(_default_return, _cb, ...) do { if (_cb != NULL) { return _cb( __VA_ARGS__ ); } else { return _default_return;} } while (0)
+#define IFCALLRESULT(_default_return, _cb, ...) (_cb != NULL) ? _cb( __VA_ARGS__ ) : (_default_return)
 
 #endif /* FREERDP_API */
index be32691..e577263 100644 (file)
@@ -44,7 +44,7 @@ FREERDP_API int gdi_SetRectRgn(HGDI_RGN hRgn, int nLeftRect, int nTopRect, int n
 FREERDP_API int gdi_EqualRgn(HGDI_RGN hSrcRgn1, HGDI_RGN hSrcRgn2);
 FREERDP_API int gdi_CopyRect(HGDI_RECT dst, HGDI_RECT src);
 FREERDP_API int gdi_PtInRect(HGDI_RECT rc, int x, int y);
-FREERDP_API int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h);
+FREERDP_API BOOL gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h);
 
 #ifdef __cplusplus
  }
index b291497..14fda44 100644 (file)
@@ -48,7 +48,7 @@ BOOL update_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
                return TRUE;
 
        memblt->bitmap = bitmap;
-       IFCALLRETURN(TRUE, cache->bitmap->MemBlt, context, memblt);
+       return IFCALLRESULT(TRUE, cache->bitmap->MemBlt, context, memblt);
 }
 
 BOOL update_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
index 81da014..57aa9e5 100644 (file)
@@ -57,7 +57,7 @@ BOOL update_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
 BOOL update_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
 {
        rdpCache* cache = context->cache;
-       IFCALLRETURN(TRUE, cache->brush->PolygonSC, context, polygon_sc);
+       return IFCALLRESULT(TRUE, cache->brush->PolygonSC, context, polygon_sc);
 }
 
 BOOL update_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
index 09d63fd..315d7bf 100644 (file)
 BOOL update_gdi_draw_nine_grid(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_grid)
 {
        rdpCache* cache = context->cache;
-       IFCALLRETURN(TRUE, cache->nine_grid->DrawNineGrid, context, draw_nine_grid);
+       return IFCALLRESULT(TRUE, cache->nine_grid->DrawNineGrid, context, draw_nine_grid);
 }
 
 BOOL update_gdi_multi_draw_nine_grid(rdpContext* context, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
 {
        rdpCache* cache = context->cache;
-       IFCALLRETURN(TRUE, cache->nine_grid->MultiDrawNineGrid, context, multi_draw_nine_grid);
+       return IFCALLRESULT(TRUE, cache->nine_grid->MultiDrawNineGrid, context, multi_draw_nine_grid);
 }
 
 void nine_grid_cache_register_callbacks(rdpUpdate* update)
index a3d9b57..14ea6b8 100644 (file)
@@ -733,6 +733,8 @@ wStream* fastpath_input_pdu_init_header(rdpFastPath* fastpath)
        rdp = fastpath->rdp;
 
        s = transport_send_stream_init(rdp->transport, 256);
+       if (!s)
+               return NULL;
 
        Stream_Seek(s, 3); /* fpInputHeader, length1 and length2 */
 
@@ -757,6 +759,8 @@ wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE ev
        rdp = fastpath->rdp;
 
        s = fastpath_input_pdu_init_header(fastpath);
+       if (!s)
+               return NULL;
        Stream_Write_UINT8(s, eventFlags | (eventCode << 5)); /* eventHeader (1 byte) */
 
        return s;
index 57a5cc2..27fe50a 100644 (file)
@@ -150,7 +150,7 @@ BOOL Pointer_SetDefault(rdpContext* context)
 
 BOOL Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
 {
-       IFCALLRETURN(TRUE, context->graphics->Pointer_Prototype->SetPosition, context, x, y);
+       return IFCALLRESULT(TRUE, context->graphics->Pointer_Prototype->SetPosition, context, x, y);
 }
 
 void graphics_register_pointer(rdpGraphics* graphics, rdpPointer* pointer)
index 153b099..0070a07 100644 (file)
@@ -343,7 +343,7 @@ static BOOL input_recv_sync_event(rdpInput* input, wStream* s)
        Stream_Seek(s, 2); /* pad2Octets (2 bytes) */
        Stream_Read_UINT32(s, toggleFlags); /* toggleFlags (4 bytes) */
 
-       IFCALLRETURN(TRUE, input->SynchronizeEvent, input, toggleFlags);
+       return IFCALLRESULT(TRUE, input->SynchronizeEvent, input, toggleFlags);
 }
 
 static BOOL input_recv_keyboard_event(rdpInput* input, wStream* s)
@@ -376,7 +376,7 @@ static BOOL input_recv_keyboard_event(rdpInput* input, wStream* s)
        else
                keyboardFlags |= KBD_FLAGS_DOWN;
 
-       IFCALLRETURN(TRUE, input->KeyboardEvent, input, keyboardFlags, keyCode);
+       return IFCALLRESULT(TRUE, input->KeyboardEvent, input, keyboardFlags, keyCode);
 }
 
 static BOOL input_recv_unicode_keyboard_event(rdpInput* input, wStream* s)
@@ -397,7 +397,7 @@ static BOOL input_recv_unicode_keyboard_event(rdpInput* input, wStream* s)
        else
                keyboardFlags |= KBD_FLAGS_DOWN;
 
-       IFCALLRETURN(TRUE, input->UnicodeKeyboardEvent, input, keyboardFlags, unicodeCode);
+       return IFCALLRESULT(TRUE, input->UnicodeKeyboardEvent, input, keyboardFlags, unicodeCode);
 }
 
 static BOOL input_recv_mouse_event(rdpInput* input, wStream* s)
@@ -411,7 +411,7 @@ static BOOL input_recv_mouse_event(rdpInput* input, wStream* s)
        Stream_Read_UINT16(s, xPos); /* xPos (2 bytes) */
        Stream_Read_UINT16(s, yPos); /* yPos (2 bytes) */
 
-       IFCALLRETURN(TRUE, input->MouseEvent, input, pointerFlags, xPos, yPos);
+       return IFCALLRESULT(TRUE, input->MouseEvent, input, pointerFlags, xPos, yPos);
 }
 
 static BOOL input_recv_extended_mouse_event(rdpInput* input, wStream* s)
@@ -425,7 +425,7 @@ static BOOL input_recv_extended_mouse_event(rdpInput* input, wStream* s)
        Stream_Read_UINT16(s, xPos); /* xPos (2 bytes) */
        Stream_Read_UINT16(s, yPos); /* yPos (2 bytes) */
 
-       IFCALLRETURN(TRUE, input->ExtendedMouseEvent, input, pointerFlags, xPos, yPos);
+       return IFCALLRESULT(TRUE, input->ExtendedMouseEvent, input, pointerFlags, xPos, yPos);
 }
 
 static BOOL input_recv_event(rdpInput* input, wStream* s)
@@ -533,12 +533,12 @@ void input_register_client_callbacks(rdpInput* input)
 
 BOOL freerdp_input_send_synchronize_event(rdpInput* input, UINT32 flags)
 {
-       IFCALLRETURN(TRUE, input->SynchronizeEvent, input, flags);
+       return IFCALLRESULT(TRUE, input->SynchronizeEvent, input, flags);
 }
 
 BOOL freerdp_input_send_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
 {
-       IFCALLRETURN(TRUE, input->KeyboardEvent, input, flags, code);
+       return IFCALLRESULT(TRUE, input->KeyboardEvent, input, flags, code);
 }
 
 BOOL freerdp_input_send_keyboard_event_ex(rdpInput* input, BOOL down, UINT32 rdp_scancode)
@@ -551,27 +551,27 @@ BOOL freerdp_input_send_keyboard_event_ex(rdpInput* input, BOOL down, UINT32 rdp
 
 BOOL freerdp_input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
 {
-       IFCALLRETURN(TRUE, input->UnicodeKeyboardEvent, input, flags, code);
+       return IFCALLRESULT(TRUE, input->UnicodeKeyboardEvent, input, flags, code);
 }
 
 BOOL freerdp_input_send_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
 {
-       IFCALLRETURN(TRUE, input->MouseEvent, input, flags, x, y);
+       return IFCALLRESULT(TRUE, input->MouseEvent, input, flags, x, y);
 }
 
 BOOL freerdp_input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
 {
-       IFCALLRETURN(TRUE, input->ExtendedMouseEvent, input, flags, x, y);
+       return IFCALLRESULT(TRUE, input->ExtendedMouseEvent, input, flags, x, y);
 }
 
 BOOL freerdp_input_send_focus_in_event(rdpInput* input, UINT16 toggleStates)
 {
-       IFCALLRETURN(TRUE, input->FocusInEvent, input, toggleStates);
+       return IFCALLRESULT(TRUE, input->FocusInEvent, input, toggleStates);
 }
 
 BOOL freerdp_input_send_keyboard_pause_event(rdpInput* input)
 {
-       IFCALLRETURN(TRUE, input->KeyboardPauseEvent, input);
+       return IFCALLRESULT(TRUE, input->KeyboardPauseEvent, input);
 }
 
 int input_process_events(rdpInput* input)
index 56d17d0..2d2e2b3 100644 (file)
@@ -970,6 +970,7 @@ static BOOL update_send_surface_frame_bits(rdpContext* context, SURFACE_BITS_COM
        s = fastpath_update_pdu_init(rdp->fastpath);
        if (!s)
                return FALSE;
+
        if (!Stream_EnsureRemainingCapacity(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH + (int) cmd->bitmapDataLength + 16))
                goto out_fail;
 
@@ -986,7 +987,7 @@ static BOOL update_send_surface_frame_bits(rdpContext* context, SURFACE_BITS_COM
        if (last)
        {
                if (!update_write_surfcmd_frame_marker(s, SURFACECMD_FRAMEACTION_END, frameId))
-                       return FALSE;
+                       goto out_fail;
        }
 
        ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s, cmd->skipCompression);
@@ -1748,7 +1749,7 @@ static BOOL update_send_pointer_color(rdpContext* context, POINTER_COLOR_UPDATE*
        if (!s)
                return FALSE;
 
-    if (!update_write_pointer_color(s, pointer_color))
+       if (!update_write_pointer_color(s, pointer_color))
                goto out_fail;
 
        ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_COLOR, s, FALSE);
index 58e6989..f8980fa 100644 (file)
@@ -104,8 +104,9 @@ int FillRect_16bpp(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr)
                }
        }
 
-       gdi_InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight);
-       return 0;
+       if (!gdi_InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight))
+               return 0;
+       return 1;
 }
 
 static int BitBlt_BLACKNESS_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -121,7 +122,7 @@ static int BitBlt_BLACKNESS_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                        memset(dstp, 0, nWidth * hdcDest->bytesPerPixel);
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_WHITENESS_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -137,7 +138,7 @@ static int BitBlt_WHITENESS_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                        memset(dstp, 0xFF, nWidth * hdcDest->bytesPerPixel);
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -147,7 +148,7 @@ static int BitBlt_SRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        BYTE* dstp;
 
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
            gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc) == 0)
@@ -161,7 +162,7 @@ static int BitBlt_SRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                                memcpy(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
                }
 
-               return 0;
+               return 1;
        }
        
        if (nYSrc < nYDest)
@@ -201,7 +202,7 @@ static int BitBlt_SRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_NOTSRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -211,7 +212,7 @@ static int BitBlt_NOTSRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
        UINT16* dstp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -229,7 +230,7 @@ static int BitBlt_NOTSRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DSTINVERT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -251,7 +252,7 @@ static int BitBlt_DSTINVERT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -261,7 +262,7 @@ static int BitBlt_SRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
        UINT16* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -279,7 +280,7 @@ static int BitBlt_SRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_NOTSRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -289,7 +290,7 @@ static int BitBlt_NOTSRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
        UINT16* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -307,7 +308,7 @@ static int BitBlt_NOTSRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCINVERT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -317,7 +318,7 @@ static int BitBlt_SRCINVERT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
        UINT16* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -335,7 +336,7 @@ static int BitBlt_SRCINVERT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCAND_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -345,7 +346,7 @@ static int BitBlt_SRCAND_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
        UINT16* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -363,7 +364,7 @@ static int BitBlt_SRCAND_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -373,7 +374,7 @@ static int BitBlt_SRCPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
        UINT16* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -391,7 +392,7 @@ static int BitBlt_SRCPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DSPDxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -404,7 +405,7 @@ static int BitBlt_DSPDxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        HGDI_BITMAP hSrcBmp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        /* D = (S & P) | (~S & D) */
        /* DSPDxax, used to draw glyphs */
@@ -437,7 +438,7 @@ static int BitBlt_DSPDxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PSDPxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -449,7 +450,7 @@ static int BitBlt_PSDPxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        UINT16 color16;
 
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        /* D = (S & D) | (~S & P) */
 
@@ -494,7 +495,7 @@ static int BitBlt_PSDPxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SPna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -505,7 +506,7 @@ static int BitBlt_SPna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
        UINT16* patp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -524,7 +525,7 @@ static int BitBlt_SPna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DPa_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -549,7 +550,7 @@ static int BitBlt_DPa_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PDxn_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -573,7 +574,7 @@ static int BitBlt_PDxn_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DSna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -583,7 +584,7 @@ static int BitBlt_DSna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
        UINT16* dstp;
 
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -601,7 +602,7 @@ static int BitBlt_DSna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
                }
        }
 
-       return 0;
+       return 1;
 }
 
 
@@ -613,7 +614,7 @@ static int BitBlt_MERGECOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
        UINT16* patp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -632,7 +633,7 @@ static int BitBlt_MERGECOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_MERGEPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -642,7 +643,7 @@ static int BitBlt_MERGEPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
        UINT16* dstp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -660,7 +661,7 @@ static int BitBlt_MERGEPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PATCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -719,7 +720,7 @@ static int BitBlt_PATCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PATINVERT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -765,7 +766,7 @@ static int BitBlt_PATINVERT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PATPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -776,7 +777,7 @@ static int BitBlt_PATPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
        UINT16* patp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -795,7 +796,7 @@ static int BitBlt_PATPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
        
-       return 0;
+       return 1;
 }
 
 int BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop)
@@ -814,10 +815,8 @@ int BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeigh
                        return 0;
        }
        
-       gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight);
-
-       if (!hdcDest)
-               return 1;
+       if (!gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight))
+               return 0;
 
        switch (rop)
        {
@@ -888,7 +887,8 @@ int PatBlt_16bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, i
        if (gdi_ClipCoords(hdc, &nXLeft, &nYLeft, &nWidth, &nHeight, NULL, NULL) == 0)
                return 0;
        
-       gdi_InvalidateRegion(hdc, nXLeft, nYLeft, nWidth, nHeight);
+       if (!gdi_InvalidateRegion(hdc, nXLeft, nYLeft, nWidth, nHeight))
+               return 0;
 
        switch (rop)
        {
index 0fe3b5a..100be43 100644 (file)
@@ -90,8 +90,9 @@ int FillRect_32bpp(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr)
                }
        }
 
-       gdi_InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight);
-       return 0;
+       if (!gdi_InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight))
+               return 0;
+       return 1;
 }
 
 static int BitBlt_BLACKNESS_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -138,7 +139,7 @@ static int BitBlt_BLACKNESS_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_WHITENESS_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -154,7 +155,7 @@ static int BitBlt_WHITENESS_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                        memset(dstp, 0xFF, nWidth * hdcDest->bytesPerPixel);
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -164,7 +165,7 @@ static int BitBlt_SRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        BYTE* dstp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
            gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc) == 0)
@@ -178,7 +179,7 @@ static int BitBlt_SRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                                memmove(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
                }
 
-               return 0;
+               return 1;
        }
        
        if (nYSrc < nYDest)
@@ -218,7 +219,7 @@ static int BitBlt_SRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_NOTSRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -228,7 +229,7 @@ static int BitBlt_NOTSRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
        UINT32* dstp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -246,7 +247,7 @@ static int BitBlt_NOTSRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DSTINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -268,7 +269,7 @@ static int BitBlt_DSTINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -278,7 +279,7 @@ static int BitBlt_SRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
        UINT32* dstp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -296,7 +297,7 @@ static int BitBlt_SRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_NOTSRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -306,7 +307,7 @@ static int BitBlt_NOTSRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
        UINT32* dstp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -324,7 +325,7 @@ static int BitBlt_NOTSRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -334,7 +335,7 @@ static int BitBlt_SRCINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
        UINT32* dstp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -352,7 +353,7 @@ static int BitBlt_SRCINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCAND_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -362,7 +363,7 @@ static int BitBlt_SRCAND_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
        UINT32* dstp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -380,7 +381,7 @@ static int BitBlt_SRCAND_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -390,7 +391,7 @@ static int BitBlt_SRCPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
        UINT32* dstp;
                
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -408,7 +409,7 @@ static int BitBlt_SRCPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DSPDxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -423,7 +424,7 @@ static int BitBlt_DSPDxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        HGDI_BITMAP hSrcBmp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        /* D = (S & P) | (~S & D) */
 
@@ -476,7 +477,7 @@ static int BitBlt_DSPDxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PSDPxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -488,7 +489,7 @@ static int BitBlt_PSDPxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        UINT32 color32;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        /* D = (S & D) | (~S & P) */
 
@@ -533,7 +534,7 @@ static int BitBlt_PSDPxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SPDSxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -545,7 +546,7 @@ static int BitBlt_SPDSxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        UINT32 color32;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        /* D = S ^ (P & (D ^ S)) */
 
@@ -590,7 +591,7 @@ static int BitBlt_SPDSxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SPna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -601,7 +602,7 @@ static int BitBlt_SPna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
        UINT32* patp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -621,7 +622,7 @@ static int BitBlt_SPna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DSna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -631,7 +632,7 @@ static int BitBlt_DSna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
        UINT32* dstp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -649,7 +650,7 @@ static int BitBlt_DSna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DPa_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -674,7 +675,7 @@ static int BitBlt_DPa_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PDxn_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -699,7 +700,7 @@ static int BitBlt_PDxn_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_MERGECOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -710,7 +711,7 @@ static int BitBlt_MERGECOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
        UINT32* patp;
        
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -730,7 +731,7 @@ static int BitBlt_MERGECOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_MERGEPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -740,7 +741,7 @@ static int BitBlt_MERGEPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
        UINT32* dstp;
        
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -758,7 +759,7 @@ static int BitBlt_MERGEPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PATCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -817,7 +818,7 @@ static int BitBlt_PATCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PATINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -863,7 +864,7 @@ static int BitBlt_PATINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PATPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -874,7 +875,7 @@ static int BitBlt_PATPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
        UINT32* patp;
 
        if (!hdcDest || !hdcSrc)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -893,7 +894,7 @@ static int BitBlt_PATPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
        
-       return 0;
+       return 1;
 }
 
 int BitBlt_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop)
@@ -912,10 +913,8 @@ int BitBlt_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeigh
                        return 0;
        }
        
-       gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight);
-
-       if (!hdcDest)
-               return 1;
+       if (!gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight))
+               return 0;
 
        switch (rop)
        {
@@ -989,7 +988,8 @@ int PatBlt_32bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, i
        if (gdi_ClipCoords(hdc, &nXLeft, &nYLeft, &nWidth, &nHeight, NULL, NULL) == 0)
                return 0;
        
-       gdi_InvalidateRegion(hdc, nXLeft, nYLeft, nWidth, nHeight);
+       if (!gdi_InvalidateRegion(hdc, nXLeft, nYLeft, nWidth, nHeight))
+               return 0;
 
        switch (rop)
        {
index d01fb2d..697b5ea 100644 (file)
 BYTE gdi_get_color_8bpp(HGDI_DC hdc, GDI_COLOR color)
 {
        /* TODO: Implement 8bpp gdi_get_color_8bpp() */
-       return 0;
+       return 1;
 }
 
 int FillRect_8bpp(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr)
 {
        /* TODO: Implement 8bpp FillRect() */
-       return 0;
+       return 1;
 }
 
 static int BitBlt_BLACKNESS_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -66,7 +66,7 @@ static int BitBlt_BLACKNESS_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                        memset(dstp, 0, nWidth * hdcDest->bytesPerPixel);
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_WHITENESS_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -82,7 +82,7 @@ static int BitBlt_WHITENESS_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                        memset(dstp, 0xFF, nWidth * hdcDest->bytesPerPixel);
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -92,7 +92,7 @@ static int BitBlt_SRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
        BYTE* dstp;
 
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
            gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc) == 0)
@@ -106,7 +106,7 @@ static int BitBlt_SRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
                                memcpy(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
                }
 
-               return 0;
+               return 1;
        }
        
        if (nYSrc < nYDest)
@@ -146,7 +146,7 @@ static int BitBlt_SRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_NOTSRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -156,7 +156,7 @@ static int BitBlt_NOTSRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
        BYTE* dstp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -174,7 +174,7 @@ static int BitBlt_NOTSRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DSTINVERT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -196,7 +196,7 @@ static int BitBlt_DSTINVERT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -206,7 +206,7 @@ static int BitBlt_SRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        BYTE* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -224,7 +224,7 @@ static int BitBlt_SRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_NOTSRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -234,7 +234,7 @@ static int BitBlt_NOTSRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
        BYTE* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -252,7 +252,7 @@ static int BitBlt_NOTSRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCINVERT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -262,7 +262,7 @@ static int BitBlt_SRCINVERT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
        BYTE* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -280,7 +280,7 @@ static int BitBlt_SRCINVERT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCAND_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -290,7 +290,7 @@ static int BitBlt_SRCAND_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidt
        BYTE* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -308,7 +308,7 @@ static int BitBlt_SRCAND_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidt
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SRCPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -318,7 +318,7 @@ static int BitBlt_SRCPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        BYTE* dstp;
                
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -336,16 +336,16 @@ static int BitBlt_SRCPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DSPDxax_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
 {
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        /* TODO: Implement 8bpp DSPDxax BitBlt */
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PSDPxax_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -357,7 +357,7 @@ static int BitBlt_PSDPxax_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
        BYTE color8;
 
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        /* D = (S & D) | (~S & P) */
 
@@ -402,7 +402,7 @@ static int BitBlt_PSDPxax_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_SPna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -413,7 +413,7 @@ static int BitBlt_SPna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
        BYTE* patp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -434,7 +434,7 @@ static int BitBlt_SPna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DPa_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -459,7 +459,7 @@ static int BitBlt_DPa_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PDxn_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -485,7 +485,7 @@ static int BitBlt_PDxn_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_DSna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -495,7 +495,7 @@ static int BitBlt_DSna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
        BYTE* dstp;
 
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -513,7 +513,7 @@ static int BitBlt_DSna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_MERGECOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -524,7 +524,7 @@ static int BitBlt_MERGECOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
        BYTE* patp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -545,7 +545,7 @@ static int BitBlt_MERGECOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_MERGEPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -555,7 +555,7 @@ static int BitBlt_MERGEPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
        BYTE* dstp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -573,7 +573,7 @@ static int BitBlt_MERGEPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PATCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -632,7 +632,7 @@ static int BitBlt_PATCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
                }
        }
 
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PATINVERT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
@@ -678,7 +678,7 @@ static int BitBlt_PATINVERT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
                }
        }
        
-       return 0;
+       return 1;
 }
 
 static int BitBlt_PATPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
@@ -689,7 +689,7 @@ static int BitBlt_PATPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
        BYTE* patp;
        
        if (!hdcSrc || !hdcDest)
-               return 1;
+               return 0;
 
        for (y = 0; y < nHeight; y++)
        {
@@ -710,11 +710,14 @@ static int BitBlt_PATPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
                }
        }
        
-       return 0;
+       return 1;
 }
 
 int BitBlt_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop)
 {
+       if (!hdcDest)
+               return 0;
+
        if (hdcSrc != NULL)
        {
                if (gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc, &nYSrc) == 0)
@@ -726,10 +729,8 @@ int BitBlt_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight
                        return 0;
        }
        
-       gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight);
-
-       if (!hdcDest)
-               return 1;
+       if (!gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight))
+               return 0;
 
        switch (rop)
        {
@@ -800,7 +801,8 @@ int PatBlt_8bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, in
        if (gdi_ClipCoords(hdc, &nXLeft, &nYLeft, &nWidth, &nHeight, NULL, NULL) == 0)
                return 0;
        
-       gdi_InvalidateRegion(hdc, nXLeft, nYLeft, nWidth, nHeight);
+       if (!gdi_InvalidateRegion(hdc, nXLeft, nYLeft, nWidth, nHeight))
+               return 0;
 
        switch (rop)
        {
index d01a4b9..da150ec 100644 (file)
@@ -105,7 +105,7 @@ INLINE GDI_COLOR gdi_SetPixel(HGDI_DC hdc, int X, int Y, GDI_COLOR crColor)
 {
        HGDI_BITMAP hBmp = (HGDI_BITMAP) hdc->selectedObject;
        *((GDI_COLOR*)&(hBmp->data[(Y * hBmp->width * hdc->bytesPerPixel) + X * hdc->bytesPerPixel])) = crColor;
-       return 0;
+       return crColor;
 }
 
 INLINE void gdi_SetPixel_8bpp(HGDI_BITMAP hBmp, int X, int Y, BYTE pixel)
@@ -195,7 +195,7 @@ HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, int nWidth, int nHeight)
  * @param nXSrc source x1
  * @param nYSrc source y1
  * @param rop raster operation code
- * @return 1 if successful, 0 otherwise
+ * @return 0 on failure, non-zero otherwise
  */
 
 int gdi_BitBlt(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop)
index 267ef35..e153aba 100644 (file)
@@ -529,7 +529,7 @@ static BOOL gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate)
                status = freerdp_image_copy(pDstData, gdi->format, nDstStep, nXDst, nYDst,
                                nWidth, nHeight, pSrcData, gdi->format, nSrcStep, nXSrc, nYSrc, gdi->palette);
 
-               gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, nWidth, nHeight);
+               return gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, nWidth, nHeight);
        }
        return TRUE;
 }
@@ -572,7 +572,7 @@ static BOOL gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
        rdpGdi* gdi = context->gdi;
 
        if (gdi_BitBlt(gdi->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
-                       dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)) != 1)
+                       dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)) == 0)
                return FALSE;
        return TRUE;
 }
@@ -607,7 +607,7 @@ static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
                }
 
                if (gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
-                               patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)) != 1)
+                               patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)) == 0)
                        ret = FALSE;
 
                gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
@@ -648,7 +648,7 @@ static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
                }
 
                if (gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
-               patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)) != 1)
+               patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)) == 0)
                        ret = FALSE;
 
                gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
@@ -704,7 +704,7 @@ static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
                }
 
                if (gdi_PatBlt(gdi->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
-                               patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)) != 1)
+                               patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop)) == 0)
                        ret = FALSE;
 
                gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
@@ -726,7 +726,7 @@ static BOOL gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
 
        if (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)) != 1)
+                       scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop)) == 0)
                return FALSE;
        return TRUE;
 }
@@ -851,9 +851,10 @@ static BOOL gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
 
        bitmap = (gdiBitmap*) memblt->bitmap;
 
-       gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
+       if (gdi_BitBlt(gdi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
                        memblt->nWidth, memblt->nHeight, bitmap->hdc,
-                       memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop));
+                       memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop)) == 0)
+               return FALSE;
        return TRUE;
 }
 
index 3cc3e80..9bc0919 100644 (file)
@@ -149,7 +149,7 @@ BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
        height = bitmap->bottom - bitmap->top + 1;
 
        if (gdi_BitBlt(context->gdi->primary->hdc, bitmap->left, bitmap->top,
-                       width, height, gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY) != 0)
+                       width, height, gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY) == 0)
                return FALSE;
        return TRUE;
 }
@@ -288,7 +288,7 @@ BOOL gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y)
        gdi_glyph = (gdiGlyph*) glyph;
 
        if (gdi_BitBlt(gdi->drawing->hdc, x, y, gdi_glyph->bitmap->width,
-                       gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0, GDI_DSPDxax) != 0)
+                       gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0, GDI_DSPDxax) == 0)
                return FALSE;
        return TRUE;
 }
@@ -298,7 +298,7 @@ BOOL gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int heigh
        GDI_RECT rect;
        HGDI_BRUSH brush;
        rdpGdi* gdi = context->gdi;
-       int ret = 1;
+       int ret = 0;
 
        /* TODO: handle fOpRedundant! See xf_Glyph_BeginDraw() */
 
@@ -307,10 +307,7 @@ BOOL gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int heigh
 
        brush = gdi_CreateSolidBrush(fgcolor);
        if (!brush)
-       {
                goto out_fail;
-               return FALSE;
-       }
 
        gdi_CRgnToRect(x, y, width, height, &rect);
        ret = gdi_FillRect(gdi->drawing->hdc, &rect, brush);
@@ -319,7 +316,7 @@ BOOL gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int heigh
 out_fail:
        gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
 
-       if (ret != 0)
+       if (ret == 0)
                return FALSE;
        return TRUE;
 }
index 8088d79..fb48c25 100644 (file)
@@ -71,7 +71,8 @@ int LINE_TO(HGDI_DC hdc, int nXEnd, int nYEnd)
        bx2 = MIN(bx2, bmp->width - 1);
        by2 = MIN(by2, bmp->height - 1);
        
-       gdi_InvalidateRegion(hdc, bx1, by1, bx2 - bx1 + 1, by2 - by1 + 1);
+       if (!gdi_InvalidateRegion(hdc, bx1, by1, bx2 - bx1 + 1, by2 - by1 + 1))
+               return 0;
 
        pen = GDI_GET_PEN_COLOR(hdc->pen);
 
index 07ef30e..13cd0d5 100644 (file)
@@ -67,6 +67,8 @@ HGDI_RGN gdi_CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBot
 HGDI_RECT gdi_CreateRect(int xLeft, int yTop, int xRight, int yBottom)
 {
        HGDI_RECT hRect = (HGDI_RECT) malloc(sizeof(GDI_RECT));
+       if (!hRect)
+               return NULL;
        hRect->objectType = GDIOBJECT_RECT;
        hRect->left = xLeft;
        hRect->top = yTop;
@@ -363,10 +365,10 @@ INLINE int gdi_PtInRect(HGDI_RECT rc, int x, int y)
  * @param y y1
  * @param w width
  * @param h height
- * @return
+ * @return FALSE on error
  */
 
-INLINE int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h)
+INLINE BOOL gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h)
 {
        GDI_RECT inv;
        GDI_RECT rgn;
@@ -374,13 +376,13 @@ INLINE int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h)
        HGDI_RGN cinvalid;
 
        if (!hdc->hwnd)
-               return 0;
+               return TRUE;
 
        if (!hdc->hwnd->invalid)
-               return 0;
+               return TRUE;
 
        if (w == 0 || h == 0)
-               return 0;
+               return TRUE;
 
        cinvalid = hdc->hwnd->cinvalid;
 
@@ -392,7 +394,7 @@ INLINE int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h)
                new_cnt = hdc->hwnd->count * 2;
                new_rgn = (HGDI_RGN) realloc(cinvalid, sizeof(GDI_RGN) * new_cnt);
                if (!new_rgn)
-                       return -1;
+                       return FALSE;
                hdc->hwnd->count = new_cnt;
                cinvalid = new_rgn;
        }
@@ -409,7 +411,7 @@ INLINE int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h)
                invalid->w = w;
                invalid->h = h;
                invalid->null = 0;
-               return 0;
+               return TRUE;
        }
 
        gdi_CRgnToRect(x, y, w, h, &rgn);
@@ -435,5 +437,5 @@ INLINE int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h)
 
        gdi_RectToRgn(&inv, invalid);
 
-       return 0;
+       return TRUE;
 }
index ac319c1..1203ff3 100644 (file)
@@ -221,6 +221,8 @@ int test_gdi_CreateRect(void)
        int y2 = 256;
 
        HGDI_RECT hRect = gdi_CreateRect(x1, y1, x2, y2);
+       if (!hRect)
+               return -1;
 
        if (hRect->objectType != GDIOBJECT_RECT)
                return -1;