binding/c: more compatible with C compiler. 70/187270/11
authorHermet Park <hermetpark@gmail.com>
Tue, 21 Aug 2018 10:20:53 +0000 (19:20 +0900)
committerSubhransu Mohanty <sub.mohanty@samsung.com>
Wed, 22 Aug 2018 04:53:44 +0000 (04:53 +0000)
Change-Id: I9fea4817cc913913f65c4b228cb0a42aae2cb2f8

example/lottieview.cpp
inc/lotcommon.h
src/binding/c/lotplayer_capi.h
src/binding/c/lottieplayer_c.cpp
src/lottie/lottieitem.cpp

index 9025db4357e98cf3fab2cb39d92c956a4ed8de6b..f52b7f83f66bf333e9a5b7afe09e0dabddec39c9 100644 (file)
@@ -56,7 +56,7 @@ void LottieView::createVgNode(LOTNode *node, Efl_VG *parent)
         //evas_vg_shape_stroke_meter_limit_set(shape, node->mStroke.meterLimit);
     }
     // update paint info
-    if (node->mType == LOTNode::BrushSolid) {
+    if (node->mType == LOTBrushType::BrushSolid) {
         int r = (node->mColor.r * node->mColor.a)/255;
         int g = (node->mColor.g * node->mColor.a)/255;
         int b = (node->mColor.b * node->mColor.a)/255;
@@ -67,7 +67,7 @@ void LottieView::createVgNode(LOTNode *node, Efl_VG *parent)
            evas_vg_node_color_set(shape, r, g, b, a);
         }
 
-    } else if (node->mType == LOTNode::BrushGradient) {
+    } else if (node->mType == LOTBrushType::BrushGradient) {
         //TODO fill the gradient info
     }
 }
index 8223df1f32bf13f3a4ac77855138c86e00246a53..aa24423019ef4d46af033f59ccb8e0f2c7abe856 100644 (file)
@@ -29,6 +29,7 @@
  */
 typedef enum
 {
+   //TODO: Coding convention??
     LOT_PLAYER_ERROR_NONE = 0,
     LOT_PLAYER_ERROR_NOT_PERMITTED,
     LOT_PLAYER_ERROR_OUT_OF_MEMORY,
@@ -36,8 +37,39 @@ typedef enum
     LOT_PLAYER_ERROR_RESULT_OUT_OF_RANGE,
     LOT_PLAYER_ERROR_ALREADY_IN_PROGRESS,
     LOT_PLAYER_ERROR_UNKNOWN
-} lotplayer_error_e;
+} LOTErrorType;
 
+typedef enum
+{
+    BrushSolid = 0,
+    BrushGradient
+} LOTBrushType;
+
+typedef enum
+{
+    FillEvenOdd = 0,
+    FillWinding
+} LOTFillRule;
+
+typedef enum
+{
+    JoinMiter = 0,
+    JoinBevel,
+    JoinRound
+} LOTJoinStyle;
+
+typedef enum
+{
+    CapFlat = 0,
+    CapSquare,
+    CapRound
+} LOTCapStyle;
+
+typedef enum
+{
+    GradientLinear = 0,
+    GradientRadial
+} LOTGradientType;
 
 typedef struct LOTNode {
 
@@ -46,50 +78,40 @@ typedef struct LOTNode {
 #define ChangeFlagPaint 0x0010
 #define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint)
 
-    enum BrushType { BrushSolid, BrushGradient };
-    enum FillRule { EvenOdd, Winding };
-    enum JoinStyle { MiterJoin, BevelJoin, RoundJoin };
-    enum CapStyle { FlatCap, SquareCap, RoundCap };
-
-    struct PathData {
+    struct {
         const float *ptPtr;
         int          ptCount;
         const char*  elmPtr;
         int          elmCount;
-    };
+    } mPath;
 
-    struct Color {
+    struct {
         unsigned char r, g, b, a;
-    };
+    } mColor;
 
-    struct Stroke {
+    struct {
         bool      enable;
         int       width;
-        CapStyle  cap;
-        JoinStyle join;
+        LOTCapStyle  cap;
+        LOTJoinStyle join;
         int       meterLimit;
         float*    dashArray;
         int       dashArraySize;
-    };
+    } mStroke;
 
-    struct Gradient {
-        enum Type { Linear = 1, Radial = 2 };
-        Gradient::Type type;
+    struct {
+        LOTGradientType type;
         struct {
             float x, y;
         } start, end, center, focal;
         float cradius;
         float fradius;
-    };
+    } mGradient;
 
     int       mFlag;
-    BrushType mType;
-    FillRule  mFillRule;
-    PathData  mPath;
-    Color     mColor;
-    Stroke    mStroke;
-    Gradient  mGradient;
-} lotnode;
+    LOTBrushType mType;
+    LOTFillRule  mFillRule;
+} LOTNode;
 
 typedef struct LOTBuffer {
     uint32_t *buffer;
@@ -97,6 +119,6 @@ typedef struct LOTBuffer {
     int       height;
     int       bytesPerLine;
     bool      clear;
-} lotbuf;
+} LOTBuffer;
 
 #endif  // _LOT_COMMON_H_
index ccf679e52dfa4a1e47dfab1268f920b6bffa11d1..ab8230b853edd3d8e6482d3e43fcbc134260c3dd 100644 (file)
@@ -1,23 +1,26 @@
 #ifndef _LOTPLAYER_CAPI_H_
 #define _LOTPLAYER_CAPI_H_
 
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
 #include <lotcommon.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef struct lotplayer_s lotplayer;
+typedef struct lotplayer_s LOTPlayer;
 
-LOT_EXPORT lotplayer *lotplayer_create(void);
-LOT_EXPORT int lotplayer_destroy(lotplayer *player);
-LOT_EXPORT int lotplayer_set_file(lotplayer *player, const char *file);
-LOT_EXPORT int lotplayer_set_size(lotplayer *player, int w, int h);
-LOT_EXPORT int lotplayer_get_size(const lotplayer *player, int* w, int* h);
-LOT_EXPORT float lotplayer_get_playtime(const lotplayer *player);
-LOT_EXPORT float lotplayer_get_pos(const lotplayer *player);
-LOT_EXPORT size_t lotplayer_get_node_count(const lotplayer *player, float pos);
-LOT_EXPORT const lotnode* lotplayer_get_node(lotplayer *player, float pos, size_t idx);
+LOT_EXPORT LOTPlayer *lotplayer_create(void);
+LOT_EXPORT int lotplayer_destroy(LOTPlayer *player);
+LOT_EXPORT int lotplayer_set_file(LOTPlayer *player, const char *file);
+LOT_EXPORT int lotplayer_set_size(LOTPlayer *player, int w, int h);
+LOT_EXPORT int lotplayer_get_size(const LOTPlayer *player, int* w, int* h);
+LOT_EXPORT float lotplayer_get_playtime(const LOTPlayer *player);
+LOT_EXPORT float lotplayer_get_pos(const LOTPlayer *player);
+LOT_EXPORT size_t lotplayer_get_node_count(const LOTPlayer *player, float pos);
+LOT_EXPORT const LOTNode* lotplayer_get_node(LOTPlayer *player, float pos, size_t idx);
 
 #ifdef __cplusplus
 }
index b3ee6a8e71ae3a1da97c9849b5ee2f4d8abcf381..93ee84320295b4aec8d23a9ce98e73f730689759 100644 (file)
@@ -1,22 +1,20 @@
 #include <lotplayer.h>
 #include "vdebug.h"
 
