From 84ffc565f21f4787cb940602d6e1c4386d205cbe Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Dec 16 2020 09:26:13 +0000 Subject: clang format --- diff --git a/toonz/sources/common/trop/quickput.cpp b/toonz/sources/common/trop/quickput.cpp index 253c334..b36f39b 100644 --- a/toonz/sources/common/trop/quickput.cpp +++ b/toonz/sources/common/trop/quickput.cpp @@ -773,7 +773,7 @@ void doQuickPutNoFilter(const TRaster32P &dn, const TRaster64P &up, assert((0 <= xI) && (xI <= up->getLx() - 1) && (0 <= yI) && (yI <= up->getLy() - 1)); - TPixel64 *upPix = upBasePix + (yI * upWrap + xI); + TPixel64 *upPix = upBasePix + (yI * upWrap + xI); if (firstColumn) upPix->m = 65535; if (upPix->m == 0) continue; @@ -2050,7 +2050,7 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRaster32P &up, } else if (deltaXL > 0) { if (lxPred < xL0) continue; - kMaxX = (lxPred - xL0) / deltaXL; // floor + kMaxX = (lxPred - xL0) / deltaXL; // floor if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil } else // (deltaXL < 0) { @@ -2064,7 +2064,7 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRaster32P &up, } else if (deltaYL > 0) { if (lyPred < yL0) continue; - kMaxY = (lyPred - yL0) / deltaYL; // floor + kMaxY = (lyPred - yL0) / deltaYL; // floor if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil } else // (deltaYL < 0) { @@ -2167,7 +2167,7 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRaster64P &up, } else if (deltaXL > 0) { if (lxPred < xL0) continue; - kMaxX = (lxPred - xL0) / deltaXL; // floor + kMaxX = (lxPred - xL0) / deltaXL; // floor if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil } else // (deltaXL < 0) { @@ -2181,7 +2181,7 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRaster64P &up, } else if (deltaYL > 0) { if (lyPred < yL0) continue; - kMaxY = (lyPred - yL0) / deltaYL; // floor + kMaxY = (lyPred - yL0) / deltaYL; // floor if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil } else // (deltaYL < 0) { @@ -2993,11 +2993,11 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up, // vector inks(palette->getStyleCount()); if (globalColorScale != TPixel::Black) - for (int i = 0; i < palette->getStyleCount(); i++) + for (int i = 0; i < palette->getStyleCount(); i++) colors[i] = applyColorScaleCMapped( palette->getStyle(i)->getAverageColor(), globalColorScale); else - for (int i = 0; i < palette->getStyleCount(); i++) + for (int i = 0; i < palette->getStyleCount(); i++) colors[i] = ::premultiply(palette->getStyle(i)->getAverageColor()); dn->lock(); @@ -3244,11 +3244,11 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up, } } } else if (s.m_globalColorScale == TPixel::Black) - for (int i = 0; i < palette->getStyleCount(); i++) + for (int i = 0; i < palette->getStyleCount(); i++) paints[i] = inks[i] = ::premultiply(palette->getStyle(i)->getAverageColor()); else - for (int i = 0; i < palette->getStyleCount(); i++) + for (int i = 0; i < palette->getStyleCount(); i++) paints[i] = inks[i] = applyColorScaleCMapped( palette->getStyle(i)->getAverageColor(), s.m_globalColorScale); @@ -3268,7 +3268,7 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up, } else if (deltaXL > 0) { if (lxPred < xL0) continue; - kMaxX = (lxPred - xL0) / deltaXL; // floor + kMaxX = (lxPred - xL0) / deltaXL; // floor if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil } else { if (xL0 < 0) continue; @@ -3282,7 +3282,7 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up, } else if (deltaYL > 0) { if (lyPred < yL0) continue; - kMaxY = (lyPred - yL0) / deltaYL; + kMaxY = (lyPred - yL0) / deltaYL; if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; } else { if (yL0 < 0) continue; @@ -3558,11 +3558,11 @@ void doQuickPutCmapped(const TRaster32P &dn, const TRasterCM32P &up, std::vector paints(count, TPixel32::Red); std::vector inks(count, TPixel32::Red); if (globalColorScale != TPixel::Black) - for (int i = 0; i < palette->getStyleCount(); i++) + for (int i = 0; i < palette->getStyleCount(); i++) paints[i] = inks[i] = applyColorScaleCMapped( palette->getStyle(i)->getAverageColor(), globalColorScale); else - for (int i = 0; i < palette->getStyleCount(); i++) + for (int i = 0; i < palette->getStyleCount(); i++) paints[i] = inks[i] = ::premultiply(palette->getStyle(i)->getAverageColor()); @@ -3660,7 +3660,7 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRasterCM32P &up, std::vector paints(plt->getStyleCount()); std::vector inks(plt->getStyleCount()); - for (int i = 0; i < plt->getStyleCount(); i++) + for (int i = 0; i < plt->getStyleCount(); i++) paints[i] = inks[i] = ::premultiply(plt->getStyle(i)->getAverageColor()); assert(std::max(up->getLx(), up->getLy()) < @@ -3714,7 +3714,7 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRasterCM32P &up, } else if (deltaXL > 0) { if (lxPred < xL0) continue; - kMaxX = (lxPred - xL0) / deltaXL; // floor + kMaxX = (lxPred - xL0) / deltaXL; // floor if (xL0 < 0) kMinX = ((-xL0) + deltaXL - 1) / deltaXL; // ceil } else // (deltaXL < 0) { @@ -3728,7 +3728,7 @@ void doQuickResampleColorFilter(const TRaster32P &dn, const TRasterCM32P &up, } else if (deltaYL > 0) { if (lyPred < yL0) continue; - kMaxY = (lyPred - yL0) / deltaYL; // floor + kMaxY = (lyPred - yL0) / deltaYL; // floor if (yL0 < 0) kMinY = ((-yL0) + deltaYL - 1) / deltaYL; // ceil } else // (deltaYL < 0) { @@ -4180,7 +4180,7 @@ void doQuickResampleFilter_optimized(const TRaster32P &dn, const TRaster32P &up, #endif // namespace -}; +}; // namespace #ifndef TNZCORE_LIGHT //============================================================================= diff --git a/toonz/sources/include/trop.h b/toonz/sources/include/trop.h index 9ba3ed3..292ba21 100644 --- a/toonz/sources/include/trop.h +++ b/toonz/sources/include/trop.h @@ -387,7 +387,7 @@ DVAPI void swapRBChannels(const TRaster32P &r); //! Convert TRasterP in an old toonz raster! /*! Use the same buffer, not creates a new raster (the palette is new instead!) - */ + */ DVAPI _RASTER *convertRaster50to46(const TRasterP &inRas, const TPaletteP &inPalette); @@ -408,4 +408,4 @@ DVAPI void lockRaster(_RASTER *raster); //! inactivity periods. DVAPI void unlockRaster(_RASTER *raster); -} // TRop namespace +} // namespace TRop diff --git a/toonz/sources/tnztools/rastertapetool.cpp b/toonz/sources/tnztools/rastertapetool.cpp index 6a6fb4b..4371a32 100644 --- a/toonz/sources/tnztools/rastertapetool.cpp +++ b/toonz/sources/tnztools/rastertapetool.cpp @@ -219,7 +219,7 @@ public: TTool::getApplication() ->getCurrentLevelStyleIndex(); // TApp::instance()->getCurrentPalette()->getStyleIndex(); if (isInt(inkString)) inkIndex = std::stoi(inkString); - params.m_inkIndex = inkIndex; + params.m_inkIndex = inkIndex; TPoint delta; TRasterCM32P ras, raux = ti->getRaster(); diff --git a/toonz/sources/toonz/frameheadgadget.cpp b/toonz/sources/toonz/frameheadgadget.cpp index b0400da..662ed2e 100644 --- a/toonz/sources/toonz/frameheadgadget.cpp +++ b/toonz/sources/toonz/frameheadgadget.cpp @@ -394,7 +394,7 @@ void FilmstripFrameHeadGadget::drawOnionSkinSelection(QPainter &p, int minMos = 0; int maxMos = 0; for (i = 0; i < mosCount; i++) { - int mos = osMask.getMos(i); + int mos = osMask.getMos(i); if (minMos > mos) minMos = mos; if (maxMos < mos) maxMos = mos; } @@ -600,7 +600,10 @@ void FilmstripFrameHeadGadget::drawShiftTraceMarker(QPainter &p) { //----------------------------------------------------------------------------- bool FilmstripFrameHeadGadget::eventFilter(QObject *obj, QEvent *e) { - if (e->type() != QEvent::MouseButtonPress && e->type() != QEvent::MouseButtonDblClick && e->type() != QEvent::MouseMove) return false; + if (e->type() != QEvent::MouseButtonPress && + e->type() != QEvent::MouseButtonDblClick && + e->type() != QEvent::MouseMove) + return false; // shift & trace case if (CommandManager::instance()->getAction(MI_ShiftTrace)->isChecked()) return shiftTraceEventFilter(obj, e); @@ -654,11 +657,11 @@ bool FilmstripFrameHeadGadget::eventFilter(QObject *obj, QEvent *e) { //----- 以下、クリック位置に応じてアクションを変えていく //クリックされたフレームを取得 - QMouseEvent *mouseEvent = dynamic_cast(e); - int frame = y2index(mouseEvent->pos().y()); + QMouseEvent *mouseEvent = dynamic_cast(e); + int frame = y2index(mouseEvent->pos().y()); if (!m_filmstrip->m_isVertical) frame = x2index(mouseEvent->pos().x()); - m_buttonPressCellIndex = frame; - int currentFrame = getCurrentFrame(); + m_buttonPressCellIndex = frame; + int currentFrame = getCurrentFrame(); //各フレーム左上からの位置 QPoint clickedPos = mouseEvent->pos() + QPoint(0, -index2y(frame)); @@ -702,7 +705,7 @@ bool FilmstripFrameHeadGadget::eventFilter(QObject *obj, QEvent *e) { else if (e->type() == QEvent::MouseButtonDblClick) { QMouseEvent *mouseEvent = dynamic_cast(e); if (mouseEvent->buttons() & Qt::LeftButton) { - int frame = y2index(mouseEvent->pos().y()); + int frame = y2index(mouseEvent->pos().y()); if (!m_filmstrip->m_isVertical) frame = x2index(mouseEvent->pos().x()); //各フレーム左上からの位置 QPoint clickedPos = mouseEvent->pos() + QPoint(0, -index2y(frame)); @@ -729,8 +732,8 @@ bool FilmstripFrameHeadGadget::eventFilter(QObject *obj, QEvent *e) { } //---- else if (e->type() == QEvent::MouseMove) { - QMouseEvent *mouseEvent = dynamic_cast(e); - int frame = y2index(mouseEvent->pos().y()); + QMouseEvent *mouseEvent = dynamic_cast(e); + int frame = y2index(mouseEvent->pos().y()); if (!m_filmstrip->m_isVertical) frame = x2index(mouseEvent->pos().x()); //各フレーム左上からの位置 QPoint clickedPos = mouseEvent->pos() + QPoint(0, -index2y(frame)); @@ -863,13 +866,13 @@ bool FilmstripFrameHeadGadget::shiftTraceEventFilter(QObject *obj, QEvent *e) { viewer->update(); } - QMouseEvent *mouseEvent = dynamic_cast(e); - int frame = y2index(mouseEvent->pos().y()); + QMouseEvent *mouseEvent = dynamic_cast(e); + int frame = y2index(mouseEvent->pos().y()); if (!m_filmstrip->m_isVertical) frame = x2index(mouseEvent->pos().x()); // position from top-left of the frame QPoint mousePos = mouseEvent->pos() + QPoint(0, -index2y(frame)); if (!m_filmstrip->m_isVertical) - mousePos = mouseEvent->pos() + QPoint(-index2x(frame), 0); + mousePos = mouseEvent->pos() + QPoint(-index2x(frame), 0); int currentFrame = getCurrentFrame(); if (m_filmstrip->m_isVertical) { diff --git a/toonz/sources/toonzlib/plasticdeformerfx.cpp b/toonz/sources/toonzlib/plasticdeformerfx.cpp index 069ec84..6fda56e 100644 --- a/toonz/sources/toonzlib/plasticdeformerfx.cpp +++ b/toonz/sources/toonzlib/plasticdeformerfx.cpp @@ -178,8 +178,8 @@ void PlasticDeformerFx::buildRenderSettings(double frame, // its handledAffine() method. m_was64bit = false; if (info.m_bpp == 64) { - m_was64bit = true; - info.m_bpp = 32; // We need to fix the input to 32-bpp + m_was64bit = true; + info.m_bpp = 32; // We need to fix the input to 32-bpp } info.m_affine = m_port->handledAffine(info, frame); } @@ -404,7 +404,7 @@ void PlasticDeformerFx::doCompute(TTile &tile, double frame, QImage img = fb.toImage().scaled(QSize(d.lx, d.ly), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - int wrap = tile.getRaster()->getLx() * sizeof(TPixel32); + int wrap = tile.getRaster()->getLx() * sizeof(TPixel32); if (!m_was64bit) { uchar *srcPix = img.bits(); uchar *dstPix = tile.getRaster()->getRawData() + wrap * (d.ly - 1); @@ -413,25 +413,25 @@ void PlasticDeformerFx::doCompute(TTile &tile, double frame, dstPix -= wrap; srcPix += wrap; } + } else if (m_was64bit) { + TRaster64P newRaster(tile.getRaster()->getSize()); + TRaster32P tempRaster(tile.getRaster()->getSize()); + uchar *srcPix = img.bits(); + uchar *dstPix = tempRaster.getPointer()->getRawData() + wrap * (d.ly - 1); + for (int y = 0; y < d.ly; y++) { + memcpy(dstPix, srcPix, wrap); + dstPix -= wrap; + srcPix += wrap; + } + TRop::convert(newRaster, tempRaster); + int size = tile.getRaster()->getLx() * tile.getRaster()->getLy() * + sizeof(TPixel64); + srcPix = newRaster.getPointer()->getRawData(); + dstPix = tile.getRaster()->getRawData(); + memcpy(dstPix, srcPix, size); + texInfo.m_bpp = 64; } - else if (m_was64bit) { - TRaster64P newRaster(tile.getRaster()->getSize()); - TRaster32P tempRaster(tile.getRaster()->getSize()); - uchar *srcPix = img.bits(); - uchar *dstPix = tempRaster.getPointer()->getRawData() + wrap * (d.ly - 1); - for (int y = 0; y < d.ly; y++) { - memcpy(dstPix, srcPix, wrap); - dstPix -= wrap; - srcPix += wrap; - } - TRop::convert(newRaster, tempRaster); - int size = tile.getRaster()->getLx() * tile.getRaster()->getLy() * sizeof(TPixel64); - srcPix = newRaster.getPointer()->getRawData(); - dstPix = tile.getRaster()->getRawData(); - memcpy(dstPix, srcPix, size); - texInfo.m_bpp = 64; - } - + fb.release(); // context->getRaster(tile.getRaster()); diff --git a/toonz/sources/toonzlib/stagevisitor.cpp b/toonz/sources/toonzlib/stagevisitor.cpp index 0864ad5..4c0c2e4 100644 --- a/toonz/sources/toonzlib/stagevisitor.cpp +++ b/toonz/sources/toonzlib/stagevisitor.cpp @@ -247,7 +247,7 @@ void Picker::onImage(const Stage::Player &player) { double dist2 = 0; TRegion *r = vi->getRegion(point); int styleId = 0; - if (r) styleId = r->getStyle(); + if (r) styleId = r->getStyle(); if (styleId != 0) picked = true; else if (vi->getNearestStroke(point, w, strokeIndex, dist2)) { @@ -277,7 +277,7 @@ void Picker::onImage(const Stage::Player &player) { TPoint p(tround(pp.x), tround(pp.y)); if (!ras->getBounds().contains(p)) return; - TPixel32 *pix = ras->pixels(p.y); + TPixel32 *pix = ras->pixels(p.y); if (pix[p.x].m != 0) picked = true; TAffine aff2 = (aff * player.m_dpiAff).inv(); @@ -292,7 +292,7 @@ void Picker::onImage(const Stage::Player &player) { ras->getBounds(); for (int y = rect.y0; !picked && y <= rect.y1; y++) { pix = ras->pixels(y); - for (int x = rect.x0; !picked && x <= rect.x1; x++) + for (int x = rect.x0; !picked && x <= rect.x1; x++) if (pix[x].m != 0) picked = true; } @@ -890,7 +890,7 @@ void RasterPainter::onVectorImage(TVectorImage *vi, TVectorRenderData rd(m_viewAff * player.m_placement, TRect(), vPalette, cf, true // alpha enabled - ); + ); rd.m_drawRegions = !inksOnly; rd.m_inkCheckEnabled = tc & ToonzCheck::eInk; @@ -996,7 +996,7 @@ void RasterPainter::onVectorImage(TVectorImage *vi, //----------------------------------------------------- /*! Create a \b Node and put it in \b m_nodes. -*/ + */ void RasterPainter::onRasterImage(TRasterImage *ri, const Stage::Player &player) { TRasterP r = ri->getRaster(); @@ -1036,7 +1036,7 @@ void RasterPainter::onRasterImage(TRasterImage *ri, : Node::eOnionSkinNone); } } else if (player.m_opacity < 255) - alpha = player.m_opacity; + alpha = player.m_opacity; TXshSimpleLevel *sl = player.m_sl; bool doPremultiply = false; bool whiteTransp = false; @@ -1062,7 +1062,7 @@ void RasterPainter::onRasterImage(TRasterImage *ri, //----------------------------------------------------------------------------- /*! Create a \b Node and put it in \b m_nodes. -*/ + */ void RasterPainter::onToonzImage(TToonzImage *ti, const Stage::Player &player) { TRasterCM32P r = ti->getRaster(); if (!ti->getPalette()) return; @@ -1375,9 +1375,9 @@ void onMeshImage(TMeshImage *mi, const Stage::Player &player, const TAffine &viewAff) { assert(mi); - static const double soMinColor[4] = {0.0, 0.0, 0.0, + static const double soMinColor[4] = {0.0, 0.0, 0.0, 0.6}; // Translucent black - static const double soMaxColor[4] = {1.0, 1.0, 1.0, + static const double soMaxColor[4] = {1.0, 1.0, 1.0, 0.6}; // Translucent white static const double rigMinColor[4] = {0.0, 1.0, 0.0, 0.6}; // Translucent green diff --git a/toonz/sources/toonzlib/stylemanager.cpp b/toonz/sources/toonzlib/stylemanager.cpp index d4feaf2..7da5737 100644 --- a/toonz/sources/toonzlib/stylemanager.cpp +++ b/toonz/sources/toonzlib/stylemanager.cpp @@ -113,9 +113,9 @@ void CustomStyleManager::StyleLoaderTask::run() { vimg->setPalette(vPalette); #ifdef LINUX - TOfflineGL *glContext = 0; - glContext = TOfflineGL::getStock(chipSize); - glContext->clear(TPixel32::White); + TOfflineGL *glContext = 0; + glContext = TOfflineGL::getStock(chipSize); + glContext->clear(TPixel32::White); #else QOpenGLContext *glContext = new QOpenGLContext(); if (QOpenGLContext::currentContext()) @@ -155,10 +155,10 @@ void CustomStyleManager::StyleLoaderTask::run() { TVectorRenderData rd(aff, chipSize, vPalette, 0, true); #ifdef LINUX - glContext->draw(img, rd); - // No need to clone! The received raster already is a copy of the - // context's buffer - ras = glContext->getRaster(); //->clone(); + glContext->draw(img, rd); + // No need to clone! The received raster already is a copy of the + // context's buffer + ras = glContext->getRaster(); //->clone(); #else tglDraw(rd, vimg.getPointer()); @@ -190,8 +190,8 @@ void CustomStyleManager::StyleLoaderTask::run() { assert(!"unsupported type for custom styles!"); #ifdef LINUX - image = new QImage(chipSize.lx, chipSize.ly, QImage::Format_RGB32); - convertRaster32ToImage(ras, image); + image = new QImage(chipSize.lx, chipSize.ly, QImage::Format_RGB32); + convertRaster32ToImage(ras, image); #endif m_data.m_patternName = m_fp.getName();