Browse Source

Android fixes. OSX fix for old SDKs.

tags/2021-05-28
jules 13 years ago
parent
commit
53c0436d71
7 changed files with 61 additions and 73 deletions
  1. +1
    -0
      modules/juce_core/maths/juce_BigInteger.cpp
  2. +1
    -1
      modules/juce_core/native/juce_android_JNIHelpers.h
  3. +4
    -1
      modules/juce_events/messages/juce_MessageManager.cpp
  4. +10
    -11
      modules/juce_events/native/juce_android_Messaging.cpp
  5. +7
    -16
      modules/juce_gui_basics/native/juce_android_Windowing.cpp
  6. +1
    -1
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm
  7. +37
    -43
      modules/juce_opengl/native/juce_OpenGL_android.h

+ 1
- 0
modules/juce_core/maths/juce_BigInteger.cpp View File

@@ -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);


+ 1
- 1
modules/juce_core/native/juce_android_JNIHelpers.h View File

@@ -270,7 +270,7 @@ public:
JNIEnv* attach()
{
JNIEnv* env = nullptr;
jvm->AttachCurrentThread (&env, 0);
jvm->AttachCurrentThread (&env, nullptr);
if (env != nullptr)
addEnv (env);


+ 4
- 1
modules/juce_events/messages/juce_MessageManager.cpp View File

@@ -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();


+ 10
- 11
modules/juce_events/native/juce_android_Messaging.cpp View File

@@ -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
void MessageManager::stopDispatchLoop()
{
public:
QuitCallback() {}
void messageCallback()
struct QuitCallback : public CallbackMessage
{
android.activity.callVoidMethod (JuceAppActivity.finish);
}
};
QuitCallback() {}
void messageCallback()
{
android.activity.callVoidMethod (JuceAppActivity.finish);
}
};
void MessageManager::stopDispatchLoop()
{
(new QuitCallback())->post();
quitMessagePosted = true;
}

+ 7
- 16
modules/juce_gui_basics/native/juce_android_Windowing.cpp View File

@@ -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();
}
//==============================================================================


+ 1
- 1
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -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;
}


+ 37
- 43
modules/juce_opengl/native/juce_OpenGL_android.h View File

@@ -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…
Cancel
Save