mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-15 18:59:54 +00:00
binding/c: more compatible with C compiler.
Change-Id: I9fea4817cc913913f65c4b228cb0a42aae2cb2f8
This commit is contained in:
parent
388736bfbe
commit
830ef02827
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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_
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user