mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-07 04:10:08 +00:00
Android fixes. OSX fix for old SDKs.
This commit is contained in:
parent
8c00299f8d
commit
53c0436d71
7 changed files with 62 additions and 74 deletions
|
|
@ -118,6 +118,7 @@ BigInteger& BigInteger::operator= (const BigInteger& other)
|
|||
if (this != &other)
|
||||
{
|
||||
highestBit = other.getHighestBit();
|
||||
jassert (other.numValues >= 4);
|
||||
numValues = (size_t) jmax ((size_t) 4, bitToIndex (highestBit) + 1);
|
||||
negative = other.negative;
|
||||
values.malloc (numValues + 1);
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ public:
|
|||
JNIEnv* attach()
|
||||
{
|
||||
JNIEnv* env = nullptr;
|
||||
jvm->AttachCurrentThread (&env, 0);
|
||||
jvm->AttachCurrentThread (&env, nullptr);
|
||||
|
||||
if (env != nullptr)
|
||||
addEnv (env);
|
||||
|
|
|
|||
|
|
@ -158,9 +158,12 @@ private:
|
|||
|
||||
void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* const func, void* const parameter)
|
||||
{
|
||||
if (MessageManager::getInstance()->isThisTheMessageThread())
|
||||
if (isThisTheMessageThread())
|
||||
return func (parameter);
|
||||
|
||||
// If this thread has the message manager locked, then this will deadlock!
|
||||
jassert (! currentThreadHasLockedMessageManager());
|
||||
|
||||
const ReferenceCountedObjectPtr<AsyncFunctionCallback> message (new AsyncFunctionCallback (func, parameter));
|
||||
message->post();
|
||||
message->finished.wait();
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ bool MessageManager::dispatchNextMessageOnSystemQueue (const bool returnIfNoPend
|
|||
bool MessageManager::postMessageToSystemQueue (MessageManager::MessageBase* const message)
|
||||
{
|
||||
message->incReferenceCount();
|
||||
getEnv()->CallVoidMethod (android.activity, JuceAppActivity.postMessage, (jlong) (pointer_sized_uint) message);
|
||||
android.activity.callVoidMethod (JuceAppActivity.postMessage, (jlong) (pointer_sized_uint) message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -63,19 +63,18 @@ void MessageManager::runDispatchLoop()
|
|||
{
|
||||
}
|
||||
|
||||
class QuitCallback : public CallbackMessage
|
||||
{
|
||||
public:
|
||||
QuitCallback() {}
|
||||
|
||||
void messageCallback()
|
||||
{
|
||||
android.activity.callVoidMethod (JuceAppActivity.finish);
|
||||
}
|
||||
};
|
||||
|
||||
void MessageManager::stopDispatchLoop()
|
||||
{
|
||||
struct QuitCallback : public CallbackMessage
|
||||
{
|
||||
QuitCallback() {}
|
||||
|
||||
void messageCallback()
|
||||
{
|
||||
android.activity.callVoidMethod (JuceAppActivity.finish);
|
||||
}
|
||||
};
|
||||
|
||||
(new QuitCallback())->post();
|
||||
quitMessagePosted = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,14 +111,9 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
class ViewDeleter : public CallbackMessage
|
||||
struct ViewDeleter : public CallbackMessage
|
||||
{
|
||||
public:
|
||||
ViewDeleter (const GlobalRef& view_)
|
||||
: view (view_)
|
||||
{
|
||||
post();
|
||||
}
|
||||
ViewDeleter (const GlobalRef& view_) : view (view_) {}
|
||||
|
||||
void messageCallback()
|
||||
{
|
||||
|
|
@ -129,7 +124,7 @@ public:
|
|||
GlobalRef view;
|
||||
};
|
||||
|
||||
new ViewDeleter (view);
|
||||
(new ViewDeleter (view))->post();
|
||||
}
|
||||
|
||||
view.clear();
|
||||
|
|
@ -148,14 +143,11 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
class VisibilityChanger : public CallbackMessage
|
||||
struct VisibilityChanger : public CallbackMessage
|
||||
{
|
||||
public:
|
||||
VisibilityChanger (const GlobalRef& view_, bool shouldBeVisible_)
|
||||
: view (view_), shouldBeVisible (shouldBeVisible_)
|
||||
{
|
||||
post();
|
||||
}
|
||||
{}
|
||||
|
||||
void messageCallback()
|
||||
{
|
||||
|
|
@ -167,7 +159,7 @@ public:
|
|||
bool shouldBeVisible;
|
||||
};
|
||||
|
||||
new VisibilityChanger (view, shouldBeVisible);
|
||||
(new VisibilityChanger (view, shouldBeVisible))->post();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -714,8 +706,7 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, setScreenSize, void, (JNIEnv
|
|||
android.screenWidth = screenWidth;
|
||||
android.screenHeight = screenHeight;
|
||||
|
||||
if (isSystemInitialised)
|
||||
Desktop::getInstance().refreshMonitorSizes();
|
||||
Desktop::getInstance().refreshMonitorSizes();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -906,7 +906,7 @@ void NSViewComponentPeer::updateKeysDown (NSEvent* ev, bool isKeyDown)
|
|||
ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept
|
||||
{
|
||||
if ([NSEvent respondsToSelector: @selector (modifierFlags)])
|
||||
NSViewComponentPeer::updateModifiers ([NSEvent modifierFlags]);
|
||||
NSViewComponentPeer::updateModifiers ((NSUInteger) [NSEvent modifierFlags]);
|
||||
|
||||
return NSViewComponentPeer::currentModifiers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,10 @@ public:
|
|||
: component (component_),
|
||||
isInsideGLCallback (false)
|
||||
{
|
||||
glView = GlobalRef (createOpenGLView (component.getPeer()));
|
||||
|
||||
{
|
||||
const ScopedLock sl (getContextListLock());
|
||||
getContextList().add (this);
|
||||
const ScopedLock sl (contextListLock);
|
||||
glView = GlobalRef (createOpenGLView (component.getPeer()));
|
||||
contextList.add (this);
|
||||
}
|
||||
|
||||
updateWindowPosition (component.getTopLevelComponent()
|
||||
|
|
@ -56,8 +55,8 @@ public:
|
|||
~NativeContext()
|
||||
{
|
||||
{
|
||||
const ScopedLock sl (getContextListLock());
|
||||
getContextList().removeValue (this);
|
||||
const ScopedLock sl (contextListLock);
|
||||
contextList.removeValue (this);
|
||||
}
|
||||
|
||||
android.activity.callVoidMethod (JuceAppActivity.deleteView, glView.get());
|
||||
|
|
@ -95,6 +94,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void contextChangedSize()
|
||||
{
|
||||
}
|
||||
|
||||
void triggerRepaint()
|
||||
{
|
||||
glView.callVoidMethod (OpenGLView.requestRender);
|
||||
|
|
@ -107,12 +110,11 @@ public:
|
|||
//==============================================================================
|
||||
static NativeContext* findContextFor (JNIEnv* env, jobject glView)
|
||||
{
|
||||
const ScopedLock sl (getContextListLock());
|
||||
const ContextArray& contexts = getContextList();
|
||||
const ScopedLock sl (contextListLock);
|
||||
|
||||
for (int i = contexts.size(); --i >= 0;)
|
||||
for (int i = contextList.size(); --i >= 0;)
|
||||
{
|
||||
NativeContext* const c = contexts.getUnchecked(i);
|
||||
NativeContext* const c = contextList.getUnchecked(i);
|
||||
|
||||
if (env->IsSameObject (c->glView.get(), glView))
|
||||
return c;
|
||||
|
|
@ -123,12 +125,11 @@ public:
|
|||
|
||||
static NativeContext* getActiveContext() noexcept
|
||||
{
|
||||
const ScopedLock sl (getContextListLock());
|
||||
const ContextArray& contexts = getContextList();
|
||||
const ScopedLock sl (contextListLock);
|
||||
|
||||
for (int i = contexts.size(); --i >= 0;)
|
||||
for (int i = contextList.size(); --i >= 0;)
|
||||
{
|
||||
NativeContext* const c = contexts.getUnchecked(i);
|
||||
NativeContext* const c = contextList.getUnchecked(i);
|
||||
|
||||
if (c->isInsideGLCallback)
|
||||
return c;
|
||||
|
|
@ -144,23 +145,16 @@ private:
|
|||
Rectangle<int> lastBounds;
|
||||
bool isInsideGLCallback;
|
||||
|
||||
static CriticalSection& getContextListLock()
|
||||
{
|
||||
static CriticalSection lock;
|
||||
return lock;
|
||||
}
|
||||
|
||||
typedef Array<NativeContext*> ContextArray;
|
||||
|
||||
static ContextArray& getContextList()
|
||||
{
|
||||
static ContextArray contexts;
|
||||
return contexts;
|
||||
}
|
||||
static CriticalSection contextListLock;
|
||||
static ContextArray contextList;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeContext);
|
||||
};
|
||||
|
||||
CriticalSection OpenGLContext::NativeContext::contextListLock;
|
||||
OpenGLContext::NativeContext::ContextArray OpenGLContext::NativeContext::contextList;
|
||||
|
||||
//==============================================================================
|
||||
bool OpenGLHelpers::isContextActive()
|
||||
{
|
||||
|
|
@ -168,34 +162,34 @@ bool OpenGLHelpers::isContextActive()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
JUCE_JNI_CALLBACK (JUCE_JOIN_MACRO (JUCE_ANDROID_ACTIVITY_CLASSNAME, _00024OpenGLView), contextCreated, void, (JNIEnv* env, jobject view))
|
||||
#define GL_VIEW_CLASS_NAME JUCE_JOIN_MACRO (JUCE_ANDROID_ACTIVITY_CLASSNAME, _00024OpenGLView)
|
||||
|
||||
JUCE_JNI_CALLBACK (GL_VIEW_CLASS_NAME, contextCreated, void, (JNIEnv* env, jobject view))
|
||||
{
|
||||
threadLocalJNIEnvHolder.getOrAttach();
|
||||
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
OpenGLContext::NativeContext* const context = OpenGLContext::NativeContext::findContextFor (env, view);
|
||||
|
||||
for (int i = 100; --i >= 0;)
|
||||
if (context != nullptr)
|
||||
{
|
||||
OpenGLContext::NativeContext* const context = OpenGLContext::NativeContext::findContextFor (env, view);
|
||||
|
||||
if (context != nullptr)
|
||||
{
|
||||
context->contextCreatedCallback();
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
return;
|
||||
}
|
||||
|
||||
Thread::sleep (20);
|
||||
context->contextCreatedCallback();
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
}
|
||||
else
|
||||
{
|
||||
jassertfalse;
|
||||
}
|
||||
|
||||
jassertfalse;
|
||||
}
|
||||
|
||||
JUCE_JNI_CALLBACK (JUCE_JOIN_MACRO (JUCE_ANDROID_ACTIVITY_CLASSNAME, _00024OpenGLView), contextChangedSize, void, (JNIEnv* env, jobject view))
|
||||
JUCE_JNI_CALLBACK (GL_VIEW_CLASS_NAME, contextChangedSize, void, (JNIEnv* env, jobject view))
|
||||
{
|
||||
OpenGLContext::NativeContext* const context = OpenGLContext::NativeContext::findContextFor (env, view);
|
||||
|
||||
if (context != nullptr)
|
||||
context->contextChangedSize();
|
||||
}
|
||||
|
||||
JUCE_JNI_CALLBACK (JUCE_JOIN_MACRO (JUCE_ANDROID_ACTIVITY_CLASSNAME, _00024OpenGLView), render, void, (JNIEnv* env, jobject view))
|
||||
JUCE_JNI_CALLBACK (GL_VIEW_CLASS_NAME, render, void, (JNIEnv* env, jobject view))
|
||||
{
|
||||
OpenGLContext::NativeContext* const context = OpenGLContext::NativeContext::findContextFor (env, view);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue