//---------------------------------------------------------------------- // //---------------------------------------------------------------------- LNResult LNFont_CreateCopy(LNHandle* font, LNHandle srcFont) { LN_FUNC_TRY_BEGIN; LRefPtr<Core::Graphics::Font> obj(TO_REFOBJ(Core::Graphics::Font, srcFont)->copy()); obj.addRef(); *font = TO_HANDLE(FuncLibManager::registerReferenceObject(obj)); LN_FUNC_TRY_END_RETURN; }
//---------------------------------------------------------------------- // //---------------------------------------------------------------------- LNResult LNTexture_CreateFromFileEx(LNHandle* texture, const LNChar* filePath, uint32_t colorKey, int levels, LNTextureFormat format) { LN_FUNC_TRY_BEGIN; LRefPtr<Core::Graphics::Texture> obj( FuncLibManager::GraphicsManager->getGraphicsDevice()->createTexture( filePath, colorKey, levels, ((Core::Graphics::SurfaceFormat)format) ) ); obj.addRef(); *texture = TO_HANDLE(FuncLibManager::registerReferenceObject(obj)); LN_FUNC_TRY_END_RETURN; }
//---------------------------------------------------------------------- // //---------------------------------------------------------------------- LNResult LNTexture_CreateEx(LNHandle* texture, int width, int height, int levels, LNTextureFormat format) { LN_FUNC_TRY_BEGIN; LRefPtr<Core::Graphics::Texture> obj( FuncLibManager::GraphicsManager->getGraphicsDevice()->createTexture( width, height, levels, ((Core::Graphics::SurfaceFormat)format) ) ); obj.addRef(); *texture = TO_HANDLE(FuncLibManager::registerReferenceObject(obj)); LN_FUNC_TRY_END_RETURN; }
//---------------------------------------------------------------------- // //---------------------------------------------------------------------- LNResult LNTexture_CreateFromFile(LNHandle* texture, const LNChar* filePath ) { LN_FUNC_TRY_BEGIN; LRefPtr<Core::Graphics::Texture> obj( FuncLibManager::GraphicsManager->getGraphicsDevice()->createTexture( filePath, 0x00000000, 1 ) ); obj.addRef(); *texture = TO_HANDLE(FuncLibManager::registerReferenceObject(obj)); LN_FUNC_TRY_END_RETURN; }
//---------------------------------------------------------------------- // //---------------------------------------------------------------------- LNResult LNFont_CreateBitmapFontFromFile(LNHandle* font, const LNChar* filePath) { LN_FUNC_TRY_BEGIN; LRefPtr<Core::Graphics::Font> obj( Graphics::Util::createBitmapFont(FuncLibManager::GraphicsManager, filePath)); obj.addRef(); *font = TO_HANDLE(FuncLibManager::registerReferenceObject(obj)); LN_FUNC_TRY_END_RETURN; }
//---------------------------------------------------------------------- // //---------------------------------------------------------------------- LNResult LNFont_Create(LNHandle* font) { LN_FUNC_TRY_BEGIN; LRefPtr<Core::Graphics::Font> obj( FuncLibManager::GraphicsManager->getFontManager()->createFont() ); obj.addRef(); *font = TO_HANDLE(FuncLibManager::registerReferenceObject(obj)); LN_FUNC_TRY_END_RETURN; }
/** * @brief This method allocates an empty slot and creates an execution that will run on it. * @param _desired_xid [in] The xid we want, or XID_ANY if doesnt mind. * @param _execution [in] The state of the task. * @param _environment [in] The environment associated. * @return The xid (eXecution ID) newly allocated. */ PUBLIC XID PROCESSOR_CreateNewExecution(IN XID _desired_xid, IN EXECUTION* _execution, IN ENVIRONMENT* _environment) { if(_desired_xid == XID_ANY) { //Search in the vector of executions for(dword i = 0; i < MAX_EXECUTIONS; i++) { //If it is empty... if(!processor[i].used) { _desired_xid = i; break; } } if(_desired_xid == XID_ANY) { //No empty room found return 0; } _desired_xid = TO_HANDLE(_desired_xid); } //If it is empty... if(!processor[TO_INDEX(_desired_xid)].used) { //Allocate processor[TO_INDEX(_desired_xid)].used = true; //Assign the slice processor[TO_INDEX(_desired_xid)].execution = _execution; processor[TO_INDEX(_desired_xid)].environment = _environment; processor[TO_INDEX(_desired_xid)].callback = 0; //Increase the number of executions processor_slices_used++; //Return XID return _desired_xid; } //Couldn't succeed return 0; }
/** * @brief This method allocates an empty slot for an existing execution. * @param _desired_xid [in] The xid we would like. * @param _xid [in] The xid of the execution we want to give more cpu. * @return The xid (eXecution ID) newly allocated. */ PUBLIC XID PROCESSOR_AssignNewExecution(IN XID _desired_xid, IN XID _xid) { if(_desired_xid == XID_ANY) { //Search the executions' vector for(dword i = 0; i < MAX_EXECUTIONS; i++) { //If it's empty... if(!processor[i].used) { _desired_xid = i; break; } } if(_desired_xid == XID_ANY) { //No empty room found return 0; } _desired_xid = TO_HANDLE(_desired_xid); } //If it's empty... if(!processor[TO_INDEX(_desired_xid)].used) { //Allocate processor[TO_INDEX(_desired_xid)].used = true; //Copy processor[TO_INDEX(_desired_xid)].execution = processor[TO_INDEX(_xid)].execution; processor[TO_INDEX(_desired_xid)].environment = processor[TO_INDEX(_xid)].environment; processor[TO_INDEX(_desired_xid)].callback = processor[TO_INDEX(_xid)].callback; //Increase the number of executions processor_slices_used++; //Return the XID return _desired_xid; } return 0; }
/** * @brief Tells what the current xid is. * @return The XID currently running. */ PUBLIC XID PROCESSOR_GetCurrentXID() { return TO_HANDLE(processor_current_slice); }