feat: add minimal HarmonyOS native napi skeleton

This commit is contained in:
OpenClaw committed 2026-03-09 17:05:17 +08:00
1 parent e328780ee5
commit 8b6e24fa61
11 files changed
+565

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
#include "MrpFacade.h"
#include "../render/FrameBuffer.h"
#include "../runtime/MrpRuntime.h"
namespace {
MrpRuntime g_runtime;
}
CommonResult MrpFacade::Init(const InitOptions &options)
{
options_ = options;
return g_runtime.Init(options.width, options.height, options.debug);
}
CommonResult MrpFacade::LoadPackage(const std::string &packagePath)
{
packagePath_ = packagePath;
return g_runtime.LoadPackage(packagePath);
}
CommonResult MrpFacade::Start()
{
return g_runtime.Start();
}
CommonResult MrpFacade::Pause()
{
return g_runtime.Pause();
}
CommonResult MrpFacade::Resume()
{
return g_runtime.Resume();
}
CommonResult MrpFacade::SendInput(const MrpInputEvent &event)
{
DispatchInput(event);
return CommonResult{true, 0, ""};
}
FrameResult MrpFacade::PullFrame()
{
FrameBuffer frameBuffer(g_runtime.Width(), g_runtime.Height());
frameBuffer.FillTestPattern(g_runtime.NextFrameId());
FrameResult result;
result.ok = true;
result.hasNewFrame = true;
result.width = g_runtime.Width();
result.height = g_runtime.Height();
result.pixelFormat = "RGBA_8888";
result.buffer = frameBuffer.Data();
result.frameId = g_runtime.CurrentFrameId();
return result;
}
CommonResult MrpFacade::Release()
{
packagePath_.clear();
return g_runtime.Release();
}
+51
View File
@@ -0,0 +1,51 @@
#ifndef MRP_PLATFORM_MRP_FACADE_H
#define MRP_PLATFORM_MRP_FACADE_H
#include <cstdint>
#include <string>
#include <vector>
#include "../input/InputEvent.h"
struct InitOptions {
std::string workDir;
int32_t width = 240;
int32_t height = 320;
bool debug = false;
};
struct CommonResult {
bool ok = false;
int32_t errorCode = 0;
std::string errorMessage;
};
struct FrameResult {
bool ok = false;
bool hasNewFrame = false;
int32_t width = 0;
int32_t height = 0;
std::string pixelFormat = "RGBA_8888";
std::vector<uint8_t> buffer;
int64_t frameId = 0;
int32_t errorCode = 0;
std::string errorMessage;
};
class MrpFacade {
public:
CommonResult Init(const InitOptions &options);
CommonResult LoadPackage(const std::string &packagePath);
CommonResult Start();
CommonResult Pause();
CommonResult Resume();
CommonResult SendInput(const MrpInputEvent &event);
FrameResult PullFrame();
CommonResult Release();
private:
InitOptions options_;
std::string packagePath_;
};
#endif