os/graphics/windowing/windowserver/test/tframerate/framerate.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tframerate/framerate.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,95 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test - Test plug-in to test wsgraphic animation artwork framerate
    1.22 + @internalComponent - Internal Symbian test code
    1.23 +*/
    1.24 +
    1.25 +#include <bitstd.h>
    1.26 +#include <graphics/wsgraphicdrawer.h>
    1.27 +#include "framerate.h"
    1.28 +#include "wsgraphicdrawercontext.h"
    1.29 +#include "wsframerate.h"
    1.30 +
    1.31 +//Constant message handle, which is used to send count value between client and plug-in
    1.32 +const TUint8 KCmdCount=0;
    1.33 +
    1.34 +/**
    1.35 +Creates new test framerate object.
    1.36 +*/
    1.37 +CGraphicDrawerTestFrameRate* CGraphicDrawerTestFrameRate::CreateL()
    1.38 +	{
    1.39 +	return new(ELeave) CGraphicDrawerTestFrameRate;
    1.40 +	}
    1.41 +
    1.42 +CGraphicDrawerTestFrameRate::CGraphicDrawerTestFrameRate()
    1.43 +	{
    1.44 +	}
    1.45 +
    1.46 +CGraphicDrawerTestFrameRate::~CGraphicDrawerTestFrameRate()
    1.47 +	{
    1.48 +	}
    1.49 +
    1.50 +void CGraphicDrawerTestFrameRate::ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner,const TDesC8& /*aData*/)
    1.51 +	{
    1.52 +	BaseConstructL(aEnv,aId,aOwner);
    1.53 +	if (aEnv.Screen(0)->ResolveObjectInterface(KMWsScreenConfigInterfaceId))
    1.54 +		{
    1.55 +		iContext = CWsGraphicDrawerNonNgaContext::NewL();
    1.56 +		}
    1.57 +	else
    1.58 +		{
    1.59 +		iContext = CWsGraphicDrawerNgaContext::NewL();
    1.60 +		}
    1.61 +	}
    1.62 +
    1.63 +/**	
    1.64 +Simulate two animations of different frame rate with their respective schedule.
    1.65 +
    1.66 +@param MWsGc Window server graphic context to draw the animation
    1.67 +@param TRect Rectangle are required to draw the animation
    1.68 +@param TDesC Parameter value to use inside this function.
    1.69 +*/
    1.70 +void CGraphicDrawerTestFrameRate::DoDraw(MWsGc& aGc,const TRect& aRect,const TDesC8& aData) const
    1.71 +	{
    1.72 +	TInt animId = aData[0];
    1.73 +	TInt requestedFps = aData[1];
    1.74 +	++iCounter[animId];
    1.75 +	//Schedule next redraw based on requested frame rate
    1.76 +	TTimeIntervalMicroSeconds nextTick = 1000000/requestedFps;
    1.77 +	iContext->ScheduleAnimation(aGc, aRect, nextTick);
    1.78 +	}
    1.79 +
    1.80 +/**	
    1.81 +Handles message between client and plug-in.
    1.82 +
    1.83 +@param TDesC Constant message command.
    1.84 +*/
    1.85 +void CGraphicDrawerTestFrameRate::HandleMessage(const TDesC8& aData)
    1.86 +	{
    1.87 +	switch (aData[0])
    1.88 +		{
    1.89 +		case KCmdCount:
    1.90 +			TPckgBuf<TAnimRate> buf;
    1.91 +			buf().iAnim1=iCounter[0];
    1.92 +			buf().iAnim2=iCounter[1];
    1.93 +			TInt err = SendMessage(buf);
    1.94 +			__ASSERT_DEBUG(err>=KErrNone, User::Invariant());
    1.95 +			break;
    1.96 +		}
    1.97 +	}
    1.98 +