mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-21 06:51:01 +01:00
[hvgl] Fix transform order
This commit is contained in:
1 parent
76dbae15e7
commit
d5174c41ae
2 files changed
+33
-22
No files matched your search
@@ -343,20 +343,21 @@ PartComposite::apply_to_transforms (hb_array_t<hb_transform_t<double>> transform
|
||||
const auto &extremumRotationIndex = StructAfter<decltype (allRotations.extremumRotationIndexX)> (extremumRotationDelta, sparseExtremumRotationCount);
|
||||
const auto &masterRotationIndex = StructAfter<decltype (allRotations.masterRotationIndexX)> (extremumRotationIndex, sparseExtremumRotationCount);
|
||||
|
||||
{
|
||||
const auto master_rotation_indices = masterRotationIndex.arrayZ;
|
||||
const auto master_rotation_deltas = masterRotationDelta.arrayZ;
|
||||
unsigned count = sparseMasterRotationCount;
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
transforms[master_rotation_indices[i]].rotate ((double) master_rotation_deltas[i], true);
|
||||
}
|
||||
{
|
||||
const auto master_translation_indices = masterTranslationIndex.arrayZ;
|
||||
const auto master_translation_deltas = masterTranslationDelta.arrayZ;
|
||||
unsigned count = sparseMasterTranslationCount;
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
transforms[master_translation_indices[i]].translate ((double) master_translation_deltas[i].x,
|
||||
(double) master_translation_deltas[i].y);
|
||||
}
|
||||
{
|
||||
const auto master_rotation_indices = masterRotationIndex.arrayZ;
|
||||
const auto master_rotation_deltas = masterRotationDelta.arrayZ;
|
||||
unsigned count = sparseMasterRotationCount;
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
transforms[master_rotation_indices[i]].rotate ((double) master_rotation_deltas[i]);
|
||||
(double) master_translation_deltas[i].y,
|
||||
true);
|
||||
}
|
||||
|
||||
auto extremum_translation_indices = extremumTranslationIndex.arrayZ;
|
||||
|
||||
+24
-14
@@ -123,16 +123,18 @@ struct hb_transform_t
|
||||
x0 == 0 && y0 == 0;
|
||||
}
|
||||
|
||||
void multiply (const hb_transform_t &o)
|
||||
void multiply (const hb_transform_t &o, bool before=false)
|
||||
{
|
||||
/* Copied from cairo, with "o" being "a" there and "this" being "b" there. */
|
||||
// Copied from cairo-matrix.c
|
||||
const hb_transform_t &a = before ? o : *this;
|
||||
const hb_transform_t &b = before ? *this : o;
|
||||
*this = {
|
||||
o.xx * xx + o.yx * xy, // xx
|
||||
o.xx * yx + o.yx * yy, // yx
|
||||
o.xy * xx + o.yy * xy, // xy
|
||||
o.xy * yx + o.yy * yy, // yy
|
||||
o.x0 * xx + o.y0 * xy + x0, // x0
|
||||
o.x0 * yx + o.y0 * yy + y0 // y0
|
||||
a.xx * b.xx + a.xy * b.yx,
|
||||
a.yx * b.xx + a.yy * b.yx,
|
||||
a.xx * b.xy + a.xy * b.yy,
|
||||
a.yx * b.xy + a.yy * b.yy,
|
||||
a.xx * b.x0 + a.xy * b.y0 + a.x0,
|
||||
a.yx * b.x0 + a.yy * b.y0 + a.y0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -172,15 +174,23 @@ struct hb_transform_t
|
||||
}
|
||||
}
|
||||
|
||||
void transform (const hb_transform_t &o) { multiply (o); }
|
||||
void transform (const hb_transform_t &o, bool before=false) { multiply (o, before); }
|
||||
|
||||
void translate (Float x, Float y)
|
||||
void translate (Float x, Float y, bool before=false)
|
||||
{
|
||||
if (x == 0 && y == 0)
|
||||
return;
|
||||
|
||||
x0 += xx * x + xy * y;
|
||||
y0 += yx * x + yy * y;
|
||||
if (before)
|
||||
{
|
||||
x0 += x;
|
||||
y0 += y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x0 += xx * x + xy * y;
|
||||
y0 += yx * x + yy * y;
|
||||
}
|
||||
}
|
||||
|
||||
void scale (Float scaleX, Float scaleY)
|
||||
@@ -194,7 +204,7 @@ struct hb_transform_t
|
||||
yy *= scaleY;
|
||||
}
|
||||
|
||||
void rotate (Float rotation)
|
||||
void rotate (Float rotation, bool before=false)
|
||||
{
|
||||
if (rotation == 0)
|
||||
return;
|
||||
@@ -204,7 +214,7 @@ struct hb_transform_t
|
||||
Float s;
|
||||
hb_sincos (rotation, s, c);
|
||||
auto other = hb_transform_t{c, s, -s, c, 0, 0};
|
||||
transform (other);
|
||||
transform (other, before);
|
||||
}
|
||||
|
||||
void skew (Float skewX, Float skewY)
|
||||
|
||||
Reference in new issue
Block a user