Fix type conversion warnings.

pull/216/head
whitequark 2017-03-10 19:39:55 +00:00
parent dbf66639aa
commit 27b59f601e
11 changed files with 32 additions and 29 deletions

@ -1 +1 @@
Subproject commit 3475a9bf811afddde7d0638fbcc2b0200d542b07
Subproject commit 6f362317bf3f176b613be48512a88b78125c79f4

View File

@ -633,16 +633,16 @@ public:
if(data.space != DRW::ModelSpace) return;
if(addPendingBlockEntity<DRW_Polyline>(data)) return;
int vNum = data.vertlist.size();
size_t vNum = data.vertlist.size();
// Check for closed polyline.
if((data.flags & 1) != 1) vNum--;
// Correct coordinate system for the case where z=-1, as described in
// http://paulbourke.net/dataformats/dxf/dxf10.html.
bool needSwapX = data.extPoint.z == -1.0;
bool needSwapX = (data.extPoint.z == -1.0);
for(int i = 0; i < vNum; i++) {
for(size_t i = 0; i < vNum; i++) {
DRW_Coord c0 = data.vertlist[i]->basePoint;
DRW_Coord c1 = data.vertlist[(i + 1) % data.vertlist.size()]->basePoint;

View File

@ -120,11 +120,12 @@ void PaintGraphics() {
pixmap->format = Pixmap::Format::BGRA;
pixmap->width = camera.width;
pixmap->height = camera.height;
pixmap->stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, camera.width);
pixmap->stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, (int)camera.width);
pixmap->data = std::vector<uint8_t>(pixmap->stride * pixmap->height);
cairo_surface_t *surface =
cairo_image_surface_create_for_data(&pixmap->data[0], CAIRO_FORMAT_RGB24,
pixmap->width, pixmap->height, pixmap->stride);
(int)pixmap->width, (int)pixmap->height,
(int)pixmap->stride);
cairo_t *context = cairo_create(surface);
CairoRenderer canvas;

View File

@ -867,7 +867,7 @@ void SolveSpace::ToggleFullScreen()
}
bool SolveSpace::FullScreenIsActive()
{
return GetWindowLong(GraphicsWnd, GWL_STYLE) & WS_OVERLAPPEDWINDOW;
return (GetWindowLong(GraphicsWnd, GWL_STYLE) & WS_OVERLAPPEDWINDOW) != 0;
}
void SolveSpace::InvalidateText()

View File

