freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] GSoC-2017-kushal 9cd140a 49/52: Updating Makefile and runme.


From: Kushal K S V S
Subject: [freetype2] GSoC-2017-kushal 9cd140a 49/52: Updating Makefile and runme.sh
Date: Fri, 25 Aug 2017 15:09:42 -0400 (EDT)

branch: GSoC-2017-kushal
commit 9cd140ab517a3c6262e0309ef77e7276d106d3db
Author: Kushal K S V S <address@hidden>
Commit: Kushal K S V S <address@hidden>

    Updating Makefile and runme.sh
---
 tests/make_png/Makefile      | 27 +++++++++++++----------
 tests/make_png/README        | 52 ++++++++++++++++++++------------------------
 tests/make_png/bitmap.c      |  1 +
 tests/make_png/bitmap.h      | 18 ++++++---------
 tests/make_png/make_sprite.c | 41 +++++++++++++++-------------------
 tests/make_png/runme.sh      | 40 +++++++++++++++-------------------
 6 files changed, 83 insertions(+), 96 deletions(-)

diff --git a/tests/make_png/Makefile b/tests/make_png/Makefile
index b742dbf..ef5a734 100644
--- a/tests/make_png/Makefile
+++ b/tests/make_png/Makefile
@@ -1,27 +1,32 @@
-# Define required macros here
+TOP_DIR := ../..
+BUILD_DIR := $(TOP_DIR)/builds/unix
 
-SHELL = /bin/sh
+include $(TOP_DIR)/builds/unix/unix-def.mk
 
 SRC_SPRITE = make_sprite.c bitmap.c murmur3.c
+SRC_LIB = $(libdir)/libfreetype.a
 
-SRC_LIB = ./base/lib/libfreetype.a
 OBJS = $(src:.c=.o)
 
 CFLAGS = -Wall -g
 CC = gcc
-INCLUDE = -I ./base/include/freetype2/
+INCLUDE = -I $(includedir)/freetype2
 LIBS = -lpng -lharfbuzz -lbz2 -ldl
 
-DPI = 72
+DPI ?= 72
+FT_TEST_RENDER_MODE ?= RGB
 
-all: sprite
+all: tests
 
-sprite:$(SRC_SPRITE)
-       $(CC) $(CFLAGS) $(INCLUDE) -DDPI=$(DPI) -o $@  $(SRC_SPRITE) $(SRC_LIB) 
$(OBJS) $(LIBS)
+tests: $(SRC_SPRITE) render_modes dpi
+       $(CC) $(CFLAGS) $(INCLUDE) -DDPI=$(DPI) 
-DFT_TEST_RENDER_MODE=$(FT_TEST_RENDER_MODE) -o $@  $(SRC_SPRITE) $(SRC_LIB) 
$(OBJS) $(LIBS)
 
-.PHONY: clean
+.PHONY: clean force
 clean:
        -rm -f *.o
 
-
-
+render_modes: force
+       echo '$(FT_TEST_RENDER_MODE)' | cmp -s - $@ || echo 
'$(FT_TEST_RENDER_MODE)' > $@
+       
+dpi: force
+       echo '$(DPI)' | cmp -s - $@ || echo '$(DPI)' > $@
\ No newline at end of file
diff --git a/tests/make_png/README b/tests/make_png/README
index 8c46ba8..9430a26 100644
--- a/tests/make_png/README
+++ b/tests/make_png/README
@@ -5,10 +5,6 @@ TODO:   Generate HTML page for detailed comparison
 
 INSTRUCTIONS 
 
-***
-FOR NOW JUST RUN ./runme.sh <path/to/older/freetype/library> test.tff 
<pt_size> <render_mode>
-***
-
 NOTE: One version of FreeType is referred as "base" version and the 
       other as the "test" version.
 
@@ -18,51 +14,56 @@ NOTE: One version of FreeType is referred as "base" version 
and the
     directory.
 
     Next, download an older version of FreeType (For example : 2.6.5)
-    ( This being the "test" version of the two)
+    ( This being the "base" version of the two)
     Go to 'include/freetype/ftoption.h' and uncomment this line 
 
         #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
   
-  2. Install the two versions 
+  2. Compile the two versions 
   -------------------------------------     
-   Go to the "test" version's folder and change the default 
+   Go to the "base" version's folder and change the default 
    installation directory to the "test" folder created.
 
-       ./configure --prefix=<path>
+           ./configure
 
-    Compile and install the library
+    Compile the library
 
-       make 
-       make install
+           make 
 
-    Repeat step 2. for the "base" version as well.
+    Repeat step 2. for the "test" version as well.
 
  3. Compile the code
   -------------------------------------     
     Return to this folder and make the binary
 
-       make
+       make tests [options]
 
-    (set resolution in DPI by passing argument
-    example: make DPI=100, if not specified,default is 72)
+    Set resolution in DPI by passing argument to variable DPI.
+    Example: make tests DPI=100, if not specified,default is 72.
 
