api: revise the api for v1.0

API Modification:
- Matrix Paint::transform() -> Matrix& Paint::transform()

issue: https://github.com/thorvg/thorvg/issues/1372
This commit is contained in:
Hermet Park 2024-10-14 15:48:34 +09:00
parent 8ee5f5c544
commit 6a45e6e494
3 changed files with 7 additions and 9 deletions

View file

@ -358,7 +358,7 @@ public:
* *
* @since 0.4 * @since 0.4
*/ */
Matrix transform() noexcept; Matrix& transform() noexcept;
/** /**
* @brief Sets the opacity of the object. * @brief Sets the opacity of the object.

View file

@ -188,7 +188,7 @@ void LottieBuilder::updateTransform(LottieGroup* parent, LottieObject** child, f
Matrix matrix; Matrix matrix;
if (!_updateTransform(transform, frameNo, false, matrix, opacity, exps)) return; if (!_updateTransform(transform, frameNo, false, matrix, opacity, exps)) return;
ctx->propagator->transform(PP(ctx->propagator)->transform() * matrix); ctx->propagator->transform(ctx->propagator->transform() * matrix);
ctx->propagator->opacity(MULTIPLY(opacity, PP(ctx->propagator)->opacity)); ctx->propagator->opacity(MULTIPLY(opacity, PP(ctx->propagator)->opacity));
//FIXME: preserve the stroke width. too workaround, need a better design. //FIXME: preserve the stroke width. too workaround, need a better design.
@ -356,7 +356,7 @@ static void _repeat(LottieGroup* parent, Shape* path, RenderContext* ctx)
Matrix inv; Matrix inv;
inverse(&repeater->transform, &inv); inverse(&repeater->transform, &inv);
shape->transform(m * (inv * PP(shape)->transform())); shape->transform(m * (inv * shape->transform()));
shapes.push(shape); shapes.push(shape);
} }
} }
@ -839,7 +839,7 @@ void LottieBuilder::updateRepeater(TVG_UNUSED LottieGroup* parent, LottieObject*
RenderRepeater r; RenderRepeater r;
r.cnt = static_cast<int>(repeater->copies(frameNo, exps)); r.cnt = static_cast<int>(repeater->copies(frameNo, exps));
r.transform = PP(ctx->propagator)->transform(); r.transform = ctx->propagator->transform();
r.offset = repeater->offset(frameNo, exps); r.offset = repeater->offset(frameNo, exps);
r.position = repeater->position(frameNo, exps); r.position = repeater->position(frameNo, exps);
r.anchor = repeater->anchor(frameNo, exps); r.anchor = repeater->anchor(frameNo, exps);
@ -1072,7 +1072,7 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
else if ((*s)->based == LottieTextRange::Based::Lines) basedIdx = line; else if ((*s)->based == LottieTextRange::Based::Lines) basedIdx = line;
if (basedIdx < start || basedIdx >= end) continue; if (basedIdx < start || basedIdx >= end) continue;
auto matrix = shape->transform(); auto& matrix = shape->transform();
shape->opacity((*s)->style.opacity(frameNo)); shape->opacity((*s)->style.opacity(frameNo));
@ -1087,8 +1087,6 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
auto position = (*s)->style.position(frameNo); auto position = (*s)->style.position(frameNo);
translate(&matrix, position.x, position.y); translate(&matrix, position.x, position.y);
shape->transform(matrix);
if (doc.stroke.render) { if (doc.stroke.render) {
auto strokeColor = (*s)->style.strokeColor(frameNo); auto strokeColor = (*s)->style.strokeColor(frameNo);
shape->strokeWidth((*s)->style.strokeWidth(frameNo) / scale); shape->strokeWidth((*s)->style.strokeWidth(frameNo) / scale);

View file

@ -86,7 +86,7 @@ static Result _compFastTrack(RenderMethod* renderer, Paint* cmpTarget, const Mat
if (ptsCnt == 0) return Result::InvalidArguments; if (ptsCnt == 0) return Result::InvalidArguments;
if (ptsCnt != 4) return Result::InsufficientCondition; if (ptsCnt != 4) return Result::InsufficientCondition;
auto& rm = P(cmpTarget)->transform(); auto& rm = cmpTarget->transform();
//No rotation and no skewing, still can try out clipping the rect region. //No rotation and no skewing, still can try out clipping the rect region.
auto tryClip = false; auto tryClip = false;
@ -423,7 +423,7 @@ Result Paint::transform(const Matrix& m) noexcept
} }
Matrix Paint::transform() noexcept Matrix& Paint::transform() noexcept
{ {
return pImpl->transform(); return pImpl->transform();
} }