freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 223404b: [graph] Implement grayscale target sur


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master 223404b: [graph] Implement grayscale target surface.
Date: Thu, 24 May 2018 21:46:43 -0400 (EDT)

branch: master
commit 223404b6714b4c4f3a9a5fef25809d2632b23ce9
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [graph] Implement grayscale target surface.
    
    * graph/grblit.c (grBlitGlyphToBitmap): Enable gray target.
    * graph/gblblit.c (gblender_blit_init, GRGB_TO_GRAY, GRGB24_TO_GRAY):
    Implement gray target.
---
 ChangeLog       |  8 ++++++++
 graph/gblblit.c | 41 +++++++++++++++++++++++++++++++++++++++++
 graph/grblit.c  |  5 +++--
 3 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 31ae55d..2f963ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-05-24  Alexei Podtelezhnikov  <address@hidden>
+
+       [graph] Implement grayscale target surface.
+
+       * graph/grblit.c (grBlitGlyphToBitmap): Enable gray target.
+       * graph/gblblit.c (gblender_blit_init, GRGB_TO_GRAY, GRGB24_TO_GRAY):
+       Implement gray target.
+
 2018-05-23  Alexei Podtelezhnikov  <address@hidden>
 
        [ftview, ftstring, ftgrid] Change dimension options.
diff --git a/graph/gblblit.c b/graph/gblblit.c
index f5e1cd4..4ac0640 100644
--- a/graph/gblblit.c
+++ b/graph/gblblit.c
@@ -46,6 +46,14 @@
 
 /* */
 
+#define  GRGB_TO_GRAY8(r,g,b)  ( (unsigned char)( ( 2*(r) + 7*(g) + (b) ) / 10 
) )
+
+#define  GRGB24_TO_GRAY8(p)   ( (unsigned char)( ( 2*( ((p) >> 16) & 0xFF ) +  
       \
+                                                   7*( ((p) >>  8) & 0xFF ) +  
       \
+                                                     ( ((p))       & 0xFF ) ) 
/ 10 ) )
+
+/* */
+
 /* Rgb32 blitting routines
  */
 
@@ -153,6 +161,33 @@
 
 #include "gblany.h"
 
+/* Gray8 blitting routines
+ */
+#define  GDST_TYPE               gray8
+#define  GDST_INCR               1
+#define  GDST_READ(d,p)          (p) = GRGB_PACK((d)[0],(d)[0],(d)[0])
+
+#define  GDST_COPY_VAR           /* nothing */
+#define  GDST_COPY(d)            *(d) = GRGB_TO_GRAY8(r,g,b)
+
+#define  GDST_STOREB(d,cells,a)                 \
+    {                                           \
+      GBlenderCell*  _g = (cells) + (a)*3;      \
+                                                \
+      *(d) = GRGB_TO_GRAY8(_g[0],_g[1],_g[2]);  \
+    }
+
+#define  GDST_STOREP(d,cells,a)           \
+    {                                     \
+      GBlenderPixel  _pix = (cells)[(a)]; \
+                                          \
+      *(d) = GRGB24_TO_GRAY8(_pix);       \
+    }
+
+#define  GDST_STOREC(d,r,g,b)   *(d) = GRGB_TO_GRAY8(r,g,b)
+
+#include "gblany.h"
+
 /* */
 
 static void
@@ -194,6 +229,7 @@ gblender_blit_init( GBlenderBlit           blit,
       case GBLENDER_TARGET_RGB24:  blit_func = _gblender_blit_gray8_rgb24; 
break;
       case GBLENDER_TARGET_RGB565: blit_func = _gblender_blit_gray8_rgb565; 
break;
       case GBLENDER_TARGET_BGR565: blit_func = _gblender_blit_gray8_bgr565; 
break;
+      case GBLENDER_TARGET_GRAY8:  blit_func = _gblender_blit_gray8_gray8; 
break;
       default:
           ;
       }
@@ -206,6 +242,7 @@ gblender_blit_init( GBlenderBlit           blit,
       case GBLENDER_TARGET_RGB24:  blit_func = _gblender_blit_hrgb_rgb24; 
break;
       case GBLENDER_TARGET_RGB565: blit_func = _gblender_blit_hrgb_rgb565; 
break;
       case GBLENDER_TARGET_BGR565: blit_func = _gblender_blit_hrgb_bgr565; 
break;
+      case GBLENDER_TARGET_GRAY8:  blit_func = _gblender_blit_hrgb_gray8; 
break;
       default:
           ;
       }
@@ -218,6 +255,7 @@ gblender_blit_init( GBlenderBlit           blit,
       case GBLENDER_TARGET_RGB24:  blit_func = _gblender_blit_hbgr_rgb24; 
break;
       case GBLENDER_TARGET_RGB565: blit_func = _gblender_blit_hbgr_rgb565; 
break;
       case GBLENDER_TARGET_BGR565: blit_func = _gblender_blit_hbgr_bgr565; 
break;
+      case GBLENDER_TARGET_GRAY8:  blit_func = _gblender_blit_hbgr_gray8; 
break;
       default:
           ;
       }
@@ -230,6 +268,7 @@ gblender_blit_init( GBlenderBlit           blit,
       case GBLENDER_TARGET_RGB24:  blit_func = _gblender_blit_vrgb_rgb24; 
break;
       case GBLENDER_TARGET_RGB565: blit_func = _gblender_blit_vrgb_rgb565; 
break;
       case GBLENDER_TARGET_BGR565: blit_func = _gblender_blit_vrgb_bgr565; 
break;
+      case GBLENDER_TARGET_GRAY8:  blit_func = _gblender_blit_vrgb_gray8; 
break;
       default:
           ;
       }
@@ -242,6 +281,7 @@ gblender_blit_init( GBlenderBlit           blit,
       case GBLENDER_TARGET_RGB24:  blit_func = _gblender_blit_vbgr_rgb24; 
break;
       case GBLENDER_TARGET_RGB565: blit_func = _gblender_blit_vbgr_rgb565; 
break;
       case GBLENDER_TARGET_BGR565: blit_func = _gblender_blit_vbgr_bgr565; 
break;
+      case GBLENDER_TARGET_GRAY8:  blit_func = _gblender_blit_vbgr_gray8; 
break;
       default:
           ;
       }
@@ -254,6 +294,7 @@ gblender_blit_init( GBlenderBlit           blit,
       case GBLENDER_TARGET_RGB24:  blit_func = _gblender_blit_bgra_rgb24; 
break;
       case GBLENDER_TARGET_RGB565: blit_func = _gblender_blit_bgra_rgb565; 
break;
       case GBLENDER_TARGET_BGR565: blit_func = _gblender_blit_bgra_bgr565; 
break;
+      case GBLENDER_TARGET_GRAY8:  blit_func = _gblender_blit_bgra_gray8; 
break;
       default:
           ;
       }
diff --git a/graph/grblit.c b/graph/grblit.c
index 0b639b2..612936a 100644
--- a/graph/grblit.c
+++ b/graph/grblit.c
@@ -1880,9 +1880,10 @@
 
       switch ( target->mode )
       {
-      case gr_pixel_mode_rgb32: dst_format  = GBLENDER_TARGET_RGB32; break;
-      case gr_pixel_mode_rgb24: dst_format  = GBLENDER_TARGET_RGB24; break;
+      case gr_pixel_mode_rgb32:  dst_format = GBLENDER_TARGET_RGB32; break;
+      case gr_pixel_mode_rgb24:  dst_format = GBLENDER_TARGET_RGB24; break;
       case gr_pixel_mode_rgb565: dst_format = GBLENDER_TARGET_RGB565; break;
+      case gr_pixel_mode_gray:   dst_format = GBLENDER_TARGET_GRAY8; break;
       default:
           goto LegacyBlit;
       }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]