#ifndef NATIVE_RENDER_THREAD_H #define NATIVE_RENDER_THREAD_H #include #include #include #include #include #include #include #include "../EGLMgr/EGLCore.h" #include "../EGLMgr/EGLSubCore.h" #include "Render.h" #include #include #include 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 registerRenderCompleteCallback(Callback callback); private: void initFontMgr(); void renderLoop(); std::thread rdThread; std::atomic 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 commandQueue_; std::mutex callbackMutex_; Callback renderCompleteCallback_; Handle(Font_FontMgr) ftMgr ; int rdWidth=0; int rdHeight=0; }; } // namespace NaitveRenderThread #endif //NATIVE_RENDER_THREAD_H