mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 06:04:03 +00:00
api: enhance the API usage.
Allow users to omit the default type casting for added convenience.
This commit is contained in:
parent
ce2a3f6040
commit
a6d7a19047
5 changed files with 9 additions and 9 deletions
|
@ -1894,7 +1894,7 @@ public:
|
||||||
* @brief The cast() function is a utility function used to cast a 'Paint' to type 'T'.
|
* @brief The cast() function is a utility function used to cast a 'Paint' to type 'T'.
|
||||||
* @since 0.11
|
* @since 0.11
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T = tvg::Paint>
|
||||||
std::unique_ptr<T> cast(Paint* paint)
|
std::unique_ptr<T> cast(Paint* paint)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<T>(static_cast<T*>(paint));
|
return std::unique_ptr<T>(static_cast<T*>(paint));
|
||||||
|
@ -1905,7 +1905,7 @@ std::unique_ptr<T> cast(Paint* paint)
|
||||||
* @brief The cast() function is a utility function used to cast a 'Fill' to type 'T'.
|
* @brief The cast() function is a utility function used to cast a 'Fill' to type 'T'.
|
||||||
* @since 0.11
|
* @since 0.11
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T = tvg::Fill>
|
||||||
std::unique_ptr<T> cast(Fill* fill)
|
std::unique_ptr<T> cast(Fill* fill)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<T>(static_cast<T*>(fill));
|
return std::unique_ptr<T>(static_cast<T*>(fill));
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
resize(width, height);
|
resize(width, height);
|
||||||
|
|
||||||
if (canvas->push(cast<Picture>(animation->picture())) != Result::Success) {
|
if (canvas->push(cast(animation->picture())) != Result::Success) {
|
||||||
errorMsg = "push() fail";
|
errorMsg = "push() fail";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
picture->scale(scale);
|
picture->scale(scale);
|
||||||
picture->translate(shiftX, shiftY);
|
picture->translate(shiftX, shiftY);
|
||||||
|
|
||||||
canvas->push(tvg::cast<tvg::Picture>(picture));
|
canvas->push(tvg::cast(picture));
|
||||||
|
|
||||||
//Run animation loop
|
//Run animation loop
|
||||||
elm_transit_duration_set(transit, animation->duration());
|
elm_transit_duration_set(transit, animation->duration());
|
||||||
|
|
|
@ -125,7 +125,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
elm_transit_repeat_times_set(transit, -1);
|
elm_transit_repeat_times_set(transit, -1);
|
||||||
elm_transit_go(transit);
|
elm_transit_go(transit);
|
||||||
|
|
||||||
canvas->push(tvg::cast<tvg::Picture>(animation->picture()));
|
canvas->push(tvg::cast(animation->picture()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,11 +353,11 @@ static void _repeat(LottieGroup* parent, int32_t frameNo, unique_ptr<Shape> path
|
||||||
//push repeat shapes in order.
|
//push repeat shapes in order.
|
||||||
if (repeater->inorder) {
|
if (repeater->inorder) {
|
||||||
for (auto shape = shapes.data; shape < shapes.end(); ++shape) {
|
for (auto shape = shapes.data; shape < shapes.end(); ++shape) {
|
||||||
parent->scene->push(cast<Shape>(*shape));
|
parent->scene->push(cast(*shape));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (auto shape = shapes.end() - 1; shape >= shapes.data; --shape) {
|
for (auto shape = shapes.end() - 1; shape >= shapes.data; --shape) {
|
||||||
parent->scene->push(cast<Shape>(*shape));
|
parent->scene->push(cast(*shape));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -802,7 +802,7 @@ static void _updatePrecomp(LottieLayer* precomp, int32_t frameNo)
|
||||||
clipper->appendRect(0, 0, static_cast<float>(precomp->w), static_cast<float>(precomp->h));
|
clipper->appendRect(0, 0, static_cast<float>(precomp->w), static_cast<float>(precomp->h));
|
||||||
clipper->transform(precomp->cache.matrix);
|
clipper->transform(precomp->cache.matrix);
|
||||||
cscene->composite(std::move(clipper), CompositeMethod::ClipPath);
|
cscene->composite(std::move(clipper), CompositeMethod::ClipPath);
|
||||||
cscene->push(cast<Scene>(precomp->scene));
|
cscene->push(cast(precomp->scene));
|
||||||
precomp->scene = cscene.release();
|
precomp->scene = cscene.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -913,7 +913,7 @@ static void _updateLayer(LottieLayer* root, LottieLayer* layer, int32_t frameNo)
|
||||||
}
|
}
|
||||||
|
|
||||||
//the given matte source was composited by the target earlier.
|
//the given matte source was composited by the target earlier.
|
||||||
if (!layer->matteSrc) root->scene->push(cast<Scene>(layer->scene));
|
if (!layer->matteSrc) root->scene->push(cast(layer->scene));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue