ReactOS 0.4.15-dev-7788-g1ad9096
ftsmooth.c File Reference
#include <ft2build.h>
#include "ftsmooth.h"
#include "ftgrays.h"
#include "ftspic.h"
#include "ftsmerrs.h"
Include dependency graph for ftsmooth.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static FT_Error ft_smooth_init (FT_Renderer render)
 
static FT_Error ft_smooth_set_mode (FT_Renderer render, FT_ULong mode_tag, FT_Pointer data)
 
static FT_Error ft_smooth_transform (FT_Renderer render, FT_GlyphSlot slot, const FT_Matrix *matrix, const FT_Vector *delta)
 
static void ft_smooth_get_cbox (FT_Renderer render, FT_GlyphSlot slot, FT_BBox *cbox)
 
static FT_Error ft_smooth_render_generic (FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector *origin, FT_Render_Mode required_mode)
 
static FT_Error ft_smooth_render (FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector *origin)
 
static FT_Error ft_smooth_render_lcd (FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector *origin)
 
static FT_Error ft_smooth_render_lcd_v (FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector *origin)
 
 FT_DEFINE_RENDERER (ft_smooth_renderer_class, FT_MODULE_RENDERER, sizeof(FT_RendererRec), "smooth", 0x10000L, 0x20000L, NULL,(FT_Module_Constructor) ft_smooth_init,(FT_Module_Destructor) NULL,(FT_Module_Requester) NULL, FT_GLYPH_FORMAT_OUTLINE,(FT_Renderer_RenderFunc) ft_smooth_render,(FT_Renderer_TransformFunc) ft_smooth_transform,(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,(FT_Renderer_SetModeFunc) ft_smooth_set_mode,(FT_Raster_Funcs *)&FT_GRAYS_RASTER_GET) FT_DEFINE_RENDERER(ft_smooth_lcd_renderer_class
 
 sizeof (FT_RendererRec)
 

Variables

 FT_MODULE_RENDERER
 
smooth lcd
 
smooth NULL
 
smooth FT_Module_Constructor ft_smooth_init
 
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_GLYPH_FORMAT_OUTLINE
 
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_Renderer_RenderFunc ft_smooth_render_lcd
 
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_Renderer_RenderFunc FT_Renderer_TransformFunc ft_smooth_transform
 
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_Renderer_RenderFunc FT_Renderer_TransformFunc FT_Renderer_GetCBoxFunc ft_smooth_get_cbox
 
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_Renderer_RenderFunc FT_Renderer_TransformFunc FT_Renderer_GetCBoxFunc FT_Renderer_SetModeFunc ft_smooth_set_mode
 

Function Documentation

◆ FT_DEFINE_RENDERER()

FT_DEFINE_RENDERER ( ft_smooth_renderer_class  ,
FT_MODULE_RENDERER  ,
sizeof(FT_RendererRec ,
"smooth"  ,
0x10000L  ,
0x20000L  ,
NULL  ,
(FT_Module_Constructor ft_smooth_init,
(FT_Module_Destructor NULL,
(FT_Module_Requester NULL,
FT_GLYPH_FORMAT_OUTLINE  ,
(FT_Renderer_RenderFunc ft_smooth_render,
(FT_Renderer_TransformFunc ft_smooth_transform,
(FT_Renderer_GetCBoxFunc ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc ft_smooth_set_mode,
(FT_Raster_Funcs *)&  FT_GRAYS_RASTER_GET 
)

◆ ft_smooth_get_cbox()

static void ft_smooth_get_cbox ( FT_Renderer  render,
FT_GlyphSlot  slot,
FT_BBox cbox 
)
static

Definition at line 81 of file ftsmooth.c.

84 {
85 FT_ZERO( cbox );
86
87 if ( slot->format == render->glyph_format )
88 FT_Outline_Get_CBox( &slot->outline, cbox );
89 }
#define FT_ZERO(p)
Definition: ftmemory.h:237
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
Definition: ftoutln.c:478
static void render(void)
Definition: ssstars.c:272
Definition: vfat.h:185

◆ ft_smooth_init()

static FT_Error ft_smooth_init ( FT_Renderer  render)
static

Definition at line 32 of file ftsmooth.c.

33 {
34 render->clazz->raster_class->raster_reset( render->raster, NULL, 0 );
35
36 return 0;
37 }
smooth NULL
Definition: ftsmooth.c:417

◆ ft_smooth_render()

static FT_Error ft_smooth_render ( FT_Renderer  render,
FT_GlyphSlot  slot,
FT_Render_Mode  mode,
const FT_Vector origin 
)
static

Definition at line 346 of file ftsmooth.c.

350 {
351 if ( mode == FT_RENDER_MODE_LIGHT )
353
356 }
@ FT_RENDER_MODE_NORMAL
Definition: freetype.h:3234
@ FT_RENDER_MODE_LIGHT
Definition: freetype.h:3235
static FT_Error ft_smooth_render_generic(FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector *origin, FT_Render_Mode required_mode)
Definition: ftsmooth.c:94
GLenum mode
Definition: glext.h:6217
voidpf uLong int origin
Definition: ioapi.h:144

◆ ft_smooth_render_generic()

static FT_Error ft_smooth_render_generic ( FT_Renderer  render,
FT_GlyphSlot  slot,
FT_Render_Mode  mode,
const FT_Vector origin,
FT_Render_Mode  required_mode 
)
static

Definition at line 94 of file ftsmooth.c.

99 {
101 FT_Outline* outline = &slot->outline;
102 FT_Bitmap* bitmap = &slot->bitmap;
103 FT_Memory memory = render->root.memory;
104 FT_Pos x_shift = 0;
105 FT_Pos y_shift = 0;
106 FT_Int hmul = ( mode == FT_RENDER_MODE_LCD );
107 FT_Int vmul = ( mode == FT_RENDER_MODE_LCD_V );
108
110
111
112 /* check glyph image format */
113 if ( slot->format != render->glyph_format )
114 {
115 error = FT_THROW( Invalid_Argument );
116 goto Exit;
117 }
118
119 /* check mode */
120 if ( mode != required_mode )
121 {
122 error = FT_THROW( Cannot_Render_Glyph );
123 goto Exit;
124 }
125
126 /* release old bitmap buffer */
127 if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
128 {
129 FT_FREE( bitmap->buffer );
130 slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
131 }
132
134
135 /* allocate new one */
136 if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
137 goto Exit;
138
139 slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
140
141 x_shift = 64 * -slot->bitmap_left;
142 y_shift = 64 * -slot->bitmap_top;
143 if ( bitmap->pixel_mode == FT_PIXEL_MODE_LCD_V )
144 y_shift += 64 * (FT_Int)bitmap->rows / 3;
145 else
146 y_shift += 64 * (FT_Int)bitmap->rows;
147
148 if ( origin )
149 {
150 x_shift += origin->x;
151 y_shift += origin->y;
152 }
153
154 /* translate outline to render it into the bitmap */
155 if ( x_shift || y_shift )
156 FT_Outline_Translate( outline, x_shift, y_shift );
157
158 /* set up parameters */
159 params.target = bitmap;
160 params.source = outline;
162
163#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
164
165 /* implode outline if needed */
166 {
167 FT_Vector* points = outline->points;
168 FT_Vector* points_end = points + outline->n_points;
169 FT_Vector* vec;
170
171
172 if ( hmul )
173 for ( vec = points; vec < points_end; vec++ )
174 vec->x *= 3;
175
176 if ( vmul )
177 for ( vec = points; vec < points_end; vec++ )
178 vec->y *= 3;
179 }
180
181 /* render outline into the bitmap */
182 error = render->raster_render( render->raster, &params );
183
184 /* deflate outline if needed */
185 {
186 FT_Vector* points = outline->points;
187 FT_Vector* points_end = points + outline->n_points;
188 FT_Vector* vec;
189
190
191 if ( hmul )
192 for ( vec = points; vec < points_end; vec++ )
193 vec->x /= 3;
194
195 if ( vmul )
196 for ( vec = points; vec < points_end; vec++ )
197 vec->y /= 3;
198 }
199
200 if ( error )
201 goto Exit;
202
203 /* finally apply filtering */
204 if ( hmul || vmul )
205 {
206 FT_Byte* lcd_weights;
207 FT_Bitmap_LcdFilterFunc lcd_filter_func;
208
209
210 /* Per-face LCD filtering takes priority if set up. */
211 if ( slot->face && slot->face->internal->lcd_filter_func )
212 {
213 lcd_weights = slot->face->internal->lcd_weights;
214 lcd_filter_func = slot->face->internal->lcd_filter_func;
215 }
216 else
217 {
218 lcd_weights = slot->library->lcd_weights;
219 lcd_filter_func = slot->library->lcd_filter_func;
220 }
221
222 if ( lcd_filter_func )
223 lcd_filter_func( bitmap, mode, lcd_weights );
224 }
225
226#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
227
228 if ( hmul ) /* lcd */
229 {
230 FT_Byte* line;
231 FT_Byte* temp = NULL;
232 FT_UInt i, j;
233
234 unsigned int height = bitmap->rows;
235 unsigned int width = bitmap->width;
236 int pitch = bitmap->pitch;
237
238
239 /* Render 3 separate monochrome bitmaps, shifting the outline */
240 /* by 1/3 pixel. */
241 width /= 3;
242
243 bitmap->buffer += width;
244
245 error = render->raster_render( render->raster, &params );
246 if ( error )
247 goto Exit;
248
249 FT_Outline_Translate( outline, -21, 0 );
250 x_shift -= 21;
251 bitmap->buffer += width;
252
253 error = render->raster_render( render->raster, &params );
254 if ( error )
255 goto Exit;
256
258 x_shift += 42;
259 bitmap->buffer -= 2 * width;
260
261 error = render->raster_render( render->raster, &params );
262 if ( error )
263 goto Exit;
264
265 /* XXX: Rearrange the bytes according to FT_PIXEL_MODE_LCD. */
266 /* XXX: It is more efficient to render every third byte above. */
267
268 if ( FT_ALLOC( temp, (FT_ULong)pitch ) )
269 goto Exit;
270
271 for ( i = 0; i < height; i++ )
272 {
273 line = bitmap->buffer + i * (FT_ULong)pitch;
274 for ( j = 0; j < width; j++ )
275 {
276 temp[3 * j ] = line[j];
277 temp[3 * j + 1] = line[j + width];
278 temp[3 * j + 2] = line[j + width + width];
279 }
280 FT_MEM_COPY( line, temp, pitch );
281 }
282
283 FT_FREE( temp );
284 }
285 else if ( vmul ) /* lcd_v */
286 {
287 int pitch = bitmap->pitch;
288
289
290 /* Render 3 separate monochrome bitmaps, shifting the outline */
291 /* by 1/3 pixel. Triple the pitch to render on each third row. */
292 bitmap->pitch *= 3;
293 bitmap->rows /= 3;
294
295 bitmap->buffer += pitch;
296
297 error = render->raster_render( render->raster, &params );
298 if ( error )
299 goto Exit;
300
302 y_shift += 21;
303 bitmap->buffer += pitch;
304
305 error = render->raster_render( render->raster, &params );
306 if ( error )
307 goto Exit;
308
309 FT_Outline_Translate( outline, 0, -42 );
310 y_shift -= 42;
311 bitmap->buffer -= 2 * pitch;
312
313 error = render->raster_render( render->raster, &params );
314 if ( error )
315 goto Exit;
316
317 bitmap->pitch /= 3;
318 bitmap->rows *= 3;
319 }
320 else /* grayscale */
321 error = render->raster_render( render->raster, &params );
322
323#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
324
325 Exit:
326 if ( !error )
327 {
328 /* everything is fine; the glyph is now officially a bitmap */
329 slot->format = FT_GLYPH_FORMAT_BITMAP;
330 }
331 else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
332 {
333 FT_FREE( bitmap->buffer );
334 slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
335 }
336
337 if ( x_shift || y_shift )
338 FT_Outline_Translate( outline, -x_shift, -y_shift );
339
340 return error;
341 }
@ FT_RENDER_MODE_LCD_V
Definition: freetype.h:3238
@ FT_RENDER_MODE_LCD
Definition: freetype.h:3237
FT_Vector * vec
Definition: ftbbox.c:448
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_RASTER_FLAG_AA
Definition: ftimage.h:941
@ FT_PIXEL_MODE_LCD_V
Definition: ftimage.h:188
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:58
#define FT_ALLOC_MULT(ptr, count, item_size)
Definition: ftmemory.h:309
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
#define FT_FREE(ptr)
Definition: ftmemory.h:329
#define FT_MEM_COPY(dest, source, count)
Definition: ftmemory.h:228
ft_glyphslot_preset_bitmap(FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector *origin)
Definition: ftobjs.c:334
#define FT_GLYPH_OWN_BITMAP
Definition: ftobjs.h:463
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:528
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
unsigned long FT_ULong
Definition: fttypes.h:253
unsigned char FT_Byte
Definition: fttypes.h:154
int FT_Error
Definition: fttypes.h:300
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum const GLfloat * params
Definition: glext.h:5645
GLsizei const GLfloat * points
Definition: glext.h:8112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
if(dx< 0)
Definition: linetemp.h:194
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:116
static calc_node_t temp
Definition: rpn_ieee.c:38
static void Exit(void)
Definition: sock.c:1330
FT_Pos x
Definition: ftimage.h:76
FT_Pos y
Definition: ftimage.h:77
Definition: uimain.c:89
uint32 width
Definition: uimain.c:91
Definition: parser.c:49
Definition: mesh.c:5330

Referenced by ft_smooth_render(), ft_smooth_render_lcd(), and ft_smooth_render_lcd_v().

◆ ft_smooth_render_lcd()

static FT_Error ft_smooth_render_lcd ( FT_Renderer  render,
FT_GlyphSlot  slot,
FT_Render_Mode  mode,
const FT_Vector origin 
)
static

Definition at line 361 of file ftsmooth.c.

365 {
368 }

◆ ft_smooth_render_lcd_v()

static FT_Error ft_smooth_render_lcd_v ( FT_Renderer  render,
FT_GlyphSlot  slot,
FT_Render_Mode  mode,
const FT_Vector origin 
)
static

Definition at line 373 of file ftsmooth.c.

◆ ft_smooth_set_mode()

static FT_Error ft_smooth_set_mode ( FT_Renderer  render,
FT_ULong  mode_tag,
FT_Pointer  data 
)
static

Definition at line 42 of file ftsmooth.c.

45 {
46 /* we simply pass it to the raster */
47 return render->clazz->raster_class->raster_set_mode( render->raster,
48 mode_tag,
49 data );
50 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ ft_smooth_transform()

static FT_Error ft_smooth_transform ( FT_Renderer  render,
FT_GlyphSlot  slot,
const FT_Matrix matrix,
const FT_Vector delta 
)
static

Definition at line 54 of file ftsmooth.c.

58 {
60
61
62 if ( slot->format != render->glyph_format )
63 {
64 error = FT_THROW( Invalid_Argument );
65 goto Exit;
66 }
67
68 if ( matrix )
69 FT_Outline_Transform( &slot->outline, matrix );
70
71 if ( delta )
72 FT_Outline_Translate( &slot->outline, delta->x, delta->y );
73
74 Exit:
75 return error;
76 }
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:711
GLuint GLenum matrix
Definition: glext.h:9407

◆ sizeof()

sizeof ( FT_RendererRec  )

Variable Documentation

◆ FT_GLYPH_FORMAT_OUTLINE

◆ FT_MODULE_RENDERER

FT_MODULE_RENDERER

Definition at line 413 of file ftsmooth.c.

◆ ft_smooth_get_cbox

◆ ft_smooth_init

smooth FT_Module_Constructor ft_smooth_init

Definition at line 422 of file ftsmooth.c.

◆ ft_smooth_render_lcd

◆ ft_smooth_set_mode

◆ ft_smooth_transform

◆ lcd

smooth lcd

Definition at line 416 of file ftsmooth.c.

◆ NULL