summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/raster
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-03-19 17:34:42 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-03-20 13:42:29 +0000
commit2eaf0cf8fd6e7c290497fedb08134a89e7b49b1d (patch)
tree0a4f7bf528e87d0b0a71ce7fccf702b87f4cdec1 /src/3rdparty/freetype/src/raster
parent77c518a50334d4dcf2476a4f39edc1e3990c7f0b (diff)
Update bundled FreeType to 2.5.5
Removed everything, imported with help of import_from_tarball.sh script, and then added a pre-generated builds/unix/ftconfig.h Task-number: QTBUG-44648 Change-Id: Iea948e41f7761f1580382b3763d04c7a61383382 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/freetype/src/raster')
-rw-r--r--src/3rdparty/freetype/src/raster/ftmisc.h37
-rw-r--r--src/3rdparty/freetype/src/raster/ftraster.c298
-rw-r--r--src/3rdparty/freetype/src/raster/ftrend1.c47
-rw-r--r--src/3rdparty/freetype/src/raster/rasterrs.h3
-rw-r--r--src/3rdparty/freetype/src/raster/rastpic.c68
-rw-r--r--src/3rdparty/freetype/src/raster/rastpic.h33
-rw-r--r--src/3rdparty/freetype/src/raster/rules.mk5
7 files changed, 328 insertions, 163 deletions
diff --git a/src/3rdparty/freetype/src/raster/ftmisc.h b/src/3rdparty/freetype/src/raster/ftmisc.h
index f04b5404bb..703155a429 100644
--- a/src/3rdparty/freetype/src/raster/ftmisc.h
+++ b/src/3rdparty/freetype/src/raster/ftmisc.h
@@ -5,7 +5,7 @@
/* Miscellaneous macros for stand-alone rasterizer (specification */
/* only). */
/* */
-/* Copyright 2005, 2009 by */
+/* Copyright 2005, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -27,6 +27,7 @@
#ifndef __FTMISC_H__
#define __FTMISC_H__
+
/* memset */
#include FT_CONFIG_STANDARD_LIBRARY_H
@@ -35,6 +36,7 @@
#define FT_LOCAL_DEF( x ) static x
+
/* from include/freetype2/fttypes.h */
typedef unsigned char FT_Byte;
@@ -77,12 +79,22 @@
} FT_MemoryRec;
+
/* from src/ftcalc.c */
-#include <inttypes.h>
+#if ( defined _WIN32 || defined _WIN64 )
+
+ typedef __int64 FT_Int64;
+
+#else
+
+#include "inttypes.h"
typedef int64_t FT_Int64;
+#endif
+
+
static FT_Long
FT_MulDiv( FT_Long a,
FT_Long b,
@@ -103,6 +115,27 @@
return ( s > 0 ) ? d : -d;
}
+
+ static FT_Long
+ FT_MulDiv_No_Round( FT_Long a,
+ FT_Long b,
+ FT_Long c )
+ {
+ FT_Int s;
+ FT_Long d;
+
+
+ s = 1;
+ if ( a < 0 ) { a = -a; s = -1; }
+ if ( b < 0 ) { b = -b; s = -s; }
+ if ( c < 0 ) { c = -c; s = -s; }
+
+ d = (FT_Long)( c > 0 ? (FT_Int64)a * b / c
+ : 0x7FFFFFFFL );
+
+ return ( s > 0 ) ? d : -d;
+ }
+
#endif /* __FTMISC_H__ */
diff --git a/src/3rdparty/freetype/src/raster/ftraster.c b/src/3rdparty/freetype/src/raster/ftraster.c
index 23ad592653..b06ac333da 100644
--- a/src/3rdparty/freetype/src/raster/ftraster.c
+++ b/src/3rdparty/freetype/src/raster/ftraster.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2005, 2007, 2008, 2009 by */
+/* Copyright 1996-2003, 2005, 2007-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -24,8 +24,8 @@
/* */
/* - copy `src/raster/ftraster.c' (this file) to your current directory */
/* */
- /* - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' */
- /* to your current directory */
+ /* - copy `include/ftimage.h' and `src/raster/ftmisc.h' to your current */
+ /* directory */
/* */
/* - compile `ftraster' with the _STANDALONE_ macro defined, as in */
/* */
@@ -60,7 +60,7 @@
#include <ft2build.h>
#include "ftraster.h"
-#include FT_INTERNAL_CALC_H /* for FT_MulDiv only */
+#include FT_INTERNAL_CALC_H /* for FT_MulDiv and FT_MulDiv_No_Round */
#include "rastpic.h"
@@ -179,6 +179,9 @@
#ifdef _STANDALONE_
+ /* Auxiliary macros for token concatenation. */
+#define FT_ERR_XCAT( x, y ) x ## y
+#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
/* This macro is used to indicate that a function parameter is unused. */
/* Its purpose is simply to reduce compiler warnings. Note also that */
@@ -187,7 +190,7 @@
#define FT_UNUSED( x ) (x) = (x)
/* Disable the tracing mechanism for simplicity -- developers can */
- /* activate it easily by redefining these two macros. */
+ /* activate it easily by redefining these macros. */
#ifndef FT_ERROR
#define FT_ERROR( x ) do { } while ( 0 ) /* nothing */
#endif
@@ -198,6 +201,10 @@
#define FT_TRACE6( x ) do { } while ( 0 ) /* nothing */
#endif
+#ifndef FT_THROW
+#define FT_THROW( e ) FT_ERR_CAT( Raster_Err_, e )
+#endif
+
#define Raster_Err_None 0
#define Raster_Err_Not_Ini -1
#define Raster_Err_Overflow -2
@@ -224,11 +231,11 @@
#include FT_INTERNAL_OBJECTS_H
-#include FT_INTERNAL_DEBUG_H /* for FT_TRACE() and FT_ERROR() */
+#include FT_INTERNAL_DEBUG_H /* for FT_TRACE, FT_ERROR, and FT_THROW */
#include "rasterrs.h"
-#define Raster_Err_None Raster_Err_Ok
+#define Raster_Err_None FT_Err_Ok
#define Raster_Err_Not_Ini Raster_Err_Raster_Uninitialized
#define Raster_Err_Overflow Raster_Err_Raster_Overflow
#define Raster_Err_Neg_Height Raster_Err_Raster_Negative_Height
@@ -255,7 +262,8 @@
/* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */
/* for clipping computations. It simply uses the FT_MulDiv() function */
/* defined in `ftcalc.h'. */
-#define SMulDiv FT_MulDiv
+#define SMulDiv FT_MulDiv
+#define SMulDiv_No_Round FT_MulDiv_No_Round
/* The rasterizer is a very general purpose component; please leave */
/* the following redefinitions there (you never know your target */
@@ -370,18 +378,23 @@
/* Simple record used to implement a stack of bands, required */
/* by the sub-banding mechanism */
- typedef struct TBand_
+ typedef struct black_TBand_
{
Short y_min; /* band's minimum */
Short y_max; /* band's maximum */
- } TBand;
+ } black_TBand;
#define AlignProfileSize \
( ( sizeof ( TProfile ) + sizeof ( Alignment ) - 1 ) / sizeof ( long ) )
+#undef RAS_ARG
+#undef RAS_ARGS
+#undef RAS_VAR
+#undef RAS_VARS
+
#ifdef FT_STATIC_RASTER
@@ -397,8 +410,8 @@
#else /* !FT_STATIC_RASTER */
-#define RAS_ARGS PWorker worker,
-#define RAS_ARG PWorker worker
+#define RAS_ARGS black_PWorker worker,
+#define RAS_ARG black_PWorker worker
#define RAS_VARS worker,
#define RAS_VAR worker
@@ -409,7 +422,7 @@
#endif /* !FT_STATIC_RASTER */
- typedef struct TWorker_ TWorker, *PWorker;
+ typedef struct black_TWorker_ black_TWorker, *black_PWorker;
/* prototypes used for sweep function dispatch */
@@ -429,26 +442,31 @@
/* NOTE: These operations are only valid on 2's complement processors */
+#undef FLOOR
+#undef CEILING
+#undef TRUNC
+#undef SCALED
#define FLOOR( x ) ( (x) & -ras.precision )
#define CEILING( x ) ( ( (x) + ras.precision - 1 ) & -ras.precision )
-#define TRUNC( x ) ( (signed long)(x) >> ras.precision_bits )
+#define TRUNC( x ) ( (Long)(x) >> ras.precision_bits )
#define FRAC( x ) ( (x) & ( ras.precision - 1 ) )
-#define SCALED( x ) ( ( (x) << ras.scale_shift ) - ras.precision_half )
+#define SCALED( x ) ( ( (ULong)(x) << ras.scale_shift ) - ras.precision_half )
-#define IS_BOTTOM_OVERSHOOT( x ) ( CEILING( x ) - x >= ras.precision_half )
-#define IS_TOP_OVERSHOOT( x ) ( x - FLOOR( x ) >= ras.precision_half )
+#define IS_BOTTOM_OVERSHOOT( x ) \
+ (Bool)( CEILING( x ) - x >= ras.precision_half )
+#define IS_TOP_OVERSHOOT( x ) \
+ (Bool)( x - FLOOR( x ) >= ras.precision_half )
/* The most used variables are positioned at the top of the structure. */
/* Thus, their offset can be coded with less opcodes, resulting in a */
/* smaller executable. */
- struct TWorker_
+ struct black_TWorker_
{
Int precision_bits; /* precision related variables */
Int precision;
Int precision_half;
- Long precision_mask;
Int precision_shift;
Int precision_step;
Int precision_jitter;
@@ -517,8 +535,8 @@
TPoint arcs[3 * MaxBezier + 1]; /* The Bezier stack */
- TBand band_stack[16]; /* band stack used for sub-banding */
- Int band_top; /* band stack top */
+ black_TBand band_stack[16]; /* band stack used for sub-banding */
+ Int band_top; /* band stack top */
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
@@ -542,20 +560,20 @@
};
- typedef struct TRaster_
+ typedef struct black_TRaster_
{
- char* buffer;
- long buffer_size;
- void* memory;
- PWorker worker;
- Byte grays[5];
- Short gray_width;
+ char* buffer;
+ long buffer_size;
+ void* memory;
+ black_PWorker worker;
+ Byte grays[5];
+ Short gray_width;
- } TRaster, *PRaster;
+ } black_TRaster, *black_PRaster;
#ifdef FT_STATIC_RASTER
- static TWorker cur_ras;
+ static black_TWorker cur_ras;
#define ras cur_ras
#else /* !FT_STATIC_RASTER */
@@ -647,17 +665,39 @@
/* Set precision variables according to param flag. */
/* */
/* <Input> */
- /* High :: Set to True for high precision (typically for ppem < 18), */
+ /* High :: Set to True for high precision (typically for ppem < 24), */
/* false otherwise. */
/* */
static void
Set_High_Precision( RAS_ARGS Int High )
{
+ /*
+ * `precision_step' is used in `Bezier_Up' to decide when to split a
+ * given y-monotonous Bezier arc that crosses a scanline before
+ * approximating it as a straight segment. The default value of 32 (for
+ * low accuracy) corresponds to
+ *
+ * 32 / 64 == 0.5 pixels ,
+ *
+ * while for the high accuracy case we have
+ *
+ * 256/ (1 << 12) = 0.0625 pixels .
+ *
+ * `precision_jitter' is an epsilon threshold used in
+ * `Vertical_Sweep_Span' to deal with small imperfections in the Bezier
+ * decomposition (after all, we are working with approximations only);
+ * it avoids switching on additional pixels which would cause artifacts
+ * otherwise.
+ *
+ * The value of `precision_jitter' has been determined heuristically.
+ *
+ */
+
if ( High )
{
ras.precision_bits = 12;
ras.precision_step = 256;
- ras.precision_jitter = 50;
+ ras.precision_jitter = 30;
}
else
{
@@ -671,7 +711,6 @@
ras.precision = 1 << ras.precision_bits;
ras.precision_half = ras.precision / 2;
ras.precision_shift = ras.precision_bits - Pixel_Bits;
- ras.precision_mask = -ras.precision;
}
@@ -706,7 +745,7 @@
if ( ras.top >= ras.maxBuff )
{
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
@@ -725,18 +764,18 @@
if ( overshoot )
ras.cProfile->flags |= Overshoot_Bottom;
- FT_TRACE6(( "New ascending profile = %lx\n", (long)ras.cProfile ));
+ FT_TRACE6(( "New ascending profile = %p\n", ras.cProfile ));
break;
case Descending_State:
if ( overshoot )
ras.cProfile->flags |= Overshoot_Top;
- FT_TRACE6(( "New descending profile = %lx\n", (long)ras.cProfile ));
+ FT_TRACE6(( "New descending profile = %p\n", ras.cProfile ));
break;
default:
FT_ERROR(( "New_Profile: invalid profile direction\n" ));
- ras.error = Raster_Err_Invalid;
+ ras.error = FT_THROW( Invalid );
return FAILURE;
}
@@ -769,8 +808,7 @@
static Bool
End_Profile( RAS_ARGS Bool overshoot )
{
- Long h;
- PProfile oldProfile;
+ Long h;
h = (Long)( ras.top - ras.cProfile->offset );
@@ -778,14 +816,17 @@
if ( h < 0 )
{
FT_ERROR(( "End_Profile: negative height encountered\n" ));
- ras.error = Raster_Err_Neg_Height;
+ ras.error = FT_THROW( Neg_Height );
return FAILURE;
}
if ( h > 0 )
{
- FT_TRACE6(( "Ending profile %lx, start = %ld, height = %ld\n",
- (long)ras.cProfile, ras.cProfile->start, h ));
+ PProfile oldProfile;
+
+
+ FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n",
+ ras.cProfile, ras.cProfile->start, h ));
ras.cProfile->height = h;
if ( overshoot )
@@ -811,7 +852,7 @@
if ( ras.top >= ras.maxBuff )
{
FT_TRACE1(( "overflow in End_Profile\n" ));
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
@@ -840,7 +881,7 @@
Insert_Y_Turn( RAS_ARGS Int y )
{
PLong y_turns;
- Int y2, n;
+ Int n;
n = ras.numTurns - 1;
@@ -854,7 +895,9 @@
if ( n >= 0 && y > y_turns[n] )
while ( n >= 0 )
{
- y2 = (Int)y_turns[n];
+ Int y2 = (Int)y_turns[n];
+
+
y_turns[n] = y;
y = y2;
n--;
@@ -865,7 +908,7 @@
ras.maxBuff--;
if ( ras.maxBuff <= ras.top )
{
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
ras.numTurns++;
@@ -890,7 +933,6 @@
static Bool
Finalize_Profile_Table( RAS_ARG )
{
- Int bottom, top;
UShort n;
PProfile p;
@@ -902,6 +944,9 @@
{
while ( n > 0 )
{
+ Int bottom, top;
+
+
if ( n > 1 )
p->link = (PProfile)( p->offset + p->height );
else
@@ -1094,7 +1139,7 @@
return SUCCESS;
else
{
- x1 += FMulDiv( Dx, ras.precision - f1, Dy );
+ x1 += SMulDiv( Dx, ras.precision - f1, Dy );
e1 += 1;
}
}
@@ -1116,20 +1161,20 @@
size = e2 - e1 + 1;
if ( ras.top + size >= ras.maxBuff )
{
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
if ( Dx > 0 )
{
- Ix = ( ras.precision * Dx ) / Dy;
+ Ix = SMulDiv_No_Round( ras.precision, Dx, Dy );
Rx = ( ras.precision * Dx ) % Dy;
Dx = 1;
}
else
{
- Ix = -( ( ras.precision * -Dx ) / Dy );
- Rx = ( ras.precision * -Dx ) % Dy;
+ Ix = -SMulDiv_No_Round( ras.precision, -Dx, Dy );
+ Rx = ( ras.precision * -Dx ) % Dy;
Dx = -1;
}
@@ -1291,7 +1336,7 @@
if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff )
{
ras.top = top;
- ras.error = Raster_Err_Overflow;
+ ras.error = FT_THROW( Overflow );
return FAILURE;
}
@@ -1829,7 +1874,7 @@
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
- v_last = v_start;
+ /* v_last = v_start; */
}
point--;
tags--;
@@ -1931,18 +1976,21 @@
y1 = SCALED( point[-2].y );
x2 = SCALED( point[-1].x );
y2 = SCALED( point[-1].y );
- x3 = SCALED( point[ 0].x );
- y3 = SCALED( point[ 0].y );
if ( flipped )
{
SWAP_( x1, y1 );
SWAP_( x2, y2 );
- SWAP_( x3, y3 );
}
if ( point <= limit )
{
+ x3 = SCALED( point[0].x );
+ y3 = SCALED( point[0].y );
+
+ if ( flipped )
+ SWAP_( x3, y3 );
+
if ( Cubic_To( RAS_VARS x1, y1, x2, y2, x3, y3 ) )
goto Fail;
continue;
@@ -1963,7 +2011,7 @@
return SUCCESS;
Invalid_Outline:
- ras.error = Raster_Err_Invalid;
+ ras.error = FT_THROW( Invalid );
Fail:
return FAILURE;
@@ -1992,8 +2040,6 @@
int i;
unsigned start;
- PProfile lastProfile;
-
ras.fProfile = NULL;
ras.joint = FALSE;
@@ -2011,7 +2057,8 @@
for ( i = 0; i < ras.outline.n_contours; i++ )
{
- Bool o;
+ PProfile lastProfile;
+ Bool o;
ras.state = Unknown_State;
@@ -2235,10 +2282,10 @@
PProfile right )
{
Long e1, e2;
- int c1, c2;
- Byte f1, f2;
Byte* target;
+ Int dropOutControl = left->flags & 7;
+
FT_UNUSED( y );
FT_UNUSED( left );
FT_UNUSED( right );
@@ -2248,13 +2295,18 @@
e1 = TRUNC( CEILING( x1 ) );
- if ( x2 - x1 - ras.precision <= ras.precision_jitter )
+ if ( dropOutControl != 2 &&
+ x2 - x1 - ras.precision <= ras.precision_jitter )
e2 = e1;
else
e2 = TRUNC( FLOOR( x2 ) );
if ( e2 >= 0 && e1 < ras.bWidth )
{
+ int c1, c2;
+ Byte f1, f2;
+
+
if ( e1 < 0 )
e1 = 0;
if ( e2 >= ras.bWidth )
@@ -2403,6 +2455,14 @@
return; /* no drop-out control */
}
+ /* undocumented but confirmed: If the drop-out would result in a */
+ /* pixel outside of the bounding box, use the pixel inside of the */
+ /* bounding box instead */
+ if ( pxl < 0 )
+ pxl = e1;
+ else if ( TRUNC( pxl ) >= ras.bWidth )
+ pxl = e2;
+
/* check that the other pixel isn't set */
e1 = pxl == e1 ? e2 : e1;
@@ -2470,32 +2530,35 @@
PProfile left,
PProfile right )
{
- Long e1, e2;
- PByte bits;
- Byte f1;
-
FT_UNUSED( left );
FT_UNUSED( right );
if ( x2 - x1 < ras.precision )
{
+ Long e1, e2;
+
+
e1 = CEILING( x1 );
e2 = FLOOR ( x2 );
if ( e1 == e2 )
{
+ Byte f1;
+ PByte bits;
+
+
bits = ras.bTarget + ( y >> 3 );
f1 = (Byte)( 0x80 >> ( y & 7 ) );
e1 = TRUNC( e1 );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
PByte p;
- p = bits - e1*ras.target.pitch;
+ p = bits - e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
p += ( ras.target.rows - 1 ) * ras.target.pitch;
@@ -2579,6 +2642,14 @@
return; /* no drop-out control */
}
+ /* undocumented but confirmed: If the drop-out would result in a */
+ /* pixel outside of the bounding box, use the pixel inside of the */
+ /* bounding box instead */
+ if ( pxl < 0 )
+ pxl = e1;
+ else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows )
+ pxl = e2;
+
/* check that the other pixel isn't set */
e1 = pxl == e1 ? e2 : e1;
@@ -2591,9 +2662,9 @@
if ( ras.target.pitch > 0 )
bits += ( ras.target.rows - 1 ) * ras.target.pitch;
- if ( e1 >= 0 &&
- e1 < ras.target.rows &&
- *bits & f1 )
+ if ( e1 >= 0 &&
+ (ULong)e1 < ras.target.rows &&
+ *bits & f1 )
return;
}
else
@@ -2605,7 +2676,7 @@
e1 = TRUNC( pxl );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
bits -= e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
@@ -2673,8 +2744,6 @@
static void
Vertical_Gray_Sweep_Step( RAS_ARG )
{
- Int c1, c2;
- PByte pix, bit, bit2;
short* count = (short*)count_table;
Byte* grays;
@@ -2683,6 +2752,9 @@
if ( ras.traceOfs > ras.gray_width )
{
+ PByte pix;
+
+
pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4;
grays = ras.grays;
@@ -2693,6 +2765,9 @@
Int last_bit = last_pixel & 3;
Bool over = 0;
+ Int c1, c2;
+ PByte bit, bit2;
+
if ( ras.gray_max_x >= last_cell && last_bit != 3 )
{
@@ -2785,7 +2860,6 @@
{
Long e1, e2;
PByte pixel;
- Byte color;
/* During the horizontal sweep, we only take care of drop-outs */
@@ -2839,6 +2913,9 @@
if ( e1 >= 0 )
{
+ Byte color;
+
+
if ( x2 - x1 >= ras.precision_half )
color = ras.grays[2];
else
@@ -2916,7 +2993,7 @@
/* check the Y-turns */
if ( ras.numTurns == 0 )
{
- ras.error = Raster_Err_Invalid;
+ ras.error = FT_THROW( Invalid );
return FAILURE;
}
@@ -3157,7 +3234,7 @@
if ( ras.band_top >= 7 || k < i )
{
ras.band_top = 0;
- ras.error = Raster_Err_Invalid;
+ ras.error = FT_THROW( Invalid );
return ras.error;
}
@@ -3346,14 +3423,14 @@
{
FT_UNUSED_RASTER;
- return Raster_Err_Unsupported;
+ return FT_THROW( Unsupported );
}
#endif /* !FT_RASTER_OPTION_ANTI_ALIASING */
static void
- ft_black_init( PRaster raster )
+ ft_black_init( black_PRaster raster )
{
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
FT_UInt n;
@@ -3381,7 +3458,8 @@
ft_black_new( void* memory,
FT_Raster *araster )
{
- static TRaster the_raster;
+ static black_TRaster the_raster;
+ FT_UNUSED( memory );
*araster = (FT_Raster)&the_raster;
@@ -3400,15 +3478,15 @@
}
-#else /* _STANDALONE_ */
+#else /* !_STANDALONE_ */
static int
- ft_black_new( FT_Memory memory,
- PRaster *araster )
+ ft_black_new( FT_Memory memory,
+ black_PRaster *araster )
{
- FT_Error error;
- PRaster raster;
+ FT_Error error;
+ black_PRaster raster = NULL;
*araster = 0;
@@ -3425,31 +3503,33 @@
static void
- ft_black_done( PRaster raster )
+ ft_black_done( black_PRaster raster )
{
FT_Memory memory = (FT_Memory)raster->memory;
+
+
FT_FREE( raster );
}
-#endif /* _STANDALONE_ */
+#endif /* !_STANDALONE_ */
static void
- ft_black_reset( PRaster raster,
- char* pool_base,
- long pool_size )
+ ft_black_reset( black_PRaster raster,
+ char* pool_base,
+ long pool_size )
{
if ( raster )
{
- if ( pool_base && pool_size >= (long)sizeof(TWorker) + 2048 )
+ if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 )
{
- PWorker worker = (PWorker)pool_base;
+ black_PWorker worker = (black_PWorker)pool_base;
- raster->buffer = pool_base + ( (sizeof ( *worker ) + 7 ) & ~7 );
- raster->buffer_size = ( ( pool_base + pool_size ) -
- (char*)raster->buffer ) / sizeof ( Long );
+ raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
+ raster->buffer_size = (long)( pool_base + pool_size -
+ (char*)raster->buffer );
raster->worker = worker;
}
else
@@ -3462,8 +3542,8 @@
}
- static void
- ft_black_set_mode( PRaster raster,
+ static int
+ ft_black_set_mode( black_PRaster raster,
unsigned long mode,
const char* palette )
{
@@ -3486,50 +3566,52 @@
FT_UNUSED( palette );
#endif
+
+ return 0;
}
static int
- ft_black_render( PRaster raster,
+ ft_black_render( black_PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
- PWorker worker;
+ black_PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
- return Raster_Err_Not_Ini;
+ return FT_THROW( Not_Ini );
if ( !outline )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return Raster_Err_None;
if ( !outline->contours || !outline->points )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
worker = raster->worker;
/* this version of the raster does not support direct rendering, sorry */
if ( params->flags & FT_RASTER_FLAG_DIRECT )
- return Raster_Err_Unsupported;
+ return FT_THROW( Unsupported );
if ( !target_map )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return Raster_Err_None;
if ( !target_map->buffer )
- return Raster_Err_Invalid;
+ return FT_THROW( Invalid );
ras.outline = *outline;
ras.target = *target_map;
diff --git a/src/3rdparty/freetype/src/raster/ftrend1.c b/src/3rdparty/freetype/src/raster/ftrend1.c
index 1ed8af6121..aa7f6d5664 100644
--- a/src/3rdparty/freetype/src/raster/ftrend1.c
+++ b/src/3rdparty/freetype/src/raster/ftrend1.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer interface (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2005, 2006 by */
+/* Copyright 1996-2003, 2005, 2006, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include "ftrend1.h"
@@ -37,7 +38,7 @@
library->raster_pool,
library->raster_pool_size );
- return Raster_Err_Ok;
+ return FT_Err_Ok;
}
@@ -61,12 +62,12 @@
const FT_Matrix* matrix,
const FT_Vector* delta )
{
- FT_Error error = Raster_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
- error = Raster_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -114,7 +115,7 @@
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
- error = Raster_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -124,13 +125,13 @@
{
/* raster1 is only capable of producing monochrome bitmaps */
if ( render->clazz == &ft_raster1_renderer_class )
- return Raster_Err_Cannot_Render_Glyph;
+ return FT_THROW( Cannot_Render_Glyph );
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
if ( render->clazz == &ft_raster5_renderer_class )
- return Raster_Err_Cannot_Render_Glyph;
+ return FT_THROW( Cannot_Render_Glyph );
}
#else /* FT_CONFIG_OPTION_PIC */
/* When PIC is enabled, we cannot get to the class object */
@@ -142,13 +143,13 @@
{
/* raster1 is only capable of producing monochrome bitmaps */
if ( render->clazz->root.module_name[6] == '1' )
- return Raster_Err_Cannot_Render_Glyph;
+ return FT_THROW( Cannot_Render_Glyph );
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
if ( render->clazz->root.module_name[6] == '5' )
- return Raster_Err_Cannot_Render_Glyph;
+ return FT_THROW( Cannot_Render_Glyph );
}
#endif /* FT_CONFIG_OPTION_PIC */
@@ -161,13 +162,28 @@
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox );
+ /* undocumented but confirmed: bbox values get rounded */
+#if 1
+ cbox.xMin = FT_PIX_ROUND( cbox.xMin );
+ cbox.yMin = FT_PIX_ROUND( cbox.yMin );
+ cbox.xMax = FT_PIX_ROUND( cbox.xMax );
+ cbox.yMax = FT_PIX_ROUND( cbox.yMax );
+#else
cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
cbox.xMax = FT_PIX_CEIL( cbox.xMax );
cbox.yMax = FT_PIX_CEIL( cbox.yMax );
+#endif
width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
+
+ if ( width > FT_USHORT_MAX || height > FT_USHORT_MAX )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
bitmap = &slot->bitmap;
memory = render->root.memory;
@@ -229,10 +245,10 @@
}
- FT_DEFINE_RENDERER(ft_raster1_renderer_class,
-
+ FT_DEFINE_RENDERER( ft_raster1_renderer_class,
+
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"raster1",
0x10000L,
@@ -260,11 +276,10 @@
/* to register it by hand in your application. It should only be */
/* used for backwards-compatibility with FT 1.x anyway. */
/* */
- FT_DEFINE_RENDERER(ft_raster5_renderer_class,
-
-
+ FT_DEFINE_RENDERER( ft_raster5_renderer_class,
+
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"raster5",
0x10000L,
diff --git a/src/3rdparty/freetype/src/raster/rasterrs.h b/src/3rdparty/freetype/src/raster/rasterrs.h
index 5df9a7ab1e..ab85c002a3 100644
--- a/src/3rdparty/freetype/src/raster/rasterrs.h
+++ b/src/3rdparty/freetype/src/raster/rasterrs.h
@@ -4,7 +4,7 @@
/* */
/* monochrome renderer error codes (specification only). */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Raster_Err_
#define FT_ERR_BASE FT_Mod_Err_Raster
diff --git a/src/3rdparty/freetype/src/raster/rastpic.c b/src/3rdparty/freetype/src/raster/rastpic.c
index 3c264877b6..5e9f7cc9c4 100644
--- a/src/3rdparty/freetype/src/raster/rastpic.c
+++ b/src/3rdparty/freetype/src/raster/rastpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for raster module. */
/* */
-/* Copyright 2009 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,21 +20,29 @@
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "rastpic.h"
+#include "rasterrs.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftraster.c */
- void FT_Init_Class_ft_standard_raster(FT_Raster_Funcs*);
+ void
+ FT_Init_Class_ft_standard_raster( FT_Raster_Funcs* funcs );
+
void
- ft_raster1_renderer_class_pic_free( FT_Library library )
+ ft_raster1_renderer_class_pic_free( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+
+
if ( pic_container->raster )
{
- RasterPIC* container = (RasterPIC*)pic_container->raster;
- if(--container->ref_count)
+ RasterPIC* container = (RasterPIC*)pic_container->raster;
+
+
+ if ( --container->ref_count )
return;
FT_FREE( container );
pic_container->raster = NULL;
@@ -43,44 +51,50 @@
FT_Error
- ft_raster1_renderer_class_pic_init( FT_Library library )
+ ft_raster1_renderer_class_pic_init( FT_Library library )
{
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- RasterPIC* container;
- FT_Memory memory = library->memory;
-
- /* since this function also serve raster5 renderer,
- it implements reference counting */
- if(pic_container->raster)
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ RasterPIC* container = NULL;
+ FT_Memory memory = library->memory;
+
+
+ /* since this function also serves raster5 renderer, */
+ /* it implements reference counting */
+ if ( pic_container->raster )
{
((RasterPIC*)pic_container->raster)->ref_count++;
return error;
}
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
- FT_MEM_SET( container, 0, sizeof(*container) );
+ FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->raster = container;
+
container->ref_count = 1;
- /* initialize pointer table - this is how the module usually expects this data */
- FT_Init_Class_ft_standard_raster(&container->ft_standard_raster);
-/*Exit:*/
- if(error)
- ft_raster1_renderer_class_pic_free(library);
+ /* initialize pointer table - */
+ /* this is how the module usually expects this data */
+ FT_Init_Class_ft_standard_raster( &container->ft_standard_raster );
+
return error;
}
+
/* re-route these init and free functions to the above functions */
- FT_Error ft_raster5_renderer_class_pic_init(FT_Library library)
+ FT_Error
+ ft_raster5_renderer_class_pic_init( FT_Library library )
{
- return ft_raster1_renderer_class_pic_init(library);
+ return ft_raster1_renderer_class_pic_init( library );
}
- void ft_raster5_renderer_class_pic_free(FT_Library library)
+
+
+ void
+ ft_raster5_renderer_class_pic_free( FT_Library library )
{
- ft_raster1_renderer_class_pic_free(library);
+ ft_raster1_renderer_class_pic_free( library );
}
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/raster/rastpic.h b/src/3rdparty/freetype/src/raster/rastpic.h
index dcd82b8ca8..e0ddba624e 100644
--- a/src/3rdparty/freetype/src/raster/rastpic.h
+++ b/src/3rdparty/freetype/src/raster/rastpic.h
@@ -19,24 +19,43 @@
#ifndef __RASTPIC_H__
#define __RASTPIC_H__
-
+
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
+
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_STANDARD_RASTER_GET ft_standard_raster
+
+#define FT_STANDARD_RASTER_GET ft_standard_raster
#else /* FT_CONFIG_OPTION_PIC */
- typedef struct RasterPIC_
+ typedef struct RasterPIC_
{
- int ref_count;
- FT_Raster_Funcs ft_standard_raster;
+ int ref_count;
+ FT_Raster_Funcs ft_standard_raster;
+
} RasterPIC;
-#define GET_PIC(lib) ((RasterPIC*)((lib)->pic_container.raster))
-#define FT_STANDARD_RASTER_GET (GET_PIC(library)->ft_standard_raster)
+
+#define GET_PIC( lib ) \
+ ( (RasterPIC*)( (lib)->pic_container.raster ) )
+#define FT_STANDARD_RASTER_GET ( GET_PIC( library )->ft_standard_raster )
+
+
+ /* see rastpic.c for the implementation */
+ void
+ ft_raster1_renderer_class_pic_free( FT_Library library );
+
+ void
+ ft_raster5_renderer_class_pic_free( FT_Library library );
+
+ FT_Error
+ ft_raster1_renderer_class_pic_init( FT_Library library );
+
+ FT_Error
+ ft_raster5_renderer_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/3rdparty/freetype/src/raster/rules.mk b/src/3rdparty/freetype/src/raster/rules.mk
index 9703b1298a..0e0b5e4ebd 100644
--- a/src/3rdparty/freetype/src/raster/rules.mk
+++ b/src/3rdparty/freetype/src/raster/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2001, 2003, 2008, 2009 by
+# Copyright 1996-2000, 2001, 2003, 2008, 2009, 2011 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -25,7 +25,8 @@ RASTER_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(RASTER_DIR))
# raster driver sources (i.e., C files)
#
RASTER_DRV_SRC := $(RASTER_DIR)/ftraster.c \
- $(RASTER_DIR)/ftrend1.c
+ $(RASTER_DIR)/ftrend1.c \
+ $(RASTER_DIR)/rastpic.c
# raster driver headers