lottie/optimization: keep painter and surface in composition to avoid memory allocation accepted/tizen/unified/20191001.062516 submit/tizen/20190929.220413 submit/tizen/20190930.064714 submit/tizen/20191001.000056
authorsubhransu mohanty <sub.mohanty@samsung.com>
Fri, 27 Sep 2019 07:01:14 +0000 (16:01 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 29 Sep 2019 21:50:13 +0000 (06:50 +0900)
src/lottie/lottieitem.cpp
src/lottie/lottieitem.h

index cdb1573..c49255d 100644 (file)
@@ -143,7 +143,7 @@ bool LOTCompItem::update(int frameNo, const VSize &size, bool keepAspectRatio)
 
 bool LOTCompItem::render(const rlottie::Surface &surface)
 {
-    VBitmap bitmap(reinterpret_cast<uchar *>(surface.buffer()),
+    mSurface.reset(reinterpret_cast<uchar *>(surface.buffer()),
                    uint(surface.width()), uint(surface.height()), uint(surface.bytesPerLine()),
                    VBitmap::Format::ARGB32_Premultiplied);
 
@@ -156,13 +156,13 @@ bool LOTCompItem::render(const rlottie::Surface &surface)
         e->preprocess(clip);
     }
 
-    VPainter painter(&bitmap);
+    mPainter.begin(&mSurface);
     // set sub surface area for drawing.
-    painter.setDrawRegion(
+    mPainter.setDrawRegion(
         VRect(int(surface.drawRegionPosX()), int(surface.drawRegionPosY()),
               int(surface.drawRegionWidth()), int(surface.drawRegionHeight())));
-    mRootLayer->render(&painter, {}, {});
-
+    mRootLayer->render(&mPainter, {}, {});
+    mPainter.end();
     return true;
 }
 
index b297672..5baa933 100644 (file)
@@ -72,6 +72,8 @@ public:
    bool render(const rlottie::Surface &surface);
    void setValue(const std::string &keypath, LOTVariant &value);
 private:
+   VPainter                                    mPainter;
+   VBitmap                                     mSurface;
    VMatrix                                     mScaleMatrix;
    VSize                                       mViewSize;
    LOTCompositionData                         *mCompData;