freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master acb1b02 3/3: [graph] Check blending cache earli


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master acb1b02 3/3: [graph] Check blending cache earlier.
Date: Thu, 14 Jan 2021 14:23:42 -0500 (EST)

branch: master
commit acb1b022797e8a4f90b37d38687c052e398f0e44
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [graph] Check blending cache earlier.
    
    This slightly reworks commit bfbd78261beff2d6 by moving the cache
    check into the initialization functions. this is especially important
    to keep the direct span rendering light.
    
    * graph/gblany.h (*): Move the cache check from here...
    * graph/gblblit.c (gblender_blit_init, grSetTargetPenBrush): ... to here.
    * graph/gblender.h (GBLANDER_VARS, GBLENDER_CHANNEL_VARS): Restore old 
macros.
---
 ChangeLog        | 14 ++++++++++++++
 graph/gblany.h   | 37 +++++++------------------------------
 graph/gblblit.c  | 37 +++++++++++++++++++++++--------------
 graph/gblender.h | 44 ++++++++++++++------------------------------
 4 files changed, 58 insertions(+), 74 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2089fe2..b8d74f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2021-01-14  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
+       [graph] Check blending cache earlier.
+
+       This slightly reworks commit bfbd78261beff2d6 by moving the cache
+       check into the initialization functions. this is especially important
+       to keep the direct span rendering light.
+
+       * graph/gblany.h (*): Move the cache check from here...
+        * graph/gblblit.c (gblender_blit_init, grSetTargetPenBrush): ... to
+       here.
+        * graph/gblender.h (GBLANDER_VARS, GBLENDER_CHANNEL_VARS): Restore old
+       macros.
+
+2021-01-14  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
        [graph] Reduce color conversions in the blender.
 
        * graph/gblblit.c (GDST_COPY_VAR): Removed.
