// // int FramBufMgrInit(unsigned char *pBufBase, int nBufSize) // // Description // This function initializes the MfcFramBufMgr(Buffer Segment Manager) // Parameters // pBufBase [IN]: pointer to the buffer which will be managed by this MfcFramBufMgr functions. // nBufSize [IN]: buffer size in bytes // Return Value // 1 : Success // 0 : Fail // BOOL FramBufMgrInit(unsigned char *pBufBase, int nBufSize) { int i; // check parameters if (pBufBase == NULL || nBufSize == 0) return FALSE; // 이미 초기화가 되어 있고 // (1) 초기화 결과와 입력 파라미터 값이 같다면 // 실수로 이 함수가 두 번 호출된 것이므로 그냥 바로 1을 리턴 // (2) 같지 않다면, // Finalize 시킨 후, 다시 재 초기화 한다. if ((_pBufferBase != NULL) && (_nBufferSize != 0)) { if ((pBufBase == _pBufferBase) && (nBufSize == _nBufferSize)) return TRUE; FramBufMgrFinal(); } _pBufferBase = pBufBase; _nBufferSize = nBufSize; _nNumSegs = nBufSize / BUF_SEGMENT_SIZE; _p_segment_info = (SEGMENT_INFO *) Mem_Alloc(_nNumSegs * sizeof(SEGMENT_INFO)); for (i=0; i<_nNumSegs; i++) { _p_segment_info[i].pBaseAddr = pBufBase + (i * BUF_SEGMENT_SIZE); _p_segment_info[i].idx_commit = 0; } _p_commit_info = (COMMIT_INFO *) Mem_Alloc(_nNumSegs * sizeof(COMMIT_INFO)); for (i=0; i<_nNumSegs; i++) { _p_commit_info[i].index_base_seg = -1; _p_commit_info[i].num_segs = 0; } return TRUE; }
// // int FramBufMgrInit(unsigned char *pBufBase, int nBufSize) // // Description // This function initializes the MfcFramBufMgr(Buffer Segment Manager) // Parameters // pBufBase [IN]: pointer to the buffer which will be managed by this MfcFramBufMgr functions. // nBufSize [IN]: buffer size in bytes // Return Value // 1 : Success // 0 : Fail // BOOL FramBufMgrInit(unsigned char *pBufBase, int nBufSize) { int i; // check parameters if (pBufBase == NULL || nBufSize == 0) return FALSE; // If the frame buffer is already initialized // (1) and the result of initialization equals input parameters, // You have to return 1 immediately because this function is called by misatake. // (2) and the result of initialization does not equal input parameters, // You have to re-initialize after finalize. if ((_pBufferBase != NULL) && (_nBufferSize != 0)) { if ((pBufBase == _pBufferBase) && (nBufSize == _nBufferSize)) return TRUE; FramBufMgrFinal(); } _pBufferBase = pBufBase; _nBufferSize = nBufSize; _nNumSegs = nBufSize / BUF_SEGMENT_SIZE; _p_segment_info = (SEGMENT_INFO *) Mem_Alloc(_nNumSegs * sizeof(SEGMENT_INFO)); for (i=0; i<_nNumSegs; i++) { _p_segment_info[i].pBaseAddr = pBufBase + (i * BUF_SEGMENT_SIZE); _p_segment_info[i].idx_commit = 0; } _p_commit_info = (COMMIT_INFO *) Mem_Alloc(_nNumSegs * sizeof(COMMIT_INFO)); for (i=0; i<_nNumSegs; i++) { _p_commit_info[i].index_base_seg = -1; _p_commit_info[i].num_segs = 0; } return TRUE; }