1
|
1
|
/** The rasterizer for the 'dense' renderer */
|
2
|
2
|
|
3
|
|
-/* END */ |
|
|
\ No newline at end of file |
|
3
|
+#undef FT_COMPONENT
|
|
4
|
+#define FT_COMPONENT dense
|
|
5
|
+
|
|
6
|
+#include <freetype/ftoutln.h>
|
|
7
|
+#include <freetype/internal/ftcalc.h>
|
|
8
|
+#include <freetype/internal/ftdebug.h>
|
|
9
|
+#include <freetype/internal/ftobjs.h>
|
|
10
|
+#include <math.h>
|
|
11
|
+
|
|
12
|
+#include "ftdense.h"
|
|
13
|
+#include "ftdenseerrs.h"
|
|
14
|
+
|
|
15
|
+#define PIXEL_BITS 8
|
|
16
|
+
|
|
17
|
+#define ONE_PIXEL ( 1 << PIXEL_BITS )
|
|
18
|
+#define TRUNC( x ) (int)( ( x ) >> PIXEL_BITS )
|
|
19
|
+
|
|
20
|
+#define UPSCALE( x ) ( ( x ) * ( ONE_PIXEL >> 6 ) )
|
|
21
|
+#define DOWNSCALE( x ) ( ( x ) >> ( PIXEL_BITS - 6 ) )
|
|
22
|
+
|
|
23
|
+#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
|
|
24
|
+#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
|
|
25
|
+#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+typedef struct dense_TRaster_
|
|
29
|
+{
|
|
30
|
+ void* memory;
|
|
31
|
+
|
|
32
|
+} dense_TRaster, *dense_PRaster;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+static int
|
|
36
|
+dense_move_to( const FT_Vector* to, dense_worker* worker )
|
|
37
|
+{
|
|
38
|
+ FT_Pos x, y;
|
|
39
|
+
|
|
40
|
+ x = UPSCALE( to->x );
|
|
41
|
+ y = UPSCALE( to->y );
|
|
42
|
+ worker->prev_x = x;
|
|
43
|
+ worker->prev_y = y;
|
|
44
|
+ return 0;
|
|
45
|
+}
|
|
46
|
+
|
|
47
|
+static int
|
|
48
|
+dense_line_to( const FT_Vector* to, dense_worker* worker )
|
|
49
|
+{
|
|
50
|
+ dense_render_line( worker, UPSCALE( to->x ), UPSCALE( to->y ) );
|
|
51
|
+ dense_move_to( to, worker );
|
|
52
|
+ return 0;
|
|
53
|
+}
|
|
54
|
+
|
|
55
|
+void
|
|
56
|
+dense_render_line( dense_worker* worker, TPos tox, TPos toy )
|
|
57
|
+{
|
|
58
|
+ return;
|
|
59
|
+}
|
|
60
|
+
|
|
61
|
+static int
|
|
62
|
+dense_conic_to( const FT_Vector* control,
|
|
63
|
+ const FT_Vector* to,
|
|
64
|
+ dense_worker* worker )
|
|
65
|
+{
|
|
66
|
+ dense_render_quadratic( worker, control, to );
|
|
67
|
+ return 0;
|
|
68
|
+}
|
|
69
|
+
|
|
70
|
+void
|
|
71
|
+dense_render_quadratic( dense_worker* worker,
|
|
72
|
+ FT_Vector* control,
|
|
73
|
+ FT_Vector* to )
|
|
74
|
+{
|
|
75
|
+ return;
|
|
76
|
+}
|
|
77
|
+
|
|
78
|
+static int
|
|
79
|
+dense_cubic_to( const FT_Vector* control1,
|
|
80
|
+ const FT_Vector* control2,
|
|
81
|
+ const FT_Vector* to,
|
|
82
|
+ dense_worker* worker )
|
|
83
|
+{
|
|
84
|
+ dense_render_cubic( worker, control1, control2, to );
|
|
85
|
+ return 0;
|
|
86
|
+}
|
|
87
|
+
|
|
88
|
+void
|
|
89
|
+dense_render_cubic( dense_worker* worker,
|
|
90
|
+ FT_Vector* control_1,
|
|
91
|
+ FT_Vector* control_2,
|
|
92
|
+ FT_Vector* to )
|
|
93
|
+{
|
|
94
|
+ return;
|
|
95
|
+}
|
|
96
|
+
|
|
97
|
+static int
|
|
98
|
+dense_raster_new( FT_Memory memory, dense_PRaster* araster )
|
|
99
|
+{
|
|
100
|
+ FT_Error error;
|
|
101
|
+ dense_PRaster raster;
|
|
102
|
+
|
|
103
|
+ if ( !FT_NEW( raster ) )
|
|
104
|
+ raster->memory = memory;
|
|
105
|
+
|
|
106
|
+ *araster = raster;
|
|
107
|
+ return error;
|
|
108
|
+}
|
|
109
|
+
|
|
110
|
+static void
|
|
111
|
+dense_raster_done( FT_Raster raster )
|
|
112
|
+{
|
|
113
|
+ FT_Memory memory = (FT_Memory)( (dense_PRaster)raster )->memory;
|
|
114
|
+
|
|
115
|
+ FT_FREE( raster );
|
|
116
|
+}
|
|
117
|
+
|
|
118
|
+static void
|
|
119
|
+dense_raster_reset( FT_Raster raster,
|
|
120
|
+ unsigned char* pool_base,
|
|
121
|
+ unsigned long pool_size )
|
|
122
|
+{
|
|
123
|
+ FT_UNUSED( raster );
|
|
124
|
+ FT_UNUSED( pool_base );
|
|
125
|
+ FT_UNUSED( pool_size );
|
|
126
|
+}
|
|
127
|
+
|
|
128
|
+static int
|
|
129
|
+dense_raster_set_mode( FT_Raster raster, unsigned long mode, void* args )
|
|
130
|
+{
|
|
131
|
+ FT_UNUSED( raster );
|
|
132
|
+ FT_UNUSED( mode );
|
|
133
|
+ FT_UNUSED( args );
|
|
134
|
+
|
|
135
|
+ return 0; /* nothing to do */
|
|
136
|
+}
|
|
137
|
+
|
|
138
|
+FT_DEFINE_OUTLINE_FUNCS( dense_decompose_funcs,
|
|
139
|
+
|
|
140
|
+ (FT_Outline_MoveTo_Func)dense_move_to, /* move_to */
|
|
141
|
+ (FT_Outline_LineTo_Func)dense_line_to, /* line_to */
|
|
142
|
+ (FT_Outline_ConicTo_Func)dense_conic_to, /* conic_to */
|
|
143
|
+ (FT_Outline_CubicTo_Func)dense_cubic_to, /* cubic_to */
|
|
144
|
+
|
|
145
|
+ 0, /* shift */
|
|
146
|
+ 0 /* delta */
|
|
147
|
+)
|
|
148
|
+
|
|
149
|
+static int
|
|
150
|
+dense_render_glyph( dense_worker* worker, const FT_Bitmap* target )
|
|
151
|
+{
|
|
152
|
+ FT_Error error = FT_Outline_Decompose( &( worker->outline ),
|
|
153
|
+ &dense_decompose_funcs, worker );
|
|
154
|
+ return error;
|
|
155
|
+}
|
|
156
|
+
|
|
157
|
+static int
|
|
158
|
+dense_raster_render( FT_Raster raster, const FT_Raster_Params* params )
|
|
159
|
+{
|
|
160
|
+ return 0;
|
|
161
|
+}
|
|
162
|
+
|
|
163
|
+FT_DEFINE_RASTER_FUNCS(
|
|
164
|
+ ft_dense_raster,
|
|
165
|
+
|
|
166
|
+ FT_GLYPH_FORMAT_OUTLINE,
|
|
167
|
+
|
|
168
|
+ (FT_Raster_New_Func)dense_raster_new, /* raster_new */
|
|
169
|
+ (FT_Raster_Reset_Func)dense_raster_reset, /* raster_reset */
|
|
170
|
+ (FT_Raster_Set_Mode_Func)dense_raster_set_mode, /* raster_set_mode */
|
|
171
|
+ (FT_Raster_Render_Func)dense_raster_render, /* raster_render */
|
|
172
|
+ (FT_Raster_Done_Func)dense_raster_done /* raster_done */
|
|
173
|
+)
|
|
174
|
+
|
|
175
|
+/* END */ |