ForCAX/entry/src/main/cpp/NativeEGLOCCT/OCCTMgr/RenderThread.h
JackLee 45176b5d7e 1-调整部分UI组件
2-调整背景颜色为有限度透明

提醒:OpenCAX由于商标已经被注册,所以本软件即日起改名NXEA
2026-04-28 21:57:30 +08:00

89 lines
2.2 KiB
C++

#ifndef NATIVE_RENDER_THREAD_H
#define NATIVE_RENDER_THREAD_H
#include <native_window/external_window.h>
#include <thread>
#include <atomic>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <functional>
#include "../EGLMgr/EGLCore.h"
#include "../EGLMgr/EGLSubCore.h"
#include "Render.h"
#include <Font_FontMgr.hxx>
#include <AIS_TextLabel.hxx>
#include <Resource_Unicode.hxx>
namespace NativeNXEA {
struct ThreadInfo{
int width;
int height;
OHNativeWindow* win;
EGLCore* eglCore;
};
class RenderThread {
public:
RenderThread();
~RenderThread();
bool start();
void stop();
void InitRender(ThreadInfo thrInfo);
void loadModel(const std::string& filePath);
void setCameraRotationMode(bool state);
void setRotation(float xAngle, float yAngle);
void setTranslation(float x, float y);
void resetView();
void setClearColor(float r, float g, float b, float a);
void resizeWindow(int width, int height);
void swicthView(std::string strView);
using Callback = std::function<void()>;
void registerRenderCompleteCallback(Callback callback);
private:
void initFontMgr();
void renderLoop();
std::thread rdThread;
std::atomic<bool> isRunning_;
std::mutex commandMutex_;
std::condition_variable commandCondition_;
ThreadInfo thrInfo;
Render* render;
EGLSubCore* eglSubCore;
enum CommandType {
CMD_LOAD_MODEL,
CMD_SET_ROTATION,
CMD_SET_TRANSLATION,
CMD_RESET_VIEW,
CMD_SET_CLEAR_COLOR,
CMD_RESIZE,
CMD_SWITCH_VIEW,
CMD_EXIT
};
struct RenderCommand {
CommandType type;
std::string param1; // For file path
float param2, param3, param4, param5;
bool param6;
RenderCommand() : type(CMD_EXIT), param1(""), param2(0.0f), param3(0.0f), param4(0.0f), param5(0.0f) {}
RenderCommand(CommandType t) : type(t), param1(""), param2(0), param3(0), param4(0), param5(0),param6(true) {}
};
std::queue<RenderCommand> commandQueue_;
std::mutex callbackMutex_;
Callback renderCompleteCallback_;
Handle(Font_FontMgr) ftMgr ;
int rdWidth=0;
int rdHeight=0;
};
} // namespace NaitveRenderThread
#endif //NATIVE_RENDER_THREAD_H