xuistats.cpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #include <precomp.h>
  2. #include "xuistats.h"
  3. #include <tataki/canvas/ifc_canvas.h>
  4. #include <tataki/color/skinclr.h>
  5. #include <api.h>
  6. #include <api/imgldr/imgldr.h>
  7. #include <api/skin/skinparse.h>
  8. #include <api/skin/gammamgr.h>
  9. #include <api/skin/skinelem.h>
  10. #include <api/skin/regioncache.h>
  11. #include <api/wnd/wndtrack.h>
  12. #include <api/font/font.h>
  13. #include <api/wnd/wndapi.h>
  14. #include <api/skin/guitree.h>
  15. #include <api/xml/xmlreader.h>
  16. #include <api/skin/groupwndcreate.h>
  17. #include <api/skin/groupmgr.h>
  18. #include <api/script/script.h>
  19. #include "bfc/ptrlist.h"
  20. #include "bfc/memblock.h"
  21. // -----------------------------------------------------------------------
  22. const wchar_t XuiStatsXuiObjectStr[] = L"Wasabi:Stats"; // This is the xml tag
  23. char XuiStatsXuiSvcName[] = "Wasabi:Stats xui object";
  24. // -----------------------------------------------------------------------
  25. XuiStats::XuiStats() {
  26. hastimer = 0;
  27. line = 0;
  28. col = 0;
  29. curcanvas = NULL;
  30. }
  31. // -----------------------------------------------------------------------
  32. XuiStats::~XuiStats() {
  33. if (hastimer)
  34. killTimer(0x10);
  35. }
  36. // -----------------------------------------------------------------------
  37. int XuiStats::onInit() {
  38. XUISTATS_PARENT::onInit();
  39. return 1;
  40. }
  41. // -----------------------------------------------------------------------
  42. #define MARGIN 10
  43. #define FONTSIZE 15
  44. #define LINEMUL 15
  45. #define COLMUL 200
  46. void XuiStats::doTextOut(Canvas *canvas, const wchar_t *text, int line, int col, const Wasabi::FontInfo *fontInfo)
  47. {
  48. RECT r;
  49. getClientRect(&r);
  50. if (!canvas || !text || !*text) return;
  51. canvas->textOutEllipsed(r.left+MARGIN+col*COLMUL, r.top+MARGIN+line*LINEMUL, COLMUL-MARGIN/2, LINEMUL, text, fontInfo);
  52. }
  53. // -----------------------------------------------------------------------
  54. void XuiStats::addLine(const wchar_t *txt, const Wasabi::FontInfo *fontInfo)
  55. {
  56. if (!curcanvas) return;
  57. RECT r;
  58. getClientRect(&r);
  59. if (line * LINEMUL + MARGIN + FONTSIZE + r.top > r.bottom)
  60. { col++; line = 0; if (*txt == 0) return; }
  61. doTextOut(curcanvas, txt, line++, col, fontInfo);
  62. }
  63. // -----------------------------------------------------------------------
  64. int XuiStats::onPaint(Canvas *canvas)
  65. {
  66. XUISTATS_PARENT::onPaint(canvas);
  67. curcanvas = canvas;
  68. line = 0;
  69. col = 0;
  70. Wasabi::FontInfo fontInfo;
  71. fontInfo.face = wasabi_default_fontnameW;
  72. fontInfo.pointSize = FONTSIZE;
  73. fontInfo.color = SkinColor(L"wasabi.list.text");
  74. addLine(L"---------------------------- System ------", &fontInfo);
  75. //addLine( StringPrintfW(L"entries in ptrlists : %d", ptrlist_totalnitems) );
  76. #ifdef _DEBUG
  77. addLine( StringPrintfW(L"total memblocks size : %d", memblocks_totalsize) , &fontInfo);
  78. #endif
  79. // TODO: add to api_timer - addLine( StringPrintfW(L"timers : %d/%d", mainmultiplex->getNumTimers(), mainmultiplex->getNumTimersLP()) , &fontInfo);
  80. addLine(L"", &fontInfo);
  81. addLine(L"----------------------------- Wnds -------", &fontInfo);
  82. addLine( StringPrintfW(L"rootwnds : %d", windowTracker->getNumAllWindows()) , &fontInfo);
  83. addLine( StringPrintfW(L"desktop rootwnds : %d", windowTracker->getNumWindows()) , &fontInfo);
  84. addLine(L"", &fontInfo);
  85. addLine(L"--------------------------- ImgLdr -------", &fontInfo);
  86. addLine( StringPrintfW(L"bytes in imgldr : %d", imageLoader::getMemUsage()) , &fontInfo);
  87. addLine( StringPrintfW(L"cached imgldr entries : %d", imageLoader::getNumCached()) , &fontInfo);
  88. addLine( StringPrintfW(L"region caches : %d", RegionCache::getNumCaches()) , &fontInfo);
  89. addLine(L"", &fontInfo);
  90. addLine(L"----------------------------- Skin -------", &fontInfo);
  91. addLine( StringPrintfW(L"skin bitmap elements : %d", WASABI_API_PALETTE->getNumBitmapElement()) , &fontInfo);
  92. addLine( StringPrintfW(L"skin color elements : %d", WASABI_API_PALETTE->getNumColorElements()) , &fontInfo);
  93. addLine( StringPrintfW(L"containers loaded : %d", SkinParser::getNumContainers()) , &fontInfo);
  94. addLine( StringPrintfW(L"gamma sets : %d", WASABI_API_COLORTHEMES->getNumGammaSets()) , &fontInfo);
  95. addLine( StringPrintfW(L"fonts : %d", Font::getNumFonts()) , &fontInfo);
  96. addLine( StringPrintfW(L"base textures : %d", WndApi::getNumBaseTextures()) , &fontInfo);
  97. addLine( StringPrintfW(L"guitree entries : %d", guiTree->getNumObject()) , &fontInfo);
  98. addLine( StringPrintfW(L"wndtype groups : %d", GroupWndCreateSvc::num_group_list) , &fontInfo);
  99. addLine( StringPrintfW(L"hosted groups : %d", GroupMgr::getNumGroups()) , &fontInfo);
  100. addLine( StringPrintfW(L"scripts : %d", Script::getNumScripts()) , &fontInfo);
  101. addLine(L"", &fontInfo);
  102. addLine(L"----------------------------- Misc -------", &fontInfo);
  103. addLine( StringPrintfW(L"registered cfgitems : %d", WASABI_API_CONFIG->config_getNumCfgItems()) , &fontInfo);
  104. if (WASABI_API_THREADPOOL)
  105. {
  106. addLine(L"", &fontInfo);
  107. addLine(L"----------------------------- ThreadPool -------", &fontInfo);
  108. addLine( StringPrintfW(L"active threads : %d", WASABI_API_THREADPOOL->GetNumberOfActiveThreads()) , &fontInfo);
  109. addLine( StringPrintfW(L"threads in pool : %d", WASABI_API_THREADPOOL->GetNumberOfThreads()) , &fontInfo);
  110. }
  111. curcanvas = NULL;
  112. return 1;
  113. }
  114. // -----------------------------------------------------------------------
  115. void XuiStats::onSetVisible(int show) {
  116. XUISTATS_PARENT::onSetVisible(show);
  117. if (show) {
  118. setTimer(0x10, 250);
  119. } else {
  120. killTimer(0x10);
  121. }
  122. hastimer = show;
  123. }
  124. // -----------------------------------------------------------------------
  125. void XuiStats::timerCallback(int p1) {
  126. if (p1 == 0x10) invalidate();
  127. else XUISTATS_PARENT::timerCallback(p1);
  128. }