2012-11-15 00:39:56 +01:00
|
|
|
#include "stdafx.h"
|
2016-02-01 22:50:02 +01:00
|
|
|
#include "Utilities/Config.h"
|
2014-09-11 21:18:19 +02:00
|
|
|
#include "Emu/Memory/Memory.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "Emu/System.h"
|
|
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
#include "GSRender.h"
|
|
|
|
|
|
2016-02-01 22:50:02 +01:00
|
|
|
// temporarily (u8 value is really CellVideoOutResolutionId, but HLE declarations shouldn't be available for the rest of emu, even indirectly)
|
|
|
|
|
extern cfg::map_entry<u8> g_cfg_video_out_resolution;
|
2016-04-27 00:27:24 +02:00
|
|
|
extern const std::unordered_map<u8, std::pair<int, int>> g_video_out_resolution_map;
|
2014-08-23 02:16:54 +02:00
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
draw_context_t GSFrameBase::new_context()
|
2013-06-30 10:46:29 +02:00
|
|
|
{
|
2015-10-05 17:40:22 +02:00
|
|
|
if (void* context = make_context())
|
|
|
|
|
{
|
|
|
|
|
return std::shared_ptr<void>(context, [this](void* ctxt) { delete_context(ctxt); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
2014-02-23 17:52:52 +01:00
|
|
|
}
|
2015-10-05 02:42:48 +02:00
|
|
|
|
2016-02-01 22:50:02 +01:00
|
|
|
GSRender::GSRender(frame_type type)
|
2015-10-05 02:42:48 +02:00
|
|
|
{
|
2016-04-27 00:27:24 +02:00
|
|
|
const auto size = g_video_out_resolution_map.at(g_cfg_video_out_resolution.get());
|
|
|
|
|
m_frame = Emu.GetCallbacks().get_gs_frame(type, size.first, size.second).release();
|
2015-10-05 02:42:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GSRender::~GSRender()
|
|
|
|
|
{
|
|
|
|
|
m_context = nullptr;
|
|
|
|
|
|
|
|
|
|
if (m_frame)
|
|
|
|
|
{
|
2015-11-26 09:06:29 +01:00
|
|
|
m_frame->hide();
|
2015-10-05 02:42:48 +02:00
|
|
|
m_frame->close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-01 22:50:02 +01:00
|
|
|
void GSRender::on_init_rsx()
|
2015-10-05 02:42:48 +02:00
|
|
|
{
|
|
|
|
|
if (m_frame)
|
|
|
|
|
{
|
|
|
|
|
m_frame->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-26 09:06:29 +01:00
|
|
|
void GSRender::on_init_thread()
|
2015-10-05 02:42:48 +02:00
|
|
|
{
|
|
|
|
|
if (m_frame)
|
|
|
|
|
{
|
|
|
|
|
m_context = m_frame->new_context();
|
|
|
|
|
m_frame->set_current(m_context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GSRender::flip(int buffer)
|
|
|
|
|
{
|
|
|
|
|
if (m_frame)
|
2015-11-26 09:06:29 +01:00
|
|
|
{
|
2015-10-05 02:42:48 +02:00
|
|
|
m_frame->flip(m_context);
|
2015-11-26 09:06:29 +01:00
|
|
|
}
|
2015-10-21 09:24:02 +02:00
|
|
|
}
|