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: #define SYMBIAN_GRAPHICS_GCE
sl@0: 
sl@0: #include "wsgraphicdrawercontext.h"
sl@0: #include "stdgraphictestdrawer.h"
sl@0: #include <graphics/wsgraphicscontext.h>
sl@0: 
sl@0: MWsGraphicDrawerContext* CWsGraphicDrawerNgaContext::NewL()
sl@0: 	{
sl@0: 	return new(ELeave) CWsGraphicDrawerNgaContext();
sl@0: 	}
sl@0: 
sl@0: void CWsGraphicDrawerNgaContext::Destroy()
sl@0: 	{
sl@0: 	delete this;
sl@0: 	}
sl@0: 
sl@0: MWsClient& CWsGraphicDrawerNgaContext::Client(MWsGc& aGc)
sl@0: 	{
sl@0: 	return aGc.Client();
sl@0: 	}
sl@0: 
sl@0: MWsScreen& CWsGraphicDrawerNgaContext::Screen(MWsGc& aGc)
sl@0: 	{
sl@0: 	return aGc.Screen();
sl@0: 	}
sl@0: 
sl@0: const TTime& CWsGraphicDrawerNgaContext::Now(MWsGc& aGc) const
sl@0: 	{
sl@0: 	return aGc.Now();
sl@0: 	}
sl@0: 
sl@0: void CWsGraphicDrawerNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow)
sl@0: 	{
sl@0: 	aGc.ScheduleAnimation(aRect, aFromNow);
sl@0: 	}
sl@0: 
sl@0: void CWsGraphicDrawerNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop)
sl@0: 	{
sl@0: 	aGc.ScheduleAnimation(aRect, aFromNow, aFreq, aStop);
sl@0: 	}
sl@0: 
sl@0: void CWsGraphicDrawerNgaContext::SetGcOrigin(MWsGc& aGc, const TPoint& aOrigin)
sl@0: 	{
sl@0: 	aGc.SetGcOrigin(aOrigin);
sl@0: 	}
sl@0: 
sl@0: TInt CWsGraphicDrawerNgaContext::Push(MWsGc& aGc) const
sl@0: 	{
sl@0: 	MWsGraphicsContext* context = aGc.ObjectInterface<MWsGraphicsContext>();
sl@0: 	if (context)
sl@0: 		{
sl@0: 		return context->Push();
sl@0: 		}
sl@0: 	return KErrNotSupported;
sl@0: 	}
sl@0: 
sl@0: void CWsGraphicDrawerNgaContext::Pop(MWsGc& aGc) const
sl@0: 	{
sl@0: 	MWsGraphicsContext* context = aGc.ObjectInterface<MWsGraphicsContext>();
sl@0: 	if (context)
sl@0: 		{
sl@0: 		context->Pop();
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: void CWsGraphicDrawerNgaContext::DrawBitmap(MWsGc& aGc, const TPoint& aDestPos, const CFbsBitmap* aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap) const
sl@0: 	{
sl@0: 	MWsGraphicsContext* context = aGc.ObjectInterface<MWsGraphicsContext>();
sl@0: 	if (context)
sl@0: 		{
sl@0: 		if (aMaskBitmap)
sl@0: 			{
sl@0: 			context->BitBltMasked(aDestPos, *aSourceBitmap, aSourceRect, *aMaskBitmap, EFalse);
sl@0: 			}
sl@0: 		else
sl@0: 			{
sl@0: 			context->BitBlt(aDestPos, *aSourceBitmap, aSourceRect);
sl@0: 			}
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: void CWsGraphicDrawerNgaContext::DrawFrameRate(MWsGc& aGc, const TRect& aRect, const CFrameRate& aFps) const
sl@0: 	{
sl@0: 	MWsGraphicsContext* context = aGc.ObjectInterface<MWsGraphicsContext>();
sl@0: 	if (context)
sl@0: 		{
sl@0: 		context->SetDrawMode(MWsGraphicsContext::EDrawModePEN);
sl@0: 		context->SetPenStyle(MWsGraphicsContext::ENullPen);
sl@0: 		context->SetBrushStyle(MWsGraphicsContext::ENullBrush);
sl@0: 
sl@0: 		if ((aFps.CountSamples() > 1) && context->HasFont())
sl@0: 			{
sl@0: 			TBuf<20> buf;
sl@0: 			buf.AppendNum(aFps.Fps());
sl@0: 			context->SetPenColor(KRgbRed);
sl@0: 			context->DrawText(buf,NULL,TPoint(aRect.iTl.iX,aRect.iBr.iY));
sl@0: 			}
sl@0: 		}
sl@0: 	}