mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Merge pull request #2624 from sigmabeta/android-save-screenshot
Android: Save screenshot at end of an emulation session.
This commit is contained in:
@ -636,7 +636,7 @@ EState GetState()
|
||||
return CORE_UNINITIALIZED;
|
||||
}
|
||||
|
||||
static std::string GenerateScreenshotName()
|
||||
static std::string GenerateScreenshotFolderPath()
|
||||
{
|
||||
const std::string& gameId = SConfig::GetInstance().GetUniqueID();
|
||||
std::string path = File::GetUserPath(D_SCREENSHOTS_IDX) + gameId + DIR_SEP_CHR;
|
||||
@ -647,8 +647,15 @@ static std::string GenerateScreenshotName()
|
||||
path = File::GetUserPath(D_SCREENSHOTS_IDX);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
static std::string GenerateScreenshotName()
|
||||
{
|
||||
std::string path = GenerateScreenshotFolderPath();
|
||||
|
||||
//append gameId, path only contains the folder here.
|
||||
path += gameId;
|
||||
path += SConfig::GetInstance().GetUniqueID();
|
||||
|
||||
std::string name;
|
||||
for (int i = 1; File::Exists(name = StringFromFormat("%s-%d.png", path.c_str(), i)); ++i)
|
||||
@ -671,6 +678,20 @@ void SaveScreenShot()
|
||||
SetState(CORE_RUN);
|
||||
}
|
||||
|
||||
void SaveScreenShot(const std::string name)
|
||||
{
|
||||
const bool bPaused = (GetState() == CORE_PAUSE);
|
||||
|
||||
SetState(CORE_PAUSE);
|
||||
|
||||
std::string filePath = GenerateScreenshotFolderPath() + name + ".png";
|
||||
|
||||
g_video_backend->Video_Screenshot(filePath);
|
||||
|
||||
if (!bPaused)
|
||||
SetState(CORE_RUN);
|
||||
}
|
||||
|
||||
void RequestRefreshInfo()
|
||||
{
|
||||
s_request_refresh_info = true;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1515,6 +1515,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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user