PageRenderTime 27ms CodeModel.GetById 11ms app.highlight 13ms RepoModel.GetById 1ms 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
  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
 27#include "llviewerprecompiledheaders.h"
 28
 29#include "lldebugview.h"
 30
 31// library includes
 32#include "llfasttimerview.h"
 33#include "llmemoryview.h"
 34#include "llconsole.h"
 35#include "lltextureview.h"
 36#include "llresmgr.h"
 37#include "imageids.h"
 38#include "llviewercontrol.h"
 39#include "llviewerwindow.h"
 40#include "llappviewer.h"
 41#include "llmemoryview.h"
 42#include "llsceneview.h"
 43#include "llviewertexture.h"
 44#include "llfloaterreg.h"
 45
 46//
 47// Globals
 48//
 49
 50LLDebugView* gDebugView = NULL;
 51
 52//
 53// Methods
 54//
 55static LLDefaultChildRegistry::Register<LLDebugView> r("debug_view");
 56
 57LLDebugView::LLDebugView(const LLDebugView::Params& p)
 58:	LLView(p),
 59	mFastTimerView(NULL),
 60	mMemoryView(NULL),
 61	mDebugConsolep(NULL),
 62	mFloaterSnapRegion(NULL)
 63{}
 64
 65LLDebugView::~LLDebugView()
 66{
 67	// These have already been deleted.  Fix the globals appropriately.
 68	gDebugView = NULL;
 69	gTextureView = NULL;
 70	gSceneView = NULL;
 71	gTextureSizeView = NULL;
 72	gTextureCategoryView = NULL;
 73}
 74
 75void LLDebugView::init()
 76{
 77	LLRect r;
 78	LLRect rect = getLocalRect();
 79
 80	// Rectangle to draw debug data in (full height, 3/4 width)
 81	r.set(10, rect.getHeight() - 100, ((rect.getWidth()*3)/4), 100);
 82	LLConsole::Params cp;
 83	cp.name("debug console");
 84	cp.max_lines(20);
 85	cp.rect(r);
 86	cp.font(LLFontGL::getFontMonospace());
 87	cp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_LEFT);
 88	cp.visible(false);
 89	mDebugConsolep = LLUICtrlFactory::create<LLConsole>(cp);
 90	addChild(mDebugConsolep);
 91
 92	r.set(150 - 25, rect.getHeight() - 50, rect.getWidth()/2 - 25, rect.getHeight() - 450);
 93
 94	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
 95  									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
 96	
 97	mFastTimerView = dynamic_cast<LLFastTimerView*>(LLFloaterReg::getInstance("fast_timers"));
 98
 99	gSceneView = new LLSceneView(r);
100	gSceneView->setFollowsTop();
101	gSceneView->setFollowsLeft();
102	gSceneView->setVisible(FALSE);
103	addChild(gSceneView);
104	gSceneView->setRect(rect);
105	
106	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
107									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
108	LLMemoryView::Params mp;
109	mp.name("memory");
110	mp.rect(r);
111	mp.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT);
112	mp.visible(false);
113	mMemoryView = LLUICtrlFactory::create<LLMemoryView>(mp);
114	addChild(mMemoryView);
115
116	r.set(150, rect.getHeight() - 50, 820, 100);
117	LLTextureView::Params tvp;
118	tvp.name("gTextureView");
119	tvp.rect(r);
120	tvp.follows.flags(FOLLOWS_BOTTOM|FOLLOWS_LEFT);
121	tvp.visible(false);
122	gTextureView = LLUICtrlFactory::create<LLTextureView>(tvp);
123	addChild(gTextureView);
124	//gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE);
125
126
127	if(gAuditTexture)
128	{
129		r.set(150, rect.getHeight() - 50, 900 + LLImageGL::sTextureLoadedCounter.size() * 30, 100);
130		LLTextureSizeView::Params tsv ;
131		tsv.name("gTextureSizeView");
132		tsv.rect(r);
133		tsv.follows.flags(FOLLOWS_BOTTOM|FOLLOWS_LEFT);
134		tsv.visible(false);
135		gTextureSizeView = LLUICtrlFactory::create<LLTextureSizeView>(tsv);
136		addChild(gTextureSizeView);
137		gTextureSizeView->setType(LLTextureSizeView::TEXTURE_MEM_OVER_SIZE) ;
138
139		r.set(150, rect.getHeight() - 50, 900 + LLViewerTexture::getTotalNumOfCategories() * 30, 100);
140		LLTextureSizeView::Params tcv ;
141		tcv.name("gTextureCategoryView");
142		tcv.rect(r);
143		tcv.follows.flags(FOLLOWS_BOTTOM|FOLLOWS_LEFT);
144		tcv.visible(false);
145		gTextureCategoryView = LLUICtrlFactory::create<LLTextureSizeView>(tcv);
146		gTextureCategoryView->setType(LLTextureSizeView::TEXTURE_MEM_OVER_CATEGORY);
147		addChild(gTextureCategoryView);
148	}
149}
150
151void LLDebugView::draw()
152{
153	if (mFloaterSnapRegion == NULL)
154	{
155		mFloaterSnapRegion = getRootView()->getChildView("floater_snap_region");
156	}
157
158	LLRect debug_rect;
159	mFloaterSnapRegion->localRectToOtherView(mFloaterSnapRegion->getLocalRect(), &debug_rect, getParent());
160
161	setShape(debug_rect);
162	LLView::draw();
163}