sl@0: // Copyright (c) 2008-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: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: #include "ratelimitdrawer.h" sl@0: #include "wsratelimitdrawer.h" sl@0: #include sl@0: sl@0: //Constant message handle, which is used to send count value between client and plug-in sl@0: const TUint8 KCmdCount=0; sl@0: // First Frame sl@0: const TInt KFirstFrame = 0; sl@0: sl@0: /** sl@0: Creates new test framerate object. sl@0: */ sl@0: CWsRateLimitGraphicDrawer* CWsRateLimitGraphicDrawer::NewL() sl@0: { sl@0: return new(ELeave) CWsRateLimitGraphicDrawer; sl@0: } sl@0: sl@0: CWsRateLimitGraphicDrawer::CWsRateLimitGraphicDrawer() sl@0: { sl@0: InitialiseMembers(); sl@0: } sl@0: sl@0: void CWsRateLimitGraphicDrawer::InitialiseMembers() sl@0: { sl@0: iColors[0] = TRgb(0x000000); sl@0: iColors[1] = TRgb(0x555555); sl@0: iColors[2] = TRgb(0x000080); sl@0: iColors[3] = TRgb(0x008000); sl@0: iColors[4] = TRgb(0x008080); sl@0: iColors[5] = TRgb(0x800000); sl@0: iColors[6] = TRgb(0x800080); sl@0: iColors[7] = TRgb(0x808000); sl@0: iColors[8] = TRgb(0x0000ff); sl@0: iColors[9] = TRgb(0x00ff00); sl@0: iColors[10] = TRgb(0x000000); sl@0: iColors[11] = TRgb(0x555555); sl@0: iColors[12] = TRgb(0x000080); sl@0: iColors[13] = TRgb(0x008000); sl@0: iColors[14] = TRgb(0x008080); sl@0: iColors[15] = TRgb(0x800000); sl@0: iColors[16] = TRgb(0x800080); sl@0: iColors[17] = TRgb(0x808000); sl@0: iColors[18] = TRgb(0x0000ff); sl@0: iColors[19] = TRgb(0x00ff00); sl@0: iColors[20] = TRgb(0x000000); sl@0: iColors[21] = TRgb(0x555555); sl@0: iColors[22] = TRgb(0x000080); sl@0: iColors[23] = TRgb(0x008000); sl@0: iColors[24] = TRgb(0x008080); sl@0: iColors[25] = TRgb(0x800000); sl@0: iColors[26] = TRgb(0x800080); sl@0: iColors[27] = TRgb(0x808000); sl@0: iColors[28] = TRgb(0x0000ff); sl@0: iColors[29] = TRgb(0x00ff00); sl@0: iColors[30] = TRgb(0x000000); sl@0: iColors[31] = TRgb(0x555555); sl@0: iColors[32] = TRgb(0x000080); sl@0: iColors[33] = TRgb(0x008000); sl@0: iColors[34] = TRgb(0x008080); sl@0: iColors[35] = TRgb(0x800000); sl@0: iColors[36] = TRgb(0x800080); sl@0: iColors[37] = TRgb(0x808000); sl@0: iColors[38] = TRgb(0x0000ff); sl@0: iColors[39] = TRgb(0x00ff00); sl@0: sl@0: iFrameRate = 0.0; sl@0: } sl@0: sl@0: sl@0: CWsRateLimitGraphicDrawer::~CWsRateLimitGraphicDrawer() sl@0: { sl@0: } sl@0: sl@0: void CWsRateLimitGraphicDrawer::ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner,const TDesC8& /*aData*/) sl@0: { sl@0: BaseConstructL(aEnv,aId,aOwner); sl@0: } sl@0: sl@0: /** sl@0: Simulate two animations of different frame rate with their respective schedule. sl@0: sl@0: @param MWsGc Window server graphic context to draw the animation sl@0: @param TRect Rectangle are required to draw the animation sl@0: @param TDesC Parameter value to use inside this function. sl@0: */ sl@0: void CWsRateLimitGraphicDrawer::DoDraw(MWsGc& aGc,const TRect& aRect,const TDesC8& /*aData*/) const sl@0: { sl@0: TPoint KWinPos = aRect.iTl + TPoint(10,10); sl@0: const TSize KWinSize(100,100); sl@0: const TRect KWinRect(KWinPos,KWinSize); sl@0: sl@0: MWsGraphicsContext* context = static_cast(aGc.ResolveObjectInterface(KMWsGraphicsContext)); sl@0: sl@0: //Get the time the animation starts sl@0: if(iFrame == KFirstFrame) sl@0: { sl@0: iStartTime = aGc.Now(); sl@0: } sl@0: sl@0: //Draw a filled rect with the chosen color sl@0: context->Push(); sl@0: context->SetBrushStyle(MWsGraphicsContext::ESolidBrush); sl@0: context->SetBrushColor(iColors[iFrame]); sl@0: context->DrawRect(KWinRect); sl@0: context->Pop(); sl@0: sl@0: if(iFrame < KMaxFrames) sl@0: { sl@0: aGc.ScheduleAnimation(KWinRect,0); sl@0: } sl@0: else sl@0: { sl@0: TTimeIntervalMicroSeconds animLength = aGc.Now().MicroSecondsFrom(iStartTime); sl@0: sl@0: iFrameRate = static_cast(KMaxFrames)/(static_cast(animLength.Int64())/KOneSecondInMicroSecs); sl@0: } sl@0: sl@0: iFrame++; sl@0: } sl@0: sl@0: /** sl@0: Handles message between client and plug-in. sl@0: sl@0: @param TDesC Constant message command. sl@0: */ sl@0: void CWsRateLimitGraphicDrawer::HandleMessage(const TDesC8& aData) sl@0: { sl@0: switch (aData[0]) sl@0: { sl@0: case KCmdCount: sl@0: TPckgBuf buf; sl@0: buf().iFrameRate = iFrameRate; sl@0: TInt err = SendMessage(buf); sl@0: __ASSERT_DEBUG(err>=KErrNone, User::Invariant()); sl@0: break; sl@0: } sl@0: } sl@0: