common: fix compiler warnings that loss data by mis-matched converision

these conversions are intented, we explicity use casting so that compiler doesn't
catch them anymore.

Change-Id: I9d905c7562c43929b040d034e5ee0d14c6750a80
This commit is contained in:
Hermet Park 2020-08-06 19:50:44 +09:00
parent 083fa57c3e
commit ef11d500ba
3 changed files with 25 additions and 24 deletions

View file

@ -168,7 +168,7 @@ static void _rotate(SwPoint& pt, SwFixed theta)
y = y - ((x + j) >> i); y = y - ((x + j) >> i);
x = tmp; x = tmp;
theta += *atan++; theta += *atan++;
}else { } else {
auto tmp = x - ((y + j) >> i); auto tmp = x - ((y + j) >> i);
y = y + ((x + j) >> i); y = y + ((x + j) >> i);
x = tmp; x = tmp;
@ -176,7 +176,8 @@ static void _rotate(SwPoint& pt, SwFixed theta)
} }
} }
pt = {x, y}; pt.x = static_cast<SwCoord>(x);
pt.y = static_cast<SwCoord>(y);
} }

View file

@ -29,8 +29,8 @@ static SwBBox _clipRegion(Surface& surface, SwBBox& in)
if (bbox.min.x < 0) bbox.min.x = 0; if (bbox.min.x < 0) bbox.min.x = 0;
if (bbox.min.y < 0) bbox.min.y = 0; if (bbox.min.y < 0) bbox.min.y = 0;
if (bbox.max.x > surface.w) bbox.max.x = surface.w; if (bbox.max.x > static_cast<SwCoord>(surface.w)) bbox.max.x = surface.w;
if (bbox.max.y > surface.h) bbox.max.y = surface.h; if (bbox.max.y > static_cast<SwCoord>(surface.h)) bbox.max.y = surface.h;
return bbox; return bbox;
} }

View file