diff --git a/graph/gblany.h b/graph/gblany.h
index 46a6be4..9486b94 100644
--- a/graph/gblany.h
+++ b/graph/gblany.h
@@ -52,15 +52,12 @@ GCONCAT( _gblender_spans_, GDST_TYPE )( int            y,
 {
   grColor         color   = surface->color;
   GBlender        blender = surface->gblender;
-  unsigned char*  dst_origin = surface->origin - y * surface->bitmap.pitch;
 
   GDST_PIX;
 
-  GBLENDER_VARS;
-
-  gblender_use_channels( blender, 0 );
+  GBLENDER_VARS(blender,pix);
 
-  GBLENDER_VARS_SET(blender,pix);
+  unsigned char*  dst_origin = surface->origin - y * surface->bitmap.pitch;
 
   for ( ; count--; spans++ )
   {
@@ -102,16 +99,12 @@ GCONCAT( _gblender_blit_gray8_, GDST_TYPE )( GBlenderBlit  
blit,
 
   GDST_PIX;
 
-  GBLENDER_VARS;
+  GBLENDER_VARS(blender,pix);
 
   int                   h        = blit->height;
   const unsigned char*  src_line = blit->src_line;
   unsigned char*        dst_line = blit->dst_line;
 
-  gblender_use_channels( blender, 0 );
-
-  GBLENDER_VARS_SET(blender,pix);
-
   do
   {
     const unsigned char*  src = src_line + (blit->src_x);
@@ -167,16 +160,12 @@ GCONCAT( _gblender_blit_hrgb_, GDST_TYPE )( GBlenderBlit  
blit,
 
   GDST_CHANNELS;
 
-  GBLENDER_CHANNEL_VARS;
+  GBLENDER_CHANNEL_VARS(blender,r,g,b);
 
   int                   h        = blit->height;
   const unsigned char*  src_line = blit->src_line;
   unsigned char*        dst_line = blit->dst_line;
 
-  gblender_use_channels( blender, 1 );
-
-  GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
-
   do
   {
     const unsigned char*  src = src_line + blit->src_x*3;
@@ -256,16 +245,12 @@ GCONCAT( _gblender_blit_hbgr_, GDST_TYPE )( GBlenderBlit  
blit,
 
   GDST_CHANNELS;
 
-  GBLENDER_CHANNEL_VARS;
+  GBLENDER_CHANNEL_VARS(blender,r,g,b);
 
   int                   h        = blit->height;
   const unsigned char*  src_line = blit->src_line;
   unsigned char*        dst_line = blit->dst_line;
 
-  gblender_use_channels( blender, 1 );
-
-  GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
-
   do
   {
     const unsigned char*  src = src_line + blit->src_x*3;
@@ -345,17 +330,13 @@ GCONCAT( _gblender_blit_vrgb_, GDST_TYPE )( GBlenderBlit  
blit,
 
   GDST_CHANNELS;
 
-  GBLENDER_CHANNEL_VARS;
+  GBLENDER_CHANNEL_VARS(blender,r,g,b);
 
   int                   h         = blit->height;
   const unsigned char*  src_line  = blit->src_line;
   int                   src_pitch = blit->src_pitch;
   unsigned char*        dst_line  = blit->dst_line;
 
-  gblender_use_channels( blender, 1 );
-
-  GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
-
   do
   {
     const unsigned char*  src = src_line + blit->src_x;
@@ -435,17 +416,13 @@ GCONCAT( _gblender_blit_vbgr_, GDST_TYPE )( GBlenderBlit  
blit,
 
   GDST_CHANNELS;
 
-  GBLENDER_CHANNEL_VARS;
+  GBLENDER_CHANNEL_VARS(blender,r,g,b);
 
   int                   h         = blit->height;
   const unsigned char*  src_line  = blit->src_line;
   int                   src_pitch = blit->src_pitch;
   unsigned char*        dst_line  = blit->dst_line;
 
-  gblender_use_channels( blender, 1 );
-
-  GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
-
   do
   {
     const unsigned char*  src = src_line + blit->src_x;
diff --git a/graph/gblblit.c b/graph/gblblit.c
index ecf19c2..4309a97 100644
--- a/graph/gblblit.c
+++ b/graph/gblblit.c
@@ -274,12 +274,27 @@ gblender_blit_init( GBlenderBlit           blit,
 
   switch ( glyph->mode )
   {
-  case gr_pixel_mode_gray:  src_format = GBLENDER_SOURCE_GRAY8; break;
-  case gr_pixel_mode_lcd:   src_format = GBLENDER_SOURCE_HRGB;  break;
-  case gr_pixel_mode_lcdv:  src_format = GBLENDER_SOURCE_VRGB;  break;
-  case gr_pixel_mode_lcd2:  src_format = GBLENDER_SOURCE_HBGR;  break;
-  case gr_pixel_mode_lcdv2: src_format = GBLENDER_SOURCE_VBGR;  break;
-  case gr_pixel_mode_bgra:  src_format = GBLENDER_SOURCE_BGRA;  break;
+  case gr_pixel_mode_gray:  src_format = GBLENDER_SOURCE_GRAY8;
+    gblender_use_channels( surface->gblender, 0 );
+    break;
+  case gr_pixel_mode_lcd:   src_format = GBLENDER_SOURCE_HRGB;
+    src_width /= 3;
+    gblender_use_channels( surface->gblender, 1 );
+    break;
+  case gr_pixel_mode_lcd2:  src_format = GBLENDER_SOURCE_HBGR;
+    src_width /= 3;
+    gblender_use_channels( surface->gblender, 1 );
+    break;
+  case gr_pixel_mode_lcdv:  src_format = GBLENDER_SOURCE_VRGB;
+    src_height /= 3;
+    gblender_use_channels( surface->gblender, 1 );
+    break;
+  case gr_pixel_mode_lcdv2: src_format = GBLENDER_SOURCE_VBGR;
+    src_height /= 3;
+    gblender_use_channels( surface->gblender, 1 );
+    break;
+  case gr_pixel_mode_bgra:  src_format = GBLENDER_SOURCE_BGRA;
+    break;
   default:
     return -2;
   }
@@ -306,14 +321,6 @@ gblender_blit_init( GBlenderBlit           blit,
     return -2;
   }
 
-  if ( glyph->mode == gr_pixel_mode_lcd  ||
-       glyph->mode == gr_pixel_mode_lcd2 )
-    src_width /= 3;
-
-  if ( glyph->mode == gr_pixel_mode_lcdv  ||
-       glyph->mode == gr_pixel_mode_lcdv2 )
-    src_height /= 3;
-
   if ( dst_x < 0 )
   {
     src_width += dst_x;
@@ -421,6 +428,8 @@ grSetTargetPenBrush( grBitmap*  target,
   }
 
   surface->color = color;
+
+  gblender_use_channels( surface->gblender, 0 );
 }
 
 
diff --git a/graph/gblender.h b/graph/gblender.h
index 71454a1..8d53589 100644
--- a/graph/gblender.h
+++ b/graph/gblender.h
@@ -149,15 +149,10 @@
 
 
   /* no final `;'! */
-#define  GBLENDER_VARS    \
-  GBlenderPixel  _gback;  \
-  GBlenderCell*  _gcells; \
-  GBlenderPixel  _gfore
-
-#define  GBLENDER_VARS_SET(_gb,_fore)                                          
                               \
-  _gback  = (_gb)->cache_back;                                                 
                               \
-  _gcells = ( (_fore) == (_gb)->cache_fore ? (_gb)->cache_cells : 
gblender_lookup( (_gb), _gback, _fore ) );  \
-  _gfore  = (_fore)
+#define  GBLENDER_VARS(_gb,_fore)                                              
                                                \
+  GBlenderPixel    _gback  = (_gb)->cache_back;                                
                                                \
+  GBlenderCell*    _gcells = ( (_fore) == (_gb)->cache_fore ? 
(_gb)->cache_cells : gblender_lookup( (_gb), _gback, _fore ) );  \
+  GBlenderPixel    _gfore  = (_fore)
 
 #define  GBLENDER_LOOKUP(gb,back)                        \
    GBLENDER_STAT_HIT(gb);                                \
@@ -175,27 +170,16 @@
 
 
   /* no final `;'! */
-#define  GBLENDER_CHANNEL_VARS \
-  unsigned int    _grback;     \
-  unsigned char*  _grcells;    \
-  unsigned int    _grfore;     \
-  unsigned int    _ggback;     \
-  unsigned char*  _ggcells;    \
-  unsigned int    _ggfore;     \
-  unsigned int    _gbback;     \
-  unsigned char*  _gbcells;    \
-  unsigned int    _gbfore
-
-#define  GBLENDER_CHANNEL_VARS_SET(_gb,_rfore,_gfore,_bfore)                   
                                             \
-  _grback  = (_gb)->cache_r_back;                                              
                                             \
-  _grcells = ( (_rfore) == (_gb)->cache_r_fore ? (_gb)->cache_r_cells : 
gblender_lookup_channel( (_gb), _grback, _rfore )); \
-  _grfore  = (_rfore);                                                         
                                             \
-  _ggback  = (_gb)->cache_g_back;                                              
                                             \
-  _ggcells = ( (_gfore) == (_gb)->cache_g_fore ? (_gb)->cache_g_cells : 
gblender_lookup_channel( (_gb), _ggback, _gfore )); \
-  _ggfore  = (_gfore);                                                         
                                             \
-  _gbback  = (_gb)->cache_b_back;                                              
                                             \
-  _gbcells = ( (_bfore) == (_gb)->cache_b_fore ? (_gb)->cache_b_cells : 
gblender_lookup_channel( (_gb), _gbback, _bfore )); \
-  _gbfore  = (_bfore);
+#define  GBLENDER_CHANNEL_VARS(_gb,_rfore,_gfore,_bfore)                       
                                                                 \
+  unsigned int     _grback  = (_gb)->cache_r_back;                             
                                                                 \
+  unsigned char*   _grcells = ( (_rfore) == (_gb)->cache_r_fore ? 
(_gb)->cache_r_cells : gblender_lookup_channel( (_gb), _grback, _rfore ));    \
+  unsigned int     _grfore  = (_rfore);                                        
                                                                 \
+  unsigned int     _ggback  = (_gb)->cache_g_back;                             
                                                                 \
+  unsigned char*   _ggcells = ( (_gfore) == (_gb)->cache_g_fore ? 
(_gb)->cache_g_cells : gblender_lookup_channel( (_gb), _ggback, _gfore ));    \
+  unsigned int     _ggfore  = (_rfore);                                        
                                                                 \
+  unsigned int     _gbback  = (_gb)->cache_b_back;                             
                                                                 \
+  unsigned char*   _gbcells = ( (_bfore) == (_gb)->cache_b_fore ? 
(_gb)->cache_b_cells : gblender_lookup_channel( (_gb), _gbback, _bfore ));    \
+  unsigned int     _gbfore  = (_bfore)
 
 #define  GBLENDER_CHANNEL_CLOSE(_gb)   \
   (_gb)->cache_r_back  = _grback;      \



reply via email to

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