mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-28 17:19:17 +01:00
[hvgl] Optimize rotation
This commit is contained in:
1 parent
fede68bd5e
commit
83a36fd835
2 files changed
+16
-7
No files matched your search
@@ -422,7 +422,12 @@ PartComposite::apply_to_transforms (hb_array_t<hb_transform_t<double>> transform
|
||||
if (master_rotation_count &&
|
||||
*master_rotation_indices == row)
|
||||
{
|
||||
transform.rotate ((double) *master_rotation_deltas, true);
|
||||
// Since transform is identity by default, we can just replace it with
|
||||
// rotation. This saves a multiplication.
|
||||
if (true)
|
||||
transform = hb_transform_t<double>::rotation ((double) *master_rotation_deltas);
|
||||
else
|
||||
transform.rotate ((double) *master_rotation_deltas, true);
|
||||
master_rotation_count--;
|
||||
master_rotation_indices++;
|
||||
master_rotation_deltas++;
|
||||
|
||||
+10
-6
@@ -203,17 +203,21 @@ struct hb_transform_t
|
||||
yy *= scaleY;
|
||||
}
|
||||
|
||||
void rotate (Float rotation, bool before=false)
|
||||
static hb_transform_t rotation (Float rotation)
|
||||
{
|
||||
if (rotation == 0)
|
||||
return;
|
||||
|
||||
// https://github.com/fonttools/fonttools/blob/f66ee05f71c8b57b5f519ee975e95edcd1466e14/Lib/fontTools/misc/transform.py#L240
|
||||
Float c;
|
||||
Float s;
|
||||
hb_sincos (rotation, s, c);
|
||||
auto other = hb_transform_t{c, s, -s, c, 0, 0};
|
||||
transform (other, before);
|
||||
return {c, s, -s, c, 0, 0};
|
||||
}
|
||||
|
||||
void rotate (Float radians, bool before=false)
|
||||
{
|
||||
if (radians == 0)
|
||||
return;
|
||||
|
||||
transform (rotation (radians), before);
|
||||
}
|
||||
|
||||
void skew (Float skewX, Float skewY)
|
||||
|
||||
Reference in new issue
Block a user