rlottie: change the name() api signature to return const char*
authorsub.mohanty@samsung.com <smohantty@gmail.com>
Sat, 3 Aug 2019 06:34:46 +0000 (15:34 +0900)
committerHermet Park <hermetpark@gmail.com>
Mon, 12 Aug 2019 08:31:50 +0000 (17:31 +0900)
this patch is a preparation for the optimization patch which
will manage the memory for name string itself instead of using std::string.

src/lottie/lottieitem.cpp
src/lottie/lottieitem.h
src/lottie/lottiemodel.h
src/lottie/lottieproxymodel.h

index 95e8d36..011f9fa 100644 (file)
@@ -227,7 +227,7 @@ void LOTLayerItem::buildLayerNode()
         mLayerCNode->mClipPath.elmPtr = nullptr;
         mLayerCNode->mClipPath.ptCount = 0;
         mLayerCNode->mClipPath.elmCount = 0;
-        mLayerCNode->keypath = name().c_str();
+        mLayerCNode->keypath = name();
     }
     if (complexContent()) mLayerCNode->mAlpha = uchar(combinedAlpha() * 255.f);
     mLayerCNode->mVisible = visible();
index b3165ef..8d51afe 100644 (file)
@@ -118,7 +118,7 @@ public:
    bool visible() const;
    virtual void buildLayerNode();
    LOTLayerNode * layerNode() const {return mLayerCNode.get();}
-   const std::string & name() const {return mLayerData->name();}
+   const char* name() const {return mLayerData->name();}
    virtual bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value);
    VBitmap& bitmap() {return mRenderBuffer;}
 protected:
@@ -289,9 +289,9 @@ public:
    void processPaintItems(std::vector<LOTPathDataItem *> &list);
    void renderList(std::vector<VDrawable *> &list) override;
    const VMatrix & matrix() const { return mMatrix;}
-   const std::string & name() const
+   const char* name() const
    {
-       static const std::string TAG = "__";
+       static const char* TAG = "__";
        return mData ? mData->name() : TAG;
    }
    bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value) override;
index 6186dd1..c8d38bb 100644 (file)
@@ -379,7 +379,7 @@ public:
     bool hidden() const {return mHidden;}
     void setHidden(bool value) {mHidden = value;}
     void setName(const char *str) {mName = str;}
-    const std::string& name() const{ return mName;}
+    const char* name() const{ return mName.c_str();}
 private:
     std::string               mName;
     bool                      mStatic{true};
index 1debf7a..ec4e5fd 100644 (file)
@@ -272,7 +272,7 @@ class LOTProxyModel
 public:
     LOTProxyModel(T *model): _modelData(model) {}
     LOTFilter& filter() {return mFilter;}
-    const std::string & name() const {return _modelData->name();}
+    const char* name() const {return _modelData->name();}
     LottieColor color(int frame) const
     {
         if (mFilter.hasFilter(rlottie::Property::StrokeColor)) {
@@ -313,7 +313,7 @@ class LOTProxyModel<LOTFillData>
 public:
     LOTProxyModel(LOTFillData *model): _modelData(model) {}
     LOTFilter& filter() {return mFilter;}
-    const std::string & name() const {return _modelData->name();}
+    const char* name() const {return _modelData->name();}
     LottieColor color(int frame) const
     {
         if (mFilter.hasFilter(rlottie::Property::FillColor)) {