Fixed warnings
authorsubhransu mohanty <sub.mohanty@samsung.com>
Thu, 11 Jul 2019 00:51:23 +0000 (09:51 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 18 Jul 2019 11:04:28 +0000 (20:04 +0900)
src/lottie/lottiemodel.h
src/vector/vbezier.h
src/vector/vglobal.h
src/vector/vinterpolator.h
src/vector/vpoint.h
src/vector/vrect.h

index 7bbcb39..029260a 100644 (file)
@@ -76,7 +76,10 @@ class LottieColor
 public:
     LottieColor() = default;
     LottieColor(float red, float green , float blue):r(red), g(green),b(blue){}
-    VColor toColor(float a=1){ return VColor((255 * r), (255 * g), (255 * b), (255 * a));}
+    VColor toColor(float a=1){ return VColor(uchar(255 * r),
+                                             uchar(255 * g),
+                                             uchar(255 * b),
+                                             uchar(255 * a));}
     friend inline LottieColor operator+(const LottieColor &c1, const LottieColor &c2);
     friend inline LottieColor operator-(const LottieColor &c1, const LottieColor &c2);
 public:
index b07e782..ea85374 100644 (file)
@@ -50,13 +50,13 @@ private:
 inline void VBezier::coefficients(float t, float &a, float &b, float &c,
                                   float &d)
 {
-    float m_t = 1. - t;
+    float m_t = 1.0f - t;
     b = m_t * m_t;
     c = t * t;
     d = c * t;
     a = b * m_t;
-    b *= 3. * t;
-    c *= 3. * m_t;
+    b *= 3.0f * t;
+    c *= 3.0f * m_t;
 }
 
 inline VPointF VBezier::pointAt(float t) const
@@ -64,7 +64,7 @@ inline VPointF VBezier::pointAt(float t) const
     // numerically more stable:
     float x, y;
 
-    float m_t = 1. - t;
+    float m_t = 1.0f - t;
     {
         float a = x1 * m_t + x2 * t;
         float b = x2 * m_t + x3 * t;
@@ -110,23 +110,23 @@ inline void VBezier::parameterSplitLeft(float t, VBezier *left)
 
 inline void VBezier::split(VBezier *firstHalf, VBezier *secondHalf) const
 {
-    float c = (x2 + x3) * .5;
-    firstHalf->x2 = (x1 + x2) * .5;
-    secondHalf->x3 = (x3 + x4) * .5;
+    float c = (x2 + x3) * .5f;
+    firstHalf->x2 = (x1 + x2) * .5f;
+    secondHalf->x3 = (x3 + x4) * .5f;
     firstHalf->x1 = x1;
     secondHalf->x4 = x4;
-    firstHalf->x3 = (firstHalf->x2 + c) * .5;
-    secondHalf->x2 = (secondHalf->x3 + c) * .5;
-    firstHalf->x4 = secondHalf->x1 = (firstHalf->x3 + secondHalf->x2) * .5;
+    firstHalf->x3 = (firstHalf->x2 + c) * .5f;
+    secondHalf->x2 = (secondHalf->x3 + c) * .5f;
+    firstHalf->x4 = secondHalf->x1 = (firstHalf->x3 + secondHalf->x2) * .5f;
 
     c = (y2 + y3) / 2;
-    firstHalf->y2 = (y1 + y2) * .5;
-    secondHalf->y3 = (y3 + y4) * .5;
+    firstHalf->y2 = (y1 + y2) * .5f;
+    secondHalf->y3 = (y3 + y4) * .5f;
     firstHalf->y1 = y1;
     secondHalf->y4 = y4;
-    firstHalf->y3 = (firstHalf->y2 + c) * .5;
-    secondHalf->y2 = (secondHalf->y3 + c) * .5;
-    firstHalf->y4 = secondHalf->y1 = (firstHalf->y3 + secondHalf->y2) * .5;
+    firstHalf->y3 = (firstHalf->y2 + c) * .5f;
+    secondHalf->y2 = (secondHalf->y3 + c) * .5f;
+    firstHalf->y4 = secondHalf->y1 = (firstHalf->y3 + secondHalf->y2) * .5f;
 }
 
 V_END_NAMESPACE
index 98837fd..86600a7 100644 (file)
@@ -25,9 +25,9 @@
 #include <type_traits>
 #include <utility>
 
-typedef uint32_t uint;
-typedef uint16_t ushort;
-typedef uint8_t  uchar;
+using uint   = uint32_t;
+using ushort = uint16_t;
+using uchar  = uint8_t;
 
 #if !defined(V_NAMESPACE)
 
@@ -73,7 +73,7 @@ typedef uint8_t  uchar;
 #include <atomic>
 class RefCount {
 public:
-    inline RefCount(int i) : atomic(i) {}
+    explicit RefCount(int i) : atomic(i) {}
     inline bool ref()
     {
         int count = atomic.load();
@@ -144,12 +144,12 @@ class vFlagHelper {
     int i;
 
 public:
-    constexpr inline vFlagHelper(int ai) noexcept : i(ai) {}
+    explicit constexpr inline vFlagHelper(int ai) noexcept : i(ai) {}
     constexpr inline operator int() const noexcept { return i; }
 
-    constexpr inline vFlagHelper(uint ai) noexcept : i(int(ai)) {}
-    constexpr inline vFlagHelper(short ai) noexcept : i(int(ai)) {}
-    constexpr inline vFlagHelper(ushort ai) noexcept : i(int(uint(ai))) {}
+    explicit constexpr inline vFlagHelper(uint ai) noexcept : i(int(ai)) {}
+    explicit constexpr inline vFlagHelper(short ai) noexcept : i(int(ai)) {}
+    explicit constexpr inline vFlagHelper(ushort ai) noexcept : i(int(uint(ai))) {}
     constexpr inline operator uint() const noexcept { return uint(i); }
 };
 
@@ -162,16 +162,16 @@ public:
     static_assert((std::is_enum<Enum>::value),
                   "vFlag is only usable on enumeration types.");
 
-    typedef typename std::conditional<
+    using Int = typename std::conditional<
         std::is_unsigned<typename std::underlying_type<Enum>::type>::value,
-        unsigned int, signed int>::type Int;
+        unsigned int, signed int>::type;
 
-    typedef Enum enum_type;
+    using  enum_type = Enum;
     // compiler-generated copy/move ctor/assignment operators are fine!
 
-    constexpr inline vFlag(Enum f) noexcept : i(Int(f)) {}
-    constexpr inline vFlag() noexcept : i(0) {}
-    constexpr inline vFlag(vFlagHelper f) noexcept : i(f) {}
+    vFlag() = default;
+    constexpr vFlag(Enum f) noexcept : i(Int(f)) {}
+    explicit constexpr vFlag(vFlagHelper f) noexcept : i(f) {}
 
     inline vFlag &operator&=(int mask) noexcept
     {
@@ -255,19 +255,14 @@ public:
         return on ? (*this |= f) : (*this &= ~f);
     }
 
-    Int i;
+    Int i{0};
 };
 
 class VColor {
 public:
-    inline VColor() noexcept { a = r = g = b = 0; }
-    inline VColor(int red, int green, int blue, int alpha = 255) noexcept
-    {
-        r = red;
-        g = green;
-        b = blue;
-        a = alpha;
-    }
+    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; }
@@ -291,7 +286,7 @@ public:
 
     uint premulARGB(float opacity) const
     {
-        int alpha = a * opacity;
+        int alpha = int(a * opacity);
         int pr = (r * alpha) / 255;
         int pg = (g * alpha) / 255;
         int pb = (b * alpha) / 255;
@@ -299,10 +294,10 @@ public:
     }
 
 public:
-    uchar a;
-    uchar r;
-    uchar g;
-    uchar b;
+    uchar a{0};
+    uchar r{0};
+    uchar g{0};
+    uchar b{0};
 };
 
 enum class FillRule: unsigned char { EvenOdd, Winding };
index 77aaaae..2201882 100644 (file)
@@ -64,11 +64,11 @@ private:
 
     float BinarySubdivide(float aX, float aA, float aB) const;
 
-    static float A(float aA1, float aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; }
+    static float A(float aA1, float aA2) { return 1.0f - 3.0f * aA2 + 3.0f * aA1; }
 
-    static float B(float aA1, float aA2) { return 3.0 * aA2 - 6.0 * aA1; }
+    static float B(float aA1, float aA2) { return 3.0f * aA2 - 6.0f * aA1; }
 
-    static float C(float aA1) { return 3.0 * aA1; }
+    static float C(float aA1) { return 3.0f * aA1; }
 
     float mX1;
     float mY1;
index 1a84cb1..3565caf 100644 (file)
@@ -44,10 +44,10 @@ public:
     inline friend VDebug &   operator<<(VDebug &os, const VPointF &o);
 
     friend inline VPointF       operator-(const VPointF &p1, const VPointF &p2);
-    friend inline const VPointF operator*(const VPointF &, float val);
-    friend inline const VPointF operator*(float val, const VPointF &);
-    friend inline const VPointF operator/(const VPointF &, float val);
-    friend inline const VPointF operator/(float val, const VPointF &);
+    friend inline const VPointF operator*(const VPointF &, float);
+    friend inline const VPointF operator*(float, const VPointF &);
+    friend inline const VPointF operator/(const VPointF &, float);
+    friend inline const VPointF operator/(float, const VPointF &);
 
 private:
     float mx{0};
index 494579b..9638859 100644 (file)
@@ -107,23 +107,17 @@ inline void VRect::translate(int dx, int dy)
 
 inline bool VRect::contains(const VRect &r, bool proper) const
 {
-    if (!proper) {
-        if ((x1 <= r.x1) && (x2 >= r.x2) && (y1 <= r.y1) && (y2 >= r.y2))
-            return true;
-        return false;
-    } else {
-        if ((x1 < r.x1) && (x2 > r.x2) && (y1 < r.y1) && (y2 > r.y2))
-            return true;
-        return false;
-    }
+    return proper ?
+           ((x1 < r.x1) && (x2 > r.x2) && (y1 < r.y1) && (y2 > r.y2)) :
+           ((x1 <= r.x1) && (x2 >= r.x2) && (y1 <= r.y1) && (y2 >= r.y2));
 }
 
 class VRectF {
 public:
     VRectF() = default;
     VRectF(float x, float y, float w, float h):x1(x),y1(y),x2(x+w),y2(y+h){}
-    explicit VRectF(const VRect &r):x1(r.left()),y1(r.top()),
-                                    x2(r.right()),y2(r.bottom()){}
+    explicit VRectF(const VRect &r):x1(float(r.left())),y1(float(r.top())),
+                                    x2(float(r.right())),y2(float(r.bottom())){}
 
     V_CONSTEXPR bool  empty() const {return x1 >= x2 || y1 >= y2;}
     V_CONSTEXPR float left() const {return x1;}
@@ -159,8 +153,8 @@ private:
     float y2{0};
 };
 
-inline VRect::VRect(const VRectF &r):x1(r.left()),y1(r.top()),
-                                     x2(r.right()),y2(r.bottom()){}
+inline VRect::VRect(const VRectF &r):x1(int(r.left())),y1(int(r.top())),
+                                     x2(int(r.right())),y2(int(r.bottom())){}
 V_END_NAMESPACE
 
 #endif  // VRECT_H