Avoid directly calling osm from Core/GPU code.

This allows UI to handle the message however it wants to, and reduces
cross linkage issues.
This commit is contained in:
Unknown W. Brackets 2016-05-27 22:00:14 -07:00
parent 27d135d48a
commit a1fbcc3d93
22 changed files with 55 additions and 46 deletions

View File

@ -1676,7 +1676,6 @@ set(LinkCommon ${CoreLibName} ${CMAKE_THREAD_LIBS_INIT} ${nativeExtraLibs})
if(HEADLESS)
add_executable(PPSSPPHeadless
headless/Headless.cpp
UI/OnScreenDisplay.cpp
headless/StubHost.h
headless/Compare.cpp
headless/Compare.h)
@ -1695,7 +1694,6 @@ if(UNITTEST)
unittest/JitHarness.cpp
Core/MIPS/ARM/ArmRegCache.cpp
Core/MIPS/ARM/ArmRegCacheFPU.cpp
UI/OnScreenDisplay.cpp
)
target_link_libraries(unitTest
${COCOA_LIBRARY} ${LinkCommon} Common)

View File

@ -1,5 +1,4 @@
#include "i18n/i18n.h"
#include "UI/OnScreenDisplay.h"
#include "Common/StringUtils.h"
#include "Common/ChunkFile.h"
#include "Common/FileUtil.h"
@ -7,6 +6,7 @@
#include "Core/CoreParameter.h"
#include "Core/CwCheat.h"
#include "Core/Config.h"
#include "Core/Host.h"
#include "Core/MIPS/MIPS.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/System.h"
@ -50,7 +50,7 @@ static void __CheatStart() {
}
if (!File::Exists(activeCheatFile)) {
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Unable to create cheat file, disk may be full"));
host->NotifyUserMessage(err->T("Unable to create cheat file, disk may be full"));
}
}

View File

@ -19,6 +19,7 @@
#include "base/logging.h"
#include "Common/ChunkFile.h"
#include "Core/Config.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "Core/System.h"
#include "Core/Dialog/SavedataParam.h"
@ -30,7 +31,6 @@
#include "Core/ELF/ParamSFO.h"
#include "Core/HW/MemoryStick.h"
#include "Core/Util/PPGeDraw.h"
#include "UI/OnScreenDisplay.h"
#include "image/png_load.h"
@ -372,7 +372,7 @@ bool SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &save
if (!pspFileSystem.GetFileInfo(dirPath).exists) {
if (!pspFileSystem.MkDir(dirPath)) {
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Unable to write savedata, disk may be full"));
host->NotifyUserMessage(err->T("Unable to write savedata, disk may be full"));
}
}
@ -397,7 +397,7 @@ bool SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &save
if (EncryptData(decryptMode, cryptedData, &cryptedSize, &aligned_len, cryptedHash, (HasKey(param) ? param->key : 0)) != 0)
{
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Save encryption failed. This save won't work on real PSP"), 6.0f);
host->NotifyUserMessage(err->T("Save encryption failed. This save won't work on real PSP"), 6.0f);
ERROR_LOG(SCEUTILITY,"Save encryption failed. This save won't work on real PSP");
delete[] cryptedData;
cryptedData = 0;
@ -642,8 +642,8 @@ void SavedataParam::LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, u8
// Don't notify the user if we're not going to upgrade the save.
if (!g_Config.bEncryptSave) {
I18NCategory *di = GetI18NCategory("Dialog");
osm.Show(di->T("When you save, it will load on a PSP, but not an older PPSSPP"), 6.0f);
osm.Show(di->T("Old savedata detected"), 6.0f);
host->NotifyUserMessage(di->T("When you save, it will load on a PSP, but not an older PPSSPP"), 6.0f);
host->NotifyUserMessage(di->T("Old savedata detected"), 6.0f);
}
} else {
if (decryptMode == 5 && prevCryptMode == 3) {

View File

@ -26,8 +26,8 @@
#include "Core/FileSystems/ISOFileSystem.h"
#include "Core/HLE/sceKernel.h"
#include "Core/HW/MemoryStick.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "UI/OnScreenDisplay.h"
#ifdef _WIN32
#include "Common/CommonWindows.h"
@ -223,7 +223,7 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
if (w32err == ERROR_DISK_FULL || w32err == ERROR_NOT_ENOUGH_QUOTA) {
// This is returned when the disk is full.
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Disk full while writing data"));
host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
}
}
@ -278,7 +278,7 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
} else if (errno == ENOSPC) {
// This is returned when the disk is full.
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Disk full while writing data"));
host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
}
#endif
@ -333,13 +333,13 @@ size_t DirectoryFileHandle::Write(const u8* pointer, s64 size)
}
if (diskFull) {
// Sign extend on 64-bit.
ERROR_LOG(FILESYS, "Disk full");
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Disk full while writing data"));
host->NotifyUserMessage(err->T("Disk full while writing data"));
// We only return an error when the disk is actually full.
// When writing this would cause the disk to be full, so it wasn't written, we return 0.
if (MemoryStick_FreeSpace() == 0) {
// Sign extend on 64-bit.
return (size_t)(s64)(s32)SCE_KERNEL_ERROR_ERRNO_DEVICE_NO_FREE_SPACE;
}
}

