freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master fdbce88: [ftgrid, ftstring, ftview] Migrate gam


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master fdbce88: [ftgrid, ftstring, ftview] Migrate gamma to `FTDemo_Display'.
Date: Wed, 31 May 2017 21:57:47 -0400 (EDT)

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

    [ftgrid, ftstring, ftview] Migrate gamma to `FTDemo_Display'.
    
    * src/ftcommon.h (FTDemo_Display): Add new field `gamma'.
    * src/ftcommon.c (FTDemo_Display_New): Initialize it.
    (FTDemo_Draw_Header): Updated.
    
    * src/ftgrid.c (GridStatusRec): Remove field `gamma'.
    (event_gamma_change): Updated.
    
    * src/ftstring.c (status): Remove field `gamma'.
    (event_gamma_change): Updated.
    
    * src/ftgrid.c (status): Remove field `gamma'.
    (event_gamma_change): Updated.
---
 ChangeLog      | 17 +++++++++++++++++
 src/ftcommon.c | 32 ++++++++++++++++----------------
 src/ftcommon.h |  2 +-
 src/ftgrid.c   | 16 +++++++---------
 src/ftstring.c | 19 +++++++++----------
 src/ftview.c   | 17 ++++++++---------
 6 files changed, 58 insertions(+), 45 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f6c8277..8d5e905 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2017-05-29  Alexei Podtelezhnikov  <address@hidden>
+
+       [ftgrid, ftstring, ftview] Migrate gamma to `FTDemo_Display'.
+
+       * src/ftcommon.h (FTDemo_Display): Add new field `gamma'.
+       * src/ftcommon.c (FTDemo_Display_New): Initialize it.
+       (FTDemo_Draw_Header): Updated.
+
+       * src/ftgrid.c (GridStatusRec): Remove field `gamma'.
+       (event_gamma_change): Updated.
+
+       * src/ftstring.c (status): Remove field `gamma'.
+       (event_gamma_change): Updated.
+
+       * src/ftgrid.c (status): Remove field `gamma'.
+       (event_gamma_change): Updated.
+
 2017-05-28  Werner Lemberg  <address@hidden>
 
        * src/ftbench.c (BENCH_TIME): Use `double' literal.
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 0ba81ad..ea6eb93 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -121,6 +121,8 @@
     display->warn_color = grFindColor( display->bitmap,
                                        0xff, 0x00, 0x00, 0xff );
 
+    display->gamma = GAMMA;
+
     return display;
   }
 
@@ -744,7 +746,6 @@
                       FTDemo_Display*  display,
                       int              ptsize,
                       int              res,
