freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 85f1bad 2/2: * src/ftmulti.c (bit): Surface bit


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master 85f1bad 2/2: * src/ftmulti.c (bit): Surface bitmap must belong to surface.
Date: Mon, 17 Jun 2019 23:07:14 -0400 (EDT)

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

    * src/ftmulti.c (bit): Surface bitmap must belong to surface.
    * graph/graph.h (grBlitGlyphToBitmap): Clarify documentation.
    * graph/grdevice.c (grNewSurface): Initialize default blender.
---
 ChangeLog        |  6 ++++++
 graph/graph.h    |  7 +------
 graph/grblit.c   | 19 -------------------
 graph/grdevice.c | 12 +++++-------
 src/ftmulti.c    | 41 ++++++++++++++++++++---------------------
 5 files changed, 32 insertions(+), 53 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index db17cac..085347a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2019-06-17  Alexei Podtelezhnikov  <address@hidden>
 
+       * src/ftmulti.c (bit): Surface bitmap must belong to surface.
+       * graph/graph.h (grBlitGlyphToBitmap): Clarify documentation.
+       * graph/grdevice.c (grNewSurface): Initialize default blender.
+
+2019-06-17  Alexei Podtelezhnikov  <address@hidden>
+
        * graph/*/rules.mk: Add missing dependency.
 
 2019-06-16  Alexei Podtelezhnikov  <address@hidden>
diff --git a/graph/graph.h b/graph/graph.h
index 88f7ba1..54d89d1 100644
--- a/graph/graph.h
+++ b/graph/graph.h
@@ -160,7 +160,7 @@
   *    writes a given glyph bitmap to a target surface.
   *
   * <Input>
-  *    target  :: handle to target bitmap
+  *    target  :: handle to target bitmap that belongs to surface
   *    glyph   :: handle to source glyph bitmap
   *    x       :: position of left-most pixel of glyph image in target surface
   *    y       :: position of top-most pixel of glyph image in target surface
@@ -475,11 +475,6 @@
   *               for the surface. the bitmap's 'pitch' and 'buffer'
   *               fields are ignored on input.
   *
-  *               On output, the bitmap describes the surface's image
-  *               completely. It is possible to write directly in it
-  *               with grBlitGlyphToBitmap, even though the use of
-  *               grBlitGlyphToSurface is recommended.
-  *
   * <Return>
   *    handle to the corresponding surface object. 0 in case of error
   *
diff --git a/graph/grblit.c b/graph/grblit.c
index 53cfbc1..7c22551 100644
--- a/graph/grblit.c
+++ b/graph/grblit.c
@@ -1748,25 +1748,6 @@
   }
 
 
- /**********************************************************************
-  *
-  * <Function>
-  *    grBlitGlyphToBitmap
-  *
-  * <Description>
-  *    writes a given glyph bitmap to a target surface.
-  *
-  * <Input>
-  *    surface :: handle to target surface
-  *    x       :: position of left-most pixel of glyph image in surface
-  *    y       :: position of top-most pixel of glyph image in surface
-  *    bitmap  :: source glyph image
-  *
-  * <Return>
-  *   Error code. 0 means success
-  *
-  **********************************************************************/
-
   typedef  void (*grColorGlyphBlitter)( grBlitter*  blit,
                                         grColor     color,
                                         int         max_gray );
diff --git a/graph/grdevice.c b/graph/grdevice.c
index 27413ee..8b51dd8 100644
--- a/graph/grdevice.c
+++ b/graph/grdevice.c
@@ -110,11 +110,6 @@
   *               for the surface. the bitmap's 'pitch' and 'buffer'
   *               fields are ignored on input.
   *
-  *               On output, the bitmap describes the surface's image
-  *               completely. It is possible to write directly in it
-  *               with grBlitGlyphToBitmap, even though the use of
-  *               grBlitGlyphToSurface is recommended.
-  *
   * <Return>
   *    handle to the corresponding surface object. 0 in case of error
   *
@@ -137,8 +132,8 @@
   *
   **********************************************************************/
 
-  extern grSurface*  grNewSurface( const char*  device_name,
-                                   grBitmap*    bitmap )
+  grSurface*  grNewSurface( const char*  device_name,
+                            grBitmap*    bitmap )
   {
     grDevice*   device;
     grSurface*  surface;
@@ -155,6 +150,9 @@
       grFree( (void *)surface );
       surface = 0;
     }
+    else
+      grSetTargetGamma( (grBitmap*)surface, 1.8 );
+
     return surface;
   }
 
diff --git a/src/ftmulti.c b/src/ftmulti.c
index 173897f..a3b1182 100644
--- a/src/ftmulti.c
+++ b/src/ftmulti.c
@@ -79,7 +79,7 @@
   static FT_Error      error;        /* error returned by FreeType? */
 
   static grSurface*    surface;      /* current display surface     */
