profilergraph.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include <SColor.h>
  18. #include <deque>
  19. #include <utility>
  20. #include <IGUIFont.h>
  21. #include <IVideoDriver.h>
  22. #include "profiler.h"
  23. /* Profiler display */
  24. class ProfilerGraph
  25. {
  26. private:
  27. struct Piece
  28. {
  29. Piece(Profiler::GraphValues v) : values(std::move(v)) {}
  30. Profiler::GraphValues values;
  31. };
  32. struct Meta
  33. {
  34. float min;
  35. float max;
  36. video::SColor color;
  37. Meta(float initial = 0,
  38. video::SColor color = video::SColor(255, 255, 255, 255)) :
  39. min(initial),
  40. max(initial), color(color)
  41. {
  42. }
  43. };
  44. std::deque<Piece> m_log;
  45. public:
  46. u32 m_log_max_size = 200;
  47. ProfilerGraph() = default;
  48. void put(const Profiler::GraphValues &values);
  49. void draw(s32 x_left, s32 y_bottom, video::IVideoDriver *driver,
  50. gui::IGUIFont *font) const;
  51. };