From cc7bde6cd1d9ab74c31ccfa1bf41a000150a1fb2 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 19 Apr 2017 19:25:57 -0300 Subject: [PATCH] Fix some compiler warnings (implicit casts & unused vars) --- src/app/cli/cli_processor.cpp | 2 +- src/app/file/gif_format.cpp | 8 +++++--- src/app/file/ico_format.cpp | 3 ++- src/app/tools/ink_processing.h | 10 +++++----- src/app/ui/browser_view.cpp | 8 ++++---- src/app/ui/color_bar.cpp | 2 +- src/app/ui/color_button.cpp | 2 +- src/app/ui/configure_timeline_popup.cpp | 2 +- src/app/ui/editor/editor.cpp | 6 +++--- src/app/ui/editor/moving_cel_state.cpp | 15 ++++++++++----- src/app/ui/editor/standby_state.cpp | 12 ++++++------ src/app/ui/palette_view.cpp | 4 ++-- src/app/ui/palettes_listbox.cpp | 6 +++--- src/doc/algorithm/resize_image.cpp | 4 ++-- src/doc/file/hex_file.cpp | 6 +++--- src/doc/layer_list.cpp | 6 +++--- src/doc/palette.cpp | 2 +- src/doc/sprite.cpp | 4 ++-- src/render/median_cut.h | 10 +++++----- src/render/render.cpp | 24 ++++++++++++++---------- src/script/engine.cpp | 6 +++--- 21 files changed, 77 insertions(+), 65 deletions(-) diff --git a/src/app/cli/cli_processor.cpp b/src/app/cli/cli_processor.cpp index 6cfaf1d5c..16dbf4ab5 100644 --- a/src/app/cli/cli_processor.cpp +++ b/src/app/cli/cli_processor.cpp @@ -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(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(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 diff --git a/src/app/file/ico_format.cpp b/src/app/file/ico_format.cpp index f1fcbdf93..03fbe311c 100644 --- a/src/app/file/ico_format.cpp +++ b/src/app/file/ico_format.cpp @@ -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) { diff --git a/src/app/tools/ink_processing.h b/src/app/tools/ink_processing.h index a55d1a7cb..6d2534221 100644 --- a/src/app/tools/ink_processing.h +++ b/src/app/tools/ink_processing.h @@ -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); diff --git a/src/app/ui/browser_view.cpp b/src/app/ui/browser_view.cpp index fc7435b17..23c6a608d 100644 --- a/src/app/ui/browser_view.cpp +++ b/src/app/ui/browser_view.cpp @@ -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; diff --git a/src/app/ui/color_bar.cpp b/src/app/ui/color_bar.cpp index 6a5868262..64da86028 100644 --- a/src/app/ui/color_bar.cpp +++ b/src/app/ui/color_bar.cpp @@ -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); diff --git a/src/app/ui/color_button.cpp b/src/app/ui/color_button.cpp index edff8135e..5039667b5 100644 --- a/src/app/ui/color_button.cpp +++ b/src/app/ui/color_button.cpp @@ -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(); diff --git a/src/app/ui/configure_timeline_popup.cpp b/src/app/ui/configure_timeline_popup.cpp index b58580f85..84543e340 100644 --- a/src/app/ui/configure_timeline_popup.cpp +++ b/src/app/ui/configure_timeline_popup.cpp @@ -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); diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 78e7b6101..9cebddbab 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -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(x), + spriteRect.x + int(m_proj.applyX(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(y), + spriteRect.y + int(m_proj.applyY(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(); diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp index d0e177fa4..457aedd74 100644 --- a/src/app/ui/editor/moving_cel_state.cpp +++ b/src/app/ui/editor/moving_cel_state.cpp @@ -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 diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp index 2b94b57a6..97a2dcf77 100644 --- a/src/app/ui/editor/standby_state.cpp +++ b/src/app/ui/editor/standby_state.cpp @@ -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; diff --git a/src/app/ui/palette_view.cpp b/src/app/ui/palette_view.cpp index 31f124b79..4bf298a66 100644 --- a/src/app/ui/palette_view.cpp +++ b/src/app/ui/palette_view.cpp @@ -392,7 +392,7 @@ bool PaletteView::onProcessMessage(Message* msg) if (static_cast(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; idrawHLine(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) { diff --git a/src/app/ui/palettes_listbox.cpp b/src/app/ui/palettes_listbox.cpp index 6189e644e..4fb260690 100644 --- a/src/app/ui/palettes_listbox.cpp +++ b/src/app/ui/palettes_listbox.cpp @@ -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; jwidth(); ++x, ++dstIt) { px = std::floor(x * x_ratio); - *dstIt = get_pixel_fast(src, px, py); + *dstIt = get_pixel_fast(src, int(px), int(py)); } } } diff --git a/src/doc/file/hex_file.cpp b/src/doc/file/hex_file.cpp index f202ad265..232322f27 100644 --- a/src/doc/file/hex_file.cpp +++ b/src/doc/file/hex_file.cpp @@ -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= m_names.size()) + if (i >= int(m_names.size())) m_names.resize(i+1); m_names[i] = name; } diff --git a/src/doc/sprite.cpp b/src/doc/sprite.cpp index ddb39b9d4..e86201740 100644 --- a/src/doc/sprite.cpp +++ b/src/doc/sprite.cpp @@ -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; diff --git a/src/render/median_cut.h b/src/render/median_cut.h index 7be665732..4a1b43fe6 100644 --- a/src/render/median_cut.h +++ b/src/render/median_cut.h @@ -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. diff --git a/src/render/render.cpp b/src/render/render.cpp index 5d1a8d559..577058579 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -164,7 +164,9 @@ void composite_image_without_scale( const LockImageBits srcBits(src, srcBounds); LockImageBits dstBits(dst, dstBounds); typename LockImageBits::const_iterator src_it = srcBits.begin(); +#ifdef _DEBUG typename LockImageBits::const_iterator src_end = srcBits.end(); +#endif typename LockImageBits::iterator dst_it, dst_end; // For each line to draw of the source image... @@ -208,8 +210,8 @@ void composite_image_scale_up( BlenderHelper 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 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; yisVisible() && 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); } } diff --git a/src/script/engine.cpp b/src/script/engine.cpp index 35e074127..3168e2890 100644 --- a/src/script/engine.cpp +++ b/src/script/engine.cpp @@ -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);