@ -142,7 +142,7 @@ static void _borderCubicTo(SwStrokeBorder* border, SwPoint& ctrl1, SwPoint& ctrl
static void _borderArcTo(SwStrokeBorder* border, SwPoint& center, SwFixed radius, SwFixed angleStart, SwFixed angleDiff, SwStroke& stroke) static void _borderArcTo(SwStrokeBorder* border, SwPoint& center, SwFixed radius, SwFixed angleStart, SwFixed angleDiff, SwStroke& stroke)
{ {
constexpr SwFixed ARC_CUBIC_ANGLE = SW_ANGLE_PI / 2; constexpr SwFixed ARC_CUBIC_ANGLE = SW_ANGLE_PI / 2;
SwPoint a = {radius, 0}; SwPoint a = {static_cast<SwCoord>(radius), 0};
mathRotate(a, angleStart); mathRotate(a, angleStart);
SCALE(stroke, a); SCALE(stroke, a);
a += center; a += center;
@ -163,7 +163,7 @@ static void _borderArcTo(SwStrokeBorder* border, SwPoint& center, SwFixed radius
theta >>= 1; theta >>= 1;
//compute end point //compute end point
SwPoint b = {radius, 0}; SwPoint b = {static_cast<SwCoord>(radius), 0};
mathRotate(b, next); mathRotate(b, next);
SCALE(stroke, b); SCALE(stroke, b);
b += center; b += center;
@ -171,12 +171,12 @@ static void _borderArcTo(SwStrokeBorder* border, SwPoint& center, SwFixed radius
//compute first and second control points //compute first and second control points
auto length = mathMulDiv(radius, mathSin(theta) * 4, (0x10000L + mathCos(theta)) * 3); auto length = mathMulDiv(radius, mathSin(theta) * 4, (0x10000L + mathCos(theta)) * 3);
SwPoint a2 = {length, 0}; SwPoint a2 = {static_cast<SwCoord>(length), 0};
mathRotate(a2, angle + rotate); mathRotate(a2, angle + rotate);
SCALE(stroke, a2); SCALE(stroke, a2);
a2 += a; a2 += a;
SwPoint b2 = {length, 0}; SwPoint b2 = {static_cast<SwCoord>(length), 0};
mathRotate(b2, next - rotate); mathRotate(b2, next - rotate);
SCALE(stroke, b2); SCALE(stroke, b2);
b2 += b; b2 += b;
@ -277,7 +277,7 @@ static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
//this is a bevel (broken angle) //this is a bevel (broken angle)
if (bevel) { if (bevel) {
SwPoint delta = {stroke.width, 0}; SwPoint delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, stroke.angleOut + rotate); mathRotate(delta, stroke.angleOut + rotate);
SCALE(stroke, delta); SCALE(stroke, delta);
delta += stroke.center; delta += stroke.center;
@ -286,7 +286,7 @@ static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
//this is a miter (intersection) //this is a miter (intersection)
} else { } else {
auto length = mathDivide(stroke.width, thcos); auto length = mathDivide(stroke.width, thcos);
SwPoint delta = {length, 0}; SwPoint delta = {static_cast<SwCoord>(length), 0};
mathRotate(delta, phi); mathRotate(delta, phi);
SCALE(stroke, delta); SCALE(stroke, delta);
delta += stroke.center; delta += stroke.center;
@ -295,7 +295,7 @@ static void _outside(SwStroke& stroke, int32_t side, SwFixed lineLength)
/* Now add and end point /* Now add and end point
Only needed if not lineto (lineLength is zero for curves) */ Only needed if not lineto (lineLength is zero for curves) */
if (lineLength == 0) { if (lineLength == 0) {
delta = {stroke.width, 0}; delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, stroke.angleOut + rotate); mathRotate(delta, stroke.angleOut + rotate);
SCALE(stroke, delta); SCALE(stroke, delta);
delta += stroke.center; delta += stroke.center;
@ -324,7 +324,7 @@ static void _inside(SwStroke& stroke, int32_t side, SwFixed lineLength)
auto rotate = SIDE_TO_ROTATE(side); auto rotate = SIDE_TO_ROTATE(side);
if (!intersect) { if (!intersect) {
delta = {stroke.width, 0}; delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, stroke.angleOut + rotate); mathRotate(delta, stroke.angleOut + rotate);
SCALE(stroke, delta); SCALE(stroke, delta);
delta += stroke.center; delta += stroke.center;
@ -366,7 +366,7 @@ void _processCorner(SwStroke& stroke, SwFixed lineLength)
void _firstSubPath(SwStroke& stroke, SwFixed startAngle, SwFixed lineLength) void _firstSubPath(SwStroke& stroke, SwFixed startAngle, SwFixed lineLength)
{ {
SwPoint delta = {stroke.width, 0}; SwPoint delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, startAngle + SW_ANGLE_PI2); mathRotate(delta, startAngle + SW_ANGLE_PI2);
SCALE(stroke, delta); SCALE(stroke, delta);
@ -397,7 +397,7 @@ static void _lineTo(SwStroke& stroke, const SwPoint& to)
auto lineLength = mathLength(delta); auto lineLength = mathLength(delta);
auto angle = mathAtan(delta); auto angle = mathAtan(delta);
delta = {stroke.width, 0}; delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, angle + SW_ANGLE_PI2); mathRotate(delta, angle + SW_ANGLE_PI2);
SCALE(stroke, delta); SCALE(stroke, delta);
@ -509,18 +509,18 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
auto rotate = SIDE_TO_ROTATE(side); auto rotate = SIDE_TO_ROTATE(side);
//compute control points //compute control points
SwPoint _ctrl1 = {length1, 0}; SwPoint _ctrl1 = {static_cast<SwCoord>(length1), 0};
mathRotate(_ctrl1, phi1 + rotate); mathRotate(_ctrl1, phi1 + rotate);
SCALE(stroke, _ctrl1); SCALE(stroke, _ctrl1);
_ctrl1 += arc[2]; _ctrl1 += arc[2];
SwPoint _ctrl2 = {length2, 0}; SwPoint _ctrl2 = {static_cast<SwCoord>(length2), 0};
mathRotate(_ctrl2, phi2 + rotate); mathRotate(_ctrl2, phi2 + rotate);
SCALE(stroke, _ctrl2); SCALE(stroke, _ctrl2);
_ctrl2 += arc[1]; _ctrl2 += arc[1];
//compute end point //compute end point
SwPoint _end = {stroke.width, 0}; SwPoint _end = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(_end, angleOut + rotate); mathRotate(_end, angleOut + rotate);
SCALE(stroke, _end); SCALE(stroke, _end);
_end += arc[0]; _end += arc[0];
@ -544,7 +544,7 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
auto sinB = abs(mathSin(beta - gamma)); auto sinB = abs(mathSin(beta - gamma));
auto alen = mathMulDiv(blen, sinA, sinB); auto alen = mathMulDiv(blen, sinA, sinB);
SwPoint delta = {alen, 0}; SwPoint delta = {static_cast<SwCoord>(alen), 0};
mathRotate(delta, beta); mathRotate(delta, beta);
delta += _start; delta += _start;
@ -581,22 +581,22 @@ static void _addCap(SwStroke& stroke, SwFixed angle, int32_t side)
auto rotate = SIDE_TO_ROTATE(side); auto rotate = SIDE_TO_ROTATE(side);
auto border = stroke.borders + side; auto border = stroke.borders + side;
SwPoint delta = {stroke.width, 0}; SwPoint delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, angle); mathRotate(delta, angle);
SCALE(stroke, delta); SCALE(stroke, delta);
SwPoint delta2 = {stroke.width, 0}; SwPoint delta2 = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta2, angle + rotate); mathRotate(delta2, angle + rotate);
SCALE(stroke, delta2); SCALE(stroke, delta2);
delta += stroke.center + delta2; delta += stroke.center + delta2;
_borderLineTo(border, delta, false); _borderLineTo(border, delta, false);
delta = {stroke.width, 0}; delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, angle); mathRotate(delta, angle);
SCALE(stroke, delta); SCALE(stroke, delta);
delta2 = {stroke.width, 0}; delta2 = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta2, angle - rotate); mathRotate(delta2, angle - rotate);
SCALE(stroke, delta2); SCALE(stroke, delta2);
delta += delta2 + stroke.center; delta += delta2 + stroke.center;
@ -614,14 +614,14 @@ static void _addCap(SwStroke& stroke, SwFixed angle, int32_t side)
auto rotate = SIDE_TO_ROTATE(side); auto rotate = SIDE_TO_ROTATE(side);
auto border = stroke.borders + side; auto border = stroke.borders + side;
SwPoint delta = {stroke.width, 0}; SwPoint delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, angle + rotate); mathRotate(delta, angle + rotate);
SCALE(stroke, delta); SCALE(stroke, delta);
delta += stroke.center; delta += stroke.center;
_borderLineTo(border, delta, false); _borderLineTo(border, delta, false);
delta = {stroke.width, 0}; delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, angle - rotate); mathRotate(delta, angle - rotate);
SCALE(stroke, delta); SCALE(stroke, delta);
delta += stroke.center; delta += stroke.center;