nn::ui2d::Pane functions

This commit is contained in:
shibbo 2024-09-15 21:10:31 -04:00
parent 9b7b00c4d6
commit 5108ca3a07
14 changed files with 351 additions and 30 deletions

View File

@ -24,7 +24,7 @@ BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 100
ColumnLimit: 150
CommentPragmas: '^ (IWYU pragma:|NOLINT)'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "decompiled",
"message": "0.8371%",
"message": "0.842%",
"color": "blue"
}

View File

@ -38424,11 +38424,11 @@ _ZNK2nn4ui2d8Material48ApplyPixelShaderCombinerUserShaderConstantBufferERNS_3gfx
_ZNK2nn4ui2d8Material25SetCommandBufferOnlyBlendERNS_3gfx14TCommandBufferINS2_12ApiVariationINS2_7ApiTypeILi4EEENS2_10ApiVersionILi8EEEEEEE=00000071005AEB30=000000C4=false
_ZNK2nn4ui2d8Material9SetShaderERNS_3gfx14TCommandBufferINS2_12ApiVariationINS2_7ApiTypeILi4EEENS2_10ApiVersionILi8EEEEEEE=00000071005AEC00=00000010=false
_ZNK2nn4ui2d8Material25CompareCopiedInstanceTestERKS1_=00000071005AEC10=00000348=false
_ZN2nn4ui2d6detail8PaneBaseC2Ev=00000071005AEF60=0000001C=false
_ZN2nn4ui2d6detail8PaneBaseC2Ev=00000071005AEF60=0000001C=true
_ZN2nn4ui2d4PaneD2Ev=00000071005AEF80=00000004=false
_ZN2nn4ui2d6detail8PaneBaseD0Ev=00000071005AEF90=00000004=false
_ZN2nn4ui2d6detail8PaneBaseD0Ev=00000071005AEF90=00000004=true
_ZN2nn4ui2d4PaneC2Ev=00000071005AEFA0=0000007C=false
_ZN2nn4ui2d4Pane16InitializeParamsEv=00000071005AF020=00000038=false
_ZN2nn4ui2d4Pane16InitializeParamsEv=00000071005AF020=00000038=true
_ZN2nn4ui2d4PaneC1EPKNS0_7ResPaneERKNS0_11BuildArgSetE=00000071005AF060=00000034=false
_ZN2nn4ui2d4Pane25InitializeByResourceBlockEPNS0_22BuildResultInformationEPNS_3gfx7TDeviceINS4_12ApiVariationINS4_7ApiTypeILi4EEENS4_10ApiVersionILi8EEEEEEEPKNS0_7ResPaneERKNS0_11BuildArgSetE=00000071005AF0A0=00000630=false
_ZN2nn4ui2d4PaneC2EPNS0_22BuildResultInformationEPNS_3gfx7TDeviceINS4_12ApiVariationINS4_7ApiTypeILi4EEENS4_10ApiVersionILi8EEEEEEEPKNS0_7ResPaneERKNS0_11BuildArgSetE=00000071005AF6D0=00000024=false

View File

@ -0,0 +1,47 @@
#pragma once
namespace nn {
namespace font {
#define NN_FONT_RUNTIME_TYPEINFO_ROOT() \
static const nn::font::detail::RuntimeTypeInfo* GetRuntimeTypeInfoStatic() { \
static const nn::font::detail::RuntimeTypeInfo s_TypeInfo(NULL); \
return &s_TypeInfo; \
} \
virtual const nn::font::detail::RuntimeTypeInfo* GetRuntimeTypeInfo() const { \
return GetRuntimeTypeInfoStatic(); \
}
#define NN_FONT_RUNTIME_TYPEINFO(base) \
static const nn::font::detail::RuntimeTypeInfo* GetRuntimeTypeInfoStatic() { \
static const nn::font::detail::RuntimeTypeInfo s_TypeInfo(base::GetRuntimeTypeInfoStatic()); \
return &s_TypeInfo; \
} \
virtual const nn::font::detail::RuntimeTypeInfo* GetRuntimeTypeInfo() const NN_OVERRIDE { \
return GetRuntimeTypeInfoStatic(); \
}
namespace detail {
class RuntimeTypeInfo {
public:
const RuntimeTypeInfo* mParent;
explicit RuntimeTypeInfo(const RuntimeTypeInfo* pParent) : mParent(pParent) {}
bool IsDerivedFrom(const RuntimeTypeInfo* s_TypeInfo) const {
const RuntimeTypeInfo* self = this;
while (self != nullptr) {
if (self == s_TypeInfo) {
return true;
}
self = self->mParent;
}
return false;
}
};
}; // namespace detail
}; // namespace font
}; // namespace nn

