windowing/windowserver/tframerate/framerate.cpp
changeset 110 7f25ef56562d
parent 98 bf7481649c98
child 111 29ddb8a72f0e
equal deleted inserted replaced
98:bf7481649c98 110:7f25ef56562d
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test - Test plug-in to test wsgraphic animation artwork framerate
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include <bitstd.h>
       
    23 #include <graphics/wsgraphicdrawer.h>
       
    24 #include "framerate.h"
       
    25 #include "wsgraphicdrawercontext.h"
       
    26 #include "wsframerate.h"
       
    27 
       
    28 //Constant message handle, which is used to send count value between client and plug-in
       
    29 const TUint8 KCmdCount=0;
       
    30 
       
    31 /**
       
    32 Creates new test framerate object.
       
    33 */
       
    34 CGraphicDrawerTestFrameRate* CGraphicDrawerTestFrameRate::CreateL()
       
    35 	{
       
    36 	return new(ELeave) CGraphicDrawerTestFrameRate;
       
    37 	}
       
    38 
       
    39 CGraphicDrawerTestFrameRate::CGraphicDrawerTestFrameRate()
       
    40 	{
       
    41 	}
       
    42 
       
    43 CGraphicDrawerTestFrameRate::~CGraphicDrawerTestFrameRate()
       
    44 	{
       
    45 	}
       
    46 
       
    47 void CGraphicDrawerTestFrameRate::ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner,const TDesC8& /*aData*/)
       
    48 	{
       
    49 	BaseConstructL(aEnv,aId,aOwner);
       
    50 	if (aEnv.Screen(0)->ResolveObjectInterface(KMWsScreenConfigInterfaceId))
       
    51 		{
       
    52 		iContext = CWsGraphicDrawerNonNgaContext::NewL();
       
    53 		}
       
    54 	else
       
    55 		{
       
    56 		iContext = CWsGraphicDrawerNgaContext::NewL();
       
    57 		}
       
    58 	}
       
    59 
       
    60 /**	
       
    61 Simulate two animations of different frame rate with their respective schedule.
       
    62 
       
    63 @param MWsGc Window server graphic context to draw the animation
       
    64 @param TRect Rectangle are required to draw the animation
       
    65 @param TDesC Parameter value to use inside this function.
       
    66 */
       
    67 void CGraphicDrawerTestFrameRate::DoDraw(MWsGc& aGc,const TRect& aRect,const TDesC8& aData) const
       
    68 	{
       
    69 	TInt animId = aData[0];
       
    70 	TInt requestedFps = aData[1];
       
    71 	++iCounter[animId];
       
    72 	//Schedule next redraw based on requested frame rate
       
    73 	TTimeIntervalMicroSeconds nextTick = 1000000/requestedFps;
       
    74 	iContext->ScheduleAnimation(aGc, aRect, nextTick);
       
    75 	}
       
    76 
       
    77 /**	
       
    78 Handles message between client and plug-in.
       
    79 
       
    80 @param TDesC Constant message command.
       
    81 */
       
    82 void CGraphicDrawerTestFrameRate::HandleMessage(const TDesC8& aData)
       
    83 	{
       
    84 	switch (aData[0])
       
    85 		{
       
    86 		case KCmdCount:
       
    87 			TPckgBuf<TAnimRate> buf;
       
    88 			buf().iAnim1=iCounter[0];
       
    89 			buf().iAnim2=iCounter[1];
       
    90 			TInt err = SendMessage(buf);
       
    91 			__ASSERT_DEBUG(err>=KErrNone, User::Invariant());
       
    92 			break;
       
    93 		}
       
    94 	}
       
    95