summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llrender/llimagegl.cpp69
-rw-r--r--indra/llrender/llimagegl.h18
-rw-r--r--indra/newview/llappviewer.cpp1
-rw-r--r--indra/newview/llviewertexture.cpp2
4 files changed, 13 insertions, 77 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;
};
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 220dff3ccb..ea2e3a4007 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4848,7 +4848,6 @@ void LLAppViewer::idle()
LLNotificationsUI::LLToast::updateClass();
LLSmoothInterpolation::updateInterpolants();
LLMortician::updateClass();
- LLImageGL::updateClass();
LLFilePickerThread::clearDead(); //calls LLFilePickerThread::notify()
LLDirPickerThread::clearDead();
F32 dt_raw = idle_timer.getElapsedTimeAndResetF32();
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index fbc5830a5c..9f3819f7d1 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -1626,7 +1626,7 @@ void LLViewerFetchedTexture::scheduleCreateTexture()
{
//actually create the texture on a background thread
createTexture();
- LLImageGLThread::sInstance->postCallback([this]()
+ LL::WorkQueue::getInstance("mainloop")->post([this]()
{
//finalize on main thread
postCreateTexture();