View File

@ -0,0 +1,10 @@
#pragma once
namespace nn {
namespace gfx {
namespace detail {
template <typename TImpl>
class RequiredMemory {};
}; // namespace detail
}; // namespace gfx
}; // namespace nn

View File

@ -0,0 +1,14 @@
#pragma once
#include "gfx/detail/gfx_Device.hpp"
#include "gfx/detail/gfx_RequiredMemory.hpp"
#include "gfx/gfx_DeviceData.hpp"
#include "gfx/gfx_VariationBase.hpp"
namespace nn {
namespace gfx {
template <typename TTarget>
class TDevice : public detail::DeviceImpl<typename detail::TargetVariation<TTarget>::Type>,
private detail::RequiredMemory<detail::DeviceImpl<typename detail::TargetVariation<TTarget>::Type>> {};
}; // namespace gfx
}; // namespace nn

View File

@ -1,5 +1,6 @@
#pragma once
#include "gfx/gfx_Device.hpp"
#include "gfx/gfx_MemoryPool.hpp"
#include "gfx/gfx_TargetConfig.hpp"
#include "gfx/gfx_VariationBase.hpp"
@ -7,5 +8,6 @@
namespace nn {
namespace gfx {
typedef TMemoryPool<TargetConfig::Variation> MemoryPool;
};
typedef TDevice<TargetConfig::Variation> Device;
}; // namespace gfx
}; // namespace nn

View File

