Android: Fix logo not displaying during loading

This commit is contained in:
Connor McLaughlin 2020-10-07 17:58:11 +10:00
parent de33c7fa2b
commit 533722456b
3 changed files with 19 additions and 1 deletions

View file

@ -366,16 +366,26 @@ bool AndroidHostInterface::AcquireHostDisplay()
!display->InitializeRenderDevice(GetShaderCacheBasePath(), g_settings.gpu_use_debug_device)) !display->InitializeRenderDevice(GetShaderCacheBasePath(), g_settings.gpu_use_debug_device))
{ {
ReportError("Failed to acquire host display."); ReportError("Failed to acquire host display.");
display->DestroyRenderDevice();
return false; return false;
} }
m_display = std::move(display); m_display = std::move(display);
if (!CreateHostDisplayResources())
{
ReportError("Failed to create host display resources");
ReleaseHostDisplay();
return false;
}
ImGui::NewFrame(); ImGui::NewFrame();
return true; return true;
} }
void AndroidHostInterface::ReleaseHostDisplay() void AndroidHostInterface::ReleaseHostDisplay()
{ {
ReleaseHostDisplayResources();
m_display->DestroyRenderDevice(); m_display->DestroyRenderDevice();
m_display.reset(); m_display.reset();
} }
@ -830,3 +840,9 @@ DEFINE_JNI_ARGS_METHOD(void, AndroidHostInterface_setCheatEnabled, jobject obj,
AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj); AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj);
hi->RunOnEmulationThread([index, enabled, hi]() { hi->SetCheatCodeState(static_cast<u32>(index), enabled, true); }); hi->RunOnEmulationThread([index, enabled, hi]() { hi->SetCheatCodeState(static_cast<u32>(index), enabled, true); });
} }
DEFINE_JNI_ARGS_METHOD(void, AndroidHostInterface_addOSDMessage, jobject obj, jstring message, jfloat duration)
{
AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj);
hi->AddOSDMessage(AndroidHelpers::JStringToString(env, message), duration);
}

View file

@ -74,6 +74,8 @@ public class AndroidHostInterface {
public native CheatCode[] getCheatList(); public native CheatCode[] getCheatList();
public native void setCheatEnabled(int index, boolean enabled); public native void setCheatEnabled(int index, boolean enabled);
public native void addOSDMessage(String message, float duration);
static { static {
System.loadLibrary("duckstation-native"); System.loadLibrary("duckstation-native");
} }

View file

@ -372,7 +372,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
private void showCheatsMenu() { private void showCheatsMenu() {
final CheatCode[] cheats = AndroidHostInterface.getInstance().getCheatList(); final CheatCode[] cheats = AndroidHostInterface.getInstance().getCheatList();
if (cheats == null) { if (cheats == null) {
Toast.makeText(this, "No cheats are loaded.", Toast.LENGTH_LONG); AndroidHostInterface.getInstance().addOSDMessage("No cheats are loaded.", 5.0f);
return; return;
} }