sw_engine: keep the code in a more primitive style

This commit is contained in:
Hermet Park 2025-07-03 15:06:24 +09:00 committed by Hermet Park
parent ea8abe8912
commit f59da6a79f
5 changed files with 97 additions and 99 deletions

View file

@ -34,17 +34,15 @@
#define SW_ANGLE_2PI (SW_ANGLE_PI << 1)
#define SW_ANGLE_PI2 (SW_ANGLE_PI >> 1)
using SwCoord = int32_t;
using SwFixed = int64_t;
static inline float TO_FLOAT(SwCoord val)
static inline float TO_FLOAT(int32_t val)
{
return static_cast<float>(val) / 64.0f;
}
struct SwPoint
{
SwCoord x, y;
int32_t x, y;
SwPoint& operator-=(const SwPoint& rhs)
{
@ -101,7 +99,7 @@ struct SwPoint
struct SwSize
{
SwCoord w, h;
int32_t w, h;
};
struct SwOutline
@ -203,15 +201,15 @@ struct SwStrokeBorder
struct SwStroke
{
SwFixed angleIn;
SwFixed angleOut;
int64_t angleIn;
int64_t angleOut;
SwPoint center;
SwFixed lineLength;
SwFixed subPathAngle;
int64_t lineLength;
int64_t subPathAngle;
SwPoint ptStartSubPath;
SwFixed subPathLineLength;
SwFixed width;
SwFixed miterlimit;
int64_t subPathLineLength;
int64_t width;
int64_t miterlimit;
SwFill* fill = nullptr;
SwStrokeBorder borders[2];
float sx, sy;
@ -319,9 +317,9 @@ struct SwMpool
unsigned allocSize;
};
static inline SwCoord TO_SWCOORD(float val)
static inline int32_t TO_SWCOORD(float val)
{
return SwCoord(val * 64.0f);
return int32_t(val * 64.0f);
}
static inline uint32_t JOIN(uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3)
@ -345,7 +343,7 @@ static inline uint8_t INTERPOLATE8(uint8_t s, uint8_t d, uint8_t a)
return (((s) * (a) + 0xff) >> 8) + (((d) * ~(a) + 0xff) >> 8);
}
static inline SwCoord HALF_STROKE(float width)
static inline int32_t HALF_STROKE(float width)
{
return TO_SWCOORD(width * 0.5f);
}
@ -515,17 +513,17 @@ static inline uint32_t opBlendSoftLight(uint32_t s, uint32_t d, TVG_UNUSED uint8
int64_t mathMultiply(int64_t a, int64_t b);
int64_t mathDivide(int64_t a, int64_t b);
int64_t mathMulDiv(int64_t a, int64_t b, int64_t c);
void mathRotate(SwPoint& pt, SwFixed angle);
SwFixed mathTan(SwFixed angle);
SwFixed mathAtan(const SwPoint& pt);
SwFixed mathCos(SwFixed angle);
SwFixed mathSin(SwFixed angle);
void mathRotate(SwPoint& pt, int64_t angle);
int64_t mathTan(int64_t angle);
int64_t mathAtan(const SwPoint& pt);
int64_t mathCos(int64_t angle);
int64_t mathSin(int64_t angle);
void mathSplitCubic(SwPoint* base);
void mathSplitLine(SwPoint* base);
SwFixed mathDiff(SwFixed angle1, SwFixed angle2);
SwFixed mathLength(const SwPoint& pt);
int mathCubicAngle(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut);
SwFixed mathMean(SwFixed angle1, SwFixed angle2);
int64_t mathDiff(int64_t angle1, int64_t angle2);
int64_t mathLength(const SwPoint& pt);
int mathCubicAngle(const SwPoint* base, int64_t& angleIn, int64_t& angleMid, int64_t& angleOut);
int64_t mathMean(int64_t angle1, int64_t angle2);
SwPoint mathTransform(const Point* to, const Matrix& transform);
bool mathUpdateOutlineBBox(const SwOutline* outline, const RenderRegion& clipBox, RenderRegion& renderBox, bool fastTrack);

View file

@ -28,7 +28,7 @@
/* Internal Class Implementation */
/************************************************************************/
static float TO_RADIAN(SwFixed angle)
static float TO_RADIAN(int64_t angle)
{
return (float(angle) / 65536.0f) * (MATH_PI / 180.0f);
}
@ -38,13 +38,13 @@ static float TO_RADIAN(SwFixed angle)
/* External Class Implementation */
/************************************************************************/
SwFixed mathMean(SwFixed angle1, SwFixed angle2)
int64_t mathMean(int64_t angle1, int64_t angle2)
{
return angle1 + mathDiff(angle1, angle2) / 2;
}
int mathCubicAngle(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut)
int mathCubicAngle(const SwPoint* base, int64_t& angleIn, int64_t& angleMid, int64_t& angleOut)
{
auto d1 = base[2] - base[3];
auto d2 = base[1] - base[2];
@ -154,7 +154,7 @@ int64_t mathMulDiv(int64_t a, int64_t b, int64_t c)
}
void mathRotate(SwPoint& pt, SwFixed angle)
void mathRotate(SwPoint& pt, int64_t angle)
{
if (angle == 0 || pt.zero()) return;
@ -164,39 +164,39 @@ void mathRotate(SwPoint& pt, SwFixed angle)
auto cosv = cosf(radian);
auto sinv = sinf(radian);
pt.x = SwCoord(nearbyint((v.x * cosv - v.y * sinv) * 64.0f));
pt.y = SwCoord(nearbyint((v.x * sinv + v.y * cosv) * 64.0f));
pt.x = int32_t(nearbyint((v.x * cosv - v.y * sinv) * 64.0f));
pt.y = int32_t(nearbyint((v.x * sinv + v.y * cosv) * 64.0f));
}
SwFixed mathTan(SwFixed angle)
int64_t mathTan(int64_t angle)
{
if (angle == 0) return 0;
return SwFixed(tanf(TO_RADIAN(angle)) * 65536.0f);
return int64_t(tanf(TO_RADIAN(angle)) * 65536.0f);
}
SwFixed mathAtan(const SwPoint& pt)
int64_t mathAtan(const SwPoint& pt)
{
if (pt.zero()) return 0;
return SwFixed(tvg::atan2(TO_FLOAT(pt.y), TO_FLOAT(pt.x)) * (180.0f / MATH_PI) * 65536.0f);
return int64_t(tvg::atan2(TO_FLOAT(pt.y), TO_FLOAT(pt.x)) * (180.0f / MATH_PI) * 65536.0f);
}
SwFixed mathSin(SwFixed angle)
int64_t mathSin(int64_t angle)
{
if (angle == 0) return 0;
return mathCos(SW_ANGLE_PI2 - angle);
}
SwFixed mathCos(SwFixed angle)
int64_t mathCos(int64_t angle)
{
return SwFixed(cosf(TO_RADIAN(angle)) * 65536.0f);
return int64_t(cosf(TO_RADIAN(angle)) * 65536.0f);
}
SwFixed mathLength(const SwPoint& pt)
int64_t mathLength(const SwPoint& pt)
{
if (pt.zero()) return 0;
@ -205,20 +205,20 @@ SwFixed mathLength(const SwPoint& pt)
if (pt.y == 0) return abs(pt.x);
auto v = pt.toPoint();
//return static_cast<SwFixed>(sqrtf(v.x * v.x + v.y * v.y) * 65536.0f);
//return static_cast<int64_t>(sqrtf(v.x * v.x + v.y * v.y) * 65536.0f);
/* approximate sqrt(x*x + y*y) using alpha max plus beta min algorithm.
With alpha = 1, beta = 3/8, giving results with the largest error less
than 7% compared to the exact value. */
if (v.x < 0) v.x = -v.x;
if (v.y < 0) v.y = -v.y;
return static_cast<SwFixed>((v.x > v.y) ? (v.x + v.y * 0.375f) : (v.y + v.x * 0.375f));
return static_cast<int64_t>((v.x > v.y) ? (v.x + v.y * 0.375f) : (v.y + v.x * 0.375f));
}
void mathSplitCubic(SwPoint* base)
{
SwCoord a, b, c, d;
int32_t a, b, c, d;
base[6].x = base[3].x;
c = base[1].x;
@ -250,7 +250,7 @@ void mathSplitLine(SwPoint* base)
}
SwFixed mathDiff(SwFixed angle1, SwFixed angle2)
int64_t mathDiff(int64_t angle1, int64_t angle2)
{
auto delta = angle2 - angle1;

View file

@ -330,7 +330,7 @@ void effectDropShadowUpdate(RenderEffectDropShadow* params, const Matrix& transf
//offset
if (params->distance > 0.0f) {
auto radian = tvg::deg2rad(90.0f - params->angle);
rd->offset = {(SwCoord)(params->distance * cosf(radian)), (SwCoord)(-1.0f * params->distance * sinf(radian))};
rd->offset = {(int32_t)(params->distance * cosf(radian)), (int32_t)(-1.0f * params->distance * sinf(radian))};
} else {
rd->offset = {0, 0};
}

View file

@ -202,13 +202,13 @@ using Area = long;
struct Band
{
SwCoord min, max;
int32_t min, max;
};
struct Cell
{
SwCoord x;
SwCoord cover;
int32_t x;
int32_t cover;
Area area;
Cell *next;
};
@ -220,11 +220,11 @@ struct RleWorker
SwPoint cellPos;
SwPoint cellMin;
SwPoint cellMax;
SwCoord cellXCnt;
SwCoord cellYCnt;
int32_t cellXCnt;
int32_t cellYCnt;
Area area;
SwCoord cover;
int32_t cover;
Cell* cells;
ptrdiff_t maxCells;
@ -245,7 +245,7 @@ struct RleWorker
long bufferSize;
Cell** yCells;
SwCoord yCnt;
int32_t yCnt;
bool invalid;
bool antiAlias;
@ -254,11 +254,11 @@ struct RleWorker
static inline SwPoint UPSCALE(const SwPoint& pt)
{
return {SwCoord(((unsigned long) pt.x) << (PIXEL_BITS - 6)), SwCoord(((unsigned long) pt.y) << (PIXEL_BITS - 6))};
return {int32_t(((unsigned long) pt.x) << (PIXEL_BITS - 6)), int32_t(((unsigned long) pt.y) << (PIXEL_BITS - 6))};
}
static inline SwCoord TRUNC(const SwCoord x)
static inline int32_t TRUNC(const int32_t x)
{
return x >> PIXEL_BITS;
}
@ -282,7 +282,7 @@ static inline SwPoint FRACT(const SwPoint& pt)
* algorithm. We use alpha = 1, beta = 3/8, giving us results with a
* largest error less than 7% compared to the exact value.
*/
static inline SwCoord HYPOT(SwPoint pt)
static inline int32_t HYPOT(SwPoint pt)
{
if (pt.x < 0) pt.x = -pt.x;
if (pt.y < 0) pt.y = -pt.y;
@ -290,7 +290,7 @@ static inline SwCoord HYPOT(SwPoint pt)
}
static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoord aCount)
static void _horizLine(RleWorker& rw, int32_t x, int32_t y, int32_t area, int32_t aCount)
{
x += rw.cellMin.x;
y += rw.cellMin.y;
@ -328,7 +328,7 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
auto& span = rle->spans.last();
if ((span.coverage == coverage) && (span.y == y) && (span.x + span.len == x)) {
//Clip x range
SwCoord xOver = 0;
int32_t xOver = 0;
if (x + aCount >= rw.cellMax.x) xOver -= (x + aCount - rw.cellMax.x);
if (x < rw.cellMin.x) xOver -= (rw.cellMin.x - x);
span.len += (aCount + xOver);
@ -337,7 +337,7 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
}
//Clip x range
SwCoord xOver = 0;
int32_t xOver = 0;
if (x + aCount >= rw.cellMax.x) xOver -= (x + aCount - rw.cellMax.x);
if (x < rw.cellMin.x) {
xOver -= (rw.cellMin.x - x);
@ -537,7 +537,7 @@ static bool _lineTo(RleWorker& rw, const SwPoint& to)
}
//any other line
} else {
#define SW_UDIV(a, b) (SwCoord)((uint64_t(a) * uint64_t(b)) >> 32)
#define SW_UDIV(a, b) (int32_t)((uint64_t(a) * uint64_t(b)) >> 32)
Area prod = diff.x * f1.y - diff.y * f1.x;
@ -614,7 +614,7 @@ static bool _cubicTo(RleWorker& rw, const SwPoint& ctrl1, const SwPoint& ctrl2,
auto min = arc[0].y;
auto max = arc[0].y;
SwCoord y;
int32_t y;
for (auto i = 1; i < 4; ++i) {
y = arc[i].y;
if (y < min) min = y;
@ -772,7 +772,7 @@ SwRle* rleRender(SwRle* rle, const SwOutline* outline, const RenderRegion& bbox,
auto min = rw.cellMin.y;
auto yMax = rw.cellMax.y;
SwCoord max;
int32_t max;
for (int n = 0; n < bandCnt; ++n, min = max) {
max = min + rw.bandSize;

View file

@ -31,16 +31,16 @@ static constexpr auto SW_STROKE_TAG_CUBIC = 2;
static constexpr auto SW_STROKE_TAG_BEGIN = 4;
static constexpr auto SW_STROKE_TAG_END = 8;
static inline SwFixed SIDE_TO_ROTATE(const int32_t s)
static inline int64_t SIDE_TO_ROTATE(const int32_t s)
{
return (SW_ANGLE_PI2 - static_cast<SwFixed>(s) * SW_ANGLE_PI);
return (SW_ANGLE_PI2 - static_cast<int64_t>(s) * SW_ANGLE_PI);
}
static inline void SCALE(const SwStroke& stroke, SwPoint& pt)
{
pt.x = static_cast<SwCoord>(pt.x * stroke.sx);
pt.y = static_cast<SwCoord>(pt.y * stroke.sy);
pt.x = static_cast<int32_t>(pt.x * stroke.sx);
pt.y = static_cast<int32_t>(pt.y * stroke.sy);
}
@ -131,10 +131,10 @@ static void _borderCubicTo(SwStrokeBorder* border, const SwPoint& ctrl1, const S
}
static void _borderArcTo(SwStrokeBorder* border, const SwPoint& center, SwFixed radius, SwFixed angleStart, SwFixed angleDiff, SwStroke& stroke)
static void _borderArcTo(SwStrokeBorder* border, const SwPoint& center, int64_t radius, int64_t angleStart, int64_t angleDiff, SwStroke& stroke)
{
constexpr SwFixed ARC_CUBIC_ANGLE = SW_ANGLE_PI / 2;
SwPoint a = {static_cast<SwCoord>(radius), 0};
constexpr int64_t ARC_CUBIC_ANGLE = SW_ANGLE_PI / 2;
SwPoint a = {static_cast<int32_t>(radius), 0};
mathRotate(a, angleStart);
SCALE(stroke, a);
a += center;
@ -155,7 +155,7 @@ static void _borderArcTo(SwStrokeBorder* border, const SwPoint& center, SwFixed
theta >>= 1;
//compute end point
SwPoint b = {static_cast<SwCoord>(radius), 0};
SwPoint b = {static_cast<int32_t>(radius), 0};
mathRotate(b, next);
SCALE(stroke, b);
b += center;
@ -163,12 +163,12 @@ static void _borderArcTo(SwStrokeBorder* border, const SwPoint& center, SwFixed
//compute first and second control points
auto length = mathMulDiv(radius, mathSin(theta) * 4, (0x10000L + mathCos(theta)) * 3);
SwPoint a2 = {static_cast<SwCoord>(length), 0};
SwPoint a2 = {static_cast<int32_t>(length), 0};
mathRotate(a2, angle + rotate);
SCALE(stroke, a2);
a2 += a;
SwPoint b2 = {static_cast<SwCoord>(length), 0};
SwPoint b2 = {static_cast<int32_t>(length), 0};
mathRotate(b2, next - rotate);
SCALE(stroke, b2);
b2 += b;
@ -227,7 +227,7 @@ static void _arcTo(SwStroke& stroke, int32_t side)
}
static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
static void _outside(SwStroke& stroke, int32_t side, int64_t lineLength)
{
auto border = stroke.borders + side;
@ -237,8 +237,8 @@ static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
//this is a mitered (pointed) or beveled (truncated) corner
auto rotate = SIDE_TO_ROTATE(side);
auto bevel = stroke.join == StrokeJoin::Bevel;
SwFixed phi = 0;
SwFixed thcos = 0;
int64_t phi = 0;
int64_t thcos = 0;
if (!bevel) {
auto theta = mathDiff(stroke.angleIn, stroke.angleOut);
@ -259,7 +259,7 @@ static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
//this is a bevel (broken angle)
if (bevel) {
SwPoint delta = {static_cast<SwCoord>(stroke.width), 0};
SwPoint delta = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta, stroke.angleOut + rotate);
SCALE(stroke, delta);
delta += stroke.center;
@ -268,7 +268,7 @@ static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
//this is a miter (intersection)
} else {
auto length = mathDivide(stroke.width, thcos);
SwPoint delta = {static_cast<SwCoord>(length), 0};
SwPoint delta = {static_cast<int32_t>(length), 0};
mathRotate(delta, phi);
SCALE(stroke, delta);
delta += stroke.center;
@ -277,7 +277,7 @@ static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
/* Now add and end point
Only needed if not lineto (lineLength is zero for curves) */
if (lineLength == 0) {
delta = {static_cast<SwCoord>(stroke.width), 0};
delta = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta, stroke.angleOut + rotate);
SCALE(stroke, delta);
delta += stroke.center;
@ -288,7 +288,7 @@ static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
}
static void _inside(SwStroke& stroke, int32_t side, SwFixed lineLength)
static void _inside(SwStroke& stroke, int32_t side, int64_t lineLength)
{
auto border = stroke.borders + side;
auto theta = mathDiff(stroke.angleIn, stroke.angleOut) / 2;
@ -299,14 +299,14 @@ static void _inside(SwStroke& stroke, int32_t side, SwFixed lineLength)
lines are long enough (line length is zero for curves). */
if (border->movable && lineLength > 0) {
//compute minimum required length of lines
SwFixed minLength = abs(mathMultiply(stroke.width, mathTan(theta)));
int64_t minLength = abs(mathMultiply(stroke.width, mathTan(theta)));
if (stroke.lineLength >= minLength && lineLength >= minLength) intersect = true;
}
auto rotate = SIDE_TO_ROTATE(side);
if (!intersect) {
delta = {static_cast<SwCoord>(stroke.width), 0};
delta = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta, stroke.angleOut + rotate);
SCALE(stroke, delta);
delta += stroke.center;
@ -315,7 +315,7 @@ static void _inside(SwStroke& stroke, int32_t side, SwFixed lineLength)
//compute median angle
auto phi = stroke.angleIn + theta;
auto thcos = mathCos(theta);
delta = {static_cast<SwCoord>(mathDivide(stroke.width, thcos)), 0};
delta = {static_cast<int32_t>(mathDivide(stroke.width, thcos)), 0};
mathRotate(delta, phi + rotate);
SCALE(stroke, delta);
delta += stroke.center;
@ -325,7 +325,7 @@ static void _inside(SwStroke& stroke, int32_t side, SwFixed lineLength)
}
void _processCorner(SwStroke& stroke, SwFixed lineLength)
void _processCorner(SwStroke& stroke, int64_t lineLength)
{
auto turn = mathDiff(stroke.angleIn, stroke.angleOut);
@ -346,9 +346,9 @@ void _processCorner(SwStroke& stroke, SwFixed lineLength)
}
void _firstSubPath(SwStroke& stroke, SwFixed startAngle, SwFixed lineLength)
void _firstSubPath(SwStroke& stroke, int64_t startAngle, int64_t lineLength)
{
SwPoint delta = {static_cast<SwCoord>(stroke.width), 0};
SwPoint delta = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta, startAngle + SW_ANGLE_PI2);
SCALE(stroke, delta);
@ -383,12 +383,12 @@ static void _lineTo(SwStroke& stroke, const SwPoint& to)
The scale needs to be reverted since the stroke width has not been scaled.
An alternative option is to scale the width of the stroke properly by
calculating the mixture of the sx/sy rating on the stroke direction. */
delta.x = static_cast<SwCoord>(delta.x / stroke.sx);
delta.y = static_cast<SwCoord>(delta.y / stroke.sy);
delta.x = static_cast<int32_t>(delta.x / stroke.sx);
delta.y = static_cast<int32_t>(delta.y / stroke.sy);
auto lineLength = mathLength(delta);
auto angle = mathAtan(delta);
delta = {static_cast<SwCoord>(stroke.width), 0};
delta = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta, angle + SW_ANGLE_PI2);
SCALE(stroke, delta);
@ -438,7 +438,7 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
arc[3] = stroke.center;
while (arc >= bezStack) {
SwFixed angleIn, angleOut, angleMid;
int64_t angleIn, angleOut, angleMid;
//initialize with current direction
angleIn = angleOut = angleMid = stroke.angleIn;
@ -491,7 +491,7 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
auto phi2 = mathMean(angleMid, angleOut);
auto length1 = mathDivide(stroke.width, mathCos(theta1));
auto length2 = mathDivide(stroke.width, mathCos(theta2));
SwFixed alpha0 = 0;
int64_t alpha0 = 0;
//compute direction of original arc
if (stroke.handleWideStrokes) {
@ -505,18 +505,18 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
auto rotate = SIDE_TO_ROTATE(side);
//compute control points
SwPoint _ctrl1 = {static_cast<SwCoord>(length1), 0};
SwPoint _ctrl1 = {static_cast<int32_t>(length1), 0};
mathRotate(_ctrl1, phi1 + rotate);
SCALE(stroke, _ctrl1);
_ctrl1 += arc[2];
SwPoint _ctrl2 = {static_cast<SwCoord>(length2), 0};
SwPoint _ctrl2 = {static_cast<int32_t>(length2), 0};
mathRotate(_ctrl2, phi2 + rotate);
SCALE(stroke, _ctrl2);
_ctrl2 += arc[1];
//compute end point
SwPoint _end = {static_cast<SwCoord>(stroke.width), 0};
SwPoint _end = {static_cast<int32_t>(stroke.width), 0};
mathRotate(_end, angleOut + rotate);
SCALE(stroke, _end);
_end += arc[0];
@ -539,7 +539,7 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
auto sinB = abs(mathSin(beta - gamma));
auto alen = mathMulDiv(blen, sinA, sinB);
SwPoint delta = {static_cast<SwCoord>(alen), 0};
SwPoint delta = {static_cast<int32_t>(alen), 0};
mathRotate(delta, beta);
delta += _start;
@ -568,28 +568,28 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
}
static void _addCap(SwStroke& stroke, SwFixed angle, int32_t side)
static void _addCap(SwStroke& stroke, int64_t angle, int32_t side)
{
if (stroke.cap == StrokeCap::Square) {
auto rotate = SIDE_TO_ROTATE(side);
auto border = stroke.borders + side;
SwPoint delta = {static_cast<SwCoord>(stroke.width), 0};
SwPoint delta = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta, angle);
SCALE(stroke, delta);
SwPoint delta2 = {static_cast<SwCoord>(stroke.width), 0};
SwPoint delta2 = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta2, angle + rotate);
SCALE(stroke, delta2);
delta += stroke.center + delta2;
_borderLineTo(border, delta, false);
delta = {static_cast<SwCoord>(stroke.width), 0};
delta = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta, angle);
SCALE(stroke, delta);
delta2 = {static_cast<SwCoord>(stroke.width), 0};
delta2 = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta2, angle - rotate);
SCALE(stroke, delta2);
delta += delta2 + stroke.center;
@ -603,14 +603,14 @@ static void _addCap(SwStroke& stroke, SwFixed angle, int32_t side)
auto rotate = SIDE_TO_ROTATE(side);
auto border = stroke.borders + side;
SwPoint delta = {static_cast<SwCoord>(stroke.width), 0};
SwPoint delta = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta, angle + rotate);
SCALE(stroke, delta);
delta += stroke.center;
_borderLineTo(border, delta, false);
delta = {static_cast<SwCoord>(stroke.width), 0};
delta = {static_cast<int32_t>(stroke.width), 0};
mathRotate(delta, angle - rotate);
SCALE(stroke, delta);
delta += stroke.center;
@ -822,7 +822,7 @@ void strokeReset(SwStroke* stroke, const RenderShape* rshape, const Matrix& tran
stroke->sy = sqrtf(powf(transform.e12, 2.0f) + powf(transform.e22, 2.0f));
stroke->width = HALF_STROKE(rshape->strokeWidth());
stroke->cap = rshape->strokeCap();
stroke->miterlimit = static_cast<SwFixed>(rshape->strokeMiterlimit() * 65536.0f);
stroke->miterlimit = static_cast<int64_t>(rshape->strokeMiterlimit() * 65536.0f);
//Save line join: it can be temporarily changed when stroking curves...
stroke->joinSaved = stroke->join = rshape->strokeJoin();