00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <GDI.H>
00033 #include <coemain.h>
00034 #include <EIKENV.H>
00035 #include "GfxBitBlitView.h"
00036 #include "GfxVideoPlayer.h"
00037 #include "hal.h"
00038 #include "CGfxTimer.h"
00039
00040 const TInt KNumberOfTests = 12;
00041 const TInt KNumOfBlits = 1000;
00042 const TTimeIntervalMicroSeconds32 KProfileYieldInMicroSeconds = 1000000/20;
00043
00044 _LIT(KLogFileDir, "c:\\data\\other\\");
00045 _LIT(KLogFileName, "c:\\data\\other\\bitblit.txt");
00046
00047
00048
00049
00050
00051
00052
00053
00054 CGfxBitBlitView* CGfxBitBlitView::NewL( const TRect& aRect )
00055 {
00056 CGfxBitBlitView* self = CGfxBitBlitView::NewLC( aRect );
00057 CleanupStack::Pop( self );
00058 return self;
00059 }
00060
00061
00062
00063
00064
00065
00066 CGfxBitBlitView* CGfxBitBlitView::NewLC( const TRect& aRect )
00067 {
00068 CGfxBitBlitView* self = new ( ELeave ) CGfxBitBlitView;
00069 CleanupStack::PushL( self );
00070 self->ConstructL( aRect );
00071 return self;
00072 }
00073
00074
00075
00076
00077
00078
00079 void CGfxBitBlitView::ConstructL( const TRect& aRect )
00080 {
00081
00082 CreateWindowL();
00083
00084
00085 SetRect( aRect );
00086
00087 iTimer = new(ELeave) CGfxTimer(*this, 0);
00088 iTimer->ConstructL();
00089
00090
00091 ActivateL();
00092 }
00093
00094
00095
00096
00097
00098
00099 CGfxBitBlitView::CGfxBitBlitView()
00100 {
00101 }
00102
00103
00104
00105
00106
00107
00108
00109 CGfxBitBlitView::~CGfxBitBlitView()
00110 {
00111 delete iTimer;
00112 CloseLogFile();
00113 }
00114
00115
00116
00117
00118
00119
00120
00121 void CGfxBitBlitView::Draw( const TRect& ) const
00122 {
00123
00124 CWindowGc& gc = SystemGc();
00125
00126
00127 TRect drawRect( Rect());
00128
00129
00130 gc.Clear( drawRect );
00131 }
00132
00133
00134
00135
00136
00137
00138 void CGfxBitBlitView::SizeChanged()
00139 {
00140 DrawNow();
00141 }
00142
00143
00144 CFbsBitmap* BitmapForDepthL(TDisplayMode aDisplayMode, TSize aSize)
00145 {
00146 CFbsBitmap* offScreenBitmap = new (ELeave) CFbsBitmap();
00147 CleanupStack::PushL(offScreenBitmap);
00148 User::LeaveIfError(offScreenBitmap->Create(aSize,aDisplayMode));
00149
00150
00151 CGraphicsContext* bitmapContext=NULL;
00152 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(offScreenBitmap);
00153 CleanupStack::PushL(bitmapDevice);
00154 User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
00155 CleanupStack::PushL(bitmapContext);
00156
00157 bitmapContext->SetBrushColor(KRgbRed);
00158 bitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
00159
00160
00161 CleanupStack::PopAndDestroy(2);
00162 CleanupStack::Pop(offScreenBitmap);
00163 return offScreenBitmap;
00164 }
00165
00166 void CGfxBitBlitView::StartL()
00167 {
00168 iCurrentTest = 0;
00169 CreateLogFileL();
00170 iTimer->Start(KProfileYieldInMicroSeconds);
00171 }
00172
00173 void CGfxBitBlitView::GfxTimerFiredL(TInt )
00174 {
00175 ProfileBitBlitL(iCurrentTest);
00176
00177 iCurrentTest++;
00178 if(iCurrentTest<KNumberOfTests)
00179 {
00180 iTimer->Start(KProfileYieldInMicroSeconds);
00181 }
00182 else
00183 {
00184 iEikonEnv->AlertWin(_L("Log Complete"), KLogFileName);
00185 CloseLogFile();
00186 }
00187 }
00188
00189 void CGfxBitBlitView::CreateLogFileL()
00190 {
00191 const TDisplayMode defaultDisplayMode = iEikonEnv->DefaultDisplayMode();
00192
00193 (void)iEikonEnv->FsSession().MkDirAll(KLogFileDir);
00194 User::LeaveIfError(iLogFile.Replace(iEikonEnv->FsSession(), KLogFileName,EFileWrite ));
00195 User::LeaveIfError( iLogFile.Write(_L8("Bitblit test results\n")) );
00196 TBuf8<255> out;
00197 out.Format(_L8("Default Display Mode %D\n\n"), static_cast<TInt>(defaultDisplayMode) );
00198 User::LeaveIfError(iLogFile.Write(out));
00199 out.Format(_L8("Width: %D, Height: %D,\n\n"), Size().iWidth, Size().iHeight);
00200 iLogFile.Write(out);
00201
00202 TInt nanokernel_tick_period;
00203 HAL::Get(HAL::ENanoTickPeriod, nanokernel_tick_period);
00204 out.Format(_L8("Nano tick period: %D\n\n"), nanokernel_tick_period);
00205 User::LeaveIfError(iLogFile.Write(out));;
00206
00207 iLogFile.Flush();
00208 }
00209 void CGfxBitBlitView::CloseLogFile()
00210 {
00211 iLogFile.Close();
00212 }
00213
00214 void CGfxBitBlitView::ProfileBitBlitL(TInt aTestNo)
00215 {
00216
00217
00218 TDisplayMode tests[KNumberOfTests]={
00220 EGray2,
00222 EGray4,
00224 EGray16,
00226 EGray256,
00228 EColor16,
00230 EColor256,
00232 EColor64K,
00234 EColor16M,
00236 ERgb,
00238 EColor4K,
00240 EColor16MU,
00242 EColor16MA};
00243
00244
00245 TBuf8<255> out;
00246
00247 CFbsBitmap* bmp = NULL;
00248 TRAPD(err, bmp=BitmapForDepthL(tests[aTestNo], Size()));
00249 if(err)
00250 {
00251 RDebug::Print(_L("BITBLIT: ERROR, %D"), err);
00252 _LIT8(KFormat, "BITBLIT: %D ERROR, %D\n\r");
00253 out.Format(KFormat, aTestNo, err);
00254 }
00255 else
00256 {
00257 CleanupStack::PushL(bmp);
00258 TUint32 startTick = User::NTickCount();
00259
00260 ActivateGc();
00261 CWindowGc& gc = SystemGc();
00262
00263 for(TInt l=0; l<KNumOfBlits; l++)
00264 {
00265 gc.BitBlt(TPoint(0,0), bmp);
00266 }
00267
00268 DeactivateGc();
00269
00270 TUint32 endTick = User::NTickCount();
00271 TInt mils = endTick-startTick;
00272 RDebug::Print(_L("BITBLIT: %D, %D"), aTestNo, mils);
00273 _LIT8(KFormat, "BITBLIT: %D, %D\n\r");
00274 out.Format(KFormat, aTestNo, mils);
00275 CleanupStack::PopAndDestroy(bmp);
00276 }
00277
00278 User::LeaveIfError(iLogFile.Write(out));
00279 iLogFile.Flush();
00280 }
00281
00282 void CGfxBitBlitView::StopL()
00283 {
00284 iTimer->Cancel();
00285 }
00286