Skip to content

Commit

Permalink
NX: Don't change the background if the color has not really changed
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-nutt committed Jul 12, 2014
1 parent 3042fc5 commit ba22619
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 228 deletions.
7 changes: 7 additions & 0 deletions configs/sama5d4-ek/nsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,12 @@ CONFIG_DEV_ZERO=y
CONFIG_ARCH_HAVE_RNG=y
CONFIG_DEV_RANDOM=y
# CONFIG_LOOP is not set

#
# Buffering
#
# CONFIG_DRVR_WRITEBUFFER is not set
# CONFIG_DRVR_READAHEAD is not set
# CONFIG_RAMDISK is not set
# CONFIG_CAN is not set
# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set
Expand Down Expand Up @@ -822,6 +828,7 @@ CONFIG_SYSLOG=y
#
CONFIG_NX=y
CONFIG_NX_NPLANES=1
CONFIG_NX_BGCOLOR=0x7b5d
# CONFIG_NX_WRITEONLY is not set

#
Expand Down
5 changes: 5 additions & 0 deletions configs/sama5d4-ek/nxwm/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ CONFIG_DEV_ZERO=y
CONFIG_ARCH_HAVE_RNG=y
CONFIG_DEV_RANDOM=y
# CONFIG_LOOP is not set

#
# Buffering
#
# CONFIG_DRVR_WRITEBUFFER is not set
# CONFIG_DRVR_READAHEAD is not set
# CONFIG_RAMDISK is not set
Expand Down Expand Up @@ -828,6 +832,7 @@ CONFIG_SYSLOG=y
#
CONFIG_NX=y
CONFIG_NX_NPLANES=1
CONFIG_NX_BGCOLOR=0x7b5d
# CONFIG_NX_WRITEONLY is not set

#
Expand Down
16 changes: 13 additions & 3 deletions graphics/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ config NX_NPLANES
int "Number of Color Planes"
default 1
---help---
Some YUV color formats requires support for multiple planes, one for each
color component. Unless you have such special hardware, this value should be
undefined or set to 1.
Some YUV color formats requires support for multiple planes, one for
each color component. Unless you have such special hardware (and
are willing to debug a lot of untested logic), this value should be
set to 1.

config NX_BGCOLOR
hex "Initial background color"
default 0x0
---help---
NX will clear the background plane initially. This is the default
color that will be used when the background is cleared. Note: This
logic would have to be extended if you want to support multiple
color planes.

config NX_WRITEONLY
bool "Write-only Graphics Device"
Expand Down
17 changes: 17 additions & 0 deletions graphics/nxbe/nxbe_configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
* Pre-Processor Definitions
****************************************************************************/

#ifndef CONFIG_NX_BGCOLOR
# define CONFIG_NX_BGCOLOR 0
#endif

/****************************************************************************
* Private Types
****************************************************************************/
Expand All @@ -57,6 +61,15 @@
* Private Data
****************************************************************************/

static const nxgl_mxpixel_t g_bgcolor[CONFIG_NX_NPLANES] =
{
CONFIG_NX_BGCOLOR

#if CONFIG_NX_NPLANES > 1
# warning Missing logic for multiple color planes
#endif
};

/****************************************************************************
* Public Data
****************************************************************************/
Expand Down Expand Up @@ -92,6 +105,10 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
return ret;
}

/* Set the initial background color */

nxgl_colorcopy(be->bgcolor, g_bgcolor);

/* Check the number of color planes */

#ifdef CONFIG_DEBUG
Expand Down
15 changes: 12 additions & 3 deletions graphics/nxmu/nxmu_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,18 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)

case NX_SVRMSG_SETBGCOLOR: /* Set the color of the background */
{
FAR struct nxsvrmsg_setbgcolor_s *bgcolormsg = (FAR struct nxsvrmsg_setbgcolor_s *)buffer;
nxgl_colorcopy(fe.be.bgcolor, bgcolormsg->color);
nxbe_fill(&fe.be.bkgd, &fe.be.bkgd.bounds, bgcolormsg->color);
FAR struct nxsvrmsg_setbgcolor_s *bgcolormsg =
(FAR struct nxsvrmsg_setbgcolor_s *)buffer;

/* Has the background color changed? */

if (!nxgl_colorcmp(fe.be.bgcolor, bgcolormsg->color))
{
/* Yes.. fill the background */

nxgl_colorcopy(fe.be.bgcolor, bgcolormsg->color);
nxbe_fill(&fe.be.bkgd, &fe.be.bkgd.bounds, bgcolormsg->color);
}
}
break;

Expand Down
12 changes: 10 additions & 2 deletions graphics/nxsu/nx_setbgcolor.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ int nx_setbgcolor(NXHANDLE handle,
}
#endif

nxgl_colorcopy(fe->be.bgcolor, color);
nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, color);
/* Has the background color changed? */

if (!nxgl_colorcmp(fe.be.bgcolor, bgcolormsg->color))
{
/* Yes.. fill the background */

nxgl_colorcopy(fe->be.bgcolor, color);
nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, color);
}

return OK;
}
Loading

0 comments on commit ba22619

Please sign in to comment.