void ConstantBufferArrayManager::addDynamicBuffer( D3D11 & d3d, ConstantBufferArrayHandle buffer, uint32_t index, void * data, uint32_t memSize ) { #ifdef _DEBUG if( !isValidHandle( buffer ) ) { // Todo log it return; } #endif auto & item = BufferArray[buffer.mIndex-1].mValue; #ifdef _DEBUG if( index > item.mNbrBuffers ) { // Todo log the error return; } #endif ConstantBufferHandle cbh = ConstantBufferManager::newDynamic( d3d, data, memSize ); ConstantHandles[ index + item.mStartIndex ] = cbh; CacheBuffers[ index + item.mStartIndex ] = ConstantBufferManager::fromHandle( cbh ); }
uint32_t ConstantBufferArrayManager::getNbrBuffers( ConstantBufferArrayHandle buffer ) { #ifdef _DEBUG if( !isValidHandle( buffer ) ) { // Todo log it return 0; } #endif return BufferArray[buffer.mIndex - 1].mValue.mNbrBuffers; }
uint32_t ConstantBufferArrayManager::getStartBindingLocation( ConstantBufferArrayHandle buffer ) { #ifdef _DEBUG if( !isValidHandle( buffer ) ) { // Todo log it return 0; } #endif return BufferArray[ buffer.mIndex - 1 ].mValue.mBindLocation; }
ID3D11Buffer * MeshManager::getIndexBuffer( MeshHandle mesh ) { #ifdef _DEBUG if( isValidHandle( mesh ) == false ) { //Todo: alert return nullptr; } #endif return Meshes[mesh.mIndex-1].mValue.mBuffers[MeshCache::INDEX_BUFFER_POSITION]; }
void ConstantBufferArrayManager::setStartBindingLocation( ConstantBufferArrayHandle buffer, uint16_t bindLocation ) { #ifdef _DEBUG if( !isValidHandle( buffer ) ) { // Todo log it return; } #endif BufferArray[buffer.mIndex - 1].mValue.mBindLocation = bindLocation; }
uint32_t MeshManager::getNbrVertexBuffers( MeshHandle mesh ) { #ifdef _DEBUG if( isValidHandle( mesh ) == false ) { //Todo: alert return 0; } #endif return Meshes[mesh.mIndex-1].mValue.mNbrOfVertexBuffers; }
void MeshManager::editMesh( MeshHandle handle, const Mesh & mesh ) { #ifdef _DEBUG if( isValidHandle( handle ) == false ) { //Todo: alert return; } #endif MeshHandleHolder & holder = MeshHandleHolders[handle.mIndex-1]; MeshCache & cache = Meshes[handle.mIndex-1].mValue; splitMesh( mesh, holder, cache ); makeCache( holder, cache ); }
void CProgressBar::slotFinishItem(const unsigned int handle) { if (isValidHandle(handle) && mProgressItemList[handle] != NULL) { QMutexLocker Locker(&mMutex); removeProgressItem(mProgressItemList[handle]); mProgressItemList[handle]->deleteLater(); mProgressItemList[handle] = NULL; } mSlotFinished = true; mWaitSlot.wakeAll(); }
ITexture* MinimapTile::getTexture() { if(!m_handle || !isValidHandle(m_handle))return 0; IResourceNode* node = (IResourceNode*)getHandleData(m_handle); if (node) { IResource* res = node->getResource(); if (res) { return (ITexture*)res->getInnerData(); } } return 0; }
void ChangePartManager::update() { if( isValidHandle(m_handle) && !m_bLoaded ) //句柄有效,且没有加载 { IResourceNode* node = (IResourceNode*)getHandleData(m_handle); if( node) { IResource * res = node->getResource(); if( res) { ModelNode * n = (ModelNode *)res->getInnerData(); if( n ) { onResLoad(n); } } } } }
Mesh MeshManager::fromHandle( MeshHandle handle ) { #ifdef _DEBUG if( isValidHandle( handle ) == false ) { //Todo: alert Mesh retValue; memset( &retValue, 0, sizeof( Mesh ) ); return retValue; } #endif Mesh mesh; MeshHandleHolder & holder = MeshHandleHolders[handle.mIndex-1]; MeshCache & cache = Meshes[handle.mIndex-1].mValue; toMesh( mesh, holder, cache ); return mesh; }
void ChangePartManager::releaeRes() { //取消外部链接 ChangePartCallBackContext context; context.pNode = 0; m_pCallBack->onChangePart(context); //释放节点前,先将子节点释放 if( m_pModelNode) { m_pModelNode->destroyAllChildren(); m_pModelNode = 0; } //释放资源 if( isValidHandle(m_handle) ) { // hero的资源延迟回收 bool bDelayRecycle = false; if (NULL != m_pOwner) { EntityViewImpl* pOwner = m_pOwner->getOwner(); if (NULL != pOwner) { bDelayRecycle = pOwner->isMainPlayer(); } } gGlobalClient->getResourceManager()->releaseResource(m_handle, bDelayRecycle); m_handle = INVALID_HANDLE; } //移除映射的资源id MZIDMap::getInstance().remove(m_ulNewResId); m_ulNewResId = 0; m_ulCurResId = 0; m_bLoaded = false; }
void ConstantBufferArrayManager::editBuffer( D3D11 & d3d, ConstantBufferArrayHandle buffer, uint32_t index, void * data, uint32_t memSize ) { #ifdef _DEBUG if( !isValidHandle( buffer ) ) { // Todo log it return; } #endif auto & item = BufferArray[buffer.mIndex - 1].mValue; #ifdef _DEBUG if( index > item.mNbrBuffers ) { // Todo log the error return; } #endif ConstantBufferManager::editBuffer( d3d, ConstantHandles[item.mStartIndex + index], data, memSize ); }
bool CProgressBar::progressItem(const unsigned C_INT32 & handle) { if (!isValidHandle(handle) || mProgressItemList[handle] == NULL) return false; QDateTime currDateTime = QDateTime::currentDateTime(); if (mNextEventProcessing >= currDateTime) return mProceed; mNextEventProcessing = currDateTime.addSecs(1); if (mPause) { mWaitPause.wait(&mMutex); } if (mpMainThread != NULL && QThread::currentThread() != mpMainThread) { QMutexLocker Locker(&mMutex); mSlotFinished = false; emit signalProgressAll(); if (!mSlotFinished) { mWaitSlot.wait(&mMutex); } } else { slotProgressAll(); } return mProceed; }
bool CProgressBar::finishItem(const unsigned C_INT32 & handle) { if (!isValidHandle(handle) || mProgressItemList[handle] == NULL) return false; if (mpMainThread != NULL && QThread::currentThread() != mpMainThread) { QMutexLocker Locker(&mMutex); mSlotFinished = false; emit signalFinishItem(handle); if (!mSlotFinished) { mWaitSlot.wait(&mMutex); } } else { slotFinishItem(handle); } return (CProcessReport::finishItem(handle) && mProceed); }
static int twoValidHandles(JNIEnv* env, jlong a, jlong b) { if (!oneValidHandle(env, a)) return JNI_FALSE; return isValidHandle(env, b, "Mandatory handle (second) passed as null"); }
static int oneValidHandle(JNIEnv* env, jlong a) { return isValidHandle(env, a, "Mandatory handle (first) passed as null"); }
static int threeValidHandles (JNIEnv* env, void* a, void *b, void* c) { if (!twoValidHandles(env, a, b)) return FALSE; return isValidHandle(env, c, "Mandatory handle (third) passed as null"); }
static int fourValidHandles (JNIEnv* env, void* a, void *b, void* c, void* d) { if (!threeValidHandles(env, a, b, c)) return FALSE; return isValidHandle(env, d, "Mandatory handle (fourth) passed as null"); }
static int twoValidHandles (JNIEnv* env, void* a, void *b) { if (!oneValidHandle(env, a)) return FALSE; return isValidHandle(env, b, "Mandatory handle (second) passed as null"); }
static int threeValidHandles(JNIEnv* env, jlong a, jlong b, jlong c) { if (!twoValidHandles(env, a, b)) return JNI_FALSE; return isValidHandle(env, c, "Mandatory handle (third) passed as null"); }
static int fourValidHandles(JNIEnv* env, jlong a, jlong b, jlong c, jlong d) { if (!threeValidHandles(env, a, b, c)) return JNI_FALSE; return isValidHandle(env, d, "Mandatory handle (fourth) passed as null"); }
bool CProgressBar::resetItem(const unsigned C_INT32 & handle) { if (!isValidHandle(handle) || mProgressItemList[handle] == NULL) return false; return (mProgressItemList[handle]->reset() && mProceed); }