mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
all: fix warnings on MSVC
* Explicit casts to suppress warnings * Fixed compiler warnings
This commit is contained in:
parent
e12729e0d3
commit
dad6c71b6c
11 changed files with 45 additions and 44 deletions
|
@ -137,7 +137,7 @@ bool GlRenderer::renderShape(RenderData data)
|
|||
uint8_t r, g, b, a;
|
||||
size_t flags = static_cast<size_t>(sdata->updateFlag);
|
||||
|
||||
GL_CHECK(glViewport(0, 0, sdata->viewWd, sdata->viewHt));
|
||||
GL_CHECK(glViewport(0, 0, (GLsizei)sdata->viewWd, (GLsizei)sdata->viewHt));
|
||||
|
||||
uint32_t primitiveCount = sdata->geometry->getPrimitiveCount();
|
||||
for (uint32_t i = 0; i < primitiveCount; ++i)
|
||||
|
|
|
@ -82,7 +82,7 @@ static int32_t _normalize(SwPoint& pt)
|
|||
auto v = pt;
|
||||
|
||||
//High order bit(MSB)
|
||||
auto shift = 31 - _clz(abs(v.x) | abs(v.y));
|
||||
int32_t shift = 31 - _clz(abs(v.x) | abs(v.y));
|
||||
|
||||
if (shift <= SAFE_MSB) {
|
||||
shift = SAFE_MSB - shift;
|
||||
|
|
|
@ -157,7 +157,7 @@ Result Shape::appendCircle(float cx, float cy, float rx, float ry) noexcept
|
|||
|
||||
Result Shape::appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept
|
||||
{
|
||||
const float M_PI_HALF = M_PI * 0.5f;
|
||||
const float M_PI_HALF = (float)(M_PI * 0.5f);
|
||||
|
||||
//just circle
|
||||
if (sweep >= 360 || sweep <= -360) return appendCircle(cx, cy, radius, radius);
|
||||
|
|
|
@ -45,8 +45,8 @@ bool PngLoader::open(const string& path)
|
|||
|
||||
if (!png_image_begin_read_from_file(image, path.c_str())) return false;
|
||||
|
||||
w = image->width;
|
||||
h = image->height;
|
||||
w = (float)image->width;
|
||||
h = (float)image->height;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ bool PngLoader::open(const char* data, uint32_t size, bool copy)
|
|||
|
||||
if (!png_image_begin_read_from_memory(image, data, size)) return false;
|
||||
|
||||
w = image->width;
|
||||
h = image->height;
|
||||
w = (float)image->width;
|
||||
h = (float)image->height;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ bool RawLoader::open(const uint32_t* data, uint32_t w, uint32_t h, bool copy)
|
|||
{
|
||||
if (!data || w == 0 || h == 0) return false;
|
||||
|
||||
this->w = w;
|
||||
this->h = h;
|
||||
this->w = (float)w;
|
||||
this->h = (float)h;
|
||||
this->copy = copy;
|
||||
|
||||
if (copy) {
|
||||
|
|
|
@ -97,9 +97,9 @@ static float _toFloat(const SvgParser* svgParse, const char* str, SvgParserLengt
|
|||
else if (type == SvgParserLengthType::Horizontal) parsedValue = (parsedValue / 100.0) * svgParse->global.w;
|
||||
else //if other then it's radius
|
||||
{
|
||||
float max = svgParse->global.w;
|
||||
float max = (float)svgParse->global.w;
|
||||
if (max < svgParse->global.h)
|
||||
max = svgParse->global.h;
|
||||
max = (float)svgParse->global.h;
|
||||
parsedValue = (parsedValue / 100.0) * max;
|
||||
}
|
||||
}
|
||||
|
@ -122,8 +122,8 @@ static float _gradientToFloat(const SvgParser* svgParse, const char* str, SvgPar
|
|||
*
|
||||
* https://www.w3.org/TR/2015/WD-SVG2-20150915/coords.html
|
||||
*/
|
||||
if (type == SvgParserLengthType::Vertical) max = svgParse->global.h;
|
||||
else if (type == SvgParserLengthType::Horizontal) max = svgParse->global.w;
|
||||
if (type == SvgParserLengthType::Vertical) max = (float)svgParse->global.h;
|
||||
else if (type == SvgParserLengthType::Horizontal) max = (float)svgParse->global.w;
|
||||
else if (type == SvgParserLengthType::Other) max = sqrtf(pow(svgParse->global.h, 2) + pow(svgParse->global.w, 2)) / sqrtf(2.0);
|
||||
|
||||
if (strstr(str, "%")) parsedValue = parsedValue / 100.0;
|
||||
|
@ -747,13 +747,13 @@ static bool _attrParseSvgNode(void* data, const char* key, const char* value)
|
|||
if (_parseNumber(&value, &doc->vy)) {
|
||||
if (_parseNumber(&value, &doc->vw)) {
|
||||
_parseNumber(&value, &doc->vh);
|
||||
loader->svgParse->global.h = doc->vh;
|
||||
loader->svgParse->global.h = (uint32_t)doc->vh;
|
||||
}
|
||||
loader->svgParse->global.w = doc->vw;
|
||||
loader->svgParse->global.w = (uint32_t)doc->vw;
|
||||
}
|
||||
loader->svgParse->global.y = doc->vy;
|
||||
loader->svgParse->global.y = (int)doc->vy;
|
||||
}
|
||||
loader->svgParse->global.x = doc->vx;
|
||||
loader->svgParse->global.x = (int)doc->vx;
|
||||
} else if (!strcmp(key, "preserveAspectRatio")) {
|
||||
if (!strcmp(value, "none")) doc->preserveAspect = false;
|
||||
} else if (!strcmp(key, "style")) {
|
||||
|
@ -1121,11 +1121,11 @@ static SvgNode* _createSvgNode(SvgLoaderData* loader, SvgNode* parent, const cha
|
|||
|
||||
if (loader->svgParse->global.w == 0) {
|
||||
if (doc->w < FLT_EPSILON) loader->svgParse->global.w = 1;
|
||||
else loader->svgParse->global.w = doc->w;
|
||||
else loader->svgParse->global.w = (uint32_t)doc->w;
|
||||
}
|
||||
if (loader->svgParse->global.h == 0) {
|
||||
if (doc->h < FLT_EPSILON) loader->svgParse->global.h = 1;
|
||||
else loader->svgParse->global.h =doc->h;
|
||||
else loader->svgParse->global.h = (uint32_t)doc->h;
|
||||
}
|
||||
|
||||
return loader->svgParse->node;
|
||||
|
|
|
@ -335,6 +335,7 @@ struct SvgNode
|
|||
SvgImageNode image;
|
||||
} node;
|
||||
bool display;
|
||||
~SvgNode();
|
||||
};
|
||||
|
||||
struct SvgParser
|
||||
|
|
|
@ -176,10 +176,10 @@ void _pathAppendArcTo(Array<PathCommand>* cmds, Array<Point>* pts, Point* cur, P
|
|||
|
||||
if (sweep) {
|
||||
//Ensure delta theta < 0 or else add 360 degrees
|
||||
if (deltaTheta < 0.0f) deltaTheta += 2.0f * M_PI;
|
||||
if (deltaTheta < 0.0f) deltaTheta += (float)(2.0f * M_PI);
|
||||
} else {
|
||||
//Ensure delta theta > 0 or else substract 360 degrees
|
||||
if (deltaTheta > 0.0f) deltaTheta -= 2.0f * M_PI;
|
||||
if (deltaTheta > 0.0f) deltaTheta -= (float)(2.0f * M_PI);
|
||||
}
|
||||
|
||||
//Add several cubic bezier to approximate the arc
|
||||
|
@ -477,8 +477,8 @@ static char* _nextCommand(char* path, char* cmd, float* arr, int* count)
|
|||
if (_parseFlag(&path, &sweep)) {
|
||||
if (_parseNumber(&path, &arr[5])) {
|
||||
if (_parseNumber(&path, &arr[6])) {
|
||||
arr[3] = large;
|
||||
arr[4] = sweep;
|
||||
arr[3] = (float)large;
|
||||
arr[4] = (float)sweep;
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,17 +214,17 @@ float svgUtilStrtof(const char *nPtr, char **endPtr)
|
|||
}
|
||||
else if (*iter == 0) goto on_success;
|
||||
|
||||
if ((_floatExact(val, 2.2250738585072011)) && ((minus_e * (int)expo_part) == -308))
|
||||
if ((_floatExact(val, 2.2250738585072011f)) && ((minus_e * (int)expo_part) == -308))
|
||||
{
|
||||
val *= 1.0e-308;
|
||||
val *= 1.0e-308f;
|
||||
a = iter;
|
||||
errno = ERANGE;
|
||||
goto on_success;
|
||||
}
|
||||
|
||||
if ((_floatExact(val, 2.2250738585072012)) && ((minus_e * (int)expo_part) <= -308))
|
||||
if ((_floatExact(val, 2.2250738585072012f)) && ((minus_e * (int)expo_part) <= -308))
|
||||
{
|
||||
val *= 1.0e-308;
|
||||
val *= 1.0e-308f;
|
||||
a = iter;
|
||||
goto on_success;
|
||||
}
|
||||
|
|
|
@ -34,17 +34,17 @@ TEST_CASE("Appending Commands", "[tvgShape]")
|
|||
REQUIRE(shape->close() == Result::Success);
|
||||
|
||||
REQUIRE(shape->moveTo(100, 100) == Result::Success);
|
||||
REQUIRE(shape->moveTo(99999999, -99999999) == Result::Success);
|
||||
REQUIRE(shape->moveTo(99999999.0f, -99999999.0f) == Result::Success);
|
||||
REQUIRE(shape->moveTo(0, 0) == Result::Success);
|
||||
|
||||
REQUIRE(shape->lineTo(120, 140) == Result::Success);
|
||||
REQUIRE(shape->lineTo(99999999, -99999999) == Result::Success);
|
||||
REQUIRE(shape->lineTo(99999999.0f, -99999999.0f) == Result::Success);
|
||||
REQUIRE(shape->lineTo(0, 0) == Result::Success);
|
||||
|
||||
REQUIRE(shape->cubicTo(0, 0, 0, 0, 0, 0) == Result::Success);
|
||||
REQUIRE(shape->cubicTo(0, 0, 99999999, -99999999, 0, 0) == Result::Success);
|
||||
REQUIRE(shape->cubicTo(0, 0, 99999999, -99999999, 99999999, -99999999) == Result::Success);
|
||||
REQUIRE(shape->cubicTo(99999999, -99999999, 99999999, -99999999, 99999999, -99999999) == Result::Success);
|
||||
REQUIRE(shape->cubicTo(0, 0, 99999999.0f, -99999999.0f, 0, 0) == Result::Success);
|
||||
REQUIRE(shape->cubicTo(0, 0, 99999999.0f, -99999999.0f, 99999999.0f, -99999999.0f) == Result::Success);
|
||||
REQUIRE(shape->cubicTo(99999999.0f, -99999999.0f, 99999999.0f, -99999999.0f, 99999999.0f, -99999999.0f) == Result::Success);
|
||||
|
||||
REQUIRE(shape->close() == Result::Success);
|
||||
|
||||
|
@ -61,22 +61,22 @@ TEST_CASE("Appending Shapes", "[tvgShape]")
|
|||
REQUIRE(shape->lineTo(120, 140) == Result::Success);
|
||||
|
||||
REQUIRE(shape->appendRect(0, 0, 0, 0, 0, 0) == Result::Success);
|
||||
REQUIRE(shape->appendRect(0, 0,99999999, -99999999, 0, 0) == Result::Success);
|
||||
REQUIRE(shape->appendRect(0, 0, 0, 0, -99999999, 99999999) == Result::Success);
|
||||
REQUIRE(shape->appendRect(99999999, -99999999, 99999999, -99999999, 99999999, -99999999) == Result::Success);
|
||||
REQUIRE(shape->appendRect(0, 0,99999999.0f, -99999999.0f, 0, 0) == Result::Success);
|
||||
REQUIRE(shape->appendRect(0, 0, 0, 0, -99999999.0f, 99999999.0f) == Result::Success);
|
||||
REQUIRE(shape->appendRect(99999999.0f, -99999999.0f, 99999999.0f, -99999999.0f, 99999999.0f, -99999999.0f) == Result::Success);
|
||||
|
||||
REQUIRE(shape->appendCircle(0, 0, 0, 0) == Result::Success);
|
||||
REQUIRE(shape->appendCircle(-99999999, 99999999, 0, 0) == Result::Success);
|
||||
REQUIRE(shape->appendCircle(-99999999, 99999999, -99999999, 99999999) == Result::Success);
|
||||
REQUIRE(shape->appendCircle(-99999999.0f, 99999999.0f, 0, 0) == Result::Success);
|
||||
REQUIRE(shape->appendCircle(-99999999.0f, 99999999.0f, -99999999.0f, 99999999.0f) == Result::Success);
|
||||
|
||||
REQUIRE(shape->appendArc(0, 0, 0, 0, 0, false) == Result::Success);
|
||||
REQUIRE(shape->appendArc(0, 0, 0, 0, 0, true) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999, 99999999, 0, 0, 0, false) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999, 99999999, 0, 0, 0, true) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999, 99999999, -99999999, 99999999, 0, false) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999, 99999999, -99999999, 99999999, 0, true) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999, 99999999, -99999999, 99999999, -400, false) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999, 99999999, -99999999, 99999999, 400, true) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999.0f, 99999999.0f, 0, 0, 0, false) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999.0f, 99999999.0f, 0, 0, 0, true) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999.0f, 99999999.0f, -99999999.0f, 99999999.0f, 0, false) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999.0f, 99999999.0f, -99999999.0f, 99999999.0f, 0, true) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999.0f, 99999999.0f, -99999999.0f, 99999999.0f, -400, false) == Result::Success);
|
||||
REQUIRE(shape->appendArc(-99999999.0f, 99999999.0f, -99999999.0f, 99999999.0f, 400, true) == Result::Success);
|
||||
}
|
||||
|
||||
TEST_CASE("Appending Pathes", "[tvgShape]")
|
||||
|
|
|
@ -275,7 +275,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
|||
basicPicture = Picture::gen();
|
||||
REQUIRE(basicPicture);
|
||||
REQUIRE(basicPicture->load(TEST_DIR"/test.png") == Result::Success);
|
||||
REQUIRE(basicPicture->scale(0.2) == Result::Success);
|
||||
REQUIRE(basicPicture->scale(0.2f) == Result::Success);
|
||||
rectMask = tvg::Shape::gen();
|
||||
REQUIRE(rectMask);
|
||||
REQUIRE(rectMask->appendRect(10, 10, 30, 30, 0, 0) == Result::Success);
|
||||
|
|
Loading…
Add table
Reference in a new issue