drivers/video: Refine the update region notification mechanism

1.Expose the notification through fb_vtable_s::updatearea
2.Incorporate old nx_notify_rectangle into the new updatearea callback
3.Migrate the calle of nx_notify_rectangle to fb_vtable_s::updatearea

Change-Id: Ia3d1f73e8757b2d381586d76ec6adc16c810018d
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi
2020-06-04 10:35:50 +08:00
committed by Alin Jerpelea
parent 154852acb5
commit fd78f83e02
24 changed files with 425 additions and 316 deletions
+6 -3
View File
@@ -143,7 +143,7 @@ config NX_WRITEONLY
config NX_UPDATE
bool "Display update hooks"
default n
default FB_UPDATE && !NX_LCDDRIVER
---help---
Enable a callout to inform some external module that the display has
been updated. This would be useful in a couple for cases.
@@ -158,8 +158,11 @@ config NX_UPDATE
When this feature is enabled, some external logic must provide this
interface:
void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect);
fb_vtable_s
{
int (*updatearea)(FAR struct fb_vtable_s *vtable,
FAR const struct fb_area_s *area);
};
That is the function that will handle the notification. It
receives the rectangular region that was updated in the provided
+4
View File
@@ -50,6 +50,10 @@ else ifeq ($(CONFIG_NX_HWCURSOR),y)
CSRCS += nxbe_cursor.c
endif
ifeq ($(CONFIG_NX_UPDATE),y)
CSRCS += nxbe_notify_rectangle.c
endif
DEPPATH += --dep-path nxbe
CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)/graphics/nxbe}
VPATH += :nxbe
+40 -12
View File
@@ -189,6 +189,7 @@ struct nxbe_plane_s
/* Framebuffer plane info describing destination video plane */
NX_DRIVERTYPE *driver;
NX_PLANEINFOTYPE pinfo;
};
@@ -216,14 +217,14 @@ struct nxbe_clipops_s
#if defined(CONFIG_NX_SWCURSOR)
struct nxbe_cursor_s
{
bool visible; /* True: the cursor is visible */
struct nxgl_rect_s bounds; /* Cursor image bounding box */
bool visible; /* True: the cursor is visible */
struct nxgl_rect_s bounds; /* Cursor image bounding box */
nxgl_mxpixel_t color1[CONFIG_NX_NPLANES]; /* Color1 is main color of the cursor */
nxgl_mxpixel_t color2[CONFIG_NX_NPLANES]; /* Color2 is color of any border */
nxgl_mxpixel_t color3[CONFIG_NX_NPLANES]; /* Color3 is the blended color */
size_t allocsize; /* Size of the background allocation */
FAR const uint8_t *image; /* Cursor image at 2-bits/pixel */
FAR nxgl_mxpixel_t *bkgd; /* Cursor background in device pixels */
size_t allocsize; /* Size of the background allocation */
FAR const uint8_t *image; /* Cursor image at 2-bits/pixel */
FAR nxgl_mxpixel_t *bkgd; /* Cursor background in device pixels */
};
#elif defined(CONFIG_NX_HWCURSOR)
struct nxbe_cursor_s
@@ -252,9 +253,9 @@ struct nxbe_state_s
FAR struct nxbe_window_s *topwnd; /* The window at the top of the display */
struct nxbe_window_s bkgd; /* The background window is always at the bottom */
/* At present, only a solid colored background is supported for refills. The
* following provides the background color. It would be nice to support
* background bitmap images as well.
/* At present, only a solid colored background is supported for refills.
* The following provides the background color. It would be nice to
* support background bitmap images as well.
*/
nxgl_mxpixel_t bgcolor[CONFIG_NX_NPLANES];
@@ -279,13 +280,14 @@ struct nxbe_state_s
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Functions
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
@@ -300,6 +302,32 @@ extern "C" {
int nxbe_colormap(FAR NX_DRIVERTYPE *dev);
#endif
/****************************************************************************
* Name: nxbe_notify_rectangle
*
* Description:
* When CONFIG_NX_UPDATE=y, then the graphics system will callout to
* inform some external module that the display has been updated. This
* would be useful in a couple for cases.
*
* - When a serial LCD is used, but a framebuffer is used to access the
* LCD. In this case, the update callout can be used to refresh the
* affected region of the display.
*
* - When VNC is enabled. This is case, this callout is necessary to
* update the remote frame buffer to match the local framebuffer.
*
* When this feature is enabled, some external logic must provide this
* interface. This is the function that will handle the notification. It
* receives the rectangular region that was updated on the provided plane.
*
****************************************************************************/
#ifdef CONFIG_NX_UPDATE
void nxbe_notify_rectangle(FAR NX_DRIVERTYPE *dev,
FAR const struct nxgl_rect_s *rect);
#endif
/****************************************************************************
* Name: nx_configure
*
@@ -523,8 +551,8 @@ void nxbe_setvisibility(FAR struct nxbe_window_s *wnd, bool hide);
* Name: nxbe_setpixel
*
* Description:
* Set a single pixel in the window to the specified color. This is simply
* a degenerate case of nxbe_fill(), but may be optimized in some architectures.
* Set a single pixel in the window to the specified color. This is simply a
* degenerate case of nxbe_fill, but may be optimized in some architectures.
*
* Input Parameters:
* wnd - The window structure reference
+5 -5
View File
@@ -67,8 +67,8 @@ struct nx_bitmap_s
* Name: bitmap_clipcopy
*
* Description:
* Called from nxbe_clipper() to performed the fill operation on visible portions
* of the rectangle.
* Called from nxbe_clipper() to performed the fill operation on visible
* portions of the rectangle.
*
****************************************************************************/
@@ -86,7 +86,7 @@ static void bitmap_clipcopy(FAR struct nxbe_clipops_s *cops,
#ifdef CONFIG_NX_UPDATE
/* Notify external logic that the display has been updated */
nx_notify_rectangle(&plane->pinfo, rect);
nxbe_notify_rectangle(plane->driver, rect);
#endif
}
@@ -340,8 +340,8 @@ void nxbe_bitmap(FAR struct nxbe_window_s *wnd,
nxbe_bitmap_dev(wnd, dest, src, origin, stride);
#ifdef CONFIG_NX_SWCURSOR
/* Update cursor backup memory and redraw the cursor in the modified window
* region.
/* Update cursor backup memory and redraw the cursor in the modified
* window region.
*/
nxbe_cursor_backupdraw_all(wnd, dest);
+3 -5
View File
@@ -107,11 +107,6 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
CONFIG_NX_NPLANES, be->vinfo.nplanes);
return -E2BIG;
}
else if (be->vinfo.nplanes < CONFIG_NX_NPLANES)
{
gwarn("WARNING: NX configured for %d planes, controller only needs %d\n",
CONFIG_NX_NPLANES, be->vinfo.nplanes);
}
#endif
/* Then get information about each color plane */
@@ -125,6 +120,8 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
return ret;
}
be->plane[i].driver = dev;
/* Select rasterizers to match the BPP reported for this plane.
* NOTE that there are configuration options to eliminate support
* for unused BPP values. If the unused BPP values are not suppressed
@@ -309,5 +306,6 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
return -ENOSYS;
}
}
return OK;
}
+3 -3
View File
@@ -83,7 +83,7 @@ static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops,
#ifdef CONFIG_NX_UPDATE
/* Notify external logic that the display has been updated */
nx_notify_rectangle(&plane->pinfo, rect);
nxbe_notify_rectangle(plane->driver, rect);
#endif
}
@@ -168,8 +168,8 @@ static inline void nxbe_fill_pwfb(FAR struct nxbe_window_s *wnd,
DEBUGASSERT(wnd->be->plane[0].pwfb.fillrectangle != NULL);
/* The rectangle that we receive here is in absolute device coordinates. We
* need to restore this to windows relative coordinates.
/* The rectangle that we receive here is in absolute device coordinates.
* We need to restore this to windows relative coordinates.
*/
nxgl_rectoffset(&relrect, rect, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y);
+16 -14
View File
@@ -78,8 +78,8 @@ struct nxbe_filltrap_s
* Name: nxbe_clipfilltrapezoid
*
* Description:
* Called from nxbe_clipper() to performed the fill operation on visible portions
* of the rectangle.
* Called from nxbe_clipper() to performed the fill operation on visible
* portions of the rectangle.
*
****************************************************************************/
@@ -107,7 +107,7 @@ static void nxbe_clipfilltrapezoid(FAR struct nxbe_clipops_s *cops,
MIN(fillinfo->trap.bot.x2, rect->pt2.x));
update.pt2.y = MIN(fillinfo->trap.bot.y, rect->pt2.y);
nx_notify_rectangle(&plane->pinfo, &update);
nxbe_notify_rectangle(plane->driver, &update);
#endif
}
@@ -129,10 +129,11 @@ static void nxbe_clipfilltrapezoid(FAR struct nxbe_clipops_s *cops,
*
****************************************************************************/
static inline void nxbe_filltrapezoid_dev(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *bounds,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
static inline void
nxbe_filltrapezoid_dev(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *bounds,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
struct nxbe_filltrap_s info;
int i;
@@ -190,10 +191,11 @@ static inline void nxbe_filltrapezoid_dev(FAR struct nxbe_window_s *wnd,
****************************************************************************/
#ifdef CONFIG_NX_RAMBACKED
static inline void nxbe_filltrapezoid_pwfb(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *bounds,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
static inline void
nxbe_filltrapezoid_pwfb(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *bounds,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
FAR const void *src[CONFIG_NX_NPLANES];
struct nxgl_trapezoid_s reltrap;
@@ -214,9 +216,9 @@ static inline void nxbe_filltrapezoid_pwfb(FAR struct nxbe_window_s *wnd,
* REVISIT: Assumes a single color plane.
*/
DEBUGASSERT(wnd->be->plane[0].pwfb.filltrapezoid != NULL);
wnd->be->plane[0].pwfb.filltrapezoid(wnd, &reltrap, &relbounds,
color[0]);
DEBUGASSERT(wnd->be->plane[0].pwfb.filltrapezoid != NULL);
wnd->be->plane[0].pwfb.filltrapezoid(wnd, &reltrap, &relbounds,
color[0]);
/* Get the source of address of the trapezoid bounding box in the
* framebuffer.
+14 -10
View File
@@ -69,8 +69,8 @@ struct nxbe_move_s
* Name: nxbe_clipmovesrc
*
* Description:
* Called from nxbe_clipper() to performed the move operation on visible regions
* of the rectangle.
* Called from nxbe_clipper() to performed the move operation on visible
* regions of the rectangle.
*
****************************************************************************/
@@ -92,7 +92,9 @@ static void nxbe_clipmovesrc(FAR struct nxbe_clipops_s *cops,
offset.x = rect->pt1.x + info->offset.x;
offset.y = rect->pt1.y + info->offset.y;
/* Move the source rectangle to the destination position in the device */
/* Move the source rectangle to the destination position in the
* device
*/
plane->dev.moverectangle(&plane->pinfo, rect, &offset);
@@ -109,7 +111,7 @@ static void nxbe_clipmovesrc(FAR struct nxbe_clipops_s *cops,
* rectangle has changed.
*/
nx_notify_rectangle(&plane->pinfo, &update);
nxbe_notify_rectangle(plane->driver, &update);
#endif
}
}
@@ -118,8 +120,8 @@ static void nxbe_clipmovesrc(FAR struct nxbe_clipops_s *cops,
* Name: nxbe_clipmoveobscured
*
* Description:
* Called from nxbe_clipper() to performed the move operation on obsrured regions
* of the rectangle.
* Called from nxbe_clipper() to performed the move operation on obsrured
* regions of the rectangle.
*
****************************************************************************/
@@ -189,7 +191,7 @@ static void nxbe_clipmovedest(FAR struct nxbe_clipops_s *cops,
nxbe_clipper(dstdata->wnd->above, &src, dstdata->order,
&srcinfo.cops, plane);
}
}
}
/****************************************************************************
@@ -336,8 +338,8 @@ static inline void nxbe_move_pwfb(FAR struct nxbe_window_s *wnd,
struct nxgl_rect_s destrect;
unsigned int bpp;
/* The rectangle that we receive here is in absolute device coordinates. We
* need to restore this to windows relative coordinates.
/* The rectangle that we receive here is in absolute device coordinates.
* We need to restore this to windows relative coordinates.
*/
nxgl_rectoffset(&srcrect, rect, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y);
@@ -457,7 +459,9 @@ void nxbe_move(FAR struct nxbe_window_s *wnd,
if (!nxgl_nullrect(&srcrect))
{
#ifdef CONFIG_NX_RAMBACKED
/* Update the pre-window framebuffer first, then the device memory. */
/* Update the pre-window framebuffer first, then the device
* memory.
*/
if (NXBE_ISRAMBACKED(wnd))
{
+65
View File
@@ -0,0 +1,65 @@
/****************************************************************************
* graphics/nxbe/nxbe_notify_rectangle.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/nx/nxglib.h>
#include "nxbe.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_notify_rectangle
*
* Description:
* When CONFIG_NX_UPDATE=y, then the graphics system will callout to
* inform some external module that the display has been updated. This
* would be useful in a couple for cases.
*
* - When a serial LCD is used, but a framebuffer is used to access the
* LCD. In this case, the update callout can be used to refresh the
* affected region of the display.
*
* - When VNC is enabled. This is case, this callout is necessary to
* update the remote frame buffer to match the local framebuffer.
*
* When this feature is enabled, some external logic must provide this
* interface. This is the function that will handle the notification. It
* receives the rectangular region that was updated on the provided plane.
*
****************************************************************************/
#ifdef CONFIG_NX_UPDATE
void nxbe_notify_rectangle(FAR NX_DRIVERTYPE *dev,
FAR const struct nxgl_rect_s *rect)
{
struct fb_area_s area;
nxgl_rect2area(&area, rect);
dev->updatearea(dev, &area);
}
#endif
+5 -4
View File
@@ -64,8 +64,8 @@ struct nxbe_setpixel_s
* Name: nxbe_clipfill
*
* Description:
* Called from nxbe_clipper() to performed the fill operation on visible portions
* of the rectangle.
* Called from nxbe_clipper() to performed the fill operation on visible
* portions of the rectangle.
*
****************************************************************************/
@@ -82,7 +82,7 @@ static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops,
#ifdef CONFIG_NX_UPDATE
/* Notify external logic that the display has been updated */
nx_notify_rectangle(&plane->pinfo, rect);
nxbe_notify_rectangle(plane->driver, rect);
#endif
}
@@ -189,7 +189,8 @@ void nxbe_setpixel(FAR struct nxbe_window_s *wnd,
#ifdef CONFIG_NX_RAMBACKED
/* If this window supports a pre-window frame buffer then shadow the full,
* unclipped bitmap in that framebuffer.
* REVISIT: The logic to set a pixel in the per-window frame buffer is missing
* REVISIT: The logic to set a pixel in the per-window frame buffer is
* missing
*/
DEBUGASSERT(!NXBE_ISRAMBACKED(wnd));
+1 -1
View File
@@ -7,7 +7,7 @@ menuconfig VNCSERVER
bool "VNC server"
default n
depends on NET_TCP && !NX_LCDDRIVER
select NX_UPDATE
select FB_UPDATE
---help---
Enable support for a VNC Remote Frame Buffer (RFB) server.
+44 -52
View File
@@ -109,6 +109,11 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
FAR struct fb_setcursor_s *settings);
#endif
/* Update the host window when there is a change to the framebuffer */
static int up_updateearea(FAR struct fb_vtable_s *vtable,
FAR const struct fb_area_s *area);
/****************************************************************************
* Private Data
****************************************************************************/
@@ -403,6 +408,44 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
}
#endif
/****************************************************************************
* Name: up_updateearea
****************************************************************************/
static int up_updateearea(FAR struct fb_vtable_s *vtable,
FAR const struct fb_area_s *area)
{
FAR struct vnc_fbinfo_s *fbinfo = (FAR struct vnc_fbinfo_s *)vtable;
FAR struct vnc_session_s *session;
struct nxgl_rect_s rect;
int ret = OK;
DEBUGASSERT(fbinfo != NULL && area != NULL);
/* Recover the session information from the display number in the planeinfo
* structure.
*/
DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
/* Verify that the session is still valid */
if (session != NULL && session->state == VNCSERVER_RUNNING)
{
/* Queue the rectangular update */
nxgl_area2rect(&rect, area);
ret = vnc_update_rectangle(session, &rect, true);
if (ret < 0)
{
gerr("ERROR: vnc_update_rectangle failed: %d\n", ret);
}
}
return ret;
}
/****************************************************************************
* Name: vnc_start_server
*
@@ -774,6 +817,7 @@ FAR struct fb_vtable_s *up_fbgetvplane(int display, int vplane)
fbinfo->vtable.getcursor = up_getcursor,
fbinfo->vtable.setcursor = up_setcursor,
#endif
fbinfo->vtable.updatearea = up_updateearea,
fbinfo->display = display;
fbinfo->initialized = true;
}
@@ -821,55 +865,3 @@ void up_fbuninitialize(int display)
}
#endif
}
/****************************************************************************
* Name: nx_notify_rectangle
*
* Description:
* When CONFIG_NX_UPDATE=y, then the graphics system will callout to
* inform some external module that the display has been updated. This
* would be useful in a couple for cases.
*
* - When a serial LCD is used, but a framebuffer is used to access the
* LCD. In this case, the update callout can be used to refresh the
* affected region of the display.
*
* - When VNC is enabled. This is case, this callout is necessary to
* update the remote frame buffer to match the local framebuffer.
*
* When this feature is enabled, some external logic must provide this
* interface. This is the function that will handle the notification. It
* receives the rectangular region that was updated on the provided plane.
*
****************************************************************************/
#ifdef CONFIG_NX_UPDATE
void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect)
{
FAR struct vnc_session_s *session;
int ret;
DEBUGASSERT(pinfo != NULL && rect != NULL);
/* Recover the session information from the display number in the planeinfo
* structure.
*/
DEBUGASSERT(pinfo->display >= 0 && pinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[pinfo->display];
/* Verify that the session is still valid */
if (session != NULL && session->state == VNCSERVER_RUNNING)
{
/* Queue the rectangular update */
ret = vnc_update_rectangle(session, rect, true);
if (ret < 0)
{
gerr("ERROR: vnc_update_rectangle failed: %d\n", ret);
}
}
}
#endif
-4
View File
@@ -60,10 +60,6 @@
/* Configuration */
#ifndef CONFIG_NX_UPDATE
# error CONFIG_NX_UPDATE must be set to use VNC
#endif
#if !defined(CONFIG_VNCSERVER_PROTO3p3) && !defined(CONFIG_VNCSERVER_PROTO3p8)
# error No VNC protocol selected
#endif