summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llimagegl.cpp69
-rw-r--r--indra/llrender/llimagegl.h18
2 files changed, 12 insertions, 75 deletions
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index cbc5392882..71c48801ac 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -183,13 +183,6 @@ void LLImageGL::initClass(LLWindow* window, S32 num_catagories, BOOL skip_analyz
LLImageGLThread::sInstance->start();
}
-//static
-void LLImageGL::updateClass()
-{
- LL_PROFILE_ZONE_SCOPED;
- LLImageGLThread::sInstance->executeCallbacks();
-}
-
//static
void LLImageGL::cleanupClass()
{
@@ -504,6 +497,9 @@ void LLImageGL::init(BOOL usemipmaps)
#endif
mCategory = -1;
+
+ // Sometimes we have to post work for the main thread.
+ mMainQueue = LL::WorkQueue::getInstance("mainloop");
}
void LLImageGL::cleanup()
@@ -1554,7 +1550,9 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
}
ref();
- LLImageGLThread::sInstance->postCallback([=]()
+ LL::WorkQueue::postMaybe(
+ mMainQueue,
+ [=]()
{
LL_PROFILE_ZONE_NAMED("cglt - delete callback");
if (old_texname != 0)
@@ -2266,61 +2264,6 @@ LLImageGLThread::LLImageGLThread(LLWindow* window)
mContext = mWindow->createSharedContext();
}
-// post a function to be executed on the LLImageGL background thread
-
-bool LLImageGLThread::post(const std::function<void()>& func)
-{
- try
- {
- mFunctionQueue.post(func);
- }
- catch (LLThreadSafeQueueInterrupt e)
- {
- return false;
- }
-
- return true;
-}
-
-//post a callback to be executed on the main thread
-
-bool LLImageGLThread::postCallback(const std::function<void()>& callback)
-{
- try
- {
- if (!mCallbackQueue.tryPost(callback))
- {
- mPendingCallbackQ.push(callback);
- }
- }
- catch (LLThreadSafeQueueInterrupt e)
- {
- //thread is closing, drop request
- return false;
- }
-
- return true;
-}
-
-void LLImageGLThread::executeCallbacks()
-{
- LL_PROFILE_ZONE_SCOPED;
- //executed from main thread
- mCallbackQueue.runPending();
-
- while (!mPendingCallbackQ.empty())
- {
- if (mCallbackQueue.tryPost(mPendingCallbackQ.front()))
- {
- mPendingCallbackQ.pop();
- }
- else
- {
- break;
- }
- }
-}
-
void LLImageGLThread::run()
{
mWindow->makeContextCurrent(mContext);
diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h
index 8264e4a5f2..b9de481aae 100644
--- a/indra/llrender/llimagegl.h
+++ b/indra/llrender/llimagegl.h
@@ -198,6 +198,7 @@ private:
void freePickMask();
LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL
+ LL::WorkQueue::weak_t mMainQueue;
U8* mPickMask; //downsampled bitmap approximation of alpha channel. NULL if no alpha channel
U16 mPickMaskWidth;
U16 mPickMaskHeight;
@@ -271,7 +272,6 @@ public:
public:
static void initClass(LLWindow* window, S32 num_catagories, BOOL skip_analyze_alpha = false);
- static void updateClass();
static void cleanupClass() ;
private:
@@ -313,27 +313,21 @@ public:
LLImageGLThread(LLWindow* window);
// post a function to be executed on the LLImageGL background thread
- bool post(const std::function<void()>& func);
-
- //post a callback to be executed on the main thread
- bool postCallback(const std::function<void()>& callback);
-
- void executeCallbacks();
+ template <typename CALLABLE>
+ bool post(CALLABLE&& func)
+ {
+ return mFunctionQueue.postIfOpen(std::forward<CALLABLE>(func));
+ }
void run() override;
// Work Queue for background thread
LL::WorkQueue mFunctionQueue;
- // Work Queue for main thread (run from updateClass)
- LL::WorkQueue mCallbackQueue;
-
LLWindow* mWindow;
void* mContext;
LLAtomicBool mFinished;
- std::queue<std::function<void()>> mPendingCallbackQ;
-
static LLImageGLThread* sInstance;
};