summaryrefslogtreecommitdiff
path: root/src/actions/actions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions/actions.cpp')
-rw-r--r--src/actions/actions.cpp44
1 files changed, 44 insertions, 0 deletions
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<std::string> 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<std::string>::const_iterator, it, data)
+ {
+ width += font->getWidth(*it);
+ font->drawString(nullGraphics, *it, 10, 10);
+ }
+ FOR_EACH (std::vector<std::string>::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<long long int>(
+ time2.tv_sec) * 1000000000LL + static_cast<long long int>(
+ time2.tv_nsec)) / 100000 - (static_cast<long long int>(
+ time1.tv_sec) * 1000000000LL + static_cast<long long int>(
+ time1.tv_nsec)) / 100000;
+ if (debugChatTab)
+ debugChatTab->chatLog("sdlfont time: " + toString(diff));
+ return true;
+}
+#endif
+
} // namespace Actions