-                      double           gamma,
                       int              error_code )
   {
     FT_Face      face;
@@ -752,7 +753,7 @@
     const char*  basename;
 
     int          line = 0;
-    int          x1, x2;
+    int          x;
 
 
     error = FTC_Manager_LookupFace( handle->cache_manager,
@@ -773,8 +774,8 @@
                        buf, display->fore_color );
 
     /* pt and dpi */
-    x1 = sprintf( buf, "%gpt at %ddpi ",
-                       ptsize / 64.0, res );
+    x = sprintf( buf, "%gpt at %ddpi ",
+                      ptsize / 64.0, res );
     grWriteCellString( display->bitmap, 0, line * HEADER_HEIGHT,
                        buf, display->fore_color );
 
@@ -788,13 +789,13 @@
 
       /* ppem */
       if ( FT_IS_SCALABLE( face ) )
-        x2 = sprintf( buf, "(%.4gppem)",
+        sprintf( buf, "(%.4gppem)",
                       FT_MulFix( face->units_per_EM,
                                  face->size->metrics.y_scale ) / 64.0 );
       else
-        x2 = sprintf( buf, "(%dppem)",
+        sprintf( buf, "(%dppem)",
                       face->size->metrics.y_ppem );
-      grWriteCellString( display->bitmap, 8 * x1, line * HEADER_HEIGHT,
+      grWriteCellString( display->bitmap, 8 * x, line * HEADER_HEIGHT,
                          buf, highlight ? display->warn_color
                                         : display->fore_color );
     }
@@ -804,26 +805,25 @@
       switch ( error_code )
       {
       case FT_Err_Invalid_Pixel_Size:
-        x2 = sprintf( buf, "Invalid pixel size" );
+        sprintf( buf, "Invalid pixel size" );
         break;
       case FT_Err_Invalid_PPem:
-        x2 = sprintf( buf, "Invalid ppem value" );
+        sprintf( buf, "Invalid ppem value" );
         break;
       default:
-        x2 = sprintf( buf, "error 0x%04x",
+        sprintf( buf, "error 0x%04x",
                       (FT_UShort)error_code );
       }
-      grWriteCellString( display->bitmap, 8 * x1, line++ * HEADER_HEIGHT,
+      grWriteCellString( display->bitmap, 8 * x, line++ * HEADER_HEIGHT,
                          buf, display->warn_color );
     }
 
     /* gamma */
-    if ( gamma == 0.0 )
-      sprintf( buf, ", gamma: sRGB mode" );
+    if ( display->gamma == 0.0 )
+      sprintf( buf, "gamma: sRGB" );
     else
-      sprintf( buf, ", gamma: %.1f", gamma );
-    grWriteCellString( display->bitmap, 8 * ( x1 + x2 ),
-                       (line++) * HEADER_HEIGHT,
+      sprintf( buf, "gamma = %.1f", display->gamma );
+    grWriteCellString( display->bitmap, DIM_X - 8 * 11, 0,
                        buf, display->fore_color );
   }
 
diff --git a/src/ftcommon.h b/src/ftcommon.h
index 45a2156..bc598a3 100644
--- a/src/ftcommon.h
+++ b/src/ftcommon.h
@@ -79,6 +79,7 @@
     grColor     fore_color;
     grColor     back_color;
     grColor     warn_color;
+    double      gamma;
 
   } FTDemo_Display;
 
@@ -266,7 +267,6 @@
                       FTDemo_Display*  display,
                       int              ptsize,
                       int              res,
-                      double           gamma,
                       int              error_code );
 
 
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 36087ca..191ce2f 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -133,7 +133,6 @@
     int          do_segment;
 
     FT_LcdFilter lcd_filter;
-    double       gamma;
     const char*  header;
     char         header_buffer[BUFSIZE];
 
@@ -176,7 +175,6 @@
 
     st->Num           = 0;
     st->lcd_filter    = FT_LCD_FILTER_DEFAULT;
-    st->gamma         = GAMMA;
     st->header        = NULL;
 
     st->mm            = NULL;
@@ -1102,14 +1100,14 @@
   static void
   event_gamma_change( double  delta )
   {
-    status.gamma += delta;
+    display->gamma += delta;
 
-    if ( status.gamma > 3.0 )
-      status.gamma = 3.0;
-    else if ( status.gamma < 0.0 )
-      status.gamma = 0.0;
+    if ( display->gamma > 3.0 )
+      display->gamma = 3.0;
+    else if ( display->gamma < 0.0 )
+      display->gamma = 0.0;
 
-    grSetGlyphGamma( status.gamma );
+    grSetGlyphGamma( display->gamma );
   }
 
 
@@ -1707,7 +1705,7 @@
 
 
     FTDemo_Draw_Header( handle, display, status.ptsize, status.res,
-                        status.gamma, error_code );
+                        error_code );
 
     if ( status.header )
       grWriteCellString( display->bitmap, 0, 3 * HEADER_HEIGHT,
diff --git a/src/ftstring.c b/src/ftstring.c
index 5ee0bf2..f201974 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -87,7 +87,6 @@
     unsigned long  encoding;
     int            res;
     int            ptsize;            /* current point size */
-    double         gamma;
     int            angle;
     const char*    text;
 
@@ -100,7 +99,7 @@
     char       header_buffer[256];
 
   } status = { DIM_X, DIM_Y,
-               RENDER_MODE_STRING, FT_ENCODING_UNICODE, 72, 48, GAMMA, 0, NULL,
+               RENDER_MODE_STRING, FT_ENCODING_UNICODE, 72, 48, 0, NULL,
                { 0, 0, 0, 0, NULL },
                { 0 }, { 0, 0, 0, 0 }, 0, NULL, { 0 } };
 
@@ -316,17 +315,17 @@
     int     i;
 
 
-    status.gamma += delta;
+    display->gamma += delta;
 
-    if ( status.gamma > 3.0 )
-      status.gamma = 3.0;
-    else if ( status.gamma < 0.1 )
-      status.gamma = 0.1;
+    if ( display->gamma > 3.0 )
+      display->gamma = 3.0;
+    else if ( display->gamma < 0.1 )
+      display->gamma = 0.1;
 
-    grSetGlyphGamma( status.gamma );
+    grSetGlyphGamma( display->gamma );
 
     for ( i = 0; i < 256; i++ )
-      status.gamma_ramp[i] = (FT_Byte)( pow( (double)i / 255., status.gamma )
+      status.gamma_ramp[i] = (FT_Byte)( pow( (double)i / 255., display->gamma )
                                         * 255. + 0.5 );
   }
 
@@ -525,7 +524,7 @@
   write_header( FT_Error  error_code )
   {
     FTDemo_Draw_Header( handle, display, status.ptsize, status.res,
-                        status.gamma, error_code );
+                        error_code );
 
     if ( status.header )
       grWriteCellString( display->bitmap, 0, 2 * HEADER_HEIGHT,
diff --git a/src/ftview.c b/src/ftview.c
index 15ded59..2891ed0 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -108,7 +108,6 @@
     int            res;
     int            ptsize;            /* current point size, 26.6 format */
     int            lcd_idx;
-    double         gamma;
     double         xbold_factor;
     double         ybold_factor;
     double         radius;
@@ -132,7 +131,7 @@
 
   } status = { 1,
                DIM_X, DIM_Y, RENDER_MODE_ALL, FT_ENCODING_NONE,
-               72, 48, 1, GAMMA, 0.04, 0.04, 0.02, 0.22,
+               72, 48, 1, 0.04, 0.04, 0.02, 0.22,
                0, { 0 }, 0, 0, 0, /* default values are set at runtime */
                0, 0, 0, 0, 0,
                FT_LCD_FILTER_DEFAULT, { 0x08, 0x4D, 0x56, 0x4D, 0x08 }, 2 };
@@ -855,14 +854,14 @@
   static void
   event_gamma_change( double  delta )
   {
-    status.gamma += delta;
+    display->gamma += delta;
 
-    if ( status.gamma > 3.0 )
-      status.gamma = 3.0;
-    else if ( status.gamma < 0.0 )
-      status.gamma = 0.0;
+    if ( display->gamma > 3.0 )
+      display->gamma = 3.0;
+    else if ( display->gamma < 0.0 )
+      display->gamma = 0.0;
 
-    grSetGlyphGamma( status.gamma );
+    grSetGlyphGamma( display->gamma );
   }
 
 
@@ -1380,7 +1379,7 @@
 
 
     FTDemo_Draw_Header( handle, display, status.ptsize, status.res,
-                        status.gamma, error_code );
+                        error_code );
 
     error = FTC_Manager_LookupFace( handle->cache_manager,
                                     handle->scaler.face_id, &face );



reply via email to

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