freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 04bcd28: [graph] Clearly separate two blenders.


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master 04bcd28: [graph] Clearly separate two blenders.
Date: Tue, 18 Jun 2019 22:50:57 -0400 (EDT)

branch: master
commit 04bcd28d17c7857c07f1b5d07fbabf55c04f1753
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [graph] Clearly separate two blenders.
    
    * graph/gblblit.[hc] (grBlitGlyphToSurface): Declare and define it.
    * graph/grblit.c (grBlitGlyphToBitmap): Call `grBlitGlyphToSurface'.
    * graph/gblender.c: Minor.
---
 ChangeLog        |  8 +++++++
 graph/gblblit.c  | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 graph/gblblit.h  | 14 +++++------
 graph/gblender.c |  2 +-
 graph/grblit.c   | 38 +++++-------------------------
 5 files changed, 89 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 085347a..562062b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-06-18  Alexei Podtelezhnikov  <address@hidden>
+
+       [graph] Clearly separate two blenders.
+
+       * graph/gblblit.[hc] (grBlitGlyphToSurface): Declare and define it.
+       * graph/grblit.c (grBlitGlyphToBitmap): Call `grBlitGlyphToSurface'.
+       * graph/gblender.c: Minor.
+
 2019-06-17  Alexei Podtelezhnikov  <address@hidden>
 
        * src/ftmulti.c (bit): Surface bitmap must belong to surface.
diff --git a/graph/gblblit.c b/graph/gblblit.c
index 5476f16..03e265e 100644
--- a/graph/gblblit.c
+++ b/graph/gblblit.c
@@ -1,3 +1,15 @@
+/****************************************************************************/
+/*                                                                          */
+/*  The FreeType project -- a free and portable quality TrueType renderer.  */
+/*                                                                          */
+/*  Copyright (C) 1996-2019 by                                              */
+/*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
+/*                                                                          */
+/*  grblit.c: Support for alpha blending with gamma correction and caching. */
+/*                                                                          */
+/****************************************************************************/
+
+
 #include "grobjs.h"
 #include "gblblit.h"
 
@@ -211,17 +223,19 @@ _gblender_blit_dummy( GBlenderBlit   blit,
 }
 
 
-GBLENDER_APIDEF( int )
+static int
 gblender_blit_init( GBlenderBlit           blit,
                     int                    dst_x,
                     int                    dst_y,
-                    grBitmap*              target,
+                    grSurface*             surface,
                     grBitmap*              glyph )
 {
   int               src_x = 0;
   int               src_y = 0;
   int               delta;
 
+  grBitmap*  target = (grBitmap*)surface;
+
   GBlenderSourceFormat   src_format;
   const unsigned char*   src_buffer = glyph->buffer;
   int                    src_pitch  = glyph->pitch;
@@ -233,8 +247,6 @@ gblender_blit_init( GBlenderBlit           blit,
   int                    dst_width  = target->width;
   int                    dst_height = target->rows;
 
-  grSurface*  surface = (grSurface*)target;
-
 
   if ( glyph->grays != 256 )
     return -2;
@@ -332,3 +344,54 @@ gblender_blit_init( GBlenderBlit           blit,
   return 0;
 }
 
+
+GBLENDER_APIDEF( int )
+grBlitGlyphToSurface( grSurface*  surface,
+                      grBitmap*   glyph,
+                      grPos       x,
+                      grPos       y,
+                      grColor     color )
+{
+  GBlenderBlitRec       gblit[1];
+  GBlenderPixel         gcolor;
+
+
+  /* check arguments */
+  if ( !surface || !glyph )
+  {
+    grError = gr_err_bad_argument;
+    return -1;
+  }
+
+  if ( !glyph->rows || !glyph->width )
+  {
+    /* nothing to do */
+    return 0;
+  }
+
+  switch ( gblender_blit_init( gblit, x, y, surface, glyph ) )
+  {
+  case -1: /* nothing to do */
+    return 0;
+  case -2:
+    return -1;
+  }
+
+  gcolor = ((GBlenderPixel)color.chroma[0] << 16) |
+           ((GBlenderPixel)color.chroma[1] << 8 ) |
+           ((GBlenderPixel)color.chroma[2]      ) ;
+
+  gblender_blit_run( gblit, gcolor );
+  return 1;
+}
+
+
+GBLENDER_APIDEF( void )
+grSetTargetGamma( grBitmap*  target,
+                  double     gamma )
+{
+  grSurface*  surface = (grSurface*)target;
+
+
+  gblender_init( surface->gblender, gamma );
+}
diff --git a/graph/gblblit.h b/graph/gblblit.h
index 082e7fe..c3a99a3 100644
--- a/graph/gblblit.h
+++ b/graph/gblblit.h
@@ -61,15 +61,15 @@ typedef struct GBlenderBlitRec_
 } GBlenderBlitRec;
 
 
-GBLENDER_API( int )
-gblender_blit_init( GBlenderBlit           blit,
-                    int                    dst_x,
-                    int                    dst_y,
-                    grBitmap*              target,
-                    grBitmap*              glyph );
+#define  gblender_blit_run(b,color)  (b)->blit_func( (b), (color) )
 
 
-#define  gblender_blit_run(b,color)  (b)->blit_func( (b), (color) )
+GBLENDER_API( int )
+grBlitGlyphToSurface( grSurface*  surface,
+                      grBitmap*   glyph,
+                      grPos       x,
+                      grPos       y,
+                      grColor     color );
 
 
 #endif /* GBLBLIT_H_ */
diff --git a/graph/gblender.c b/graph/gblender.c
index 0bfce5c..1347030 100644
--- a/graph/gblender.c
+++ b/graph/gblender.c
@@ -207,7 +207,7 @@ gblender_init( GBlender   blender,
 }
 
 
-GBLENDER_API( void )
+GBLENDER_APIDEF( void )
 gblender_use_channels( GBlender  blender,
                        int       channels )
 {
diff --git a/graph/grblit.c b/graph/grblit.c
index 7c22551..35b26fa 100644
--- a/graph/grblit.c
+++ b/graph/grblit.c
@@ -10,6 +10,7 @@
 /****************************************************************************/
 
 #include "grblit.h"
+#include "gblblit.h"
 
 #define  GRAY8
 
@@ -1786,17 +1787,6 @@
 #endif
 
 
-#include "gblblit.h"
-
-  void  grSetTargetGamma( grBitmap*  target, double  gamma )
-  {
-    grSurface*  surface = (grSurface*)target;
-
-
-    gblender_init( surface->gblender, gamma );
-  }
-
-
   int
   grBlitGlyphToBitmap( grBitmap*  target,
                        grBitmap*  glyph,
@@ -1821,31 +1811,15 @@
       return 0;
     }
 
-   /* short cut to alpha blender for certain glyph types
-    */
+    /* short cut to alpha blender for certain glyph types */
+    switch ( grBlitGlyphToSurface( (grSurface*)target, glyph, x, y, color ) )
     {
-      GBlenderBlitRec       gblit[1];
-      GBlenderPixel         gcolor;
-
-
-      switch ( gblender_blit_init( gblit, x, y, target, glyph ) )
-      {
-      case -1: /* nothing to do */
-        return 0;
-      case -2:
-        goto LegacyBlit;
-      }
-
-      gcolor = ((GBlenderPixel)color.chroma[0] << 16) |
-               ((GBlenderPixel)color.chroma[1] << 8 ) |
-               ((GBlenderPixel)color.chroma[2]      ) ;
-
-      gblender_blit_run( gblit, gcolor );
+    case 1:
       return 1;
+    case 0:
+      return 0;
     }
 
-  LegacyBlit:      /* no gamma correction, no caching */
-
     /* set up blitter and compute clipping.  Return immediately if needed */
     blit.source = *glyph;
     blit.target = *target;



reply via email to

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