freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master ce8385a: [graph] Relocate `gblender' to `grSurf


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master ce8385a: [graph] Relocate `gblender' to `grSurface'.
Date: Sun, 16 Jun 2019 00:07:55 -0400 (EDT)

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

    [graph] Relocate `gblender' to `grSurface'.
    
    This will be needed for direct rendering and simplifies gamma setting.
    
    * graph/grobjs.h (grSurface): Put `bitmap' on top, add `gblender'.
    * graph/graph.h: s/grSetGlyphGamma/grSetTargetGamma/.
    * graph/grblit.c (grSetTargetGamma): Move `gblender_init' here...
    (grBlitGlyphToBitmap): ...from here.
    * src/ftcommon.c (FTDemo_Display_New): Call `grSetTargetGamma'.
    * src/ft{diff,grid,string,view,multi}.c: Updated.
---
 ChangeLog      | 13 +++++++++++++
 graph/graph.h  |  4 ++--
 graph/grblit.c | 25 +++++++++----------------
 graph/grobjs.h |  6 +++++-
 src/ftcommon.c |  2 ++
 src/ftdiff.c   |  4 ++--
 src/ftgrid.c   |  2 +-
 src/ftmulti.c  |  2 ++
 src/ftstring.c |  2 +-
 src/ftview.c   |  2 +-
 10 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7a7a52d..21cdc9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2019-06-15  Alexei Podtelezhnikov  <address@hidden>
+
+       [graph] Relocate `gblender' to `grSurface'.
+
+       This will be needed for direct rendering and simplifies gamma setting.
+
+       * graph/grobjs.h (grSurface): Put `bitmap' on top, add `gblender'.
+       * graph/graph.h: s/grSetGlyphGamma/grSetTargetGamma/.
+       * graph/grblit.c (grSetTargetGamma): Move `gblender_init' here...
+       (grBlitGlyphToBitmap): ...from here.
+       * src/ftcommon.c (FTDemo_Display_New): Call `grSetTargetGamma'.
+       * src/ft{diff,grid,string,view,multi}.c: Updated.
+
 2019-06-14  Alexei Podtelezhnikov  <address@hidden>
 
        * graph/gblblit.c (gblender_blit_init): Switch to lookup table.
diff --git a/graph/graph.h b/graph/graph.h
index c5cec9e..88f7ba1 100644
--- a/graph/graph.h
+++ b/graph/graph.h
@@ -663,7 +663,7 @@
  /**********************************************************************
   *
   * <Function>
-  *    grSetGlyphGamma
+  *    grSetTargetGamma
   *
   * <Description>
   *    set the gamma-correction coefficient. This is only used to
@@ -675,7 +675,7 @@
   **********************************************************************/
 
   extern
-  void  grSetGlyphGamma( double  gamma_value );
+  void  grSetTargetGamma( grBitmap*  target, double  gamma_value );
 
 /* */
 
diff --git a/graph/grblit.c b/graph/grblit.c
index 02b515c..fa6d449 100644
--- a/graph/grblit.c
+++ b/graph/grblit.c
@@ -1808,11 +1808,12 @@
 
 #include "gblblit.h"
 
-  static double    gr_glyph_gamma = 1.8;
-
-  void  grSetGlyphGamma( double  gamma )
+  void  grSetTargetGamma( grBitmap*  target, double  gamma )
   {
-    gr_glyph_gamma = gamma;
+    grSurface*  surface = (grSurface*)target;
+
+
+    gblender_init( surface->gblender, gamma );
   }
 
 
@@ -1848,8 +1849,8 @@
       int                   width, height;
       GBlenderBlitRec       gblit[1];
       GBlenderPixel         gcolor;
-      static GBlenderRec    gblender[1];
-      static double         gblender_gamma = -100.0;
+      grSurface*            surface = (grSurface*)target;
+
 
       if ( glyph->grays != 256 )
         goto LegacyBlit;
@@ -1880,23 +1881,15 @@
 
       switch ( target->mode )
       {
+      case gr_pixel_mode_gray:   dst_format = GBLENDER_TARGET_GRAY8; 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;
       }
 
-     /* initialize blender when needed, i.e. when gamma changes
-      */
-      if ( gblender_gamma != gr_glyph_gamma  )
-      {
-        gblender_gamma = gr_glyph_gamma;
-        gblender_init( gblender, gblender_gamma );
-      }
-
-      if ( gblender_blit_init( gblit, gblender,
+      if ( gblender_blit_init( gblit, surface->gblender,
                                x, y,
                                src_format,
                                glyph->buffer,
diff --git a/graph/grobjs.h b/graph/grobjs.h
index 0b615d6..92c7f9b 100644
--- a/graph/grobjs.h
+++ b/graph/grobjs.h
@@ -18,6 +18,7 @@
 #include "graph.h"
 #include "grconfig.h"
 #include "grtypes.h"
+#include "gblender.h"
 
 
   typedef struct grBiColor_
@@ -109,8 +110,11 @@
 
   struct grSurface_
   {
-    grDevice*          device;
     grBitmap           bitmap;
+
+    GBlenderRec        gblender[1];
+
+    grDevice*          device;
     grBool             refresh;
     grBool             owner;
 
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 7f42a9b..19de19f 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -162,6 +162,8 @@
 
     display->gamma = GAMMA;
 
+    grSetTargetGamma( display->bitmap, display->gamma );
+
     return display;
   }
 
diff --git a/src/ftdiff.c b/src/ftdiff.c
index 3ab8ba1..d0489ce 100644
--- a/src/ftdiff.c
+++ b/src/ftdiff.c
@@ -1014,7 +1014,7 @@
     display->bitmap  = &surface->bitmap;
     display->gamma   = GAMMA;
 
-    grSetGlyphGamma( display->gamma );
+    grSetTargetGamma( display->bitmap, display->gamma );
 
     memset( &display->fore_color, 0, sizeof( grColor ) );
     memset( &display->back_color, 0xff, sizeof( grColor ) );
@@ -1123,7 +1123,7 @@
     else if ( display->gamma < 0.0001 )
       display->gamma = 0.0;
 
-    grSetGlyphGamma( display->gamma );
+    grSetTargetGamma( display->bitmap, display->gamma );
   }
 
 
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 263043b..8dab729 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -1156,7 +1156,7 @@
     else if ( display->gamma < 0.0 )
       display->gamma = 0.0;
 
-    grSetGlyphGamma( display->gamma );
+    grSetTargetGamma( display->bitmap, display->gamma );
   }
 
 
diff --git a/src/ftmulti.c b/src/ftmulti.c
index c7313bc..173897f 100644
--- a/src/ftmulti.c
+++ b/src/ftmulti.c
@@ -301,6 +301,8 @@
     if ( !surface )
       PanicZ( "could not allocate display surface\n" );
 
+    grSetTargetGamma( (grBitmap*)surface, 1.8 );
+
     graph_init = 1;
   }
 
diff --git a/src/ftstring.c b/src/ftstring.c
index f44303f..5e4c973 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -395,7 +395,7 @@
     else if ( display->gamma < 0.1 )
       display->gamma = 0.1;
 
-    grSetGlyphGamma( display->gamma );
+    grSetTargetGamma( display->bitmap, display->gamma );
   }
 
 
diff --git a/src/ftview.c b/src/ftview.c
index 78e9113..f196f99 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -919,7 +919,7 @@
     else if ( display->gamma < 0.0 )
       display->gamma = 0.0;
 
-    grSetGlyphGamma( display->gamma );
+    grSetTargetGamma( display->bitmap, display->gamma );
   }
 
 



reply via email to

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