Skip to content

Commit

Permalink
Reverted AffineTransform.concat() implementation with ktm. [skip CI]
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Nov 26, 2024
1 parent 1499d81 commit 6d6141a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Source/3rdParty/ktm/simd/skv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace skv
typedef float32x4_t fv4;
typedef int32x4_t sv4;
#elif KTM_SIMD_ENABLE(KTM_SIMD_SSE)
typedef __m64 fv2;
typedef __m64 sv2;
typedef uint64_t fv2;
typedef uint64_t sv2;
typedef __m128 fv4;
#if KTM_SIMD_ENABLE(KTM_SIMD_SSE2)
typedef __m128i sv4;
Expand Down
5 changes: 5 additions & 0 deletions Source/3rdParty/nanovg/nanovg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,11 @@ void nvgTransform(NVGcontext* ctx, float a, float b, float c, float d, float e,
nvgTransformPremultiply(state->xform, t);
}

void nvgSetTransform(NVGcontext* ctx, float xform[6]) {
NVGstate* state = nvg__getState(ctx);
memcpy(state->xform, xform, sizeof(xform[0]) * 6);
}

void nvgResetTransform(NVGcontext* ctx)
{
NVGstate* state = nvg__getState(ctx);
Expand Down
2 changes: 2 additions & 0 deletions Source/3rdParty/nanovg/nanovg.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ void nvgResetTransform(NVGcontext* ctx);
// [0 0 1]
void nvgTransform(NVGcontext* ctx, float a, float b, float c, float d, float e, float f);

void nvgSetTransform(NVGcontext* ctx, float xform[6]);

// Translates current coordinate system.
void nvgTranslate(NVGcontext* ctx, float x, float y);

Expand Down
5 changes: 2 additions & 3 deletions Source/Render/VGRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,8 @@ void nvg::ApplyTransform(NotNull<Node, 1> node) {
transform.translate(size.width / 2, size.height / 2);
transform.scale(1.0f / scale, -1.0f / scale);
const auto& world = node->getWorld();
nvgResetTransform(Context());
nvgTransform(Context(), transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty);
nvgTransform(Context(), world.m[0], world.m[1], world.m[4], world.m[5], world.m[12], world.m[13]);
transform.concat({world.m[0], world.m[1], world.m[4], world.m[5], world.m[12], world.m[13]});
nvgSetTransform(Context(), &transform.a);
}

void nvg::Translate(float x, float y) {
Expand Down
8 changes: 1 addition & 7 deletions Source/Support/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,7 @@ AffineTransform& AffineTransform::scale(float sx, float sy) {
}

AffineTransform& AffineTransform::concat(const AffineTransform& t2) {
*this = {
a * t2.a + b * t2.c,
a * t2.b + b * t2.d,
c * t2.a + d * t2.c,
c * t2.b + d * t2.d,
tx * t2.a + ty * t2.c + t2.tx,
tx * t2.b + ty * t2.d + t2.ty};
r_cast<ktm::faffine2d*>(this)->concat(r_cast<const ktm::faffine2d&>(t2));
return *this;
}

Expand Down

0 comments on commit 6d6141a

Please sign in to comment.