sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Debug bar sl@0: // sl@0: // sl@0: sl@0: #include "debugbar.h" sl@0: #include sl@0: #include "screen.h" sl@0: #include "wstop.h" sl@0: #include sl@0: #include "walkwindowtree.h" sl@0: #include "rootwin.h" sl@0: sl@0: CDebugBar* CDebugBar::NewL(CScreen * aScreen, TTimeIntervalMicroSeconds32 aRefreshInterval) sl@0: { sl@0: CDebugBar* self = new(ELeave) CDebugBar(aScreen); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aRefreshInterval); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CDebugBar::~CDebugBar() sl@0: { sl@0: delete iTimer; sl@0: } sl@0: sl@0: CDebugBar::CDebugBar(CScreen * aScreen) : iScreen(aScreen) sl@0: { sl@0: } sl@0: sl@0: void CDebugBar::ConstructL(TTimeIntervalMicroSeconds32 aRefreshInterval) sl@0: { sl@0: iTimer = CPeriodic::NewL(EPriorityNormal); sl@0: iTimer->Start(TTimeIntervalMicroSeconds32(3000000),aRefreshInterval,TCallBack(RedrawDebugBarCallback, this)); sl@0: } sl@0: sl@0: TBool CDebugBar::RedrawDebugBarCallback(TAny * aAny) sl@0: { sl@0: CDebugBar* self = reinterpret_cast(aAny); sl@0: self->iPolls++; //minus-out the events which cause this debug-bar to 'tick' sl@0: self->iScreen->ScheduleRender(0); sl@0: return ETrue; sl@0: } sl@0: sl@0: void CDebugBar::DebugBarInfo(RArray& aArray) const sl@0: { sl@0: _LIT(KLine1Format, "KeyEvents %d; %Ld; WServ %.1f%%; Drawing %.1f%%; Reclaimed %.1f%%"); sl@0: _LIT(KLine2Format, "RedrawStore size %d3B; updates %d/s, pixels %d/s"); sl@0: CWsActiveScheduler* scheduler = CWsActiveScheduler::Static(); sl@0: TInt updatesPerSecond; sl@0: TInt64 pixelsPerSecond; sl@0: scheduler->DrawStats(updatesPerSecond,pixelsPerSecond,2); sl@0: sl@0: TInt64 wserv = scheduler->Total() - iLastTotal; sl@0: TInt64 nonwserv = scheduler->Idle() - iLastIdle; sl@0: TInt64 drawing = scheduler->Drawing() - iLastDrawing; sl@0: TInt64 reclaimed = scheduler->ReclaimedIdleTime() - iLastReclaimedIdleTime; sl@0: TReal wservPercent = wserv+nonwserv? ((TReal)wserv / (TReal)(wserv + nonwserv)) * 100.0 : 0.0 ; sl@0: TReal drawingPercent = wserv? ((TReal)drawing / (TReal)wserv) * 100.0: 0 ; sl@0: TReal reclaimedPercent = wserv+nonwserv? ((TReal)reclaimed / (TReal)(wserv + nonwserv)) * 100.0: 100.0 ; sl@0: sl@0: TWalkWindowTreeRedrawStoreSize redrawStoreWalker; sl@0: iScreen->RootWindow()->WalkWindowTree(redrawStoreWalker, EWalkChildrenAndBehind); sl@0: sl@0: iTextLine0.Format(KLine1Format,iKeyEvents,scheduler->Requests()-iPolls,wservPercent,drawingPercent,reclaimedPercent); sl@0: iTextLine1.Format(KLine2Format,redrawStoreWalker.iTotalSize, updatesPerSecond, pixelsPerSecond); sl@0: sl@0: iLastTotal=scheduler->Total(); sl@0: iLastIdle=scheduler->Idle(); sl@0: iLastDrawing=scheduler->Drawing(); sl@0: iLastReclaimedIdleTime=scheduler->ReclaimedIdleTime(); sl@0: sl@0: aArray.Reset(); sl@0: TPtrC ptr(iTextLine0); sl@0: aArray.Append(ptr); sl@0: ptr.Set(iTextLine1); sl@0: aArray.Append(ptr); sl@0: } sl@0: sl@0: void CDebugBar::OnKeyEvent() sl@0: { sl@0: iKeyEvents++; sl@0: iScreen->ScheduleRender(0); sl@0: } sl@0: sl@0: