Swiftgram/inc/lottieplayer.h
Hermet Park 9410d9e32d lottieplayer: code refactoring.
change type to struct and declare type scopes explicitly.

Change-Id: If85fbc97917ba324030c3e65765f315e590239ed
2018-08-14 03:29:35 +00:00

116 lines
2.3 KiB
C++

#ifndef LOTPLAYER_H
#define LOTPLAYER_H
#include <future>
#include <vector>
#ifdef _WIN32
#ifdef LOT_BUILD
#ifdef DLL_EXPORT
#define LOT_EXPORT __declspec(dllexport)
#else
#define LOT_EXPORT
#endif
#else
#define LOT_EXPORT __declspec(dllimport)
#endif
#else
#ifdef __GNUC__
#if __GNUC__ >= 4
#define LOT_EXPORT __attribute__((visibility("default")))
#else
#define LOT_EXPORT
#endif
#else
#define LOT_EXPORT
#endif
#endif
class LOTPlayerPrivate;
class LOTNode;
struct LOT_EXPORT LOTBuffer {
uint32_t *buffer = nullptr;
int width = 0;
int height = 0;
int bytesPerLine = 0;
bool clear = true;
};
class LOT_EXPORT LOTPlayer {
public:
~LOTPlayer();
LOTPlayer();
bool setFilePath(const char *filePath);
float playTime() const;
float pos();
const std::vector<LOTNode *> &renderList(float pos) const;
// TODO: Consider correct position...
void setSize(int width, int height);
void size(int &width, int &height) const;
std::future<bool> render(float pos, LOTBuffer buffer);
bool renderSync(float pos, LOTBuffer buffer);
public:
LOTPlayerPrivate *d;
};
#define ChangeFlagNone 0x0000
#define ChangeFlagPath 0x0001
#define ChangeFlagPaint 0x0010
#define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint)
struct LOTNode {
enum BrushType { BrushSolid, BrushGradient };
enum FillRule { EvenOdd, Winding };
enum JoinStyle { MiterJoin, BevelJoin, RoundJoin };
enum CapStyle { FlatCap, SquareCap, RoundCap };
struct PathData {
const float *ptPtr;
int ptCount;
const char* elmPtr;
int elmCount;
};
struct Color {
unsigned char r, g, b, a;
};
struct Stroke {
bool enable;
int width;
CapStyle cap;
JoinStyle join;
int meterLimit;
float* dashArray;
int dashArraySize;
};
struct Gradient {
enum Type { Linear = 1, Radial = 2 };
Gradient::Type type;
struct {
float x, y;
} start, end, center, focal;
float cradius;
float fradius;
};
int mFlag;
BrushType mType;
FillRule mFillRule;
PathData mPath;
Color mColor;
Stroke mStroke;
Gradient mGradient;
};
#endif // LOTPLAYER_H