[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] anuj-distance-field ab8d18f 01/95: added the structure of ne
From: |
Anuj Verma |
Subject: |
[freetype2] anuj-distance-field ab8d18f 01/95: added the structure of new `sdf' module |
Date: |
Sun, 2 Aug 2020 01:10:23 -0400 (EDT) |
branch: anuj-distance-field
commit ab8d18f149274b219abf11f9d4e3632728fb0b1c
Author: preversewharf45 <preverse45you@gmail.com>
Commit: Anuj Verma <anujv@iitbhilai.ac.in>
added the structure of new `sdf' module
---
CMakeLists.txt | 1 +
[GSoC]ChangeLog | 23 +++++++++
include/freetype/config/ftmodule.h | 1 +
include/freetype/ftmoderr.h | 1 +
modules.cfg | 2 +
src/sdf/ftsdf.c | 73 +++++++++++++++++++++++++++++
src/sdf/ftsdf.h | 17 +++++++
src/sdf/ftsdferrs.h | 18 ++++++++
src/sdf/ftsdfrend.c | 95 ++++++++++++++++++++++++++++++++++++++
src/sdf/ftsdfrend.h | 20 ++++++++
src/sdf/module.mk | 10 ++++
src/sdf/rules.mk | 58 +++++++++++++++++++++++
src/sdf/sdf.c | 9 ++++
13 files changed, 328 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c9befb4..aa63602 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -347,6 +347,7 @@ set(BASE_SRCS
src/pshinter/pshinter.c
src/psnames/psnames.c
src/raster/raster.c
+ src/sdf/sdf.c
src/sfnt/sfnt.c
src/smooth/smooth.c
src/truetype/truetype.c
diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog
new file mode 100644
index 0000000..d592bd8
--- /dev/null
+++ b/[GSoC]ChangeLog
@@ -0,0 +1,23 @@
+2020-06-18 Anuj Verma <anujv@iitbhilai.ac.in>
+
+ [sdf] Added the structure of a new module to render
+ signed distance fields.
+
+ * src/sdf/sdf.c, src/sdf/ftsdfrend.c, src/sdf/ftsdf.c,
+ src/sdf/ftsdfrend.h, src/sdf/ftsdf.h, src/sdf/ftsdferrs.h:
+ Added files required by the `sdf' renderer module and added
+ the basic structure and functions required.
+
+ * src/sdf/rules.mk, src/sdf/module.mk: Added files required to
+ build the `sdf' module using the default build system.
+
+ * CMakeLists.txt (`BASE_SRCS'): Add `src/sdf/sdf.c' to the variable.
+
+ * include/freetype/config/ftmodule.h: Added `sdf' module
+ declaration so that the module can be added when not compiling
+ with GNU make.
+
+ * modules.cfg (RASTER_MODULES): Include `sdf' module to the default
+ rasterizer module list.
+
+ * include/freetype/ftmoderr.h: sdf module error define
\ No newline at end of file
diff --git a/include/freetype/config/ftmodule.h
b/include/freetype/config/ftmodule.h
index b5c4b1e..81b6655 100644
--- a/include/freetype/config/ftmodule.h
+++ b/include/freetype/config/ftmodule.h
@@ -26,5 +26,6 @@ FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
+FT_USE_MODULE( FT_Renderer_Class, ft_sdf_renderer_class )
/* EOF */
diff --git a/include/freetype/ftmoderr.h b/include/freetype/ftmoderr.h
index f05fc53..b2c7d60 100644
--- a/include/freetype/ftmoderr.h
+++ b/include/freetype/ftmoderr.h
@@ -171,6 +171,7 @@
FT_MODERRDEF( Type42, 0x1400, "Type 42 module" )
FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" )
FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" )
+ FT_MODERRDEF( Sdf, 0x1700, "signed distance field raster module" )
#ifdef FT_MODERR_END_LIST
diff --git a/modules.cfg b/modules.cfg
index d6cdbe5..d64c5ff 100644
--- a/modules.cfg
+++ b/modules.cfg
@@ -99,6 +99,8 @@ RASTER_MODULES += raster
# Anti-aliasing rasterizer.
RASTER_MODULES += smooth
+# Signed distance field rasterizer.
+RASTER_MODULES += sdf
####
#### auxiliary modules
diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c
new file mode 100644
index 0000000..b4b5c48
--- /dev/null
+++ b/src/sdf/ftsdf.c
@@ -0,0 +1,73 @@
+
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/ftdebug.h>
+#include "ftsdf.h"
+
+#include "ftsdferrs.h"
+
+ static int
+ sdf_raster_new( FT_Memory memory,
+ FT_Raster* araster)
+ {
+ FT_Error error = FT_THROW( Unimplemented_Feature );
+
+
+ FT_UNUSED( memory );
+ FT_UNUSED( araster );
+
+ return error;
+ }
+
+ static void
+ sdf_raster_reset( FT_Raster raster,
+ unsigned char* pool_base,
+ unsigned long pool_size )
+ {
+ FT_UNUSED( raster );
+ FT_UNUSED( pool_base );
+ FT_UNUSED( pool_size );
+ }
+
+ static int
+ sdf_raster_set_mode( FT_Raster raster,
+ unsigned long mode,
+ void* args )
+ {
+ FT_UNUSED( raster );
+ FT_UNUSED( mode );
+ FT_UNUSED( args );
+
+
+ return 0;
+ }
+
+ static int
+ sdf_raster_render( FT_Raster raster,
+ const FT_Raster_Params* params )
+ {
+ FT_UNUSED( raster );
+ FT_UNUSED( params );
+
+
+ return 0;
+ }
+
+ static void
+ sdf_raster_done( FT_Raster raster )
+ {
+ FT_UNUSED( raster );
+ }
+
+ FT_DEFINE_RASTER_FUNCS(
+ ft_sdf_raster,
+
+ FT_GLYPH_FORMAT_OUTLINE,
+
+ (FT_Raster_New_Func) sdf_raster_new, /* raster_new */
+ (FT_Raster_Reset_Func) sdf_raster_reset, /* raster_reset */
+ (FT_Raster_Set_Mode_Func) sdf_raster_set_mode, /* raster_set_mode */
+ (FT_Raster_Render_Func) sdf_raster_render, /* raster_render */
+ (FT_Raster_Done_Func) sdf_raster_done /* raster_done */
+ )
+
+/* END */
diff --git a/src/sdf/ftsdf.h b/src/sdf/ftsdf.h
new file mode 100644
index 0000000..c88efd2
--- /dev/null
+++ b/src/sdf/ftsdf.h
@@ -0,0 +1,17 @@
+
+#ifndef FTSDF_H_
+#define FTSDF_H_
+
+#include <ft2build.h>
+#include FT_CONFIG_CONFIG_H
+#include <freetype/ftimage.h>
+
+FT_BEGIN_HEADER
+
+ FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_sdf_raster;
+
+FT_END_HEADER
+
+#endif /* FTSDF_H_ */
+
+/* END */
diff --git a/src/sdf/ftsdferrs.h b/src/sdf/ftsdferrs.h
new file mode 100644
index 0000000..ea63af0
--- /dev/null
+++ b/src/sdf/ftsdferrs.h
@@ -0,0 +1,18 @@
+
+#ifndef FTSDFERRS_H_
+#define FTSDFERRS_H_
+
+#include <freetype/ftmoderr.h>
+
+#undef FTERRORS_H_
+
+#undef FT_ERR_PREFIX
+#define FT_ERR_PREFIX Sdf_Err_
+#define FT_ERR_BASE FT_Mod_Err_Sdf
+
+#include <freetype/fterrors.h>
+
+#endif /* FTSDFERRS_H_ */
+
+
+/* END */
diff --git a/src/sdf/ftsdfrend.c b/src/sdf/ftsdfrend.c
new file mode 100644
index 0000000..6264169
--- /dev/null
+++ b/src/sdf/ftsdfrend.c
@@ -0,0 +1,95 @@
+
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftobjs.h>
+#include "ftsdfrend.h"
+#include "ftsdf.h"
+
+#include "ftsdferrs.h"
+
+
+ static FT_Error
+ ft_sdf_render( FT_Renderer render,
+ FT_GlyphSlot slot,
+ FT_Render_Mode mode,
+ const FT_Vector* origin )
+ {
+ FT_Error error = FT_THROW( Unimplemented_Feature );
+
+
+ FT_UNUSED( render );
+ FT_UNUSED( slot );
+ FT_UNUSED( mode );
+ FT_UNUSED( origin );
+
+ return error;
+ }
+
+ static FT_Error
+ ft_sdf_transform( FT_Renderer render,
+ FT_GlyphSlot slot,
+ const FT_Matrix* matrix,
+ const FT_Vector* delta )
+ {
+ FT_Error error = FT_THROW( Unimplemented_Feature );
+
+
+ FT_UNUSED( render );
+ FT_UNUSED( slot );
+ FT_UNUSED( matrix );
+ FT_UNUSED( delta );
+
+ return error;
+ }
+
+ static void
+ ft_sdf_get_cbox( FT_Renderer render,
+ FT_GlyphSlot slot,
+ FT_BBox* cbox )
+ {
+ FT_UNUSED( render );
+ FT_UNUSED( slot );
+ FT_UNUSED( cbox );
+ }
+
+ static FT_Error
+ ft_sdf_set_mode( FT_Renderer render,
+ FT_ULong mode_tag,
+ FT_Pointer data )
+ {
+ FT_Error error = FT_THROW( Unimplemented_Feature );
+
+
+ FT_UNUSED( render );
+ FT_UNUSED( mode_tag );
+ FT_UNUSED( data );
+
+ return error;
+ }
+
+ FT_DEFINE_RENDERER(
+ ft_sdf_renderer_class,
+
+ FT_MODULE_RENDERER,
+ sizeof( FT_RendererRec ),
+
+ "sdf",
+ 0x10000L,
+ 0x20000L,
+
+ NULL,
+
+ (FT_Module_Constructor) NULL,
+ (FT_Module_Destructor) NULL,
+ (FT_Module_Requester) NULL,
+
+ FT_GLYPH_FORMAT_OUTLINE,
+
+ (FT_Renderer_RenderFunc) ft_sdf_render, /* render_glyph */
+ (FT_Renderer_TransformFunc)ft_sdf_transform, /* transform_glyph */
+ (FT_Renderer_GetCBoxFunc) ft_sdf_get_cbox, /* get_glyph_cbox */
+ (FT_Renderer_SetModeFunc) ft_sdf_set_mode, /* set_mode */
+
+ (FT_Raster_Funcs*)&ft_sdf_raster /* raster_class */
+ )
+
+/* END */
diff --git a/src/sdf/ftsdfrend.h b/src/sdf/ftsdfrend.h
new file mode 100644
index 0000000..b07a806
--- /dev/null
+++ b/src/sdf/ftsdfrend.h
@@ -0,0 +1,20 @@
+
+#ifndef FTSDFREND_H_
+#define FTSDFREND_H_
+
+
+#include <freetype/ftrender.h>
+
+
+FT_BEGIN_HEADER
+
+
+ FT_DECLARE_RENDERER( ft_sdf_renderer_class )
+
+
+FT_END_HEADER
+
+#endif /* FTSDFREND_H_ */
+
+
+/* END */
\ No newline at end of file
diff --git a/src/sdf/module.mk b/src/sdf/module.mk
new file mode 100644
index 0000000..7d66c3c
--- /dev/null
+++ b/src/sdf/module.mk
@@ -0,0 +1,10 @@
+
+
+FTMODULE_H_COMMANDS += SDF_RENDERER
+
+define SDF_RENDERER
+$(OPEN_DRIVER) FT_Renderer_Class, ft_sdf_renderer_class $(CLOSE_DRIVER)
+$(ECHO_DRIVER)sdf $(ECHO_DRIVER_DESC) signed distance field renderer
$(ECHO_DRIVER_DONE)
+endef
+
+#EOF
\ No newline at end of file
diff --git a/src/sdf/rules.mk b/src/sdf/rules.mk
new file mode 100644
index 0000000..7785b7f
--- /dev/null
+++ b/src/sdf/rules.mk
@@ -0,0 +1,58 @@
+
+
+# sdf driver directory
+#
+SDF_DIR := $(SRC_DIR)/sdf
+
+
+# compilation flags for the driver
+#
+SDF_COMPILE := $(CC) $(ANSIFLAGS) \
+ $I$(subst /,$(COMPILER_SEP),$(SDF_DIR)) \
+ $(INCLUDE_FLAGS) \
+ $(FT_CFLAGS)
+
+
+# sdf driver sources (i.e., C files)
+#
+SDF_DRV_SRC := $(SDF_DIR)/ftsdfrend.c \
+ $(SDF_DIR)/ftsdf.c
+
+
+# sdf driver headers
+#
+SDF_DRV_H := $(SDF_DRV_SRC:%.c=%.h) \
+ $(SDF_DIR)/ftsdferrs.h
+
+
+# sdf driver object(s)
+#
+# SDF_DRV_OBJ_M is used during `multi' builds.
+# SDF_DRV_OBJ_S is used during `single' builds.
+#
+SDF_DRV_OBJ_M := $(SDF_DRV_SRC:$(SDF_DIR)/%.c=$(OBJ_DIR)/%.$O)
+SDF_DRV_OBJ_S := $(OBJ_DIR)/sdf.$O
+
+
+# sdf driver source file for single build
+#
+SDF_DRV_SRC_S := $(SDF_DIR)/sdf.c
+
+
+# sdf driver - single object
+#
+$(SDF_DRV_OBJ_S): $(SDF_DRV_SRC_S) $(SDF_DRV_SRC) \
+ $(FREETYPE_H) $(SDF_DRV_H)
+ $(SDF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(SDF_DRV_SRC_S))
+
+
+# sdf driver - multiple objects
+#
+$(OBJ_DIR)/%.$O: $(SDF_DIR)/%.c $(FREETYPE_H) $(SDF_DRV_H)
+ $(SDF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
+
+
+# update main driver list
+#
+DRV_OBJ_S += $(SDF_DRV_OBJ_S)
+DRV_OBJ_M += $(SDF_DRV_OBJ_M)
\ No newline at end of file
diff --git a/src/sdf/sdf.c b/src/sdf/sdf.c
new file mode 100644
index 0000000..5481c8f
--- /dev/null
+++ b/src/sdf/sdf.c
@@ -0,0 +1,9 @@
+
+
+#define FT_MAKE_OPTION_SINGLE_OBJECT
+
+#include "ftsdfrend.c"
+#include "ftsdf.c"
+
+
+/* END */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] anuj-distance-field ab8d18f 01/95: added the structure of new `sdf' module,
Anuj Verma <=