[Renderer] Implement single backend frame handler
This commit is contained in:
parent
f1ed2f4cab
commit
51ca49ad83
@ -3,6 +3,7 @@
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
Utils::Signal<Renderer::BackendCallback> Renderer::BackendFrameSignal;
|
Utils::Signal<Renderer::BackendCallback> Renderer::BackendFrameSignal;
|
||||||
|
Utils::Signal<Renderer::BackendCallback> Renderer::SingleBackendFrameSignal;
|
||||||
|
|
||||||
Utils::Signal<Scheduler::Callback> Renderer::EndRecoverDeviceSignal;
|
Utils::Signal<Scheduler::Callback> Renderer::EndRecoverDeviceSignal;
|
||||||
Utils::Signal<Scheduler::Callback> Renderer::BeginRecoverDeviceSignal;
|
Utils::Signal<Scheduler::Callback> Renderer::BeginRecoverDeviceSignal;
|
||||||
@ -41,11 +42,22 @@ namespace Components
|
|||||||
if (device)
|
if (device)
|
||||||
{
|
{
|
||||||
device->AddRef();
|
device->AddRef();
|
||||||
|
|
||||||
Renderer::BackendFrameSignal(device);
|
Renderer::BackendFrameSignal(device);
|
||||||
|
|
||||||
|
Utils::Signal<Renderer::BackendCallback> copy(Renderer::SingleBackendFrameSignal);
|
||||||
|
Renderer::SingleBackendFrameSignal.clear();
|
||||||
|
copy(device);
|
||||||
|
|
||||||
device->Release();
|
device->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::OnNextBackendFrame(Utils::Slot<Renderer::BackendCallback> callback)
|
||||||
|
{
|
||||||
|
Renderer::SingleBackendFrameSignal.connect(callback);
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::OnBackendFrame(Utils::Slot<Renderer::BackendCallback> callback)
|
void Renderer::OnBackendFrame(Utils::Slot<Renderer::BackendCallback> callback)
|
||||||
{
|
{
|
||||||
Renderer::BackendFrameSignal.connect(callback);
|
Renderer::BackendFrameSignal.connect(callback);
|
||||||
@ -63,12 +75,12 @@ namespace Components
|
|||||||
|
|
||||||
int Renderer::Width()
|
int Renderer::Width()
|
||||||
{
|
{
|
||||||
return Utils::Hook::Get<int>(0x66E1C68);
|
return reinterpret_cast<LPPOINT>(0x66E1C68)->x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Renderer::Height()
|
int Renderer::Height()
|
||||||
{
|
{
|
||||||
return Utils::Hook::Get<int>(0x66E1C6C);
|
return reinterpret_cast<LPPOINT>(0x66E1C68)->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::PreVidRestart()
|
void Renderer::PreVidRestart()
|
||||||
@ -155,6 +167,7 @@ namespace Components
|
|||||||
Renderer::~Renderer()
|
Renderer::~Renderer()
|
||||||
{
|
{
|
||||||
Renderer::BackendFrameSignal.clear();
|
Renderer::BackendFrameSignal.clear();
|
||||||
|
Renderer::SingleBackendFrameSignal.clear();
|
||||||
|
|
||||||
Renderer::EndRecoverDeviceSignal.clear();
|
Renderer::EndRecoverDeviceSignal.clear();
|
||||||
Renderer::BeginRecoverDeviceSignal.clear();
|
Renderer::BeginRecoverDeviceSignal.clear();
|
||||||
|
@ -14,6 +14,7 @@ namespace Components
|
|||||||
static int Height();
|
static int Height();
|
||||||
|
|
||||||
static void OnBackendFrame(Utils::Slot<BackendCallback> callback);
|
static void OnBackendFrame(Utils::Slot<BackendCallback> callback);
|
||||||
|
static void OnNextBackendFrame(Utils::Slot<BackendCallback> callback);
|
||||||
static void OnDeviceRecoveryEnd(Utils::Slot<Scheduler::Callback> callback);
|
static void OnDeviceRecoveryEnd(Utils::Slot<Scheduler::Callback> callback);
|
||||||
static void OnDeviceRecoveryBegin(Utils::Slot<Scheduler::Callback> callback);
|
static void OnDeviceRecoveryBegin(Utils::Slot<Scheduler::Callback> callback);
|
||||||
|
|
||||||
@ -32,5 +33,6 @@ namespace Components
|
|||||||
static Utils::Signal<Scheduler::Callback> BeginRecoverDeviceSignal;
|
static Utils::Signal<Scheduler::Callback> BeginRecoverDeviceSignal;
|
||||||
|
|
||||||
static Utils::Signal<BackendCallback> BackendFrameSignal;
|
static Utils::Signal<BackendCallback> BackendFrameSignal;
|
||||||
|
static Utils::Signal<BackendCallback> SingleBackendFrameSignal;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -68,16 +68,23 @@ namespace Utils
|
|||||||
public:
|
public:
|
||||||
Signal()
|
Signal()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> _(this->mutex);
|
||||||
|
|
||||||
this->slots.clear();
|
this->slots.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Signal(Signal& obj) : Signal()
|
Signal(Signal& obj) : Signal()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> _(this->mutex);
|
||||||
|
std::lock_guard<std::recursive_mutex> __(obj.mutex);
|
||||||
|
|
||||||
Utils::Merge(&this->slots, obj.getSlots());
|
Utils::Merge(&this->slots, obj.getSlots());
|
||||||
}
|
}
|
||||||
|
|
||||||
void connect(Slot<T> slot)
|
void connect(Slot<T> slot)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> _(this->mutex);
|
||||||
|
|
||||||
if (slot)
|
if (slot)
|
||||||
{
|
{
|
||||||
this->slots.push_back(slot);
|
this->slots.push_back(slot);
|
||||||
@ -86,6 +93,8 @@ namespace Utils
|
|||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> _(this->mutex);
|
||||||
|
|
||||||
this->slots.clear();
|
this->slots.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +106,8 @@ namespace Utils
|
|||||||
template <class ...Args>
|
template <class ...Args>
|
||||||
void operator()(Args&&... args) const
|
void operator()(Args&&... args) const
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> _(this->mutex);
|
||||||
|
|
||||||
std::vector<Slot<T>> copiedSlots;
|
std::vector<Slot<T>> copiedSlots;
|
||||||
Utils::Merge(&copiedSlots, this->slots);
|
Utils::Merge(&copiedSlots, this->slots);
|
||||||
|
|
||||||
@ -110,6 +121,7 @@ namespace Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
mutable std::recursive_mutex mutex;
|
||||||
std::vector<Slot<T>> slots;
|
std::vector<Slot<T>> slots;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user