diff --git a/graphics/nxbe/nxbe_bitmap.c b/graphics/nxbe/nxbe_bitmap.c index fe13f8c35dd..b2209e7d466 100644 --- a/graphics/nxbe/nxbe_bitmap.c +++ b/graphics/nxbe/nxbe_bitmap.c @@ -329,16 +329,21 @@ void nxbe_bitmap(FAR struct nxbe_window_s *wnd, nxbe_bitmap_dev(wnd, dest, src, origin, stride); #ifdef CONFIG_NX_SWCURSOR - /* Save the modified cursor background region - * REVISIT: Only a single color plane is supported - */ + /* Update the software cursor if it is visible */ - wnd->be->plane[0].cursor.backup(wnd->be, dest, 0); + if (wnd->be->cursor.visible) + { + /* Save the modified cursor background region + * REVISIT: Only a single color plane is supported + */ - /* Restore the software cursor if any part of the cursor was - * overwritten by the bitmap copy. - */ + wnd->be->plane[0].cursor.backup(wnd->be, dest, 0); - wnd->be->plane[0].cursor.draw(wnd->be, dest, 0); + /* Restore the software cursor if any part of the cursor was + * overwritten by the bitmap copy. + */ + + wnd->be->plane[0].cursor.draw(wnd->be, dest, 0); + } #endif } diff --git a/graphics/nxbe/nxbe_cursor.c b/graphics/nxbe/nxbe_cursor.c index 03fe80731b7..796dd0644d0 100644 --- a/graphics/nxbe/nxbe_cursor.c +++ b/graphics/nxbe/nxbe_cursor.c @@ -69,23 +69,36 @@ void nxbe_cursor_enable(FAR struct nxbe_state_s *be, bool enable) { - /* Are we enabling the cursor */ + /* Are we enabling the cursor? Don't allow the cursor to be enabled if no + * image has been assigned to the cursor */ if (enable && !be->cursor.visible) { +#ifdef CONFIG_NX_SWCURSOR + /* Don't allow the cursor to be enabled if no image has been assigned + * to the cursor + */ + + if (be->cursor.image != NULL) + { + /* Save the cursor background image */ + + DEBUGASSERT(be->cursor.bkgd != NULL); + be->plane[0].cursor.backup(be, &be->cursor.bounds, 0); + + /* Write the new cursor image to device memory */ + + be->plane[0].cursor.draw(be, &be->cursor.bounds, 0); + + /* Mark the cursor visible */ + + be->cursor.visible = true; + } +#else /* Mark the cursor visible */ be->cursor.visible = true; -#ifdef CONFIG_NX_SWCURSOR - /* Save the cursor background image */ - - be->plane[0].cursor.backup(be, &be->cursor.bounds, 0); - - /* Write the new cursor image to device memory */ - - be->plane[0].cursor.draw(be, &be->cursor.bounds, 0); -#else /* For a hardware cursor, this would require some interaction with the * grahics device. */ @@ -105,6 +118,7 @@ void nxbe_cursor_enable(FAR struct nxbe_state_s *be, bool enable) #ifdef CONFIG_NX_SWCURSOR /* Erase the old cursor image by writing the saved background image. */ + DEBUGASSERT(be->cursor.bkgd != NULL); be->plane[0].cursor.erase(be, &be->cursor.bounds, 0); #else /* For a hardware cursor, this would require some interaction with the @@ -156,6 +170,7 @@ void nxbe_cursor_setimage(FAR struct nxbe_state_s *be, { /* Erase the old cursor image by writing the saved background image. */ + DEBUGASSERT(be->cursor.bkgd != NULL); be->plane[0].cursor.erase(be, &be->cursor.bounds, 0); } @@ -283,16 +298,16 @@ void nxbe_cursor_setposition(FAR struct nxbe_state_s *be, nxgl_rectoffset(&be->cursor.bounds, &be->cursor.bounds, dx, dy); - /* Read in the new background image at this offset */ - - be->plane[0].cursor.backup(be, &be->cursor.bounds, 0); - /* If the cursor is visible, then put write the new cursor image into * device graphics memory now. */ if (be->cursor.visible) { + /* Read in the new background image at this offset */ + + be->plane[0].cursor.backup(be, &be->cursor.bounds, 0); + /* Write the new cursor image to the device graphics memory. */ be->plane[0].cursor.draw(be, &be->cursor.bounds, 0); diff --git a/graphics/nxbe/nxbe_fill.c b/graphics/nxbe/nxbe_fill.c index e8df58095ad..c76fd43c39c 100644 --- a/graphics/nxbe/nxbe_fill.c +++ b/graphics/nxbe/nxbe_fill.c @@ -129,21 +129,26 @@ static inline void nxbe_fill_dev(FAR struct nxbe_window_s *wnd, &info.cops, &wnd->be->plane[i]); #ifdef CONFIG_NX_SWCURSOR - /* Save the modified cursor background region. - * - * REVISIT: This and the following logic belongs in the function - * nxbe_clipfill(). It is here only because the struct nxbe_state_s - * (wnd->be) is not available at that point. This may result in an - * excessive number of cursor updates. - */ + /* Update the software cursor if it is visible */ - wnd->be->plane[i].cursor.backup(wnd->be, rect, i); + if (wnd->be->cursor.visible) + { + /* Save the modified cursor background region. + * + * REVISIT: This and the following logic belongs in the function + * nxbe_clipfill(). It is here only because the struct nxbe_state_s + * (wnd->be) is not available at that point. This may result in an + * excessive number of cursor updates. + */ - /* Restore the software cursor if any part of the cursor was - * overwritten by the fill. - */ + wnd->be->plane[i].cursor.backup(wnd->be, rect, i); - wnd->be->plane[i].cursor.draw(wnd->be, rect, i); + /* Restore the software cursor if any part of the cursor was + * overwritten by the fill. + */ + + wnd->be->plane[i].cursor.draw(wnd->be, rect, i); + } #endif } } diff --git a/graphics/nxbe/nxbe_filltrapezoid.c b/graphics/nxbe/nxbe_filltrapezoid.c index 473e863d725..7c5b3d6988c 100644 --- a/graphics/nxbe/nxbe_filltrapezoid.c +++ b/graphics/nxbe/nxbe_filltrapezoid.c @@ -159,21 +159,26 @@ static inline void nxbe_filltrapezoid_dev(FAR struct nxbe_window_s *wnd, &info.cops, &wnd->be->plane[i]); #ifdef CONFIG_NX_SWCURSOR - /* Save the modified cursor background region. - * - * REVISIT: This and the following logic belongs in the function - * nxbe_clipfilltrapezoid(). It is here only because the struct - * nxbe_state_s (wnd->be) is not available at that point. This - * result in an excessive number of cursor updates. - */ + /* Update the software cursor if it is visible */ - wnd->be->plane[i].cursor.backup(wnd->be, bounds, i); + if (wnd->be->cursor.visible) + { + /* Save the modified cursor background region. + * + * REVISIT: This and the following logic belongs in the function + * nxbe_clipfilltrapezoid(). It is here only because the struct + * nxbe_state_s (wnd->be) is not available at that point. This + * result in an excessive number of cursor updates. + */ - /* Restore the software cursor if any part of the cursor was - * overwritten by the fill. - */ + wnd->be->plane[i].cursor.backup(wnd->be, bounds, i); - wnd->be->plane[i].cursor.draw(wnd->be, bounds, i); + /* Restore the software cursor if any part of the cursor was + * overwritten by the fill. + */ + + wnd->be->plane[i].cursor.draw(wnd->be, bounds, i); + } #endif } } diff --git a/graphics/nxbe/nxbe_flush.c b/graphics/nxbe/nxbe_flush.c index 89bee660928..365fb8f0270 100644 --- a/graphics/nxbe/nxbe_flush.c +++ b/graphics/nxbe/nxbe_flush.c @@ -95,11 +95,16 @@ void nxbe_flush(FAR struct nxbe_window_s *wnd, nxbe_bitmap_dev(wnd, dest, src, origin, stride); #ifdef CONFIG_NX_SWCURSOR - /* Restore the software cursor if any part of the cursor was overwritten - * by the above copy. - */ + /* Is the software cursor visible? */ - wnd->be->plane[0].cursor.draw(wnd->be, dest, 0); + if (wnd->be->cursor.visible) + { + /* Restore the software cursor if any part of the cursor was + * overwritten by the above copy. + */ + + wnd->be->plane[0].cursor.draw(wnd->be, dest, 0); + } #endif } diff --git a/graphics/nxbe/nxbe_move.c b/graphics/nxbe/nxbe_move.c index 8ab2964316c..109a3066d44 100644 --- a/graphics/nxbe/nxbe_move.c +++ b/graphics/nxbe/nxbe_move.c @@ -280,9 +280,14 @@ static inline void nxbe_move_dev(FAR struct nxbe_window_s *wnd, #endif { #ifdef CONFIG_NX_SWCURSOR - /* Remove the cursor from the source region */ + /* Is the cursor visible? */ - wnd->be->plane[i].cursor.erase(wnd->be, rect, i); + if (wnd->be->cursor.visible) + { + /* Remove the cursor from the source region */ + + wnd->be->plane[i].cursor.erase(wnd->be, rect, i); + } #endif nxbe_clipper(wnd->above, &info.srcrect, info.order, @@ -290,23 +295,28 @@ static inline void nxbe_move_dev(FAR struct nxbe_window_s *wnd, #ifdef CONFIG_NX_SWCURSOR - /* Save the modified cursor background region at the destination - * region. This would be necessary only for small moves that stay - * within the cursor region. - * - * REVISIT: This and the following logic belongs in the function - * nxbe_clipmovedest(). It is here only because the struct - * nxbe_state_s (wnd->be) is not available at that point. This - * result in an excessive number of cursor updates. - */ + /* Update the software cursor if it is visible */ - wnd->be->plane[i].cursor.backup(wnd->be, &dest, i); + if (wnd->be->cursor.visible) + { + /* Save the modified cursor background region at the destination + * region. This would be necessary only for small moves that stay + * within the cursor region. + * + * REVISIT: This and the following logic belongs in the function + * nxbe_clipmovedest(). It is here only because the struct + * nxbe_state_s (wnd->be) is not available at that point. This + * result in an excessive number of cursor updates. + */ - /* Restore the software cursor if any part of the cursor was - * overwritten by the fill. - */ + wnd->be->plane[i].cursor.backup(wnd->be, &dest, i); - wnd->be->plane[i].cursor.draw(wnd->be, &dest, i); + /* Restore the software cursor if any part of the cursor was + * overwritten by the fill. + */ + + wnd->be->plane[i].cursor.draw(wnd->be, &dest, i); + } #endif } } diff --git a/graphics/nxbe/nxbe_setpixel.c b/graphics/nxbe/nxbe_setpixel.c index f5489e66291..14d3ba097a6 100644 --- a/graphics/nxbe/nxbe_setpixel.c +++ b/graphics/nxbe/nxbe_setpixel.c @@ -153,20 +153,25 @@ void nxbe_setpixel(FAR struct nxbe_window_s *wnd, &info.cops, &wnd->be->plane[i]); #ifdef CONFIG_NX_SWCURSOR - /* Save the modified cursor pixe at the point. - * - * REVISIT: This and the following logic belongs in the function - * nxbe_clipfill(). It is here only because the struct nxbe_state_s - * (wnd->be) is not available at that point. - */ + /* Update the software cursor if it is visible */ - wnd->be->plane[i].cursor.backup(wnd->be, &rect, i); + if (wnd->be->cursor.visible) + { + /* Save the modified cursor pixe at the point. + * + * REVISIT: This and the following logic belongs in the function + * nxbe_clipfill(). It is here only because the struct + * nxbe_state_s (wnd->be) is not available at that point. + */ - /* Restore the software cursor if if that point is a visible cursor - * bit that was overwritten by the above operation. - */ + wnd->be->plane[i].cursor.backup(wnd->be, &rect, i); - wnd->be->plane[i].cursor.draw(wnd->be, &rect, i); + /* Restore the software cursor if if that point is a visible + * cursor bit that was overwritten by the above operation. + */ + + wnd->be->plane[i].cursor.draw(wnd->be, &rect, i); + } #endif } }