From: Hermet Park Date: Fri, 7 Sep 2018 10:40:02 +0000 (+0900) Subject: capi: changed file name. X-Git-Tag: submit/tizen/20180917.042405~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F188698%2F1;p=platform%2Fcore%2Fuifw%2Flottie-player.git capi: changed file name. Change-Id: Ic1c6b550751041f856814d24b668ab9f97606170 --- diff --git a/src/binding/c/CMakeLists.txt b/src/binding/c/CMakeLists.txt index 5d4965d..7737952 100644 --- a/src/binding/c/CMakeLists.txt +++ b/src/binding/c/CMakeLists.txt @@ -1,6 +1,6 @@ target_sources(lottie-player PRIVATE - "${CMAKE_CURRENT_LIST_DIR}/lottieanimation_c.cpp" + "${CMAKE_CURRENT_LIST_DIR}/lottieanimation_capi.cpp" ) target_include_directories(lottie-player diff --git a/src/binding/c/lottieanimation_c.cpp b/src/binding/c/lottieanimation_c.cpp deleted file mode 100644 index fa2f9f4..0000000 --- a/src/binding/c/lottieanimation_c.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "lottieanimation.h" -#include "vdebug.h" - -using namespace lottie; - -extern "C" { - -struct Lottie_Animation_S -{ - std::unique_ptr mAnimation; - size_t mCurFrame; - LOTNode **mNodeArray; - size_t mArraySize{0}; - std::future mRenderTask; -}; - -LOT_EXPORT Lottie_Animation_S *lottie_animation_from_file(const char *file) -{ - if (auto animation = Animation::loadFromFile(file) ) { - Lottie_Animation_S *handle = new Lottie_Animation_S(); - handle->mAnimation = std::move(animation); - return handle; - } else { - return nullptr; - } -} - -Lottie_Animation_S *lottie_animation_from_data(const char *data, const char *key) -{ - if (auto animation = Animation::loadFromData(data, key) ) { - Lottie_Animation_S *handle = new Lottie_Animation_S(); - handle->mAnimation = std::move(animation); - return handle; - } else { - return nullptr; - } -} - -LOT_EXPORT void lottie_animation_destroy(Lottie_Animation_S *animation) -{ - if (animation) - delete animation; -} - -LOT_EXPORT void lottie_animation_get_size(const Lottie_Animation_S *animation, size_t *w, size_t *h) -{ - if (!animation) return; - - animation->mAnimation->size(*w, *h); -} - -LOT_EXPORT double lottie_animation_get_duration(const Lottie_Animation_S *animation) -{ - if (!animation) return 0; - - return animation->mAnimation->duration(); -} - -LOT_EXPORT size_t lottie_animation_get_totalframe(const Lottie_Animation_S *animation) -{ - if (!animation) return 0; - - return animation->mAnimation->totalFrame(); -} - - -LOT_EXPORT double lottie_animation_get_framerate(const Lottie_Animation_S *animation) -{ - if (!animation) return 0; - - return animation->mAnimation->frameRate(); -} - -LOT_EXPORT void lottie_animation_prepare_frame(Lottie_Animation_S *animation, size_t frameNo, size_t w, size_t h) -{ - if (!animation) return; - - auto list = animation->mAnimation->renderList(frameNo, w, h); - animation->mNodeArray = list.data(); - animation->mArraySize = list.size(); -} - -LOT_EXPORT size_t lottie_animation_get_node_count(const Lottie_Animation_S *animation) -{ - if (!animation) return 0; - - return animation->mArraySize; -} - -LOT_EXPORT const LOTNode* lottie_animation_get_node(const Lottie_Animation_S *animation, size_t idx) -{ - if (!animation) return nullptr; - - if (idx >= animation->mArraySize) return nullptr; - - return animation->mNodeArray[idx]; -} - -LOT_EXPORT void -lottie_animation_render_async(Lottie_Animation_S *animation, - size_t frame_number, - uint32_t *buffer, - size_t width, - size_t height, - size_t bytes_per_line) -{ - if (!animation) return; - - lottie::Surface surface(buffer, width, height, bytes_per_line); - animation->mRenderTask = animation->mAnimation->render(frame_number, surface); -} - -LOT_EXPORT void -lottie_animation_render_flush(Lottie_Animation_S *animation) -{ - if (!animation) return; - - if (animation->mRenderTask.valid()) { - animation->mRenderTask.get(); - } -} - -} diff --git a/src/binding/c/lottieanimation_capi.cpp b/src/binding/c/lottieanimation_capi.cpp new file mode 100644 index 0000000..fa2f9f4 --- /dev/null +++ b/src/binding/c/lottieanimation_capi.cpp @@ -0,0 +1,123 @@ +#include "lottieanimation.h" +#include "vdebug.h" + +using namespace lottie; + +extern "C" { + +struct Lottie_Animation_S +{ + std::unique_ptr mAnimation; + size_t mCurFrame; + LOTNode **mNodeArray; + size_t mArraySize{0}; + std::future mRenderTask; +}; + +LOT_EXPORT Lottie_Animation_S *lottie_animation_from_file(const char *file) +{ + if (auto animation = Animation::loadFromFile(file) ) { + Lottie_Animation_S *handle = new Lottie_Animation_S(); + handle->mAnimation = std::move(animation); + return handle; + } else { + return nullptr; + } +} + +Lottie_Animation_S *lottie_animation_from_data(const char *data, const char *key) +{ + if (auto animation = Animation::loadFromData(data, key) ) { + Lottie_Animation_S *handle = new Lottie_Animation_S(); + handle->mAnimation = std::move(animation); + return handle; + } else { + return nullptr; + } +} + +LOT_EXPORT void lottie_animation_destroy(Lottie_Animation_S *animation) +{ + if (animation) + delete animation; +} + +LOT_EXPORT void lottie_animation_get_size(const Lottie_Animation_S *animation, size_t *w, size_t *h) +{ + if (!animation) return; + + animation->mAnimation->size(*w, *h); +} + +LOT_EXPORT double lottie_animation_get_duration(const Lottie_Animation_S *animation) +{ + if (!animation) return 0; + + return animation->mAnimation->duration(); +} + +LOT_EXPORT size_t lottie_animation_get_totalframe(const Lottie_Animation_S *animation) +{ + if (!animation) return 0; + + return animation->mAnimation->totalFrame(); +} + + +LOT_EXPORT double lottie_animation_get_framerate(const Lottie_Animation_S *animation) +{ + if (!animation) return 0; + + return animation->mAnimation->frameRate(); +} + +LOT_EXPORT void lottie_animation_prepare_frame(Lottie_Animation_S *animation, size_t frameNo, size_t w, size_t h) +{ + if (!animation) return; + + auto list = animation->mAnimation->renderList(frameNo, w, h); + animation->mNodeArray = list.data(); + animation->mArraySize = list.size(); +} + +LOT_EXPORT size_t lottie_animation_get_node_count(const Lottie_Animation_S *animation) +{ + if (!animation) return 0; + + return animation->mArraySize; +} + +LOT_EXPORT const LOTNode* lottie_animation_get_node(const Lottie_Animation_S *animation, size_t idx) +{ + if (!animation) return nullptr; + + if (idx >= animation->mArraySize) return nullptr; + + return animation->mNodeArray[idx]; +} + +LOT_EXPORT void +lottie_animation_render_async(Lottie_Animation_S *animation, + size_t frame_number, + uint32_t *buffer, + size_t width, + size_t height, + size_t bytes_per_line) +{ + if (!animation) return; + + lottie::Surface surface(buffer, width, height, bytes_per_line); + animation->mRenderTask = animation->mAnimation->render(frame_number, surface); +} + +LOT_EXPORT void +lottie_animation_render_flush(Lottie_Animation_S *animation) +{ + if (!animation) return; + + if (animation->mRenderTask.valid()) { + animation->mRenderTask.get(); + } +} + +} diff --git a/src/binding/c/meson.build b/src/binding/c/meson.build index 3c297fc..182aba5 100644 --- a/src/binding/c/meson.build +++ b/src/binding/c/meson.build @@ -1,4 +1,4 @@ -source_file = files('lottieanimation_c.cpp') +source_file = files('lottieanimation_capi.cpp') binding_c_dep = declare_dependency( include_directories : include_directories('.'),