rlottie: ran clang-format with the latest code
authorsubhransu mohanty <sub.mohanty@samsung.com>
Mon, 24 Jun 2019 07:51:29 +0000 (16:51 +0900)
committerHermet Park <hermetpark@gmail.com>
Tue, 25 Jun 2019 11:59:33 +0000 (20:59 +0900)
26 files changed:
.clang-format
src/lottie/lottieanimation.cpp
src/lottie/lottieitem.cpp
src/lottie/lottiekeypath.cpp
src/lottie/lottieloader.cpp
src/lottie/lottiemodel.cpp
src/lottie/lottieparser.cpp
src/vector/stb/stb_image.cpp
src/vector/vbezier.cpp
src/vector/vbitmap.cpp
src/vector/vbrush.cpp
src/vector/vcompositionfunctions.cpp
src/vector/vdasher.cpp
src/vector/vdebug.cpp
src/vector/vdrawable.cpp
src/vector/vdrawhelper.cpp
src/vector/vdrawhelper_neon.cpp
src/vector/velapsedtimer.cpp
src/vector/vimageloader.cpp
src/vector/vmatrix.cpp
src/vector/vpainter.cpp
src/vector/vpath.cpp
src/vector/vpathmesure.cpp
src/vector/vraster.cpp
src/vector/vrect.cpp
src/vector/vrle.cpp

index 830be3872beb54d82ad5836772399f42338b0f25..10f4c7a503523fb5c4bea0c29b224aa61e9e841c 100644 (file)
@@ -1,6 +1,6 @@
 ---
 Language:        Cpp
-# BasedOnStyle:  Tizen
+BasedOnStyle:  Google
 AccessModifierOffset: -4
 AlignAfterOpenBracket: Align
 AlignConsecutiveAssignments: false
index 7547ac8ae7944dd94a5a76a76c4dea6b53c02436..7b11f4f8ced7078cfdea840f3ba27c466a034231 100644 (file)
@@ -1,25 +1,25 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 #include "config.h"
-#include "rlottie.h"
 #include "lottieitem.h"
 #include "lottieloader.h"
 #include "lottiemodel.h"
+#include "rlottie.h"
 
 #include <fstream>
 
