Try to fix overlay related lag.

merge-requests/30/head
Mr_Goldberg 2020-01-25 15:23:16 -05:00
parent 350293a9c3
commit e0af318948
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
1 changed files with 5 additions and 3 deletions

View File

@ -123,6 +123,7 @@ void Steam_Overlay::SetNotificationInset(int nHorizontalInset, int nVerticalInse
void Steam_Overlay::SetupOverlay() void Steam_Overlay::SetupOverlay()
{ {
PRINT_DEBUG("%s\n", __FUNCTION__);
std::lock_guard<std::recursive_mutex> lock(overlay_mutex); std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (!setup_overlay_called) if (!setup_overlay_called)
{ {
@ -599,19 +600,20 @@ void Steam_Overlay::CreateFonts()
// Try to make this function as short as possible or it might affect game's fps. // Try to make this function as short as possible or it might affect game's fps.
void Steam_Overlay::OverlayProc() void Steam_Overlay::OverlayProc()
{ {
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (!Ready()) if (!Ready())
return; return;
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui::PushFont(font_notif); ImGui::PushFont(font_notif);
overlay_mutex.lock();
BuildNotifications(io.DisplaySize.x, io.DisplaySize.y); BuildNotifications(io.DisplaySize.x, io.DisplaySize.y);
overlay_mutex.unlock();
ImGui::PopFont(); ImGui::PopFont();
if (show_overlay) if (show_overlay)
{ {
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
int friend_size = friends.size(); int friend_size = friends.size();
// Set the overlay windows to the size of the game window // Set the overlay windows to the size of the game window
@ -693,7 +695,6 @@ void Steam_Overlay::Callback(Common_Message *msg)
void Steam_Overlay::RunCallbacks() void Steam_Overlay::RunCallbacks()
{ {
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (overlay_state_changed) if (overlay_state_changed)
{ {
GameOverlayActivated_t data = { 0 }; GameOverlayActivated_t data = { 0 };
@ -706,6 +707,7 @@ void Steam_Overlay::RunCallbacks()
Steam_Friends* steamFriends = get_steam_client()->steam_friends; Steam_Friends* steamFriends = get_steam_client()->steam_friends;
Steam_Matchmaking* steamMatchmaking = get_steam_client()->steam_matchmaking; Steam_Matchmaking* steamMatchmaking = get_steam_client()->steam_matchmaking;
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
while (!has_friend_action.empty()) while (!has_friend_action.empty())
{ {
auto friend_info = friends.find(has_friend_action.front()); auto friend_info = friends.find(has_friend_action.front());