-extern "C" {
-
 using namespace lottieplayer;
 
-using lotplayer = LOTPlayer;
+extern "C" {
 
-LOT_EXPORT lotplayer *lotplayer_create(void)
+LOT_EXPORT LOTPlayer *lotplayer_create(void)
 {
-   lotplayer* p = new LOTPlayer();
+   LOTPlayer* p = new LOTPlayer();
    if (!p) {
       vCritical << "Failed to initialize lotplayer";
    }
    return p;
 }
 
-LOT_EXPORT int lotplayer_destroy(lotplayer *player)
+LOT_EXPORT int lotplayer_destroy(LOTPlayer *player)
 {
     if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER;
     delete(player);
@@ -24,7 +22,7 @@ LOT_EXPORT int lotplayer_destroy(lotplayer *player)
     return LOT_PLAYER_ERROR_NONE;
 }
 
-LOT_EXPORT int lotplayer_set_file(lotplayer *player, const char *file)
+LOT_EXPORT int lotplayer_set_file(LOTPlayer *player, const char *file)
 {
    if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER;
    bool ret = player->setFilePath(file);
@@ -34,7 +32,7 @@ LOT_EXPORT int lotplayer_set_file(lotplayer *player, const char *file)
    return LOT_PLAYER_ERROR_NONE;
 }
 
-LOT_EXPORT int lotplayer_set_size(lotplayer *player, int w, int h)
+LOT_EXPORT int lotplayer_set_size(LOTPlayer *player, int w, int h)
 {
    if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER;
 
@@ -43,7 +41,7 @@ LOT_EXPORT int lotplayer_set_size(lotplayer *player, int w, int h)
    return LOT_PLAYER_ERROR_NONE;
 }
 
-LOT_EXPORT int lotplayer_get_size(const lotplayer *player, int* w, int* h)
+LOT_EXPORT int lotplayer_get_size(const LOTPlayer *player, int* w, int* h)
 {
    if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER;
 
@@ -52,7 +50,7 @@ LOT_EXPORT int lotplayer_get_size(const lotplayer *player, int* w, int* h)
    return LOT_PLAYER_ERROR_NONE;
 }
 
-LOT_EXPORT float lotplayer_get_pos(const lotplayer *player)
+LOT_EXPORT float lotplayer_get_pos(const LOTPlayer *player)
 {
    if (!player) {
         vWarning << "Invalid parameter player = nullptr";
@@ -62,14 +60,14 @@ LOT_EXPORT float lotplayer_get_pos(const lotplayer *player)
    return player->pos();
 }
 
-LOT_EXPORT size_t lotplayer_get_node_count(const lotplayer *player, float pos)
+LOT_EXPORT size_t lotplayer_get_node_count(const LOTPlayer *player, float pos)
 {
    if (!player) return LOT_PLAYER_ERROR_NONE;
 
    return player->renderList(pos).size();
 }
 
-LOT_EXPORT float lotplayer_get_playtime(const lotplayer *player)
+LOT_EXPORT float lotplayer_get_playtime(const LOTPlayer *player)
 {
    if (!player) {
         vWarning << "Invalid parameter player = nullptr";
@@ -79,7 +77,7 @@ LOT_EXPORT float lotplayer_get_playtime(const lotplayer *player)
    return player->playTime();
 }
 
-LOT_EXPORT const lotnode* lotplayer_get_node(lotplayer *player, float pos, size_t idx)
+LOT_EXPORT const LOTNode* lotplayer_get_node(LOTPlayer *player, float pos, size_t idx)
 {
    if (!player) {
         vWarning << "Invalid parameter player = nullptr";
index dc0f2b468f0703dd94ff8a172c9595295dbf84ba..77f8544c7ad73c06d8eabb83c1754e49660ae2ab 100644 (file)
@@ -979,40 +979,40 @@ void LOTDrawable::sync()
 
         switch (mFillRule) {
         case FillRule::EvenOdd:
-            mCNode.mFillRule = LOTNode::EvenOdd;
+            mCNode.mFillRule = LOTFillRule::FillEvenOdd;
             break;
         default:
-            mCNode.mFillRule = LOTNode::Winding;
+            mCNode.mFillRule = LOTFillRule::FillWinding;
             break;
         }
 
         switch (mStroke.cap) {
         case CapStyle::Flat:
-            mCNode.mStroke.cap = LOTNode::FlatCap;
+            mCNode.mStroke.cap = LOTCapStyle::CapFlat;
             break;
         case CapStyle::Square:
-            mCNode.mStroke.cap = LOTNode::SquareCap;
+            mCNode.mStroke.cap = LOTCapStyle::CapSquare;
             break;
         case CapStyle::Round:
-            mCNode.mStroke.cap = LOTNode::RoundCap;
+            mCNode.mStroke.cap = LOTCapStyle::CapRound;
             break;
         default:
-            mCNode.mStroke.cap = LOTNode::FlatCap;
+            mCNode.mStroke.cap = LOTCapStyle::CapFlat;
             break;
         }
 
         switch (mStroke.join) {
         case JoinStyle::Miter:
-            mCNode.mStroke.join = LOTNode::MiterJoin;
+            mCNode.mStroke.join = LOTJoinStyle::JoinMiter;
             break;
         case JoinStyle::Bevel:
-            mCNode.mStroke.join = LOTNode::BevelJoin;
+            mCNode.mStroke.join = LOTJoinStyle::JoinBevel;
             break;
         case JoinStyle::Round:
-            mCNode.mStroke.join = LOTNode::RoundJoin;
+            mCNode.mStroke.join = LOTJoinStyle::JoinRound;
             break;
         default:
-            mCNode.mStroke.join = LOTNode::MiterJoin;
+            mCNode.mStroke.join = LOTJoinStyle::JoinMiter;
             break;
         }
 
@@ -1025,23 +1025,23 @@ void LOTDrawable::sync()
 
     switch (mBrush.type()) {
     case VBrush::Type::Solid:
-        mCNode.mType = LOTNode::BrushSolid;
+        mCNode.mType = LOTBrushType::BrushSolid;
         mCNode.mColor.r = mBrush.mColor.r;
         mCNode.mColor.g = mBrush.mColor.g;
         mCNode.mColor.b = mBrush.mColor.b;
         mCNode.mColor.a = mBrush.mColor.a;
         break;
     case VBrush::Type::LinearGradient:
-        mCNode.mType = LOTNode::BrushGradient;
-        mCNode.mGradient.type = LOTNode::Gradient::Linear;
+        mCNode.mType = LOTBrushType::BrushGradient;
+        mCNode.mGradient.type = LOTGradientType::GradientLinear;
         mCNode.mGradient.start.x = mBrush.mGradient->linear.x1;
         mCNode.mGradient.start.y = mBrush.mGradient->linear.y1;
         mCNode.mGradient.end.x = mBrush.mGradient->linear.x2;
         mCNode.mGradient.end.y = mBrush.mGradient->linear.y2;
         break;
     case VBrush::Type::RadialGradient:
-        mCNode.mType = LOTNode::BrushGradient;
-        mCNode.mGradient.type = LOTNode::Gradient::Radial;
+        mCNode.mType = LOTBrushType::BrushGradient;
+        mCNode.mGradient.type = LOTGradientType::GradientRadial;
         mCNode.mGradient.center.x = mBrush.mGradient->radial.cx;
         mCNode.mGradient.center.y = mBrush.mGradient->radial.cy;
         mCNode.mGradient.focal.x = mBrush.mGradient->radial.fx;