From 9a444f0547e661ad36a94869c86114502343e431 Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Thu, 25 Aug 2016 22:36:01 -0400 Subject: [PATCH] * src/smooth/ftgrays.c (gray_raster_render): Minor tweaks. --- ChangeLog | 6 +++++- src/smooth/ftgrays.c | 42 ++++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index bbb3d32e7..8b1e97a19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-08-26 Alexei Podtelezhnikov + + * src/smooth/ftgrays.c (gray_raster_render): Minor tweaks. + 2016-08-26 Werner Lemberg [type1] Fix heap buffer overflow. @@ -32,7 +36,7 @@ This removes unnecessary complexity of span merging and buffering. Instead, the spans are rendered as they come, speeding up the - rendering by about 5% percents as a result. + rendering by about 5% as a result. * src/smooth/ftgrays.c [FT_MAX_GRAY_SPANS]: Macro removed. (gray_TWorker): Remove span buffer and related fields. diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index 6f438ab6a..8e1dcbeb0 100644 --- a/src/smooth/ftgrays.c +++ b/src/smooth/ftgrays.c @@ -1924,12 +1924,18 @@ typedef ptrdiff_t FT_PtrDist; const FT_Bitmap* target_map = params->target; FT_BBox cbox, clip; +#ifndef FT_STATIC_RASTER gray_TWorker worker[1]; +#endif if ( !raster ) return FT_THROW( Invalid_Argument ); + /* this version does not support monochrome rendering */ + if ( !( params->flags & FT_RASTER_FLAG_AA ) ) + return FT_THROW( Invalid_Mode ); + if ( !outline ) return FT_THROW( Invalid_Outline ); @@ -1944,9 +1950,19 @@ typedef ptrdiff_t FT_PtrDist; outline->contours[outline->n_contours - 1] + 1 ) return FT_THROW( Invalid_Outline ); - /* if direct mode is not set, we must have a target bitmap */ - if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) ) + ras.outline = *outline; + + if ( params->flags & FT_RASTER_FLAG_DIRECT ) { + if ( !params->gray_spans ) + return 0; + + ras.render_span = (FT_Raster_Span_Func)params->gray_spans; + ras.render_span_data = params->user; + } + else + { + /* if direct mode is not set, we must have a target bitmap */ if ( !target_map ) return FT_THROW( Invalid_Argument ); @@ -1956,11 +1972,11 @@ typedef ptrdiff_t FT_PtrDist; if ( !target_map->buffer ) return FT_THROW( Invalid_Argument ); - } - /* this version does not support monochrome rendering */ - if ( !( params->flags & FT_RASTER_FLAG_AA ) ) - return FT_THROW( Invalid_Mode ); + ras.target = *target_map; + ras.render_span = (FT_Raster_Span_Func)gray_render_span; + ras.render_span_data = &ras; + } FT_Outline_Get_CBox( outline, &cbox ); @@ -2006,20 +2022,6 @@ typedef ptrdiff_t FT_PtrDist; ras.count_ex = ras.max_ex - ras.min_ex; ras.count_ey = ras.max_ey - ras.min_ey; - ras.outline = *outline; - - if ( params->flags & FT_RASTER_FLAG_DIRECT ) - { - ras.render_span = (FT_Raster_Span_Func)params->gray_spans; - ras.render_span_data = params->user; - } - else - { - ras.target = *target_map; - ras.render_span = (FT_Raster_Span_Func)gray_render_span; - ras.render_span_data = &ras; - } - return gray_convert_glyph( RAS_VAR ); }