os/graphics/windowing/windowserver/nga/SERVER/debugbar.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Debug bar
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "debugbar.h"
sl@0
    19
#include <bitstd.h>
sl@0
    20
#include "screen.h"
sl@0
    21
#include "wstop.h"
sl@0
    22
#include <e32cmn.h>
sl@0
    23
#include "walkwindowtree.h"	
sl@0
    24
#include "rootwin.h"
sl@0
    25
sl@0
    26
CDebugBar* CDebugBar::NewL(CScreen * aScreen, TTimeIntervalMicroSeconds32 aRefreshInterval)
sl@0
    27
	{
sl@0
    28
	CDebugBar* self = new(ELeave) CDebugBar(aScreen);
sl@0
    29
	CleanupStack::PushL(self);
sl@0
    30
	self->ConstructL(aRefreshInterval);
sl@0
    31
	CleanupStack::Pop(self);
sl@0
    32
	return self;
sl@0
    33
	}
sl@0
    34
sl@0
    35
CDebugBar::~CDebugBar()
sl@0
    36
	{
sl@0
    37
	delete iTimer;	
sl@0
    38
	}
sl@0
    39
	
sl@0
    40
CDebugBar::CDebugBar(CScreen * aScreen) : iScreen(aScreen)
sl@0
    41
	{
sl@0
    42
	}
sl@0
    43
	
sl@0
    44
void CDebugBar::ConstructL(TTimeIntervalMicroSeconds32 aRefreshInterval)
sl@0
    45
	{
sl@0
    46
	iTimer = CPeriodic::NewL(EPriorityNormal);
sl@0
    47
	iTimer->Start(TTimeIntervalMicroSeconds32(3000000),aRefreshInterval,TCallBack(RedrawDebugBarCallback, this));
sl@0
    48
	}
sl@0
    49
	
sl@0
    50
TBool CDebugBar::RedrawDebugBarCallback(TAny * aAny)
sl@0
    51
	{
sl@0
    52
	CDebugBar* self = reinterpret_cast<CDebugBar *>(aAny);
sl@0
    53
	self->iPolls++; //minus-out the events which cause this debug-bar to 'tick'
sl@0
    54
	self->iScreen->ScheduleRender(0);
sl@0
    55
	return ETrue;
sl@0
    56
	}
sl@0
    57
	
sl@0
    58
void CDebugBar::DebugBarInfo(RArray<TPtrC>& aArray) const
sl@0
    59
	{	
sl@0
    60
	_LIT(KLine1Format, "KeyEvents %d; %Ld; WServ %.1f%%; Drawing %.1f%%; Reclaimed %.1f%%");
sl@0
    61
	_LIT(KLine2Format, "RedrawStore size %d3B; updates %d/s, pixels %d/s"); 
sl@0
    62
	CWsActiveScheduler* scheduler = CWsActiveScheduler::Static();
sl@0
    63
	TInt updatesPerSecond;
sl@0
    64
	TInt64 pixelsPerSecond;
sl@0
    65
	scheduler->DrawStats(updatesPerSecond,pixelsPerSecond,2);
sl@0
    66
sl@0
    67
	TInt64 wserv = scheduler->Total() - iLastTotal;
sl@0
    68
	TInt64 nonwserv = scheduler->Idle() - iLastIdle;
sl@0
    69
	TInt64 drawing = scheduler->Drawing() - iLastDrawing;
sl@0
    70
	TInt64 reclaimed = scheduler->ReclaimedIdleTime() - iLastReclaimedIdleTime;
sl@0
    71
	TReal wservPercent =  wserv+nonwserv? ((TReal)wserv / (TReal)(wserv + nonwserv)) * 100.0 : 0.0 ;
sl@0
    72
	TReal drawingPercent = wserv? ((TReal)drawing / (TReal)wserv) * 100.0: 0 ;
sl@0
    73
	TReal reclaimedPercent = wserv+nonwserv? ((TReal)reclaimed / (TReal)(wserv + nonwserv)) * 100.0: 100.0 ;
sl@0
    74
		
sl@0
    75
	TWalkWindowTreeRedrawStoreSize redrawStoreWalker;
sl@0
    76
	iScreen->RootWindow()->WalkWindowTree(redrawStoreWalker, EWalkChildrenAndBehind);
sl@0
    77
		
sl@0
    78
	iTextLine0.Format(KLine1Format,iKeyEvents,scheduler->Requests()-iPolls,wservPercent,drawingPercent,reclaimedPercent);
sl@0
    79
	iTextLine1.Format(KLine2Format,redrawStoreWalker.iTotalSize, updatesPerSecond, pixelsPerSecond);
sl@0
    80
		
sl@0
    81
	iLastTotal=scheduler->Total();
sl@0
    82
	iLastIdle=scheduler->Idle();
sl@0
    83
	iLastDrawing=scheduler->Drawing();
sl@0
    84
	iLastReclaimedIdleTime=scheduler->ReclaimedIdleTime();	
sl@0
    85
			
sl@0
    86
	aArray.Reset();
sl@0
    87
	TPtrC ptr(iTextLine0);
sl@0
    88
	aArray.Append(ptr);
sl@0
    89
	ptr.Set(iTextLine1);
sl@0
    90
	aArray.Append(ptr);	
sl@0
    91
	}
sl@0
    92
sl@0
    93
void CDebugBar::OnKeyEvent()
sl@0
    94
	{
sl@0
    95
	iKeyEvents++;
sl@0
    96
	iScreen->ScheduleRender(0);
sl@0
    97
	}
sl@0
    98
sl@0
    99