@@ -29,30 +29,32 @@ struct RenderTask {
     RenderTask() { receiver = sender.get_future(); }
     std::promise<Surface> sender;
     std::future<Surface>  receiver;
-    AnimationImpl     *playerImpl{nullptr};
-    size_t              frameNo{0};
-    Surface            surface;
+    AnimationImpl *       playerImpl{nullptr};
+    size_t                frameNo{0};
+    Surface               surface;
 };
 using SharedRenderTask = std::shared_ptr<RenderTask>;
 
 class AnimationImpl {
-
 public:
     void    init(const std::shared_ptr<LOTModel> &model);
     bool    update(size_t frameNo, const VSize &size);
-    VSize   size() const {return mCompItem->size();}
-    double  duration() const {return mModel->duration();}
-    double  frameRate() const {return mModel->frameRate();}
-    size_t  totalFrame() const {return mModel->totalFrame();}
-    size_t  frameAtPos(double pos) const {return mModel->frameAtPos(pos);}
+    VSize   size() const { return mCompItem->size(); }
+    double  duration() const { return mModel->duration(); }
+    double  frameRate() const { return mModel->frameRate(); }
+    size_t  totalFrame() const { return mModel->totalFrame(); }
+    size_t  frameAtPos(double pos) const { return mModel->frameAtPos(pos); }
     Surface render(size_t frameNo, const Surface &surface);
     std::future<Surface> renderAsync(size_t frameNo, Surface &&surface);
-    const LOTLayerNode *
-                 renderTree(size_t frameNo, const VSize &size);
+    const LOTLayerNode * renderTree(size_t frameNo, const VSize &size);
 
-    const LayerInfoList& layerInfoList() const { return mModel->layerInfoList();}
+    const LayerInfoList &layerInfoList() const
+    {
+        return mModel->layerInfoList();
+    }
     void setValue(const std::string &keypath, LOTVariant &&value);
     void removeFilter(const std::string &keypath, Property prop);
+
 private:
     std::string                  mFilePath;
     std::shared_ptr<LOTModel>    mModel;
@@ -70,36 +72,34 @@ void AnimationImpl::setValue(const std::string &keypath, LOTVariant &&value)
 const LOTLayerNode *AnimationImpl::renderTree(size_t frameNo, const VSize &size)
 {
     if (update(frameNo, size)) {
-       mCompItem->buildRenderTree();
+        mCompItem->buildRenderTree();
     }
     return mCompItem->renderTree();
 }
 
 bool AnimationImpl::update(size_t frameNo, const VSize &size)
 {
-   frameNo += mModel->startFrame();
+    frameNo += mModel->startFrame();
 
-   if (frameNo > mModel->endFrame())
-       frameNo = mModel->endFrame();
+    if (frameNo > mModel->endFrame()) frameNo = mModel->endFrame();
 
-   if (frameNo < mModel->startFrame())
-       frameNo = mModel->startFrame();
+    if (frameNo < mModel->startFrame()) frameNo = mModel->startFrame();
 
-   mCompItem->resize(size);
-   return mCompItem->update(frameNo);
+    mCompItem->resize(size);
+    return mCompItem->update(frameNo);
 }
 
 Surface AnimationImpl::render(size_t frameNo, const Surface &surface)
 {
     bool renderInProgress = mRenderInProgress.load();
-    if (renderInProgress)
-      {
+    if (renderInProgress) {
         vCritical << "Already Rendering Scheduled for this Animation";
         return surface;
-      }
+    }
 
     mRenderInProgress.store(true);
-    update(frameNo, VSize(surface.drawRegionWidth(), surface.drawRegionHeight()));
+    update(frameNo,
+           VSize(surface.drawRegionWidth(), surface.drawRegionHeight()));
     mCompItem->render(surface);
     mRenderInProgress.store(false);
 
@@ -115,8 +115,8 @@ void AnimationImpl::init(const std::shared_ptr<LOTModel> &model)
 
 #ifdef LOTTIE_THREAD_SUPPORT
 
-#include "vtaskqueue.h"
 #include <thread>
+#include "vtaskqueue.h"
 
 /*
  * Implement a task stealing schduler to perform render task
@@ -133,12 +133,12 @@ class RenderTaskScheduler {
     const unsigned           _count{std::thread::hardware_concurrency()};
     std::vector<std::thread> _threads;
     std::vector<TaskQueue<SharedRenderTask>> _q{_count};
-    std::atomic<unsigned>              _index{0};
+    std::atomic<unsigned>                    _index{0};
 
     void run(unsigned i)
     {
         while (true) {
-            bool success = false;
+            bool             success = false;
             SharedRenderTask task;
             for (unsigned n = 0; n != _count * 32; ++n) {
                 if (_q[(i + n) % _count].try_pop(task)) {
@@ -148,7 +148,8 @@ class RenderTaskScheduler {
             }
             if (!success && !_q[i].pop(task)) break;
 
-            auto result = task->playerImpl->render(task->frameNo, task->surface);
+            auto result =
+                task->playerImpl->render(task->frameNo, task->surface);
             task->sender.set_value(result);
         }
     }
@@ -161,10 +162,10 @@ class RenderTaskScheduler {
     }
 
 public:
-    static RenderTaskSchedulerinstance()
+    static RenderTaskScheduler &instance()
     {
-         static RenderTaskScheduler singleton;
-         return singleton;
+        static RenderTaskScheduler singleton;
+        return singleton;
     }
 
     ~RenderTaskScheduler()
@@ -194,10 +195,10 @@ public:
 #else
 class RenderTaskScheduler {
 public:
-    static RenderTaskSchedulerinstance()
+    static RenderTaskScheduler &instance()
     {
-         static RenderTaskScheduler singleton;
-         return singleton;
+        static RenderTaskScheduler singleton;
+        return singleton;
     }
 
     std::future<Surface> process(SharedRenderTask task)
@@ -209,8 +210,8 @@ public:
 };
 #endif
 
-
-std::future<Surface> AnimationImpl::renderAsync(size_t frameNo, Surface &&surface)
+std::future<Surface> AnimationImpl::renderAsync(size_t    frameNo,
+                                                Surface &&surface)
 {
     if (!mTask) {
         mTask = std::make_shared<RenderTask>();
@@ -230,8 +231,9 @@ std::future<Surface> AnimationImpl::renderAsync(size_t frameNo, Surface &&surfac
  * Description about the setFilePath Api
  * @param path  add the details
  */
-std::unique_ptr<Animation>
-Animation::loadFromData(std::string jsonData, const std::string &key, const std::string &resourcePath)
+std::unique_ptr<Animation> Animation::loadFromData(
+    std::string jsonData, const std::string &key,
+    const std::string &resourcePath)
 {
     if (jsonData.empty()) {
         vWarning << "jason data is empty";
@@ -248,8 +250,7 @@ Animation::loadFromData(std::string jsonData, const std::string &key, const std:
     return nullptr;
 }
 
-std::unique_ptr<Animation>
-Animation::loadFromFile(const std::string &path)
+std::unique_ptr<Animation> Animation::loadFromFile(const std::string &path)
 {
     if (path.empty()) {
         vWarning << "File path is empty";
@@ -293,8 +294,8 @@ size_t Animation::frameAtPos(double pos)
     return d->frameAtPos(pos);
 }
 
-const LOTLayerNode *
-Animation::renderTree(size_t frameNo, size_t width, size_t height) const
+const LOTLayerNode *Animation::renderTree(size_t frameNo, size_t width,
+                                          size_t height) const
 {
     return d->renderTree(frameNo, VSize(width, height));
 }
@@ -309,81 +310,77 @@ void Animation::renderSync(size_t frameNo, Surface surface)
     d->render(frameNo, surface);
 }
 
-const LayerInfoListAnimation::layers() const
+const LayerInfoList &Animation::layers() const
 {
     return d->layerInfoList();
 }
 
-void Animation::setValue(Color_Type,Property prop,
-                         const std::string &keypath,
+void Animation::setValue(Color_Type, Property prop, const std::string &keypath,
                          Color value)
 {
-    d->setValue(keypath, LOTVariant(prop, [value](const FrameInfo &){ return value;}));
+    d->setValue(keypath,
+                LOTVariant(prop, [value](const FrameInfo &) { return value; }));
 }
 
-void Animation::setValue(Float_Type, Property prop,
-                         const std::string &keypath,
+void Animation::setValue(Float_Type, Property prop, const std::string &keypath,
                          float value)
 {
-    d->setValue(keypath, LOTVariant(prop, [value](const FrameInfo &){ return value;}));
+    d->setValue(keypath,
+                LOTVariant(prop, [value](const FrameInfo &) { return value; }));
 }
 
-void Animation::setValue(Size_Type,Property prop,
-                         const std::string &keypath,
+void Animation::setValue(Size_Type, Property prop, const std::string &keypath,
                          Size value)
 {
-    d->setValue(keypath, LOTVariant(prop, [value](const FrameInfo &){ return value;}));
+    d->setValue(keypath,
+                LOTVariant(prop, [value](const FrameInfo &) { return value; }));
 }
 
-void Animation::setValue(Point_Type, Property prop,
-                         const std::string &keypath,
+void Animation::setValue(Point_Type, Property prop, const std::string &keypath,
                          Point value)
 {
-    d->setValue(keypath, LOTVariant(prop, [value](const FrameInfo &){ return value;}));
+    d->setValue(keypath,
+                LOTVariant(prop, [value](const FrameInfo &) { return value; }));
 }
 
-void Animation::setValue(Color_Type,Property prop,
-                         const std::string &keypath,
-                         std::function<Color(const FrameInfo &)> && value)
+void Animation::setValue(Color_Type, Property prop, const std::string &keypath,
+                         std::function<Color(const FrameInfo &)> &&value)
 {
     d->setValue(keypath, LOTVariant(prop, value));
 }
 
-void Animation::setValue(Float_Type, Property prop,
-                         const std::string &keypath,
-                         std::function<float(const FrameInfo &)> && value)
+void Animation::setValue(Float_Type, Property prop, const std::string &keypath,
+                         std::function<float(const FrameInfo &)> &&value)
 {
     d->setValue(keypath, LOTVariant(prop, value));
 }
 
-void Animation::setValue(Size_Type,Property prop,
-                         const std::string &keypath,
-                         std::function<Size(const FrameInfo &)> && value)
+void Animation::setValue(Size_Type, Property prop, const std::string &keypath,
+                         std::function<Size(const FrameInfo &)> &&value)
 {
     d->setValue(keypath, LOTVariant(prop, value));
 }
 
-void Animation::setValue(Point_Type, Property prop,
-                         const std::string &keypath,
-                         std::function<Point(const FrameInfo &)> && value)
+void Animation::setValue(Point_Type, Property prop, const std::string &keypath,
+                         std::function<Point(const FrameInfo &)> &&value)
 {
     d->setValue(keypath, LOTVariant(prop, value));
 }
 
-Animation::Animation(): d(std::make_unique<AnimationImpl>()) {}
+Animation::Animation() : d(std::make_unique<AnimationImpl>()) {}
 
 /*
  * this is only to supress build fail
  * because unique_ptr expects the destructor in the same translation unit.
  */
-Animation::~Animation(){}
-
-Surface::Surface(uint32_t *buffer,
-                 size_t width, size_t height, size_t bytesPerLine)
-                :mBuffer(buffer),
-                 mWidth(width),
-                 mHeight(height),
-                 mBytesPerLine(bytesPerLine)
+Animation::~Animation() {}
+
+Surface::Surface(uint32_t *buffer, size_t width, size_t height,
+                 size_t bytesPerLine)
+    mBuffer(buffer),
+      mWidth(width),
+      mHeight(height),
+      mBytesPerLine(bytesPerLine)
 {
     mDrawArea.w = mWidth;
     mDrawArea.h = mHeight;
@@ -391,8 +388,7 @@ Surface::Surface(uint32_t *buffer,
 
 void Surface::setDrawRegion(size_t x, size_t y, size_t width, size_t height)
 {
-    if ((x + width > mWidth) ||
-        (y + height > mHeight)) return;
+    if ((x + width > mWidth) || (y + height > mHeight)) return;
 
     mDrawArea.x = x;
     mDrawArea.y = y;
@@ -400,7 +396,6 @@ void Surface::setDrawRegion(size_t x, size_t y, size_t width, size_t height)
     mDrawArea.h = height;
 }
 
-
 #ifdef LOTTIE_LOGGING_SUPPORT
 void initLogging()
 {
index a687d76c64cb255f88cd6eeef3390365c3603d1a..c87a43628f68db6bc8dab4f543e4f63ad670672c 100644 (file)
@@ -1,30 +1,30 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "lottieitem.h"
-#include <cmath>
 #include <algorithm>
-#include <iterator> 
+#include <cmath>
+#include <iterator>
+#include "lottiekeypath.h"
 #include "vbitmap.h"
 #include "vdasher.h"
 #include "vpainter.h"
 #include "vraster.h"
-#include "lottiekeypath.h"
 
 /* Lottie Layer Rules
  * 1. time stretch is pre calculated and applied to all the properties of the
  * AE. which means (start frame > endFrame) 3.
  */
 
-static
-bool transformProp(rlottie::Property prop)
+static bool transformProp(rlottie::Property prop)
 {
     switch (prop) {
-        case rlottie::Property::TrAnchor:
-        case rlottie::Property::TrScale:
-        case rlottie::Property::TrOpacity:
-        case rlottie::Property::TrPosition:
-        case rlottie::Property::TrRotation:
-            return true;
-        default:
-            return false;
+    case rlottie::Property::TrAnchor:
+    case rlottie::Property::TrScale:
+    case rlottie::Property::TrOpacity:
+    case rlottie::Property::TrPosition:
+    case rlottie::Property::TrRotation:
+        return true;
+    default:
+        return false;
     }
 }
-static
-bool fillProp(rlottie::Property prop)
+static bool fillProp(rlottie::Property prop)
 {
     switch (prop) {
-        case rlottie::Property::FillColor:
-        case rlottie::Property::FillOpacity:
-            return true;
-        default:
-            return false;
+    case rlottie::Property::FillColor:
+    case rlottie::Property::FillOpacity:
+        return true;
+    default:
+        return false;
     }
 }
 
-static
-bool strokeProp(rlottie::Property prop)
+static bool strokeProp(rlottie::Property prop)
 {
     switch (prop) {
-        case rlottie::Property::StrokeColor:
-        case rlottie::Property::StrokeOpacity:
-        case rlottie::Property::StrokeWidth:
-            return true;
-        default:
-            return false;
+    case rlottie::Property::StrokeColor:
+    case rlottie::Property::StrokeOpacity:
+    case rlottie::Property::StrokeWidth:
+        return true;
+    default:
+        return false;
     }
 }
 
@@ -87,8 +84,8 @@ void LOTCompItem::setValue(const std::string &keypath, LOTVariant &value)
     mRootLayer->resolveKeyPath(key, 0, value);
 }
 
-std::unique_ptr<LOTLayerItem>
-LOTCompItem::createLayerItem(LOTLayerData *layerData)
+std::unique_ptr<LOTLayerItem> LOTCompItem::createLayerItem(
+    LOTLayerData *layerData)
 {
     switch (layerData->mLayerType) {
     case LayerType::Precomp: {
@@ -157,17 +154,16 @@ void LOTCompItem::buildRenderTree()
     mRootLayer->buildLayerNode();
 }
 
-const LOTLayerNode * LOTCompItem::renderTree() const
+const LOTLayerNode *LOTCompItem::renderTree() const
 {
     return mRootLayer->layerNode();
 }
 
 bool LOTCompItem::render(const rlottie::Surface &surface)
 {
-    VBitmap bitmap(reinterpret_cast<uchar *>(surface.buffer()),
-                   surface.width(), surface.height(),
-                   surface.bytesPerLine(), VBitmap::Format::ARGB32_Premultiplied);
-
+    VBitmap bitmap(reinterpret_cast<uchar *>(surface.buffer()), surface.width(),
+                   surface.height(), surface.bytesPerLine(),
+                   VBitmap::Format::ARGB32_Premultiplied);
 
     /* schedule all preprocess task for this frame at once.
      */
@@ -180,14 +176,15 @@ bool LOTCompItem::render(const rlottie::Surface &surface)
 
     VPainter painter(&bitmap);
     // set sub surface area for drawing.
-    painter.setDrawRegion(VRect(surface.drawRegionPosX(), surface.drawRegionPosY(),
-                          surface.drawRegionWidth(), surface.drawRegionHeight()));
+    painter.setDrawRegion(
+        VRect(surface.drawRegionPosX(), surface.drawRegionPosY(),
+              surface.drawRegionWidth(), surface.drawRegionHeight()));
     mRootLayer->render(&painter, {}, {});
 
     return true;
 }
 
-void LOTMaskItem::update(int frameNo, const VMatrix &parentMatrix,
+void LOTMaskItem::update(int frameNo, const VMatrix &            parentMatrix,
                          float /*parentAlpha*/, const DirtyFlag &flag)
 {
     if (flag.testFlag(DirtyFlagBit::None) && mData->isStatic()) return;
@@ -239,8 +236,7 @@ void LOTLayerItem::buildLayerNode()
         mLayerCNode->mClipPath.elmCount = 0;
         mLayerCNode->name = name().c_str();
     }
-    if (complexContent())
-       mLayerCNode->mAlpha = combinedAlpha() * 255;
+    if (complexContent()) mLayerCNode->mAlpha = combinedAlpha() * 255;
     mLayerCNode->mVisible = visible();
     // update matte
     if (hasMatte()) {
@@ -267,7 +263,7 @@ void LOTLayerItem::buildLayerNode()
         mMasksCNode.resize(mLayerMask->mMasks.size());
         size_t i = 0;
         for (const auto &mask : mLayerMask->mMasks) {
-            LOTMask *cNode = &mMasksCNode[i++];
+            LOTMask *                          cNode = &mMasksCNode[i++];
             const std::vector<VPath::Element> &elm = mask.mFinalPath.elements();
             const std::vector<VPointF> &       pts = mask.mFinalPath.points();
             const float *ptPtr = reinterpret_cast<const float *>(pts.data());
@@ -300,7 +296,8 @@ void LOTLayerItem::buildLayerNode()
     }
 }
 
-void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, const VRle &matteRle)
+void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask,
+                          const VRle &matteRle)
 {
     mDrawableList.clear();
     renderList(mDrawableList);
@@ -308,11 +305,9 @@ void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, const VRle
     VRle mask;
     if (mLayerMask) {
         mask = mLayerMask->maskRle(painter->clipBoundingRect());
-        if (!inheritMask.empty())
-            mask = mask & inheritMask;
+        if (!inheritMask.empty()) mask = mask & inheritMask;
         // if resulting mask is empty then return.
-        if (mask.empty())
-            return;
+        if (mask.empty()) return;
     } else {
         mask = inheritMask;
     }
@@ -354,7 +349,8 @@ LOTLayerMaskItem::LOTLayerMaskItem(LOTLayerData *layerData)
     }
 }
 
-void LOTLayerMaskItem::update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag)
+void LOTLayerMaskItem::update(int frameNo, const VMatrix &parentMatrix,
+                              float parentAlpha, const DirtyFlag &flag)
 {
     if (flag.testFlag(DirtyFlagBit::None) && isStatic()) return;
 
@@ -376,14 +372,12 @@ VRle LOTLayerMaskItem::maskRle(const VRect &clipRect)
             break;
         }
         case LOTMaskData::Mode::Substarct: {
-            if (rle.empty() && !clipRect.empty())
-                rle = VRle::toRle(clipRect);
+            if (rle.empty() && !clipRect.empty()) rle = VRle::toRle(clipRect);
             rle = rle - i.rle();
             break;
         }
         case LOTMaskData::Mode::Intersect: {
-            if (rle.empty() && !clipRect.empty())
-                rle = VRle::toRle(clipRect);
+            if (rle.empty() && !clipRect.empty()) rle = VRle::toRle(clipRect);
             rle = rle & i.rle();
             break;
         }
@@ -405,8 +399,7 @@ VRle LOTLayerMaskItem::maskRle(const VRect &clipRect)
     return mRle;
 }
 
-
-LOTLayerItem::LOTLayerItem(LOTLayerData *layerData): mLayerData(layerData)
+LOTLayerItem::LOTLayerItem(LOTLayerData *layerData) : mLayerData(layerData)
 {
     if (mLayerData->mHasMask)
         mLayerMask = std::make_unique<LOTLayerMaskItem>(mLayerData);
@@ -416,14 +409,14 @@ bool LOTLayerItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
                                   LOTVariant &value)
 {
     if (!keyPath.matches(name(), depth)) {
-      return false;
+        return false;
     }
 
     if (!keyPath.skip(name())) {
-      if (keyPath.fullyResolvesTo(name(), depth) &&
-          transformProp(value.property())) {
-          //@TODO handle propery update.
-      }
+        if (keyPath.fullyResolvesTo(name(), depth) &&
+            transformProp(value.property())) {
+            //@TODO handle propery update.
+        }
     }
     return true;
 }
@@ -431,7 +424,7 @@ bool LOTLayerItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
 bool LOTShapeLayerItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
                                        LOTVariant &value)
 {
-    if (LOTLayerItem::resolveKeyPath(keyPath, depth, value)){
+    if (LOTLayerItem::resolveKeyPath(keyPath, depth, value)) {
         if (keyPath.propagate(name(), depth)) {
             uint newDepth = keyPath.nextDepth(name(), depth);
             mRoot->resolveKeyPath(keyPath, newDepth, value);
@@ -448,7 +441,7 @@ bool LOTCompLayerItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
         if (keyPath.propagate(name(), depth)) {
             uint newDepth = keyPath.nextDepth(name(), depth);
             for (const auto &layer : mLayers) {
-                layer->resolveKeyPath( keyPath, newDepth, value);
+                layer->resolveKeyPath(keyPath, newDepth, value);
             }
         }
         return true;
@@ -473,7 +466,6 @@ void LOTLayerItem::update(int frameNumber, const VMatrix &parentMatrix,
     VMatrix m = matrix(frameNo());
     m *= parentMatrix;
 
-
     // 3. update the dirty flag based on the change
     if (!mCombinedMatrix.fuzzyCompare(m)) {
         mDirtyFlag |= DirtyFlagBit::Matrix;
@@ -490,9 +482,9 @@ void LOTLayerItem::update(int frameNumber, const VMatrix &parentMatrix,
     }
 
     // 5. if no parent property change and layer is static then nothing to do.
-    if (!mLayerData->precompLayer() &&
-        flag().testFlag(DirtyFlagBit::None) &&
-        isStatic()) return;
+    if (!mLayerData->precompLayer() && flag().testFlag(DirtyFlagBit::None) &&
+        isStatic())
+        return;
 
     // 6. update the content of the layer
     updateContent();
@@ -503,9 +495,9 @@ void LOTLayerItem::update(int frameNumber, const VMatrix &parentMatrix,
 
 VMatrix LOTLayerItem::matrix(int frameNo) const
 {
-    return mParentLayer ?
-               (mLayerData->matrix(frameNo) * mParentLayer->matrix(frameNo)) :
-                mLayerData->matrix(frameNo);
+    return mParentLayer
+               ? (mLayerData->matrix(frameNo) * mParentLayer->matrix(frameNo))
+               : mLayerData->matrix(frameNo);
 }
 
 bool LOTLayerItem::visible() const
@@ -519,11 +511,11 @@ bool LOTLayerItem::visible() const
 
 LOTCompLayerItem::LOTCompLayerItem(LOTLayerData *layerModel)
     : LOTLayerItem(layerModel)
-{   
+{
     // 1. create layer item
     for (auto &i : mLayerData->mChildren) {
         LOTLayerData *layerModel = static_cast<LOTLayerData *>(i.get());
-        auto layerItem = LOTCompItem::createLayerItem(layerModel);
+        auto          layerItem = LOTCompItem::createLayerItem(layerModel);
         if (layerItem) mLayers.push_back(std::move(layerItem));
     }
 
@@ -531,8 +523,9 @@ 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 auto &val) { return val->id() == id; });
             if (search != mLayers.end()) layer->setParentLayer((*search).get());
         }
     }
@@ -576,7 +569,8 @@ void LOTCompLayerItem::buildLayerNode()
     }
 }
 
-void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, const VRle &matteRle)
+void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask,
+                              const VRle &matteRle)
 {
     if (vIsZero(combinedAlpha())) return;
 
@@ -584,9 +578,10 @@ void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, const
         renderHelper(painter, inheritMask, matteRle);
     } else {
         if (complexContent()) {
-            VSize size = painter->clipBoundingRect().size();
+            VSize    size = painter->clipBoundingRect().size();
             VPainter srcPainter;
-            VBitmap srcBitmap(size.width(), size.height(), VBitmap::Format::ARGB32_Premultiplied);
+            VBitmap  srcBitmap(size.width(), size.height(),
+                              VBitmap::Format::ARGB32_Premultiplied);
             srcPainter.begin(&srcBitmap);
             renderHelper(&srcPainter, inheritMask, matteRle);
             srcPainter.end();
@@ -597,16 +592,15 @@ void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, const
     }
 }
 
-void LOTCompLayerItem::renderHelper(VPainter *painter, const VRle &inheritMask, const VRle &matteRle)
+void LOTCompLayerItem::renderHelper(VPainter *painter, const VRle &inheritMask,
+                                    const VRle &matteRle)
 {
     VRle mask;
     if (mLayerMask) {
         mask = mLayerMask->maskRle(painter->clipBoundingRect());
-        if (!inheritMask.empty())
-            mask = mask & inheritMask;
+        if (!inheritMask.empty()) mask = mask & inheritMask;
         // if resulting mask is empty then return.
-        if (mask.empty())
-            return;
+        if (mask.empty()) return;
     } else {
         mask = inheritMask;
     }
@@ -627,7 +621,8 @@ void LOTCompLayerItem::renderHelper(VPainter *painter, const VRle &inheritMask,
             if (layer->visible()) {
                 if (matte) {
                     if (matte->visible())
-                        renderMatteLayer(painter, mask, matteRle, matte, layer.get());
+                        renderMatteLayer(painter, mask, matteRle, matte,
+                                         layer.get());
                 } else {
                     layer->render(painter, mask, matteRle);
                 }
@@ -637,24 +632,24 @@ void LOTCompLayerItem::renderHelper(VPainter *painter, const VRle &inheritMask,
     }
 }
 
-void LOTCompLayerItem::renderMatteLayer(VPainter *painter,
-                                        const VRle &mask,
-                                        const VRle &matteRle,
-                                        LOTLayerItem *layer,
-                                        LOTLayerItem *src)
+void LOTCompLayerItem::renderMatteLayer(VPainter *painter, const VRle &mask,
+                                        const VRle &  matteRle,
+                                        LOTLayerItem *layer, LOTLayerItem *src)
 {
     VSize size = painter->clipBoundingRect().size();
     // Decide if we can use fast matte.
     // 1. draw src layer to matte buffer
     VPainter srcPainter;
-    src->bitmap().reset(size.width(), size.height(), VBitmap::Format::ARGB32_Premultiplied);
+    src->bitmap().reset(size.width(), size.height(),
+                        VBitmap::Format::ARGB32_Premultiplied);
     srcPainter.begin(&src->bitmap());
     src->render(&srcPainter, mask, matteRle);
     srcPainter.end();
 
     // 2. draw layer to layer buffer
     VPainter layerPainter;
-    layer->bitmap().reset(size.width(), size.height(), VBitmap::Format::ARGB32_Premultiplied);
+    layer->bitmap().reset(size.width(), size.height(),
+                          VBitmap::Format::ARGB32_Premultiplied);
     layerPainter.begin(&layer->bitmap());
     layer->render(&layerPainter, mask, matteRle);
 
@@ -662,19 +657,21 @@ void LOTCompLayerItem::renderMatteLayer(VPainter *painter,
     switch (layer->matteType()) {
     case MatteType::Alpha:
     case MatteType::Luma: {
-        layerPainter.setCompositionMode(VPainter::CompositionMode::CompModeDestIn);
+        layerPainter.setCompositionMode(
+            VPainter::CompositionMode::CompModeDestIn);
         break;
     }
     case MatteType::AlphaInv:
     case MatteType::LumaInv: {
-        layerPainter.setCompositionMode(VPainter::CompositionMode::CompModeDestOut);
+        layerPainter.setCompositionMode(
+            VPainter::CompositionMode::CompModeDestOut);
         break;
     }
     default:
         break;
     }
 
-    //2.2 update srcBuffer if the matte is luma type
+    // 2.2 update srcBuffer if the matte is luma type
     if (layer->matteType() == MatteType::Luma ||
         layer->matteType() == MatteType::LumaInv) {
         src->bitmap().updateLuma();
@@ -690,7 +687,7 @@ void LOTCompLayerItem::renderMatteLayer(VPainter *painter,
 void LOTClipperItem::update(const VMatrix &matrix)
 {
     mPath.reset();
-    mPath.addRect(VRectF(0,0, mSize.width(), mSize.height()));
+    mPath.addRect(VRectF(0, 0, mSize.width(), mSize.height()));
     mPath.transform(matrix);
     mRasterizer.rasterize(mPath);
 }
@@ -705,11 +702,11 @@ void LOTCompLayerItem::updateContent()
     if (mClipper && flag().testFlag(DirtyFlagBit::Matrix)) {
         mClipper->update(combinedMatrix());
     }
-    int mappedFrame = mLayerData->timeRemap(frameNo());
+    int   mappedFrame = mLayerData->timeRemap(frameNo());
     float alpha = combinedAlpha();
     if (complexContent()) alpha = 1;
     for (const auto &layer : mLayers) {
-        layer->update( mappedFrame, combinedMatrix(), alpha);
+        layer->update(mappedFrame, combinedMatrix(), alpha);
     }
 }
 
@@ -739,7 +736,8 @@ void LOTCompLayerItem::renderList(std::vector<VDrawable *> &list)
 
 LOTSolidLayerItem::LOTSolidLayerItem(LOTLayerData *layerData)
     : LOTLayerItem(layerData)
-{}
+{
+}
 
 void LOTSolidLayerItem::updateContent()
 {
@@ -794,8 +792,8 @@ void LOTImageLayerItem::updateContent()
 {
     if (flag() & DirtyFlagBit::Matrix) {
         VPath path;
-        path.addRect(
-            VRectF(0, 0, mLayerData->mAsset->mWidth, mLayerData->mAsset->mHeight));
+        path.addRect(VRectF(0, 0, mLayerData->mAsset->mWidth,
+                            mLayerData->mAsset->mHeight));
         path.transform(combinedMatrix());
         mRenderNode.mFlag |= VDrawable::DirtyState::Path;
         mRenderNode.mPath = path;
@@ -826,9 +824,12 @@ void LOTImageLayerItem::buildLayerNode()
         LOTDrawable *lotDrawable = static_cast<LOTDrawable *>(i);
         lotDrawable->sync();
 
-        lotDrawable->mCNode->mImageInfo.data = lotDrawable->mBrush.mTexture.data();
-        lotDrawable->mCNode->mImageInfo.width = lotDrawable->mBrush.mTexture.width();
-        lotDrawable->mCNode->mImageInfo.height = lotDrawable->mBrush.mTexture.height();
+        lotDrawable->mCNode->mImageInfo.data =
+            lotDrawable->mBrush.mTexture.data();
+        lotDrawable->mCNode->mImageInfo.width =
+            lotDrawable->mBrush.mTexture.width();
+        lotDrawable->mCNode->mImageInfo.height =
+            lotDrawable->mBrush.mTexture.height();
 
         lotDrawable->mCNode->mImageInfo.mMatrix.m11 = combinedMatrix().m_11();
         lotDrawable->mCNode->mImageInfo.mMatrix.m12 = combinedMatrix().m_12();
@@ -869,8 +870,8 @@ LOTShapeLayerItem::LOTShapeLayerItem(LOTLayerData *layerData)
     }
 }
 
-std::unique_ptr<LOTContentItem>
-LOTShapeLayerItem::createContentItem(LOTData *contentData)
+std::unique_ptr<LOTContentItem> LOTShapeLayerItem::createContentItem(
+    LOTData *contentData)
 {
     switch (contentData->type()) {
     case LOTData::Type::ShapeGroup: {
@@ -878,34 +879,44 @@ LOTShapeLayerItem::createContentItem(LOTData *contentData)
             static_cast<LOTGroupData *>(contentData));
     }
     case LOTData::Type::Rect: {
-        return std::make_unique<LOTRectItem>(static_cast<LOTRectData *>(contentData));
+        return std::make_unique<LOTRectItem>(
+            static_cast<LOTRectData *>(contentData));
     }
     case LOTData::Type::Ellipse: {
-        return std::make_unique<LOTEllipseItem>(static_cast<LOTEllipseData *>(contentData));
+        return std::make_unique<LOTEllipseItem>(
+            static_cast<LOTEllipseData *>(contentData));
     }
     case LOTData::Type::Shape: {
-        return std::make_unique<LOTShapeItem>(static_cast<LOTShapeData *>(contentData));
+        return std::make_unique<LOTShapeItem>(
+            static_cast<LOTShapeData *>(contentData));
     }
     case LOTData::Type::Polystar: {
-        return std::make_unique<LOTPolystarItem>(static_cast<LOTPolystarData *>(contentData));
+        return std::make_unique<LOTPolystarItem>(
+            static_cast<LOTPolystarData *>(contentData));
     }
     case LOTData::Type::Fill: {
-        return std::make_unique<LOTFillItem>(static_cast<LOTFillData *>(contentData));
+        return std::make_unique<LOTFillItem>(
+            static_cast<LOTFillData *>(contentData));
     }
     case LOTData::Type::GFill: {
-        return std::make_unique<LOTGFillItem>(static_cast<LOTGFillData *>(contentData));
+        return std::make_unique<LOTGFillItem>(
+            static_cast<LOTGFillData *>(contentData));
     }
     case LOTData::Type::Stroke: {
-        return std::make_unique<LOTStrokeItem>(static_cast<LOTStrokeData *>(contentData));
+        return std::make_unique<LOTStrokeItem>(
+            static_cast<LOTStrokeData *>(contentData));
     }
     case LOTData::Type::GStroke: {
-        return std::make_unique<LOTGStrokeItem>(static_cast<LOTGStrokeData *>(contentData));
+        return std::make_unique<LOTGStrokeItem>(
+            static_cast<LOTGStrokeData *>(contentData));
     }
     case LOTData::Type::Repeater: {
-        return std::make_unique<LOTRepeaterItem>(static_cast<LOTRepeaterData *>(contentData));
+        return std::make_unique<LOTRepeaterItem>(
+            static_cast<LOTRepeaterData *>(contentData));
     }
     case LOTData::Type::Trim: {
-        return std::make_unique<LOTTrimItem>(static_cast<LOTTrimData *>(contentData));
+        return std::make_unique<LOTTrimItem>(
+            static_cast<LOTTrimData *>(contentData));
     }
     default:
         return nullptr;
@@ -945,32 +956,34 @@ void LOTShapeLayerItem::renderList(std::vector<VDrawable *> &list)
     mRoot->renderList(list);
 }
 
-bool LOTContentGroupItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value)
+bool LOTContentGroupItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
+                                         LOTVariant &value)
 {
     if (!keyPath.matches(name(), depth)) {
-      return false;
+        return false;
     }
 
     if (!keyPath.skip(name())) {
-      if (keyPath.fullyResolvesTo(name(), depth) &&
-          transformProp(value.property())) {
-          //@TODO handle property update
-      }
+        if (keyPath.fullyResolvesTo(name(), depth) &&
+            transformProp(value.property())) {
+            //@TODO handle property update
+        }
     }
 
     if (keyPath.propagate(name(), depth)) {
         uint newDepth = keyPath.nextDepth(name(), depth);
         for (auto &child : mContents) {
-            child->resolveKeyPath( keyPath, newDepth, value);
+            child->resolveKeyPath(keyPath, newDepth, value);
         }
     }
     return true;
 }
 
-bool LOTFillItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value)
+bool LOTFillItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
+                                 LOTVariant &value)
 {
     if (!keyPath.matches(mModel.name(), depth)) {
-      return false;
+        return false;
     }
 
     if (keyPath.fullyResolvesTo(mModel.name(), depth) &&
@@ -981,10 +994,11 @@ bool LOTFillItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &va
     return false;
 }
 
-bool LOTStrokeItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value)
+bool LOTStrokeItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
+                                   LOTVariant &value)
 {
     if (!keyPath.matches(mModel.name(), depth)) {
-      return false;
+        return false;
     }
 
     if (keyPath.fullyResolvesTo(mModel.name(), depth) &&
@@ -995,9 +1009,8 @@ bool LOTStrokeItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &
     return false;
 }
 
-LOTContentGroupItem::LOTContentGroupItem(LOTGroupData *data) :
-    LOTContentItem(ContentType::Group),
-    mData(data)
+LOTContentGroupItem::LOTContentGroupItem(LOTGroupData *data)
+    : LOTContentItem(ContentType::Group), mData(data)
 {
     addChildren(mData);
 }
@@ -1085,11 +1098,13 @@ void LOTContentGroupItem::processPaintItems(
             break;
         }
         case ContentType::Paint: {
-            static_cast<LOTPaintDataItem *>(content)->addPathItems(list, curOpCount);
+            static_cast<LOTPaintDataItem *>(content)->addPathItems(list,
+                                                                   curOpCount);
             break;
         }
         case ContentType::Group: {
-            static_cast<LOTContentGroupItem *>(content)->processPaintItems(list);
+            static_cast<LOTContentGroupItem *>(content)->processPaintItems(
+                list);
             break;
         }
         default:
@@ -1098,8 +1113,7 @@ void LOTContentGroupItem::processPaintItems(
     }
 }
 
-void LOTContentGroupItem::processTrimItems(
-    std::vector<LOTPathDataItem *> &list)
+void LOTContentGroupItem::processTrimItems(std::vector<LOTPathDataItem *> &list)
 {
     int curOpCount = list.size();
     for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
@@ -1131,13 +1145,13 @@ void LOTContentGroupItem::processTrimItems(
  * mTemp - keeps a referece to the mLocalPath and can be updated by the
  *          path operation objects(trim, merge path),
  *  mFinalPath - it takes a deep copy of the intermediate path(mTemp) each time
- *  when the path is dirty(so if path changes every frame we don't realloc just copy to the
- *  final path).
- * NOTE: As path objects are COW objects we have to be carefull about the refcount so that
- * we don't generate deep copy while modifying the path objects.
+ *  when the path is dirty(so if path changes every frame we don't realloc just
+ * copy to the final path). NOTE: As path objects are COW objects we have to be
+ * carefull about the refcount so that we don't generate deep copy while
+ * modifying the path objects.
  */
-void LOTPathDataItem::update(int frameNo, const VMatrix &,
-                             float, const DirtyFlag &flag)
+void LOTPathDataItem::update(int              frameNo, const VMatrix &, float,
+                             const DirtyFlag &flag)
 {
     mPathChanged = false;
 
@@ -1162,11 +1176,12 @@ void LOTPathDataItem::update(int frameNo, const VMatrix &,
     }
 }
 
-const VPath & LOTPathDataItem::finalPath()
+const VPath &LOTPathDataItem::finalPath()
 {
     if (mPathChanged || mNeedUpdate) {
         mFinalPath.clone(mTemp);
-        mFinalPath.transform(static_cast<LOTContentGroupItem *>(parent())->matrix());
+        mFinalPath.transform(
+            static_cast<LOTContentGroupItem *>(parent())->matrix());
         mNeedUpdate = false;
     }
     return mFinalPath;
@@ -1176,7 +1191,7 @@ LOTRectItem::LOTRectItem(LOTRectData *data)
 {
 }
 
-void LOTRectItem::updatePath(VPathpath, int frameNo)
+void LOTRectItem::updatePath(VPath &path, int frameNo)
 {
     VPointF pos = mData->mPos.value(frameNo);
     VPointF size = mData->mSize.value(frameNo);
@@ -1193,7 +1208,7 @@ LOTEllipseItem::LOTEllipseItem(LOTEllipseData *data)
 {
 }
 
-void LOTEllipseItem::updatePath(VPathpath, int frameNo)
+void LOTEllipseItem::updatePath(VPath &path, int frameNo)
 {
     VPointF pos = mData->mPos.value(frameNo);
     VPointF size = mData->mSize.value(frameNo);
@@ -1209,7 +1224,7 @@ LOTShapeItem::LOTShapeItem(LOTShapeData *data)
 {
 }
 
-void LOTShapeItem::updatePath(VPathpath, int frameNo)
+void LOTShapeItem::updatePath(VPath &path, int frameNo)
 {
     mData->mShape.value(frameNo).toPath(path);
 }
@@ -1219,7 +1234,7 @@ LOTPolystarItem::LOTPolystarItem(LOTPolystarData *data)
 {
 }
 
-void LOTPolystarItem::updatePath(VPathpath, int frameNo)
+void LOTPolystarItem::updatePath(VPath &path, int frameNo)
 {
     VPointF pos = mData->mPos.value(frameNo);
     float   points = mData->mPointCount.value(frameNo);
@@ -1249,11 +1264,12 @@ void LOTPolystarItem::updatePath(VPath& path, int frameNo)
  * PaintData Node handling
  *
  */
-LOTPaintDataItem::LOTPaintDataItem(bool staticContent):
-    LOTContentItem(ContentType::Paint),
-    mStaticContent(staticContent){}
+LOTPaintDataItem::LOTPaintDataItem(bool staticContent)
+    : LOTContentItem(ContentType::Paint), mStaticContent(staticContent)
+{
+}
 
-void LOTPaintDataItem::update(int frameNo, const VMatrix &/*parentMatrix*/,
+void LOTPaintDataItem::update(int   frameNo, const VMatrix & /*parentMatrix*/,
                               float parentAlpha, const DirtyFlag &flag)
 {
     mRenderNodeUpdate = true;
@@ -1297,13 +1313,13 @@ void LOTPaintDataItem::renderList(std::vector<VDrawable *> &list)
     list.push_back(&mDrawable);
 }
 
-
-void LOTPaintDataItem::addPathItems(std::vector<LOTPathDataItem *> &list, int startOffset)
+void LOTPaintDataItem::addPathItems(std::vector<LOTPathDataItem *> &list,
+                                    int                             startOffset)
 {
-    std::copy(list.begin() + startOffset, list.end(), back_inserter(mPathItems));
+    std::copy(list.begin() + startOffset, list.end(),
+              back_inserter(mPathItems));
 }
 
-
 LOTFillItem::LOTFillItem(LOTFillData *data)
     : LOTPaintDataItem(data->isStatic()), mModel(data)
 {
@@ -1378,15 +1394,15 @@ void LOTStrokeItem::updateRenderNode()
     color.setAlpha(color.a * parentAlpha());
     VBrush brush(color);
     mDrawable.setBrush(brush);
-    float scale = getScale(static_cast<LOTContentGroupItem *>(parent())->matrix());
-    mDrawable.setStrokeInfo(mModel.capStyle(), mModel.joinStyle(), mModel.meterLimit(),
-                            mWidth * scale);
+    float scale =
+        getScale(static_cast<LOTContentGroupItem *>(parent())->matrix());
+    mDrawable.setStrokeInfo(mModel.capStyle(), mModel.joinStyle(),
+                            mModel.meterLimit(), mWidth * scale);
     if (mDashArraySize) {
-        for (int i = 0 ; i < mDashArraySize ; i++)
-            mDashArray[i] *= scale;
+        for (int i = 0; i < mDashArraySize; i++) mDashArray[i] *= scale;
 
         /* AE draw the dash even if dash value is 0 */
-        if (vCompare(mDashArray[0], 0.0f)) mDashArray[0]= 0.1;
+        if (vCompare(mDashArray[0], 0.0f)) mDashArray[0] = 0.1;
 
         mDrawable.setDashInfo(mDashArray, mDashArraySize);
     }
@@ -1417,21 +1433,20 @@ void LOTGStrokeItem::updateRenderNode()
     float scale = getScale(mGradient->mMatrix);
     mGradient->setAlpha(mAlpha * parentAlpha());
     mDrawable.setBrush(VBrush(mGradient.get()));
-    mDrawable.setStrokeInfo(mCap, mJoin, mMiterLimit,
-                            mWidth * scale);
+    mDrawable.setStrokeInfo(mCap, mJoin, mMiterLimit, mWidth * scale);
     if (mDashArraySize) {
-        for (int i = 0 ; i < mDashArraySize ; i++)
-            mDashArray[i] *= scale;
+        for (int i = 0; i < mDashArraySize; i++) mDashArray[i] *= scale;
         mDrawable.setDashInfo(mDashArray, mDashArraySize);
     }
 }
 
-LOTTrimItem::LOTTrimItem(LOTTrimData *data):
-    LOTContentItem(ContentType::Trim),
-    mData(data) {}
+LOTTrimItem::LOTTrimItem(LOTTrimData *data)
+    : LOTContentItem(ContentType::Trim), mData(data)
+{
+}
 
-void LOTTrimItem::update(int frameNo, const VMatrix &/*parentMatrix*/,
-                         float /*parentAlpha*/, const DirtyFlag &/*flag*/)
+void LOTTrimItem::update(int frameNo, const VMatrix & /*parentMatrix*/,
+                         float /*parentAlpha*/, const DirtyFlag & /*flag*/)
 {
     mDirty = false;
 
@@ -1459,7 +1474,7 @@ void LOTTrimItem::update()
         return;
     }
 
-    if (vCompare(std::fabs(mCache.mSegment.start - mCache.mSegment.end) , 1)) {
+    if (vCompare(std::fabs(mCache.mSegment.start - mCache.mSegment.end), 1)) {
         for (auto &i : mPathItems) {
             i->updatePath(i->localPath());
         }
@@ -1473,15 +1488,15 @@ void LOTTrimItem::update()
             pm.setEnd(mCache.mSegment.end);
             i->updatePath(pm.trim(i->localPath()));
         }
-    } else { // LOTTrimData::TrimType::Individually
+    } else {  // LOTTrimData::TrimType::Individually
         float totalLength = 0.0;
         for (auto &i : mPathItems) {
             totalLength += i->localPath().length();
         }
         float start = totalLength * mCache.mSegment.start;
-        float end  = totalLength * mCache.mSegment.end;
+        float end = totalLength * mCache.mSegment.end;
 
-        if (start < end ) {
+        if (start < end) {
             float curLen = 0.0;
             for (auto &i : mPathItems) {
                 if (curLen > end) {
@@ -1491,7 +1506,7 @@ void LOTTrimItem::update()
                 }
                 float len = i->localPath().length();
 
-                if (curLen < start  && curLen + len < start) {
+                if (curLen < start && curLen + len < start) {
                     curLen += len;
                     // update with empty path.
                     i->updatePath(VPath());
@@ -1515,36 +1530,36 @@ void LOTTrimItem::update()
             }
         }
     }
-
 }
 
-
-void LOTTrimItem::addPathItems(std::vector<LOTPathDataItem *> &list, int startOffset)
+void LOTTrimItem::addPathItems(std::vector<LOTPathDataItem *> &list,
+                               int                             startOffset)
 {
-    std::copy(list.begin() + startOffset, list.end(), back_inserter(mPathItems));
+    std::copy(list.begin() + startOffset, list.end(),
+              back_inserter(mPathItems));
 }
 
-
 LOTRepeaterItem::LOTRepeaterItem(LOTRepeaterData *data) : mRepeaterData(data)
 {
     assert(mRepeaterData->content());
 
     mCopies = mRepeaterData->maxCopies();
 
-    for (int i= 0; i < mCopies; i++) {
-        auto content = std::make_unique<LOTContentGroupItem>(mRepeaterData->content());
+    for (int i = 0; i < mCopies; i++) {
+        auto content =
+            std::make_unique<LOTContentGroupItem>(mRepeaterData->content());
         content->setParent(this);
         mContents.push_back(std::move(content));
     }
 }
 
-void LOTRepeaterItem::update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag)
+void LOTRepeaterItem::update(int frameNo, const VMatrix &parentMatrix,
+                             float parentAlpha, const DirtyFlag &flag)
 {
-
     DirtyFlag newFlag = flag;
 
     float copies = mRepeaterData->copies(frameNo);
-    int visibleCopies = int(copies);
+    int   visibleCopies = int(copies);
 
     if (visibleCopies == 0) {
         mHidden = true;
@@ -1562,12 +1577,14 @@ void LOTRepeaterItem::update(int frameNo, const VMatrix &parentMatrix, float par
     newFlag |= DirtyFlagBit::Alpha;
 
     for (int i = 0; i < mCopies; ++i) {
-        float newAlpha = parentAlpha * lerp(startOpacity, endOpacity, i / copies);
+        float newAlpha =
+            parentAlpha * lerp(startOpacity, endOpacity, i / copies);
 
         // hide rest of the copies , @TODO find a better solution.
-        if ( i >= visibleCopies) newAlpha = 0;
+        if (i >= visibleCopies) newAlpha = 0;
 
-        VMatrix result = mRepeaterData->mTransform.matrix(frameNo, i + offset) * parentMatrix;
+        VMatrix result = mRepeaterData->mTransform.matrix(frameNo, i + offset) *
+                         parentMatrix;
         mContents[i]->update(frameNo, result, newAlpha, newFlag);
     }
 }
@@ -1581,10 +1598,10 @@ void LOTRepeaterItem::renderList(std::vector<VDrawable *> &list)
 static void updateGStops(LOTNode *n, const VGradient *grad)
 {
     if (grad->mStops.size() != n->mGradient.stopCount) {
-        if (n->mGradient.stopCount)
-            free(n->mGradient.stopPtr);
+        if (n->mGradient.stopCount) free(n->mGradient.stopPtr);
         n->mGradient.stopCount = grad->mStops.size();
-        n->mGradient.stopPtr = (LOTGradientStop *) malloc(n->mGradient.stopCount * sizeof(LOTGradientStop));
+        n->mGradient.stopPtr = (LOTGradientStop *)malloc(
+            n->mGradient.stopCount * sizeof(LOTGradientStop));
     }
 
     LOTGradientStop *ptr = n->mGradient.stopPtr;
@@ -1596,7 +1613,6 @@ static void updateGStops(LOTNode *n, const VGradient *grad)
         ptr->b = i.second.blue();
         ptr++;
     }
-
 }
 
 void LOTDrawable::sync()
@@ -1681,10 +1697,10 @@ void LOTDrawable::sync()
     case VBrush::Type::LinearGradient: {
         mCNode->mBrushType = LOTBrushType::BrushGradient;
         mCNode->mGradient.type = LOTGradientType::GradientLinear;
-        VPointF s = mBrush.mGradient->mMatrix.map({mBrush.mGradient->linear.x1,
-                                                   mBrush.mGradient->linear.y1});
-        VPointF e = mBrush.mGradient->mMatrix.map({mBrush.mGradient->linear.x2,
-                                                   mBrush.mGradient->linear.y2});
+        VPointF s = mBrush.mGradient->mMatrix.map(
+            {mBrush.mGradient->linear.x1, mBrush.mGradient->linear.y1});
+        VPointF e = mBrush.mGradient->mMatrix.map(
+            {mBrush.mGradient->linear.x2, mBrush.mGradient->linear.y2});
         mCNode->mGradient.start.x = s.x();
         mCNode->mGradient.start.y = s.y();
         mCNode->mGradient.end.x = e.x();
@@ -1695,10 +1711,10 @@ void LOTDrawable::sync()
     case VBrush::Type::RadialGradient: {
         mCNode->mBrushType = LOTBrushType::BrushGradient;
         mCNode->mGradient.type = LOTGradientType::GradientRadial;
-        VPointF c = mBrush.mGradient->mMatrix.map({mBrush.mGradient->radial.cx,
-                                                   mBrush.mGradient->radial.cy});
-        VPointF f = mBrush.mGradient->mMatrix.map({mBrush.mGradient->radial.fx,
-                                                   mBrush.mGradient->radial.fy});
+        VPointF c = mBrush.mGradient->mMatrix.map(
+            {mBrush.mGradient->radial.cx, mBrush.mGradient->radial.cy});
+        VPointF f = mBrush.mGradient->mMatrix.map(
+            {mBrush.mGradient->radial.fx, mBrush.mGradient->radial.fy});
         mCNode->mGradient.center.x = c.x();
         mCNode->mGradient.center.y = c.y();
         mCNode->mGradient.focal.x = f.x();
index 95076602201243995b0e1deb276ee1dd1bbcbad9..e8b6c6aefc334d93f3a7564a3c4508aa9a18e87f 100644 (file)
@@ -4,78 +4,83 @@
 
 LOTKeyPath::LOTKeyPath(const std::string &keyPath)
 {
-    std::stringstream ss (keyPath);
-    std::string item;
+    std::stringstream ss(keyPath);
+    std::string       item;
 
-    while (getline (ss, item, '.')) {
-        mKeys.push_back (item);
+    while (getline(ss, item, '.')) {
+        mKeys.push_back(item);
     }
 }
 
 bool LOTKeyPath::matches(const std::string &key, uint depth)
 {
-  if (skip(key)) {
-    // This is an object we programatically create.
-    return true;
-  }
-  if (depth > size()) {
+    if (skip(key)) {
+        // This is an object we programatically create.
+        return true;
+    }
+    if (depth > size()) {
+        return false;
+    }
+    if ((mKeys[depth] == key) || (mKeys[depth] == "*") ||
+        (mKeys[depth] == "**")) {
+        return true;
+    }
     return false;
-  }
-  if ((mKeys[depth] == key) ||
-      (mKeys[depth] == "*") ||
-      (mKeys[depth] == "**")) {
-    return true;
-  }
-  return false;
 }
 
-uint LOTKeyPath::nextDepth(const std::string key, uint depth) {
-  if (skip(key)) {
-    // If it's a container then we added programatically and it isn't a part of the keypath.
-    return depth;
-  }
-  if ( mKeys[depth] != "**") {
-    // If it's not a globstar then it is part of the keypath.
-    return depth + 1;
-  }
-  if (depth == size()) {
-    // The last key is a globstar.
+uint LOTKeyPath::nextDepth(const std::string key, uint depth)
+{
+    if (skip(key)) {
+        // If it's a container then we added programatically and it isn't a part
+        // of the keypath.
+        return depth;
+    }
+    if (mKeys[depth] != "**") {
+        // If it's not a globstar then it is part of the keypath.
+        return depth + 1;
+    }
+    if (depth == size()) {
+        // The last key is a globstar.
+        return depth;
+    }
+    if (mKeys[depth + 1] == key) {
+        // We are a globstar and the next key is our current key so consume
+        // both.
+        return depth + 2;
+    }
     return depth;
-  }
-  if (mKeys[depth + 1] == key) {
-    // We are a globstar and the next key is our current key so consume both.
-    return depth + 2;
-  }
-  return depth;
 }
 
-bool LOTKeyPath::fullyResolvesTo(const std::string key, uint depth) {
+bool LOTKeyPath::fullyResolvesTo(const std::string key, uint depth)
+{
     if (depth > mKeys.size()) {
-      return false;
+        return false;
     }
 
     bool isLastDepth = (depth == size());
 
     if (!isGlobstar(depth)) {
-      bool matches = (mKeys[depth] == key) || isGlob(depth);
-      return (isLastDepth || (depth == size() - 1 && endsWithGlobstar())) && matches;
+        bool matches = (mKeys[depth] == key) || isGlob(depth);
+        return (isLastDepth || (depth == size() - 1 && endsWithGlobstar())) &&
+               matches;
     }
 
     bool isGlobstarButNextKeyMatches = !isLastDepth && mKeys[depth + 1] == key;
     if (isGlobstarButNextKeyMatches) {
-      return depth == size() - 1 ||
-          (depth == size() - 2 && endsWithGlobstar());
+        return depth == size() - 1 ||
+               (depth == size() - 2 && endsWithGlobstar());
     }
 
     if (isLastDepth) {
-      return true;
+        return true;
     }
 
     if (depth + 1 < size()) {
-      // We are a globstar but there is more than 1 key after the globstar we we can't fully match.
-      return false;
+        // We are a globstar but there is more than 1 key after the globstar we
+        // we can't fully match.
+        return false;
     }
-    // Return whether the next key (which we now know is the last one) is the same as the current
-    // key.
+    // Return whether the next key (which we now know is the last one) is the
+    // same as the current key.
     return mKeys[depth + 1] == key;
-  }
+}
index 34c20ac8575243bc0686cb609e6d3d0b282ee852..28b4e4b1ce42cf3c10331fbc817f92b4bf79a6d3 100644 (file)
@@ -1,27 +1,27 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "lottieloader.h"
 #include "lottieparser.h"
 
+#include <cstring>
 #include <fstream>
 #include <unordered_map>
-#include <cstring>
 using namespace std;
 
 #ifdef LOTTIE_CACHE_SUPPORT
@@ -60,23 +60,18 @@ public:
     static LottieFileCache &instance()
     {
         static LottieFileCache CACHE;
-        return CACHE;  
-    }
-    std::shared_ptr<LOTModel> find(const std::string &)
-    {
-        return nullptr;
+        return CACHE;
     }
+    std::shared_ptr<LOTModel> find(const std::string &) { return nullptr; }
     void add(const std::string &, std::shared_ptr<LOTModel>) {}
 };
 
 #endif
 
-
-
 static std::string dirname(const std::string &path)
 {
     const char *ptr = strrchr(path.c_str(), '/');
-    int len = int(ptr + 1 - path.c_str()); // +1 to include '/'
+    int         len = int(ptr + 1 - path.c_str());  // +1 to include '/'
     return std::string(path, 0, len);
 }
 
@@ -95,7 +90,8 @@ bool LottieLoader::load(const std::string &path)
         std::stringstream buf;
         buf << f.rdbuf();
 
-        LottieParser parser(const_cast<char *>(buf.str().data()), dirname(path).c_str());
+        LottieParser parser(const_cast<char *>(buf.str().data()),
+                            dirname(path).c_str());
         mModel = parser.model();
         LottieFileCache::instance().add(path, mModel);
 
@@ -105,12 +101,14 @@ bool LottieLoader::load(const std::string &path)
     return true;
 }
 
-bool LottieLoader::loadFromData(std::string &&jsonData, const std::string &key, const std::string &resourcePath)
+bool LottieLoader::loadFromData(std::string &&jsonData, const std::string &key,
+                                const std::string &resourcePath)
 {
     mModel = LottieFileCache::instance().find(key);
     if (mModel) return true;
 
-    LottieParser parser(const_cast<char *>(jsonData.c_str()), resourcePath.c_str());
+    LottieParser parser(const_cast<char *>(jsonData.c_str()),
+                        resourcePath.c_str());
     mModel = parser.model();
     LottieFileCache::instance().add(key, mModel);
 
index 221d82668f7f912efb4c0aa2531316249b2a072c..6da671ffb9ce2080c844ba356f9eb28ca16ec312 100644 (file)
@@ -1,27 +1,27 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "lottiemodel.h"
-#include "vline.h"
-#include "vimageloader.h"
 #include <cassert>
+#include <iterator>
 #include <stack>
-#include <iterator>  
+#include "vimageloader.h"
+#include "vline.h"
 
 /*
  * We process the iterator objects in the children list
  * under a new shape group object which we add it as children to the repeater
  * object.
  * Then we visit the childrens of the newly created shape group object to
- * process the remaining repeater object(when children list contains more than one
- * repeater).
+ * process the remaining repeater object(when children list contains more than
+ * one repeater).
  *
  */
 class LottieRepeaterProcesser {
 public:
-    void visitChildren(LOTGroupData *obj) {
-        for (auto i = obj->mChildren.rbegin(); i != obj->mChildren.rend(); ++i ) {
+    void visitChildren(LOTGroupData *obj)
+    {
+        for (auto i = obj->mChildren.rbegin(); i != obj->mChildren.rend();
+             ++i) {
             auto child = (*i).get();
             if (child->type() == LOTData::Type::Repeater) {
-                LOTRepeaterData *repeater = static_cast<LOTRepeaterData *>(child);
+                LOTRepeaterData *repeater =
+                    static_cast<LOTRepeaterData *>(child);
                 // check if this repeater is already processed
-                // can happen if the layer is an asset and referenced by multiple layer.
+                // can happen if the layer is an asset and referenced by
+                // multiple layer.
                 if (repeater->content()) continue;
 
                 repeater->setContent(std::make_shared<LOTShapeGroupData>());
@@ -51,28 +55,28 @@ public:
                 //   object before the repeater
                 ++i;
                 // 2. move all the children till repater to the group
-                std::move(obj->mChildren.begin(),
-                          i.base(), back_inserter(content->mChildren));
+                std::move(obj->mChildren.begin(), i.base(),
+                          back_inserter(content->mChildren));
                 // 3. erase the objects from the original children list
-                obj->mChildren.erase(obj->mChildren.begin(),
-                                     i.base());
+                obj->mChildren.erase(obj->mChildren.begin(), i.base());
 
-                // 5. visit newly created group to process remaining repeater object.
+                // 5. visit newly created group to process remaining repeater
+                // object.
                 visitChildren(content);
                 // 6. exit the loop as the current iterators are invalid
                 break;
             } else {
                 visit(child);
             }
-
         }
     }
 
-    void visit(LOTData *obj) {
+    void visit(LOTData *obj)
+    {
         switch (obj->mType) {
         case LOTData::Type::Repeater:
         case LOTData::Type::ShapeGroup:
-        case LOTData::Type::Layer:{
+        case LOTData::Type::Layer: {
             visitChildren(static_cast<LOTGroupData *>(obj));
             break;
         }
@@ -82,7 +86,6 @@ public:
     }
 };
 
-
 void LOTCompositionData::processRepeaterObjects()
 {
     LottieRepeaterProcesser visitor;
@@ -96,10 +99,10 @@ VMatrix LOTRepeaterTransform::matrix(int frameNo, float multiplier) const
     scale.setY(std::pow(scale.y(), multiplier));
     VMatrix m;
     m.translate(mPosition.value(frameNo) * multiplier)
-     .translate(mAnchor.value(frameNo))
-     .scale(scale)
-     .rotate(mRotation.value(frameNo) * multiplier)
-     .translate(-mAnchor.value(frameNo));
+        .translate(mAnchor.value(frameNo))
+        .scale(scale)
+        .rotate(mRotation.value(frameNo) * multiplier)
+        .translate(-mAnchor.value(frameNo));
 
     return m;
 }
@@ -325,7 +328,8 @@ void LOTGradient::update(std::unique_ptr<VGradient> &grad, int frameNo)
 
 void LOTAsset::loadImageData(std::string data)
 {
-    if (!data.empty()) mBitmap = VImageLoader::instance().load(data.c_str(), data.length());
+    if (!data.empty())
+        mBitmap = VImageLoader::instance().load(data.c_str(), data.length());
 }
 
 void LOTAsset::loadImagePath(std::string path)
index 1b487db8b03f1352dcf23d162bfe490b93ac496c..c51623967157705ae80cac2c21aaa9ccfe4b42d8 100644 (file)
@@ -1,24 +1,23 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "lottieparser.h"
 
-
 //#define DEBUG_PARSER
 
 //#define DEBUG_PRINT_TREE
@@ -174,8 +173,9 @@ protected:
 class LottieParserImpl : protected LookaheadParserHandler {
 public:
     LottieParserImpl(char *str, const char *dir_path)
-        :LookaheadParserHandler(str),
-         mDirPath(dir_path){}
+        : LookaheadParserHandler(str), mDirPath(dir_path)
+    {
+    }
 
 public:
     bool        EnterObject();
@@ -267,8 +267,8 @@ public:
     void resolveLayerRefs();
 
 protected:
-    std::unordered_map<std::string,
-                       std::shared_ptr<VInterpolator>> mInterpolatorCache;
+    std::unordered_map<std::string, std::shared_ptr<VInterpolator>>
+                                               mInterpolatorCache;
     std::shared_ptr<LOTCompositionData>        mComposition;
     LOTCompositionData *                       compRef{nullptr};
     LOTLayerData *                             curLayerRef{nullptr};
@@ -498,7 +498,7 @@ int LottieParserImpl::PeekType()
     return -1;
 }
 
-void LottieParserImpl::Skip(const char */*key*/)
+void LottieParserImpl::Skip(const char * /*key*/)
 {
     if (PeekType() == kArrayType) {
         EnterArray();
@@ -534,7 +534,7 @@ LottieBlendMode LottieParserImpl::getBlendMode()
 
 void LottieParserImpl::resolveLayerRefs()
 {
-    for (const autoi : mLayersToUpdate) {
+    for (const auto &i : mLayersToUpdate) {
         LOTLayerData *layer = i.get();
         auto          search = compRef->mAssets.find(layer->mPreCompRefId);
         if (search != compRef->mAssets.end()) {
@@ -542,7 +542,8 @@ void LottieParserImpl::resolveLayerRefs()
                 layer->mAsset = search->second;
             } else if (layer->mLayerType == LayerType::Precomp) {
                 layer->mChildren = search->second->mLayers;
-                layer->setStatic(layer->isStatic() && search->second->isStatic());
+                layer->setStatic(layer->isStatic() &&
+                                 search->second->isStatic());
             }
         }
     }
@@ -607,35 +608,34 @@ void LottieParserImpl::parseAssets(LOTCompositionData *composition)
     // update the precomp layers with the actual layer object
 }
 
-static constexpr const unsigned char B64index[256] = { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 62, 63, 62, 62, 63, 52, 53, 54, 55,
-56, 57, 58, 59, 60, 61,  0,  0,  0,  0,  0,  0,  0,  0,  1,  2,  3,  4,  5,  6,
-7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,  0,
-0,  0,  0, 63,  0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 };
+static constexpr const unsigned char B64index[256] = {
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  62, 63, 62, 62, 63, 52, 53, 54, 55, 56, 57,
+    58, 59, 60, 61, 0,  0,  0,  0,  0,  0,  0,  0,  1,  2,  3,  4,  5,  6,
+    7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+    25, 0,  0,  0,  0,  63, 0,  26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
+    37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51};
 
-std::string b64decode(const voiddata, const size_t len)
+std::string b64decode(const void *data, const size_t len)
 {
-    unsigned char* p = (unsigned char*)data;
-    int pad = len > 0 && (len % 4 || p[len - 1] == '=');
-    const size_t L = ((len + 3) / 4 - pad) * 4;
-    std::string str(L / 4 * 3 + pad, '\0');
+    unsigned char *p = (unsigned char *)data;
+    int            pad = len > 0 && (len % 4 || p[len - 1] == '=');
+    const size_t   L = ((len + 3) / 4 - pad) * 4;
+    std::string    str(L / 4 * 3 + pad, '\0');
 
-    for (size_t i = 0, j = 0; i < L; i += 4)
-    {
-        int n = B64index[p[i]] << 18 | B64index[p[i + 1]] << 12 | B64index[p[i + 2]] << 6 | B64index[p[i + 3]];
+    for (size_t i = 0, j = 0; i < L; i += 4) {
+        int n = B64index[p[i]] << 18 | B64index[p[i + 1]] << 12 |
+                B64index[p[i + 2]] << 6 | B64index[p[i + 3]];
         str[j++] = n >> 16;
         str[j++] = n >> 8 & 0xFF;
         str[j++] = n & 0xFF;
     }
-    if (pad)
-    {
+    if (pad) {
         int n = B64index[p[L]] << 18 | B64index[p[L + 1]] << 12;
         str[str.size() - 1] = n >> 16;
 
-        if (len > L + 2 && p[L + 2] != '=')
-        {
+        if (len > L + 2 && p[L + 2] != '=') {
             n |= B64index[p[L + 2]] << 6;
             str.push_back(n >> 8 & 0xFF);
         }
@@ -643,13 +643,12 @@ std::string b64decode(const void* data, const size_t len)
     return str;
 }
 
-static std::string
-convertFromBase64(const std::string &str)
+static std::string convertFromBase64(const std::string &str)
 {
     // usual header look like "data:image/png;base64,"
     // so need to skip till ','.
     int startIndex = str.find(",", 0);
-    startIndex += 1; // skip ","
+    startIndex += 1;  // skip ","
     int length = str.length() - startIndex;
 
     const char *b64Data = str.c_str() + startIndex;
@@ -666,9 +665,9 @@ std::shared_ptr<LOTAsset> LottieParserImpl::parseAsset()
     RAPIDJSON_ASSERT(PeekType() == kObjectType);
     std::shared_ptr<LOTAsset> sharedAsset = std::make_shared<LOTAsset>();
     LOTAsset *                asset = sharedAsset.get();
-    std::string    filename;
-    std::string    relativePath;
-    bool           embededResource = false;
+    std::string               filename;
+    std::string               relativePath;
+    bool                      embededResource = false;
     EnterObject();
     while (const char *key = NextObjectKey()) {
         if (0 == strcmp(key, "w")) {
@@ -715,7 +714,7 @@ std::shared_ptr<LOTAsset> LottieParserImpl::parseAsset()
     if (asset->mAssetType == LOTAsset::Type::Image) {
         if (embededResource) {
             // embeder resource should start with "data:"
-            if (filename.compare(0, 5,"data:") == 0) {
+            if (filename.compare(0, 5, "data:") == 0) {
                 asset->loadImageData(convertFromBase64(filename));
             }
         } else {
@@ -745,11 +744,11 @@ void LottieParserImpl::parseLayers(LOTCompositionData *comp)
 LottieColor LottieParserImpl::toColor(const char *str)
 {
     LottieColor color;
-    int len = strlen(str);
+    int         len = strlen(str);
 
     // some resource has empty color string
     // return a default color for those cases.
-    if (!len) return  color;
+    if (!len) return color;
 
     RAPIDJSON_ASSERT(len == 7);
     RAPIDJSON_ASSERT(str[0] == '#');
@@ -846,7 +845,9 @@ std::shared_ptr<LOTData> LottieParserImpl::parseLayer(bool record)
         } else if (0 == strcmp(key, "ddd")) { /*3d layer */
             RAPIDJSON_ASSERT(PeekType() == kNumberType);
             ddd = GetInt();
-        } else if (0 == strcmp(key, "parent")) { /*Layer Parent. Uses "ind" of parent.*/
+        } else if (0 ==
+                   strcmp(key,
+                          "parent")) { /*Layer Parent. Uses "ind" of parent.*/
             RAPIDJSON_ASSERT(PeekType() == kNumberType);
             layer->mParentId = GetInt();
         } else if (0 == strcmp(key, "refId")) { /*preComp Layer reference id*/
@@ -918,18 +919,19 @@ std::shared_ptr<LOTData> LottieParserImpl::parseLayer(bool record)
 
     // update the static property of layer
     bool staticFlag = true;
-    for (const autochild : layer->mChildren) {
+    for (const auto &child : layer->mChildren) {
         staticFlag &= child.get()->isStatic();
     }
 
-    for (const automask : layer->mMasks) {
+    for (const auto &mask : layer->mMasks) {
         staticFlag &= mask->isStatic();
     }
 
     layer->setStatic(staticFlag && layer->mTransform->isStatic());
 
     if (record) {
-        mLayerInfoList.push_back(LayerInfo(layer->mName, layer->mInFrame, layer->mOutFrame));
+        mLayerInfoList.push_back(
+            LayerInfo(layer->mName, layer->mInFrame, layer->mOutFrame));
     }
     return sharedLayer;
 }
@@ -1028,7 +1030,7 @@ std::shared_ptr<LOTData> LottieParserImpl::parseObjectTypeAttr()
     } else if (0 == strcmp(type, "rp")) {
         curLayerRef->mHasRepeater = true;
         return parseReapeaterObject();
-    }  else if (0 == strcmp(type, "mm")) {
+    } else if (0 == strcmp(type, "mm")) {
         vWarning << "Merge Path is not supported yet";
         return nullptr;
     } else {
@@ -1079,7 +1081,7 @@ std::shared_ptr<LOTData> LottieParserImpl::parseGroupObject()
         }
     }
     bool staticFlag = true;
-    for (const autochild : group->mChildren) {
+    for (const auto &child : group->mChildren) {
         staticFlag &= child.get()->isStatic();
     }
 
@@ -1298,7 +1300,6 @@ void LottieParserImpl::getValue(LOTRepeaterTransform &obj)
     }
 }
 
-
 std::shared_ptr<LOTData> LottieParserImpl::parseReapeaterObject()
 {
     std::shared_ptr<LOTRepeaterData> sharedRepeater =
@@ -1310,9 +1311,9 @@ std::shared_ptr<LOTData> LottieParserImpl::parseReapeaterObject()
             obj->mName = GetString();
         } else if (0 == strcmp(key, "c")) {
             parseProperty(obj->mCopies);
-            float maxCopy= 0.0;
+            float maxCopy = 0.0;
             if (!obj->mCopies.isStatic()) {
-                for(auto &keyFrame : obj->mCopies.animation().mKeyFrames) {
+                for (auto &keyFrame : obj->mCopies.animation().mKeyFrames) {
                     if (maxCopy < keyFrame.mValue.mStartValue)
                         maxCopy = keyFrame.mValue.mStartValue;
                     if (maxCopy < keyFrame.mValue.mEndValue)
@@ -1344,7 +1345,8 @@ std::shared_ptr<LOTData> LottieParserImpl::parseReapeaterObject()
 /*
  * https://github.com/airbnb/lottie-web/blob/master/docs/json/shapes/transform.json
  */
-std::shared_ptr<LOTTransformData> LottieParserImpl::parseTransformObject(bool ddd)
+std::shared_ptr<LOTTransformData> LottieParserImpl::parseTransformObject(
+    bool ddd)
 {
     std::shared_ptr<LOTTransformData> sharedTransform =
         std::make_shared<LOTTransformData>();
@@ -1368,7 +1370,7 @@ std::shared_ptr<LOTTransformData> LottieParserImpl::parseTransformObject(bool dd
                     parseProperty(obj->mX);
                 } else if (obj->mSeparate && (0 == strcmp(key, "y"))) {
                     parseProperty(obj->mY);
-                }else {
+                } else {
                     Skip(key);
                 }
             }
@@ -1400,7 +1402,8 @@ std::shared_ptr<LOTTransformData> LottieParserImpl::parseTransformObject(bool dd
                          obj->mX.isStatic() && obj->mY.isStatic();
     if (obj->m3D) {
         obj->mStaticMatrix = obj->mStaticMatrix && obj->m3D->mRx.isStatic() &&
-                             obj->m3D->mRy.isStatic() && obj->m3D->mRz.isStatic();
+                             obj->m3D->mRy.isStatic() &&
+                             obj->m3D->mRz.isStatic();
     }
 
     obj->setStatic(obj->mStaticMatrix && obj->mOpacity.isStatic());
@@ -1429,7 +1432,7 @@ std::shared_ptr<LOTData> LottieParserImpl::parseFillObject()
             obj->mEnabled = GetBool();
         } else if (0 == strcmp(key, "r")) {
             obj->mFillRule = getFillRule();
-        }  else if (0 == strcmp(key, "hd")) {
+        } else if (0 == strcmp(key, "hd")) {
             obj->mHidden = GetBool();
         } else {
 #ifdef DEBUG_PARSER
@@ -1693,7 +1696,7 @@ void LottieParserImpl::getValue(float &val)
     if (PeekType() == kArrayType) {
         EnterArray();
         if (NextArrayValue()) val = GetDouble();
-        //discard rest
+        // discard rest
         while (NextArrayValue()) {
             GetDouble();
         }
@@ -1829,14 +1832,16 @@ VPointF LottieParserImpl::parseInperpolatorPoint()
 }
 
 template <typename T>
-bool LottieParserImpl::parseKeyFrameValue(const char *,
-                                          LOTKeyFrameValue<T> &){ return false;}
+bool LottieParserImpl::parseKeyFrameValue(const char *, LOTKeyFrameValue<T> &)
+{
+    return false;
+}
 
 template <>
-bool LottieParserImpl::parseKeyFrameValue(const char * key,
+bool LottieParserImpl::parseKeyFrameValue(const char *               key,
                                           LOTKeyFrameValue<VPointF> &value)
 {
-   if (0 == strcmp(key, "ti")) {
+    if (0 == strcmp(key, "ti")) {
         value.mPathKeyFrame = true;
         getValue(value.mInTangent);
     } else if (0 == strcmp(key, "to")) {
@@ -1848,13 +1853,13 @@ bool LottieParserImpl::parseKeyFrameValue(const char * key,
     return true;
 }
 
-std::shared_ptr<VInterpolator>
-LottieParserImpl::interpolator(VPointF inTangent, VPointF outTangent, std::string key)
+std::shared_ptr<VInterpolator> LottieParserImpl::interpolator(
+    VPointF inTangent, VPointF outTangent, std::string key)
 {
     if (key.empty()) {
         std::array<char, 20> temp;
-        snprintf(temp.data(), temp.size(), "%.2f_%.2f_%.2f_%.2f",
-                 inTangent.x(), inTangent.y(), outTangent.x(), outTangent.y());
+        snprintf(temp.data(), temp.size(), "%.2f_%.2f_%.2f_%.2f", inTangent.x(),
+                 inTangent.y(), outTangent.x(), outTangent.y());
         key = temp.data();
     }
 
@@ -1862,8 +1867,9 @@ LottieParserImpl::interpolator(VPointF inTangent, VPointF outTangent, std::strin
     if (search != mInterpolatorCache.end()) {
         return search->second;
     } else {
-        auto obj = std::make_shared<VInterpolator>(VInterpolator(outTangent, inTangent));
-        mInterpolatorCache[std::move(key)] =  obj;
+        auto obj = std::make_shared<VInterpolator>(
+            VInterpolator(outTangent, inTangent));
+        mInterpolatorCache[std::move(key)] = obj;
         return obj;
     }
 }
@@ -1876,10 +1882,10 @@ void LottieParserImpl::parseKeyFrame(LOTAnimInfo<T> &obj)
 {
     struct ParsedField {
         std::string interpolatorKey;
-        bool interpolator{false};
-        bool value{false};
-        bool hold{false};
-        bool noEndValue{true};
+        bool        interpolator{false};
+        bool        value{false};
+        bool        hold{false};
+        bool        noEndValue{true};
     };
 
     EnterObject();
@@ -1900,7 +1906,7 @@ void LottieParserImpl::parseKeyFrame(LOTAnimInfo<T> &obj)
             parsed.value = true;
             getValue(keyframe.mValue.mStartValue);
             continue;
-        }  else if (0 == strcmp(key, "e")) {
+        } else if (0 == strcmp(key, "e")) {
             parsed.noEndValue = false;
             getValue(keyframe.mValue.mEndValue);
             continue;
@@ -1915,7 +1921,7 @@ void LottieParserImpl::parseKeyFrame(LOTAnimInfo<T> &obj)
                     if (parsed.interpolatorKey.empty()) {
                         parsed.interpolatorKey = GetString();
                     } else {
-                        //skip rest of the string
+                        // skip rest of the string
                         GetString();
                     }
                 }
@@ -1938,9 +1944,9 @@ void LottieParserImpl::parseKeyFrame(LOTAnimInfo<T> &obj)
         // update the endFrame value of current keyframe
         obj.mKeyFrames.back().mEndFrame = keyframe.mStartFrame;
         // if no end value provided, copy start value to previous frame
-        if (parsed.value &&
-            parsed.noEndValue) {
-            obj.mKeyFrames.back().mValue.mEndValue = keyframe.mValue.mStartValue;
+        if (parsed.value && parsed.noEndValue) {
+            obj.mKeyFrames.back().mValue.mEndValue =
+                keyframe.mValue.mStartValue;
         }
     }
 
@@ -1949,10 +1955,11 @@ void LottieParserImpl::parseKeyFrame(LOTAnimInfo<T> &obj)
         keyframe.mEndFrame = keyframe.mStartFrame;
         obj.mKeyFrames.push_back(keyframe);
     } else if (parsed.interpolator) {
-        keyframe.mInterpolator = interpolator(inTangent, outTangent, std::move(parsed.interpolatorKey));
+        keyframe.mInterpolator = interpolator(
+            inTangent, outTangent, std::move(parsed.interpolatorKey));
         obj.mKeyFrames.push_back(keyframe);
     } else {
-        //its the last frame discard.
+        // its the last frame discard.
     }
 }
 
@@ -2038,15 +2045,11 @@ class LOTDataInspector {
 public:
     void visit(LOTCompositionData *obj, std::string level)
     {
-        vDebug << " { "
-               << level
-               << "Composition:: a: " << !obj->isStatic()
-               << ", v: " << obj->mVersion
-               << ", stFm: " << obj->startFrame()
+        vDebug << " { " << level << "Composition:: a: " << !obj->isStatic()
+               << ", v: " << obj->mVersion << ", stFm: " << obj->startFrame()
                << ", endFm: " << obj->endFrame()
                << ", W: " << obj->size().width()
-               << ", H: " << obj->size().height()
-               << "\n";
+               << ", H: " << obj->size().height() << "\n";
         level.append("\t");
         visit(obj->mRootLayer.get(), level);
         level.erase(level.end() - 1, level.end());
@@ -2054,53 +2057,44 @@ public:
     }
     void visit(LOTLayerData *obj, std::string level)
     {
-        vDebug << level
-               << "{ "
-               << layerType(obj->mLayerType)
-               << ", name: "<< obj->name()
-               << ", id:" << obj->mId << " Pid:" << obj->mParentId
-               << ", a:" << !obj->isStatic()
-               << ", "<<matteType(obj->mMatteType)
-               << ", mask:"<<obj->hasMask()
-               << ", inFm:" << obj->mInFrame
-               << ", outFm:" << obj->mOutFrame
-               << ", stFm:" << obj->mStartFrame
-               << ", ts:" << obj->mTimeStreatch
-               << ", ao:" << obj->autoOrient()
+        vDebug << level << "{ " << layerType(obj->mLayerType)
+               << ", name: " << obj->name() << ", id:" << obj->mId
+               << " Pid:" << obj->mParentId << ", a:" << !obj->isStatic()
+               << ", " << matteType(obj->mMatteType)
+               << ", mask:" << obj->hasMask() << ", inFm:" << obj->mInFrame
+               << ", outFm:" << obj->mOutFrame << ", stFm:" << obj->mStartFrame
+               << ", ts:" << obj->mTimeStreatch << ", ao:" << obj->autoOrient()
                << ", ddd:" << (obj->mTransform ? obj->mTransform->ddd() : false)
                << ", W:" << obj->layerSize().width()
                << ", H:" << obj->layerSize().height();
 
         if (obj->mLayerType == LayerType::Image)
-            vDebug << level
-                   << "\t{ "
+            vDebug << level << "\t{ "
                    << "ImageInfo:"
                    << " W :" << obj->mAsset->mWidth
-                   << ", H :" << obj->mAsset->mHeight
-                   <<" }"
+                   << ", H :" << obj->mAsset->mHeight << " }"
                    << "\n";
         else {
-            vDebug<< level;
+            vDebug << level;
         }
         visitChildren(static_cast<LOTGroupData *>(obj), level);
-        vDebug << level
-               << "} "
-               << layerType(obj->mLayerType).c_str()
+        vDebug << level << "} " << layerType(obj->mLayerType).c_str()
                << ", id: " << obj->mId << "\n";
     }
     void visitChildren(LOTGroupData *obj, std::string level)
     {
         level.append("\t");
-        for (const auto& child : obj->mChildren) visit(child.get(), level);
-        if (obj->mTransform)
-            visit(obj->mTransform.get(), level);
+        for (const auto &child : obj->mChildren) visit(child.get(), level);
+        if (obj->mTransform) visit(obj->mTransform.get(), level);
     }
 
-    void visit(LOTData *obj, std::string level) {
+    void visit(LOTData *obj, std::string level)
+    {
         switch (obj->mType) {
         case LOTData::Type::Repeater: {
             auto r = static_cast<LOTRepeaterData *>(obj);
-            vDebug << level << "{ Repeater: name: "<<obj->name()<<" , a:" << !obj->isStatic()
+            vDebug << level << "{ Repeater: name: " << obj->name()
+                   << " , a:" << !obj->isStatic()
                    << ", copies:" << r->maxCopies()
                    << ", offset:" << r->offset(0);
             visitChildren(r->mContent.get(), level);
@@ -2108,55 +2102,66 @@ public:
             break;
         }
         case LOTData::Type::ShapeGroup: {
-            vDebug << level << "{ ShapeGroup: name: "<<obj->name()<<" , a:" << !obj->isStatic();
+            vDebug << level << "{ ShapeGroup: name: " << obj->name()
+                   << " , a:" << !obj->isStatic();
             visitChildren(static_cast<LOTGroupData *>(obj), level);
             vDebug << level << "} ShapeGroup";
             break;
         }
-        case LOTData::Type::Layer:{
+        case LOTData::Type::Layer: {
             visit(static_cast<LOTLayerData *>(obj), level);
             break;
         }
-        case LOTData::Type::Trim:{
-            vDebug << level << "{ Trim: name: "<<obj->name()<<" , a:" << !obj->isStatic() << " }";
+        case LOTData::Type::Trim: {
+            vDebug << level << "{ Trim: name: " << obj->name()
+                   << " , a:" << !obj->isStatic() << " }";
             break;
         }
-        case LOTData::Type::Rect:{
-            vDebug << level << "{ Rect: name: "<<obj->name()<<" , a:" << !obj->isStatic() << " }";
+        case LOTData::Type::Rect: {
+            vDebug << level << "{ Rect: name: " << obj->name()
+                   << " , a:" << !obj->isStatic() << " }";
             break;
         }
-        case LOTData::Type::Ellipse:{
-            vDebug << level << "{ Ellipse: name: "<<obj->name()<<" , a:" << !obj->isStatic() << " }";
+        case LOTData::Type::Ellipse: {
+            vDebug << level << "{ Ellipse: name: " << obj->name()
+                   << " , a:" << !obj->isStatic() << " }";
             break;
         }
-        case LOTData::Type::Shape:{
-            vDebug << level << "{ Shape: name: "<<obj->name()<<" , a:" << !obj->isStatic() << " }";
+        case LOTData::Type::Shape: {
+            vDebug << level << "{ Shape: name: " << obj->name()
+                   << " , a:" << !obj->isStatic() << " }";
             break;
         }
-        case LOTData::Type::Polystar:{
-            vDebug << level << "{ Polystar: name: "<<obj->name()<<" , a:" << !obj->isStatic() << " }";
+        case LOTData::Type::Polystar: {
+            vDebug << level << "{ Polystar: name: " << obj->name()
+                   << " , a:" << !obj->isStatic() << " }";
             break;
         }
-        case LOTData::Type::Transform:{
-            vDebug << level << "{ Transform: name: "<<obj->name()<<" , a: " << !obj->isStatic() << " }";
+        case LOTData::Type::Transform: {
+            vDebug << level << "{ Transform: name: " << obj->name()
+                   << " , a: " << !obj->isStatic() << " }";
             break;
         }
-        case LOTData::Type::Stroke:{
-            vDebug << level << "{ Stroke: name: "<<obj->name()<<" , a:" << !obj->isStatic() << " }";
+        case LOTData::Type::Stroke: {
+            vDebug << level << "{ Stroke: name: " << obj->name()
+                   << " , a:" << !obj->isStatic() << " }";
             break;
         }
-        case LOTData::Type::GStroke:{
-            vDebug << level << "{ GStroke: name: "<<obj->name()<<" , a:" << !obj->isStatic() << " }";
+        case LOTData::Type::GStroke: {
+            vDebug << level << "{ GStroke: name: " << obj->name()
+                   << " , a:" << !obj->isStatic() << " }";
             break;
         }
-        case LOTData::Type::Fill:{
-            vDebug << level << "{ Fill: name: "<<obj->name()<<" , a:" << !obj->isStatic() << " }";
+        case LOTData::Type::Fill: {
+            vDebug << level << "{ Fill: name: " << obj->name()
+                   << " , a:" << !obj->isStatic() << " }";
             break;
         }
-        case LOTData::Type::GFill:{
+        case LOTData::Type::GFill: {
             auto f = static_cast<LOTGFillData *>(obj);
-            vDebug << level << "{ GFill: name: "<<obj->name()<<" , a:" << !f->isStatic()
-                   << ", ty:" << f->mGradientType << ", s:" << f->mStartPoint.value(0)
+            vDebug << level << "{ GFill: name: " << obj->name()
+                   << " , a:" << !f->isStatic() << ", ty:" << f->mGradientType
+                   << ", s:" << f->mStartPoint.value(0)
                    << ", e:" << f->mEndPoint.value(0) << " }";
             break;
         }
@@ -2223,7 +2228,8 @@ LottieParser::~LottieParser()
     delete d;
 }
 
-LottieParser::LottieParser(char *str, const char *dir_path) : d(new LottieParserImpl(str, dir_path))
+LottieParser::LottieParser(char *str, const char *dir_path)
+    : d(new LottieParserImpl(str, dir_path))
 {
     d->parseComposition();
 }
index 320a726425da0e2fcc23dc05afc4e4b68d617fb7..e9d79e4247d2e98f9cf016ed78d44122a31b1cc8 100644 (file)
@@ -43,21 +43,21 @@ extern "C" {
  * exported function wrapper from the library
  */
 
-LOT_EXPORT unsigned char *
-lottie_image_load(char const *filename, int *x, int *y, int *comp, int req_comp)
+LOT_EXPORT unsigned char *lottie_image_load(char const *filename, int *x,
+                                            int *y, int *comp, int req_comp)
 {
     return stbi_load(filename, x, y, comp, req_comp);
 }
 
-LOT_EXPORT unsigned char *
-lottie_image_load_from_data(const char *imageData, int len, int *x, int *y, int *comp, int req_comp)
+LOT_EXPORT unsigned char *lottie_image_load_from_data(const char *imageData,
+                                                      int len, int *x, int *y,
+                                                      int *comp, int req_comp)
 {
     unsigned char *data = (unsigned char *)imageData;
     return stbi_load_from_memory(data, len, x, y, comp, req_comp);
 }
 
-LOT_EXPORT void
-lottie_image_free(unsigned char *data)
+LOT_EXPORT void lottie_image_free(unsigned char *data)
 {
     stbi_image_free(data);
 }
index e8b931c4a5c2bc8c2657287d7ee933653594600e..c5d7a173dabb53e026bc3eee86c56e389a4ee076 100644 (file)
@@ -1,24 +1,24 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vbezier.h"
-#include "vline.h"
 #include <cmath>
+#include "vline.h"
 
 V_BEGIN_NAMESPACE
 
@@ -113,7 +113,8 @@ void VBezier::splitAtLength(float len, VBezier *left, VBezier *right)
 
 VPointF VBezier::derivative(float t) const
 {
-    // p'(t) = 3 * (-(1-2t+t^2) * p0 + (1 - 4 * t + 3 * t^2) * p1 + (2 * t - 3 * t^2) * p2 + t^2 * p3)
+    // p'(t) = 3 * (-(1-2t+t^2) * p0 + (1 - 4 * t + 3 * t^2) * p1 + (2 * t - 3 *
+    // t^2) * p2 + t^2 * p3)
 
     float m_t = 1. - t;
 
@@ -126,7 +127,6 @@ VPointF VBezier::derivative(float t) const
                        a * y1 + b * y2 + c * y3 + d * y4);
 }
 
-
 float VBezier::angleAt(float t) const
 {
     if (t < 0 || t > 1) {
@@ -135,5 +135,4 @@ float VBezier::angleAt(float t) const
     return VLine({}, derivative(t)).angle();
 }
 
-
 V_END_NAMESPACE
index 84493daeaf8a68c00108292a498670777c6ad338..20963a65e08b28203882a4284b278b40194041b9 100644 (file)
@@ -1,54 +1,54 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vbitmap.h"
 #include <string.h>
-#include "vglobal.h"
 #include "vdrawhelper.h"
+#include "vglobal.h"
 
 V_BEGIN_NAMESPACE
 
 struct VBitmap::Impl {
-    uchar *             mData{nullptr};
-    uint                mWidth{0};
-    uint                mHeight{0};
-    uint                mStride{0};
-    uint                mBytes{0};
-    uint                mDepth{0};
-    VBitmap::Format     mFormat{VBitmap::Format::Invalid};
-    bool                mOwnData;
-    bool                mRoData;
-
-    Impl() = delete ;
-
-    Impl(uint width, uint height, VBitmap::Format format):
-        mOwnData(true),
-        mRoData(false)
+    uchar *         mData{nullptr};
+    uint            mWidth{0};
+    uint            mHeight{0};
+    uint            mStride{0};
+    uint            mBytes{0};
+    uint            mDepth{0};
+    VBitmap::Format mFormat{VBitmap::Format::Invalid};
+    bool            mOwnData;
+    bool            mRoData;
+
+    Impl() = delete;
+
+    Impl(uint width, uint height, VBitmap::Format format)
+        : mOwnData(true), mRoData(false)
     {
         reset(width, height, format);
     }
 
     void reset(uint width, uint height, VBitmap::Format format)
     {
-        if (mOwnData && mData) delete(mData);
+        if (mOwnData && mData) delete (mData);
 
         mDepth = depth(format);
-        uint stride = ((width * mDepth + 31) >> 5) << 2; // bytes per scanline (must be multiple of 4)
+        uint stride = ((width * mDepth + 31) >> 5)
+                      << 2;  // bytes per scanline (must be multiple of 4)
 
         mWidth = width;
         mHeight = height;
@@ -58,9 +58,8 @@ struct VBitmap::Impl {
         mData = reinterpret_cast<uchar *>(::operator new(mBytes));
     }
 
-    Impl(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format):
-        mOwnData(false),
-        mRoData(false)
+    Impl(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format)
+        : mOwnData(false), mRoData(false)
     {
         mWidth = w;
         mHeight = h;
@@ -76,11 +75,11 @@ struct VBitmap::Impl {
         if (mOwnData && mData) ::operator delete(mData);
     }
 
-    uint stride() const {return mStride;}
-    uint width() const {return mWidth;}
-    uint height() const {return mHeight;}
-    VBitmap::Format format() const {return mFormat;}
-    uchar* data() { return mData;}
+    uint            stride() const { return mStride; }
+    uint            width() const { return mWidth; }
+    uint            height() const { return mHeight; }
+    VBitmap::Format format() const { return mFormat; }
+    uchar *         data() { return mData; }
 
     static uint depth(VBitmap::Format format)
     {
@@ -103,12 +102,13 @@ struct VBitmap::Impl {
         //@TODO
     }
 
-    void updateLuma() {
+    void updateLuma()
+    {
         if (mFormat != VBitmap::Format::ARGB32_Premultiplied) return;
 
-        for (uint col = 0 ; col < mHeight ; col++) {
-            uint *pixel = (uint *) (mData + mStride * col);
-            for (uint row = 0 ; row < mWidth; row++) {
+        for (uint col = 0; col < mHeight; col++) {
+            uint *pixel = (uint *)(mData + mStride * col);
+            for (uint row = 0; row < mWidth; row++) {
                 int alpha = vAlpha(*pixel);
                 if (alpha == 0) {
                     pixel++;
@@ -120,12 +120,12 @@ struct VBitmap::Impl {
                 int blue = vBlue(*pixel);
 
                 if (alpha != 255) {
-                    //un multiply
+                    // un multiply
                     red = (red * 255) / alpha;
                     green = (green * 255) / alpha;
                     blue = (blue * 255) / alpha;
                 }
-                int luminosity = (0.299*red + 0.587*green + 0.114*blue);
+                int luminosity = (0.299 * red + 0.587 * green + 0.114 * blue);
                 *pixel = luminosity << 24;
                 pixel++;
             }
@@ -135,19 +135,17 @@ struct VBitmap::Impl {
 
 VBitmap::VBitmap(uint width, uint height, VBitmap::Format format)
 {
-    if (width <=0 || height <=0 || format == Format::Invalid) return;
+    if (width <= 0 || height <= 0 || format == Format::Invalid) return;
 
     mImpl = std::make_shared<Impl>(width, height, format);
-
 }
 
 VBitmap::VBitmap(uchar *data, uint width, uint height, uint bytesPerLine,
                  VBitmap::Format format)
 {
-    if (!data ||
-        width <=0 || height <=0 ||
-        bytesPerLine <=0 ||
-        format == Format::Invalid) return;
+    if (!data || width <= 0 || height <= 0 || bytesPerLine <= 0 ||
+        format == Format::Invalid)
+        return;
 
     mImpl = std::make_shared<Impl>(data, width, height, bytesPerLine, format);
 }
@@ -155,8 +153,7 @@ VBitmap::VBitmap(uchar *data, uint width, uint height, uint bytesPerLine,
 void VBitmap::reset(uint w, uint h, VBitmap::Format format)
 {
     if (mImpl) {
-        if (w == mImpl->width() &&
-            h == mImpl->height() &&
+        if (w == mImpl->width() && h == mImpl->height() &&
             format == mImpl->format()) {
             return;
         }
index ca2df7b77daef6c4ea5c0271ab4f67f40018ecaa..cdc114ecfe8712554ef8545b487f3292a53504bb 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vbrush.h"
index 02459fe5ab7b9b44ee47d705e7774106ce730fd9..52ac0dbe0e2a772866fa82965bba321dd4e94387 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vdrawhelper.h"
@@ -60,7 +60,8 @@ void comp_func_solid_SourceOver(uint32_t *dest, int length, uint32_t color,
   dest = d * sa * ca + d * cia
        = d * (sa * ca + cia)
 */
-static void comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha)
+static void comp_func_solid_DestinationIn(uint *dest, int length, uint color,
+                                          uint const_alpha)
 {
     uint a = vAlpha(color);
     if (const_alpha != 255) {
@@ -76,11 +77,11 @@ static void comp_func_solid_DestinationIn(uint *dest, int length, uint color, ui
   dest = d * sia * ca + d * cia
        = d * (sia * ca + cia)
 */
-static void comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha)
+static void comp_func_solid_DestinationOut(uint *dest, int length, uint color,
+                                           uint const_alpha)
 {
     uint a = vAlpha(~color);
-    if (const_alpha != 255)
-        a = BYTE_MUL(a, const_alpha) + 255 - const_alpha;
+    if (const_alpha != 255) a = BYTE_MUL(a, const_alpha) + 255 - const_alpha;
     for (int i = 0; i < length; ++i) {
         dest[i] = BYTE_MUL(dest[i], a);
     }
@@ -130,7 +131,8 @@ void comp_func_SourceOver(uint32_t *dest, const uint32_t *src, int length,
     }
 }
 
-void comp_func_DestinationIn(uint *dest, const uint *src, int length, uint const_alpha)
+void comp_func_DestinationIn(uint *dest, const uint *src, int length,
+                             uint const_alpha)
 {
     if (const_alpha == 255) {
         for (int i = 0; i < length; ++i) {
@@ -145,7 +147,8 @@ void comp_func_DestinationIn(uint *dest, const uint *src, int length, uint const
     }
 }
 
-void comp_func_DestinationOut(uint *dest, const uint *src, int length, uint const_alpha)
+void comp_func_DestinationOut(uint *dest, const uint *src, int length,
+                              uint const_alpha)
 {
     if (const_alpha == 255) {
         for (int i = 0; i < length; ++i) {
@@ -161,16 +164,11 @@ void comp_func_DestinationOut(uint *dest, const uint *src, int length, uint cons
 }
 
 CompositionFunctionSolid COMP_functionForModeSolid_C[] = {
-                                                            comp_func_solid_Source,
-                                                            comp_func_solid_SourceOver,
-                                                            comp_func_solid_DestinationIn,
-                                                            comp_func_solid_DestinationOut
-                                                        };
+    comp_func_solid_Source, comp_func_solid_SourceOver,
+    comp_func_solid_DestinationIn, comp_func_solid_DestinationOut};
 
-CompositionFunction COMP_functionForMode_C[] = {comp_func_Source,
-                                                comp_func_SourceOver,
-                                                comp_func_DestinationIn,
-                                                comp_func_DestinationOut
-                                               };
+CompositionFunction COMP_functionForMode_C[] = {
+    comp_func_Source, comp_func_SourceOver, comp_func_DestinationIn,
+    comp_func_DestinationOut};
 
 void vInitBlendFunctions() {}
index 760fdc58367b6e4a6286ef43979bdbc1520e0315..a6ca9abceacebf473ef129bb3b8d9220df29e959 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vbezier.h"
@@ -29,8 +29,7 @@ VDasher::VDasher(const float *dashArray, size_t size)
 {
     mDashArray = reinterpret_cast<const VDasher::Dash *>(dashArray);
     mArraySize = size / 2;
-    if (size % 2)
-        mDashOffset = dashArray[size - 1];
+    if (size % 2) mDashOffset = dashArray[size - 1];
     mIndex = 0;
     mCurrentLength = 0;
     mDiscard = false;
@@ -78,13 +77,13 @@ void VDasher::moveTo(const VPointF &p)
 
 void VDasher::addLine(const VPointF &p)
 {
-   if (mDiscard) return;
+    if (mDiscard) return;
 
-   if (mStartNewSegment) {
+    if (mStartNewSegment) {
         mResult.moveTo(mCurPt);
         mStartNewSegment = false;
-   }
-   mResult.lineTo(p);
+    }
+    mResult.lineTo(p);
 }
 
 void VDasher::updateActiveSegment()
@@ -149,7 +148,7 @@ void VDasher::cubicTo(const VPointF &cp1, const VPointF &cp2, const VPointF &e)
 {
     VBezier left, right;
     VBezier b = VBezier::fromPoints(mCurPt, cp1, cp2, e);
-    float bezLen = b.length();
+    float   bezLen = b.length();
 
     if (bezLen <= mCurrentLength) {
         mCurrentLength -= bezLen;
index 86d00c22c95249cf633059ff1ceb431d44cd7942..8a0c19cef5f2192e626d4cbf71eef90fa85fe9df 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vdebug.h"
@@ -54,7 +54,8 @@ void format_timestamp(std::ostream& os, uint64_t timestamp)
     char        buffer[32];
     strftime(buffer, 32, "%Y-%m-%d %T.", gmtime);
     char microseconds[7];
-    snprintf(microseconds, 7, "%06llu", (long long unsigned int)timestamp % 1000000);
+    snprintf(microseconds, 7, "%06llu",
+             (long long unsigned int)timestamp % 1000000);
     os << '[' << buffer << microseconds << ']';
 }
 
@@ -456,10 +457,12 @@ private:
     size_t const              m_size;
     Item*                     m_ring;
     std::atomic<unsigned int> m_write_index;
+
 public:
-    char                      pad[64];
+    char pad[64];
+
 private:
-    unsigned int              m_read_index;
+    unsigned int m_read_index;
 };
 
 class Buffer {
@@ -722,7 +725,7 @@ void initialize(NonGuaranteedLogger ngl, std::string const& log_directory,
                 uint32_t           log_file_roll_size_mb)
 {
     nanologger = std::make_unique<NanoLogger>(ngl, log_directory, log_file_name,
-                                    log_file_roll_size_mb);
+                                              log_file_roll_size_mb);
     atomic_nanologger.store(nanologger.get(), std::memory_order_seq_cst);
 }
 
@@ -731,7 +734,7 @@ void initialize(GuaranteedLogger gl, std::string const& log_directory,
                 uint32_t           log_file_roll_size_mb)
 {
     nanologger = std::make_unique<NanoLogger>(gl, log_directory, log_file_name,
-                                    log_file_roll_size_mb);
+                                              log_file_roll_size_mb);
     atomic_nanologger.store(nanologger.get(), std::memory_order_seq_cst);
 }
 
@@ -748,4 +751,4 @@ bool is_logged(LogLevel level)
            loglevel.load(std::memory_order_relaxed);
 }
 
-#endif //LOTTIE_LOGGING_SUPPORT
+#endif  // LOTTIE_LOGGING_SUPPORT
index 775564c251e3cf446f59e71af00c8b5812299158..946054f2ccacd0a75099a9d2576e65151d931bb2 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vdrawable.h"
index 27ee26634bb62166414726f647bf8e0637af21bb..a22ce34dd3e356ef581b9537465b4c651ccb7093 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 /****************************************************************************
 ****************************************************************************/
 
 #include "vdrawhelper.h"
+#include <algorithm>
 #include <climits>
 #include <cstring>
 #include <mutex>
 #include <unordered_map>
-#include <algorithm>
 
 class VGradientCache {
 public:
@@ -65,14 +65,15 @@ public:
     };
     using VCacheData = std::shared_ptr<const CacheInfo>;
     using VCacheKey = int64_t;
-    using VGradientColorTableHash = std::unordered_multimap<VCacheKey, VCacheData>;
+    using VGradientColorTableHash =
+        std::unordered_multimap<VCacheKey, VCacheData>;
 
     bool generateGradientColorTable(const VGradientStops &stops, float alpha,
                                     uint32_t *colorTable, int size);
     VCacheData getBuffer(const VGradient &gradient)
     {
-        VCacheKey   hash_val = 0;
-        VCacheData info;
+        VCacheKey             hash_val = 0;
+        VCacheData            info;
         const VGradientStops &stops = gradient.mStops;
         for (uint i = 0; i < stops.size() && i <= 2; i++)
             hash_val += (stops[i].second.premulARGB() * gradient.alpha());
@@ -111,20 +112,19 @@ public:
     }
 
 protected:
-    uint maxCacheSize() const { return 60; }
+    uint       maxCacheSize() const { return 60; }
     VCacheData addCacheElement(VCacheKey hash_val, const VGradient &gradient)
     {
         if (mCache.size() == maxCacheSize()) {
-            uint count = maxCacheSize()/10;
+            uint count = maxCacheSize() / 10;
             while (count--) {
                 mCache.erase(mCache.begin());
             }
         }
         auto cache_entry = std::make_shared<CacheInfo>(gradient.mStops);
-        cache_entry->alpha = generateGradientColorTable(gradient.mStops,
-                                                        gradient.alpha(),
-                                                        cache_entry->buffer32,
-                                                        VGradient::colorTableSize);
+        cache_entry->alpha = generateGradientColorTable(
+            gradient.mStops, gradient.alpha(), cache_entry->buffer32,
+            VGradient::colorTableSize);
         mCache.insert(std::make_pair(hash_val, cache_entry));
         return cache_entry;
     }
@@ -133,7 +133,8 @@ protected:
     std::mutex              mMutex;
 };
 
-bool VGradientCache::generateGradientColorTable(const VGradientStops &stops, float opacity,
+bool VGradientCache::generateGradientColorTable(const VGradientStops &stops,
+                                                float                 opacity,
                                                 uint32_t *colorTable, int size)
 {
     int                  dist, idist, pos = 0, i;
@@ -496,8 +497,8 @@ void fetch_radial_gradient(uint32_t *buffer, const Operator *op,
     }
 }
 
-static inline Operator getOperator(const VSpanData * data,
-                                   const VRle::Span *, size_t)
+static inline Operator getOperator(const VSpanData *data, const VRle::Span *,
+                                   size_t)
 {
     Operator op;
     bool     solidSource = false;
@@ -532,7 +533,8 @@ static inline Operator getOperator(const VSpanData * data,
     return op;
 }
 
-static void blendColorARGB(size_t count, const VRle::Span *spans, void *userData)
+static void blendColorARGB(size_t count, const VRle::Span *spans,
+                           void *userData)
 {
     VSpanData *data = (VSpanData *)(userData);
     Operator   op = getOperator(data, spans, count);
@@ -587,25 +589,26 @@ static void blendGradientARGB(size_t count, const VRle::Span *spans,
     }
 }
 
-template<class T>
-constexpr const T& clamp( const T& v, const T& lo, const T& hi)
+template <class T>
+constexpr const T &clamp(const T &v, const T &lo, const T &hi)
 {
     return v < lo ? lo : hi < v ? hi : v;
 }
 
 static const int buffer_size = 1024;
 static const int fixed_scale = 1 << 16;
-static void blend_transformed_argb(size_t count, const VRle::Span *spans, void *userData)
+static void      blend_transformed_argb(size_t count, const VRle::Span *spans,
+                                        void *userData)
 {
     VSpanData *data = reinterpret_cast<VSpanData *>(userData);
-    if (data->mBitmap.format != VBitmap::Format::ARGB32_Premultiplied
-        && data->mBitmap.format != VBitmap::Format::ARGB32) {
+    if (data->mBitmap.format != VBitmap::Format::ARGB32_Premultiplied &&
+        data->mBitmap.format != VBitmap::Format::ARGB32) {
         //@TODO other formats not yet handled.
         return;
     }
 
     Operator op = getOperator(data, spans, count);
-    uint buffer[buffer_size];
+    uint     buffer[buffer_size];
 
     const int image_x1 = data->mBitmap.x1;
     const int image_y1 = data->mBitmap.y1;
@@ -623,21 +626,23 @@ static void blend_transformed_argb(size_t count, const VRle::Span *spans, void *
             const float cx = spans->x + float(0.5);
             const float cy = spans->y + float(0.5);
 
-            int x = int((data->m21 * cy
-                         + data->m11 * cx + data->dx) * fixed_scale);
-            int y = int((data->m22 * cy
-                         + data->m12 * cx + data->dy) * fixed_scale);
+            int x =
+                int((data->m21 * cy + data->m11 * cx + data->dx) * fixed_scale);
+            int y =
+                int((data->m22 * cy + data->m12 * cx + data->dy) * fixed_scale);
 
-            int length = spans->len;
-            const int coverage = (spans->coverage * data->mBitmap.const_alpha) >> 8;
+            int       length = spans->len;
+            const int coverage =
+                (spans->coverage * data->mBitmap.const_alpha) >> 8;
             while (length) {
-                int l = std::min(length, buffer_size);
+                int         l = std::min(length, buffer_size);
                 const uint *end = buffer + l;
-                uint *b = buffer;
+                uint *      b = buffer;
                 while (b < end) {
                     int px = clamp(x >> 16, image_x1, image_x2);
                     int py = clamp(y >> 16, image_y1, image_y2);
-                    *b = reinterpret_cast<const uint *>(data->mBitmap.scanLine(py))[px];
+                    *b = reinterpret_cast<const uint *>(
+                        data->mBitmap.scanLine(py))[px];
 
                     x += fdx;
                     y += fdy;
@@ -663,20 +668,24 @@ static void blend_transformed_argb(size_t count, const VRle::Span *spans, void *
             float y = data->m22 * cy + data->m12 * cx + data->dy;
             float w = data->m23 * cy + data->m13 * cx + data->m33;
 
-            int length = spans->len;
-            const int coverage = (spans->coverage * data->mBitmap.const_alpha) >> 8;
+            int       length = spans->len;
+            const int coverage =
+                (spans->coverage * data->mBitmap.const_alpha) >> 8;
             while (length) {
-                int l = std::min(length, buffer_size);
+                int         l = std::min(length, buffer_size);
                 const uint *end = buffer + l;
-                uint *b = buffer;
+                uint *      b = buffer;
                 while (b < end) {
                     const float iw = w == 0 ? 1 : 1 / w;
                     const float tx = x * iw;
                     const float ty = y * iw;
-                    const int px = clamp(int(tx) - (tx < 0), image_x1, image_x2);
-                    const int py = clamp(int(ty) - (ty < 0), image_y1, image_y2);
+                    const int   px =
+                        clamp(int(tx) - (tx < 0), image_x1, image_x2);
+                    const int py =
+                        clamp(int(ty) - (ty < 0), image_y1, image_y2);
 
-                    *b = reinterpret_cast<const uint *>(data->mBitmap.scanLine(py))[px];
+                    *b = reinterpret_cast<const uint *>(
+                        data->mBitmap.scanLine(py))[px];
                     x += fdx;
                     y += fdy;
                     w += fdw;
@@ -692,11 +701,12 @@ static void blend_transformed_argb(size_t count, const VRle::Span *spans, void *
     }
 }
 
-static void blend_untransformed_argb(size_t count, const VRle::Span *spans, void *userData)
+static void blend_untransformed_argb(size_t count, const VRle::Span *spans,
+                                     void *userData)
 {
     VSpanData *data = reinterpret_cast<VSpanData *>(userData);
-    if (data->mBitmap.format != VBitmap::Format::ARGB32_Premultiplied
-        && data->mBitmap.format != VBitmap::Format::ARGB32) {
+    if (data->mBitmap.format != VBitmap::Format::ARGB32_Premultiplied &&
+        data->mBitmap.format != VBitmap::Format::ARGB32) {
         //@TODO other formats not yet handled.
         return;
     }
@@ -720,12 +730,12 @@ static void blend_untransformed_argb(size_t count, const VRle::Span *spans, void
                 length += sx;
                 sx = 0;
             }
-            if (sx + length > image_width)
-                length = image_width - sx;
+            if (sx + length > image_width) length = image_width - sx;
             if (length > 0) {
-                const int coverage = (spans->coverage * data->mBitmap.const_alpha) >> 8;
+                const int coverage =
+                    (spans->coverage * data->mBitmap.const_alpha) >> 8;
                 const uint *src = (const uint *)data->mBitmap.scanLine(sy) + sx;
-                uint *dest = data->buffer(x, spans->y);
+                uint *      dest = data->buffer(x, spans->y);
                 op.func(dest, src, length, coverage);
             }
         }
@@ -776,8 +786,9 @@ void VSpanData::setup(const VBrush &brush, VPainter::CompositionMode /*mode*/,
     }
     case VBrush::Type::Texture: {
         mType = VSpanData::Type::Texture;
-        initTexture(&brush.mTexture, 255, VBitmapData::Plain,
-                    VRect(0, 0, brush.mTexture.width(), brush.mTexture.height()));
+        initTexture(
+            &brush.mTexture, 255, VBitmapData::Plain,
+            VRect(0, 0, brush.mTexture.width(), brush.mTexture.height()));
         setupMatrix(brush.mMatrix);
         break;
     }
@@ -801,19 +812,15 @@ void VSpanData::setupMatrix(const VMatrix &matrix)
     dy = inv.mty;
     transformType = inv.type();
 
-    const bool affine = inv.isAffine();
+    const bool  affine = inv.isAffine();
     const float f1 = m11 * m11 + m21 * m21;
     const float f2 = m12 * m12 + m22 * m22;
-    fast_matrix = affine
-        && f1 < 1e4
-        && f2 < 1e4
-        && f1 > (1.0 / 65536)
-        && f2 > (1.0 / 65536)
-        && fabs(dx) < 1e4
-        && fabs(dy) < 1e4;
+    fast_matrix = affine && f1 < 1e4 && f2 < 1e4 && f1 > (1.0 / 65536) &&
+                  f2 > (1.0 / 65536) && fabs(dx) < 1e4 && fabs(dy) < 1e4;
 }
 
-void VSpanData::initTexture(const VBitmap *bitmap, int alpha, VBitmapData::Type type, const VRect &sourceRect)
+void VSpanData::initTexture(const VBitmap *bitmap, int alpha,
+                            VBitmapData::Type type, const VRect &sourceRect)
 {
     mType = VSpanData::Type::Texture;
 
@@ -849,7 +856,7 @@ void VSpanData::updateSpanFunc()
     }
     case VSpanData::Type::Texture: {
         //@TODO update proper image function.
-        if (transformType <= VMatrix::MatrixType::Translate){
+        if (transformType <= VMatrix::MatrixType::Translate) {
             mUnclippedBlendFunc = &blend_untransformed_argb;
         } else {
             mUnclippedBlendFunc = &blend_transformed_argb;
index 806a8b566f228b93052ccc68630c21e772bd2460..25a2fed5f1f1632bf18729f3496f767395cc9399 100644 (file)
@@ -2,39 +2,26 @@
 
 #include "vdrawhelper.h"
 
-extern "C" void
-pixman_composite_src_n_8888_asm_neon (int32_t   w,
-                                      int32_t   h,
-                                      uint32_t *dst,
-                                      int32_t   dst_stride,
-                                      uint32_t  src);
+extern "C" void pixman_composite_src_n_8888_asm_neon(int32_t w, int32_t h,
+                                                     uint32_t *dst,
+                                                     int32_t   dst_stride,
+                                                     uint32_t  src);
 
-extern "C" void
-pixman_composite_over_n_8888_asm_neon(int32_t   w,
-                                      int32_t   h,
-                                      uint32_t *dst,
-                                      int32_t   dst_stride,
-                                      uint32_t  src);
+extern "C" void pixman_composite_over_n_8888_asm_neon(int32_t w, int32_t h,
+                                                      uint32_t *dst,
+                                                      int32_t   dst_stride,
+                                                      uint32_t  src);
 
 void memfill32(uint32_t *dest, uint32_t value, int length)
 {
-    pixman_composite_src_n_8888_asm_neon(length,
-                                         1,
-                                         dest,
-                                         length,
-                                         value);
+    pixman_composite_src_n_8888_asm_neon(length, 1, dest, length, value);
 }
 
-void
-comp_func_solid_SourceOver_neon(uint32_t *dest, int length, uint32_t color,
-                                uint32_t const_alpha)
+void comp_func_solid_SourceOver_neon(uint32_t *dest, int length, uint32_t color,
+                                     uint32_t const_alpha)
 {
     if (const_alpha != 255) color = BYTE_MUL(color, const_alpha);
 
-    pixman_composite_over_n_8888_asm_neon(length,
-                                          1,
-                                          dest,
-                                          length,
-                                          color);
+    pixman_composite_over_n_8888_asm_neon(length, 1, dest, length, color);
 }
 #endif
index 0dedda37a955b33b6d7c1f18a49f43c3e30e9b57..4c74027476a76ce68eb74940c9fa88a5cbc1be8a 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "velapsedtimer.h"
index 9592d073b8a4a0733d263d3a38bb9674f74b5836..4f3f84062b4c84dd7f715fc4f8757154f1847cd8 100644 (file)
@@ -1,6 +1,6 @@
 #include "vimageloader.h"
-#include "vdebug.h"
 #include "config.h"
+#include "vdebug.h"
 #ifndef WIN32
 #include <dlfcn.h>
 #else
 #endif
 #include <cstring>
 
-using lottie_image_load_f = unsigned char* (*)(const char *filename, int *x, int *y, int *comp, int req_comp);
-using lottie_image_load_data_f = unsigned char* (*)(const char  *data, int len, int *x, int *y, int *comp, int req_comp);
+using lottie_image_load_f = unsigned char *(*)(const char *filename, int *x,
+                                               int *y, int *comp, int req_comp);
+using lottie_image_load_data_f = unsigned char *(*)(const char *data, int len,
+                                                    int *x, int *y, int *comp,
+                                                    int req_comp);
 using lottie_image_free_f = void (*)(unsigned char *);
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-extern unsigned char * lottie_image_load(char const *filename, int *x, int *y, int *comp, int req_comp);
-extern unsigned char * lottie_image_load_from_data(const char *imageData, int len, int *x, int *y, int *comp, int req_comp);
-extern void lottie_image_free(unsigned char *data);
+extern unsigned char *lottie_image_load(char const *filename, int *x, int *y,
+                                        int *comp, int req_comp);
+extern unsigned char *lottie_image_load_from_data(const char *imageData,
+                                                  int len, int *x, int *y,
+                                                  int *comp, int req_comp);
+extern void           lottie_image_free(unsigned char *data);
 
 #ifdef __cplusplus
 }
 #endif
 
-
-struct VImageLoader::Impl
-{
+struct VImageLoader::Impl {
     lottie_image_load_f      imageLoad{nullptr};
     lottie_image_free_f      imageFree{nullptr};
     lottie_image_load_data_f imageFromData{nullptr};
 
 #ifndef LOTTIE_STATIC_IMAGE_LOADER
 #ifdef WIN32
-    HMODULE                  dl_handle{ nullptr };
-    bool moduleLoad() {
+    HMODULE dl_handle{nullptr};
+    bool    moduleLoad()
+    {
         dl_handle = LoadLibraryA("librlottie-image-loader.dll");
         return (dl_handle == nullptr);
     }
-    void moduleFree() {
+    void moduleFree()
+    {
         if (dl_handle) FreeLibrary(dl_handle);
     }
-    void init() {
-        imageLoad = (lottie_image_load_f)GetProcAddress(dl_handle, "lottie_image_load");
-        imageFree = (lottie_image_free_f)GetProcAddress(dl_handle, "lottie_image_free");
-        imageFromData = (lottie_image_load_data_f)GetProcAddress(dl_handle, "lottie_image_load_from_data");
+    void init()
+    {
+        imageLoad =
+            (lottie_image_load_f)GetProcAddress(dl_handle, "lottie_image_load");
+        imageFree =
+            (lottie_image_free_f)GetProcAddress(dl_handle, "lottie_image_free");
+        imageFromData = (lottie_image_load_data_f)GetProcAddress(
+            dl_handle, "lottie_image_load_from_data");
     }
 #else
-    void                    *dl_handle{nullptr};
-    void init() {
-        imageLoad = (lottie_image_load_f) dlsym(dl_handle, "lottie_image_load");
-        imageFree = (lottie_image_free_f) dlsym(dl_handle, "lottie_image_free");
-        imageFromData = (lottie_image_load_data_f) dlsym(dl_handle, "lottie_image_load_from_data");
+    void *dl_handle{nullptr};
+    void  init()
+    {
+        imageLoad = (lottie_image_load_f)dlsym(dl_handle, "lottie_image_load");
+        imageFree = (lottie_image_free_f)dlsym(dl_handle, "lottie_image_free");
+        imageFromData = (lottie_image_load_data_f)dlsym(
+            dl_handle, "lottie_image_load_from_data");
     }
 
-    void moduleFree() {
+    void moduleFree()
+    {
         if (dl_handle) dlclose(dl_handle);
     }
 #ifdef __APPLE__
-    bool moduleLoad() {
+    bool moduleLoad()
+    {
         dl_handle = dlopen("librlottie-image-loader.dylib", RTLD_LAZY);
         return (dl_handle == nullptr);
     }
 #else
-    bool moduleLoad() {
+    bool moduleLoad()
+    {
         dl_handle = dlopen("librlottie-image-loader.so", RTLD_LAZY);
         return (dl_handle == nullptr);
     }
-#endif 
+#endif
 #endif
 #else
     void *dl_handle{nullptr};
-    void init() {
+    void  init()
+    {
         imageLoad = lottie_image_load;
         imageFree = lottie_image_free;
         imageFromData = lottie_image_load_from_data;
     }
     void moduleFree() {}
-    bool moduleLoad() {return false;}
+    bool moduleLoad() { return false; }
 #endif
 
-
     Impl()
     {
         if (moduleLoad()) {
-            vWarning<<"Failed to dlopen librlottie-image-loader library";
+            vWarning << "Failed to dlopen librlottie-image-loader library";
             return;
         }
-        
+
         init();
-               
+
         if (!imageLoad)
-            vWarning<<"Failed to find symbol lottie_image_load in librlottie-image-loader library";
+            vWarning << "Failed to find symbol lottie_image_load in "
+                        "librlottie-image-loader library";
 
         if (!imageFree)
-            vWarning<<"Failed to find symbol lottie_image_free in librlottie-image-loader library";
+            vWarning << "Failed to find symbol lottie_image_free in "
+                        "librlottie-image-loader library";
 
         if (!imageFromData)
-            vWarning<<"Failed to find symbol lottie_image_load_data in librlottie-image-loader library";
+            vWarning << "Failed to find symbol lottie_image_load_data in "
+                        "librlottie-image-loader library";
     }
 
-    ~Impl()
-    {  
-        moduleFree();
-    }
+    ~Impl() { moduleFree(); }
 
-    VBitmap createBitmap(unsigned char *data, int width, int height, int channel)
+    VBitmap createBitmap(unsigned char *data, int width, int height,
+                         int channel)
     {
         // premultiply alpha
         if (channel == 4)
@@ -114,7 +130,8 @@ struct VImageLoader::Impl
             convertToBGRA(data, width, height);
 
         // create a bitmap of same size.
-        VBitmap result = VBitmap(width, height, VBitmap::Format::ARGB32_Premultiplied);
+        VBitmap result =
+            VBitmap(width, height, VBitmap::Format::ARGB32_Premultiplied);
 
         // copy the data to bitmap buffer
         memcpy(result.data(), data, width * height * 4);
@@ -129,7 +146,7 @@ struct VImageLoader::Impl
     {
         if (!imageLoad) return VBitmap();
 
-        int width, height, n;
+        int            width, height, n;
         unsigned char *data = imageLoad(fileName, &width, &height, &n, 4);
 
         if (!data) {
@@ -143,8 +160,9 @@ struct VImageLoader::Impl
     {
         if (!imageFromData) return VBitmap();
 
-        int width, height, n;
-        unsigned char *data = imageFromData(imageData, len, &width, &height, &n, 4);
+        int            width, height, n;
+        unsigned char *data =
+            imageFromData(imageData, len, &width, &height, &n, 4);
 
         if (!data) {
             return VBitmap();
@@ -157,7 +175,7 @@ struct VImageLoader::Impl
      */
     void convertToBGRAPremul(unsigned char *bits, int width, int height)
     {
-        int pixelCount = width * height;
+        int            pixelCount = width * height;
         unsigned char *pix = bits;
         for (int i = 0; i < pixelCount; i++) {
             unsigned char r = pix[0];
@@ -181,7 +199,7 @@ struct VImageLoader::Impl
      */
     void convertToBGRA(unsigned char *bits, int width, int height)
     {
-        int pixelCount = width * height;
+        int            pixelCount = width * height;
         unsigned char *pix = bits;
         for (int i = 0; i < pixelCount; i++) {
             unsigned char r = pix[0];
@@ -193,11 +211,7 @@ struct VImageLoader::Impl
     }
 };
 
-VImageLoader::VImageLoader():
-    mImpl(std::make_unique<VImageLoader::Impl>())
-{
-
-}
+VImageLoader::VImageLoader() : mImpl(std::make_unique<VImageLoader::Impl>()) {}
 
 VImageLoader::~VImageLoader() {}
 
@@ -210,4 +224,3 @@ VBitmap VImageLoader::load(const char *data, int len)
 {
     return mImpl->load(data, len);
 }
-
index 36498b48387aa3490b04491f51bf7890175897d7..334e33e7dd3e3b6a8c4d5e07bef10332a42ce979 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vmatrix.h"
index 09cadc2e1ecd17ebaf39401cdfc5920dc5a85365..cdcaa11f439f0b7c5f5f2ffdbf70b5b4879fc913 100644 (file)
@@ -1,24 +1,24 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vpainter.h"
-#include "vdrawhelper.h"
 #include <algorithm>
+#include "vdrawhelper.h"
 
 V_BEGIN_NAMESPACE
 
@@ -26,8 +26,13 @@ class VPainterImpl {
 public:
     void drawRle(const VPoint &pos, const VRle &rle);
     void drawRle(const VRle &rle, const VRle &clip);
-    void setCompositionMode(VPainter::CompositionMode mode) { mSpanData.mCompositionMode = mode;}
-    void  drawBitmapUntransform(const VRect &target, const VBitmap &bitmap, const VRect &source, uint8_t const_alpha);
+    void setCompositionMode(VPainter::CompositionMode mode)
+    {
+        mSpanData.mCompositionMode = mode;
+    }
+    void drawBitmapUntransform(const VRect &target, const VBitmap &bitmap,
+                               const VRect &source, uint8_t const_alpha);
+
 public:
     VRasterBuffer mBuffer;
     VSpanData     mSpanData;
@@ -51,8 +56,7 @@ void VPainterImpl::drawRle(const VRle &rle, const VRle &clip)
 
     if (!mSpanData.mUnclippedBlendFunc) return;
 
-    rle.intersect(clip, mSpanData.mUnclippedBlendFunc,
-                  &mSpanData);
+    rle.intersect(clip, mSpanData.mUnclippedBlendFunc, &mSpanData);
 }
 
 static void fillRect(const VRect &r, VSpanData *data)
@@ -64,10 +68,9 @@ static void fillRect(const VRect &r, VSpanData *data)
     y1 = std::max(r.y(), 0);
     y2 = std::min(r.y() + r.height(), data->mDrawableSize.height());
 
-    if (x2 <= x1 || y2 <= y1)
-        return;
+    if (x2 <= x1 || y2 <= y1) return;
 
-    const int nspans = 256;
+    const int  nspans = 256;
     VRle::Span spans[nspans];
 
     int y = y1;
@@ -87,13 +90,13 @@ static void fillRect(const VRect &r, VSpanData *data)
     }
 }
 
-void  VPainterImpl::drawBitmapUntransform(const VRect &target,
-                                          const VBitmap &bitmap,
-                                          const VRect &source, uint8_t const_alpha)
+void VPainterImpl::drawBitmapUntransform(const VRect &  target,
+                                         const VBitmap &bitmap,
+                                         const VRect &  source,
+                                         uint8_t        const_alpha)
 {
     mSpanData.initTexture(&bitmap, const_alpha, VBitmapData::Plain, source);
-    if (!mSpanData.mUnclippedBlendFunc)
-        return;
+    if (!mSpanData.mUnclippedBlendFunc) return;
     mSpanData.dx = -target.x();
     mSpanData.dy = -target.y();
 
@@ -102,8 +105,6 @@ void  VPainterImpl::drawBitmapUntransform(const VRect &target,
     fillRect(rr, &mSpanData);
 }
 
-
-
 VPainter::~VPainter()
 {
     delete mImpl;
@@ -129,18 +130,17 @@ bool VPainter::begin(VBitmap *buffer)
 }
 void VPainter::end() {}
 
-void  VPainter::setDrawRegion(const VRect &region)
+void VPainter::setDrawRegion(const VRect &region)
 {
     mImpl->mSpanData.setDrawRegion(region);
 }
 
-
 void VPainter::setBrush(const VBrush &brush)
 {
     mImpl->mSpanData.setup(brush);
 }
 
-void  VPainter::setCompositionMode(CompositionMode mode)
+void VPainter::setCompositionMode(CompositionMode mode)
 {
     mImpl->setCompositionMode(mode);
 }
@@ -155,13 +155,13 @@ void VPainter::drawRle(const VRle &rle, const VRle &clip)
     mImpl->drawRle(rle, clip);
 }
 
-
 VRect VPainter::clipBoundingRect() const
 {
     return mImpl->mSpanData.clipRect();
 }
 
-void  VPainter::drawBitmap(const VPoint &point, const VBitmap &bitmap, const VRect &source, uint8_t const_alpha)
+void VPainter::drawBitmap(const VPoint &point, const VBitmap &bitmap,
+                          const VRect &source, uint8_t const_alpha)
 {
     if (!bitmap.valid()) return;
 
@@ -169,7 +169,8 @@ void  VPainter::drawBitmap(const VPoint &point, const VBitmap &bitmap, const VRe
                bitmap, source, const_alpha);
 }
 
-void  VPainter::drawBitmap(const VRect &target, const VBitmap &bitmap, const VRect &source, uint8_t const_alpha)
+void VPainter::drawBitmap(const VRect &target, const VBitmap &bitmap,
+                          const VRect &source, uint8_t const_alpha)
 {
     if (!bitmap.valid()) return;
 
@@ -183,19 +184,23 @@ void  VPainter::drawBitmap(const VRect &target, const VBitmap &bitmap, const VRe
     }
 }
 
-void  VPainter::drawBitmap(const VPoint &point, const VBitmap &bitmap, uint8_t const_alpha)
+void VPainter::drawBitmap(const VPoint &point, const VBitmap &bitmap,
+                          uint8_t const_alpha)
 {
     if (!bitmap.valid()) return;
 
     drawBitmap(VRect(point.x(), point.y(), bitmap.width(), bitmap.height()),
-               bitmap, VRect(0, 0, bitmap.width(), bitmap.height()), const_alpha);
+               bitmap, VRect(0, 0, bitmap.width(), bitmap.height()),
+               const_alpha);
 }
 
-void  VPainter::drawBitmap(const VRect &rect, const VBitmap &bitmap, uint8_t const_alpha)
+void VPainter::drawBitmap(const VRect &rect, const VBitmap &bitmap,
+                          uint8_t const_alpha)
 {
     if (!bitmap.valid()) return;
 
-    drawBitmap(rect, bitmap, VRect(0, 0, bitmap.width(), bitmap.height()), const_alpha);
+    drawBitmap(rect, bitmap, VRect(0, 0, bitmap.width(), bitmap.height()),
+               const_alpha);
 }
 
 V_END_NAMESPACE
index 14f260c7a7b289795d8bf5e21510200fbd77f17d..a82cbdf2cd9c359004a4e88b4463e90b0f02644d 100644 (file)
@@ -1,29 +1,29 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vpath.h"
 #include <cassert>
+#include <iterator>
 #include <vector>
-#include <iterator> 
 #include "vbezier.h"
 #include "vdebug.h"
-#include "vrect.h"
 #include "vline.h"
+#include "vrect.h"
 
 V_BEGIN_NAMESPACE
 
@@ -49,13 +49,14 @@ float VPath::VPathData::length() const
             i++;
             break;
         case VPath::Element::LineTo: {
-            mLength += VLine( m_points[i-1], m_points[i]).length();
+            mLength += VLine(m_points[i - 1], m_points[i]).length();
             i++;
             break;
         }
         case VPath::Element::CubicTo: {
-            mLength += VBezier::fromPoints(m_points[i-1], m_points[i],
-                                       m_points[i+1], m_points[i+2]).length();
+            mLength += VBezier::fromPoints(m_points[i - 1], m_points[i],
+                                           m_points[i + 1], m_points[i + 2])
+                           .length();
             i += 3;
             break;
         }
@@ -75,26 +76,26 @@ void VPath::VPathData::checkNewSegment()
     }
 }
 
-void  VPath::VPathData::moveTo(float x, float y)
+void VPath::VPathData::moveTo(float x, float y)
 {
     mStartPoint = {x, y};
     mNewSegment = false;
     m_elements.emplace_back(VPath::Element::MoveTo);
-    m_points.emplace_back(x,y);
+    m_points.emplace_back(x, y);
     m_segments++;
     mLengthDirty = true;
 }
 
-void  VPath::VPathData::lineTo(float x, float y)
+void VPath::VPathData::lineTo(float x, float y)
 {
     checkNewSegment();
     m_elements.emplace_back(VPath::Element::LineTo);
-    m_points.emplace_back(x,y);
+    m_points.emplace_back(x, y);
     mLengthDirty = true;
 }
 
-void  VPath::VPathData::cubicTo(float cx1, float cy1, float cx2, float cy2,
-                                float ex, float ey)
+void VPath::VPathData::cubicTo(float cx1, float cy1, float cx2, float cy2,
+                               float ex, float ey)
 {
     checkNewSegment();
     m_elements.emplace_back(VPath::Element::CubicTo);
@@ -148,7 +149,7 @@ static constexpr float K_PI = float(M_PI);
 void VPath::VPathData::arcTo(const VRectF &rect, float startAngle,
                              float sweepLength, bool forceMoveTo)
 {
-    size_t     point_count = 0;
+    size_t  point_count = 0;
     VPointF pts[15];
     VPointF curve_start =
         curvesForArc(rect, startAngle, sweepLength, pts, &point_count);
@@ -191,32 +192,24 @@ void VPath::VPathData::addOval(const VRectF &rect, VPath::Direction dir)
         // moveto 12 o'clock.
         moveTo(x + w2, y);
         // 12 -> 3 o'clock
-        cubicTo(x + w2 + w2k, y, x + w, y + h2 - h2k,
-                x + w, y + h2);
+        cubicTo(x + w2 + w2k, y, x + w, y + h2 - h2k, x + w, y + h2);
         // 3 -> 6 o'clock
-        cubicTo(x + w, y + h2 + h2k, x + w2 + w2k, y + h,
-                x + w2, y + h);
+        cubicTo(x + w, y + h2 + h2k, x + w2 + w2k, y + h, x + w2, y + h);
         // 6 -> 9 o'clock
-        cubicTo(x + w2 - w2k, y + h, x, y + h2 + h2k,
-                x, y + h2);
+        cubicTo(x + w2 - w2k, y + h, x, y + h2 + h2k, x, y + h2);
         // 9 -> 12 o'clock
-        cubicTo(x, y + h2 - h2k, x + w2 - w2k, y,
-                x + w2, y);
+        cubicTo(x, y + h2 - h2k, x + w2 - w2k, y, x + w2, y);
     } else {
         // moveto 12 o'clock.
         moveTo(x + w2, y);
         // 12 -> 9 o'clock
-        cubicTo(x + w2 - w2k, y, x, y + h2 - h2k,
-                x, y + h2);
+        cubicTo(x + w2 - w2k, y, x, y + h2 - h2k, x, y + h2);
         // 9 -> 6 o'clock
-        cubicTo(x, y + h2 + h2k, x + w2 - w2k, y + h,
-                x + w2, y + h);
+        cubicTo(x, y + h2 + h2k, x + w2 - w2k, y + h, x + w2, y + h);
         // 6 -> 3 o'clock
-        cubicTo(x + w2 + w2k, y + h, x + w, y + h2 + h2k,
-                x + w, y + h2);
+        cubicTo(x + w2 + w2k, y + h, x + w, y + h2 + h2k, x + w, y + h2);
         // 3 -> 12 o'clock
-        cubicTo(x + w, y + h2 - h2k, x + w2 + w2k, y,
-                x + w2, y);
+        cubicTo(x + w, y + h2 - h2k, x + w2 + w2k, y, x + w2, y);
     }
     close();
 }
@@ -249,8 +242,8 @@ void VPath::VPathData::addRect(const VRectF &rect, VPath::Direction dir)
 void VPath::VPathData::addRoundRect(const VRectF &rect, float roundness,
                                     VPath::Direction dir)
 {
-    if (2 * roundness > rect.width()) roundness = rect.width()/2.0f;
-    if (2 * roundness > rect.height()) roundness = rect.height()/2.0f;
+    if (2 * roundness > rect.width()) roundness = rect.width() / 2.0f;
+    if (2 * roundness > rect.height()) roundness = rect.height() / 2.0f;
     addRoundRect(rect, roundness, roundness, dir);
 }
 
@@ -608,9 +601,8 @@ void VPath::VPathData::addPolystar(float points, float innerRadius,
                 cp2y *= partialPointAmount;
             }
 
-            cubicTo(previousX - cp1x + cx, previousY - cp1y + cy,
-                    x + cp2x + cx, y + cp2y + cy,
-                    x + cx, y + cy);
+            cubicTo(previousX - cp1x + cx, previousY - cp1y + cy, x + cp2x + cx,
+                    y + cp2y + cy, x + cx, y + cy);
         } else {
             lineTo(x + cx, y + cy);
         }
@@ -672,8 +664,8 @@ void VPath::VPathData::addPolygon(float points, float radius, float roundness,
             float cp2x = radius * roundness * POLYGON_MAGIC_NUMBER * cp2Dx;
             float cp2y = radius * roundness * POLYGON_MAGIC_NUMBER * cp2Dy;
 
-            cubicTo(previousX - cp1x + cx, previousY - cp1y + cy,
-                    x + cp2x + cx, y + cp2y + cy, x, y);
+            cubicTo(previousX - cp1x + cx, previousY - cp1y + cy, x + cp2x + cx,
+                    y + cp2y + cy, x, y);
         } else {
             lineTo(x + cx, y + cy);
         }
@@ -695,8 +687,10 @@ void VPath::VPathData::addPath(const VPathData &path)
     if (m_elements.capacity() < m_elements.size() + path.m_elements.size())
         m_elements.reserve(m_elements.size() + path.m_elements.size());
 
-    std::copy(path.m_points.begin(), path.m_points.end(), back_inserter(m_points));
-    std::copy(path.m_elements.begin(), path.m_elements.end(), back_inserter(m_elements));
+    std::copy(path.m_points.begin(), path.m_points.end(),
+              back_inserter(m_points));
+    std::copy(path.m_elements.begin(), path.m_elements.end(),
+              back_inserter(m_elements));
 
     m_segments += segment;
     mLengthDirty = true;
index 2aa4227d97b99b2979e22311fb4dbe28f03cac02..f0f305b075a7ff4820338c486ab93c907321d19b 100644 (file)
@@ -1,25 +1,25 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vpathmesure.h"
+#include <limits>
 #include "vbezier.h"
 #include "vdasher.h"
-#include <limits>
 
 V_BEGIN_NAMESPACE
 
@@ -34,20 +34,25 @@ VPath VPathMesure::trim(const VPath &path)
     if (vCompare(mStart, mEnd)) return VPath();
 
     if ((vCompare(mStart, 0.0f) && (vCompare(mEnd, 1.0f))) ||
-        (vCompare(mStart, 1.0f) && (vCompare(mEnd, 0.0f)))) return path;
+        (vCompare(mStart, 1.0f) && (vCompare(mEnd, 0.0f))))
+        return path;
 
     float length = path.length();
 
     if (mStart < mEnd) {
-        float   array[4] = {0.0f, length * mStart, //1st segment
-                            (mEnd - mStart) * length, std::numeric_limits<float>::max(), //2nd segment
-                           };
+        float array[4] = {
+            0.0f, length * mStart,  // 1st segment
+            (mEnd - mStart) * length,
+            std::numeric_limits<float>::max(),  // 2nd segment
+        };
         VDasher dasher(array, 4);
         return dasher.dashed(path);
     } else {
-        float   array[4] = {length * mEnd, (mStart - mEnd) * length, //1st segment
-                            (1 - mStart) * length, std::numeric_limits<float>::max(), //2nd segment
-                           };
+        float array[4] = {
+            length * mEnd, (mStart - mEnd) * length,  // 1st segment
+            (1 - mStart) * length,
+            std::numeric_limits<float>::max(),  // 2nd segment
+        };
         VDasher dasher(array, 4);
         return dasher.dashed(path);
     }
index 3a47b2cafb941fc31083958f1e48c25e37a4dc27..3f24e3dd70ffbc56a0aaeed560ed186c0c2e5f26 100644 (file)
@@ -1,50 +1,53 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vraster.h"
 #include <cstring>
 #include <memory>
+#include "config.h"
 #include "v_ft_raster.h"
 #include "v_ft_stroker.h"
 #include "vdebug.h"
 #include "vmatrix.h"
 #include "vpath.h"
 #include "vrle.h"
-#include "config.h"
 
 V_BEGIN_NAMESPACE
 
-template<typename T>
-class dyn_array
-{
+template <typename T>
+class dyn_array {
 public:
-    explicit dyn_array(size_t size):mCapacity(size),mData(std::make_unique<T[]>(mCapacity)){}
+    explicit dyn_array(size_t size)
+        : mCapacity(size), mData(std::make_unique<T[]>(mCapacity))
+    {
+    }
     void reserve(size_t size)
     {
         if (mCapacity > size) return;
         mCapacity = size;
         mData = std::make_unique<T[]>(mCapacity);
     }
-    T* data() const {return mData.get();}
-    dyn_array& operator=(dyn_array &&) noexcept = delete;
+    T *        data() const { return mData.get(); }
+    dyn_array &operator=(dyn_array &&) noexcept = delete;
+
 private:
-    size_t                 mCapacity{0};
-    std::unique_ptr<T[]>   mData{nullptr};
+    size_t               mCapacity{0};
+    std::unique_ptr<T[]> mData{nullptr};
 };
 
 struct FTOutline {
@@ -59,13 +62,16 @@ public:
     void close();
     void end();
     void transform(const VMatrix &m);
-    SW_FT_Pos TO_FT_COORD(float x) { return SW_FT_Pos(x*64);}  // to freetype 26.6 coordinate.
-    SW_FT_Outline          ft;
-    bool                   closed{false};
-    SW_FT_Stroker_LineCap  ftCap;
-    SW_FT_Stroker_LineJoin ftJoin;
-    SW_FT_Fixed            ftWidth;
-    SW_FT_Fixed            ftMeterLimit;
+    SW_FT_Pos TO_FT_COORD(float x)
+    {
+        return SW_FT_Pos(x * 64);
+    }  // to freetype 26.6 coordinate.
+    SW_FT_Outline           ft;
+    bool                    closed{false};
+    SW_FT_Stroker_LineCap   ftCap;
+    SW_FT_Stroker_LineJoin  ftJoin;
+    SW_FT_Fixed             ftWidth;
+    SW_FT_Fixed             ftMeterLimit;
     dyn_array<SW_FT_Vector> mPointMemory{100};
     dyn_array<char>         mTagMemory{100};
     dyn_array<short>        mContourMemory{10};
@@ -235,63 +241,65 @@ void FTOutline::end()
 
 static void rleGenerationCb(int count, const SW_FT_Span *spans, void *user)
 {
-    VRle *      rle = static_cast<VRle *>(user);
+    VRle *rle = static_cast<VRle *>(user);
     auto *rleSpan = reinterpret_cast<const VRle::Span *>(spans);
     rle->addSpan(rleSpan, count);
 }
 
 static void bboxCb(int x, int y, int w, int h, void *user)
 {
-    VRle *      rle = static_cast<VRle *>(user);
+    VRle *rle = static_cast<VRle *>(user);
     rle->setBoundingRect({x, y, w, h});
 }
 
-
 class SharedRle {
 public:
     SharedRle() = default;
-    VRle& unsafe(){ return _rle;}
-    void notify() {
+    VRle &unsafe() { return _rle; }
+    void  notify()
+    {
         {
             std::lock_guard<std::mutex> lock(_mutex);
             _ready = true;
         }
         _cv.notify_one();
     }
-    VRle& get(){
-
+    VRle &get()
+    {
         if (!_pending) return _rle;
 
         std::unique_lock<std::mutex> lock(_mutex);
-        while(!_ready) _cv.wait(lock);
+        while (!_ready) _cv.wait(lock);
         _pending = false;
         return _rle;
     }
 
-    void reset() {
+    void reset()
+    {
         _ready = false;
         _pending = true;
     }
+
 private:
-    VRle                     _rle;
-    std::mutex               _mutex;
-    std::condition_variable  _cv;
-    bool                     _ready{true};
-    bool                     _pending{false};
+    VRle                    _rle;
+    std::mutex              _mutex;
+    std::condition_variable _cv;
+    bool                    _ready{true};
+    bool                    _pending{false};
 };
 
 struct VRleTask {
-    SharedRle     mRle;
-    VPath         mPath;
-    float         mStrokeWidth;
-    float         mMeterLimit;
-    VRect         mClip;
-    FillRule      mFillRule;
-    CapStyle      mCap;
-    JoinStyle     mJoin;
-    bool          mGenerateStroke;
-
-    VRle& rle() { return mRle.get();}
+    SharedRle mRle;
+    VPath     mPath;
+    float     mStrokeWidth;
+    float     mMeterLimit;
+    VRect     mClip;
+    FillRule  mFillRule;
+    CapStyle  mCap;
+    JoinStyle mJoin;
+    bool      mGenerateStroke;
+
+    VRle &rle() { return mRle.get(); }
 
     void update(VPath path, FillRule fillRule, const VRect &clip)
     {
@@ -302,7 +310,8 @@ struct VRleTask {
         mGenerateStroke = false;
     }
 
-    void update(VPath path, CapStyle cap, JoinStyle join, float width, float meterLimit, const VRect &clip)
+    void update(VPath path, CapStyle cap, JoinStyle join, float width,
+                float meterLimit, const VRect &clip)
     {
         mRle.reset();
         mPath = std::move(path);
@@ -328,10 +337,10 @@ struct VRleTask {
         if (!mClip.empty()) {
             params.flags |= SW_FT_RASTER_FLAG_CLIP;
 
-            params.clip_box.xMin =  mClip.left();
-            params.clip_box.yMin =  mClip.top();
-            params.clip_box.xMax =  mClip.right();
-            params.clip_box.yMax =  mClip.bottom();
+            params.clip_box.xMin = mClip.left();
+            params.clip_box.yMin = mClip.top();
+            params.clip_box.xMax = mClip.right();
+            params.clip_box.yMax = mClip.bottom();
         }
         // compute rle
         sw_ft_grays_raster.raster_render(nullptr, &params);
@@ -345,8 +354,8 @@ struct VRleTask {
 
             uint points, contors;
 
-            SW_FT_Stroker_Set(stroker, outRef.ftWidth, outRef.ftCap, outRef.ftJoin,
-                              outRef.ftMeterLimit);
+            SW_FT_Stroker_Set(stroker, outRef.ftWidth, outRef.ftCap,
+                              outRef.ftJoin, outRef.ftMeterLimit);
             SW_FT_Stroker_ParseOutline(stroker, &outRef.ft);
             SW_FT_Stroker_GetCounts(stroker, &points, &contors);
 
@@ -380,14 +389,14 @@ using VTask = std::shared_ptr<VRleTask>;
 
 #ifdef LOTTIE_THREAD_SUPPORT
 
-#include "vtaskqueue.h"
 #include <thread>
+#include "vtaskqueue.h"
 
 class RleTaskScheduler {
-    const unsigned                  _count{std::thread::hardware_concurrency()};
-    std::vector<std::thread>        _threads;
-    std::vector<TaskQueue<VTask>>   _q{_count};
-    std::atomic<unsigned>           _index{0};
+    const unsigned                _count{std::thread::hardware_concurrency()};
+    std::vector<std::thread>      _threads;
+    std::vector<TaskQueue<VTask>> _q{_count};
+    std::atomic<unsigned>         _index{0};
 
     void run(unsigned i)
     {
@@ -425,11 +434,12 @@ class RleTaskScheduler {
             _threads.emplace_back([&, n] { run(n); });
         }
     }
+
 public:
-    static RleTaskSchedulerinstance()
+    static RleTaskScheduler &instance()
     {
-         static RleTaskScheduler singleton;
-         return singleton;
+        static RleTaskScheduler singleton;
+        return singleton;
     }
 
     ~RleTaskScheduler()
@@ -459,48 +469,38 @@ class RleTaskScheduler {
 public:
     FTOutline     outlineRef;
     SW_FT_Stroker stroker;
+
 public:
-    static RleTaskSchedulerinstance()
+    static RleTaskScheduler &instance()
     {
-         static RleTaskScheduler singleton;
-         return singleton;
+        static RleTaskScheduler singleton;
+        return singleton;
     }
 
-    RleTaskScheduler()
-    {
-        SW_FT_Stroker_New(&stroker);
-    }
+    RleTaskScheduler() { SW_FT_Stroker_New(&stroker); }
 
-    ~RleTaskScheduler()
-    {
-        SW_FT_Stroker_Done(stroker);
-    }
+    ~RleTaskScheduler() { SW_FT_Stroker_Done(stroker); }
 
-    void process(VTask task)
-    {
-        (*task)(outlineRef, stroker);
-    }
+    void process(VTask task) { (*task)(outlineRef, stroker); }
 };
 #endif
 
-
-struct VRasterizer::VRasterizerImpl
-{
+struct VRasterizer::VRasterizerImpl {
     VRleTask mTask;
 
-    VRle& rle(){ return mTask.rle(); }
-    VRleTask& task(){ return mTask; }
+    VRle &    rle() { return mTask.rle(); }
+    VRleTask &task() { return mTask; }
 };
 
 VRle VRasterizer::rle()
 {
-    if(!d) return VRle();
+    if (!d) return VRle();
     return d->rle();
 }
 
 void VRasterizer::init()
 {
-    if(!d) d = std::make_shared<VRasterizerImpl>();
+    if (!d) d = std::make_shared<VRasterizerImpl>();
 }
 
 void VRasterizer::updateRequest()
@@ -520,7 +520,8 @@ void VRasterizer::rasterize(VPath path, FillRule fillRule, const VRect &clip)
     updateRequest();
 }
 
-void VRasterizer::rasterize(VPath path, CapStyle cap, JoinStyle join, float width, float meterLimit, const VRect &clip)
+void VRasterizer::rasterize(VPath path, CapStyle cap, JoinStyle join,
+                            float width, float meterLimit, const VRect &clip)
 {
     init();
     if (path.empty() || vIsZero(width)) {
index 2180009de3e8cbed9037157f2929ce56d91c8c50..bc5b008735ffee952a47da51963b7dc8cbd34e9f 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vrect.h"
@@ -21,8 +21,7 @@
 
 VRect VRect::operator&(const VRect &r) const
 {
-    if (empty())
-        return VRect();
+    if (empty()) return VRect();
 
     int l1 = x1;
     int r1 = x1;
@@ -38,8 +37,7 @@ VRect VRect::operator&(const VRect &r) const
     else
         r2 = r.x2;
 
-    if (l1 > r2 || l2 > r1)
-        return VRect();
+    if (l1 > r2 || l2 > r1) return VRect();
 
     int t1 = y1;
     int b1 = y1;
@@ -55,8 +53,7 @@ VRect VRect::operator&(const VRect &r) const
     else
         b2 = r.y2;
 
-    if (t1 > b2 || t2 > b1)
-        return VRect();
+    if (t1 > b2 || t2 > b1) return VRect();
 
     VRect tmp;
     tmp.x1 = std::max(l1, l2);
index e3373464e2032c9211b80b3ac795d1733927c70b..988ea3af483fce36dacdc73b6f78f11fbf3d0fc5 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include "vrle.h"
 
 V_BEGIN_NAMESPACE
 
-enum class Operation {
-    Add,
-    Xor
-};
+enum class Operation { Add, Xor };
 
 struct VRleHelper {
     size_t      alloc;
@@ -41,7 +38,8 @@ struct VRleHelper {
 static void rleIntersectWithRle(VRleHelper *, int, int, VRleHelper *,
                                 VRleHelper *);
 static void rleIntersectWithRect(const VRect &, VRleHelper *, VRleHelper *);
-static void rleOpGeneric(VRleHelper *, VRleHelper *, VRleHelper *, Operation op);
+static void rleOpGeneric(VRleHelper *, VRleHelper *, VRleHelper *,
+                         Operation op);
 static void rleSubstractWithRle(VRleHelper *, VRleHelper *, VRleHelper *);
 
 static inline uchar divBy255(int x)
@@ -128,7 +126,7 @@ void VRle::VRleData::updateBbox() const
 
     mBboxDirty = false;
 
-    int l = std::numeric_limits<int>::max();
+    int               l = std::numeric_limits<int>::max();
     const VRle::Span *span = mSpans.data();
 
     mBbox = VRect();
@@ -170,7 +168,7 @@ void VRle::VRleData::opIntersect(const VRect &r, VRle::VRleSpanCb cb,
         return;
     }
 
-    VRect clip = r;
+    VRect                       clip = r;
     VRleHelper                  tresult, tmp_obj;
     std::array<VRle::Span, 256> array;
 
@@ -247,7 +245,8 @@ void VRle::VRleData::opSubstract(const VRle::VRleData &a,
     mBboxDirty = true;
 }
 
-void VRle::VRleData::opGeneric(const VRle::VRleData &a, const VRle::VRleData &b, OpCode code)
+void VRle::VRleData::opGeneric(const VRle::VRleData &a, const VRle::VRleData &b,
+                               OpCode code)
 {
     // This routine assumes, obj1(span_y) < obj2(span_y).
 
@@ -325,14 +324,13 @@ void VRle::VRleData::opGeneric(const VRle::VRleData &a, const VRle::VRleData &b,
     mBboxDirty = false;
 }
 
-static void  rle_cb(size_t count, const VRle::Span *spans, void *userData)
+static void rle_cb(size_t count, const VRle::Span *spans, void *userData)
 {
     auto vector = static_cast<std::vector<VRle::Span> *>(userData);
     copyArrayToVector(spans, count, *vector);
 }
 
-void opIntersectHelper(const VRle::VRleData &obj1,
-                       const VRle::VRleData &obj2,
+void opIntersectHelper(const VRle::VRleData &obj1, const VRle::VRleData &obj2,
                        VRle::VRleSpanCb cb, void *userData)
 {
     VRleHelper                  result, source, clip;
@@ -368,7 +366,6 @@ void VRle::VRleData::opIntersect(const VRle::VRleData &obj1,
     updateBbox();
 }
 
-
 #define VMIN(a, b) ((a) < (b) ? (a) : (b))
 #define VMAX(a, b) ((a) > (b) ? (a) : (b))
 
@@ -506,16 +503,16 @@ static void rleIntersectWithRect(const VRect &clip, VRleHelper *tmp_obj,
     result->size = result->alloc - available;
 }
 
-void blitXor(VRle::Span *spans, int count, uchar *buffer,
-                        int offsetX)
+void blitXor(VRle::Span *spans, int count, uchar *buffer, int offsetX)
 {
     while (count--) {
-        int x = spans->x + offsetX;
-        int l = spans->len;
+        int    x = spans->x + offsetX;
+        int    l = spans->len;
         uchar *ptr = buffer + x;
         while (l--) {
             int da = *ptr;
-            *ptr = divBy255((255 - spans->coverage) * (da) + spans->coverage * (255 - da));
+            *ptr = divBy255((255 - spans->coverage) * (da) +
+                            spans->coverage * (255 - da));
             ptr++;
         }
         spans++;
@@ -526,8 +523,8 @@ void blitDestinationOut(VRle::Span *spans, int count, uchar *buffer,
                         int offsetX)
 {
     while (count--) {
-        int x = spans->x + offsetX;
-        int l = spans->len;
+        int    x = spans->x + offsetX;
+        int    l = spans->len;
         uchar *ptr = buffer + x;
         while (l--) {
             *ptr = divBy255((255 - spans->coverage) * (*ptr));
@@ -540,8 +537,8 @@ void blitDestinationOut(VRle::Span *spans, int count, uchar *buffer,
 void blitSrcOver(VRle::Span *spans, int count, uchar *buffer, int offsetX)
 {
     while (count--) {
-        int x = spans->x + offsetX;
-        int l = spans->len;
+        int    x = spans->x + offsetX;
+        int    l = spans->len;
         uchar *ptr = buffer + x;
         while (l--) {
             *ptr = spans->coverage + divBy255((255 - spans->coverage) * (*ptr));
@@ -554,8 +551,8 @@ void blitSrcOver(VRle::Span *spans, int count, uchar *buffer, int offsetX)
 void blit(VRle::Span *spans, int count, uchar *buffer, int offsetX)
 {
     while (count--) {
-        int x = spans->x + offsetX;
-        int l = spans->len;
+        int    x = spans->x + offsetX;
+        int    l = spans->len;
         uchar *ptr = buffer + x;
         while (l--) {
             *ptr = std::max(spans->coverage, *ptr);
@@ -567,9 +564,9 @@ void blit(VRle::Span *spans, int count, uchar *buffer, int offsetX)
 
 size_t bufferToRle(uchar *buffer, int size, int offsetX, int y, VRle::Span *out)
 {
-    size_t   count = 0;
-    uchar value = buffer[0];
-    int   curIndex = 0;
+    size_t count = 0;
+    uchar  value = buffer[0];
+    int    curIndex = 0;
 
     size = offsetX < 0 ? size + offsetX : size;
     for (int i = 0; i < size; i++) {
@@ -598,7 +595,8 @@ size_t bufferToRle(uchar *buffer, int size, int offsetX, int y, VRle::Span *out)
     return count;
 }
 
-static void rleOpGeneric(VRleHelper *a, VRleHelper *b, VRleHelper *result, Operation op)
+static void rleOpGeneric(VRleHelper *a, VRleHelper *b, VRleHelper *result,
+                         Operation op)
 {
     std::array<VRle::Span, 256> temp;
     VRle::Span *                out = result->spans;
@@ -636,7 +634,7 @@ static void rleOpGeneric(VRleHelper *a, VRleHelper *b, VRleHelper *result, Opera
                 blitXor(bStart, (bPtr - bStart), array.data(), -offset);
             VRle::Span *tResult = temp.data();
             size_t size = bufferToRle(array.data(), std::max(aLength, bLength),
-                                   offset, y, tResult);
+                                      offset, y, tResult);
             if (available >= size) {
                 while (size--) {
                     *out++ = *tResult++;
@@ -696,7 +694,7 @@ static void rleSubstractWithRle(VRleHelper *a, VRleHelper *b,
             blitDestinationOut(bStart, (bPtr - bStart), array.data(), -offset);
             VRle::Span *tResult = temp.data();
             size_t size = bufferToRle(array.data(), std::max(aLength, bLength),
-                                   offset, y, tResult);
+                                      offset, y, tResult);
             if (available >= size) {
                 while (size--) {
                     *out++ = *tResult++;