Anurag Thakur pushed to branch gsoc-anurag-2022-final at FreeType / FreeType
Commits:
-
03cc2183
by Anurag Thakur at 2022-11-19T11:06:36+05:30
[dense] Enable module compilation
* src/dense/ftdense.c: Redefine FT_SWAP to fix compilation error
* src/include/freetype/config/ftmodule.h: Added ft_dense_renderer_class
* src/dense/dense.c: Build single object of module
* modules.cfg: Added 'dense' RASTER_MODULE
* src/dense/module.mk, src/dense/rules.mk: Added Makefile
* CMakeLists.txt: Added 'dense.c' to compilation files
7 changed files:
Changes:
CMakeLists.txt
... |
... |
@@ -405,6 +405,7 @@ set(BASE_SRCS |
405
|
405
|
src/cache/ftcache.c
|
406
|
406
|
src/cff/cff.c
|
407
|
407
|
src/cid/type1cid.c
|
|
408
|
+ src/dense/dense.c
|
408
|
409
|
src/gzip/ftgzip.c
|
409
|
410
|
src/lzw/ftlzw.c
|
410
|
411
|
src/pcf/pcf.c
|
include/freetype/config/ftmodule.h
... |
... |
@@ -24,6 +24,7 @@ FT_USE_MODULE( FT_Module_Class, psaux_module_class ) |
24
|
24
|
FT_USE_MODULE( FT_Module_Class, psnames_module_class )
|
25
|
25
|
FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
|
26
|
26
|
FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
|
|
27
|
+FT_USE_MODULE( FT_Renderer_Class, ft_dense_renderer_class )
|
27
|
28
|
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
|
28
|
29
|
FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
|
29
|
30
|
FT_USE_MODULE( FT_Renderer_Class, ft_sdf_renderer_class )
|
modules.cfg
... |
... |
@@ -93,6 +93,9 @@ HINTING_MODULES += pshinter |
93
|
93
|
#### raster modules -- at least one is required for vector font formats
|
94
|
94
|
####
|
95
|
95
|
|
|
96
|
+# Dense Rasterizer
|
|
97
|
+RASTER_MODULES += dense
|
|
98
|
+
|
96
|
99
|
# Anti-aliasing rasterizer.
|
97
|
100
|
RASTER_MODULES += smooth
|
98
|
101
|
|
src/dense/dense.c
1
|
1
|
/** For building a single object of the entire module */
|
|
2
|
+#define FT_MAKE_OPTION_SINGLE_OBJECT
|
2
|
3
|
|
3
|
|
-/* END */ |
|
|
\ No newline at end of file |
|
4
|
+#include "ftdense.c"
|
|
5
|
+#include "ftdenserend.c"
|
|
6
|
+/* END */ |
src/dense/ftdense.c
... |
... |
@@ -20,7 +20,7 @@ |
20
|
20
|
#define UPSCALE( x ) ( ( x ) * ( ONE_PIXEL >> 6 ) )
|
21
|
21
|
#define DOWNSCALE( x ) ( ( x ) >> ( PIXEL_BITS - 6 ) )
|
22
|
22
|
|
23
|
|
-#define FT_SWAP(a, b) ( (a) ^= (b) ^=(a) ^= (b))
|
|
23
|
+#define FT_SWAP(a, b) { (a) = (a) + (b); (b) = (a) - (b); (a) = (a) - (b);}
|
24
|
24
|
#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
|
25
|
25
|
#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
|
26
|
26
|
#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
|
... |
... |
@@ -256,17 +256,17 @@ dense_render_cubic( dense_worker* worker, |
256
|
256
|
FT_Vector aP2 = { control_2->x, control_2->y };
|
257
|
257
|
FT_Vector aP3 = { to->x, to->y };
|
258
|
258
|
|
259
|
|
- float devx = aP0.x - aP1->x - aP1->x + aP2->x;
|
260
|
|
- float devy = aP0.y - aP1->y - aP1->y + aP2->y;
|
|
259
|
+ float devx = aP0.x - aP1.x - aP1.x + aP2.x;
|
|
260
|
+ float devy = aP0.y - aP1.y - aP1.y + aP2.y;
|
261
|
261
|
float devsq0 = devx * devx + devy * devy;
|
262
|
|
- devx = aP1->x - aP2->x - aP2->x + aP3->x;
|
263
|
|
- devy = aP1->y - aP2->y - aP2->y + aP3->y;
|
|
262
|
+ devx = aP1.x - aP2.x - aP2.x + aP3.x;
|
|
263
|
+ devy = aP1.y - aP2.y - aP2.y + aP3.y;
|
264
|
264
|
float devsq1 = devx * devx + devy * devy;
|
265
|
265
|
float devsq = fmax( devsq0, devsq1 );
|
266
|
266
|
|
267
|
267
|
if ( devsq < 0.333f )
|
268
|
268
|
{
|
269
|
|
- dense_render_line( worker, aP3->x, aP3->y );
|
|
269
|
+ dense_render_line( worker, aP3.x, aP3.y );
|
270
|
270
|
return;
|
271
|
271
|
}
|
272
|
272
|
|
... |
... |
@@ -278,8 +278,8 @@ dense_render_cubic( dense_worker* worker, |
278
|
278
|
for ( int i = 0; i < n; i++ )
|
279
|
279
|
{
|
280
|
280
|
t += nrecip;
|
281
|
|
- FT_Vector a = Lerp( t, Lerp( t, aP0, *aP1 ), Lerp( t, *aP1, *aP2 ) );
|
282
|
|
- FT_Vector b = Lerp( t, Lerp( t, *aP1, *aP2 ), Lerp( t, *aP2, *aP3 ) );
|
|
281
|
+ FT_Vector a = Lerp( t, Lerp( t, aP0, aP1 ), Lerp( t, aP1, aP2 ) );
|
|
282
|
+ FT_Vector b = Lerp( t, Lerp( t, aP1, aP2 ), Lerp( t, aP2, aP3 ) );
|
283
|
283
|
FT_Vector next = Lerp( t, a, b );
|
284
|
284
|
dense_render_line( worker, next.x, next.y );
|
285
|
285
|
worker->prev_x = next.x;
|
src/dense/module.mk
|
1
|
+#
|
|
2
|
+# FreeType 2 smooth renderer module definition
|
|
3
|
+#
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+# Copyright (C) 1996-2021 by
|
|
7
|
+# David Turner, Robert Wilhelm, and Werner Lemberg.
|
|
8
|
+#
|
|
9
|
+# This file is part of the FreeType project, and may only be used, modified,
|
|
10
|
+# and distributed under the terms of the FreeType project license,
|
|
11
|
+# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
|
12
|
+# indicate that you have read the license and understand and accept it
|
|
13
|
+# fully.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+FTMODULE_H_COMMANDS += DENSE_RENDERER
|
|
17
|
+
|
|
18
|
+define DENSE_RENDERER
|
|
19
|
+$(OPEN_DRIVER) FT_Renderer_Class, ft_dense_renderer_class $(CLOSE_DRIVER)
|
|
20
|
+$(ECHO_DRIVER)dense $(ECHO_DRIVER_DESC)anti-aliased dense renderer$(ECHO_DRIVER_DONE)
|
|
21
|
+endef
|
|
22
|
+
|
|
23
|
+# EOF |
src/dense/rules.mk
|
1
|
+#
|
|
2
|
+# FreeType 2 DENSE renderer module build rules
|
|
3
|
+#
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+# Copyright (C) 1996-2021 by
|
|
7
|
+# David Turner, Robert Wilhelm, and Werner Lemberg.
|
|
8
|
+#
|
|
9
|
+# This file is part of the FreeType project, and may only be used, modified,
|
|
10
|
+# and distributed under the terms of the FreeType project license,
|
|
11
|
+# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
|
12
|
+# indicate that you have read the license and understand and accept it
|
|
13
|
+# fully.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+# DENSE driver directory
|
|
17
|
+#
|
|
18
|
+DENSE_DIR := $(SRC_DIR)/dense
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+# compilation flags for the driver
|
|
22
|
+#
|
|
23
|
+DENSE_COMPILE := $(CC) $(ANSIFLAGS) \
|
|
24
|
+ $I$(subst /,$(COMPILER_SEP),$(DENSE_DIR)) \
|
|
25
|
+ $(INCLUDE_FLAGS) \
|
|
26
|
+ $(FT_CFLAGS)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+# DENSE driver sources (i.e., C files)
|
|
30
|
+#
|
|
31
|
+DENSE_DRV_SRC := $(DENSE_DIR)/ftdense.c \
|
|
32
|
+ $(DENSE_DIR)/ftdenserend.c
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+# DENSE driver headers
|
|
36
|
+#
|
|
37
|
+DENSE_DRV_H := $(DENSE_DRV_SRC:%c=%h) \
|
|
38
|
+ $(DENSE_DIR)/ftdenseerrs.h
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+# DENSE driver object(s)
|
|
42
|
+#
|
|
43
|
+# DENSE_DRV_OBJ_M is used during `multi' builds.
|
|
44
|
+# DENSE_DRV_OBJ_S is used during `single' builds.
|
|
45
|
+#
|
|
46
|
+DENSE_DRV_OBJ_M := $(DENSE_DRV_SRC:$(DENSE_DIR)/%.c=$(OBJ_DIR)/%.$O)
|
|
47
|
+DENSE_DRV_OBJ_S := $(OBJ_DIR)/dense.$O
|
|
48
|
+
|
|
49
|
+# DENSE driver source file for single build
|
|
50
|
+#
|
|
51
|
+DENSE_DRV_SRC_S := $(DENSE_DIR)/dense.c
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+# DENSE driver - single object
|
|
55
|
+#
|
|
56
|
+$(DENSE_DRV_OBJ_S): $(DENSE_DRV_SRC_S) $(DENSE_DRV_SRC) \
|
|
57
|
+ $(FREETYPE_H) $(DENSE_DRV_H)
|
|
58
|
+ $(DENSE_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(DENSE_DRV_SRC_S))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+# DENSE driver - multiple objects
|
|
62
|
+#
|
|
63
|
+$(OBJ_DIR)/%.$O: $(DENSE_DIR)/%.c $(FREETYPE_H) $(DENSE_DRV_H)
|
|
64
|
+ $(DENSE_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+# update main driver object lists
|
|
68
|
+#
|
|
69
|
+DRV_OBJS_S += $(DENSE_DRV_OBJ_S)
|
|
70
|
+DRV_OBJS_M += $(DENSE_DRV_OBJ_M)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+# EOF |
|