@ -61,9 +61,10 @@ std::string Narrow(const std::wstring &in)
if(in == L"") return "";
std::string out;
out.resize(WideCharToMultiByte(CP_UTF8, 0, &in[0], in.length(), NULL, 0, NULL, NULL));
ssassert(WideCharToMultiByte(CP_UTF8, 0, &in[0], in.length(),
&out[0], out.length(), NULL, NULL),
out.resize(WideCharToMultiByte(CP_UTF8, 0, &in[0], (int)in.length(),
NULL, 0, NULL, NULL));
ssassert(WideCharToMultiByte(CP_UTF8, 0, &in[0], (int)in.length(),
&out[0], (int)out.length(), NULL, NULL),
"Invalid UTF-16");
return out;
}
@ -83,8 +84,9 @@ std::wstring Widen(const std::string &in)
if(in == "") return L"";
std::wstring out;
out.resize(MultiByteToWideChar(CP_UTF8, 0, &in[0], in.length(), NULL, 0));
ssassert(MultiByteToWideChar(CP_UTF8, 0, &in[0], in.length(), &out[0], out.length()),
out.resize(MultiByteToWideChar(CP_UTF8, 0, &in[0], (int)in.length(), NULL, 0));
ssassert(MultiByteToWideChar(CP_UTF8, 0, &in[0], (int)in.length(),
&out[0], (int)out.length()),
"Invalid UTF-8");
return out;
}
@ -125,7 +127,7 @@ std::string PathFromCurrentDirectory(const std::string &relFilename)
std::wstring relFilenameW = Widen(relFilename);
std::wstring absFilenameW;
absFilenameW.resize(GetFullPathNameW(relFilenameW.c_str(), 0, NULL, NULL));
DWORD length = GetFullPathNameW(relFilenameW.c_str(), absFilenameW.length(),
DWORD length = GetFullPathNameW(relFilenameW.c_str(), (int)absFilenameW.length(),
&absFilenameW[0], NULL);
ssassert(length != 0, "Expected GetFullPathName to succeed");
absFilenameW.resize(length);

View File

@ -335,7 +335,7 @@ void UiCanvas::DrawBitmapText(const std::string &str, int x, int y, RgbaColor co
for(char32_t codepoint : ReadUTF8(str)) {
DrawBitmapChar(codepoint, x, y, color, zIndex);
x += font->GetWidth(codepoint) * 8;
x += (int)font->GetWidth(codepoint) * 8;
}
}

View File

@ -318,9 +318,9 @@ void SurfaceRenderer::OutputInPaintOrder() {
int aZIndex = a.second,
bZIndex = b.second;
int aLayerIndex =
size_t aLayerIndex =
std::find(std::begin(stackup), std::end(stackup), aLayer) - std::begin(stackup);
int bLayerIndex =
size_t bLayerIndex =
std::find(std::begin(stackup), std::end(stackup), bLayer) - std::begin(stackup);
if(aLayerIndex == bLayerIndex) {
return aZIndex < bZIndex;

View File

@ -12,7 +12,7 @@ void CairoRenderer::OutputStart() {
cairo_save(context);
RgbaColor bgColor = lighting.backgroundColor;
cairo_rectangle(context, 0.0, 0.0, camera.width, camera.height);
cairo_rectangle(context, 0.0, 0.0, (double)camera.width, (double)camera.height);
cairo_set_source_rgba(context, bgColor.redF(), bgColor.greenF(), bgColor.blueF(),
bgColor.alphaF());
cairo_fill(context);
@ -47,7 +47,7 @@ void CairoRenderer::SelectStroke(hStroke hcs) {
dash *= stroke->StippleScalePx(camera);
}
cairo_set_line_width(context, stroke->WidthPx(camera));
cairo_set_dash(context, dashes.data(), dashes.size(), 0);
cairo_set_dash(context, dashes.data(), (int)dashes.size(), 0);
cairo_set_source_rgba(context, color.redF(), color.greenF(), color.blueF(),
color.alphaF());
if(antialias) {

View File

@ -49,9 +49,9 @@ std::string LoadStringFromGzip(const std::string &name) {
result.resize(inflatedSize);
stream.next_in = (Bytef *)data;
stream.avail_in = deflatedSize;
stream.avail_in = (uInt)deflatedSize;
stream.next_out = (Bytef *)&result[0];
stream.avail_out = result.length();
stream.avail_out = (uInt)result.length();
ssassert(inflate(&stream, Z_NO_FLUSH) == Z_STREAM_END, "Cannot inflate resource");
ssassert(stream.avail_out == 0, "Inflated resource larger than what trailer indicates");
@ -302,9 +302,9 @@ bool Pixmap::WritePng(FILE *f, bool flip) {
if(setjmp(png_jmpbuf(png_ptr))) goto exit;
png_init_io(png_ptr, f);
png_set_IHDR(png_ptr, info_ptr, width, height, 8,
colorType, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_set_IHDR(png_ptr, info_ptr,
(png_uint_32)width, (png_uint_32)height, 8, colorType,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
if(bgr) png_set_bgr(png_ptr);
png_write_info(png_ptr, info_ptr);
png_write_image(png_ptr, &rows[0]);
@ -528,7 +528,7 @@ void BitmapFont::AddGlyph(char32_t codepoint, std::shared_ptr<const Pixmap> pixm
"Too many glyphs for current texture size");
BitmapFont::Glyph glyph = {};
glyph.advanceCells = pixmap->width / 8;
glyph.advanceCells = (uint8_t)(pixmap->width / 8);
glyph.position = nextPosition++;
glyphs.emplace(codepoint, std::move(glyph));
@ -590,7 +590,7 @@ const BitmapFont::Glyph &BitmapFont::GetGlyph(char32_t codepoint) {
// Read glyph bits.
unsigned short glyphBits[16];
int glyphLength = reader.CountUntilEol();
size_t glyphLength = reader.CountUntilEol();
if(glyphLength == 4 * 16) {
glyph.advanceCells = 2;
for(size_t i = 0; i < 16; i++) {

View File

@ -187,8 +187,8 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
if(canvas) {
canvas->DrawPixmap(icon.pixmap,
x - icon.pixmap->width / 2,
y - icon.pixmap->height / 2);
x - (int)icon.pixmap->width / 2,
y - (int)icon.pixmap->height / 2);
if(toolbarHovered == icon.command ||
(pending.operation == Pending::COMMAND &&
@ -239,7 +239,7 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
}
}
int tw = canvas->canvas->GetBitmapFont()->GetWidth(tooltip) * 8 + 10,
int tw = (int)canvas->canvas->GetBitmapFont()->GetWidth(tooltip) * 8 + 10,
th = SS.TW.LINE_HEIGHT + 2;
int ox = toolbarMouseX + 3, oy = toolbarMouseY + 3;

View File

@ -332,7 +332,7 @@ void TtfFont::PlotString(const std::string &str,
data.u = u;
data.v = v;
data.beziers = sbl;
data.factor = 1.0 / capHeight;
data.factor = (float)(1.0 / capHeight);
data.bx = bx;
if(int fterr = FT_Outline_Decompose(&fontFace->glyph->outline, &outlineFuncs, &data)) {
dbp("freetype: bezier decomposition failed (gid %d): %s",