From: subhransu mohanty Date: Tue, 21 Aug 2018 03:59:33 +0000 (+0900) Subject: lottie: build fix. X-Git-Tag: submit/tizen/20180917.042405~85 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a0d4d746bdea9165a953c7a73b0f367a2c5b250;p=platform%2Fcore%2Fuifw%2Flottie-player.git lottie: build fix. Change-Id: Ie008c71e2fcb3bcf7197245e26880e71e2bedc32 --- diff --git a/src/binding/c/lottieplayer.cpp b/src/binding/c/lottieplayer.cpp deleted file mode 100644 index b3ee6a8..0000000 --- a/src/binding/c/lottieplayer.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include -#include "vdebug.h" - -extern "C" { - -using namespace lottieplayer; - -using lotplayer = LOTPlayer; - -LOT_EXPORT lotplayer *lotplayer_create(void) -{ - lotplayer* p = new LOTPlayer(); - if (!p) { - vCritical << "Failed to initialize lotplayer"; - } - return p; -} - -LOT_EXPORT int lotplayer_destroy(lotplayer *player) -{ - if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER; - delete(player); - - return LOT_PLAYER_ERROR_NONE; -} - -LOT_EXPORT int lotplayer_set_file(lotplayer *player, const char *file) -{ - if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER; - bool ret = player->setFilePath(file); - - if (!ret) return -1; - - return LOT_PLAYER_ERROR_NONE; -} - -LOT_EXPORT int lotplayer_set_size(lotplayer *player, int w, int h) -{ - if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER; - - player->setSize(w, h); - - return LOT_PLAYER_ERROR_NONE; -} - -LOT_EXPORT int lotplayer_get_size(const lotplayer *player, int* w, int* h) -{ - if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER; - - player->size(*w, *h); - - return LOT_PLAYER_ERROR_NONE; -} - -LOT_EXPORT float lotplayer_get_pos(const lotplayer *player) -{ - if (!player) { - vWarning << "Invalid parameter player = nullptr"; - return -1.0f; - } - - return player->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) -{ - if (!player) { - vWarning << "Invalid parameter player = nullptr"; - return 0.0f; - } - - return player->playTime(); -} - -LOT_EXPORT const lotnode* lotplayer_get_node(lotplayer *player, float pos, size_t idx) -{ - if (!player) { - vWarning << "Invalid parameter player = nullptr"; - return nullptr; - } - - if (idx >= player->renderList(pos).size()) { - vWarning << "Invalid parameter idx? (0 ~ " << player->renderList(pos).size() << "), given idx = " << idx; - return nullptr; - } - - return player->renderList(pos)[idx]; -} - -} diff --git a/src/binding/c/lottieplayer_c.cpp b/src/binding/c/lottieplayer_c.cpp new file mode 100644 index 0000000..b3ee6a8 --- /dev/null +++ b/src/binding/c/lottieplayer_c.cpp @@ -0,0 +1,97 @@ +#include +#include "vdebug.h" + +extern "C" { + +using namespace lottieplayer; + +using lotplayer = LOTPlayer; + +LOT_EXPORT lotplayer *lotplayer_create(void) +{ + lotplayer* p = new LOTPlayer(); + if (!p) { + vCritical << "Failed to initialize lotplayer"; + } + return p; +} + +LOT_EXPORT int lotplayer_destroy(lotplayer *player) +{ + if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER; + delete(player); + + return LOT_PLAYER_ERROR_NONE; +} + +LOT_EXPORT int lotplayer_set_file(lotplayer *player, const char *file) +{ + if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER; + bool ret = player->setFilePath(file); + + if (!ret) return -1; + + return LOT_PLAYER_ERROR_NONE; +} + +LOT_EXPORT int lotplayer_set_size(lotplayer *player, int w, int h) +{ + if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER; + + player->setSize(w, h); + + return LOT_PLAYER_ERROR_NONE; +} + +LOT_EXPORT int lotplayer_get_size(const lotplayer *player, int* w, int* h) +{ + if (!player) return LOT_PLAYER_ERROR_INVALID_PARAMETER; + + player->size(*w, *h); + + return LOT_PLAYER_ERROR_NONE; +} + +LOT_EXPORT float lotplayer_get_pos(const lotplayer *player) +{ + if (!player) { + vWarning << "Invalid parameter player = nullptr"; + return -1.0f; + } + + return player->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) +{ + if (!player) { + vWarning << "Invalid parameter player = nullptr"; + return 0.0f; + } + + return player->playTime(); +} + +LOT_EXPORT const lotnode* lotplayer_get_node(lotplayer *player, float pos, size_t idx) +{ + if (!player) { + vWarning << "Invalid parameter player = nullptr"; + return nullptr; + } + + if (idx >= player->renderList(pos).size()) { + vWarning << "Invalid parameter idx? (0 ~ " << player->renderList(pos).size() << "), given idx = " << idx; + return nullptr; + } + + return player->renderList(pos)[idx]; +} + +} diff --git a/src/binding/c/meson.build b/src/binding/c/meson.build index 223e5f7..646983b 100644 --- a/src/binding/c/meson.build +++ b/src/binding/c/meson.build @@ -1,6 +1,6 @@ install_headers(['lotplayer_capi.h']) -source_file = files('lottieplayer.cpp') +source_file = files('lottieplayer_c.cpp') binding_c_dep = declare_dependency( include_directories : include_directories('.'),