sl@0: // Copyright (c) 2007-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 sl@0: */ sl@0: #include //KNullUidValue sl@0: #include sl@0: #include "t_pseudoappsurfacedwindow.h" sl@0: sl@0: #include "t_testsurfacerasterizer.h" sl@0: #include "t_pseudoapputils.h" sl@0: #include "t_pseudoappscreen.h" //KScreenWindow sl@0: #include "t_pseudoappcfbsbitmapanim.h" sl@0: #include "t_pseudoappvganimation.h" sl@0: #include "t_pseudoappopenglanimation.h" sl@0: #include "t_pseudoappperformanceanim.h" sl@0: sl@0: sl@0: CTestSurfacedWindow* CTestSurfacedWindow::NewL(TInt aScreenNo, TInt aWindowNumber, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults, sl@0: const TDesC& aConfigFileName, CTPseudoAppShared& aPseudoAppShared) sl@0: { sl@0: RDebug::Print(_L("Creating CTestSurfacedWindow class\n")); sl@0: CTestSurfacedWindow* self = new (ELeave) CTestSurfacedWindow(aScreenNo, aWindowNumber, aPseudoAppShared); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aScreenNo, aWindowNumber, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName); sl@0: CleanupStack::Pop(); // self; sl@0: return self; sl@0: } sl@0: sl@0: void CTestSurfacedWindow::ConstructL(TInt aScreenNo, TInt aWindowNumber, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults, sl@0: const TDesC& aConfigFileName) sl@0: { sl@0: RDebug::Print(_L("Constructing CTestSurfacedWindow for screen %d\n"), aScreenNo); sl@0: sl@0: //Create CIniData class for reading in values form ini files sl@0: iUtils = CIniData::NewL(aConfigFileName); sl@0: sl@0: TSize surfaceSize; sl@0: TInt surfacePresent = 0; sl@0: TPixelFormat pixelFormat = EFormatRgb; sl@0: sl@0: RDebug::Print(_L("Import configuration for ui window class and create it\n")); sl@0: ImportWindowConfigL(aScreenNo, aWindowNumber, aMode, aFrameDuration, aScreenSize, aGceTestResults); sl@0: sl@0: RDebug::Print(_L("Import configuration for test surface class and create it\n")); sl@0: ImportSurfaceConfigL(aScreenNo, aWindowNumber, aScreenSize, surfaceSize, surfacePresent, pixelFormat); sl@0: sl@0: RDebug::Print(_L("Surface height = %d Surface Width = %d\n"),surfaceSize.iHeight, surfaceSize.iWidth); sl@0: sl@0: RDebug::Print(_L("Import configuration for test animation class and create it\n")); sl@0: ImportAnimConfigL(aScreenNo, aWindowNumber, aMode, surfaceSize, pixelFormat); sl@0: sl@0: if(surfacePresent) sl@0: { sl@0: RDebug::Print(_L("Create Surface Rasterizer\n")); sl@0: iSurfaceRasterizer = CTestSurfaceRasterizer::NewL(iSurfaceId, iSurfaceScreenNumber, &iSurfaceManager); sl@0: sl@0: if(iSurfaceRasterizer == 0) sl@0: { sl@0: RDebug::Print(_L("Fatal error creating Surface Rasterizer, aborting\n")); sl@0: User::Exit(0); sl@0: } sl@0: } sl@0: sl@0: iGceTestResults = aGceTestResults; sl@0: } sl@0: sl@0: CTestSurfacedWindow::CTestSurfacedWindow(TInt aScreenNo, TInt aWindowNumber, CTPseudoAppShared& aPseudoAppShared) sl@0: :iScreenNo(aScreenNo), iWindowNumber(aWindowNumber), iPseudoAppShared(aPseudoAppShared) sl@0: { sl@0: } sl@0: sl@0: void CTestSurfacedWindow::UpdateL(SurfaceDetails& aSurfDetails) sl@0: { sl@0: //Test to see if the surfaced window has an animation associated with it sl@0: if(iTestAnimation) sl@0: { sl@0: iTestAnimation->DrawL(iSurfaceRasterizer, aSurfDetails); sl@0: } sl@0: sl@0: //Draw the window last to avoid appearance of "black" surface sl@0: iTestWindow->DrawL(); sl@0: } sl@0: sl@0: CTestSurfacedWindow::~CTestSurfacedWindow() sl@0: { sl@0: delete iUtils; sl@0: if(iSizeArray) sl@0: { sl@0: TInt noElements = iSizeArray->Count(); sl@0: iSizeArray->Delete(0, noElements); sl@0: delete iSizeArray; sl@0: iSizeArray = 0; sl@0: } sl@0: sl@0: if(iPositionArray) sl@0: { sl@0: TInt noElements = iPositionArray->Count(); sl@0: iPositionArray->Delete(0, noElements); sl@0: delete iPositionArray; sl@0: iPositionArray = 0; sl@0: } sl@0: sl@0: if(iLoadsarects) sl@0: { sl@0: TInt noElements = iLoadsarects->Count(); sl@0: iLoadsarects->Delete(0, noElements); sl@0: delete iLoadsarects; sl@0: iLoadsarects = 0; sl@0: } sl@0: sl@0: if(iLoadsaParameters) sl@0: { sl@0: TInt noElements = iLoadsaParameters->Count(); sl@0: iLoadsaParameters->Delete(0, noElements); sl@0: delete iLoadsaParameters; sl@0: iLoadsaParameters = 0; sl@0: } sl@0: sl@0: delete iSurfaceRasterizer; sl@0: delete iTestWindow; sl@0: delete iTestAnimation; sl@0: sl@0: DestroySurface(); sl@0: DestroySurfaceManager(); sl@0: } sl@0: sl@0: void CTestSurfacedWindow::RotateL(TInt aScreenNo, TInt aWindowNumber, const TSize& aScreenSize, TInt aFrameNumber) sl@0: { sl@0: if(iTestAnimation) sl@0: { sl@0: //Destroy the current surface and create a new surface with the new screen dimensions sl@0: TSize surfaceSize; sl@0: TInt surfacePresent = 0; sl@0: TPixelFormat pixelFormat = EFormatRgb; sl@0: sl@0: delete iSurfaceRasterizer; sl@0: delete iTestAnimation; sl@0: sl@0: DestroySurface(); sl@0: sl@0: ImportSurfaceConfigL(aScreenNo, aWindowNumber, aScreenSize, surfaceSize, surfacePresent, pixelFormat); sl@0: sl@0: RDebug::Print(_L("Surface height = %d Surface Width = %d\n"),surfaceSize.iHeight, surfaceSize.iWidth); sl@0: sl@0: RDebug::Print(_L("Import configuration for test animation class and create it\n")); sl@0: ImportAnimConfigL(0, 1, EColor16MA, surfaceSize, pixelFormat); sl@0: sl@0: if(surfacePresent) sl@0: { sl@0: RDebug::Print(_L("Create Surface Rasterizer\n")); sl@0: sl@0: iSurfaceRasterizer = CTestSurfaceRasterizer::NewL(iSurfaceId, iSurfaceScreenNumber, &iSurfaceManager); sl@0: sl@0: if(iSurfaceRasterizer == 0) sl@0: { sl@0: RDebug::Print(_L("Fatal error creating Surface Rasterizer, aborting\n")); sl@0: User::Exit(0); sl@0: } sl@0: } sl@0: sl@0: if(iTestAnimation->RotationSupported()) sl@0: { sl@0: //Continue animation from the last unrotated frame number sl@0: iTestAnimation->SetFrameNumber(aFrameNumber); sl@0: } sl@0: } sl@0: sl@0: iTestWindow->Rotate(aScreenSize); sl@0: } sl@0: sl@0: TBool CTestSurfacedWindow::RotationSupported() sl@0: { sl@0: if(iPseudoAppShared.RotationSupported(iScreenNo, iWindowNumber, iSurfaceId)) sl@0: { sl@0: if(iTestAnimation) sl@0: { sl@0: return iTestAnimation->RotationSupported(); sl@0: } sl@0: else sl@0: { sl@0: //If no test animation is present, rotation is possible sl@0: return ETrue; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: return EFalse; sl@0: } sl@0: sl@0: } sl@0: sl@0: void CTestSurfacedWindow::ImportWindowConfigL(TInt aScreenNo, TInt aWindowNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults) sl@0: { sl@0: TBuf tempStore; sl@0: tempStore.Format(KScreenWindowNumber, aScreenNo, aWindowNo); sl@0: sl@0: TSize windowSize; sl@0: TInt windowType; sl@0: TInt windowChangeGeometry; sl@0: TInt windowChangeBehavior; sl@0: sl@0: tempStore.Format(KScreenWindowNumber, aScreenNo, aWindowNo); sl@0: sl@0: READ_INI3A(tempStore, type, ui_window, ecom_window, empty_window, sl@0: windowType, EUiWindow, EEcomWindow, EEmptyWindow, iUtils); sl@0: sl@0: //viewfinder and empty windows are both catered for by the CTestEmptyWindow class sl@0: switch(windowType) sl@0: { sl@0: case EEcomWindow: sl@0: { sl@0: TPtrC multiBitmapEcomFile; sl@0: TInt multiBitmapEcomFileSize; sl@0: sl@0: READ_INI1A(tempStore, multi_bitmap_ecom_file, multiBitmapEcomFile, iUtils); sl@0: READ_INI1A(tempStore, multi_bitmap_ecom_file_size, multiBitmapEcomFileSize, iUtils); sl@0: sl@0: READ_INI5A(tempStore, window_change_geometry, none, size, position, position_and_size, sl@0: position_and_size_with_opacity, windowChangeGeometry, ENoChanges, EWindowSize, sl@0: EWindowPosition, EWindowPositionAndSize, EWindowPositionAndSizeWithOpacity, iUtils); sl@0: READ_INI3A(tempStore, window_change_behavior, none, incremental, cyclic, windowChangeBehavior, sl@0: ENoChange, EIncremental, ECyclic, iUtils); sl@0: sl@0: sl@0: sl@0: iSizeArray = ImportWindowSizeChangeParamsL(tempStore); sl@0: iPositionArray = ImportWindowPositionChangeParamsL(tempStore); sl@0: sl@0: BuildDimensionArrayL(aScreenSize, aFrameDuration, windowChangeGeometry, windowChangeBehavior); sl@0: sl@0: iTestWindow = CTestEcomWindow::NewL(aScreenNo, aMode, multiBitmapEcomFile, multiBitmapEcomFileSize, aGceTestResults, iLoadsaParameters); sl@0: break; sl@0: } sl@0: case EEmptyWindow: sl@0: { sl@0: iTestWindow = CTestEmptyWindow::NewL(aScreenNo, aMode, aScreenSize); sl@0: break; sl@0: } sl@0: case EUiWindow: sl@0: { sl@0: TPtrC multiBitmapUiFile; sl@0: TInt multiBitmapUiFileSize; sl@0: TInt multiBitmapUiFileTransparency; sl@0: sl@0: READ_INI1A(tempStore, multi_bitmap_ui_file, multiBitmapUiFile, iUtils); sl@0: READ_INI1A(tempStore, multi_bitmap_ui_file_size, multiBitmapUiFileSize, iUtils); sl@0: READ_INI2A(tempStore, multi_bitmap_ui_file_transparency, True, False, sl@0: multiBitmapUiFileTransparency, ETrue, EFalse, iUtils); sl@0: READ_INI5A(tempStore, window_change_geometry, none, size, position, position_and_size, sl@0: position_and_size_with_opacity, windowChangeGeometry, ENoChanges, EWindowSize, sl@0: EWindowPosition, EWindowPositionAndSize, EWindowPositionAndSizeWithOpacity, iUtils); sl@0: READ_INI3A(tempStore, window_change_behavior, none, incremental, cyclic, windowChangeBehavior, sl@0: ENoChange, EIncremental, ECyclic, iUtils); sl@0: sl@0: sl@0: iSizeArray = ImportWindowSizeChangeParamsL(tempStore); sl@0: iPositionArray = ImportWindowPositionChangeParamsL(tempStore); sl@0: sl@0: BuildDimensionArrayL(aScreenSize, aFrameDuration, windowChangeGeometry, windowChangeBehavior); sl@0: sl@0: iLoadsarects = ImportWindowBitmapParamsL(tempStore, multiBitmapUiFileSize, aScreenSize); sl@0: sl@0: iTestWindow = CTestUiWindow::NewL(aScreenNo, aMode, multiBitmapUiFile, multiBitmapUiFileSize, iLoadsarects, sl@0: aFrameDuration, sl@0: multiBitmapUiFileTransparency, sl@0: aGceTestResults, iLoadsaParameters); sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: break; //Cannot reach default, Lint warning removal only sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CTestSurfacedWindow::ImportSurfaceConfigL(TInt aScreenNo, TInt aWindowNo, const TSize& aScreenSize, TSize& aSurfaceSize, TInt& aSurfacePresent, TPixelFormat& aPixelFormat) sl@0: { sl@0: TBuf tempStore; sl@0: tempStore.Format(KScreenSurface, aScreenNo, aWindowNo); sl@0: sl@0: TInt shareScreenNumber; sl@0: TInt shareWindowNumber; sl@0: sl@0: // Check to see if window is sharing surface with another window sl@0: TBool shareSurface = TImportScreenConfig::GetShareSurfaceInfoL(aScreenNo, aWindowNo, shareScreenNumber, shareWindowNumber, iUtils); sl@0: sl@0: // Check to see if this window already has a SurfaceId allocated for it s sl@0: iSurfaceId = iPseudoAppShared.GetSurfaceId(aScreenNo, aWindowNo); sl@0: sl@0: if(shareSurface && iSurfaceId.IsNull()) sl@0: { sl@0: // SurfaceId not found, but check to see if the sharing window already has a SurfaceId allocated for it sl@0: iSurfaceId = iPseudoAppShared.GetSurfaceId(shareScreenNumber, shareWindowNumber); sl@0: } sl@0: sl@0: if(!iSurfaceId.IsNull()) sl@0: { sl@0: // SurfaceId found - open surface to use with this window sl@0: sl@0: //Create a surface manager session sl@0: CreateSurfaceManager(); sl@0: sl@0: iSurfaceManager.OpenSurface(iSurfaceId); sl@0: RSurfaceManager::TInfoBuf infoBuf; sl@0: User::LeaveIfError(KErrNone == iSurfaceManager.SurfaceInfo(iSurfaceId, infoBuf)); sl@0: RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); sl@0: aSurfaceSize = info.iSize; sl@0: if(info.iPixelFormat == EUidPixelFormatYUV_422Interleaved) sl@0: { sl@0: aPixelFormat =EFormatYuv; sl@0: } sl@0: aSurfacePresent = ETrue; sl@0: shareSurface = ETrue; sl@0: } sl@0: else sl@0: { sl@0: // SurfaceId not found - create surface to use with this window sl@0: sl@0: READ_INI2A(tempStore, surface_present, True, False, aSurfacePresent, ETrue, EFalse, iUtils); sl@0: READ_INI1A(tempStore, sneeky_surface_height, aSurfaceSize.iHeight, iUtils); sl@0: READ_INI1A(tempStore, surface_width, aSurfaceSize.iWidth, iUtils); sl@0: sl@0: //Convert surface size percentages to pixel sizes sl@0: if(aScreenSize.iWidth <= 0) sl@0: { sl@0: RDebug::Print(_L("surface_width is zero or less, quitting\n")); sl@0: User::Exit(0); sl@0: } sl@0: else sl@0: { sl@0: aSurfaceSize.iWidth = aSurfaceSize.iWidth*aScreenSize.iWidth/100; sl@0: } sl@0: sl@0: if(aScreenSize.iHeight <= 0) sl@0: { sl@0: RDebug::Print(_L("surface_height is zero or less, quitting\n")); sl@0: User::Exit(0); sl@0: } sl@0: else sl@0: { sl@0: aSurfaceSize.iHeight = aSurfaceSize.iHeight*aScreenSize.iHeight/100; sl@0: } sl@0: sl@0: if(!aSurfacePresent && !shareSurface) sl@0: { sl@0: RDebug::Print(_L("Screen %d, Window %d has no backgroung surface\n"),aScreenNo, aWindowNo); sl@0: return; sl@0: } sl@0: sl@0: RDebug::Print(_L("Setting up surface attributes\n")); sl@0: TInt bytesPerPixel; sl@0: TInt pixelFormat; sl@0: RSurfaceManager::TSurfaceCreationAttributesBuf attribBuf; sl@0: RSurfaceManager::TSurfaceCreationAttributes& buffer = attribBuf(); sl@0: buffer.iMappable = ETrue; sl@0: sl@0: READ_INI4A(tempStore, surface_pixel_format, EUidPixelFormatARGB_8888, EUidPixelFormatRGB_565, EUidPixelFormatARGB_8888_PRE, sl@0: EUidPixelFormatYUV_422Interleaved, pixelFormat, EUidPixelFormatARGB_8888, EUidPixelFormatRGB_565, EUidPixelFormatARGB_8888_PRE, sl@0: EUidPixelFormatYUV_422Interleaved, iUtils); sl@0: READ_INI1A(tempStore, surface_bytes_per_pixel, bytesPerPixel, iUtils); sl@0: READ_INI1A(tempStore, surface_offset_to_first_buffer, buffer.iOffsetToFirstBuffer, iUtils); sl@0: READ_INI1A(tempStore, surface_alignment, buffer.iAlignment, iUtils); sl@0: READ_INI2A(tempStore, surface_contiguous, True, False, buffer.iContiguous, ETrue, EFalse, iUtils); sl@0: READ_INI1A(tempStore, surface_buffer_number, buffer.iBuffers, iUtils); sl@0: sl@0: buffer.iPixelFormat = static_cast(pixelFormat); sl@0: iSurfaceBufferNumber = buffer.iBuffers; sl@0: iSurfaceScreenNumber = aScreenNo; sl@0: if(buffer.iPixelFormat == EUidPixelFormatYUV_422Interleaved) sl@0: { sl@0: aPixelFormat =EFormatYuv; sl@0: } sl@0: sl@0: //Assign size attribute to surface size calculated above sl@0: buffer.iSize = aSurfaceSize; sl@0: sl@0: //Calculate required stride sl@0: buffer.iStride = buffer.iSize.iWidth * bytesPerPixel; sl@0: RDebug::Print(_L("Stride is %d\n"),buffer.iStride); sl@0: sl@0: //Create a surface manager session sl@0: CreateSurfaceManager(); sl@0: sl@0: RDebug::Print(_L("Call to CreateSurface()\n")); sl@0: TInt err = iSurfaceManager.CreateSurface(attribBuf, iSurfaceId); sl@0: if (err != KErrNone) sl@0: { sl@0: RDebug::Print(_L("Error creating surface, aborting\n")); sl@0: User::Exit(0); sl@0: } sl@0: } sl@0: sl@0: //Assign the created surface to be the window background - surface needs to be open to do this ????? sl@0: //Window must be activated at this point for the correct screen mode to be applied sl@0: RDebug::Print(_L("Set Background Surface on the window\n")); sl@0: sl@0: TInt ret = iTestWindow->Window()->SetBackgroundSurface(iSurfaceId); sl@0: if(ret != KErrNone) sl@0: { sl@0: RDebug::Print(_L("Error associating surface with window, SetBackgroundSurface returns %d aborting\n"), ret); sl@0: User::Exit(0); sl@0: } sl@0: sl@0: // Update PseudoAppShared SurfaceId array sl@0: iPseudoAppShared.SetSurfaceIdL(aScreenNo, aWindowNo, iSurfaceId); sl@0: if(shareSurface) sl@0: { sl@0: iPseudoAppShared.SetSurfaceIdL(shareScreenNumber, shareWindowNumber, iSurfaceId); sl@0: } sl@0: } sl@0: sl@0: void CTestSurfacedWindow::ImportAnimConfigL(TInt aScreenNo, TInt aWindowNo, TDisplayMode aMode, const TSize& aSurfaceSize, TPixelFormat aPixelFormat) sl@0: { sl@0: TInt applicationType; sl@0: TBuf tempStore; sl@0: tempStore.Format(KScreenAnimation, aScreenNo, aWindowNo); sl@0: sl@0: READ_INI5A(tempStore, application_type, none, cfbsbitmap, openvg, opengles, performance, sl@0: applicationType, ENoApp, EFbsBitmap, EOpenVG, EOpenGLes, EPerformance, iUtils); sl@0: sl@0: if(applicationType == ENoApp) sl@0: { sl@0: RDebug::Print(_L("Screen %d, Window %d has no surface animation\n"),aScreenNo, aWindowNo); sl@0: return; sl@0: } sl@0: sl@0: TInt imageSize; sl@0: TPtrC multiBitmapAnimFile; sl@0: TInt verticalRate; sl@0: TInt horizontalRate; sl@0: sl@0: //Read in the values from the ini file, taking specified action on failure sl@0: READ_INI1A(tempStore, image_size, imageSize, iUtils); sl@0: READ_INI1A(tempStore, multi_bitmap_anim_file, multiBitmapAnimFile, iUtils); sl@0: READ_INI1A(tempStore, vertical_frames_per_traverse, verticalRate, iUtils); sl@0: READ_INI1A(tempStore, horizontal_frames_per_traverse, horizontalRate, iUtils); sl@0: sl@0: //Ensure the animation step sizes are sub-multiples of the frame dimensions sl@0: TImportScreenConfig::VerifyFramesPerTraverse(horizontalRate, aSurfaceSize.iWidth); sl@0: TImportScreenConfig::VerifyFramesPerTraverse(verticalRate, aSurfaceSize.iHeight); sl@0: sl@0: //Convert image size percentage into a pixel size sl@0: if(imageSize <= 0) sl@0: { sl@0: RDebug::Print(_L("image_size is zero or less, quitting\n")); sl@0: User::Exit(0); sl@0: } sl@0: else sl@0: { sl@0: //Scale the bitmap to the short screen dimension sl@0: if(aSurfaceSize.iWidth > aSurfaceSize.iHeight) sl@0: { sl@0: imageSize = imageSize*aSurfaceSize.iHeight/100; sl@0: } sl@0: else sl@0: { sl@0: imageSize = imageSize*aSurfaceSize.iWidth/100; sl@0: } sl@0: } sl@0: sl@0: iTestAnimation = CreateAnimationL(applicationType, TSize(imageSize,imageSize), sl@0: aSurfaceSize, multiBitmapAnimFile, aMode, sl@0: horizontalRate, verticalRate, aPixelFormat); sl@0: } sl@0: sl@0: sl@0: CTestAnimation* CTestSurfacedWindow::CreateAnimationL(TInt aAppType, const TSize& aAnimSize, const TSize& aSurfaceSize, sl@0: TPtrC& aBitmapFile, TDisplayMode aDisplayMode, sl@0: TInt aHorizontalRate, TInt aVerticalRate, sl@0: TPixelFormat aPixelFormat) sl@0: { sl@0: CTestAnimation* anim = 0; sl@0: switch(aAppType) sl@0: { sl@0: case EFbsBitmap: sl@0: { sl@0: anim = CCFbsBitmapAnimation::NewL(aDisplayMode, sl@0: aAnimSize, sl@0: aSurfaceSize, sl@0: aBitmapFile, sl@0: aHorizontalRate, sl@0: aVerticalRate, sl@0: aPixelFormat); sl@0: break; sl@0: } sl@0: sl@0: case EOpenVG: sl@0: { sl@0: anim = CVgAnimation::NewL(iTestWindow->Window(), sl@0: aDisplayMode, sl@0: aSurfaceSize, sl@0: aHorizontalRate, sl@0: aVerticalRate); sl@0: break; sl@0: } sl@0: case EOpenGLes: sl@0: { sl@0: anim = COpenGLAnimation::NewL(iTestWindow->Window(), sl@0: aDisplayMode, sl@0: aSurfaceSize, sl@0: aHorizontalRate, sl@0: aVerticalRate); sl@0: break; sl@0: } sl@0: sl@0: case EPerformance: sl@0: { sl@0: anim = CPerformanceAnimation::NewL(); sl@0: break; sl@0: } sl@0: case ENoApp: sl@0: { sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: break; //Cannot reach the default, Lint warning removal purposes only sl@0: } sl@0: } sl@0: return anim; sl@0: } sl@0: sl@0: CArrayFixFlat* CTestSurfacedWindow::ImportWindowBitmapParamsL(const TDesC& tempStore, TInt aMultiBitmapUiFileSize, const TSize& aScreenSize) sl@0: { sl@0: TBuf temp; sl@0: TBuf tempStore1; sl@0: sl@0: CArrayFixFlat* loadsarects = new (ELeave) CArrayFixFlat(1); sl@0: sl@0: for(TInt i=0; iExtendL() = aRect; sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print(_L("Cannot determine rectangle dimensions from string: %s\n"), rectString.Ptr()); sl@0: RDebug::Print(_L("Undefined behavior may result\n")); sl@0: } sl@0: } sl@0: return loadsarects; sl@0: } sl@0: sl@0: CArrayFixFlat* CTestSurfacedWindow::ImportWindowSizeChangeParamsL(const TDesC& tempStore) sl@0: { sl@0: TBuf temp = tempStore; sl@0: CArrayFixFlat* intArray = new (ELeave) CArrayFixFlat(1); sl@0: sl@0: TInt windowSizeValues; sl@0: TBuf tempStore1; sl@0: sl@0: READ_INI1A(tempStore, window_size_values, windowSizeValues, iUtils); sl@0: sl@0: TInt windowSize; sl@0: for(TInt i=1; iExtendL() = windowSize; sl@0: } sl@0: sl@0: return intArray; sl@0: } sl@0: sl@0: CArrayFixFlat* CTestSurfacedWindow::ImportWindowPositionChangeParamsL(const TDesC& tempStore) sl@0: { sl@0: TBuf temp = tempStore; sl@0: CArrayFixFlat* intArray = new (ELeave) CArrayFixFlat(1); sl@0: sl@0: TInt windowPositionValues; sl@0: TBuf tempStore1; sl@0: sl@0: READ_INI1A(tempStore, window_position_values, windowPositionValues, iUtils); sl@0: sl@0: for(TInt i=1; iExtendL() = point.iX; sl@0: intArray->ExtendL() = point.iY; sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print(_L("Cannot determine point dimensions from string: %s\n"), windowPosition.Ptr()); sl@0: RDebug::Print(_L("Undefined behavior may result\n")); sl@0: } sl@0: } sl@0: return intArray; sl@0: } sl@0: sl@0: void CTestSurfacedWindow::CreateSurfaceManager() sl@0: { sl@0: RDebug::Print(_L("Create Surface Manager\n")); sl@0: sl@0: TInt ret; sl@0: sl@0: RDebug::Print(_L("Loading the device driver and Opening the Logical Channel\n")); sl@0: ret = iSurfaceManager.Open(); sl@0: if(ret==KErrNone) sl@0: { sl@0: RDebug::Print(_L("Surface manager opened ok\n")); sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print(_L("Error opening surface manager\n")); sl@0: } sl@0: } sl@0: sl@0: void CTestSurfacedWindow::DestroySurfaceManager() sl@0: { sl@0: RDebug::Print(_L("Close the Logical Channel\n")); sl@0: iSurfaceManager.Close(); sl@0: } sl@0: sl@0: void CTestSurfacedWindow::DestroySurface() sl@0: { sl@0: // Remove SurfaceId entry from surface array sl@0: iPseudoAppShared.RemoveSurfaceIdEntry(iScreenNo, iWindowNumber); sl@0: sl@0: RDebug::Print(_L("Closing surface\n")); sl@0: TInt ret = iSurfaceManager.CloseSurface(iSurfaceId); sl@0: sl@0: if(ret!=KErrNone) sl@0: { sl@0: RDebug::Print(_L("Surface failed to close\n")); sl@0: } sl@0: } sl@0: sl@0: void CTestSurfacedWindow::BuildDimensionArrayL(const TSize& aScreenSize, TInt aFrameDuration, TInt aWindowChangeGeometry, TInt aWindowChangeBehavior) sl@0: { sl@0: TInt indexX; sl@0: TInt indexY; sl@0: sl@0: iLoadsaParameters = new (ELeave) CArrayFixFlat(1); sl@0: sl@0: TDrawParameters drawParams; sl@0: sl@0: for(TInt i=0; iCount()))/aFrameDuration]; sl@0: drawParams.iWindowSize = TSize( (aScreenSize.iWidth*drawParams.iBitmapScale)/100, sl@0: (aScreenSize.iHeight*drawParams.iBitmapScale)/100 ); sl@0: break; sl@0: } sl@0: case EWindowPosition: sl@0: { sl@0: indexX = 2*((((i*(iPositionArray->Count()/2))))/aFrameDuration); sl@0: indexY = 2*((((i*(iPositionArray->Count()/2))))/aFrameDuration) + 1; sl@0: drawParams.iWindowPos.iX = (aScreenSize.iWidth * (*iPositionArray)[indexX])/100; sl@0: drawParams.iWindowPos.iY = (aScreenSize.iHeight * (*iPositionArray)[indexY])/100; sl@0: break; sl@0: } sl@0: case EWindowPositionAndSize: sl@0: { sl@0: drawParams.iBitmapScale = (*iSizeArray)[ (i*(iSizeArray->Count()))/aFrameDuration]; sl@0: drawParams.iWindowSize = TSize( (aScreenSize.iWidth*drawParams.iBitmapScale)/100, sl@0: (aScreenSize.iHeight*drawParams.iBitmapScale)/100 ); sl@0: sl@0: indexX = 2*((((i*(iPositionArray->Count()/2))))/aFrameDuration); sl@0: indexY = 2*((((i*(iPositionArray->Count()/2))))/aFrameDuration) + 1; sl@0: drawParams.iWindowPos.iX = (aScreenSize.iWidth * (*iPositionArray)[indexX])/100; sl@0: drawParams.iWindowPos.iY = (aScreenSize.iHeight * (*iPositionArray)[indexY])/100; sl@0: break; sl@0: } sl@0: case EWindowPositionAndSizeWithOpacity: sl@0: { sl@0: ParamChangeOpacity(i, aFrameDuration, drawParams); sl@0: drawParams.iBitmapScale = (*iSizeArray)[ (i*(iSizeArray->Count()))/aFrameDuration]; sl@0: drawParams.iWindowSize = TSize( (aScreenSize.iWidth*drawParams.iBitmapScale)/100, sl@0: (aScreenSize.iHeight*drawParams.iBitmapScale)/100 ); sl@0: sl@0: indexX = 2*((((i*(iPositionArray->Count()/2))))/aFrameDuration); sl@0: indexY = 2*((((i*(iPositionArray->Count()/2))))/aFrameDuration) + 1; sl@0: drawParams.iWindowPos.iX = (aScreenSize.iWidth * (*iPositionArray)[indexX])/100; sl@0: drawParams.iWindowPos.iY = (aScreenSize.iHeight * (*iPositionArray)[indexY])/100; sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: break; sl@0: } sl@0: sl@0: case ENoChange: sl@0: default: sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: sl@0: iLoadsaParameters->ExtendL() = drawParams; sl@0: } sl@0: } sl@0: sl@0: void CTestSurfacedWindow::ParamChangeCyclicPosition(TDrawParameters& aDrawParams, TInt aFrameCounter, TInt aFrameDuration, const TSize& aScreenSize) sl@0: { sl@0: TInt increment = (aScreenSize.iHeight * (100 - (*iSizeArray)[0]) + sl@0: aScreenSize.iWidth * (100 - (*iSizeArray)[0]))/(aFrameDuration * 25); sl@0: sl@0: if(aFrameCounter < (aFrameDuration/2 - 1)) sl@0: { sl@0: CalcNewWindowLocation(aScreenSize, increment, 1, aDrawParams); sl@0: } sl@0: else if(aFrameCounter != (aFrameDuration - 1)) sl@0: { sl@0: CalcNewWindowLocation(aScreenSize, increment, -1, aDrawParams); sl@0: } sl@0: else sl@0: { sl@0: aDrawParams.iWindowPos.iY -= increment; sl@0: } sl@0: } sl@0: sl@0: void CTestSurfacedWindow::ParamChangeCyclicPositionAndSize(TDrawParameters& aDrawParams, TInt aFrameCounter, TInt aFrameDuration, const TSize& aScreenSize) sl@0: { sl@0: TInt incrementX = 2*aScreenSize.iWidth/aFrameDuration; sl@0: TInt incrementY = 2*aScreenSize.iHeight/aFrameDuration; sl@0: TSize incrementSize(incrementX, incrementY); sl@0: TInt eigth = aFrameDuration/8; sl@0: sl@0: if(aFrameCounter < eigth) sl@0: { sl@0: aDrawParams.iWindowSize -= incrementSize; sl@0: aDrawParams.iWindowPos.iY += incrementY; sl@0: aDrawParams.iWindowPos.iX = 0; sl@0: } sl@0: else if( (aFrameCounter >= eigth) && (aFrameCounter < 2*eigth) ) sl@0: { sl@0: aDrawParams.iWindowSize -= incrementSize; sl@0: aDrawParams.iWindowPos.iY += incrementY; sl@0: aDrawParams.iWindowPos.iX += 2*incrementX; sl@0: } sl@0: else if( (aFrameCounter >= 2*eigth) && (aFrameCounter < 3*eigth) ) sl@0: { sl@0: aDrawParams.iWindowSize -= incrementSize; sl@0: aDrawParams.iWindowPos.iY -= 2*incrementY; sl@0: aDrawParams.iWindowPos.iX += incrementX; sl@0: } sl@0: else if( (aFrameCounter >= 3*eigth) && (aFrameCounter < 4*eigth) ) sl@0: { sl@0: aDrawParams.iWindowSize -= incrementSize; sl@0: aDrawParams.iWindowPos.iY = 0; sl@0: aDrawParams.iWindowPos.iX -= 3*incrementX; sl@0: } sl@0: else if( (aFrameCounter >= 4*eigth) && (aFrameCounter < 5*eigth) ) sl@0: { sl@0: aDrawParams.iWindowSize += incrementSize; sl@0: aDrawParams.iWindowPos.iY = 0; sl@0: aDrawParams.iWindowPos.iX += 3*incrementX; sl@0: } sl@0: else if( (aFrameCounter >= 5*eigth) && (aFrameCounter < 6*eigth) ) sl@0: { sl@0: aDrawParams.iWindowSize += incrementSize; sl@0: aDrawParams.iWindowPos.iY += 2*incrementY; sl@0: aDrawParams.iWindowPos.iX -= incrementX; sl@0: } sl@0: else if( (aFrameCounter >= 6*eigth) && (aFrameCounter < 7*eigth) ) sl@0: { sl@0: aDrawParams.iWindowSize += incrementSize; sl@0: aDrawParams.iWindowPos.iY -= incrementY; sl@0: aDrawParams.iWindowPos.iX -= 2*incrementX; sl@0: } sl@0: else sl@0: { sl@0: aDrawParams.iWindowSize += incrementSize; sl@0: aDrawParams.iWindowPos.iY -= incrementY; sl@0: aDrawParams.iWindowPos.iX = 0; sl@0: } sl@0: } sl@0: sl@0: void CTestSurfacedWindow::ParamChangeOpacity(TInt aFrameCounter, TInt aFrameDuration, TDrawParameters& aDrawParams) sl@0: { sl@0: TInt alpha = (512 * aFrameCounter)/(aFrameDuration); sl@0: if(alpha > 255) sl@0: { sl@0: alpha = 511 - alpha; sl@0: } sl@0: sl@0: aDrawParams.iBitmapAlpha = alpha; sl@0: } sl@0: sl@0: void CTestSurfacedWindow::CalcNewWindowLocation(const TSize& aScreensize, TInt aIncrement, TInt aDirection,TDrawParameters& aDrawParams) sl@0: { sl@0: if(aDrawParams.iWindowPos.iX <= 0) sl@0: { sl@0: aDrawParams.iWindowPos.iX = 0; sl@0: aDrawParams.iWindowPos.iY += aIncrement*aDirection; sl@0: } sl@0: if((aDrawParams.iWindowPos.iY + aDrawParams.iWindowSize.iHeight) >= aScreensize.iHeight) sl@0: { sl@0: aDrawParams.iWindowPos.iY = aScreensize.iHeight - aDrawParams.iWindowSize.iHeight; sl@0: aDrawParams.iWindowPos.iX += aIncrement*aDirection; sl@0: } sl@0: if((aDrawParams.iWindowPos.iX + aDrawParams.iWindowSize.iWidth) >= aScreensize.iWidth) sl@0: { sl@0: aDrawParams.iWindowPos.iX = aScreensize.iWidth - aDrawParams.iWindowSize.iWidth; sl@0: aDrawParams.iWindowPos.iY -= aIncrement*aDirection; sl@0: } sl@0: if(aDrawParams.iWindowPos.iY <= 0) sl@0: { sl@0: aDrawParams.iWindowPos.iY = 0; sl@0: aDrawParams.iWindowPos.iX -= aIncrement*aDirection; sl@0: } sl@0: }