1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed some dodgy threading in the openGL rendering context.

This commit is contained in:
jules 2012-12-27 22:00:17 +00:00
parent 906a99763d
commit ff20ad64f3
2 changed files with 13 additions and 22 deletions

View file

@ -37,7 +37,7 @@ public:
#else
shadersAvailable (false),
#endif
needsUpdate (true)
needsUpdate (1)
{
nativeContext = new NativeContext (component, pixFormat, contextToShare);
@ -90,7 +90,7 @@ public:
void triggerRepaint()
{
needsUpdate = true;
needsUpdate = 1;
#if JUCE_ANDROID
if (nativeContext != nullptr)
@ -143,7 +143,9 @@ public:
{
ScopedPointer<MessageManagerLock> mmLock;
if (context.renderComponents && needsUpdate)
const bool isUpdating = needsUpdate.compareAndSetBool (0, 1);
if (context.renderComponents && isUpdating)
{
mmLock = new MessageManagerLock (this); // need to acquire this before locking the context.
if (! mmLock->lockWasGained())
@ -166,9 +168,8 @@ public:
if (context.renderComponents)
{
if (needsUpdate)
if (isUpdating)
{
needsUpdate = false;
paintComponent();
mmLock = nullptr;
}
@ -357,8 +358,8 @@ public:
ReferenceCountedArray<ReferenceCountedObject> associatedObjects;
WaitableEvent canPaintNowFlag, finishedPaintingFlag;
bool volatile shadersAvailable;
bool volatile needsUpdate;
bool shadersAvailable;
Atomic<int> needsUpdate;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CachedImage)
};