ref: 1e0cef9e72aea5df787853e1952166807f4656fc
parent: d8ac180c8829b94845f31a8baea5a2573fffee42
author: Alexei Podtelezhnikov <apodtele@gmail.com>
date: Wed Jun 23 20:19:50 EDT 2021
[smooth, raster] Fix up and align error codes. FT_Render_Glyph picked up FAILURE or 1 returned from the raster function, which became a confusing error code. Instead, return Raster_Overflow in the unlikely event that banding does not help or another meaningful error. * src/smooth/ftgrays.c (gray_convert_glyph_inner, gray_convert_glyph): Use Raster_Overflow when the rendering pool is exhausted and return it if banding does not help. (gray_raster_render): Use Smooth_Err_Ok. * src/raster/ftraster.c (Render_Single_Pass): Return Raster_Overflow if banding does not help or another error code.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2021-06-24 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [smooth, raster] Fix up and align error codes.
+
+ FT_Render_Glyph picked up FAILURE or 1 returned from the raster
+ function, which became a confusing error code. Instead, return
+ Raster_Overflow in the unlikely event that banding does not help or
+ another meaningful error.
+
+ * src/smooth/ftgrays.c (gray_convert_glyph_inner, gray_convert_glyph):
+ Use Raster_Overflow when the rendering pool is exhausted and return it
+ if banding does not help.
+ (gray_raster_render): Use Smooth_Err_Ok.
+
+ * src/raster/ftraster.c (Render_Single_Pass): Return Raster_Overflow
+ if banding does not help or another error code.
+
2021-06-23 Alexei Podtelezhnikov <apodtele@gmail.com>
[smooth, raster] Remove synonymous error macros.
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -3050,7 +3050,7 @@
if ( Convert_Glyph( RAS_VARS flipped ) )
{
if ( ras.error != Raster_Err_Raster_Overflow )
- return FAILURE;
+ return ras.error;
ras.error = Raster_Err_Ok;
@@ -3068,7 +3068,7 @@
if ( ras.band_top >= 7 || k < i )
{
ras.band_top = 0;
- ras.error = FT_THROW( Invalid_Outline );
+ ras.error = FT_THROW( Raster_Overflow );
return ras.error;
}
@@ -3089,7 +3089,7 @@
}
}
- return SUCCESS;
+ return Raster_Err_Ok;
}
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -168,10 +168,11 @@
typedef ptrdiff_t FT_PtrDist;
+#define Smooth_Err_Ok 0
#define Smooth_Err_Invalid_Outline -1
#define Smooth_Err_Cannot_Render_Glyph -2
#define Smooth_Err_Invalid_Argument -3
-#define Smooth_Err_Out_Of_Memory -4
+#define Smooth_Err_Raster_Overflow -4
#define FT_BEGIN_HEADER
#define FT_END_HEADER
@@ -1601,7 +1602,7 @@
}
FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
- return 0;
+ return Smooth_Err_Ok;
Exit:
FT_TRACE5(( "FT_Outline_Decompose: Error 0x%x\n", error ));
@@ -1650,7 +1651,7 @@
}
else
{
- error = FT_THROW( Out_Of_Memory );
+ error = FT_THROW( Raster_Overflow );
FT_TRACE7(( "band [%d..%d]: to be bisected\n",
ras.min_ey, ras.max_ey ));
@@ -1726,8 +1727,8 @@
band--;
continue;
}
- else if ( error != Smooth_Err_Out_Of_Memory )
- return 1;
+ else if ( error != Smooth_Err_Raster_Overflow )
+ return error;
/* render pool overflow; we will reduce the render band by half */
width >>= 1;
@@ -1736,7 +1737,7 @@
if ( width == 0 )
{
FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
- return 1;
+ return FT_THROW( Raster_Overflow );
}
band++;
@@ -1745,7 +1746,7 @@
} while ( band >= bands );
}
- return 0;
+ return Smooth_Err_Ok;
}
@@ -1773,7 +1774,7 @@
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
- return 0;
+ return Smooth_Err_Ok;
if ( !outline->contours || !outline->points )
return FT_THROW( Invalid_Outline );
@@ -1787,7 +1788,7 @@
if ( params->flags & FT_RASTER_FLAG_DIRECT )
{
if ( !params->gray_spans )
- return 0;
+ return Smooth_Err_Ok;
ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
ras.render_span_data = params->user;
@@ -1805,7 +1806,7 @@
/* nothing to do */
if ( !target_map->width || !target_map->rows )
- return 0;
+ return Smooth_Err_Ok;
if ( !target_map->buffer )
return FT_THROW( Invalid_Argument );
@@ -1829,7 +1830,7 @@
/* exit if nothing to do */
if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
- return 0;
+ return Smooth_Err_Ok;
return gray_convert_glyph( RAS_VAR );
}