summaryrefslogtreecommitdiffstats
path: root/src/truetype/ttinterp.c
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2013-12-12 09:12:18 -0800
committerVictoria Lease <violets@google.com>2013-12-12 09:23:45 -0800
commitec0bab5697bb31ba980810145f62e3799946ec60 (patch)
treebaa7eea792c50b86250831c67a9f2a6eb5be6a91 /src/truetype/ttinterp.c
parent899c67b6cfcd2010784fbf08c5415af16c526e0c (diff)
downloadandroid_external_freetype-ec0bab5697bb31ba980810145f62e3799946ec60.tar.gz
android_external_freetype-ec0bab5697bb31ba980810145f62e3799946ec60.tar.bz2
android_external_freetype-ec0bab5697bb31ba980810145f62e3799946ec60.zip
Update freetype to 8bb09b0fe4d9747bcf452a777cabed7d7ef435e2
Integrated patches from freetype2 git repository, up to hashval 8bb09b0fe4d9747bcf452a777cabed7d7ef435e2, which is post-2.5.2. Most recent commit message from freetype git: [truetype] Simplify logic of rendering modes. Noteworthy patches included: [sfnt] Fix handling of embedded bitmap strikes. [truetype] Improve handling of buggy embedded bitmap strikes. Add FT_FACE_FLAG_COLOR and FT_HAS_COLOR. Change-Id: I4a22d96c9443c7a587475ca0a9c684843e144b18
Diffstat (limited to 'src/truetype/ttinterp.c')
-rw-r--r--src/truetype/ttinterp.c266
1 files changed, 183 insertions, 83 deletions
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 798d4a9..3f110c2 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -1437,9 +1437,108 @@
#undef PACK
-#if 1
+
+#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
+
+#if defined( __arm__ ) && \
+ ( defined( __thumb2__ ) || !defined( __thumb__ ) )
+
+#define TT_MulFix14 TT_MulFix14_arm
static FT_Int32
+ TT_MulFix14_arm( FT_Int32 a,
+ FT_Int b )
+ {
+ register FT_Int32 t, t2;
+
+
+#if defined( __CC_ARM ) || defined( __ARMCC__ )
+
+ __asm
+ {
+ smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
+ mov a, t, asr #31 /* a = (hi >> 31) */
+ add a, a, #0x2000 /* a += 0x2000 */
+ adds t2, t2, a /* t2 += a */
+ adc t, t, #0 /* t += carry */
+ mov a, t2, lsr #14 /* a = t2 >> 14 */
+ orr a, a, t, lsl #18 /* a |= t << 18 */
+ }
+
+#elif defined( __GNUC__ )
+
+ __asm__ __volatile__ (
+ "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
+ "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
+#ifdef __clang__
+ "add.w %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
+#else
+ "add %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
+#endif
+ "adds %1, %1, %0\n\t" /* %1 += %0 */
+ "adc %2, %2, #0\n\t" /* %2 += carry */
+ "mov %0, %1, lsr #14\n\t" /* %0 = %1 >> 16 */
+ "orr %0, %0, %2, lsl #18\n\t" /* %0 |= %2 << 16 */
+ : "=r"(a), "=&r"(t2), "=&r"(t)
+ : "r"(a), "r"(b)
+ : "cc" );
+
+#endif
+
+ return a;
+ }
+
+#endif /* __arm__ && ( __thumb2__ || !__thumb__ ) */
+
+#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
+
+
+#if defined( __GNUC__ ) && \
+ ( defined( __i386__ ) || defined( __x86_64__ ) )
+
+#define TT_MulFix14 TT_MulFix14_long_long
+
+ /* Temporarily disable the warning that C90 doesn't support `long long'. */
+#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
+#pragma GCC diagnostic push
+#endif
+#pragma GCC diagnostic ignored "-Wlong-long"
+
+ /* This is declared `noinline' because inlining the function results */
+ /* in slower code. The `pure' attribute indicates that the result */
+ /* only depends on the parameters. */
+ static __attribute__(( noinline ))
+ __attribute__(( pure )) FT_Int32
+ TT_MulFix14_long_long( FT_Int32 a,
+ FT_Int b )
+ {
+
+ long long ret = (long long)a * b;
+
+ /* The following line assumes that right shifting of signed values */
+ /* will actually preserve the sign bit. The exact behaviour is */
+ /* undefined, but this is true on x86 and x86_64. */
+ long long tmp = ret >> 63;
+
+
+ ret += 0x2000 + tmp;
+
+ return (FT_Int32)( ret >> 14 );
+ }
+
+#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
+#pragma GCC diagnostic pop
+#endif
+
+#endif /* __GNUC__ && ( __i386__ || __x86_64__ ) */
+
+
+#ifndef TT_MulFix14
+
+ /* Compute (a*b)/2^14 with maximum accuracy and rounding. */
+ /* This is optimized to be faster than calling FT_MulFix() */
+ /* for platforms where sizeof(int) == 2. */
+ static FT_Int32
TT_MulFix14( FT_Int32 a,
FT_Int b )
{
@@ -1470,37 +1569,50 @@
return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
}
-#else
+#endif /* !TT_MulFix14 */
- /* compute (a*b)/2^14 with maximum accuracy and rounding */
- static FT_Int32
- TT_MulFix14( FT_Int32 a,
- FT_Int b )
- {
- FT_Int32 m, s, hi;
- FT_UInt32 l, lo;
+#if defined( __GNUC__ ) && \
+ ( defined( __i386__ ) || \
+ defined( __x86_64__ ) || \
+ defined( __arm__ ) )
- /* compute ax*bx as 64-bit value */
- l = (FT_UInt32)( ( a & 0xFFFFU ) * b );
- m = ( a >> 16 ) * b;
+#define TT_DotFix14 TT_DotFix14_long_long
- lo = l + ( (FT_UInt32)m << 16 );
- hi = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo < l );
+#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
+#pragma GCC diagnostic push
+#endif
+#pragma GCC diagnostic ignored "-Wlong-long"
- /* divide the result by 2^14 with rounding */
- s = hi >> 31;
- l = lo + (FT_UInt32)s;
- hi += s + ( l < lo );
- lo = l;
+ static __attribute__(( pure )) FT_Int32
+ TT_DotFix14_long_long( FT_Int32 ax,
+ FT_Int32 ay,
+ FT_Int bx,
+ FT_Int by )
+ {
+ /* Temporarily disable the warning that C90 doesn't support */
+ /* `long long'. */
- l = lo + 0x2000U;
- hi += l < lo;
+ long long temp1 = (long long)ax * bx;
+ long long temp2 = (long long)ay * by;
+
+
+ temp1 += temp2;
+ temp2 = temp1 >> 63;
+ temp1 += 0x2000 + temp2;
+
+ return (FT_Int32)( temp1 >> 14 );
- return (FT_Int32)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );
}
+
+#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
+#pragma GCC diagnostic pop
#endif
+#endif /* __GNUC__ && (__arm__ || __i386__ || __x86_64__) */
+
+
+#ifndef TT_DotFix14
/* compute (ax*bx+ay*by)/2^14 with maximum accuracy and rounding */
static FT_Int32
@@ -1543,6 +1655,8 @@
return (FT_Int32)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );
}
+#endif /* TT_DotFix14 */
+
/*************************************************************************/
/* */
@@ -3037,42 +3151,42 @@
}
-#define DO_JROT \
- if ( args[1] != 0 ) \
- { \
- if ( args[0] == 0 && CUR.args == 0 ) \
- CUR.error = FT_THROW( Bad_Argument ); \
- CUR.IP += args[0]; \
- if ( CUR.IP < 0 || \
- ( CUR.callTop > 0 && \
- CUR.IP > CUR.callStack[CUR.callTop - 1].Cur_End ) ) \
- CUR.error = FT_THROW( Bad_Argument ); \
- CUR.step_ins = FALSE; \
+#define DO_JROT \
+ if ( args[1] != 0 ) \
+ { \
+ if ( args[0] == 0 && CUR.args == 0 ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.IP += args[0]; \
+ if ( CUR.IP < 0 || \
+ ( CUR.callTop > 0 && \
+ CUR.IP > CUR.callStack[CUR.callTop - 1].Def->end ) ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.step_ins = FALSE; \
}
-#define DO_JMPR \
- if ( args[0] == 0 && CUR.args == 0 ) \
- CUR.error = FT_THROW( Bad_Argument ); \
- CUR.IP += args[0]; \
- if ( CUR.IP < 0 || \
- ( CUR.callTop > 0 && \
- CUR.IP > CUR.callStack[CUR.callTop - 1].Cur_End ) ) \
- CUR.error = FT_THROW( Bad_Argument ); \
+#define DO_JMPR \
+ if ( args[0] == 0 && CUR.args == 0 ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.IP += args[0]; \
+ if ( CUR.IP < 0 || \
+ ( CUR.callTop > 0 && \
+ CUR.IP > CUR.callStack[CUR.callTop - 1].Def->end ) ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
CUR.step_ins = FALSE;
-#define DO_JROF \
- if ( args[1] == 0 ) \
- { \
- if ( args[0] == 0 && CUR.args == 0 ) \
- CUR.error = FT_THROW( Bad_Argument ); \
- CUR.IP += args[0]; \
- if ( CUR.IP < 0 || \
- ( CUR.callTop > 0 && \
- CUR.IP > CUR.callStack[CUR.callTop - 1].Cur_End ) ) \
- CUR.error = FT_THROW( Bad_Argument ); \
- CUR.step_ins = FALSE; \
+#define DO_JROF \
+ if ( args[1] == 0 ) \
+ { \
+ if ( args[0] == 0 && CUR.args == 0 ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.IP += args[0]; \
+ if ( CUR.IP < 0 || \
+ ( CUR.callTop > 0 && \
+ CUR.IP > CUR.callStack[CUR.callTop - 1].Def->end ) ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ CUR.step_ins = FALSE; \
}
@@ -4788,7 +4902,7 @@
if ( pRec->Cur_Count > 0 )
{
CUR.callTop++;
- CUR.IP = pRec->Cur_Restart;
+ CUR.IP = pRec->Def->start;
}
else
/* Loop through the current function */
@@ -4878,8 +4992,7 @@
pCrec->Caller_Range = CUR.curRange;
pCrec->Caller_IP = CUR.IP + 1;
pCrec->Cur_Count = 1;
- pCrec->Cur_Restart = def->start;
- pCrec->Cur_End = def->end;
+ pCrec->Def = def;
CUR.callTop++;
@@ -4967,8 +5080,7 @@
pCrec->Caller_Range = CUR.curRange;
pCrec->Caller_IP = CUR.IP + 1;
pCrec->Cur_Count = (FT_Int)args[0];
- pCrec->Cur_Restart = def->start;
- pCrec->Cur_End = def->end;
+ pCrec->Def = def;
CUR.callTop++;
@@ -6173,7 +6285,7 @@
FT_F26Dot6 distance;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- FT_F26Dot6 control_value_cutin;
+ FT_F26Dot6 control_value_cutin = 0; /* pacify compiler */
if ( SUBPIXEL_HINTING )
@@ -6542,8 +6654,8 @@
control_value_cutin,
minimum_distance;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- FT_Int B1;
- FT_Int B2;
+ FT_Int B1 = 0; /* pacify compiler */
+ FT_Int B2 = 0;
FT_Bool reverse_move = FALSE;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
@@ -7708,26 +7820,16 @@
CUR.ignore_x_mode &&
CUR.rasterizer_version >= TT_INTERPRETER_VERSION_35 )
{
- /********************************/
- /* HINTING FOR GRAYSCALE */
- /* Selector Bit: 5 */
- /* Return Bit(s): 12 */
- /* */
- if ( ( args[0] & 32 ) != 0 && CUR.grayscale_hinting )
- K |= 1 << 12;
-
- /********************************/
- /* HINTING FOR SUBPIXEL */
- /* Selector Bit: 6 */
- /* Return Bit(s): 13 */
- /* */
- if ( ( args[0] & 64 ) != 0 &&
- CUR.subpixel_hinting &&
- CUR.rasterizer_version >= 37 )
- {
- K |= 1 << 13;
- /* the stuff below is irrelevant if subpixel_hinting is not set */
+ if ( CUR.rasterizer_version >= 37 )
+ {
+ /********************************/
+ /* HINTING FOR SUBPIXEL */
+ /* Selector Bit: 6 */
+ /* Return Bit(s): 13 */
+ /* */
+ if ( ( args[0] & 64 ) != 0 && CUR.subpixel )
+ K |= 1 << 13;
/********************************/
/* COMPATIBLE WIDTHS ENABLED */
@@ -7803,8 +7905,7 @@
call->Caller_Range = CUR.curRange;
call->Caller_IP = CUR.IP + 1;
call->Cur_Count = 1;
- call->Cur_Restart = def->start;
- call->Cur_End = def->end;
+ call->Def = def;
INS_Goto_CodeRange( def->range, def->start );
@@ -8860,8 +8961,7 @@
callrec->Caller_Range = CUR.curRange;
callrec->Caller_IP = CUR.IP + 1;
callrec->Cur_Count = 1;
- callrec->Cur_Restart = def->start;
- callrec->Cur_End = def->end;
+ callrec->Def = def;
if ( INS_Goto_CodeRange( def->range, def->start ) == FAILURE )
goto LErrorLabel_;