diff -r 000000000000 -r bde4ae8d615e os/graphics/windowing/windowserver/test/t_integ/src/t_pseudoappcfbsbitmapanim.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/graphics/windowing/windowserver/test/t_integ/src/t_pseudoappcfbsbitmapanim.cpp Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,171 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent +*/ + +#include "t_pseudoappcfbsbitmapanim.h" +#include "t_testsurfacerasterizer.h" + +EXPORT_C CCFbsBitmapAnimation* CCFbsBitmapAnimation::NewL(TDisplayMode aMode, const TSize& aAnimSize, const TSize& aSurfaceSize, + TPtrC& aBitmapFile, TInt aHorizontalRate, TInt aVerticalRate, + TPixelFormat aPixelFormat) + { + RDebug::Print(_L("Creating CCFbsBitmapAnimation class\n")); + CCFbsBitmapAnimation* self = new (ELeave) CCFbsBitmapAnimation(); + CleanupStack::PushL(self); + self->ConstructL(aMode, aAnimSize, aSurfaceSize, aBitmapFile, aHorizontalRate, aVerticalRate, aPixelFormat); + CleanupStack::Pop(); // self; + return self; + } + +void CCFbsBitmapAnimation::ConstructL(TDisplayMode aMode, const TSize& aAnimSize, const TSize& aSurfaceSize, + TPtrC& aBitmapFile, TInt aHorizontalRate, TInt aVerticalRate, + TPixelFormat aPixelFormat) + { + RDebug::Print(_L("Creating full-screen bitmap\n")); + + iBitmapAnimFile.Set(aBitmapFile); + iHorizontalRate = aHorizontalRate; + iVerticalRate = aVerticalRate; + iAnimSize = aAnimSize; + iSurfaceSize = aSurfaceSize; + iPixelFormat = aPixelFormat; + iRotationSupported = ETrue; + + iFullSurfaceBitmap = new(ELeave) CFbsBitmap; + + if(iPixelFormat == EFormatYuv) + { + TSize sz(iSurfaceSize.iWidth/2, iSurfaceSize.iHeight); + iFullSurfaceBitmap->Create(sz, static_cast(aMode)); + } + else + { + iFullSurfaceBitmap->Create(iSurfaceSize, static_cast(aMode)); + } + iFullSurfaceBitmapDevice = CFbsBitmapDevice::NewL(iFullSurfaceBitmap); + iFullSurfaceBitmapGc = CFbsBitGc::NewL(); + iFullSurfaceBitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + } + +CCFbsBitmapAnimation::CCFbsBitmapAnimation() : CTestAnimation() + { + }; + +EXPORT_C CCFbsBitmapAnimation::~CCFbsBitmapAnimation() + { + delete iFullSurfaceBitmapGc; + delete iFullSurfaceBitmapDevice; + delete iFullSurfaceBitmap; + } + +EXPORT_C void CCFbsBitmapAnimation::Rotate(TSize /*aScreenSize*/) + { + } + +EXPORT_C void CCFbsBitmapAnimation::DrawL(CTestSurfaceRasterizer* aSurfaceRasterizer, SurfaceDetails& aSurfDetails) + { + iFullSurfaceBitmapGc->Activate(iFullSurfaceBitmapDevice); + iFullSurfaceBitmapGc->Clear(); + + RedrawSurfaceL(); + + //Send the fullscreen bitmap to the test rasterizer + iFullSurfaceBitmap->LockHeap(); + + TUint32* bitmapBufferPtr = iFullSurfaceBitmap->DataAddress(); + aSurfaceRasterizer->DrawRect(bitmapBufferPtr, aSurfDetails); + + iFullSurfaceBitmap->UnlockHeap(); + } + +EXPORT_C void CCFbsBitmapAnimation::SetFrameNumber(TInt aFrameNumber) + { + iFrameCounter = aFrameNumber; + } + +void CCFbsBitmapAnimation::RedrawSurfaceL() + { + CFbsBitmap bitmap; + User::LeaveIfError(bitmap.Load(iBitmapAnimFile, iFrameCounter)); + + const TSize nativeSize(bitmap.SizeInPixels()); + + const TSize fullScreenSize(iFullSurfaceBitmap->SizeInPixels()); + + if(iPixelFormat == EFormatYuv) + { + TInt noOfPixels=fullScreenSize.iWidth * fullScreenSize.iHeight; + TInt counter=noOfPixels; + TUint32* address = iFullSurfaceBitmap->DataAddress(); + for(TInt i=0; iDrawBitmap(TRect(TPoint(iXPos, iYPos), sz), &bitmap, TRect(TPoint(0,0), nativeSize)); + + //Wrap in x co-ord + if( (iXPos + iAnimSize.iWidth) > iSurfaceSize.iWidth) + { + iFullSurfaceBitmapGc->DrawBitmap(TRect(TPoint(iXPos - iSurfaceSize.iWidth, iYPos), sz), + &bitmap, TRect(TPoint(0,0), nativeSize)); + } + + //Wrap in y co-ord + if( (iYPos + iAnimSize.iHeight) > iSurfaceSize.iHeight) + { + iFullSurfaceBitmapGc->DrawBitmap(TRect(TPoint(iXPos, iYPos - iSurfaceSize.iHeight), sz), + &bitmap, TRect(TPoint(0,0), nativeSize)); + } + + //Wrap in both x and y co-ords + if( ((iXPos + iAnimSize.iWidth) > iSurfaceSize.iWidth) && ((iYPos + iAnimSize.iHeight) > iSurfaceSize.iHeight) ) + { + iFullSurfaceBitmapGc->DrawBitmap(TRect(TPoint(iXPos - iSurfaceSize.iWidth, iYPos - iSurfaceSize.iHeight), sz), + &bitmap, TRect(TPoint(0,0), nativeSize)); + } + + //Increment x and y positions and wrap if necessary + iXPos += iSurfaceSize.iWidth/iHorizontalRate; + iYPos += iSurfaceSize.iHeight/iVerticalRate; + iXPos = iXPos % iSurfaceSize.iWidth; + iYPos = iYPos % iSurfaceSize.iHeight; + + iFrameCounter++; + }