@ -0,0 +1,104 @@
#pragma once
#include "gfx/gfx_Types.hpp"
#include "ui2d/ui2d_Types.hpp"
#include "util/util_IntrusiveList.hpp"
#include "util/util_MathTypes.hpp"
namespace nn {
namespace gfx {
class CommandBuffer; // todo -- get rid of me later
};
namespace ui2d {
namespace detail {
class PaneBase {
public:
PaneBase();
virtual ~PaneBase();
nn::util::IntrusiveListNode mLink; // 0x08
};
}; // namespace detail
struct ResPane;
class ResExtUserData;
struct ResExtUserDataList;
class AnimTransform;
class AnimResource;
class Material;
class DrawInfo;
class Pane;
class CaptureTexture;
typedef nn::util::IntrusiveList<Pane, nn::util::IntrusiveListMemberNodeTraits<detail::PaneBase, &detail::PaneBase::mLink, Pane>> PaneList;
class Pane : public detail::PaneBase {
public:
NN_UI2D_RUNTIME_TYPEINFO_ROOT();
Pane();
struct CalculateContext {};
typedef CalculateContext CalculateMtxContext;
virtual ~Pane();
virtual void Finalize(nn::gfx::Device*);
virtual const nn::util::Unorm8x4 GetVertexColor(int) const;
virtual void SetVertexColor(int, const nn::util::Unorm8x4&);
virtual uint8_t GetColorElement(int) const;
virtual void SetColorElement(int, uint8_t);
virtual uint8_t GetVertexColorElement(int) const;
virtual void SetVertexColorElement(int, uint8_t);
virtual uint8_t GetMaterialCount() const;
virtual Material* GetMaterial(int) const;
virtual void GetSizeWithCaptureEffect(Size*) const;
virtual void GetVertexPosWithCaptureEffect(util::Float2*) const;
virtual float GetItalicSize() const;
virtual Pane* FindPaneByName(const char*, bool recursive = true);
virtual const Pane* FindPaneByName(const char*, bool recursive = true) const;
virtual Material* FindMaterialByName(const char*, bool recursive = true);
virtual const Material* FindMaterialByName(const char*, bool recursive = true) const;
virtual void BindAnimation(AnimTransform*, bool recursive = true, bool enabled = true);
virtual void UnbindAnimation(AnimTransform*, bool recursive = true);
virtual void UnbindAnimationSelf(AnimTransform*);
virtual void Calculate(DrawInfo&, CalculateMtxContext&, bool);
virtual void Draw(DrawInfo&, nn::gfx::CommandBuffer&);
virtual void DrawSelf(DrawInfo&, nn::gfx::CommandBuffer&);
virtual void SetupPaneEffectSourceImageRenderState(nn::gfx::CommandBuffer&) const {}
virtual void LoadMtx(DrawInfo&);
virtual Pane* FindPaneByNameRecursive(const char*);
virtual const Pane* FindPaneByNameRecursive(const char*) const;
virtual Material* FindMaterialByNameRecursive(const char*);
virtual const Material* FindMaterialByNameRecursive(const char*) const;
void InitializeParams();
void SetName(const char*);
void SetUserData(const char*);
Pane* mParent;
PaneList mChildList;
nn::util::Float3 mTranslate;
nn::util::Float3 mRotate;
nn::util::Float2 mScale;
Size mSize;
uint8_t mFlag;
uint8_t mAlpha;
uint8_t mGlobalAlpha;
uint8_t mBasePosition;
uint8_t mFlagEx;
u8 pad[3];
uint32_t mSystemFlags;
u8 pad1[4];
nn::util::MatrixT4x3fType mGlobalMtx;
const nn::util::MatrixT4x3fType* mUserMtx;
const ResExtUserDataList* mExtUserDataList;
char mName[25];
char mUserData[9];
};
}; // namespace ui2d
}; // namespace nn

View File

@ -0,0 +1,17 @@
#pragma once
#include "font/font_Util.hpp"
#include "types.hpp"
namespace nn {
namespace ui2d {
/* these are already defined in nn::font */
#define NN_UI2D_RUNTIME_TYPEINFO_ROOT NN_FONT_RUNTIME_TYPEINFO_ROOT
#define NN_UI2D_RUNTIME_TYPEINFO NN_FONT_RUNTIME_TYPEINFO
struct Size {
f32 mWidth;
f32 mHeight;
};
}; // namespace ui2d
}; // namespace nn

View File

@ -0,0 +1,36 @@
#pragma once
#include <cstdio>
namespace nn {
namespace util {
class IntrusiveListNode {
public:
IntrusiveListNode() {
mPrev = this;
mNext = this;
}
private:
IntrusiveListNode* mPrev; // 0x00
IntrusiveListNode* mNext; // 0x08
};
namespace detail {
class IntrusiveistImplementation {
public:
IntrusiveListNode mRoot;
};
}; // namespace detail
template <class T, class Traits>
class IntrusiveList {
public:
detail::IntrusiveistImplementation mImplementation;
};
template <class Holder, IntrusiveListNode Holder::*Member, class T = Holder,
size_t IsComplete = sizeof(Holder)>
class IntrusiveListMemberNodeTraits {};
}; // namespace util
}; // namespace nn

View File

