From 5f556cf0d55465adf87cc248834a5650b2ef29fa Mon Sep 17 00:00:00 2001 From: "sub.mohanty@samsung.com" Date: Sat, 21 Jul 2018 17:07:00 +0900 Subject: [PATCH] lottie: give a make_unique wrapper till we move to c++14 Change-Id: I09061f807f6bf9ad5eea631f206d89705e3ae1bc --- src/lottie/lottieitem.cpp | 6 +++--- src/lottie/lottiemodel.cpp | 4 ++-- src/lottie/lottieplayer.cpp | 2 +- src/vector/vglobal.h | 10 ++++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index d928b74..e037b6c 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -401,7 +401,7 @@ LOTLayerItem::LOTLayerItem(LOTLayerData *layerData):mLayerData(layerData), { if (mLayerData->mHasMask) { for (auto i : mLayerData->mMasks) { - mMasks.push_back(std::unique_ptr(new LOTMaskItem(i.get()))); + mMasks.push_back(std::make_unique(i.get())); } } } @@ -565,7 +565,7 @@ LOTSolidLayerItem::LOTSolidLayerItem(LOTLayerData *layerData):LOTLayerItem(layer void LOTSolidLayerItem::updateContent() { if (!mRenderNode) { - mRenderNode = std::unique_ptr(new VDrawable()); + mRenderNode = std::make_unique(); mRenderNode->mType = VDrawable::Type::Fill; mRenderNode->mFlag |= VDrawable::DirtyState::All; } @@ -765,7 +765,7 @@ void LOTPathDataItem::addPaintOperation(std::vector &list, i { for(auto paintItem : list) { bool sameGroup = (externalCount-- > 0) ? false : true; - mNodeList.push_back(std::unique_ptr(new VDrawable())); + mNodeList.push_back(std::make_unique()); mRenderList.push_back(LOTRenderNode(this, paintItem, mNodeList.back().get(), sameGroup)); } } diff --git a/src/lottie/lottiemodel.cpp b/src/lottie/lottiemodel.cpp index a31f640..17cbb00 100644 --- a/src/lottie/lottiemodel.cpp +++ b/src/lottie/lottiemodel.cpp @@ -312,9 +312,9 @@ void LOTGradient::update(std::unique_ptr &grad, int frameNo) bool init = false; if (!grad) { if (mGradientType == 1) - grad = std::unique_ptr(new VLinearGradient(0,0,0,0)); + grad = std::make_unique(0,0,0,0); else - grad = std::unique_ptr(new VRadialGradient(0,0,0,0,0,0)); + grad = std::make_unique(0,0,0,0,0,0); grad->mSpread = VGradient::Spread::Pad; init = true; } diff --git a/src/lottie/lottieplayer.cpp b/src/lottie/lottieplayer.cpp index 3313f5f..e336139 100644 --- a/src/lottie/lottieplayer.cpp +++ b/src/lottie/lottieplayer.cpp @@ -123,7 +123,7 @@ LOTPlayerPrivate::setFilePath(std::string path) LottieLoader loader; if (loader.load(path)) { mModel = loader.model(); - mCompItem = std::unique_ptr(new LOTCompItem(mModel.get())); + mCompItem = std::make_unique(mModel.get()); setPos(0); return true; } diff --git a/src/vector/vglobal.h b/src/vector/vglobal.h index 0585955..eefe5b2 100644 --- a/src/vector/vglobal.h +++ b/src/vector/vglobal.h @@ -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 +std::unique_ptr make_unique( Args&& ...args ) +{ + return std::unique_ptr( new T( std::forward(args)... ) ); +} +} #include class RefCount -- 2.7.4