freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master daf13a2: [graph] New batch device.


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master daf13a2: [graph] New batch device.
Date: Thu, 6 Jun 2019 22:17:54 -0400 (EDT)

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

    [graph] New batch device.
    
    This driver maintains the image in memory without displaying it,
    useful for batch processing without GUI.
    
    * graph/batch/grbatch.[hc]: New implenetation files.
    * graph/batch/rules.mk: Makefile with unconditinal compilation.
    * graph/grinit.c (GR_INIT_DEVICE_CHAIN): Add the driver at the tail.
---
 ChangeLog             |  11 ++++++
 graph/batch/grbatch.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++
 graph/batch/grbatch.h |  23 +++++++++++
 graph/batch/rules.mk  |  33 ++++++++++++++++
 graph/grinit.c        |   4 ++
 5 files changed, 175 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f30fa4f..918eb12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-06-06  Alexei Podtelezhnikov  <address@hidden>
+
+       [graph] New batch device.
+
+       This driver maintains the image in memory without displaying it,
+       useful for batch processing without GUI.
+
+       * graph/batch/grbatch.[hc]: New implenetation files.
+       * graph/batch/rules.mk: Makefile with unconditinal compilation.
+       * graph/grinit.c (GR_INIT_DEVICE_CHAIN): Add the driver at the tail.
+
 2019-06-05  Alexei Podtelezhnikov  <address@hidden>
 
        [graph] Stay true to linked lists.
diff --git a/graph/batch/grbatch.c b/graph/batch/grbatch.c
new file mode 100644
index 0000000..c7916f8
--- /dev/null
+++ b/graph/batch/grbatch.c
@@ -0,0 +1,104 @@
+/*******************************************************************
+ *
+ *  grbatch.c  Batch processing driver.
+ *
+ *  This driver maintains the image in memory without displaying it,
+ *  used by the graphics utility of the FreeType test suite.
+ *
+ *  Copyright (C) 1999-2019 by
+ *  David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ *  This file is part of the FreeType project, and may only be used
+ *  modified and distributed under the terms of the FreeType project
+ *  license, LICENSE.TXT. By continuing to use, modify or distribute
+ *  this file you indicate that you have read the license and
+ *  understand and accept it fully.
+ *
+ ******************************************************************/
+
+#include <stdio.h>
+
+/* FT graphics subsystem */
+#include "grobjs.h"
+#include "grdevice.h"
+
+
+  static int
+  gr_batch_device_init( void )
+  {
+    return 0;  /* success */
+  }
+
+  static void
+  gr_batch_device_done( void )
+  {
+    /* nothing to do */
+  }
+
+  static void
+  gr_batch_surface_set_title( grSurface*   surface,
+                            const char*  title_string )
+  {
+    printf( "%s\n", title_string );  /* prompt */
+  }
+
+  static void
+  gr_batch_surface_refresh_rect( grSurface* surface,
+                                 int x, int y, int width, int height )
+  {
+    /* no screen or window to refresh */
+  }
+
+  static void
+  gr_batch_surface_done( grSurface* surface )
+  {
+    grDoneBitmap( &(surface->bitmap) );
+  }
+
+  static int
+  gr_batch_surface_listen_event( grSurface* surface,
+                                 int event_mode,
+                                 grEvent* event )
+  {
+    event->type = gr_event_key;
+
+    event->key = grKEY( getchar() );
+
+    return 1;
+  }
+
+  static int
+  gr_batch_surface_init( grSurface* surface,
+                         grBitmap* bitmap )
+  {
+    if ( grNewBitmap( bitmap->mode, bitmap->grays,
+                      bitmap->width, bitmap->rows, bitmap) )
+      return 0;
+
+    surface->bitmap     = *bitmap;
+    surface->refresh    = 0;
+    surface->owner      = 0;
+    surface->saturation = 0;
+    surface->blit_mono  = 0;
+
+    surface->refresh_rect = gr_batch_surface_refresh_rect;
+    surface->set_title    = gr_batch_surface_set_title;
+    surface->listen_event = gr_batch_surface_listen_event;
+    surface->done         = gr_batch_surface_done;
+
+    return 1;
+  }
+
+  grDevice  gr_batch_device =
+  {
+    sizeof(grSurface),
+    "batch",
+
+    gr_batch_device_init,
+    gr_batch_device_done,
+
+    gr_batch_surface_init,
+
+    0,
+    0
+  };
diff --git a/graph/batch/grbatch.h b/graph/batch/grbatch.h
new file mode 100644
index 0000000..5a7ef85
--- /dev/null
+++ b/graph/batch/grbatch.h
@@ -0,0 +1,23 @@
+#ifndef GRBATCH_H_
+#define GRBATCH_H_
+
+#include "grobjs.h"
+
+  extern
+  grDevice  gr_batch_device;
+
+#ifdef GR_INIT_BUILD
+  static
+  grDeviceChain  gr_batch_device_chain =
+  {
+    "batch",
+    &gr_batch_device,
+    GR_INIT_DEVICE_CHAIN
+  };
+
+#undef GR_INIT_DEVICE_CHAIN
+#define GR_INIT_DEVICE_CHAIN  &gr_batch_device_chain
+
+#endif  /* GR_INIT_BUILD */
+
+#endif /* GRBATCH_H_ */
diff --git a/graph/batch/rules.mk b/graph/batch/rules.mk
new file mode 100644
index 0000000..2551484
--- /dev/null
+++ b/graph/batch/rules.mk
@@ -0,0 +1,33 @@
+#**************************************************************************
+#*
+#*  Batch processing driver makefile
+#*
+#**************************************************************************
+
+# directory of batch driver
+#
+GR_BATCH := $(GRAPH)/batch
+
+# add batch driver to lib objects
+#
+GRAPH_OBJS += $(OBJ_DIR_2)/grbatch.$O
+
+# add batch driver to list of devices
+#
+DEVICES += BATCH
+
+# batch driver compilation rule
+#
+$(OBJ_DIR_2)/grbatch.$O : $(GR_BATCH)/grbatch.c $(GR_BATCH)/grbatch.h
+ifneq ($(LIBTOOL),)
+       $(LIBTOOL) --mode=compile $(CC) -static $(CFLAGS) \
+                $(GRAPH_INCLUDES:%=$I%) \
+                $I$(subst /,$(COMPILER_SEP),$(GR_BATCH)) \
+                $T$(subst /,$(COMPILER_SEP),$@ $<)
+else
+       $(CC) $(CFLAGS) $(GRAPH_INCLUDES:%=$I%) \
+                $I$(subst /,$(COMPILER_SEP),$(GR_BATCH)) \
+                $T$(subst /,$(COMPILER_SEP),$@ $<)
+endif
+
+# EOF
diff --git a/graph/grinit.c b/graph/grinit.c
index 6fb9c38..7982d96 100644
--- a/graph/grinit.c
+++ b/graph/grinit.c
@@ -5,6 +5,10 @@
 #define GR_INIT_DEVICE_CHAIN   ((grDeviceChain*)0)
 #define GR_INIT_BUILD
 
+#ifdef DEVICE_BATCH
+#include "batch/grbatch.h"
+#endif
+
 #ifdef DEVICE_X11
 #ifndef VMS
 #include "x11/grx11.h"



reply via email to

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