lottie: give a make_unique wrapper till we move to c++14 54/184754/3
authorsub.mohanty@samsung.com <smohantty@subhransus-MacBook-Air.local>
Sat, 21 Jul 2018 08:07:00 +0000 (17:07 +0900)
committerSubhransu Mohanty <sub.mohanty@samsung.com>
Tue, 24 Jul 2018 06:11:43 +0000 (06:11 +0000)
Change-Id: I09061f807f6bf9ad5eea631f206d89705e3ae1bc

src/lottie/lottieitem.cpp
src/lottie/lottiemodel.cpp
src/lottie/lottieplayer.cpp
src/vector/vglobal.h

index d928b74..e037b6c 100644 (file)
@@ -401,7 +401,7 @@ LOTLayerItem::LOTLayerItem(LOTLayerData *layerData):mLayerData(layerData),
 {
     if (mLayerData->mHasMask) {
         for (auto i : mLayerData->mMasks) {
-            mMasks.push_back(std::unique_ptr<LOTMaskItem>(new LOTMaskItem(i.get())));
+            mMasks.push_back(std::make_unique<LOTMaskItem>(i.get()));
         }
     }
 }
@@ -565,7 +565,7 @@ LOTSolidLayerItem::LOTSolidLayerItem(LOTLayerData *layerData):LOTLayerItem(layer
 void LOTSolidLayerItem::updateContent()
 {
    if (!mRenderNode) {
-      mRenderNode = std::unique_ptr<VDrawable>(new VDrawable());
+      mRenderNode = std::make_unique<VDrawable>();
       mRenderNode->mType = VDrawable::Type::Fill;
       mRenderNode->mFlag |= VDrawable::DirtyState::All;
    }
@@ -765,7 +765,7 @@ void LOTPathDataItem::addPaintOperation(std::vector<LOTPaintDataItem *> &list, i
 {
     for(auto paintItem : list) {
       bool sameGroup = (externalCount-- > 0) ? false : true;
-      mNodeList.push_back(std::unique_ptr<VDrawable>(new VDrawable()));
+      mNodeList.push_back(std::make_unique<VDrawable>());
       mRenderList.push_back(LOTRenderNode(this, paintItem, mNodeList.back().get(), sameGroup));
     }
 }
index a31f640..17cbb00 100644 (file)
@@ -312,9 +312,9 @@ void LOTGradient::update(std::unique_ptr<VGradient> &grad, int frameNo)
     bool init = false;
     if (!grad) {
         if (mGradientType == 1)
-            grad = std::unique_ptr<VLinearGradient>(new VLinearGradient(0,0,0,0));
+            grad = std::make_unique<VLinearGradient>(0,0,0,0);
         else
-            grad = std::unique_ptr<VRadialGradient>(new VRadialGradient(0,0,0,0,0,0));
+            grad = std::make_unique<VRadialGradient>(0,0,0,0,0,0);
         grad->mSpread = VGradient::Spread::Pad;
         init = true;
     }
index 3313f5f..e336139 100644 (file)
@@ -123,7 +123,7 @@ LOTPlayerPrivate::setFilePath(std::string path)
    LottieLoader loader;
    if (loader.load(path)) {
       mModel = loader.model();
-      mCompItem =  std::unique_ptr<LOTCompItem>(new LOTCompItem(mModel.get()));
+      mCompItem =  std::make_unique<LOTCompItem>(mModel.get());
       setPos(0);
       return true;
    }
index 0585955..eefe5b2 100644 (file)
@@ -35,6 +35,16 @@ typedef uint8_t          uchar;
 #include"vdebug.h"
 
 #define VECTOR_FALLTHROUGH
+/*
+ * keep this till we move the code to c++14
+ */
+namespace std {
+template<typename T, typename ...Args>
+std::unique_ptr<T> make_unique( Args&& ...args )
+{
+    return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );
+}
+}
 
 #include<atomic>
 class RefCount