From 45949cf0fbade4f211520926c5e839c68cd01fbb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 Aug 2014 14:52:10 +0300 Subject: Move chat command /testsdlfont into actions. --- src/actions/actions.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/actions/actions.h | 5 +++++ 2 files changed, 49 insertions(+) (limited to 'src/actions') diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 22dd4834b..9198b474b 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -993,4 +993,48 @@ impHandler(dumpMods) return true; } +#if defined USE_OPENGL && defined DEBUG_SDLFONT +impHandler0(testSdlFont) +{ + Font *font = new Font("fonts/dejavusans.ttf", 18); + timespec time1; + timespec time2; + NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics; + std::vector data; + volatile int width = 0; + + for (int f = 0; f < 300; f ++) + data.push_back("test " + toString(f) + "string"); + nullGraphics->beginDraw(); + + clock_gettime(CLOCK_MONOTONIC, &time1); + for (int f = 0; f < 500; f ++) + { + FOR_EACH (std::vector::const_iterator, it, data) + { + width += font->getWidth(*it); + font->drawString(nullGraphics, *it, 10, 10); + } + FOR_EACH (std::vector::const_iterator, it, data) + font->drawString(nullGraphics, *it, 10, 10); + + font->doClean(); + } + + clock_gettime(CLOCK_MONOTONIC, &time2); + + delete nullGraphics; + delete font; + + int64_t diff = (static_cast( + time2.tv_sec) * 1000000000LL + static_cast( + time2.tv_nsec)) / 100000 - (static_cast( + time1.tv_sec) * 1000000000LL + static_cast( + time1.tv_nsec)) / 100000; + if (debugChatTab) + debugChatTab->chatLog("sdlfont time: " + toString(diff)); + return true; +} +#endif + } // namespace Actions diff --git a/src/actions/actions.h b/src/actions/actions.h index 7a8217570..f3c58da54 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -21,6 +21,8 @@ #ifndef ACTIONS_ACTIONS_H #define ACTIONS_ACTIONS_H +#include "localconsts.h" + #define decHandler(name) bool name(InputEvent &event) struct InputEvent; @@ -78,6 +80,9 @@ namespace Actions decHandler(dumpOGL); decHandler(dumpGL); decHandler(dumpMods); +#if defined USE_OPENGL && defined DEBUG_SDLFONT + decHandler(testSdlFont); +#endif } // namespace Actions #undef decHandler -- cgit v1.2.3-70-g09d2