View File

@ -24,10 +24,10 @@
#include <cstring>
#include "util/text/parsers.h"
#include "Core/Core.h"
#include "Core/Host.h"
#include "Core/HLE/sceKernelInterrupt.h"
#include "Core/HLE/sceKernelThread.h"
#include "Core/HLE/sceKernelMemory.h"
#include "UI/OnScreenDisplay.h"
#include "proAdhoc.h"
#include "i18n/i18n.h"
@ -1419,7 +1419,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
iResult = getaddrinfo(g_Config.proAdhocServer.c_str(),0,NULL,&resultAddr);
if (iResult != 0) {
ERROR_LOG(SCENET, "DNS Error (%s)\n", g_Config.proAdhocServer.c_str());
osm.Show("DNS Error connecting to " + g_Config.proAdhocServer, 8.0f);
host->NotifyUserMessage("DNS Error connecting to " + g_Config.proAdhocServer, 8.0f);
return iResult;
}
for (ptr = resultAddr; ptr != NULL; ptr = ptr->ai_next) {
@ -1442,7 +1442,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
char buffer[512];
snprintf(buffer, sizeof(buffer), "Socket error (%i) when connecting to %s/%u.%u.%u.%u:%u", errno, g_Config.proAdhocServer.c_str(), sip[0], sip[1], sip[2], sip[3], ntohs(server_addr.sin_port));
ERROR_LOG(SCENET, "%s", buffer);
osm.Show(std::string(buffer), 8.0f);
host->NotifyUserMessage(buffer, 8.0f);
return iResult;
}
@ -1458,7 +1458,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
changeBlockingMode(metasocket, 1); // Change to non-blocking
if (sent > 0) {
I18NCategory *n = GetI18NCategory("Networking");
osm.Show(n->T("Network Initialized"), 1.0);
host->NotifyUserMessage(n->T("Network Initialized"), 1.0);
return 0;
}
else{

View File

@ -64,6 +64,8 @@ public:
virtual bool CanCreateShortcut() {return false;}
virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) {return false;}
virtual void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) {}
// Used for headless.
virtual bool ShouldSkipUI() { return false; }
virtual void SendDebugOutput(const std::string &output) {}

View File

