From 2a868b9f3b8e3b5f8b9e5f728f628ec88fd5e3ad Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Thu, 19 Jul 2018 21:17:07 +0200 Subject: Feature: Framerate display window (#6822) Frame rate and various game loop/graphics timing measurements and graphs. Accessible via the Help menu, and can print some stats in the console via the fps command. --- src/video/allegro_v.cpp | 3 +++ src/video/cocoa/wnd_quartz.mm | 3 +++ src/video/cocoa/wnd_quickdraw.mm | 3 +++ src/video/sdl_v.cpp | 3 +++ src/video/win32_v.cpp | 3 +++ 5 files changed, 15 insertions(+) (limited to 'src/video') diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index 50fe0c499..960d7fb7c 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -24,6 +24,7 @@ #include "../network/network.h" #include "../core/random_func.hpp" #include "../core/math_func.hpp" +#include "../framerate_type.h" #include "allegro_v.h" #include @@ -56,6 +57,8 @@ void VideoDriver_Allegro::MakeDirty(int left, int top, int width, int height) static void DrawSurfaceToScreen() { + PerformanceMeasurer framerate(PFE_VIDEO); + int n = _num_dirty_rects; if (n == 0) return; diff --git a/src/video/cocoa/wnd_quartz.mm b/src/video/cocoa/wnd_quartz.mm index 7bec27824..4245a3c18 100644 --- a/src/video/cocoa/wnd_quartz.mm +++ b/src/video/cocoa/wnd_quartz.mm @@ -33,6 +33,7 @@ #include "cocoa_v.h" #include "../../core/math_func.hpp" #include "../../gfx_func.h" +#include "../../framerate_type.h" /* On some old versions of MAC OS this may not be defined. * Those versions generally only produce code for PPC. So it should be safe to @@ -431,6 +432,8 @@ WindowQuartzSubdriver::~WindowQuartzSubdriver() void WindowQuartzSubdriver::Draw(bool force_update) { + PerformanceMeasurer framerate(PFE_VIDEO); + /* Check if we need to do anything */ if (this->num_dirty_rects == 0 || [ this->window isMiniaturized ]) return; diff --git a/src/video/cocoa/wnd_quickdraw.mm b/src/video/cocoa/wnd_quickdraw.mm index df10d8773..8475efb0f 100644 --- a/src/video/cocoa/wnd_quickdraw.mm +++ b/src/video/cocoa/wnd_quickdraw.mm @@ -32,6 +32,7 @@ #include "cocoa_v.h" #include "../../core/math_func.hpp" #include "../../gfx_func.h" +#include "../../framerate_type.h" /** * Important notice regarding all modifications!!!!!!! @@ -361,6 +362,8 @@ WindowQuickdrawSubdriver::~WindowQuickdrawSubdriver() void WindowQuickdrawSubdriver::Draw(bool force_update) { + PerformanceMeasurer framerate(PFE_VIDEO); + /* Check if we need to do anything */ if (this->num_dirty_rects == 0 || [ this->window isMiniaturized ]) return; diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 81005ab04..f40c4b646 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -23,6 +23,7 @@ #include "../core/random_func.hpp" #include "../core/math_func.hpp" #include "../fileio_func.h" +#include "../framerate_type.h" #include "sdl_v.h" #include @@ -148,6 +149,8 @@ static void CheckPaletteAnim() static void DrawSurfaceToScreen() { + PerformanceMeasurer framerate(PFE_VIDEO); + int n = _num_dirty_rects; if (n == 0) return; diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 9559163c3..0655065a6 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -23,6 +23,7 @@ #include "../progress.h" #include "../window_gui.h" #include "../window_func.h" +#include "../framerate_type.h" #include "win32_v.h" #include #include @@ -359,6 +360,8 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen) /** Do palette animation and blit to the window. */ static void PaintWindow(HDC dc) { + PerformanceMeasurer framerate(PFE_VIDEO); + HDC dc2 = CreateCompatibleDC(dc); HBITMAP old_bmp = (HBITMAP)SelectObject(dc2, _wnd.dib_sect); HPALETTE old_palette = SelectPalette(dc, _wnd.gdi_palette, FALSE); -- cgit v1.2.3-70-g09d2