From 4bcd13eabd73346b6df63ca3b88c80cc74e2385a Mon Sep 17 00:00:00 2001 From: Gregory Nutt <gnutt@nuttx.org> Date: Tue, 14 Jul 2015 07:57:54 -0600 Subject: [PATCH] Add RGB blending logic needed to support anti-aliasing --- configs | 2 +- include/fixedmath.h | 2 ++ include/nuttx/nx/nxglib.h | 33 +++++++++++++++++++++++++++++++++ libnx/nxglib/Make.defs | 8 ++++---- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/configs b/configs index 6ef8051be6..9b001f72c9 160000 --- a/configs +++ b/configs @@ -1 +1 @@ -Subproject commit 6ef8051be6870845a0cbbe769fcf9a3205285123 +Subproject commit 9b001f72c97902ceb979fe44c5564c17d3f19be3 diff --git a/include/fixedmath.h b/include/fixedmath.h index 7ff6ef262b..38a991136b 100644 --- a/include/fixedmath.h +++ b/include/fixedmath.h @@ -121,6 +121,7 @@ /* Conversions */ #define b8toi(a) ((a) >> 8) /* Conversion to integer */ +#define ub8toi(a) ((a) >> 8) /* Conversion to unsigned integer */ #define itob8(i) (((b8_t)(i)) << 8) /* Conversion from integer */ #define uitoub8(i) (((ub8_t)(i)) << 8) /* Conversion from unsigned integer */ #define b8tof(b) (((float)b)/256.0) /* Conversion to float */ @@ -152,6 +153,7 @@ /* Conversions */ #define b16toi(a) ((a) >> 16) /* Conversion to integer */ +#define ub16toi(a) ((a) >> 16) /* Conversion to unsgined integer */ #define itob16(i) (((b16_t)(i)) << 16) /* Conversion from integer */ #define uitoub16(i) (((ub16_t)(i)) << 16) /* Conversion from unsigned integer */ #define b16tof(b) (((float)b)/65536.0) /* Conversion to float */ diff --git a/include/nuttx/nx/nxglib.h b/include/nuttx/nx/nxglib.h index 6e2d1a53d5..d29d261f8f 100644 --- a/include/nuttx/nx/nxglib.h +++ b/include/nuttx/nx/nxglib.h @@ -745,6 +745,39 @@ void nxgl_circletraps(FAR const struct nxgl_point_s *center, nxgl_coord_t radius, FAR struct nxgl_trapezoid_s *circle); +/**************************************************************************** + * Name: nxglib_rgb24_blend and nxglib_rgb565_blend + * + * Description: + * Blend a foreground color onto a background color. This is *not* alpha + * blending: color2 is assumed to be opaque and "under" a semi- + * transparent color1. + * + * The frac1 value could be though as related to the 1/alpha value for + * color1. However, the background, color2, is always treated as though + * alpha == 1. + * + * This algorithm is used to handle endpoints as part of the + * implementation of anti-aliasing without transparency. + * + * Input Parameters: + * color1 - The semi-transparent, forground color + * color2 - The opaque, background color + * frac1 - The fractional amount of color1 to blend into color2 + * + * Returned Value: + * The blended color, encoded just was the input color1 and color2 + * + ****************************************************************************/ + +#if !defined(CONFIG_NX_DISABLE_24BPP) || !defined(CONFIG_NX_DISABLE_32BPP) +uint32_t nxglib_rgb24_blend(uint32_t color1, uint32_t color2, ub16_t frac1); +#endif + +#ifndef CONFIG_NX_DISABLE_16BPP +uint16_t nxglib_rgb565_blend(uint16_t color1, uint16_t color2, ub16_t frac1); +#endif + #undef EXTERN #if defined(__cplusplus) } diff --git a/libnx/nxglib/Make.defs b/libnx/nxglib/Make.defs index 8593c91aca..2f972ab2f8 100644 --- a/libnx/nxglib/Make.defs +++ b/libnx/nxglib/Make.defs @@ -41,10 +41,10 @@ CSRCS += nxglib_circlepts.c nxglib_circletraps.c nxglib_intersecting.c CSRCS += nxglib_nonintersecting.c nxglib_nullrect.c nxglib_rectadd.c CSRCS += nxglib_rectcopy.c nxglib_rectinside.c nxglib_rectintersect.c CSRCS += nxglib_rectoffset.c nxglib_rectoverlap.c nxglib_rectsize.c -CSRCS += nxglib_rectunion.c nxglib_rgb2yuv.c nxglib_runcopy.c -CSRCS += nxglib_runoffset.c nxglib_splitline.c nxglib_trapcopy.c -CSRCS += nxglib_trapoffset.c nxglib_vectoradd.c nxglib_vectsubtract.c -CSRCS += nxglib_yuv2rgb.c +CSRCS += nxglib_rectunion.c nxglib_rgb2yuv.c nxglib_rgbblend.c +CSRCS += nxglib_runcopy.c nxglib_runoffset.c nxglib_splitline.c +CSRCS += nxglib_trapcopy.c nxglib_trapoffset.c nxglib_vectoradd.c +CSRCS += nxglib_vectsubtract.c nxglib_yuv2rgb.c ifneq ($(CONFIG_NX_NPLANES),1) CSRCS += nxglib_colorcmp.c nxglib_colorcopy.c