@ -22,13 +22,13 @@
#include "Common/Common.h"
#include "Core/Config.h"
#include "Core/CoreParameter.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/System.h"
#include "GPU/Common/FramebufferCommon.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUState.h"
#include "UI/OnScreenDisplay.h" // Gross dependency!
void CenterDisplayOutputRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation) {
float outW;
@ -1012,5 +1012,5 @@ void FramebufferManagerCommon::ShowScreenResolution() {
messageStream << gr->T("Window Size") << ": ";
messageStream << PSP_CoreParameter().pixelWidth << "x" << PSP_CoreParameter().pixelHeight;
osm.Show(messageStream.str(), 2.0f, 0xFFFFFF, -1, true, "resize");
host->NotifyUserMessage(messageStream.str(), 2.0f, 0xFFFFFF, "resize");
}

View File

@ -22,12 +22,14 @@
#include <map>
#include "helper/global.h"
#include "base/logging.h"
#include "i18n/i18n.h"
#include "math/lin/matrix4x4.h"
#include "math/math_util.h"
#include "util/text/utf8.h"
#include "Common/Common.h"
#include "Core/Config.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "GPU/Math3D.h"
#include "GPU/GPUState.h"
@ -35,7 +37,6 @@
#include "GPU/Directx9/ShaderManagerDX9.h"
#include "GPU/Directx9/DrawEngineDX9.h"
#include "GPU/Directx9/FramebufferDX9.h"
#include "UI/OnScreenDisplay.h"
namespace DX9 {
@ -613,8 +614,9 @@ VSShader *ShaderManagerDX9::ApplyShader(int prim, u32 vertType) {
vs = new VSShader(VSID, codeBuffer_, useHWTransform);
if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics");
ERROR_LOG(HLE, "Shader compilation failed, falling back to software transform");
osm.Show("hardware transform error - falling back to software", 2.5f, 0xFF3030FF, -1, true);
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);
delete vs;
ComputeVertexShaderID(&VSID, vertType, false);

View File

@ -46,8 +46,6 @@
#include "GPU/GLES/DrawEngineGLES.h"
#include "GPU/GLES/ShaderManager.h"
#include "UI/OnScreenDisplay.h"
// #define DEBUG_READ_PIXELS 1
static const char tex_fs[] =
@ -180,9 +178,9 @@ void FramebufferManager::CompileDraw2DProgram() {
}
}
if (!firstLine.empty()) {
osm.Show("Post-shader error: " + firstLine + "...", 10.0f, 0xFF3090FF);
host->NotifyUserMessage("Post-shader error: " + firstLine + "...", 10.0f, 0xFF3090FF);
} else {
osm.Show("Post-shader error, see log for details", 10.0f, 0xFF3090FF);
host->NotifyUserMessage("Post-shader error, see log for details", 10.0f, 0xFF3090FF);
}
usePostShader_ = false;
} else {

View File

@ -26,12 +26,14 @@
#include "base/logging.h"
#include "base/timeutil.h"
#include "i18n/i18n.h"
#include "math/math_util.h"
#include "math/lin/matrix4x4.h"
#include "profiler/profiler.h"
#include "Common/FileUtil.h"
#include "Core/Config.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "GPU/Math3D.h"
#include "GPU/GPUState.h"
@ -39,9 +41,7 @@
#include "GPU/GLES/GLStateCache.h"
#include "GPU/GLES/ShaderManager.h"
#include "GPU/GLES/DrawEngineGLES.h"
#include "UI/OnScreenDisplay.h"
#include "Framebuffer.h"
#include "i18n/i18n.h"
Shader::Shader(const char *code, uint32_t glShaderType, bool useHWTransform)
: failed_(false), useHWTransform_(useHWTransform) {
@ -845,7 +845,7 @@ Shader *ShaderManager::ApplyVertexShader(int prim, u32 vertType, ShaderID *VSID)
if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics");
ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform");
osm.Show(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF, -1, true);
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);
delete vs;
// TODO: Look for existing shader with the appropriate ID, use that instead of generating a new one - however, need to make sure

View File

@ -38,7 +38,6 @@
#include "GPU/GLES/ShaderManager.h"
#include "GPU/GLES/DrawEngineGLES.h"
#include "GPU/Common/TextureDecoder.h"
#include "UI/OnScreenDisplay.h"
#ifdef _M_SSE
#include <xmmintrin.h>
@ -1917,9 +1916,9 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &repla
I18NCategory *err = GetI18NCategory("Error");
if (scaleFactor > 1) {
osm.Show(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
osm.Show(err->T("Warning: Video memory FULL, switching to slow caching mode"), 2.0f);
host->NotifyUserMessage(err->T("Warning: Video memory FULL, switching to slow caching mode"), 2.0f);
}
} else if (err != GL_NO_ERROR) {
// We checked the err anyway, might as well log if there is one.

View File

@ -50,8 +50,6 @@
#include "GPU/Vulkan/ShaderManagerVulkan.h"
#include "GPU/Vulkan/VulkanUtil.h"
#include "UI/OnScreenDisplay.h"
const VkFormat framebufFormat = VK_FORMAT_R8G8B8A8_UNORM;
static const char tex_fs[] = R"(#version 400

View File

@ -39,7 +39,6 @@
#include "GPU/Vulkan/FramebufferVulkan.h"
#include "GPU/Vulkan/FragmentShaderGeneratorVulkan.h"
#include "GPU/Vulkan/VertexShaderGeneratorVulkan.h"
#include "UI/OnScreenDisplay.h"
VulkanFragmentShader::VulkanFragmentShader(VulkanContext *vulkan, ShaderID id, const char *code, bool useHWTransform)
: vulkan_(vulkan), id_(id), failed_(false), useHWTransform_(useHWTransform), module_(0) {

View File

@ -42,7 +42,6 @@
#include "GPU/Vulkan/ShaderManagerVulkan.h"
#include "GPU/Vulkan/DrawEngineVulkan.h"
#include "GPU/Common/TextureDecoder.h"
#include "UI/OnScreenDisplay.h"
#ifdef _M_SSE
#include <xmmintrin.h>
@ -1360,9 +1359,9 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry,VulkanPushBuffe
I18NCategory *err = GetI18NCategory("Error");
if (scaleFactor > 1) {
osm.Show(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
osm.Show(err->T("Warning: Video memory FULL, switching to slow caching mode"), 2.0f);
host->NotifyUserMessage(err->T("Warning: Video memory FULL, switching to slow caching mode"), 2.0f);
}
scaleFactor = 1;

View File

@ -18,6 +18,7 @@
#pragma once
#include "Core/Host.h"
#include "UI/OnScreenDisplay.h"
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
#include "Core/Debugger/SymbolMap.h"
@ -50,6 +51,10 @@ public:
bool IsDebuggingEnabled() override {return false;}
bool AttemptLoadSymbolMap() override {return false;}
void SetWindowTitle(const char *message) override {}
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override {
osm.Show(message, duration, color, -1, true, id);
}
};
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
@ -126,6 +131,11 @@ public:
mainWindow->setWindowTitle(title);
}
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override {
osm.Show(message, duration, color, -1, true, id);
}
bool GPUDebuggingActive()
{
auto dialogDisplayList = mainWindow->GetDialogDisplaylist();

View File

@ -60,6 +60,7 @@
<ClInclude Include="GameScreen.h" />
<ClInclude Include="GameSettingsScreen.h" />
<ClInclude Include="CwCheatScreen.h" />
<ClInclude Include="HostTypes.h" />
<ClInclude Include="MainScreen.h" />
<ClInclude Include="MiscScreens.h" />
<ClInclude Include="OnScreenDisplay.h" />

View File

@ -132,6 +132,7 @@
<Filter>Screens</Filter>
</ClInclude>
<ClInclude Include="DisplayLayoutEditor.h" />
<ClInclude Include="HostTypes.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="Screens">

View File

@ -34,10 +34,12 @@
#include "input/keycodes.h"
#include "util/text/utf8.h"
#include "Common/StringUtils.h"
#include "Core/Core.h"
#include "Core/Config.h"
#include "Core/CoreParameter.h"
#include "Core/System.h"
#include "Core/Debugger/SymbolMap.h"
#include "Windows/EmuThread.h"
#include "Windows/DSoundStream.h"
#include "Windows/WindowsHost.h"
@ -54,10 +56,8 @@
#include "Windows/XinputDevice.h"
#include "Windows/KeyboardDevice.h"
#include "Core/Debugger/SymbolMap.h"
#include "Common/StringUtils.h"
#include "Windows/main.h"
#include "UI/OnScreenDisplay.h"
static const int numCPUs = 1;
@ -348,3 +348,7 @@ void WindowsHost::GoFullscreen(bool viewFullscreen) {
void WindowsHost::ToggleDebugConsoleVisibility() {
MainWindow::ToggleDebugConsoleVisibility();
}
void WindowsHost::NotifyUserMessage(const std::string &message, float duration, u32 color, const char *id) {
osm.Show(message, duration, color, -1, true, id);
}

View File

@ -64,6 +64,8 @@ public:
bool CanCreateShortcut() override;
bool CreateDesktopShortcut(std::string argumentPath, std::string title) override;
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override;
void GoFullscreen(bool) override;
std::shared_ptr<KeyboardDevice> keyboard;

View File

@ -169,7 +169,6 @@ EXEC_AND_LIB_FILES := \
$(SRC)/Core/MIPS/IR/IRPassSimplify.cpp \
$(SRC)/Core/MIPS/IR/IRRegCache.cpp \
$(SRC)/UI/ui_atlas.cpp \
$(SRC)/UI/OnScreenDisplay.cpp \
$(SRC)/ext/libkirk/AES.c \
$(SRC)/ext/libkirk/amctrl.c \
$(SRC)/ext/libkirk/SHA1.c \
@ -411,6 +410,7 @@ LOCAL_SRC_FILES := \
$(SRC)/UI/TouchControlVisibilityScreen.cpp \
$(SRC)/UI/CwCheatScreen.cpp \
$(SRC)/UI/InstallZipScreen.cpp \
$(SRC)/UI/OnScreenDisplay.cpp \
$(SRC)/UI/ProfilerDraw.cpp \
$(SRC)/UI/NativeApp.cpp \
$(SRC)/UI/ComboKeyMappingScreen.cpp

View File

@ -224,7 +224,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\ext\native\ext\glew\glew.c" />
<ClCompile Include="..\UI\OnScreenDisplay.cpp" />
<ClCompile Include="..\Windows\GPU\D3D9Context.cpp" />
<ClCompile Include="..\Windows\GPU\WindowsGLContext.cpp" />
<ClCompile Include="..\Windows\GPU\WindowsVulkanContext.cpp" />
@ -266,7 +265,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\UI\OnScreenDisplay.h" />
<ClInclude Include="Compare.h" />
<ClInclude Include="StubHost.h" />
<ClInclude Include="WindowsHeadlessHost.h" />

View File

@ -3,7 +3,6 @@
<ItemGroup>
<ClCompile Include="Headless.cpp" />
<ClCompile Include="Compare.cpp" />
<ClCompile Include="..\UI\OnScreenDisplay.cpp" />
<ClCompile Include="..\ext\native\ext\glew\glew.c" />
<ClCompile Include="..\Windows\GPU\D3D9Context.cpp">
<Filter>Windows</Filter>
@ -28,7 +27,6 @@
<ItemGroup>
<ClInclude Include="StubHost.h" />
<ClInclude Include="Compare.h" />
<ClInclude Include="..\UI\OnScreenDisplay.h" />
<ClInclude Include="WindowsHeadlessHost.h">
<Filter>Windows</Filter>
</ClInclude>