freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 58df96f 21/22: [ftdiff] Make it agnostic to dis


From: Werner Lemberg
Subject: [freetype2-demos] master 58df96f 21/22: [ftdiff] Make it agnostic to display mode.
Date: Fri, 5 Mar 2021 11:18:41 -0500 (EST)

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

    [ftdiff] Make it agnostic to display mode.
    
    * src/ftdiff.c (main): Let the driver choose the mode.
    (adisplay_init): Call `grFindColor' to set colors.
    (adisplay_clear): Call `grFillRect' to clear display.
---
 ChangeLog    |  8 ++++++++
 src/ftdiff.c | 33 ++++-----------------------------
 2 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 93136bc..74594ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-02-26  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [ftdiff] Make it agnostic to display mode.
+
+       * src/ftdiff.c (main): Let the driver choose the mode.
+       (adisplay_init): Call `grFindColor' to set colors.
+       (adisplay_clear): Call `grFillRect' to clear display.
+
 2021-02-25  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
        * graph/gblany.h, graph/gblblit.c: Multiply by 0x010101U.
diff --git a/src/ftdiff.c b/src/ftdiff.c
index 51c2651..741c17b 100644
--- a/src/ftdiff.c
+++ b/src/ftdiff.c
@@ -989,10 +989,6 @@
     grBitmap    bit;
 
 
-    if ( mode != gr_pixel_mode_gray  &&
-         mode != gr_pixel_mode_rgb24 )
-      return -1;
-
     grInitDevices();
 
     bit.mode  = mode;
@@ -1013,8 +1009,8 @@
 
     grSetTargetGamma( display->bitmap, display->gamma );
 
-    memset( &display->fore_color, 0, sizeof( grColor ) );
-    memset( &display->back_color, 0xff, sizeof( grColor ) );
+    display->fore_color = grFindColor( display->bitmap,   0,   0,   0, 255 );
+    display->back_color = grFindColor( display->bitmap, 255, 255, 255, 255 );
 
     return 0;
   }
@@ -1024,30 +1020,9 @@
   adisplay_clear( ADisplay  display )
   {
     grBitmap*  bit   = display->bitmap;
-    int        pitch = bit->pitch;
-
-
-    if ( pitch < 0 )
-      pitch = -pitch;
-
-    if ( bit->mode == gr_pixel_mode_gray )
-      memset( bit->buffer,
-              display->back_color.value,
-              (size_t)pitch * (size_t)bit->rows );
-    else
-    {
-      unsigned char*  p = bit->buffer;
-      int             i, j;
-
 
-      for ( i = 0; i < bit->rows; i++ )
-      {
-        for ( j = 0; j < bit->width; j++ )
-          memcpy( p + 3 * j, display->back_color.chroma, 3 );
 
-        p += pitch;
-      }
-    }
+    grFillRect( bit, 0, 0, bit->width, bit->rows, display->back_color );
   }
 
 
@@ -1622,7 +1597,7 @@
     }
 
     /* Initialize display */
-    if ( adisplay_init( adisplay, gr_pixel_mode_rgb24,
+    if ( adisplay_init( adisplay, gr_pixel_mode_none,
                         width, height ) < 0 )
     {
       fprintf( stderr, "could not initialize display!  Aborting.\n" );



reply via email to

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