-  static grBitmap      bit;          /* current display bitmap      */
+  static grBitmap*     bit;          /* current display bitmap      */
 
   static int  width     = DIM_X;     /* window width                */
   static int  height    = DIM_Y;     /* window height               */
@@ -277,12 +277,12 @@
   static void
   Clear_Display( void )
   {
-    long  bitmap_size = (long)bit.pitch * bit.rows;
+    long  bitmap_size = (long)bit->pitch * bit->rows;
 
 
     if ( bitmap_size < 0 )
       bitmap_size = -bitmap_size;
-    memset( bit.buffer, 0, (unsigned long)bitmap_size );
+    memset( bit->buffer, 0, (unsigned long)bitmap_size );
   }
 
 
@@ -290,18 +290,16 @@
   static void
   Init_Display( void )
   {
-    grInitDevices();
+    grBitmap  bitmap = { height, width, 0, gr_pixel_mode_gray, 256, NULL };
+
 
-    bit.mode  = gr_pixel_mode_gray;
-    bit.width = width;
-    bit.rows  = height;
-    bit.grays = 256;
+    grInitDevices();
 
-    surface = grNewSurface( 0, &bit );
+    surface = grNewSurface( 0, &bitmap );
     if ( !surface )
       PanicZ( "could not allocate display surface\n" );
 
-    grSetTargetGamma( (grBitmap*)surface, 1.8 );
+    bit = (grBitmap*)surface;
 
     graph_init = 1;
   }
@@ -347,7 +345,8 @@
     x_top = x_offset + glyph->bitmap_left;
     y_top = y_offset - glyph->bitmap_top;
 
-    grBlitGlyphToBitmap( &bit, &bit3, x_top, y_top, fore_color );
+    grBlitGlyphToBitmap( bit, &bit3,
+                         x_top, y_top, fore_color );
 
     return 0;
   }
@@ -424,12 +423,12 @@
 
         x += ( ( glyph->metrics.horiAdvance + 32 ) >> 6 ) + 1;
 
-        if ( x + size->metrics.x_ppem > bit.width )
+        if ( x + size->metrics.x_ppem > bit->width )
         {
           x  = start_x;
           y += step_y;
 
-          if ( y >= bit.rows )
+          if ( y >= bit->rows )
             return FT_Err_Ok;
         }
       }
@@ -492,12 +491,12 @@
 
         x += ( ( glyph->metrics.horiAdvance + 32 ) >> 6 ) + 1;
 
-        if ( x + size->metrics.x_ppem > bit.width )
+        if ( x + size->metrics.x_ppem > bit->width )
         {
           x  = start_x;
           y += step_y;
 
-          if ( y >= bit.rows )
+          if ( y >= bit->rows )
             return FT_Err_Ok;
         }
       }
@@ -534,7 +533,7 @@
     grSetLineHeight( 10 );
     grGotoxy( 0, 0 );
     grSetMargin( 2, 1 );
-    grGotobitmap( &bit );
+    grGotobitmap( bit );
 
     sprintf( buf,
              "FreeType MM Glyph Viewer - part of the FreeType %s test suite",
@@ -1167,12 +1166,12 @@
         if ( !new_header )
           new_header = Header;
 
-        grWriteCellString( &bit, 0, 0, new_header, fore_color );
+        grWriteCellString( bit, 0, 0, new_header, fore_color );
         new_header = NULL;
 
         sprintf( Header, "PS name: %s",
                          FT_Get_Postscript_Name( face ) );
-        grWriteCellString( &bit, 0, 16, Header, fore_color );
+        grWriteCellString( bit, 0, 16, Header, fore_color );
 
         sprintf( Header, "axes:" );
         {
@@ -1197,7 +1196,7 @@
                      sizeof ( Header ) - strlen( Header ) - 1 );
           }
         }
-        grWriteCellString( &bit, 0, 24, Header, fore_color );
+        grWriteCellString( bit, 0, 24, Header, fore_color );
 
         if ( num_shown_axes > MAX_MM_AXES / 2 )
         {
@@ -1222,7 +1221,7 @@
                      sizeof ( Header ) - strlen( Header ) - 1 );
           }
 
-          grWriteCellString( &bit, 0, 32, Header, fore_color );
+          grWriteCellString( bit, 0, 32, Header, fore_color );
         }
 
         {
@@ -1260,7 +1259,7 @@
         sprintf( Header, "%.100s: not an MM font file, or could not be opened",
                          ft_basename( argv[file] ) );
 
-      grWriteCellString( &bit, 0, 8, Header, fore_color );
+      grWriteCellString( bit, 0, 8, Header, fore_color );
       grRefreshSurface( surface );
 
       if ( !( key = Process_Event() ) )



reply via email to

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