当前位置: 首页>>代码示例>>C++>>正文


C++ BaseEngine::_RenderBitmap方法代码示例

本文整理汇总了C++中BaseEngine::_RenderBitmap方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseEngine::_RenderBitmap方法的具体用法?C++ BaseEngine::_RenderBitmap怎么用?C++ BaseEngine::_RenderBitmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseEngine的用法示例。


在下文中一共展示了BaseEngine::_RenderBitmap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

void*
BaseEngine::_DrawingThread(void* arg)
{
    BaseEngine*  engine =(BaseEngine*)arg;
    int& pages = engine->fPages;
    std::vector< std::pair<BBitmap*, bool> >& bitmap = engine->fBitmap;
    std::vector< pthread_mutex_t >& mutex = engine->fMutex;

    int upperbound = -1;
    int lowerbound = -1;
    int pageFuture = -1;
    int pagePast   = -1;
    int currentPage = -1;
    int deleteIndex = 0;
    bool forwardPriority = true;
	
	while(true) {
		pthread_mutex_lock(&gEngineStopMutex);
		if (engine->fStopThread) {
			engine->fStopThread = false;
			pthread_mutex_unlock(&gEngineStopMutex);
			return nullptr;			
		}
		pthread_mutex_unlock(&gEngineStopMutex);
		
        if (currentPage != engine->fCurrentPageNo) {
            if (engine->fCurrentPageNo < currentPage)
                forwardPriority = false;
            else
                forwardPriority = true;

            deleteIndex = 0;
            currentPage = engine->fCurrentPageNo;
            pageFuture = pagePast = currentPage;
            lowerbound =  currentPage - engine->fBackwardCache;
            upperbound =  currentPage + engine->fForwardCache;

            if (lowerbound < 0)         lowerbound = 0;
            if (upperbound >= pages)    upperbound = pages - 1;
        } else {
            for (; deleteIndex < pages; ++deleteIndex) {
                pthread_mutex_lock(&mutex[deleteIndex]);
                if (bitmap[deleteIndex].first != nullptr
                    && (deleteIndex < lowerbound || deleteIndex > upperbound)) {
                    delete bitmap[deleteIndex].first;
                    bitmap[deleteIndex].first = nullptr;
                    pthread_mutex_unlock(&mutex[deleteIndex]);
                    break;
                }
                pthread_mutex_unlock(&mutex[deleteIndex]);
            }

            if (forwardPriority) {
                if (pageFuture < upperbound) {
                    ++pageFuture;
                    pthread_mutex_lock(&mutex[pageFuture]);
                    if (bitmap[pageFuture].first == nullptr) {
                        bitmap[pageFuture] = engine->_RenderBitmap(pageFuture);
                    } else if (bitmap[pageFuture].second == true) {
                        delete bitmap[pageFuture].first;
                        bitmap[pageFuture] = engine->_RenderBitmap(pageFuture);
                    }
                    pthread_mutex_unlock(&mutex[pageFuture]);
                } else if (pagePast > lowerbound) {
                    --pagePast;
                    pthread_mutex_lock(&mutex[pagePast]);
                    if (bitmap[pagePast].first == nullptr) {
                        bitmap[pagePast] = engine->_RenderBitmap(pagePast);
                    } else if (bitmap[pageFuture].second == true) {
                        delete bitmap[pageFuture].first;
                        bitmap[pageFuture] = engine->_RenderBitmap(pageFuture);
                    }
                    pthread_mutex_unlock(&mutex[pagePast]);
                } else {
                    usleep(1000);
                }
            } else {
                if (pagePast > lowerbound) {
                    --pagePast;
                    pthread_mutex_lock(&mutex[pagePast]);
                    if (bitmap[pagePast].first == nullptr)
                        bitmap[pagePast] = engine->_RenderBitmap(pagePast);

                    pthread_mutex_unlock(&mutex[pagePast]);
                } else if (pageFuture < upperbound) {
                    ++pageFuture;
                    pthread_mutex_lock(&mutex[pageFuture]);
                    if (bitmap[pageFuture].first == nullptr)
                        bitmap[pageFuture] = engine->_RenderBitmap(pageFuture);

                    pthread_mutex_unlock(&mutex[pageFuture]);
                } else {
                    usleep(1000);
                }
            }
        }
    }
	return nullptr;
}
开发者ID:humdingerb,项目名称:DocumentViewer,代码行数:99,代码来源:BaseEngine.cpp


注:本文中的BaseEngine::_RenderBitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。