- 3. Run the executable
-  ------------------------------------- 
+    Set the Rendering mode by passing FT_TEST_RENDER_MODE.
+    <render_mode> can take values 1. MONO
+                                                         2. AA
+                                                         3. RGB
+                                                         4. BGR
+                                                         5. VRGB
+                                                         6. VBGR
+    ( Example: make tests FT_TEST_RENDER_MODE=RGB )
 
-       ./sprite <a> <b> <font_file> <pt_size> <render_mode>
+ 4. Run the executable
+  ------------------------------------- 
 
-    <a> is the libfreetype.so from the base vesion. 
-    <b> is the libfreetype.so from the test vesion.
+       sh runme.sh <a> <font_file> <pt_size> 
 
-    ( <a> and <b> are in <base/test version's installation folder>/lib/ )
+    <a> is directory of the 'base' FreeType version. 
     ( The path to these should be absolute. )
 
-       Open index.html for "list-view"
+       Open ./html/index.html for "list-view"
 ---------------------------------------------------------------------
 
 FEATURES
 
-    Generates sprite sheets in the ./images folder.
+    Generates sprite sheets in the ./html/images folder.
 
     Generates "list-view" web-page i.e index.html
 
@@ -71,8 +72,3 @@ FEATURES
       ->  Glyph-Index
       ->  Name
       ->  Difference Metric 
-
-
-
-
-
diff --git a/tests/make_png/bitmap.c b/tests/make_png/bitmap.c
index db6d616..e0ab987 100644
--- a/tests/make_png/bitmap.c
+++ b/tests/make_png/bitmap.c
@@ -289,6 +289,7 @@ int Generate_PNG (IMAGE *bitmap,
 
   status = 0;
   
+  printf("Generated image   %s\n", path );
   for (y = 0; y < bitmap->height; y++) {
     png_free (png_ptr, row_pointers[y]);
   }
diff --git a/tests/make_png/bitmap.h b/tests/make_png/bitmap.h
index d74a081..0ce860d 100644
--- a/tests/make_png/bitmap.h
+++ b/tests/make_png/bitmap.h
@@ -31,6 +31,7 @@ typedef struct {                /* To store 128bit Hash */
   FT_UInt32 hash[4];
 }HASH_128;
 
+/* A 32-bit pixel */
 typedef struct {
   unsigned char red;
   unsigned char green;
@@ -38,21 +39,16 @@ typedef struct {
   unsigned char alpha;
 } PIXEL;
 
-typedef struct {
-  unsigned char red;
-  unsigned char green;
-  unsigned char blue;
-  unsigned char alpha;
-} PIXEL_BGRA;
-
-/* A picture. */
-    
+/* A picture. */ 
 typedef struct  {
   PIXEL* pixels;
   size_t width;
   size_t height;
 } IMAGE;
-    
+
+/* Render modes */
+enum render_modes
+  { MONO, AA, RGB, BGR, VRGB, VBGR };    
 /*-----------------------------------------------------------------*/
 
 HASH_32* Generate_Hash_x86_32(FT_Bitmap* bitmap, HASH_32* murmur);
@@ -66,7 +62,7 @@ int Compare_Hash(HASH_128* hash_b, HASH_128* hash_t);
 /* Returns a pointer to pixel */
 /* at (x,y) co-ordinate */
 PIXEL* Pixel_At (IMAGE * bitmap, int x, int y);  
-/* buffer to image */
+/*Render mode string to render_mode code */
 void Make_PNG (FT_Bitmap* bitmap,IMAGE* fruit, int i,int render_mode);
 /* Image to file */
 int Generate_PNG (IMAGE *bitmap, const char *path,int render_mode);   
diff --git a/tests/make_png/make_sprite.c b/tests/make_png/make_sprite.c
index 72cfd67..b85d3ee 100644
--- a/tests/make_png/make_sprite.c
+++ b/tests/make_png/make_sprite.c
@@ -2,18 +2,10 @@
 
 int main(int argc, char const *argv[])
 {
-  if(argc != 6)
+  if(argc != 5)
   {
-    printf("Usage: ./sprite <base .so> <test .so> \
-           <fnt_file> <pt_size> <render_mode>\n");
-
-    printf("Values for render_mode    0 - monochrome\n");
-    printf("                          1 - anti-aliased\n");
-    printf("                          2 - lcd horizontal-RGB\n");
-    printf("                          3 - lcd horizontal-BGR\n");
-    printf("                          4 - lcd vertical-RGB\n");
-    printf("                          5 - lcd vertical-BGR\n");
-
+    printf("Usage: ./tests <base .so> <test .so>\
+    <fnt_file> <pt_size>\n");
     return 0;
   }
 
@@ -22,8 +14,7 @@ int main(int argc, char const *argv[])
   const char*      base_version; 
   const char*      test_version; 
   const char*      font_file;
-  int              size;
-  int              render_mode; 
+  int              size; 
 
   int              load_flag;  /* FT_LOAD_XXX */
   int              render_flag; /* FT_RENDER_MODE_XXX */
@@ -34,7 +25,6 @@ int main(int argc, char const *argv[])
   
   font_file        = argv[3];
   size             = atoi(argv[4]);
-  render_mode      = atoi(argv[5]);
 
   FT_Library       base_library;
   FT_Face          base_face;
@@ -64,7 +54,7 @@ int main(int argc, char const *argv[])
   HASH_128 *  base_murmur = (HASH_128 *) malloc(sizeof(HASH_128)) ;
   HASH_128 *  test_murmur = (HASH_128 *) malloc(sizeof(HASH_128)) ;  
 
-  int Is_Different;
+  int Is_Different, total_count = 0;
   int pixel_diff, i;
 
   char glyph_name[50] = ".not-def";
@@ -203,8 +193,8 @@ int main(int argc, char const *argv[])
                                               "FT_Done_FreeType");
 
 /*******************************************************************/
-
-  switch ( render_mode ) {
+  
+  switch ( FT_TEST_RENDER_MODE ) {
   case 0: render_flag   = FT_RENDER_MODE_MONO;
           load_flag     = FT_LOAD_MONOCHROME;
           target_flag   = FT_LOAD_TARGET_MONO;
@@ -251,7 +241,7 @@ int main(int argc, char const *argv[])
     exit(1);
   }
 
-  if (render_mode > 1 )
+  if (FT_TEST_RENDER_MODE > 1 )
   {
     error = Base_Library_SetLcdFilter( base_library,
                                        FT_LCD_FILTER_DEFAULT );
@@ -389,16 +379,17 @@ int main(int argc, char const *argv[])
 
     if (Is_Different != 0) 
     {
+      total_count++;
       pixel_diff = 0; /* Difference metric*/
-      if (render_mode == 0)
+      if (FT_TEST_RENDER_MODE == 0)
       { /* If monochrome, take the converted image*/
-        Make_PNG( &base_target, base_png, i, render_mode );
-        Make_PNG( &test_target, test_png, i, render_mode );
+        Make_PNG( &base_target, base_png, i, FT_TEST_RENDER_MODE );
+        Make_PNG( &test_target, test_png, i, FT_TEST_RENDER_MODE );
 
       }else{
 
-        Make_PNG( base_bitmap, base_png, i, render_mode );
-        Make_PNG( test_bitmap, test_png, i, render_mode );
+        Make_PNG( base_bitmap, base_png, i, FT_TEST_RENDER_MODE );
+        Make_PNG( test_bitmap, test_png, i, FT_TEST_RENDER_MODE );
       }
       /* Aligning images and appending rows */
       if (base_png->height < test_png->height)
@@ -437,11 +428,13 @@ int main(int argc, char const *argv[])
 
       sprintf( output_file_name, "./html/images/%s.png", glyph_name );
 
-      Generate_PNG ( output, output_file_name, render_mode );
+      Generate_PNG ( output, output_file_name, FT_TEST_RENDER_MODE );
       /* To print table row to HTML file */
       Print_Row(fp,i,glyph_name,pixel_diff );
     }
   }
+  printf("Total   %ld\nFaulty  %d\n",base_face->num_glyphs,
+                                                         total_count );
  /* HTML footer */
   fprintf(fp,
         "</tbody>\n\
diff --git a/tests/make_png/runme.sh b/tests/make_png/runme.sh
old mode 100644
new mode 100755
index 9761ad7..1b768c3
--- a/tests/make_png/runme.sh
+++ b/tests/make_png/runme.sh
@@ -1,30 +1,26 @@
-TEST_DIR=$1
-BASE_DIR=$PWD
+rm -f ./html/images/*
 
-cd $TEST_DIR/include/freetype/config/
-sed -i 's/\/\* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING \*\//#define 
FT_CONFIG_OPTION_SUBPIXEL_RENDERING /g' ftoption.h
+BASE_DIR=$1
+TEST_DIR=../..
 
-cd $TEST_DIR
-./autogen.sh
-./configure --prefix=$BASE_DIR/test/
-make 
-make install 
+BASE_LIB=$BASE_DIR/objs/.libs/libfreetype.so
+TEST_LIB=$TEST_DIR/objs/.libs/libfreetype.so
 
-cd $BASE_DIR/../..
-./autogen.sh
-./configure --prefix=$BASE_DIR/base/
-make 
-make install
+FONT_FILE=$2
+PT_SIZE=$3
 
-cd $BASE_DIR
-make
+echo
+echo "*** Generating Images ***"
+echo 
 
-BASE_LIB=./base/lib/libfreetype.so
-TEST_LIB=./test/lib/libfreetype.so
+./tests $BASE_LIB $TEST_LIB $FONT_FILE $PT_SIZE
+
+echo "Font:  " $FONT_FILE
+echo "Size:  " $PT_SIZE
+
+# Removing the current DPI and Render Mode settings
+# for future compilations. 
+rm -f ./render_modes ./dpi
 
-FONT_FILE=$2
-PT_SIZE=$3
-RENDER_MODE=$4
 
-./sprite $BASE_LIB $TEST_LIB $FONT_FILE $PT_SIZE $RENDER_MODE
 



reply via email to

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