PageRenderTime 29ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/lldebugview.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 163 lines | 106 code | 22 blank | 35 comment | 3 complexity | 41edf63943b56d627834eac8265cf268 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lldebugview.cpp
  3. * @brief A view containing UI elements only visible in build mode.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "lldebugview.h"
  28. // library includes
  29. #include "llfasttimerview.h"
  30. #include "llmemoryview.h"
  31. #include "llconsole.h"
  32. #include "lltextureview.h"
  33. #include "llresmgr.h"
  34. #include "imageids.h"
  35. #include "llviewercontrol.h"
  36. #include "llviewerwindow.h"
  37. #include "llappviewer.h"
  38. #include "llmemoryview.h"
  39. #include "llsceneview.h"
  40. #include "llviewertexture.h"
  41. #include "llfloaterreg.h"
  42. //
  43. // Globals
  44. //
  45. LLDebugView* gDebugView = NULL;
  46. //
  47. // Methods
  48. //
  49. static LLDefaultChildRegistry::Register<LLDebugView> r("debug_view");
  50. LLDebugView::LLDebugView(const LLDebugView::Params& p)
  51. : LLView(p),
  52. mFastTimerView(NULL),
  53. mMemoryView(NULL),
  54. mDebugConsolep(NULL),
  55. mFloaterSnapRegion(NULL)
  56. {}
  57. LLDebugView::~LLDebugView()
  58. {
  59. // These have already been deleted. Fix the globals appropriately.
  60. gDebugView = NULL;
  61. gTextureView = NULL;
  62. gSceneView = NULL;
  63. gTextureSizeView = NULL;
  64. gTextureCategoryView = NULL;
  65. }
  66. void LLDebugView::init()
  67. {
  68. LLRect r;
  69. LLRect rect = getLocalRect();
  70. // Rectangle to draw debug data in (full height, 3/4 width)
  71. r.set(10, rect.getHeight() - 100, ((rect.getWidth()*3)/4), 100);
  72. LLConsole::Params cp;
  73. cp.name("debug console");
  74. cp.max_lines(20);
  75. cp.rect(r);
  76. cp.font(LLFontGL::getFontMonospace());
  77. cp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_LEFT);
  78. cp.visible(false);
  79. mDebugConsolep = LLUICtrlFactory::create<LLConsole>(cp);
  80. addChild(mDebugConsolep);
  81. r.set(150 - 25, rect.getHeight() - 50, rect.getWidth()/2 - 25, rect.getHeight() - 450);
  82. r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f),
  83. (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
  84. mFastTimerView = dynamic_cast<LLFastTimerView*>(LLFloaterReg::getInstance("fast_timers"));
  85. gSceneView = new LLSceneView(r);
  86. gSceneView->setFollowsTop();
  87. gSceneView->setFollowsLeft();
  88. gSceneView->setVisible(FALSE);
  89. addChild(gSceneView);
  90. gSceneView->setRect(rect);
  91. r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f),
  92. (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
  93. LLMemoryView::Params mp;
  94. mp.name("memory");
  95. mp.rect(r);
  96. mp.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT);
  97. mp.visible(false);
  98. mMemoryView = LLUICtrlFactory::create<LLMemoryView>(mp);
  99. addChild(mMemoryView);
  100. r.set(150, rect.getHeight() - 50, 820, 100);
  101. LLTextureView::Params tvp;
  102. tvp.name("gTextureView");
  103. tvp.rect(r);
  104. tvp.follows.flags(FOLLOWS_BOTTOM|FOLLOWS_LEFT);
  105. tvp.visible(false);
  106. gTextureView = LLUICtrlFactory::create<LLTextureView>(tvp);
  107. addChild(gTextureView);
  108. //gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE);
  109. if(gAuditTexture)
  110. {
  111. r.set(150, rect.getHeight() - 50, 900 + LLImageGL::sTextureLoadedCounter.size() * 30, 100);
  112. LLTextureSizeView::Params tsv ;
  113. tsv.name("gTextureSizeView");
  114. tsv.rect(r);
  115. tsv.follows.flags(FOLLOWS_BOTTOM|FOLLOWS_LEFT);
  116. tsv.visible(false);
  117. gTextureSizeView = LLUICtrlFactory::create<LLTextureSizeView>(tsv);
  118. addChild(gTextureSizeView);
  119. gTextureSizeView->setType(LLTextureSizeView::TEXTURE_MEM_OVER_SIZE) ;
  120. r.set(150, rect.getHeight() - 50, 900 + LLViewerTexture::getTotalNumOfCategories() * 30, 100);
  121. LLTextureSizeView::Params tcv ;
  122. tcv.name("gTextureCategoryView");
  123. tcv.rect(r);
  124. tcv.follows.flags(FOLLOWS_BOTTOM|FOLLOWS_LEFT);
  125. tcv.visible(false);
  126. gTextureCategoryView = LLUICtrlFactory::create<LLTextureSizeView>(tcv);
  127. gTextureCategoryView->setType(LLTextureSizeView::TEXTURE_MEM_OVER_CATEGORY);
  128. addChild(gTextureCategoryView);
  129. }
  130. }
  131. void LLDebugView::draw()
  132. {
  133. if (mFloaterSnapRegion == NULL)
  134. {
  135. mFloaterSnapRegion = getRootView()->getChildView("floater_snap_region");
  136. }
  137. LLRect debug_rect;
  138. mFloaterSnapRegion->localRectToOtherView(mFloaterSnapRegion->getLocalRect(), &debug_rect, getParent());
  139. setShape(debug_rect);
  140. LLView::draw();
  141. }