[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] bytecode_tweaks 5f2b3d6e9 6/7: [truetype] Tweak bytecode loo
From: |
Werner Lemberg |
Subject: |
[freetype2] bytecode_tweaks 5f2b3d6e9 6/7: [truetype] Tweak bytecode looping. |
Date: |
Wed, 7 May 2025 21:56:45 -0400 (EDT) |
branch: bytecode_tweaks
commit 5f2b3d6e9fecf96ffc5077cc2b61bf54b75f52da
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[truetype] Tweak bytecode looping.
* src/truetype/ttinterp.c (Ins_FLIPPT,SHP,SHPIX,IP,ALIGNRP): Handle
counters and stack locally.
(TT_RunIns): Updated.
---
src/truetype/ttinterp.c | 98 ++++++++++++++++++++++++-------------------------
1 file changed, 48 insertions(+), 50 deletions(-)
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index cabf49a19..4c6b0539d 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -4979,11 +4979,22 @@
* Stack: uint32... -->
*/
static void
- Ins_FLIPPT( TT_ExecContext exc )
+ Ins_FLIPPT( TT_ExecContext exc,
+ FT_Long* args )
{
+ FT_Long loop = exc->GS.loop;
FT_UShort point;
+ if ( exc->new_top < loop )
+ {
+ if ( exc->pedantic_hinting )
+ exc->error = FT_THROW( Too_Few_Arguments );
+ goto Fail;
+ }
+
+ exc->new_top -= loop;
+
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
/* See `ttinterp.h' for details on backward compatibility mode. */
if ( SUBPIXEL_HINTING_MINIMAL &&
@@ -4993,18 +5004,9 @@
goto Fail;
#endif
- if ( exc->top < exc->GS.loop )
+ while ( loop-- )
{
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Too_Few_Arguments );
- goto Fail;
- }
-
- while ( exc->GS.loop > 0 )
- {
- exc->args--;
-
- point = (FT_UShort)exc->stack[exc->args];
+ point = (FT_UShort)*(--args);
if ( BOUNDS( point, exc->pts.n_points ) )
{
@@ -5016,13 +5018,10 @@
}
else
exc->pts.tags[point] ^= FT_CURVE_TAG_ON;
-
- exc->GS.loop--;
}
Fail:
exc->GS.loop = 1;
- exc->new_top = exc->args;
}
@@ -5178,8 +5177,10 @@
* Stack: uint32... -->
*/
static void
- Ins_SHP( TT_ExecContext exc )
+ Ins_SHP( TT_ExecContext exc,
+ FT_Long* args )
{
+ FT_Long loop = exc->GS.loop;
TT_GlyphZoneRec zp;
FT_UShort refp;
@@ -5187,20 +5188,21 @@
FT_UShort point;
- if ( exc->top < exc->GS.loop )
+ if ( exc->new_top < loop )
{
if ( exc->pedantic_hinting )
exc->error = FT_THROW( Invalid_Reference );
goto Fail;
}
+ exc->new_top -= loop;
+
if ( Compute_Point_Displacement( exc, &dx, &dy, &zp, &refp ) )
return;
- while ( exc->GS.loop > 0 )
+ while ( loop-- )
{
- exc->args--;
- point = (FT_UShort)exc->stack[exc->args];
+ point = (FT_UShort)*(--args);
if ( BOUNDS( point, exc->zp2.n_points ) )
{
@@ -5212,13 +5214,10 @@
}
else
Move_Zp2_Point( exc, point, dx, dy, TRUE );
-
- exc->GS.loop--;
}
Fail:
exc->GS.loop = 1;
- exc->new_top = exc->args;
}
@@ -5334,6 +5333,7 @@
Ins_SHPIX( TT_ExecContext exc,
FT_Long* args )
{
+ FT_Long loop = exc->GS.loop;
FT_F26Dot6 dx, dy;
FT_UShort point;
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
@@ -5343,22 +5343,21 @@
#endif
-
- if ( exc->top < exc->GS.loop + 1 )
+ if ( exc->new_top < loop )
{
if ( exc->pedantic_hinting )
exc->error = FT_THROW( Invalid_Reference );
goto Fail;
}
+ exc->new_top -= loop;
+
dx = TT_MulFix14( args[0], exc->GS.freeVector.x );
dy = TT_MulFix14( args[0], exc->GS.freeVector.y );
- while ( exc->GS.loop > 0 )
+ while ( loop-- )
{
- exc->args--;
-
- point = (FT_UShort)exc->stack[exc->args];
+ point = (FT_UShort)*(--args);
if ( BOUNDS( point, exc->zp2.n_points ) )
{
@@ -5387,13 +5386,10 @@
else
#endif
Move_Zp2_Point( exc, point, dx, dy, TRUE );
-
- exc->GS.loop--;
}
Fail:
exc->GS.loop = 1;
- exc->new_top = exc->args;
}
@@ -5847,13 +5843,15 @@
* Stack: uint32 uint32... -->
*/
static void
- Ins_ALIGNRP( TT_ExecContext exc )
+ Ins_ALIGNRP( TT_ExecContext exc,
+ FT_Long* args )
{
+ FT_Long loop = exc->GS.loop;
FT_UShort point;
FT_F26Dot6 distance;
- if ( exc->top < exc->GS.loop ||
+ if ( exc->new_top < loop ||
BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
{
if ( exc->pedantic_hinting )
@@ -5861,11 +5859,11 @@
goto Fail;
}
- while ( exc->GS.loop > 0 )
- {
- exc->args--;
+ exc->new_top -= loop;
- point = (FT_UShort)exc->stack[exc->args];
+ while ( loop-- )
+ {
+ point = (FT_UShort)*(--args);
if ( BOUNDS( point, exc->zp1.n_points ) )
{
@@ -5882,13 +5880,10 @@
exc->func_move( exc, &exc->zp1, point, NEG_LONG( distance ) );
}
-
- exc->GS.loop--;
}
Fail:
exc->GS.loop = 1;
- exc->new_top = exc->args;
}
@@ -6030,21 +6025,25 @@
/* SOMETIMES, DUMBER CODE IS BETTER CODE */
static void
- Ins_IP( TT_ExecContext exc )
+ Ins_IP( TT_ExecContext exc,
+ FT_Long* args )
{
+ FT_Long loop = exc->GS.loop;
FT_F26Dot6 old_range, cur_range;
FT_Vector* orus_base;
FT_Vector* cur_base;
FT_Int twilight;
- if ( exc->top < exc->GS.loop )
+ if ( exc->new_top < loop )
{
if ( exc->pedantic_hinting )
exc->error = FT_THROW( Invalid_Reference );
goto Fail;
}
+ exc->new_top -= loop;
+
/*
* We need to deal in a special way with the twilight zone.
* Otherwise, by definition, the value of exc->twilight.orus[n] is (0,0),
@@ -6102,9 +6101,9 @@
cur_range = PROJECT( &exc->zp1.cur[exc->GS.rp2], cur_base );
}
- for ( ; exc->GS.loop > 0; exc->GS.loop-- )
+ while ( loop-- )
{
- FT_UInt point = (FT_UInt)exc->stack[--exc->args];
+ FT_UInt point = (FT_UInt)*(--args);
FT_F26Dot6 org_dist, cur_dist, new_dist;
@@ -6176,7 +6175,6 @@
Fail:
exc->GS.loop = 1;
- exc->new_top = exc->args;
}
@@ -7237,7 +7235,7 @@
case 0x32: /* SHP */
case 0x33: /* SHP */
- Ins_SHP( exc );
+ Ins_SHP( exc, args );
break;
case 0x34: /* SHC */
@@ -7255,7 +7253,7 @@
break;
case 0x39: /* IP */
- Ins_IP( exc );
+ Ins_IP( exc, args );
break;
case 0x3A: /* MSIRP */
@@ -7264,7 +7262,7 @@
break;
case 0x3C: /* AlignRP */
- Ins_ALIGNRP( exc );
+ Ins_ALIGNRP( exc, args );
break;
case 0x3D: /* RTDG */
@@ -7500,7 +7498,7 @@
break;
case 0x80: /* FLIPPT */
- Ins_FLIPPT( exc );
+ Ins_FLIPPT( exc, args );
break;
case 0x81: /* FLIPRGON */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] bytecode_tweaks 5f2b3d6e9 6/7: [truetype] Tweak bytecode looping.,
Werner Lemberg <=