mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
graphics/nxbe: Add some missing checks: Don't permit the software cursor to be enabled until it has been assigned an image; don't perform any cursor operations while the cursor is disabled.
This commit is contained in:
@@ -329,16 +329,21 @@ void nxbe_bitmap(FAR struct nxbe_window_s *wnd,
|
|||||||
nxbe_bitmap_dev(wnd, dest, src, origin, stride);
|
nxbe_bitmap_dev(wnd, dest, src, origin, stride);
|
||||||
|
|
||||||
#ifdef CONFIG_NX_SWCURSOR
|
#ifdef CONFIG_NX_SWCURSOR
|
||||||
/* Save the modified cursor background region
|
/* Update the software cursor if it is visible */
|
||||||
* REVISIT: Only a single color plane is supported
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
wnd->be->plane[0].cursor.backup(wnd->be, dest, 0);
|
||||||
* overwritten by the bitmap copy.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-14
@@ -69,23 +69,36 @@
|
|||||||
|
|
||||||
void nxbe_cursor_enable(FAR struct nxbe_state_s *be, bool enable)
|
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)
|
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 */
|
/* Mark the cursor visible */
|
||||||
|
|
||||||
be->cursor.visible = true;
|
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
|
/* For a hardware cursor, this would require some interaction with the
|
||||||
* grahics device.
|
* grahics device.
|
||||||
*/
|
*/
|
||||||
@@ -105,6 +118,7 @@ void nxbe_cursor_enable(FAR struct nxbe_state_s *be, bool enable)
|
|||||||
#ifdef CONFIG_NX_SWCURSOR
|
#ifdef CONFIG_NX_SWCURSOR
|
||||||
/* Erase the old cursor image by writing the saved background image. */
|
/* 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);
|
be->plane[0].cursor.erase(be, &be->cursor.bounds, 0);
|
||||||
#else
|
#else
|
||||||
/* For a hardware cursor, this would require some interaction with the
|
/* 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. */
|
/* 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);
|
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);
|
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
|
/* If the cursor is visible, then put write the new cursor image into
|
||||||
* device graphics memory now.
|
* device graphics memory now.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (be->cursor.visible)
|
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. */
|
/* Write the new cursor image to the device graphics memory. */
|
||||||
|
|
||||||
be->plane[0].cursor.draw(be, &be->cursor.bounds, 0);
|
be->plane[0].cursor.draw(be, &be->cursor.bounds, 0);
|
||||||
|
|||||||
+17
-12
@@ -129,21 +129,26 @@ static inline void nxbe_fill_dev(FAR struct nxbe_window_s *wnd,
|
|||||||
&info.cops, &wnd->be->plane[i]);
|
&info.cops, &wnd->be->plane[i]);
|
||||||
|
|
||||||
#ifdef CONFIG_NX_SWCURSOR
|
#ifdef CONFIG_NX_SWCURSOR
|
||||||
/* Save the modified cursor background region.
|
/* Update the software cursor if it is visible */
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
wnd->be->plane[i].cursor.backup(wnd->be, rect, i);
|
||||||
* overwritten by the fill.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,21 +159,26 @@ static inline void nxbe_filltrapezoid_dev(FAR struct nxbe_window_s *wnd,
|
|||||||
&info.cops, &wnd->be->plane[i]);
|
&info.cops, &wnd->be->plane[i]);
|
||||||
|
|
||||||
#ifdef CONFIG_NX_SWCURSOR
|
#ifdef CONFIG_NX_SWCURSOR
|
||||||
/* Save the modified cursor background region.
|
/* Update the software cursor if it is visible */
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
wnd->be->plane[i].cursor.backup(wnd->be, bounds, i);
|
||||||
* overwritten by the fill.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,11 +95,16 @@ void nxbe_flush(FAR struct nxbe_window_s *wnd,
|
|||||||
nxbe_bitmap_dev(wnd, dest, src, origin, stride);
|
nxbe_bitmap_dev(wnd, dest, src, origin, stride);
|
||||||
|
|
||||||
#ifdef CONFIG_NX_SWCURSOR
|
#ifdef CONFIG_NX_SWCURSOR
|
||||||
/* Restore the software cursor if any part of the cursor was overwritten
|
/* Is the software cursor visible? */
|
||||||
* by the above copy.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+26
-16
@@ -280,9 +280,14 @@ static inline void nxbe_move_dev(FAR struct nxbe_window_s *wnd,
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NX_SWCURSOR
|
#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
|
#endif
|
||||||
|
|
||||||
nxbe_clipper(wnd->above, &info.srcrect, info.order,
|
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
|
#ifdef CONFIG_NX_SWCURSOR
|
||||||
/* Save the modified cursor background region at the destination
|
/* Update the software cursor if it is visible */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
wnd->be->plane[i].cursor.backup(wnd->be, &dest, i);
|
||||||
* overwritten by the fill.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,20 +153,25 @@ void nxbe_setpixel(FAR struct nxbe_window_s *wnd,
|
|||||||
&info.cops, &wnd->be->plane[i]);
|
&info.cops, &wnd->be->plane[i]);
|
||||||
|
|
||||||
#ifdef CONFIG_NX_SWCURSOR
|
#ifdef CONFIG_NX_SWCURSOR
|
||||||
/* Save the modified cursor pixe at the point.
|
/* Update the software cursor if it is visible */
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
wnd->be->plane[i].cursor.backup(wnd->be, &rect, i);
|
||||||
* bit that was overwritten by the above operation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user