diff --git a/graphics/nxbe/nxbe_filltrapezoid.c b/graphics/nxbe/nxbe_filltrapezoid.c index 82adbd5190e..31593e71e6f 100644 --- a/graphics/nxbe/nxbe_filltrapezoid.c +++ b/graphics/nxbe/nxbe_filltrapezoid.c @@ -285,9 +285,10 @@ void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) { struct nxgl_rect_s remaining; + struct nxgl_rect_s absclip; struct nxgl_trapezoid_s devtrap; - DEBUGASSERT(wnd != NULL && trap != NULL); + DEBUGASSERT(wnd != NULL && clip != NULL && trap != NULL); /* Offset the trapezoid by the window origin to position it within * the device graphics coordinate system. @@ -304,12 +305,8 @@ void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd, /* Clip to any user specified clipping window */ - if (clip != NULL) - { - struct nxgl_rect_s tmp; - nxgl_rectoffset(&tmp, clip, wnd->bounds.pt1.x, wnd->bounds.pt1.y); - nxgl_rectintersect(&remaining, &remaining, &tmp); - } + nxgl_rectoffset(&absclip, clip, wnd->bounds.pt1.x, wnd->bounds.pt1.y); + nxgl_rectintersect(&remaining, &remaining, &absclip); /* Clip to the limits of the window and of the background screen */ diff --git a/libs/libnx/nx/nx_drawline.c b/libs/libnx/nx/nx_drawline.c index 762957e3e7e..f142db954f1 100644 --- a/libs/libnx/nx/nx_drawline.c +++ b/libs/libnx/nx/nx_drawline.c @@ -80,7 +80,7 @@ int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector, int ret; #ifdef CONFIG_DEBUG_FEATURES - if (!hwnd || !vector || width < 1 || !color) + if (hwnd == NULL || vector == NULL || width < 1 || color == NULL) { set_errno(EINVAL); return ERROR; diff --git a/libs/libnx/nxglib/nxglib_trapoffset.c b/libs/libnx/nxglib/nxglib_trapoffset.c index 51ec4922358..9222f43d59e 100644 --- a/libs/libnx/nxglib/nxglib_trapoffset.c +++ b/libs/libnx/nxglib/nxglib_trapoffset.c @@ -60,4 +60,3 @@ void nxgl_trapoffset(FAR struct nxgl_trapezoid_s *dest, nxgl_runoffset(&dest->top, &src->top, dx, dy); nxgl_runoffset(&dest->bot, &src->bot, dx, dy); } - diff --git a/libs/libnx/nxmu/nx_filltrapezoid.c b/libs/libnx/nxmu/nx_filltrapezoid.c index 49327a9d106..b6069257f6c 100644 --- a/libs/libnx/nxmu/nx_filltrapezoid.c +++ b/libs/libnx/nxmu/nx_filltrapezoid.c @@ -77,10 +77,10 @@ int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, struct nxsvrmsg_filltrapezoid_s outmsg; int i; +#ifdef CONFIG_DEBUG_FEATURES /* Some debug-only sanity checks */ -#ifdef CONFIG_DEBUG_FEATURES - if (!wnd || !trap || !color) + if (wnd == NULL || trap == NULL || color == NULL) { set_errno(EINVAL); return ERROR; @@ -94,13 +94,22 @@ int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, /* If no clipping window was provided, then use the size of the entire window */ - if (clip) + if (clip != NULL) { nxgl_rectcopy(&outmsg.clip, clip); } else { - nxgl_rectcopy(&outmsg.clip, &wnd->bounds); + struct nxgl_rect_s tmpclip; + + /* Convert the window bounds to window relative coordinates */ + + nxgl_rectoffset(&tmpclip, &wnd->bounds, + -wnd->bounds.pt1.x, -wnd->bounds.pt1.y); + + /* And use that for the clipping winding */ + + nxgl_rectcopy(&outmsg.clip, &tmpclip); } /* Copy the trapezod and the color into the message */