trial & error to figure out the lottie packaging issue in vd. 59/214159/1
authorHermet Park <hermetpark@gmail.com>
Wed, 18 Sep 2019 11:31:45 +0000 (20:31 +0900)
committerHermet Park <hermetpark@gmail.com>
Wed, 18 Sep 2019 11:31:45 +0000 (20:31 +0900)
Change-Id: I3109d1dfc4fb00fc41a8aaed5c20b08018564b45

CMakeLists.txt
example/evasapp.cpp
example/lottieview.cpp
example/uxsampletest.cpp
meson.build
src/lottie/lottieitem.cpp
src/lottie/lottieparser.cpp
src/vector/vdrawhelper.cpp
src/vector/vglobal.h

index e0d4e0b..4f6f1c8 100644 (file)
@@ -45,7 +45,7 @@ target_include_directories(rlottie
 target_compile_options(rlottie
                     PUBLIC
                     PRIVATE
-                        -std=c++14
+                        -std=c++11
                         -fno-exceptions
                         -fno-unwind-tables
                         -fno-asynchronous-unwind-tables
index 1fa3c0e..c3c8011 100644 (file)
@@ -134,7 +134,7 @@ EvasApp::jsonFiles(const std::string &dirName, bool /*recurse*/)
       closedir(d);
     }
 
-    std::sort(result.begin(), result.end(), [](auto & a, auto &b){return a < b;});
+    std::sort(result.begin(), result.end(), [](std::string & a, std::string &b){return a < b;});
 
     return result;
 }
index 8659c16..3ac4dc9 100644 (file)
@@ -55,27 +55,27 @@ LottieView::LottieView(Evas *evas, Strategy s) {
 
     switch (s) {
     case Strategy::renderCpp: {
-        mRenderDelegate = std::make_unique<RlottieRenderStrategy_CPP>(evas);
+        mRenderDelegate = std::unique_ptr<RlottieRenderStrategy_CPP>(new RlottieRenderStrategy_CPP(evas));
         break;
     }
     case Strategy::renderCppAsync: {
-        mRenderDelegate = std::make_unique<RlottieRenderStrategy_CPP_ASYNC>(evas);
+        mRenderDelegate = std::unique_ptr<RlottieRenderStrategy_CPP_ASYNC>(new RlottieRenderStrategy_CPP_ASYNC(evas));
         break;
     }
     case Strategy::renderC: {
-        mRenderDelegate = std::make_unique<RlottieRenderStrategy_C>(evas);
+        mRenderDelegate = std::unique_ptr<RlottieRenderStrategy_C>(new RlottieRenderStrategy_C(evas));
         break;
     }
     case Strategy::renderCAsync: {
-        mRenderDelegate = std::make_unique<RlottieRenderStrategy_C_ASYNC>(evas);
+        mRenderDelegate = std::unique_ptr<RlottieRenderStrategy_C_ASYNC>(new RlottieRenderStrategy_C_ASYNC(evas));
         break;
     }
     case Strategy::eflVg: {
-        mRenderDelegate = std::make_unique<EflVgRenderStrategy>(evas);
+        mRenderDelegate = std::unique_ptr<EflVgRenderStrategy>(new EflVgRenderStrategy(evas));
         break;
     }
     default:
-        mRenderDelegate = std::make_unique<RlottieRenderStrategy_CPP>(evas);
+        mRenderDelegate = std::unique_ptr<RlottieRenderStrategy_CPP>(new RlottieRenderStrategy_CPP(evas));
         break;
     }
 }
index 6fcbae8..5e6b462 100644 (file)
@@ -57,7 +57,7 @@ public:
 
 private:
   void show() {
-      mView = std::make_unique<LottieView>(mApp->evas(), Strategy::renderCAsync);
+      mView = std::unique_ptr<LottieView>(new LottieView(mApp->evas(), Strategy::renderCAsync));
       mView->setFilePath(mResourceList[mCurIndex].c_str());
       mView->setPos(0, 0);
       mView->setSize(mApp->width(), mApp->height());
index e4d1669..4ca9664 100644 (file)
@@ -1,6 +1,6 @@
 project('rlottie',
         'cpp',
-        default_options : ['warning_level=3', 'werror=true', 'cpp_std=c++14', 'optimization=s'],
+        default_options : ['warning_level=3', 'werror=true', 'cpp_std=c++11', 'optimization=s'],
         version : '0.0.1',
         license : 'Apache')
 
index cdab800..68815fc 100644 (file)
@@ -432,9 +432,8 @@ LOTCompLayerItem::LOTCompLayerItem(LOTLayerData *layerModel)
     for (const auto &layer : mLayers) {
         int id = layer->parentId();
         if (id >= 0) {
-            auto search =
-                std::find_if(mLayers.begin(), mLayers.end(),
-                             [id](const auto &val) { return val->id() == id; });
+            auto search = std::find_if(mLayers.begin(), mLayers.end(),
+                            [id](const std::unique_ptr<LOTLayerItem>& val){ return val->id() == id;});
             if (search != mLayers.end()) layer->setParentLayer((*search).get());
         }
     }
index aab1275..50776f7 100644 (file)
@@ -589,7 +589,7 @@ void LottieParserImpl::parseComposition()
         }
     }
 
-    if (comp->mVersion.empty()) {
+    if (comp->mVersion.empty() || !comp->mRootLayer) {
         // don't have a valid bodymovin header
         return;
     }
@@ -771,10 +771,7 @@ LottieColor LottieParserImpl::toColor(const char *str)
 
     // some resource has empty color string
     // return a default color for those cases.
-    if (!len) return color;
-
-    RAPIDJSON_ASSERT(len == 7);
-    RAPIDJSON_ASSERT(str[0] == '#');
+    if (len != 7 || str[0] != '#') return color;
 
     char tmp[3] = {'\0', '\0', '\0'};
     tmp[0] = str[1];
@@ -1712,13 +1709,16 @@ void LottieParserImpl::getValue(std::vector<VPointF> &v)
 
 void LottieParserImpl::getValue(VPointF &pt)
 {
-    float val[4];
+    float val[4] = {0.f};
     int   i = 0;
 
     if (PeekType() == kArrayType) EnterArray();
 
     while (NextArrayValue()) {
-        val[i++] = GetDouble();
+        const auto value = GetDouble();
+        if (i < 4) {
+            val[i++] = value;
+        }
     }
     pt.setX(val[0]);
     pt.setY(val[1]);
@@ -1742,12 +1742,15 @@ void LottieParserImpl::getValue(float &val)
 
 void LottieParserImpl::getValue(LottieColor &color)
 {
-    float val[4];
+    float val[4] = {0.f};
     int   i = 0;
     if (PeekType() == kArrayType) EnterArray();
 
     while (NextArrayValue()) {
-        val[i++] = GetDouble();
+        const auto value = GetDouble();
+        if (i < 4) {
+            val[i++] = value;
+        }
     }
     color.r = val[0];
     color.g = val[1];
index d6fa3d1..e3ae7a8 100644 (file)
@@ -135,6 +135,9 @@ protected:
         return cache_entry;
     }
 
+private:
+    VGradientCache() = default;
+
     VGradientColorTableHash mCache;
     std::mutex              mMutex;
 };
index 75c947c..5426890 100644 (file)
@@ -70,6 +70,45 @@ using uchar  = uint8_t;
 #define VECTOR_FALLTHROUGH
 #endif
 
+#if __cplusplus==201103L
+
+#include <memory>
+
+namespace std {
+
+template<class T> struct _Unique_if {
+    typedef unique_ptr<T> _Single_object;
+};
+
+template<class T> struct _Unique_if<T[]> {
+    typedef unique_ptr<T[]> _Unknown_bound;
+};
+
+template<class T, size_t N> struct _Unique_if<T[N]> {
+    typedef void _Known_bound;
+};
+
+template<class T, class... Args>
+    typename _Unique_if<T>::_Single_object
+    make_unique(Args&&... args) {
+        return unique_ptr<T>(new T(std::forward<Args>(args)...));
+    }
+
+template<class T>
+    typename _Unique_if<T>::_Unknown_bound
+    make_unique(size_t n) {
+        typedef typename remove_extent<T>::type U;
+        return unique_ptr<T>(new U[n]());
+    }
+
+template<class T, class... Args>
+    typename _Unique_if<T>::_Known_bound
+    make_unique(Args&&...) = delete;
+
+}  //namespace std
+
+#endif //__cplusplus==201103L
+
 #include <atomic>
 class RefCount {
 public: