mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Core.cpp: Some slight simplifications
This commit is contained in:
parent
0deefb82a9
commit
0477ba8c78
@ -59,14 +59,12 @@ static uint32_t steppingAddress = 0;
|
|||||||
static std::set<CoreLifecycleFunc> lifecycleFuncs;
|
static std::set<CoreLifecycleFunc> lifecycleFuncs;
|
||||||
static std::set<CoreStopRequestFunc> stopFuncs;
|
static std::set<CoreStopRequestFunc> stopFuncs;
|
||||||
static bool windowHidden = false;
|
static bool windowHidden = false;
|
||||||
static GraphicsContext *graphicsContext;
|
|
||||||
static bool powerSaving = false;
|
static bool powerSaving = false;
|
||||||
|
|
||||||
static MIPSExceptionInfo g_exceptionInfo;
|
static MIPSExceptionInfo g_exceptionInfo;
|
||||||
|
|
||||||
void Core_SetGraphicsContext(GraphicsContext *ctx) {
|
void Core_SetGraphicsContext(GraphicsContext *ctx) {
|
||||||
graphicsContext = ctx;
|
PSP_CoreParameter().graphicsContext = ctx;
|
||||||
PSP_CoreParameter().graphicsContext = graphicsContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core_NotifyWindowHidden(bool hidden) {
|
void Core_NotifyWindowHidden(bool hidden) {
|
||||||
@ -198,24 +196,28 @@ bool UpdateScreenScale(int width, int height) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: not used on Android.
|
// Used by Windows, SDL, Qt.
|
||||||
void UpdateRunLoop() {
|
void UpdateRunLoop(GraphicsContext *ctx) {
|
||||||
|
NativeFrame(ctx);
|
||||||
if (windowHidden && g_Config.bPauseWhenMinimized) {
|
if (windowHidden && g_Config.bPauseWhenMinimized) {
|
||||||
sleep_ms(16);
|
sleep_ms(16);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NativeFrame(graphicsContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: not used on Android.
|
||||||
void Core_RunLoop(GraphicsContext *ctx) {
|
void Core_RunLoop(GraphicsContext *ctx) {
|
||||||
float refreshRate = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);
|
float refreshRate = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);
|
||||||
|
|
||||||
graphicsContext = ctx;
|
if (windowHidden && g_Config.bPauseWhenMinimized) {
|
||||||
while ((GetUIState() != UISTATE_INGAME || !PSP_IsInited()) && GetUIState() != UISTATE_EXIT) {
|
sleep_ms(16);
|
||||||
// In case it was pending, we're not in game anymore. We won't get to Core_Run().
|
return;
|
||||||
Core_StateProcessed();
|
}
|
||||||
|
|
||||||
|
if ((GetUIState() != UISTATE_INGAME || !PSP_IsInited()) && GetUIState() != UISTATE_EXIT) {
|
||||||
|
// In case it was pending, we're not in game anymore.
|
||||||
double startTime = time_now_d();
|
double startTime = time_now_d();
|
||||||
UpdateRunLoop();
|
NativeFrame(ctx);
|
||||||
|
|
||||||
// Simple throttling to not burn the GPU in the menu.
|
// Simple throttling to not burn the GPU in the menu.
|
||||||
double diffTime = time_now_d() - startTime;
|
double diffTime = time_now_d() - startTime;
|
||||||
@ -227,8 +229,8 @@ void Core_RunLoop(GraphicsContext *ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((coreState == CORE_RUNNING || coreState == CORE_STEPPING) && GetUIState() == UISTATE_INGAME) {
|
if ((coreState == CORE_RUNNING || coreState == CORE_STEPPING) && GetUIState() == UISTATE_INGAME) {
|
||||||
UpdateRunLoop();
|
NativeFrame(ctx);
|
||||||
if (!windowHidden && !Core_IsStepping()) {
|
if (!windowHidden && !Core_IsStepping()) {
|
||||||
ctx->SwapBuffers();
|
ctx->SwapBuffers();
|
||||||
}
|
}
|
||||||
@ -308,7 +310,8 @@ bool Core_Run(GraphicsContext *ctx) {
|
|||||||
if (GetUIState() != UISTATE_INGAME) {
|
if (GetUIState() != UISTATE_INGAME) {
|
||||||
Core_StateProcessed();
|
Core_StateProcessed();
|
||||||
if (GetUIState() == UISTATE_EXIT) {
|
if (GetUIState() == UISTATE_EXIT) {
|
||||||
UpdateRunLoop();
|
// Not sure why we do a final frame here?
|
||||||
|
NativeFrame(ctx);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Core_RunLoop(ctx);
|
Core_RunLoop(ctx);
|
||||||
@ -318,6 +321,7 @@ bool Core_Run(GraphicsContext *ctx) {
|
|||||||
switch (coreState) {
|
switch (coreState) {
|
||||||
case CORE_RUNNING:
|
case CORE_RUNNING:
|
||||||
case CORE_STEPPING:
|
case CORE_STEPPING:
|
||||||
|
Core_StateProcessed();
|
||||||
// enter a fast runloop
|
// enter a fast runloop
|
||||||
Core_RunLoop(ctx);
|
Core_RunLoop(ctx);
|
||||||
if (coreState == CORE_POWERDOWN) {
|
if (coreState == CORE_POWERDOWN) {
|
||||||
@ -332,7 +336,6 @@ bool Core_Run(GraphicsContext *ctx) {
|
|||||||
case CORE_RUNTIME_ERROR:
|
case CORE_RUNTIME_ERROR:
|
||||||
// Exit loop!!
|
// Exit loop!!
|
||||||
Core_StateProcessed();
|
Core_StateProcessed();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case CORE_NEXTFRAME:
|
case CORE_NEXTFRAME:
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
class GraphicsContext;
|
class GraphicsContext;
|
||||||
|
|
||||||
// called from emu thread
|
// called from emu thread
|
||||||
void UpdateRunLoop();
|
void UpdateRunLoop(GraphicsContext *ctx);
|
||||||
|
|
||||||
// Returns false when an UI exit state is detected.
|
// Returns false when an UI exit state is detected.
|
||||||
bool Core_Run(GraphicsContext *ctx);
|
bool Core_Run(GraphicsContext *ctx);
|
||||||
|
@ -475,7 +475,7 @@ void MainUI::EmuThreadFunc() {
|
|||||||
emuThreadState = (int)EmuThreadState::RUNNING;
|
emuThreadState = (int)EmuThreadState::RUNNING;
|
||||||
while (emuThreadState != (int)EmuThreadState::QUIT_REQUESTED) {
|
while (emuThreadState != (int)EmuThreadState::QUIT_REQUESTED) {
|
||||||
updateAccelerometer();
|
updateAccelerometer();
|
||||||
UpdateRunLoop();
|
UpdateRunLoop(graphicsContext);
|
||||||
}
|
}
|
||||||
emuThreadState = (int)EmuThreadState::STOPPED;
|
emuThreadState = (int)EmuThreadState::STOPPED;
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ void MainUI::paintGL() {
|
|||||||
#endif
|
#endif
|
||||||
updateAccelerometer();
|
updateAccelerometer();
|
||||||
if (emuThreadState == (int)EmuThreadState::DISABLED) {
|
if (emuThreadState == (int)EmuThreadState::DISABLED) {
|
||||||
UpdateRunLoop();
|
UpdateRunLoop(graphicsContext);
|
||||||
} else {
|
} else {
|
||||||
graphicsContext->ThreadFrame();
|
graphicsContext->ThreadFrame();
|
||||||
// Do the rest in EmuThreadFunc
|
// Do the rest in EmuThreadFunc
|
||||||
|
@ -656,7 +656,7 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext) {
|
|||||||
NativeInitGraphics(graphicsContext);
|
NativeInitGraphics(graphicsContext);
|
||||||
|
|
||||||
while (emuThreadState != (int)EmuThreadState::QUIT_REQUESTED) {
|
while (emuThreadState != (int)EmuThreadState::QUIT_REQUESTED) {
|
||||||
UpdateRunLoop();
|
UpdateRunLoop(graphicsContext);
|
||||||
}
|
}
|
||||||
emuThreadState = (int)EmuThreadState::STOPPED;
|
emuThreadState = (int)EmuThreadState::STOPPED;
|
||||||
graphicsContext->StopThread();
|
graphicsContext->StopThread();
|
||||||
@ -1428,7 +1428,7 @@ int main(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
const uint8_t *keys = SDL_GetKeyboardState(NULL);
|
const uint8_t *keys = SDL_GetKeyboardState(NULL);
|
||||||
if (emuThreadState == (int)EmuThreadState::DISABLED) {
|
if (emuThreadState == (int)EmuThreadState::DISABLED) {
|
||||||
UpdateRunLoop();
|
UpdateRunLoop(graphicsContext);
|
||||||
}
|
}
|
||||||
if (g_QuitRequested || g_RestartRequested)
|
if (g_QuitRequested || g_RestartRequested)
|
||||||
break;
|
break;
|
||||||
|
@ -1517,8 +1517,6 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runVulkanRenderLoo
|
|||||||
|
|
||||||
while (!exitRenderLoop) {
|
while (!exitRenderLoop) {
|
||||||
LockedNativeUpdateRender();
|
LockedNativeUpdateRender();
|
||||||
graphicsContext->SwapBuffers();
|
|
||||||
|
|
||||||
ProcessFrameCommands(env);
|
ProcessFrameCommands(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user