@ -13,6 +13,17 @@ namespace nn {
uint8_t v[4];
};
struct Float2 {
union {
float v[2];
struct {
float x;
float y;
};
};
};
struct Float3 {
union {
float v[3];

View File

@ -8,37 +8,41 @@
namespace nn {
namespace util {
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fSetScaleRotateXyz(
float32x4x4_t matrix, float32x4_t scale, float32x4_t rotationRadian);
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fSetScaleRotateXyz(float32x4x4_t matrix, float32x4_t scale, float32x4_t rotationRadian);
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fSetTranslate(float32x4x4_t matrix,
float32x4_t translate);
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fSetTranslate(float32x4x4_t matrix, float32x4_t translate);
NN_FORCEINLINE void MatrixRowMajor4x3fStore(FloatColumnMajor4x3* pOutValue,
float32x4x4_t source);
NN_FORCEINLINE void MatrixRowMajor4x3fStore(FloatColumnMajor4x3* pOutValue, float32x4x4_t source);
NN_FORCEINLINE void MatrixSetScaleRotateXyz(MatrixRowMajor4x3fType* pOutValue,
const Vector3fType& scale,
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fIdentity();
NN_FORCEINLINE float32x4x3_t MatrixColumnMajor4x3fIdentity();
NN_FORCEINLINE void MatrixSetScaleRotateXyz(MatrixRowMajor4x3fType* pOutValue, const Vector3fType& scale,
const Vector3fType& rotationRadian) {
pOutValue->_m =
MatrixRowMajor4x3fSetScaleRotateXyz(pOutValue->_m, scale._v, rotationRadian._v);
pOutValue->_m = MatrixRowMajor4x3fSetScaleRotateXyz(pOutValue->_m, scale._v, rotationRadian._v);
}
NN_FORCEINLINE void MatrixSetTranslate(MatrixRowMajor4x3fType* pOutValue,
const Vector3fType& translate) {
NN_FORCEINLINE void MatrixSetTranslate(MatrixRowMajor4x3fType* pOutValue, const Vector3fType& translate) {
pOutValue->_m = MatrixRowMajor4x3fSetTranslate(pOutValue->_m, translate._v);
}
NN_FORCEINLINE void MatrixStore(FloatColumnMajor4x3* pOutValue,
const MatrixRowMajor4x3fType& source) {
NN_FORCEINLINE void MatrixStore(FloatColumnMajor4x3* pOutValue, const MatrixRowMajor4x3fType& source) {
MatrixRowMajor4x3fStore(pOutValue, source._m);
}
NN_FORCEINLINE void MatrixIdentity(MatrixRowMajor4x3fType* pOutValue) {
pOutValue->_m = MatrixRowMajor4x3fIdentity();
}
NN_FORCEINLINE void MatrixIdentity(MatrixColumnMajor4x3fType* pOutValue) {
pOutValue->_m = MatrixColumnMajor4x3fIdentity();
}
/* the sdk has a million wrappers due to the multiple variations of functions supported */
/* we are not doing that. we are writing only the neon version */
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fSetScaleRotateXyz(
float32x4x4_t matrix, float32x4_t scale, float32x4_t rotationRadian) {
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fSetScaleRotateXyz(float32x4x4_t matrix, float32x4_t scale, float32x4_t rotationRadian) {
float32x4_t vSinRadian, vCosRadian;
Vector4fSinCos(&vSinRadian, &vCosRadian, rotationRadian);
@ -65,12 +69,10 @@ namespace nn {
float32x4_t NegativeOneOne = Vector4fSet(-1.f, 1.f, 0.f, 0.f);
float32x4_t OneNegativeOne = Vector4fSet(1.f, -1.f, 0.f, 0.f);
float32x4_t row1 = vaddq_f32(vmulq_n_f32(sinYsinYOne_x_cosZsinZcosY, sinX),
vmulq_f32(NegativeOneOne, vmulq_n_f32(sinZcosZ, cosX)));
float32x4_t row1 = vaddq_f32(vmulq_n_f32(sinYsinYOne_x_cosZsinZcosY, sinX), vmulq_f32(NegativeOneOne, vmulq_n_f32(sinZcosZ, cosX)));
vResult.val[1] = vmulq_n_f32(row1, Vector4fGetY(scale));
float32x4_t row2 = vaddq_f32(vmulq_n_f32(sinYsinYOne_x_cosZsinZcosY, cosX),
vmulq_f32(OneNegativeOne, vmulq_n_f32(sinZcosZ, sinX)));
float32x4_t row2 = vaddq_f32(vmulq_n_f32(sinYsinYOne_x_cosZsinZcosY, cosX), vmulq_f32(OneNegativeOne, vmulq_n_f32(sinZcosZ, sinX)));
vResult.val[2] = vmulq_n_f32(row2, Vector4fGetZ(scale));
vResult.val[3] = matrix.val[3];
@ -78,8 +80,7 @@ namespace nn {
return vResult;
}
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fSetTranslate(float32x4x4_t matrix,
float32x4_t translate) {
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fSetTranslate(float32x4x4_t matrix, float32x4_t translate) {
float32x4x4_t vResult;
vResult.val[0] = matrix.val[0];
vResult.val[1] = matrix.val[1];
@ -104,8 +105,7 @@ namespace nn {
return vResult;
}
NN_FORCEINLINE void MatrixRowMajor4x3fStore(FloatColumnMajor4x3* pOutValue,
float32x4x4_t source) {
NN_FORCEINLINE void MatrixRowMajor4x3fStore(FloatColumnMajor4x3* pOutValue, float32x4x4_t source) {
float32x4x4_t matrixT = Matrix4x4fTranspose(source);
Vector4fStore(pOutValue->m[0], matrixT.val[0]);
@ -113,5 +113,28 @@ namespace nn {
Vector4fStore(pOutValue->m[2], matrixT.val[2]);
}
NN_FORCEINLINE float32x4x4_t MatrixRowMajor4x3fIdentity() {
float32x4_t vZero = Vector4fZero();
float32x4x4_t vResult;
vResult.val[0] = Vector4fSetX(vZero, 1.f);
vResult.val[1] = Vector4fSetY(vZero, 1.f);
vResult.val[2] = Vector4fSetZ(vZero, 1.f);
vResult.val[3] = vZero;
return vResult;
}
NN_FORCEINLINE float32x4x3_t MatrixColumnMajor4x3fIdentity() {
float32x4_t vZero = Vector4fZero();
float32x4x3_t vResult;
vResult.val[0] = Vector4fSetX(vZero, 1.f);
vResult.val[1] = Vector4fSetY(vZero, 1.f);
vResult.val[2] = Vector4fSetZ(vZero, 1.f);
return vResult;
}
}; // namespace util
}; // namespace nn

View File

@ -0,0 +1,26 @@
#pragma once
#include "types.hpp"
namespace nn {
namespace util {
template <typename T>
int Strlcpy(T* pDest, const T* pSrc, s32 count) {
auto srcEnd = pSrc;
if (count > 0) {
while (--count & *srcEnd) {
*pDest++ = *srcEnd;
}
*pDest = 0;
}
while (*srcEnd) {
srcEnd++;
}
return static_cast<s32>(srcEnd - pSrc);
}
}; // namespace util
}; // namespace nn

View File

@ -0,0 +1,31 @@
#include "ui2d/ui2d_Pane.hpp"
#include "util/util_MatrixApi.hpp"
#include "util/util_StringUtil.hpp"
namespace nn {
namespace ui2d {
namespace detail {
PaneBase::PaneBase() {}
PaneBase::~PaneBase() {}
}; // namespace detail
void Pane::InitializeParams() {
mParent = nullptr;
mFlag = 0;
mFlagEx = 0;
mSystemFlags = 0;
mExtUserDataList = nullptr;
nn::util::MatrixIdentity(&mGlobalMtx);
mUserMtx = nullptr;
}
void Pane::SetName(const char* pName) {
nn::util::Strlcpy(mName, pName, sizeof(mName));
}
void Pane::SetUserData(const char* pUserData) {
nn::util::Strlcpy(mUserData, pUserData, sizeof(mUserData));
}
}; // namespace ui2d
}; // namespace nn