Android: Save screenshot at end of an emulation session.

This commit is contained in:
sigmabeta
2015-06-18 21:28:40 -04:00
committed by Eder Bastos
parent 2cea910431
commit a028805626
11 changed files with 62 additions and 17 deletions

View File

@ -671,6 +671,22 @@ void SaveScreenShot()
SetState(CORE_RUN);
}
void SaveScreenShot(std::string name)
{
const bool bPaused = (GetState() == CORE_PAUSE);
SetState(CORE_PAUSE);
const std::string& gameId = SConfig::GetInstance().GetUniqueID();
std::string path = File::GetUserPath(D_SCREENSHOTS_IDX) + gameId + DIR_SEP_CHR;
name = StringFromFormat("%s%s.png", path.c_str(), name.c_str());
g_video_backend->Video_Screenshot(name);
if (!bPaused)
SetState(CORE_RUN);
}
void RequestRefreshInfo()
{
s_request_refresh_info = true;

View File

@ -52,6 +52,7 @@ void SetState(EState _State);
EState GetState();
void SaveScreenShot();
void SaveScreenShot(std::string name);
void Callback_WiimoteInterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);

View File

@ -31,6 +31,7 @@
#include "UICommon/UICommon.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoBackendBase.h"
ANativeWindow* surf;
@ -40,6 +41,7 @@ std::string g_set_userpath = "";
JavaVM* g_java_vm;
jclass g_jni_class;
jmethodID g_jni_method_alert;
jmethodID g_jni_method_end;
#define DOLPHIN_TAG "DolphinEmuNative"
@ -394,6 +396,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulati
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv *env, jobject obj)
{
Core::SaveScreenShot("thumb");
Renderer::s_screenshotCompleted.Wait();
Core::Stop();
updateMainFrameEvent.Set(); // Kick the waiting event
}
@ -591,6 +595,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_CacheClasses
// Method signature taken from javap -s Source/Android/app/build/intermediates/classes/arm/debug/org/dolphinemu/dolphinemu/NativeLibrary.class
g_jni_method_alert = env->GetStaticMethodID(g_jni_class, "displayAlertMsg", "(Ljava/lang/String;)V");
g_jni_method_end = env->GetStaticMethodID(g_jni_class, "endEmulationActivity", "()V");
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jobject _surf)
@ -624,6 +629,9 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *
UICommon::Shutdown();
ANativeWindow_release(surf);
// Execute the Java method.
env->CallStaticVoidMethod(g_jni_class, g_jni_method_end);
}

View File

@ -1510,6 +1510,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
// Reset settings
s_sScreenshotName.clear();
s_bScreenshot = false;
s_screenshotCompleted.Set();
}
// Frame dumps are handled a little differently in Windows

View File

@ -17,6 +17,7 @@
#include <string>
#include "Common/Atomic.h"
#include "Common/Event.h"
#include "Common/Profiler.h"
#include "Common/StringUtil.h"
#include "Common/Timer.h"
@ -53,6 +54,8 @@ Renderer *g_renderer = nullptr;
std::mutex Renderer::s_criticalScreenshot;
std::string Renderer::s_sScreenshotName;
Common::Event Renderer::s_screenshotCompleted;
volatile bool Renderer::s_bScreenshot;
// The framebuffer size

View File

@ -17,6 +17,7 @@
#include <mutex>
#include <string>
#include "Common/Event.h"
#include "Common/MathUtil.h"
#include "Common/Thread.h"
#include "VideoCommon/BPMemory.h"
@ -133,6 +134,8 @@ public:
// Max height/width
virtual int GetMaxTextureSize() = 0;
static Common::Event s_screenshotCompleted;
protected:
static void CalculateTargetScale(int x, int y, int* scaledX, int* scaledY);