From: David Gow Date: Wed, 15 Oct 2014 07:51:19 +0000 (+0800) Subject: profileon/profileoff in debugscript X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=77e5193080bdeb052803683b77bc6dd16f427b57;p=ipdf%2Fcode.git profileon/profileoff in debugscript --- diff --git a/src/debugscript.cpp b/src/debugscript.cpp index ed10cc3..9d78b26 100644 --- a/src/debugscript.cpp +++ b/src/debugscript.cpp @@ -1,4 +1,5 @@ #include "debugscript.h" +#include "profiler.h" #include @@ -185,6 +186,16 @@ void DebugScript::ParseAction(View * view, Screen * scr) { currentAction.type = AT_PrintBounds; } + else if (actionType == "profileon") + { + currentAction.type = AT_ProfileDisplay; + currentAction.iz = 1; + } + else if (actionType == "profileoff") + { + currentAction.type = AT_ProfileDisplay; + currentAction.iz = 0; + } else Fatal("Unknown action %s", actionType.c_str()); @@ -401,6 +412,11 @@ bool DebugScript::Execute(View *view, Screen *scr) printf("%s\t%s\t%s\t%s\n", Str(view->GetBounds().x).c_str(), Str(view->GetBounds().y).c_str(), Str(view->GetBounds().w).c_str(), Str(view->GetBounds().h).c_str()); break; } + case AT_ProfileDisplay: + { + g_profiler.Enable(currentAction.iz); + break; + } default: Fatal("Unknown script command in queue."); } diff --git a/src/debugscript.h b/src/debugscript.h index 0625535..25fee58 100644 --- a/src/debugscript.h +++ b/src/debugscript.h @@ -45,6 +45,7 @@ private: AT_ScreenShot, // take screenshot AT_PrintFPS, // Print FPS statistics about the frames AT_PrintBounds, // Print bounds + AT_ProfileDisplay, AT_Quit }; diff --git a/src/profiler.cpp b/src/profiler.cpp index 4348603..f718637 100644 --- a/src/profiler.cpp +++ b/src/profiler.cpp @@ -31,9 +31,10 @@ void Profiler::EndFrame() // Zero all of the frame counts for (auto& it : m_zones) { -#ifndef PROFILER_SILENT - Debug("Perf: Zone \"%s\" frame: %d ms (%d calls), total: %d ms (%d calls)", it.first.c_str(), it.second.tics_frame * 1000 / SDL_GetPerformanceFrequency(), it.second.calls_frame, it.second.tics_total * 1000 / SDL_GetPerformanceFrequency(), it.second.calls_total); -#endif + if (m_enabled) + { + printf("perf_zone\t\"%s\"\t%lu %lu\t%lu %lu\n", it.first.c_str(), it.second.tics_frame * 1000 / SDL_GetPerformanceFrequency(), it.second.calls_frame, it.second.tics_total * 1000 / SDL_GetPerformanceFrequency(), it.second.calls_total); + } it.second.tics_frame = 0; it.second.calls_frame = 0; } diff --git a/src/profiler.h b/src/profiler.h index a20b8d8..f69f06a 100644 --- a/src/profiler.h +++ b/src/profiler.h @@ -12,12 +12,14 @@ namespace IPDF class Profiler { public: - Profiler() {} + Profiler() : m_enabled(false) {} void BeginZone(std::string name); void EndZone(); void EndFrame(); + + void Enable(bool enabled) { m_enabled = enabled; } private: struct ProfileZone { @@ -31,6 +33,7 @@ namespace IPDF std::map m_zones; std::stack m_zone_stack; + bool m_enabled; }; extern Profiler g_profiler; diff --git a/src/svg-tests/fox-vector-box.svg b/src/svg-tests/fox-vector-box.svg new file mode 100644 index 0000000..cd3641c --- /dev/null +++ b/src/svg-tests/fox-vector-box.svg @@ -0,0 +1,218 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VECTOR GRAPHICS + + + + +