mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 20:14:37 +00:00
common: preventing msvc compiler warnings (#817)
This commit is contained in:
parent
9d63e2894d
commit
4589196689
7 changed files with 24 additions and 24 deletions
|
@ -150,7 +150,7 @@ bool _prepareRadial(SwFill* fill, const RadialGradient* radial, const Matrix* tr
|
||||||
//FIXME; Scale + Rotation is not working properly
|
//FIXME; Scale + Rotation is not working properly
|
||||||
radius *= sx;
|
radius *= sx;
|
||||||
|
|
||||||
if (abs(sx - sy) > FLT_EPSILON) {
|
if (fabsf(sx - sy) > FLT_EPSILON) {
|
||||||
fill->sx = sx;
|
fill->sx = sx;
|
||||||
fill->sy = sy;
|
fill->sy = sy;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ void fillFetchLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x,
|
||||||
float t = (fill->linear.dx * rx + fill->linear.dy * ry + fill->linear.offset) * (GRADIENT_STOP_SIZE - 1);
|
float t = (fill->linear.dx * rx + fill->linear.dy * ry + fill->linear.offset) * (GRADIENT_STOP_SIZE - 1);
|
||||||
float inc = (fill->linear.dx) * (GRADIENT_STOP_SIZE - 1);
|
float inc = (fill->linear.dx) * (GRADIENT_STOP_SIZE - 1);
|
||||||
|
|
||||||
if (abs(inc) < FLT_EPSILON) {
|
if (fabsf(inc) < FLT_EPSILON) {
|
||||||
auto color = _fixedPixel(fill, static_cast<int32_t>(t * FIXPT_SIZE));
|
auto color = _fixedPixel(fill, static_cast<int32_t>(t * FIXPT_SIZE));
|
||||||
rasterRGBA32(dst, color, 0, len);
|
rasterRGBA32(dst, color, 0, len);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -40,8 +40,8 @@ static inline SwFixed SIDE_TO_ROTATE(const int32_t s)
|
||||||
|
|
||||||
static inline void SCALE(const SwStroke& stroke, SwPoint& pt)
|
static inline void SCALE(const SwStroke& stroke, SwPoint& pt)
|
||||||
{
|
{
|
||||||
pt.x *= stroke.sx;
|
pt.x = static_cast<SwCoord>(pt.x * stroke.sx);
|
||||||
pt.y *= stroke.sy;
|
pt.y = static_cast<SwCoord>(pt.y * stroke.sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ float bezLength(const Bezier& cur)
|
||||||
auto len = _lineLength(cur.start, cur.ctrl1) + _lineLength(cur.ctrl1, cur.ctrl2) + _lineLength(cur.ctrl2, cur.end);
|
auto len = _lineLength(cur.start, cur.ctrl1) + _lineLength(cur.ctrl1, cur.ctrl2) + _lineLength(cur.ctrl2, cur.end);
|
||||||
auto chord = _lineLength(cur.start, cur.end);
|
auto chord = _lineLength(cur.start, cur.end);
|
||||||
|
|
||||||
if (fabs(len - chord) > BEZIER_EPSILON) {
|
if (fabsf(len - chord) > BEZIER_EPSILON) {
|
||||||
bezSplit(cur, left, right);
|
bezSplit(cur, left, right);
|
||||||
return bezLength(left) + bezLength(right);
|
return bezLength(left) + bezLength(right);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ float bezAt(const Bezier& bz, float at)
|
||||||
bezSplitLeft(right, t, left);
|
bezSplitLeft(right, t, left);
|
||||||
len = bezLength(left);
|
len = bezLength(left);
|
||||||
|
|
||||||
if (fabs(len - at) < BEZIER_EPSILON || fabs(smallest - biggest) < BEZIER_EPSILON) {
|
if (fabsf(len - at) < BEZIER_EPSILON || fabsf(smallest - biggest) < BEZIER_EPSILON) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ Result Shape::appendArc(float cx, float cy, float radius, float startAngle, floa
|
||||||
startAngle = (startAngle * M_PI) / 180;
|
startAngle = (startAngle * M_PI) / 180;
|
||||||
sweep = sweep * M_PI / 180;
|
sweep = sweep * M_PI / 180;
|
||||||
|
|
||||||
auto nCurves = ceil(abs(sweep / M_PI_HALF));
|
auto nCurves = ceil(fabsf(sweep / M_PI_HALF));
|
||||||
auto sweepSign = (sweep < 0 ? -1 : 1);
|
auto sweepSign = (sweep < 0 ? -1 : 1);
|
||||||
auto fract = fmodf(sweep, M_PI_HALF);
|
auto fract = fmodf(sweep, M_PI_HALF);
|
||||||
fract = (fabsf(fract) < std::numeric_limits<float>::epsilon()) ? M_PI_HALF * sweepSign : fract;
|
fract = (fabsf(fract) < std::numeric_limits<float>::epsilon()) ? M_PI_HALF * sweepSign : fract;
|
||||||
|
@ -194,7 +194,7 @@ Result Shape::appendArc(float cx, float cy, float radius, float startAngle, floa
|
||||||
auto by = end.y;
|
auto by = end.y;
|
||||||
auto q1 = ax * ax + ay * ay;
|
auto q1 = ax * ax + ay * ay;
|
||||||
auto q2 = ax * bx + ay * by + q1;
|
auto q2 = ax * bx + ay * by + q1;
|
||||||
auto k2 = static_cast<float> (4.0/3.0) * ((sqrtf(2 * q1 * q2) - q2) / (ax * by - ay * bx));
|
auto k2 = (4.0f/3.0f) * ((sqrtf(2 * q1 * q2) - q2) / (ax * by - ay * bx));
|
||||||
|
|
||||||
start = end; //Next start point is the current end point
|
start = end; //Next start point is the current end point
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ void _pathAppendArcTo(Array<PathCommand>* cmds, Array<Point>* pts, Point* cur, P
|
||||||
//Correction of out-of-range radii, see F6.6.2 (step 4)
|
//Correction of out-of-range radii, see F6.6.2 (step 4)
|
||||||
if (lambda > 1.0f) {
|
if (lambda > 1.0f) {
|
||||||
//See F6.6.3
|
//See F6.6.3
|
||||||
float lambdaRoot = sqrt(lambda);
|
float lambdaRoot = sqrtf(lambda);
|
||||||
|
|
||||||
rx *= lambdaRoot;
|
rx *= lambdaRoot;
|
||||||
ry *= lambdaRoot;
|
ry *= lambdaRoot;
|
||||||
|
@ -132,7 +132,7 @@ void _pathAppendArcTo(Array<PathCommand>* cmds, Array<Point>* pts, Point* cur, P
|
||||||
if (c < 0.0f) {
|
if (c < 0.0f) {
|
||||||
//Scale uniformly until we have a single solution
|
//Scale uniformly until we have a single solution
|
||||||
//(see F6.2) i.e. when c == 0.0
|
//(see F6.2) i.e. when c == 0.0
|
||||||
float scale = sqrt(1.0f - c / (rx2 * ry2));
|
float scale = sqrtf(1.0f - c / (rx2 * ry2));
|
||||||
rx *= scale;
|
rx *= scale;
|
||||||
ry *= scale;
|
ry *= scale;
|
||||||
//Update rx2 and ry2
|
//Update rx2 and ry2
|
||||||
|
@ -147,7 +147,7 @@ void _pathAppendArcTo(Array<PathCommand>* cmds, Array<Point>* pts, Point* cur, P
|
||||||
cy = 0.0f;
|
cy = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
//Complete c calculation
|
//Complete c calculation
|
||||||
c = sqrt(c / ((rx2 * y1p2) + (ry2 * x1p2)));
|
c = sqrtf(c / ((rx2 * y1p2) + (ry2 * x1p2)));
|
||||||
//Inverse sign if Fa == Fs
|
//Inverse sign if Fa == Fs
|
||||||
if (largeArc == sweep) c = -c;
|
if (largeArc == sweep) c = -c;
|
||||||
|
|
||||||
|
@ -186,26 +186,26 @@ void _pathAppendArcTo(Array<PathCommand>* cmds, Array<Point>* pts, Point* cur, P
|
||||||
//(smaller than 90 degrees)
|
//(smaller than 90 degrees)
|
||||||
//We add one extra segment because we want something
|
//We add one extra segment because we want something
|
||||||
//Smaller than 90deg (i.e. not 90 itself)
|
//Smaller than 90deg (i.e. not 90 itself)
|
||||||
segments = (int)(fabsf(deltaTheta / float(M_PI_2))) + 1.0f;
|
segments = static_cast<int>(fabsf(deltaTheta / float(M_PI_2)) + 1.0f);
|
||||||
delta = deltaTheta / segments;
|
delta = deltaTheta / segments;
|
||||||
|
|
||||||
//http://www.stillhq.com/ctpfaq/2001/comp.text.pdf-faq-2001-04.txt (section 2.13)
|
//http://www.stillhq.com/ctpfaq/2001/comp.text.pdf-faq-2001-04.txt (section 2.13)
|
||||||
bcp = 4.0f / 3.0f * (1.0f - cos(delta / 2.0f)) / sin(delta / 2.0f);
|
bcp = 4.0f / 3.0f * (1.0f - cosf(delta / 2.0f)) / sinf(delta / 2.0f);
|
||||||
|
|
||||||
cosPhiRx = cosPhi * rx;
|
cosPhiRx = cosPhi * rx;
|
||||||
cosPhiRy = cosPhi * ry;
|
cosPhiRy = cosPhi * ry;
|
||||||
sinPhiRx = sinPhi * rx;
|
sinPhiRx = sinPhi * rx;
|
||||||
sinPhiRy = sinPhi * ry;
|
sinPhiRy = sinPhi * ry;
|
||||||
|
|
||||||
cosTheta1 = cos(theta1);
|
cosTheta1 = cosf(theta1);
|
||||||
sinTheta1 = sin(theta1);
|
sinTheta1 = sinf(theta1);
|
||||||
|
|
||||||
for (int i = 0; i < segments; ++i) {
|
for (int i = 0; i < segments; ++i) {
|
||||||
//End angle (for this segment) = current + delta
|
//End angle (for this segment) = current + delta
|
||||||
float c1x, c1y, ex, ey, c2x, c2y;
|
float c1x, c1y, ex, ey, c2x, c2y;
|
||||||
float theta2 = theta1 + delta;
|
float theta2 = theta1 + delta;
|
||||||
float cosTheta2 = cos(theta2);
|
float cosTheta2 = cosf(theta2);
|
||||||
float sinTheta2 = sin(theta2);
|
float sinTheta2 = sinf(theta2);
|
||||||
Point p[3];
|
Point p[3];
|
||||||
|
|
||||||
//First control point (based on start point sx,sy)
|
//First control point (based on start point sx,sy)
|
||||||
|
|
|
@ -80,7 +80,7 @@ static unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient*
|
||||||
stops[i].r = colorStop->r;
|
stops[i].r = colorStop->r;
|
||||||
stops[i].g = colorStop->g;
|
stops[i].g = colorStop->g;
|
||||||
stops[i].b = colorStop->b;
|
stops[i].b = colorStop->b;
|
||||||
stops[i].a = (colorStop->a * opacity) / 255.0f;
|
stops[i].a = static_cast<uint8_t>((colorStop->a * opacity) / 255);
|
||||||
stops[i].offset = colorStop->offset;
|
stops[i].offset = colorStop->offset;
|
||||||
//check the offset corner cases - refer to: https://svgwg.org/svg2-draft/pservers.html#StopNotes
|
//check the offset corner cases - refer to: https://svgwg.org/svg2-draft/pservers.html#StopNotes
|
||||||
if (colorStop->offset < prevOffset) stops[i].offset = prevOffset;
|
if (colorStop->offset < prevOffset) stops[i].offset = prevOffset;
|
||||||
|
@ -101,12 +101,12 @@ static unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient*
|
||||||
int radius;
|
int radius;
|
||||||
auto fillGrad = RadialGradient::gen();
|
auto fillGrad = RadialGradient::gen();
|
||||||
|
|
||||||
radius = sqrt(pow(rw, 2) + pow(rh, 2)) / sqrt(2.0);
|
radius = static_cast<int>(sqrtf(pow(rw, 2) + pow(rh, 2)) / sqrtf(2.0));
|
||||||
if (!g->userSpace) {
|
if (!g->userSpace) {
|
||||||
//That is according to Units in here
|
//That is according to Units in here
|
||||||
//https://www.w3.org/TR/2015/WD-SVG2-20150915/coords.html
|
//https://www.w3.org/TR/2015/WD-SVG2-20150915/coords.html
|
||||||
int min = (rh > rw) ? rw : rh;
|
int min = static_cast<int>((rh > rw) ? rw : rh);
|
||||||
radius = sqrt(pow(min, 2) + pow(min, 2)) / sqrt(2.0);
|
radius = static_cast<int>(sqrtf(pow(min, 2) + pow(min, 2)) / sqrtf(2.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g->usePercentage) {
|
if (g->usePercentage) {
|
||||||
|
@ -123,7 +123,7 @@ static unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient*
|
||||||
g->radial->cy = g->radial->cx * g->transform->e21 + g->radial->cy * g->transform->e22 + g->transform->e23;
|
g->radial->cy = g->radial->cx * g->transform->e21 + g->radial->cy * g->transform->e22 + g->transform->e23;
|
||||||
g->radial->cx = cx;
|
g->radial->cx = cx;
|
||||||
|
|
||||||
auto sx = sqrt(pow(g->transform->e11, 2) + pow(g->transform->e21, 2));
|
auto sx = sqrtf(pow(g->transform->e11, 2) + pow(g->transform->e21, 2));
|
||||||
g->radial->r *= sx;
|
g->radial->r *= sx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ static unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient*
|
||||||
stops[i].r = colorStop->r;
|
stops[i].r = colorStop->r;
|
||||||
stops[i].g = colorStop->g;
|
stops[i].g = colorStop->g;
|
||||||
stops[i].b = colorStop->b;
|
stops[i].b = colorStop->b;
|
||||||
stops[i].a = (colorStop->a * opacity) / 255.0f;
|
stops[i].a = static_cast<uint8_t>((colorStop->a * opacity) / 255);
|
||||||
stops[i].offset = colorStop->offset;
|
stops[i].offset = colorStop->offset;
|
||||||
//check the offset corner cases - refer to: https://svgwg.org/svg2-draft/pservers.html#StopNotes
|
//check the offset corner cases - refer to: https://svgwg.org/svg2-draft/pservers.html#StopNotes
|
||||||
if (colorStop->offset < prevOffset) stops[i].offset = prevOffset;
|
if (colorStop->offset < prevOffset) stops[i].offset = prevOffset;
|
||||||
|
|
|
@ -438,7 +438,7 @@ TvgBinCounter TvgSaver::serializeStroke(const Shape* shape, const Matrix* pTrans
|
||||||
|
|
||||||
//width
|
//width
|
||||||
auto width = shape->strokeWidth();
|
auto width = shape->strokeWidth();
|
||||||
if (preTransform) width *= sqrt(pow(pTransform->e11, 2) + pow(pTransform->e21, 2)); //we know x/y scaling factors are same.
|
if (preTransform) width *= sqrtf(pow(pTransform->e11, 2) + pow(pTransform->e21, 2)); //we know x/y scaling factors are same.
|
||||||
auto cnt = writeTagProperty(TVG_TAG_SHAPE_STROKE_WIDTH, SIZE(width), &width);
|
auto cnt = writeTagProperty(TVG_TAG_SHAPE_STROKE_WIDTH, SIZE(width), &width);
|
||||||
|
|
||||||
//cap
|
//cap
|
||||||
|
|
Loading…
Add table
Reference in a new issue