From: subhransu mohanty Date: Thu, 11 Jul 2019 04:46:44 +0000 (+0900) Subject: fix clang code model warning. X-Git-Tag: submit/tizen/20190719.015332~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=70a65ce8760759206d6a964c044d4e1dbb26f427;p=platform%2Fcore%2Fuifw%2Flottie-player.git fix clang code model warning. --- diff --git a/.appveyor.yml b/.appveyor.yml index e53600d..0b51e29 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,7 +14,7 @@ install: - pip install meson==0.50.0 ninja - call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %ARCH% build_script: - - meson -Dwarning_level=0 -Dwerror=false --backend=ninja --prefix=%cd% build + - meson -Dwerror=false --backend=ninja --prefix=%cd% build - where link - ninja -C build test_script: diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index 7964ab5..367f25f 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -131,7 +131,7 @@ bool LOTCompItem::update(int frameNo) float sx = float(viewPort.width()) / viewBox.width(); float sy = float(viewPort.height()) / viewBox.height(); - float scale = fmin(sx, sy); + float scale = std::min(sx, sy); float tx = (viewPort.width() - viewBox.width() * scale) * 0.5f; float ty = (viewPort.height() - viewBox.height() * scale) * 0.5f; @@ -1340,7 +1340,7 @@ void LOTFillItem::updateRenderNode() { VColor color = mColor; - color.setAlpha(color.a * parentAlpha()); + color.setAlpha(uchar(color.a * parentAlpha())); VBrush brush(color); mDrawable.setBrush(brush); mDrawable.setFillRule(mModel.fillRule()); @@ -1397,7 +1397,7 @@ void LOTStrokeItem::updateRenderNode() { VColor color = mColor; - color.setAlpha(color.a * parentAlpha()); + color.setAlpha(uchar(color.a * parentAlpha())); VBrush brush(color); mDrawable.setBrush(brush); float scale = diff --git a/src/lottie/lottiemodel.h b/src/lottie/lottiemodel.h index 029260a..fa7d2b1 100644 --- a/src/lottie/lottiemodel.h +++ b/src/lottie/lottiemodel.h @@ -250,8 +250,8 @@ public: } bool changed(int prevFrame, int curFrame) const { - int first = mKeyFrames.front().mStartFrame; - int last = mKeyFrames.back().mEndFrame; + auto first = mKeyFrames.front().mStartFrame; + auto last = mKeyFrames.back().mEndFrame; return !((first > prevFrame && first > curFrame) || (last < prevFrame && last < curFrame)); @@ -572,7 +572,7 @@ public: size_t frameAtPos(double pos) const { if (pos < 0) pos = 0; if (pos > 1) pos = 1; - return pos * frameDuration(); + return size_t(pos * frameDuration()); } long frameAtTime(double timeInSec) const { return frameAtPos(timeInSec / duration()); @@ -979,7 +979,7 @@ public: double duration() const {return mRoot->duration();} size_t totalFrame() const {return mRoot->totalFrame();} size_t frameDuration() const {return mRoot->frameDuration();} - size_t frameRate() const {return mRoot->frameRate();} + double frameRate() const {return mRoot->frameRate();} size_t startFrame() const {return mRoot->startFrame();} size_t endFrame() const {return mRoot->endFrame();} size_t frameAtPos(double pos) const {return mRoot->frameAtPos(pos);} diff --git a/src/vector/vbitmap.cpp b/src/vector/vbitmap.cpp index b2f676c..db5506b 100644 --- a/src/vector/vbitmap.cpp +++ b/src/vector/vbitmap.cpp @@ -17,7 +17,7 @@ */ #include "vbitmap.h" -#include +#include #include "vdrawhelper.h" #include "vglobal.h" @@ -35,8 +35,12 @@ struct VBitmap::Impl { bool mRoData; Impl() = delete; + Impl(Impl&&) = delete; + Impl(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + Impl& operator=(Impl&) = delete; - Impl(uint width, uint height, VBitmap::Format format) + explicit Impl(uint width, uint height, VBitmap::Format format) : mOwnData(true), mRoData(false) { reset(width, height, format); @@ -55,24 +59,19 @@ struct VBitmap::Impl { mFormat = format; mStride = stride; mBytes = mStride * mHeight; - mData = reinterpret_cast(::operator new(mBytes)); + mData = new uchar[mBytes]; } - Impl(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format) - : mOwnData(false), mRoData(false) + explicit Impl(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format) + : mData(data), mWidth(w), mHeight(h), mStride(bytesPerLine), + mDepth(depth(format)), mFormat(format), mOwnData(false), mRoData(false) { - mWidth = w; - mHeight = h; - mFormat = format; - mStride = bytesPerLine; mBytes = mStride * mHeight; - mData = data; - mDepth = depth(format); } ~Impl() { - if (mOwnData && mData) ::operator delete(mData); + if (mOwnData && mData) delete[] mData; } uint stride() const { return mStride; } @@ -125,7 +124,7 @@ struct VBitmap::Impl { green = (green * 255) / alpha; blue = (blue * 255) / alpha; } - int luminosity = (0.299f * red + 0.587f * green + 0.114f * blue); + int luminosity = int(0.299f * red + 0.587f * green + 0.114f * blue); *pixel = luminosity << 24; pixel++; } @@ -195,7 +194,7 @@ uchar *VBitmap::data() const bool VBitmap::valid() const { - return mImpl ? true : false; + return (mImpl != nullptr); } VBitmap::Format VBitmap::format() const diff --git a/src/vector/vbrush.cpp b/src/vector/vbrush.cpp index 11ec6eb..7d761fa 100644 --- a/src/vector/vbrush.cpp +++ b/src/vector/vbrush.cpp @@ -21,9 +21,7 @@ V_BEGIN_NAMESPACE VGradient::VGradient(VGradient::Type type) - : mType(type), - mSpread(VGradient::Spread::Pad), - mMode(VGradient::Mode::Absolute) + : mType(type) { if (mType == Type::Linear) linear.x1 = linear.y1 = linear.x2 = linear.y2 = 0.0f; @@ -41,7 +39,7 @@ VBrush::VBrush(const VColor &color) : mType(VBrush::Type::Solid), mColor(color) { } -VBrush::VBrush(int r, int g, int b, int a) +VBrush::VBrush(uchar r, uchar g, uchar b, uchar a) : mType(VBrush::Type::Solid), mColor(r, g, b, a) { diff --git a/src/vector/vbrush.h b/src/vector/vbrush.h index 23a7695..c71a269 100644 --- a/src/vector/vbrush.h +++ b/src/vector/vbrush.h @@ -27,14 +27,14 @@ V_BEGIN_NAMESPACE -typedef std::pair VGradientStop; -typedef std::vector VGradientStops; +using VGradientStop = std::pair; +using VGradientStops = std::vector; class VGradient { public: enum class Mode { Absolute, Relative }; enum class Spread { Pad, Repeat, Reflect }; enum class Type { Linear, Radial }; - VGradient(VGradient::Type type); + explicit VGradient(VGradient::Type type); void setStops(const VGradientStops &stops); void setAlpha(float alpha) {mAlpha = alpha;} float alpha() const {return mAlpha;} @@ -42,16 +42,16 @@ public: public: static constexpr int colorTableSize = 1024; - VGradient::Type mType; - VGradient::Spread mSpread; - VGradient::Mode mMode; + VGradient::Type mType{Type::Linear}; + VGradient::Spread mSpread{Spread::Pad}; + VGradient::Mode mMode{Mode::Absolute}; VGradientStops mStops; float mAlpha{1.0}; struct Linear{ - float x1, y1, x2, y2; + float x1{0}, y1{0}, x2{0}, y2{0}; }; struct Radial{ - float cx, cy, fx, fy, cradius, fradius; + float cx{0}, cy{0}, fx{0}, fy{0}, cradius{0}, fradius{0}; }; union { Linear linear; @@ -64,10 +64,10 @@ class VBrush { public: enum class Type { NoBrush, Solid, LinearGradient, RadialGradient, Texture }; VBrush() = default; - VBrush(const VColor &color); - VBrush(const VGradient *gradient); - VBrush(int r, int g, int b, int a); - VBrush(const VBitmap &texture); + explicit VBrush(const VColor &color); + explicit VBrush(const VGradient *gradient); + explicit VBrush(uchar r, uchar g, uchar b, uchar a); + explicit VBrush(const VBitmap &texture); inline VBrush::Type type() const { return mType; } void setMatrix(const VMatrix &m); public: diff --git a/src/vector/vcowptr.h b/src/vector/vcowptr.h index dcc283a..705945d 100644 --- a/src/vector/vcowptr.h +++ b/src/vector/vcowptr.h @@ -19,7 +19,7 @@ #ifndef VCOWPTR_H #define VCOWPTR_H -#include +#include #include "vglobal.h" template @@ -30,9 +30,8 @@ class vcow_ptr { model() = default; template - explicit model(Args&&... args) : mValue(std::forward(args)...) - { - } + explicit model(Args&&... args) : mValue(std::forward(args)...){} + explicit model(const T& other) : mValue(other){} T mValue; }; @@ -54,7 +53,7 @@ public: } template - vcow_ptr(Args&&... args) : mModel(new model(std::forward(args)...)) + explicit vcow_ptr(Args&&... args) : mModel(new model(std::forward(args)...)) { } @@ -71,7 +70,8 @@ public: auto operator=(const vcow_ptr& x) noexcept -> vcow_ptr& { - return *this = vcow_ptr(x); + *this = vcow_ptr(x); + return *this; } auto operator=(vcow_ptr&& x) noexcept -> vcow_ptr& @@ -85,7 +85,7 @@ public: auto operator-> () const noexcept -> const element_type* { return &read(); } - int refCount() const noexcept + std::size_t refCount() const noexcept { assert(mModel); diff --git a/src/vector/vglobal.h b/src/vector/vglobal.h index 86600a7..75c947c 100644 --- a/src/vector/vglobal.h +++ b/src/vector/vglobal.h @@ -91,7 +91,7 @@ public: if (count == -1) // isStatic return true; atomic.fetch_sub(1); - return --count; + return (--count == 0); } bool isShared() const { @@ -263,14 +263,14 @@ public: VColor() = default; explicit VColor(uchar red, uchar green, uchar blue, uchar alpha = 255) noexcept :a(alpha), r(red), g(green), b(blue){} - inline int red() const noexcept { return r; } - inline int green() const noexcept { return g; } - inline int blue() const noexcept { return b; } - inline int alpha() const noexcept { return a; } - inline void setRed(int red) noexcept { r = red; } - inline void setGreen(int green) noexcept { g = green; } - inline void setBlue(int blue) noexcept { b = blue; } - inline void setAlpha(int alpha) noexcept { a = alpha; } + inline uchar red() const noexcept { return r; } + inline uchar green() const noexcept { return g; } + inline uchar blue() const noexcept { return b; } + inline uchar alpha() const noexcept { return a; } + inline void setRed(uchar red) noexcept { r = red; } + inline void setGreen(uchar green) noexcept { g = green; } + inline void setBlue(uchar blue) noexcept { b = blue; } + inline void setAlpha(uchar alpha) noexcept { a = alpha; } inline bool isOpaque() const { return a == 255; } inline bool operator==(const VColor &o) const { diff --git a/src/vector/vpath.h b/src/vector/vpath.h index ceebd4b..6045854 100644 --- a/src/vector/vpath.h +++ b/src/vector/vpath.h @@ -69,7 +69,7 @@ public: const std::vector & points() const; void clone(const VPath &srcPath); bool unique() const { return d.unique();} - int refCount() const { return d.refCount();} + size_t refCount() const { return d.refCount();} private: struct VPathData { diff --git a/src/vector/vrle.cpp b/src/vector/vrle.cpp index ee4135e..d56710d 100644 --- a/src/vector/vrle.cpp +++ b/src/vector/vrle.cpp @@ -31,9 +31,9 @@ V_BEGIN_NAMESPACE enum class Operation { Add, Xor }; struct VRleHelper { - size_t alloc; - size_t size; - VRle::Span *spans; + size_t alloc{0}; + size_t size{0}; + VRle::Span *spans{nullptr}; }; static void rleIntersectWithRle(VRleHelper *, int, int, VRleHelper *, VRleHelper *); @@ -150,7 +150,7 @@ void VRle::VRleData::invert() } } -void VRle::VRleData::operator*=(int alpha) +void VRle::VRleData::operator*=(uchar alpha) { alpha &= 0xff; for (auto &i : mSpans) { diff --git a/src/vector/vrle.h b/src/vector/vrle.h index b8d97db..6ba92d6 100644 --- a/src/vector/vrle.h +++ b/src/vector/vrle.h @@ -30,13 +30,13 @@ V_BEGIN_NAMESPACE class VRle { public: struct Span { - short x; - short y; - ushort len; - uchar coverage; + short x{0}; + short y{0}; + ushort len{0}; + uchar coverage{0}; }; - typedef void (*VRleSpanCb)(size_t count, const VRle::Span *spans, - void *userData); + using VRleSpanCb = void (*)(size_t count, const VRle::Span *spans, + void *userData); bool empty() const; VRect boundingRect() const; void setBoundingRect(const VRect &bbox); @@ -46,7 +46,7 @@ public: void translate(const VPoint &p); void invert(); - void operator*=(int alpha); + void operator*=(uchar alpha); void intersect(const VRect &r, VRleSpanCb cb, void *userData) const; void intersect(const VRle &rle, VRleSpanCb cb, void *userData) const; @@ -59,7 +59,7 @@ public: static VRle toRle(const VRect &rect); bool unique() const {return d.unique();} - int refCount() const { return d.refCount();} + size_t refCount() const { return d.refCount();} void clone(const VRle &o); private: @@ -75,7 +75,7 @@ private: void setBbox(const VRect &bbox) const; void reset(); void translate(const VPoint &p); - void operator*=(int alpha); + void operator*=(uchar alpha); void invert(); void opIntersect(const VRect &, VRle::VRleSpanCb, void *) const; void opGeneric(const VRle::VRleData &, const VRle::VRleData &, OpCode code); @@ -119,7 +119,7 @@ inline void VRle::invert() d.write().invert(); } -inline void VRle::operator*=(int alpha) +inline void VRle::operator*=(uchar alpha) { d.write() *= alpha; }