mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Extend our OSD class to support callbacks on init, onframe, and shutdown.
This commit is contained in:
@ -24,6 +24,8 @@
|
|||||||
#include "RenderBase.h"
|
#include "RenderBase.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace OSD
|
namespace OSD
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -39,6 +41,26 @@ struct MESSAGE
|
|||||||
u32 dwTimeStamp;
|
u32 dwTimeStamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CALLBACK
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
CallbackPtr m_functionptr;
|
||||||
|
CallbackType m_type;
|
||||||
|
u32 m_data;
|
||||||
|
public:
|
||||||
|
CALLBACK(CallbackType OnType, CallbackPtr FuncPtr, u32 UserData)
|
||||||
|
{
|
||||||
|
m_type = OnType;
|
||||||
|
m_functionptr = FuncPtr;
|
||||||
|
m_data = UserData;
|
||||||
|
}
|
||||||
|
void Call()
|
||||||
|
{
|
||||||
|
m_functionptr(m_data);
|
||||||
|
}
|
||||||
|
CallbackType Type() { return m_type; }
|
||||||
|
};
|
||||||
|
std::vector<CALLBACK> m_callbacks;
|
||||||
static std::list<MESSAGE> s_listMsgs;
|
static std::list<MESSAGE> s_listMsgs;
|
||||||
|
|
||||||
void AddMessage(const char* pstr, u32 ms)
|
void AddMessage(const char* pstr, u32 ms)
|
||||||
@ -86,4 +108,17 @@ void ClearMessages()
|
|||||||
it = s_listMsgs.erase(it);
|
it = s_listMsgs.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On-Screen Display Callbacks
|
||||||
|
void AddCallback(CallbackType OnType, CallbackPtr FuncPtr, u32 UserData)
|
||||||
|
{
|
||||||
|
m_callbacks.push_back(CALLBACK(OnType, FuncPtr, UserData));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoCallbacks(CallbackType OnType)
|
||||||
|
{
|
||||||
|
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
||||||
|
if (it->Type() == OnType)
|
||||||
|
it->Call();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -26,6 +26,18 @@ void AddMessage(const char* str, u32 ms = 2000);
|
|||||||
void DrawMessages(); // draw the current messages on the screen. Only call once per frame.
|
void DrawMessages(); // draw the current messages on the screen. Only call once per frame.
|
||||||
void ClearMessages();
|
void ClearMessages();
|
||||||
|
|
||||||
|
// On-screen callbacks
|
||||||
|
enum CallbackType
|
||||||
|
{
|
||||||
|
OSD_INIT = 0,
|
||||||
|
OSD_ONFRAME,
|
||||||
|
OSD_SHUTDOWN
|
||||||
|
};
|
||||||
|
typedef void(*CallbackPtr)(u32);
|
||||||
|
|
||||||
|
void AddCallback(CallbackType OnType, CallbackPtr FuncPtr, u32 UserData);
|
||||||
|
|
||||||
|
void DoCallbacks(CallbackType OnType);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif // _OSD_H_
|
#endif // _OSD_H_
|
||||||
|
@ -1410,6 +1410,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||||||
|
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
// Do our OSD callbacks
|
||||||
|
OSD::DoCallbacks(OSD::OSD_ONFRAME);
|
||||||
OSD::DrawMessages();
|
OSD::DrawMessages();
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
@ -157,7 +157,10 @@ void VideoBackend::ShowConfig(void *_hParent)
|
|||||||
diag.ShowModal();
|
diag.ShowModal();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
void Test(u32 Data)
|
||||||
|
{
|
||||||
|
printf("Data: %d\n", Data);
|
||||||
|
}
|
||||||
bool VideoBackend::Initialize(void *&window_handle)
|
bool VideoBackend::Initialize(void *&window_handle)
|
||||||
{
|
{
|
||||||
InitializeShared();
|
InitializeShared();
|
||||||
@ -175,6 +178,9 @@ bool VideoBackend::Initialize(void *&window_handle)
|
|||||||
if (!GLInterface->Create(window_handle))
|
if (!GLInterface->Create(window_handle))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Do our OSD callbacks
|
||||||
|
OSD::DoCallbacks(OSD::OSD_INIT);
|
||||||
|
|
||||||
s_BackendInitialized = true;
|
s_BackendInitialized = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -222,6 +228,10 @@ void VideoBackend::Video_Prepare()
|
|||||||
void VideoBackend::Shutdown()
|
void VideoBackend::Shutdown()
|
||||||
{
|
{
|
||||||
s_BackendInitialized = false;
|
s_BackendInitialized = false;
|
||||||
|
|
||||||
|
// Do our OSD callbacks
|
||||||
|
OSD::DoCallbacks(OSD::OSD_SHUTDOWN);
|
||||||
|
|
||||||
GLInterface->Shutdown();
|
GLInterface->Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "SWRenderer.h"
|
#include "SWRenderer.h"
|
||||||
#include "SWStatistics.h"
|
#include "SWStatistics.h"
|
||||||
|
|
||||||
|
#include "OnScreenDisplay.h"
|
||||||
|
|
||||||
static GLuint s_RenderTarget = 0;
|
static GLuint s_RenderTarget = 0;
|
||||||
|
|
||||||
static GLint attr_pos = -1, attr_tex = -1;
|
static GLint attr_pos = -1, attr_tex = -1;
|
||||||
@ -181,6 +183,9 @@ void SWRenderer::DrawTexture(u8 *texture, int width, int height)
|
|||||||
|
|
||||||
void SWRenderer::SwapBuffer()
|
void SWRenderer::SwapBuffer()
|
||||||
{
|
{
|
||||||
|
// Do our OSD callbacks
|
||||||
|
OSD::DoCallbacks(OSD::OSD_ONFRAME);
|
||||||
|
|
||||||
DrawDebugText();
|
DrawDebugText();
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "SWVertexLoader.h"
|
#include "SWVertexLoader.h"
|
||||||
#include "SWStatistics.h"
|
#include "SWStatistics.h"
|
||||||
|
|
||||||
|
#include "OnScreenDisplay.h"
|
||||||
#define VSYNC_ENABLED 0
|
#define VSYNC_ENABLED 0
|
||||||
|
|
||||||
namespace SW
|
namespace SW
|
||||||
@ -81,6 +82,8 @@ bool VideoSoftware::Initialize(void *&window_handle)
|
|||||||
INFO_LOG(VIDEO, "%s", "SWRenderer::Create failed\n");
|
INFO_LOG(VIDEO, "%s", "SWRenderer::Create failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Do our OSD callbacks
|
||||||
|
OSD::DoCallbacks(OSD::OSD_INIT);
|
||||||
|
|
||||||
InitBPMemory();
|
InitBPMemory();
|
||||||
InitXFMemory();
|
InitXFMemory();
|
||||||
@ -111,15 +114,15 @@ void VideoSoftware::DoState(PointerWrap& p)
|
|||||||
OpcodeDecoder::DoState(p);
|
OpcodeDecoder::DoState(p);
|
||||||
Clipper::DoState(p);
|
Clipper::DoState(p);
|
||||||
p.Do(swxfregs);
|
p.Do(swxfregs);
|
||||||
p.Do(bpmem);
|
p.Do(bpmem);
|
||||||
p.DoPOD(swstats);
|
p.DoPOD(swstats);
|
||||||
|
|
||||||
// CP Memory
|
// CP Memory
|
||||||
p.DoArray(arraybases, 16);
|
p.DoArray(arraybases, 16);
|
||||||
p.DoArray(arraystrides, 16);
|
p.DoArray(arraystrides, 16);
|
||||||
p.Do(MatrixIndexA);
|
p.Do(MatrixIndexA);
|
||||||
p.Do(MatrixIndexB);
|
p.Do(MatrixIndexB);
|
||||||
p.Do(g_VtxDesc.Hex);
|
p.Do(g_VtxDesc.Hex);
|
||||||
p.DoArray(g_VtxAttr, 8);
|
p.DoArray(g_VtxAttr, 8);
|
||||||
p.DoMarker("CP Memory");
|
p.DoMarker("CP Memory");
|
||||||
|
|
||||||
@ -163,6 +166,9 @@ void VideoSoftware::Shutdown()
|
|||||||
HwRasterizer::Shutdown();
|
HwRasterizer::Shutdown();
|
||||||
SWRenderer::Shutdown();
|
SWRenderer::Shutdown();
|
||||||
|
|
||||||
|
// Do our OSD callbacks
|
||||||
|
OSD::DoCallbacks(OSD::OSD_SHUTDOWN);
|
||||||
|
|
||||||
GLInterface->Shutdown();
|
GLInterface->Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user