Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 #include <limits.h> //UINT_MAX
26 #include "t_testsurfacerasterizer.h"
28 EXPORT_C CTestSurfaceRasterizer* CTestSurfaceRasterizer::NewL(const TSurfaceId& aSurfaceId, TInt aSurfaceScreenNumber, RSurfaceManager* aSurfaceManager)
30 RDebug::Print(_L("Creating CTestSurfaceRasterizer class\n"));
31 CTestSurfaceRasterizer* self = new (ELeave) CTestSurfaceRasterizer();
32 CleanupStack::PushL(self);
33 TInt ret = self->ConstructL(aSurfaceId, aSurfaceScreenNumber, aSurfaceManager);
34 CleanupStack::Pop(); // self;
46 TBool CTestSurfaceRasterizer::ConstructL(const TSurfaceId& aSurfaceId, TInt aSurfaceScreenNumber, RSurfaceManager* aSurfaceManager)
48 RDebug::Print(_L("Constructing CTestSurfaceRasterizer\n"));
50 iSurfaceId = aSurfaceId;
52 iSurfaceScreenNumber = aSurfaceScreenNumber;
54 iSurfaceManager = aSurfaceManager;
56 TInt err = iSurfaceManager->MapSurface(iSurfaceId, iChunk);
60 RDebug::Print(_L("Error mapping to surface\n"));
66 iSurfaceManager->SurfaceInfo(iSurfaceId, iInfoBuf);
71 EXPORT_C CTestSurfaceRasterizer::CTestSurfaceRasterizer()
75 CTestSurfaceRasterizer::~CTestSurfaceRasterizer()
80 EXPORT_C void CTestSurfaceRasterizer::DrawRect(TUint32* aBuffer, SurfaceDetails& aSurfDetails)
82 //Send the fullscreen bitmap to the test rasterizer
84 RSurfaceManager::TSurfaceInfoV01& info = iInfoBuf();
86 aSurfDetails.aSurfaceId = iSurfaceId;
87 aSurfDetails.aSurfaceSize = info.iSize;
88 aSurfDetails.aBufferNumber = iSurfaceCurrentBuffer;
91 TInt offsetToCurrentBuffer;
92 TInt err = iSurfaceManager->GetBufferOffset(iSurfaceId, iSurfaceCurrentBuffer, offsetToCurrentBuffer);
95 RDebug::Print(_L("Could not open buffer number\n"));
98 TUint32* surfaceBufferPtr = reinterpret_cast<TUint32*>(iChunk.Base() + offsetToCurrentBuffer);
100 TInt noOfBytes = (info.iStride * info.iSize.iHeight);
101 Mem::Move(surfaceBufferPtr, aBuffer, noOfBytes);
103 iSurfaceCurrentBuffer++;
104 if(iSurfaceCurrentBuffer == info.iBuffers)
106 iSurfaceCurrentBuffer = 0;
110 EXPORT_C void CTestSurfaceRasterizer::PerfTestL(TInt aFrameNumber)
112 //Send the fullscreen bitmap to the test rasterizer
114 RSurfaceManager aManager;
115 User::LeaveIfError(aManager.Open());
117 TInt err = aManager.OpenSurface(iSurfaceId);
120 RDebug::Print(_L("Error opening a surface\n"));
124 err = aManager.MapSurface(iSurfaceId, aChunk);
127 RDebug::Print(_L("Error mapping to surface\n"));
131 RSurfaceManager::TInfoBuf InfoBuf;
132 RSurfaceManager::TSurfaceInfoV01& info = InfoBuf();
135 aManager.SurfaceInfo(iSurfaceId, InfoBuf);
137 TInt noOfPixels = (info.iSize.iWidth * info.iSize.iHeight);
139 TInt offsetToCurrentBuffer;
140 err = iSurfaceManager->GetBufferOffset(iSurfaceId, iSurfaceCurrentBuffer,offsetToCurrentBuffer);
143 RDebug::Print(_L("Could not open buffer number\n"));
146 TUint32* surfaceBufferPtr = reinterpret_cast<TUint32*>(aChunk.Base() + offsetToCurrentBuffer);
148 if(aFrameNumber < info.iBuffers)
150 TInt sector = aFrameNumber % info.iBuffers;
151 TInt offset = (noOfPixels * sector)/info.iBuffers;
152 Mem::Fill((surfaceBufferPtr + offset), noOfPixels, TChar(0xFF));
158 TRect(0, 0, info.iSize.iWidth, info.iSize.iHeight)
161 RRegion region(1, rc);
162 RSurfaceUpdateSession aSurfaceUpdateSession;
164 err = aSurfaceUpdateSession.Connect();
167 RDebug::Print(_L("error in connecting surface update session\n"));
171 TInt ret = aSurfaceUpdateSession.SubmitUpdate(KAllScreens, iSurfaceId, iSurfaceCurrentBuffer, ®ion);
173 RDebug::Print(_L("Frame %d done\n"), aFrameNumber);
177 RDebug::Print(_L("Error submitting update request\n"));
180 iSurfaceCurrentBuffer++;
181 if(iSurfaceCurrentBuffer == info.iBuffers)
183 iSurfaceCurrentBuffer = 0;
188 err = aManager.CloseSurface(iSurfaceId);
191 RDebug::Print(_L("Error closing the surface\n"));