本文整理汇总了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;
}