Fix some compiler warnings (implicit casts & unused vars)

This commit is contained in:
David Capello 2017-04-19 19:25:57 -03:00
parent 7bc593ac34
commit cc7bde6cd1
21 changed files with 77 additions and 65 deletions

View File

@ -59,7 +59,7 @@ bool match_path(const std::string& filter,
base::split_string(filter, a, "/");
base::split_string(layer_path, b, "/");
for (int i=0; i<a.size() && i<b.size(); ++i) {
for (std::size_t i=0; i<a.size() && i<b.size(); ++i) {
if (a[i] != b[i] && a[i] != "*")
return false;
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -581,7 +581,7 @@ private:
for (int y=0; y<frameBounds.h; ++y) {
for (int x=0; x<frameBounds.w; ++x) {
color_t i = get_pixel_fast<IndexedTraits>(frameImage, x, y);
if (i == m_localTransparentIndex)
if (int(i) == m_localTransparentIndex)
continue;
i = m_remap[i];
@ -600,7 +600,7 @@ private:
for (int y=0; y<frameBounds.h; ++y) {
for (int x=0; x<frameBounds.w; ++x) {
color_t i = get_pixel_fast<IndexedTraits>(frameImage, x, y);
if (i == m_localTransparentIndex)
if (int(i) == m_localTransparentIndex)
continue;
i = rgba(
@ -898,7 +898,9 @@ public:
m_nextImage = m_images[2].get();
auto frame_beg = m_fop->roi().selectedFrames().begin();
#if _DEBUG
auto frame_end = m_fop->roi().selectedFrames().end();
#endif
auto frame_it = frame_beg;
// In this code "gifFrame" will be the GIF frame, and "frame" will

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -151,6 +151,7 @@ bool IcoFormat::onLoad(FileOp* fop)
bmpHeader.yPelsPerMeter = fgetl(f); // unused for ico
bmpHeader.clrUsed = fgetl(f); // unused for ico
bmpHeader.clrImportant = fgetl(f); // unused for ico
(void)bmpHeader; // unused
// Read the palette
if (entry.bpp <= 8) {

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -180,7 +180,7 @@ public:
void processPixel(int x, int y) {
color_t c = *m_srcAddress;
if (c == m_maskIndex)
if (int(c) == m_maskIndex)
c = m_palette->getEntry(c) & rgba_rgb_mask; // Alpha = 0
else
c = m_palette->getEntry(c);
@ -245,7 +245,7 @@ public:
void processPixel(int x, int y) {
color_t c = *m_srcAddress;
if (c == m_maskIndex)
if (int(c) == m_maskIndex)
c = m_palette->getEntry(c) & rgba_rgb_mask; // Alpha = 0
else
c = m_palette->getEntry(c);
@ -304,14 +304,14 @@ public:
m_rgbmap(loop->getRgbMap()),
m_opacity(loop->getOpacity()),
m_maskIndex(loop->getLayer()->isBackground() ? -1: loop->sprite()->transparentColor()),
m_color(loop->getPrimaryColor() == m_maskIndex ?
m_color(int(loop->getPrimaryColor()) == m_maskIndex ?
(m_palette->getEntry(loop->getPrimaryColor()) & rgba_rgb_mask):
(m_palette->getEntry(loop->getPrimaryColor()))) {
}
void processPixel(int x, int y) {
color_t c = *m_srcAddress;
if (c == m_maskIndex)
if (int(c) == m_maskIndex)
c = m_palette->getEntry(c) & rgba_rgb_mask; // Alpha = 0
else
c = m_palette->getEntry(c);

View File

@ -148,7 +148,7 @@ private:
gfx::Point p = cpos.origin();
int maxH = 0;
int itemLevel = 0;
Widget* prevChild = nullptr;
//Widget* prevChild = nullptr;
for (auto child : children) {
gfx::Size sz = child->sizeHint(gfx::Size(width, 0));
@ -174,7 +174,7 @@ private:
p.x = cpos.x + itemLevel*font()->textLength(" - ");
p.y += maxH;
maxH = 0;
prevChild = nullptr;
//prevChild = nullptr;
}
if (child->isExpansive())
@ -182,8 +182,8 @@ private:
callback(gfx::Rect(p, sz), child);
if (!isItem) prevChild = child;
if (isBreak) prevChild = nullptr;
//if (!isItem) prevChild = child;
//if (isBreak) prevChild = nullptr;
maxH = std::max(maxH, sz.h);
p.x += sz.w;

View File

@ -651,7 +651,7 @@ void ColorBar::setTransparentIndex(int index)
Sprite* sprite = writer.sprite();
if (sprite &&
sprite->pixelFormat() == IMAGE_INDEXED &&
sprite->transparentColor() != index) {
int(sprite->transparentColor()) != index) {
// TODO merge this code with SpritePropertiesCommand
Transaction transaction(writer.context(), "Set Transparent Color");
DocumentApi api = writer.document()->getApi(transaction);

View File

@ -209,7 +209,7 @@ void ColorButton::onPaint(PaintEvent& ev)
current_editor->sprite()->pixelFormat() == IMAGE_INDEXED) {
m_dependOnLayer = true;
if (current_editor->sprite()->transparentColor() == color.getIndex() &&
if (int(current_editor->sprite()->transparentColor()) == color.getIndex() &&
current_editor->layer() &&
!current_editor->layer()->isBackground()) {
color = app::Color::fromMask();

View File

@ -134,7 +134,7 @@ void ConfigureTimelinePopup::updateWidgetsFromCurrentSettings()
bool visibleThumbBox = Preferences::instance().thumbnails.visibleOptions();
m_box->zoom()->setValue(docPref.thumbnails.zoom());
m_box->zoom()->setValue(int(docPref.thumbnails.zoom())); // TODO add a slider for floating points
m_box->thumbCheck()->setSelected(visibleThumbBox);
m_box->thumbHSeparator()->setVisible(visibleThumbBox);
m_box->thumbBox()->setVisible(visibleThumbBox);

View File

@ -765,7 +765,7 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
if (x > 0) {
gfx::Color color = color_utils::color_for_ui(m_docPref.grid.color());
g->drawVLine(color,
spriteRect.x + m_proj.applyX<double>(x),
spriteRect.x + int(m_proj.applyX<double>(x)),
enclosingRect.y,
enclosingRect.h);
}
@ -776,7 +776,7 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
gfx::Color color = color_utils::color_for_ui(m_docPref.grid.color());
g->drawHLine(color,
enclosingRect.x,
spriteRect.y + m_proj.applyY<double>(y),
spriteRect.y + int(m_proj.applyY<double>(y)),
enclosingRect.w);
}
}
@ -1209,7 +1209,7 @@ gfx::Point Editor::autoScroll(MouseMessage* msg, AutoScroll dir)
return mousePos;
// Hide the brush preview
//HideBrushPreview hide(editor->brushPreview());
//HideBrushPreview hide(m_brushPreview);
View* view = View::getView(this);
gfx::Rect vp = view->viewportBounds();

View File

@ -173,9 +173,14 @@ bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg)
}
// Move selection if it was visible
if (m_maskVisible)
api.setMaskPosition(document->mask()->bounds().x + m_celOffset.x,
document->mask()->bounds().y + m_celOffset.y);
if (m_maskVisible) {
// TODO Moving the mask when we move a ref layer (e.g. by
// m_celOffset=(0.5,0.5)) will not move the final
// position of the mask (so the ref layer is moved and
// the mask isn't).
api.setMaskPosition(document->mask()->bounds().x + int(m_celOffset.x),
document->mask()->bounds().y + int(m_celOffset.y));
}
transaction.commit();
}
@ -298,8 +303,8 @@ bool MovingCelState::onUpdateStatusBar(Editor* editor)
gfx::Point MovingCelState::intCelOffset() const
{
return gfx::Point(std::round(m_celOffset.x),
std::round(m_celOffset.y));
return gfx::Point(int(std::round(m_celOffset.x)),
int(std::round(m_celOffset.y)));
}
} // namespace app

View File

@ -553,8 +553,8 @@ bool StandbyState::onUpdateStatusBar(Editor* editor)
if (editor->docPref().show.grid()) {
auto gb = editor->docPref().grid.bounds();
int col = (std::floor(spritePos.x) - (gb.x % gb.w)) / gb.w;
int row = (std::floor(spritePos.y) - (gb.y % gb.h)) / gb.h;
int col = int((std::floor(spritePos.x) - (gb.x % gb.w)) / gb.w);
int row = int((std::floor(spritePos.y) - (gb.y % gb.h)) / gb.h);
sprintf(
buf+std::strlen(buf), " :grid: %d %d", col, row);
}
@ -936,10 +936,10 @@ bool StandbyState::Decorator::getSymmetryHandles(Editor* editor, Handles& handle
handles.push_back(
Handle(TOP,
gfx::Rect(pt1.x, pt1.y, part->width(), part->height())));
gfx::Rect(int(pt1.x), int(pt1.y), part->width(), part->height())));
handles.push_back(
Handle(BOTTOM,
gfx::Rect(pt2.x, pt2.y, part->width(), part->height())));
gfx::Rect(int(pt2.x), int(pt2.y), part->width(), part->height())));
}
if (int(mode) & int(app::gen::SymmetryMode::VERTICAL)) {
@ -957,10 +957,10 @@ bool StandbyState::Decorator::getSymmetryHandles(Editor* editor, Handles& handle
handles.push_back(
Handle(LEFT,
gfx::Rect(pt1.x, pt1.y, part->width(), part->height())));
gfx::Rect(int(pt1.x), int(pt1.y), part->width(), part->height())));
handles.push_back(
Handle(RIGHT,
gfx::Rect(pt2.x, pt2.y, part->width(), part->height())));
gfx::Rect(int(pt2.x), int(pt2.y), part->width(), part->height())));
}
return true;

View File

@ -392,7 +392,7 @@ bool PaletteView::onProcessMessage(Message* msg)
if (static_cast<MouseMessage*>(msg)->preciseWheel())
scroll += delta;
else
scroll += delta * 3 * m_boxsize;
scroll += delta * 3 * int(m_boxsize);
view->setViewScroll(scroll);
}
@ -486,7 +486,7 @@ void PaletteView::onPaint(ui::PaintEvent& ev)
if (fgIndex == i) {
gfx::Color neg = color_utils::blackandwhite_neg(gfxColor);
for (int i=0; i<int(m_boxsize/2); ++i)
g->drawHLine(neg, box.x, box.y+i, m_boxsize/2-i);
g->drawHLine(neg, box.x, box.y+i, int(m_boxsize/2)-i);
}
if (bgIndex == i) {

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -66,9 +66,9 @@ class PalettesListItem : public ResourceListItem {
void onClick(Event& ev) override {
IconButton::onClick(ev);
int j, i = m_comment.find("http");
std::string::size_type j, i = m_comment.find("http");
if (i != std::string::npos) {
for (j=i+4; j<int(m_comment.size()) && is_url_char(m_comment[j]); ++j)
for (j=i+4; j != m_comment.size() && is_url_char(m_comment[j]); ++j)
;
base::launcher::open_url(m_comment.substr(i, j-i));
}

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (c) 2001-2016 David Capello
// Copyright (c) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -36,7 +36,7 @@ void resize_image_nearest(const Image* src, Image* dst)
py = std::floor(y * y_ratio);
for (int x=0; x<dst->width(); ++x, ++dstIt) {
px = std::floor(x * x_ratio);
*dstIt = get_pixel_fast<ImageTraits>(src, px, py);
*dstIt = get_pixel_fast<ImageTraits>(src, int(px), int(py));
}
}
}

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (c) 2016 David Capello
// Copyright (c) 2016-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -43,8 +43,8 @@ Palette* load_hex_file(const char *filename)
continue;
// Find 6 consecutive hex digits
for (int i=0; i<line.size(); ++i) {
int j = i;
for (std::string::size_type i=0; i != line.size(); ++i) {
std::string::size_type j = i;
for (; j<i+6; ++j) {
if (!base::is_hex_digit(line[j]))
break;

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (c) 2016 David Capello
// Copyright (c) 2016-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -34,7 +34,7 @@ bool are_layers_adjacent(const LayerList& layers)
prev = layer;
++count;
}
if (count == layers.size())
if (count == layer_t(layers.size()))
return true;
count = 0;
@ -45,7 +45,7 @@ bool are_layers_adjacent(const LayerList& layers)
prev = layer;
++count;
}
if (count == layers.size())
if (count == layer_t(layers.size()))
return true;
return false;

View File

@ -280,7 +280,7 @@ void Palette::applyRemap(const Remap& remap)
void Palette::setEntryName(const int i, const std::string& name)
{
if (i >= m_names.size())
if (i >= int(m_names.size()))
m_names.resize(i+1);
m_names[i] = name;
}

View File

@ -482,8 +482,8 @@ void Sprite::pickCels(const double x,
continue;
const gfx::Point ipos(
(pos.x-celBounds.x)*image->width()/celBounds.w,
(pos.y-celBounds.y)*image->height()/celBounds.h);
int((pos.x-celBounds.x)*image->width()/celBounds.w),
int((pos.y-celBounds.y)*image->height()/celBounds.h));
if (!image->bounds().contains(ipos))
continue;

View File

@ -1,5 +1,5 @@
// Aseprite Render Library
// Copyright (c) 2001-2015 David Capello
// Copyright (c) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -126,10 +126,10 @@ namespace render {
b /= count;
a /= count;
return doc::rgba((255 * r / (Histogram::RElements-1)),
(255 * g / (Histogram::GElements-1)),
(255 * b / (Histogram::BElements-1)),
(255 * a / (Histogram::AElements-1)));
return doc::rgba(int(255 * r / (Histogram::RElements-1)),
int(255 * g / (Histogram::GElements-1)),
int(255 * b / (Histogram::BElements-1)),
int(255 * a / (Histogram::AElements-1)));
}
// The boxes will be sort in the priority_queue by volume.

View File

@ -164,7 +164,9 @@ void composite_image_without_scale(
const LockImageBits<SrcTraits> srcBits(src, srcBounds);
LockImageBits<DstTraits> dstBits(dst, dstBounds);
typename LockImageBits<SrcTraits>::const_iterator src_it = srcBits.begin();
#ifdef _DEBUG
typename LockImageBits<SrcTraits>::const_iterator src_end = srcBits.end();
#endif
typename LockImageBits<DstTraits>::iterator dst_it, dst_end;
// For each line to draw of the source image...
@ -208,8 +210,8 @@ void composite_image_scale_up(
BlenderHelper<DstTraits, SrcTraits> blender(src, pal, blendMode);
int px_x, px_y;
int px_w = sx;
int px_h = sy;
int px_w = int(sx);
int px_h = int(sy);
int first_px_w = px_w - (area.src.x % px_w);
int first_px_h = px_h - (area.src.y % px_h);
@ -346,8 +348,8 @@ void composite_image_scale_down(
return;
BlenderHelper<DstTraits, SrcTraits> blender(src, pal, blendMode);
int step_w = 1.0 / sx;
int step_h = 1.0 / sy;
int step_w = int(1.0 / sx);
int step_h = int(1.0 / sy);
if (step_w < 1 || step_h < 1)
return;
@ -415,8 +417,8 @@ void composite_image_general(
gfx::Rect dstBounds(
area.dstBounds().x, area.dstBounds().y,
std::ceil(area.dstBounds().w),
std::ceil(area.dstBounds().h));
int(std::ceil(area.dstBounds().w)),
int(std::ceil(area.dstBounds().h)));
gfx::RectF srcBounds = area.srcBounds();
int dstY = dstBounds.y;
@ -424,7 +426,7 @@ void composite_image_general(
double srcXDelta = 1.0 / sx;
int srcWidth = src->width();
for (int y=0; y<dstBounds.h; ++y, ++dstY) {
int srcY = (srcBounds.y+double(y)) / sy;
int srcY = int((srcBounds.y+double(y)) / sy);
double srcX = srcXStart;
int oldSrcX;
@ -702,9 +704,11 @@ void Render::renderSprite(
else {
renderBackground(dstImage, area);
if (bgLayer && bgLayer->isVisible() && rgba_geta(bg_color) > 0) {
blend_rect(dstImage, area.dst.x, area.dst.y,
area.dst.x+area.size.w-1,
area.dst.y+area.size.h-1,
blend_rect(dstImage,
int(area.dst.x),
int(area.dst.y),
int(area.dst.x+area.size.w-1),
int(area.dst.y+area.size.h-1),
bg_color, 255);
}
}

View File

@ -1,5 +1,5 @@
// Aseprite Scripting Library
// Copyright (c) 2015-2016 David Capello
// Copyright (c) 2015-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -512,7 +512,7 @@ void Engine::evalFile(const std::string& file)
if (fseek(f, 0, SEEK_END) < 0)
return;
int sz = ftell(f);
long sz = ftell(f);
if (sz < 0)
return;
@ -521,7 +521,7 @@ void Engine::evalFile(const std::string& file)
char* buf = (char*)duk_push_fixed_buffer(handle, sz);
ASSERT(buf != nullptr);
if (fread(buf, 1, sz, f) != sz)
if (long(fread(buf, 1, sz, f)) != sz)
return;
fclose(f);