os/graphics/egl/egltest/src/egltest_benchmark_sgimage.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @test
    19 */
    20 
    21 #include <test/tefunit.h> // for ASSERT macros
    22 #include <e32msgqueue.h>
    23 
    24 #include <test/tprofiler.h>
    25 #include <test/egltestcommonprocess.h>
    26 #include <test/egltestcommonconversion.h>
    27 #include <test/egltestcommoninisettings.h>
    28 
    29 #include "egltest_benchmark_sgimage.h"
    30 
    31 //In general, there is no checking of the returned errors for the API we will be profiling
    32 //we assume that the basic operations will just work, as they have been tested in many other places
    33 //we don’t want error checking to interfere with the profiling itself 
    34 //to enable error checking, uncomment the macro below 
    35 //#define ENABLE_CHECKING_WHILST_PROFILING    1 
    36 
    37 _LIT(KBenchmarkSection, "Benchmark");
    38 
    39 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    40 const TInt KBenchmarkDrawImageThreshold = 5; //semi-arbitrary number which signifies deviation in percentage between min and max number of image drawing
    41 #endif
    42 
    43 
    44 #define ENABLE_BENCHMARK_VERBOSE_LOGGING    1
    45 
    46 //data will be used to cleanup VgImages if leaving occurs
    47 NONSHARABLE_CLASS(CVgImageDeleteData) : public CBase
    48     {
    49 public:
    50     CVgImageDeleteData(VGImage*& aVgImages, TInt aNumVgImages) :
    51         iVgImages(aVgImages),
    52         iNumVgImages(aNumVgImages)
    53         {
    54         }
    55     ~CVgImageDeleteData();
    56 private:    
    57     VGImage*& iVgImages;//the ownership will be transferred and cleanup function will destroy this array
    58     TInt iNumVgImages;
    59     };
    60 
    61 CVgImageDeleteData::~CVgImageDeleteData()
    62     {
    63     if(iVgImages)
    64         {
    65         for(TInt count=iNumVgImages-1; count >= 0; --count)
    66             {
    67             vgDestroyImage(iVgImages[count]);
    68             }
    69         delete [] iVgImages;
    70         }
    71     }
    72 
    73 //data will be used to cleanup RSgImages if leaving occurs
    74 NONSHARABLE_CLASS(CSgImageDeleteData) : public CBase
    75     {
    76 public:
    77     CSgImageDeleteData(RSgImage*& aSgImages, TInt aNumSgImages) :
    78         iSgImages(aSgImages),
    79         iNumSgImages(aNumSgImages)
    80         {
    81         }
    82     ~CSgImageDeleteData();
    83 private:    
    84     RSgImage*& iSgImages;//the ownership will be transferred and cleanup function will destroy this array
    85     TInt iNumSgImages;
    86     };
    87 
    88 CSgImageDeleteData::~CSgImageDeleteData()
    89     {
    90     if(iSgImages)
    91         {
    92         for(TInt count=iNumSgImages-1; count >= 0; --count)
    93             {
    94             iSgImages[count].Close();
    95             }
    96         delete [] iSgImages;
    97         }
    98     }
    99 
   100 //data will be used to cleanup EGLImages if leaving occurs
   101 NONSHARABLE_CLASS(CEglImageDeleteData) : public CBase
   102     {
   103 public:
   104     CEglImageDeleteData(CEglTestStep& aImageBaseStep, 
   105             EGLImageKHR*& aEglImages, EGLDisplay& aDisplay, TInt aNumEglImages) : 
   106         iImageBaseStep(aImageBaseStep), iEglImages(aEglImages), iDisplay(aDisplay), iNumEglImages(aNumEglImages)
   107         {
   108         }
   109     ~CEglImageDeleteData();
   110 private:    
   111 	CEglTestStep& iImageBaseStep; //not owned by this object
   112     EGLImageKHR*& iEglImages; //the ownership will be transferred and cleanup function will destroy this array
   113     EGLDisplay iDisplay; //not owned by this object
   114     TInt iNumEglImages;
   115     };
   116 
   117 CEglImageDeleteData::~CEglImageDeleteData()
   118     {
   119     if(iEglImages)
   120         {
   121         CTestEglSession* eglSession = iImageBaseStep.GetEglSess(); 
   122         for(TInt count=iNumEglImages-1; count >= 0; --count)
   123             {    
   124             eglSession->DestroyEGLImage( iDisplay, iEglImages[count]);
   125             }
   126         delete [] iEglImages;
   127         }
   128     }
   129 
   130 CEglTest_Benchmark_Base::~CEglTest_Benchmark_Base()
   131     {
   132     delete iProfiler;
   133     }
   134 
   135 TVerdict CEglTest_Benchmark_Base::doTestStepPreambleL()
   136     {
   137     TVerdict verdict = CEglTestStep::doTestStepPreambleL();
   138     iProfiler = CTProfiler::NewL(*this);
   139     //read all parameters from config
   140     CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
   141     CleanupStack::PushL(iniParser);
   142     iNumIterations = iniParser->GetNumberOfIterations(KBenchmarkSection);
   143     if(!iNumIterations)
   144         {
   145         ERR_PRINTF1(_L("The number iterations is not specified in INI file, the test will not be executed!"));
   146         User::Leave(KErrArgument);      
   147         }
   148     
   149     iImageSize = iniParser->GetImageSize(KBenchmarkSection);
   150     if(iImageSize == TSize(0,0))
   151         {
   152         ERR_PRINTF1(_L("The image size whether is not specified in INI file or is TSize(0,0), the test will not be executed!"));
   153         User::Leave(KErrArgument);      
   154         }
   155     iPixelFormat = iniParser->GetPixelFormat(KBenchmarkSection, 0);
   156     if(iPixelFormat == EUidPixelFormatUnknown)
   157         {
   158         ERR_PRINTF1(_L("The image pixel format is not specified in INI file, the test will not be executed!"));
   159         User::Leave(KErrArgument);      
   160         }
   161     CleanupStack::PopAndDestroy(iniParser);
   162     INFO_PRINTF5(_L("**** The test will be run in following configuration: number of iterations %d, image size (%d, %d), image pixel format 0X%X"), iNumIterations, iImageSize.iWidth, iImageSize.iHeight, iPixelFormat);
   163     return verdict;
   164     }
   165 
   166 TVerdict CEglTest_Benchmark_Base::doTestStepPostambleL()
   167     {
   168     delete iProfiler; //we need to delete here to keep happy heap checking in the base class 
   169     iProfiler = NULL;
   170     return CEglTestStep::doTestStepPostambleL();
   171     }
   172 
   173 
   174 
   175 /**
   176 @SYMTestCaseID GRAPHICS-EGL-0434
   177 
   178 @SYMTestPriority 1
   179 
   180 @SYMPREQ 2637
   181 
   182 @SYMTestCaseDesc
   183     Performance test - Creating and destroying VGImage
   184 @SYMTestActions
   185 Creating regular VGImage
   186 Init EGL, create context and surface
   187 For i = 0 to N
   188     Start timer
   189     Create VGImage[i] with size: 50x50 and format:  VG_sARGB_8888_PRE
   190     Stop timer and record time
   191 End loop
   192 Record average time of creating VGImage
   193 
   194 Closing regular VGImage
   195 For i = N to 0
   196     Start timer
   197     Destroy VGImage[i]
   198     Stop timer and record time
   199 End loop
   200 Record average time of destroying VGImage
   201 Destroy context, surface and terminate EGL
   202 
   203 Creating VGImage from uninitialized RSgImage
   204 Open RSgDriver
   205 Construct TSgImageInfo object with
   206 •   Size: 50x50
   207 •   PixelFormat: ESgPixelFormatARGB_8888_PRE
   208 •   Usage: ESgUsageBitOpenVgImage;
   209 
   210 For i = 0 to N
   211     Start timer
   212     Create RSgImage[i] with arguments TSgImageInfo but without initialized data
   213     Stop timer and record time
   214 
   215     Start timer
   216     Create an EGLImage[i] from the RSgImage[i]
   217     Stop timer and record time
   218 
   219     Start timer
   220     Create a VGImage[i] from the EGLImage[i]
   221     Stop timer and record time
   222 
   223     Record total time of  RSgImage[i], EGLImage[i] and VGImage[i] creation
   224 End loop
   225 Record average creation time of RSgImage, EGLImage, VGImage and the whole RSgImage-EGLImage-VGImage chain
   226 
   227 Destroying VGImage from RSgImage
   228 For i = N to 0
   229     Start timer
   230     Close VGImage[i]
   231     Stop timer and record time
   232 
   233     Start timer
   234     Close EGLImage[i]
   235     Stop timer and record time
   236 
   237     Start timer
   238     Close RSgImage[i]
   239     Stop timer and record time
   240 
   241     Record total time for closing VGImage[i], EGLImage[i] and RSgImage[i]
   242 End loop
   243 Record average closing time of RSgImage, EGLImage, VGImage, and the whole 
   244 VGImage-EGLImage-RSgImage chain
   245 
   246 Creating VGImage from initialized RSgImage
   247 For i = 0 to N
   248     Start timer
   249     Create RSgImage[i] with arguments TSgImageInfo a stride of 200 and a  pointer to a 
   250     data array of size 10000 bytes
   251     Stop timer and record time
   252 
   253     Start timer
   254     Create an EGLImage[i] from the RSgImage[i]
   255     Stop timer and record time
   256 
   257     Start timer
   258     Create a VGImage[i] from the EGLImage[i]
   259     Stop timer and record time
   260 
   261     Record total time for RSgImage[i], EGLImage[i] and VGImage[i] creation
   262 End loop
   263 Record average creation time of RSgImage, EGLImage, VGImage and the whole 
   264 RSgImage-EGLImage-VGImage chain
   265 Close all VGImages, EGLImages and RSgImages
   266 Close RSgDriver
   267 
   268 @SYMTestExpectedResults
   269 The creation of RSgImage, EGLImage and VGImage must return no error. 
   270 The average time shall be made available in an easy-to-use format for further 
   271 analysis and comparison.
   272 */
   273 TVerdict CEglTest_Benchmark_CreateCloseImage::doTestStepL()
   274     {
   275     SetTestStepID(_L("GRAPHICS-EGL-0434"));
   276     INFO_PRINTF1(_L("CEglTest_Benchmark_CreateCloseImage::doTestStepL"));
   277 
   278 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   279 	INFO_PRINTF1(_L("CEglTest_Benchmark_CreateCloseImage can only be run with SgImage-Lite"));
   280 #else
   281     TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KVG_KHR_EGL_image | KEGL_KHR_image_pixmap);
   282     if(!ret)
   283         {
   284         // The extension is not supported
   285         RecordTestResultL();
   286         CloseTMSGraphicsStep();
   287         return TestStepResult();
   288         }
   289  
   290     ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
   291     GetDisplayL();
   292     CreateEglSessionL();
   293     iEglSess->InitializeL();
   294     iEglSess->OpenSgDriverL();
   295  //----create pixmap and make context curent
   296     TSgImageInfo imageInfo;
   297     imageInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
   298     imageInfo.iPixelFormat = iPixelFormat;
   299     imageInfo.iSizeInPixels = iImageSize;
   300     //create a dummy surface and context for the purpose of enabling use of VG
   301     iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, CTestEglSession::EResourceCloseSgImageLate);
   302 
   303     //Creating regular VGImages
   304     //Create an array of VGImages and push them into cleanup stack
   305     //vgImageDeleteData takes ownership of the VGImages array. 
   306     //If leaving occurs or this object is destroyed from the cleanup stack 
   307     //it will delete all images and then the array
   308     VGImageFormat vgPixelFormat = EglTestConversion::PixelFormatToVgFormat(iPixelFormat);
   309     VGImage* vgImages = NULL;
   310     CVgImageDeleteData* vgImageDeleteData = new (ELeave) CVgImageDeleteData(vgImages, iNumIterations);
   311     CleanupStack::PushL(vgImageDeleteData);    
   312     vgImages = new (ELeave)VGImage[iNumIterations];
   313     //-------   start profiling
   314     iProfiler->InitResults();
   315     for(TInt count=iNumIterations - 1; count >= 0; --count)
   316         {
   317         //we will use VG_IMAGE_QUALITY_NONANTIALIASED flag to avoid OpenVG making the quality improvements
   318         //at the expense of performance (for instance to create an extra buffer) 
   319         vgImages[count] = vgCreateImage(vgPixelFormat, iImageSize.iWidth, iImageSize.iHeight, VG_IMAGE_QUALITY_NONANTIALIASED);
   320         //we will check the images later, to avoid interfering with the profiler
   321         iProfiler->MarkResultSetL();
   322         }
   323     iProfiler->ResultsAnalysis(_L("Creating regular VGImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
   324     
   325     //check that we created all VgImages
   326     for(TInt count=iNumIterations - 1; count >= 0; --count)
   327         {
   328         ASSERT_VG_TRUE(vgImages[count] !=  VG_INVALID_HANDLE);
   329         }    
   330     //Closing regular VGImage
   331     iProfiler->InitResults();
   332     for(TInt count=iNumIterations-1; count >= 0; --count)
   333         {
   334         vgDestroyImage(vgImages[count]);
   335         iProfiler->MarkResultSetL();
   336         }
   337     iProfiler->ResultsAnalysis(_L("Closing regular VGImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
   338 
   339 //---  Creating VGImage from uninitialized RSgImage  
   340     //Create an array of SgImages and push them into cleanup stack
   341     //sgImageData takes ownership of the SgImages array. 
   342     //If leaving occurs or this object is destroyed from the cleanup stack 
   343     //it will delete all images and then the array
   344     imageInfo.iUsage = ESgUsageBitOpenVgImage;
   345     RSgImage* sgImages = NULL;
   346     CSgImageDeleteData* sgImageData = new (ELeave)CSgImageDeleteData(sgImages, iNumIterations);
   347     CleanupStack::PushL(sgImageData);    
   348     sgImages = new (ELeave) RSgImage[iNumIterations];
   349     
   350     iProfiler->InitResults();
   351     for(TInt count=iNumIterations-1; count >= 0; --count)
   352         {
   353         const TInt res = sgImages[count].Create(imageInfo, NULL);
   354 #ifdef ENABLE_CHECKING_WHILST_PROFILING
   355         TESTL(res == KErrNone);
   356 #endif
   357         iProfiler->MarkResultSetL();
   358         }
   359     iProfiler->ResultsAnalysis(_L("Creating uninitialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
   360     
   361     //check that we created all sgImages successfully
   362     for(TInt count=iNumIterations - 1; count >= 0; --count)
   363         {
   364         TESTL(!sgImages[count].IsNull());
   365         }    
   366     
   367     //Create an array of EglImages and push them into cleanup stack
   368     //eglImageDeleteData takes ownership of the EglImages array. 
   369     //If leaving occurs or this object is destroyed from the cleanup stack 
   370     //it will delete all images and then the array
   371     EGLImageKHR* eglImages = NULL;
   372     CEglImageDeleteData* eglImageDeleteData = new (ELeave)CEglImageDeleteData(*this, eglImages, iDisplay, iNumIterations); 
   373     CleanupStack::PushL(eglImageDeleteData);    
   374     eglImages = new (ELeave) EGLImageKHR[iNumIterations];
   375     
   376     iProfiler->InitResults();
   377     for(TInt count=iNumIterations-1; count >= 0; --count)
   378         {//we will use preserved flag as sgImage supposedly has some content
   379         eglImages[count]= iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImages[count],const_cast<EGLint *> (KEglImageAttribsPreservedTrue));
   380         iProfiler->MarkResultSetL();
   381         }
   382     iProfiler->ResultsAnalysis(_L("Creating EGLImage from uninitialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
   383 
   384     //check that we created all EglImages successfully
   385     for(TInt count=iNumIterations-1; count >= 0; --count)
   386         {
   387         ASSERT_EGL_TRUE(eglImages[count] != EGL_NO_IMAGE_KHR)
   388         }
   389     
   390     iProfiler->InitResults();
   391     for(TInt count=iNumIterations-1; count >= 0; --count)
   392         {
   393         vgImages[count] = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImages[count]);
   394         iProfiler->MarkResultSetL();
   395         }   
   396     iProfiler->ResultsAnalysis(_L("Creating VGImage from EGLImage, which in turn based on uninitialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
   397     
   398     //check that we created all sgImages successfully
   399     for(TInt count=iNumIterations-1; count >= 0; --count)
   400         {
   401         ASSERT_VG_TRUE(vgImages[count] != VG_INVALID_HANDLE);
   402         }
   403     
   404     //Destroying VGImage/EGLImage/RSgImages
   405     iProfiler->InitResults();
   406     for(TInt count=iNumIterations-1; count >= 0; --count)
   407         {
   408         vgDestroyImage(vgImages[count]);
   409         iProfiler->MarkResultSetL();
   410         }
   411     iProfiler->ResultsAnalysis(_L("Destroying VGImage which based on RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
   412     
   413     iProfiler->InitResults();
   414     for(TInt count=iNumIterations-1; count >= 0; --count)
   415         {
   416         const TBool res = iEglSess->DestroyEGLImage(iDisplay, eglImages[count]);
   417 #ifdef ENABLE_CHECKING_WHILST_PROFILING
   418         ASSERT_EGL_TRUE(res)
   419 #endif
   420         iProfiler->MarkResultSetL();
   421         }
   422     iProfiler->ResultsAnalysis(_L("Destroying EGLImage which in turn based on RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
   423     
   424     iProfiler->InitResults();
   425     for(TInt count=iNumIterations-1; count >= 0; --count)
   426         {
   427         sgImages[count].Close();
   428         iProfiler->MarkResultSetL();
   429         }   
   430     iProfiler->ResultsAnalysis(_L("Closing RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
   431     
   432     //Creating initialized VGImage from initialized RSgImage
   433     const TInt KDataStride = iImageSize.iWidth * EglTestConversion::BytePerPixel(iPixelFormat);
   434     const TInt KDataSizeInByte = KDataStride *  iImageSize.iHeight;
   435     TInt* data = new (ELeave) TInt[KDataSizeInByte];
   436     User::LeaveIfNull(data);
   437     CleanupStack::PushL(data);
   438     
   439     Mem::Fill(data, KDataSizeInByte / 2, 0xff);
   440     Mem::FillZ(data + KDataSizeInByte / 2, KDataSizeInByte / 2);
   441     
   442     iProfiler->InitResults();
   443     for(TInt count=iNumIterations-1; count >= 0; --count)
   444         {
   445         const TInt res = sgImages[count].Create(imageInfo, data, KDataStride);
   446 #ifdef ENABLE_CHECKING_WHILST_PROFILING
   447         TESTL(res == KErrNone);
   448 #endif
   449         iProfiler->MarkResultSetL();
   450         }
   451     iProfiler->ResultsAnalysis(_L("Creating initialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
   452     
   453     //check that we created all sgImages successfully
   454     for(TInt count=iNumIterations-1; count >= 0; --count)
   455         {
   456         TESTL(!sgImages[count].IsNull());
   457         }
   458     
   459     iProfiler->InitResults();
   460     for(TInt count=iNumIterations-1; count >= 0; --count)
   461         {//we will use preserved flag as sgImage supposedly has some content
   462         eglImages[count]= iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, 
   463                 &sgImages[count], const_cast<EGLint *> (KEglImageAttribsPreservedTrue));
   464         iProfiler->MarkResultSetL();
   465         }
   466     iProfiler->ResultsAnalysis(_L("Creating EGLImage from initialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
   467 
   468     //check that we created all EglImages successfully
   469     for(TInt count=iNumIterations-1; count >= 0; --count)
   470         {
   471         ASSERT_EGL_TRUE(eglImages[count] != EGL_NO_IMAGE_KHR)
   472         }
   473     
   474     iProfiler->InitResults();
   475     for(TInt count=iNumIterations-1; count >= 0; --count)
   476         {
   477         vgImages[count] = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImages[count]);
   478         iProfiler->MarkResultSetL();
   479         }   
   480     iProfiler->ResultsAnalysis(_L("Creating VGImage from EGLImage which in turn based on initialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
   481 
   482     //check that we created all VgImages successfully
   483     for(TInt count=iNumIterations-1; count >= 0; --count)
   484         {
   485         ASSERT_VG_TRUE(vgImages[count] != VG_INVALID_HANDLE);
   486         }
   487     
   488     CleanupStack::PopAndDestroy(data);    
   489     //Destroying VGImage/EGLImage/RSgImages
   490     //no need to profile as we have already done this before
   491     CleanupStack::PopAndDestroy(3, vgImageDeleteData);  // vgImageDeleteData, sgImageData, eglImageDeleteData  
   492     
   493     CleanAll();
   494 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   495     RecordTestResultL();
   496     CloseTMSGraphicsStep();
   497     return TestStepResult();
   498     }
   499 
   500 /**
   501 @SYMTestCaseID GRAPHICS-EGL-0435
   502 
   503 @SYMTestPriority 1
   504 
   505 @SYMPREQ 2637
   506 
   507 @SYMTestCaseDesc
   508     Performance test – Creating and destroying VGImage from an RSgImage via Open
   509 @SYMTestActions
   510 Environmental settings:
   511 •   Image Size: w50 h50
   512 •   Simulated Load: 0%
   513 •   Pixel format ESgPixelFormatARGB_8888_PRE
   514 •   Number of benchmark iteration: N
   515 
   516 The method of creation of the RSgImage is similar to the case taken from GRAPHICS-EGL-RSGIMAGE_LITE-0406
   517 
   518 From Process A:
   519 Open the RSgDriver
   520 Create an RSgImage
   521 Spawn a client process B, passing in the drawable ID of the RSgImage
   522 Wait for process B to exit
   523 
   524 From process B:
   525 Open RSgDriver
   526 For i = 0 to N
   527     Start timer
   528     Open RSgImage[i]
   529     Stop timer and record time
   530 
   531     Start timer
   532     Create an EGLImage[i] from the RSgImage[i]
   533     Stop timer and record time
   534 
   535     Start timer
   536     Create a VGImage[i] from the EGLImage[i]
   537     Stop timer and record time
   538 
   539     Record total time of RSgImage[i] open and EGLImage[i] and VGImage[i] creation
   540 End loop
   541 Record average opening time of RSgImage, and average creation time of EGLImage, 
   542 VGImage and the whole RSgImage-EGLImage-VGImage chain
   543 For i = N to 0
   544     Start timer
   545     Close VGImage[i]
   546     Stop timer and record time
   547 
   548     Start timer
   549     Close EGLImage[i]
   550     Stop timer and record time
   551 
   552     Start timer
   553     Close RSgImage[i]
   554     Stop timer and record time
   555 
   556     Record total time for closing VGImage[i], EGLImage[i] and RSgImage[i]
   557 End loop
   558 Record average closing time of RSgImage, EGLImage, VGImage, and the whole VGImage-EGLImage-RSgImage chain
   559 
   560 Close RSgDriver
   561 Exit
   562 
   563 @SYMTestExpectedResults
   564     The creation/opening of RSgImage, EGLImage and VGImage must return no error. 
   565     The average time shall be made available in an easy-to-use format 
   566     for further analysis and comparison. All allocated image memory should be freed
   567 */
   568 TVerdict CEglTest_Benchmark_Multi_Process_CreateCloseImage::doTestStepL()
   569     {
   570     SetTestStepID(_L("GRAPHICS-EGL-0435"));
   571     SetTestStepName(KBenchmark_Multi_Process_CreateCloseImage);
   572     INFO_PRINTF1(_L("CEglTest_Benchmark_Multi_Process_CreateCloseImage::doTestStepL"));
   573 
   574 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   575 	INFO_PRINTF1(_L("CEglTest_Benchmark_Multi_Process_CreateCloseImage can only be run with SgImage-Lite"));
   576 #else
   577     TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KVG_KHR_EGL_image | KEGL_KHR_image_pixmap);
   578     if(!ret)
   579         {
   580         // The extension is not supported
   581         RecordTestResultL();
   582         CloseTMSGraphicsStep();
   583         return TestStepResult();
   584         }
   585 
   586     // launch 2 processes
   587     Test_MultiProcessL(KEglTestStepDllName, 2, TestStepName());
   588     
   589 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   590     RecordTestResultL();
   591     CloseTMSGraphicsStep();
   592     return TestStepResult();
   593     }
   594 
   595 void CEglTest_Benchmark_Multi_Process_CreateCloseImage::doProcessFunctionL(TInt aIdx)
   596     {
   597     INFO_PRINTF2(_L("CEglTest_Benchmark_Multi_Process_CreateCloseImage::doProcessFunctionL, Process %d"),aIdx);
   598 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   599     GetDisplayL();
   600     CreateEglSessionL(aIdx);
   601     iEglSess->InitializeL();    
   602     iEglSess->OpenSgDriverL();
   603 
   604     TSgImageInfo imageInfo;
   605     imageInfo.iUsage = ESgUsageBitOpenVgImage;
   606     imageInfo.iPixelFormat = iPixelFormat;
   607     imageInfo.iSizeInPixels = iImageSize;
   608     RArray<TSgDrawableId> sgIdImageList; 
   609     
   610     //Create an array of SgImages and push them into cleanup stack
   611     //sgImageData takes ownership of the SgImages array. 
   612     //If leaving occurs or this object is destroyed from the cleanup stack 
   613     //it will delete all images and then the array
   614     RSgImage* sgImages = NULL;
   615     CSgImageDeleteData* sgImageData = new (ELeave)CSgImageDeleteData(sgImages, iNumIterations);
   616     CleanupStack::PushL(sgImageData);    
   617     sgImages = new (ELeave) RSgImage[iNumIterations];
   618     
   619     RMsgQueue<TSgDrawableId> messageQueue;
   620     User::LeaveIfError(messageQueue.Open(EProcSlotMsgQueueSgId, EOwnerProcess));
   621     CleanupClosePushL(messageQueue);
   622 
   623     //create  iNumIterations number of SgImages in one process and send them over to the second process
   624     INFO_PRINTF3(_L("Process %d, Start sending %d SgImage IDs to other process..."), aIdx, iNumIterations);
   625     if(aIdx == 0)
   626         {
   627         for(TInt count=0; count < iNumIterations; ++count)
   628             {
   629             const TInt res = sgImages[count].Create(imageInfo, NULL);
   630             TESTL(res == KErrNone);
   631             messageQueue.SendBlocking(sgImages[count].Id());
   632             }
   633         }
   634     else if(aIdx == 1)
   635         {
   636         for(TInt count=0; count < iNumIterations; ++count)
   637             {
   638             TSgDrawableId sgImageId;
   639             messageQueue.ReceiveBlocking(sgImageId);
   640             sgIdImageList.AppendL(sgImageId);
   641             }
   642         }
   643     INFO_PRINTF3(_L("Process %d, Finish sending %d SgImage IDs to other process..."), aIdx, iNumIterations);
   644     
   645     CleanupStack::PopAndDestroy(&messageQueue); 
   646     
   647     // Wait for both processes to reach this point
   648     // This is to be sure that there is no context 
   649     //switching whilst the profiling occurs
   650     Rendezvous(aIdx);
   651     if(aIdx == 1)
   652         {
   653         imageInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
   654         //create a dummy surface and context for the purpose of enabling use of VG
   655         iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, CTestEglSession::EResourceCloseSgImageLate);
   656         
   657         iProfiler->InitResults();
   658         for(TInt count=iNumIterations-1; count >= 0; --count)
   659             {
   660             const TInt res = sgImages[count].Open(sgIdImageList[count]);
   661 #ifdef ENABLE_CHECKING_WHILST_PROFILING
   662             TESTL(res == KErrNone);
   663 #endif            
   664             iProfiler->MarkResultSetL();
   665             }
   666         iProfiler->ResultsAnalysis(_L("Open RSgImage from another process"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
   667         
   668         //check that we created all sgImages successfully
   669         for(TInt count=iNumIterations-1; count >= 0; --count)
   670             {
   671             TESTL(!sgImages[count].IsNull());
   672             }
   673         
   674         //Create an array of EglImages and push them into cleanup stack
   675         //eglImageDeleteData takes ownership of EglImages array. 
   676         //If leaving occurs or this object is destroyed from the cleanup stack 
   677         //it will delete all images and then the array
   678         EGLImageKHR* eglImages = NULL;
   679         CEglImageDeleteData* eglImageDeleteData = new (ELeave)CEglImageDeleteData(*this, eglImages, iDisplay, iNumIterations); 
   680         CleanupStack::PushL(eglImageDeleteData);    
   681         eglImages = new (ELeave) EGLImageKHR[iNumIterations];
   682         
   683         iProfiler->InitResults();
   684         for(TInt count=iNumIterations-1; count >= 0; --count)
   685             {//we will use preserved flag as sgImage supposedly has some content
   686             eglImages[count]= iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImages[count],const_cast<EGLint *> (KEglImageAttribsPreservedTrue));
   687             iProfiler->MarkResultSetL();
   688             }
   689         iProfiler->ResultsAnalysis(_L("Creating EGLImage from RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
   690         
   691         //check that we created all EglImages successfully
   692         for(TInt count=iNumIterations-1; count >= 0; --count)
   693             {
   694             ASSERT_EGL_TRUE(eglImages[count] != EGL_NO_IMAGE_KHR)
   695             }
   696         
   697         //Create an array of VGImages and push them into cleanup stack
   698         //vgImageDeleteData takes ownership of VgImages array. 
   699         //If leaving occurs or this object is destroyed from the cleanup stack 
   700         //it will delete all images and then the array
   701         VGImage* vgImages = NULL;
   702         CVgImageDeleteData* vgImageDeleteData = new (ELeave) CVgImageDeleteData(vgImages, iNumIterations);
   703         CleanupStack::PushL(vgImageDeleteData);
   704         vgImages = new (ELeave) VGImage[iNumIterations];
   705         
   706         iProfiler->InitResults();
   707         for(TInt count=iNumIterations-1; count >= 0; --count)
   708             {
   709             vgImages[count] = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImages[count]);
   710             iProfiler->MarkResultSetL();
   711             }   
   712         iProfiler->ResultsAnalysis(_L("Creating VGImage from EGLImage, which in turn based on SgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
   713 
   714         //check that we created all VgImages successfully
   715         for(TInt count=iNumIterations-1; count >= 0; --count)
   716             {
   717             ASSERT_VG_TRUE(vgImages[count] != VG_INVALID_HANDLE);
   718             }   
   719         
   720         sgIdImageList.Reset();
   721         
   722         //Destroying VGImage/EglImage/RSgImages
   723         iProfiler->InitResults();
   724         for(TInt count=iNumIterations-1; count >= 0; --count)
   725             {
   726             vgDestroyImage(vgImages[count]);
   727             iProfiler->MarkResultSetL();
   728             }
   729         iProfiler->ResultsAnalysis(_L("Destroying VGImage based on EGLImage which in turn based on RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
   730         
   731         iProfiler->InitResults();
   732         for(TInt count=iNumIterations-1; count >= 0; --count)
   733             {
   734             const TBool res = iEglSess->DestroyEGLImage(iDisplay, eglImages[count]);
   735 #ifdef ENABLE_CHECKING_WHILST_PROFILING
   736             ASSERT_EGL_TRUE(res);
   737 #endif            
   738             iProfiler->MarkResultSetL();
   739             }
   740         iProfiler->ResultsAnalysis(_L("Destroying EGLImage which based on RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
   741         
   742         iProfiler->InitResults();
   743         for(TInt count=iNumIterations-1; count >= 0; --count)
   744             {
   745             sgImages[count].Close();
   746             iProfiler->MarkResultSetL();
   747             }   
   748         iProfiler->ResultsAnalysis(_L("Closing RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
   749         CleanupStack::PopAndDestroy(2, eglImageDeleteData); //eglImageDeleteData, vgImageDeleteData     
   750         }
   751 
   752     // Wait for both processes to reach this point
   753     Rendezvous(aIdx);
   754     CleanupStack::PopAndDestroy(sgImageData);
   755     CleanAll();
   756 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   757     }
   758 
   759 
   760 /**
   761 @SYMTestCaseID GRAPHICS-EGL-0436
   762 
   763 @SYMTestPriority 1
   764 
   765 @SYMPREQ 2637
   766 
   767 @SYMTestCaseDesc
   768     Performance test - Drawing of VGImage
   769 
   770 @SYMTestPurpose             
   771 Compare the relative speed of drawing a regular pre-existing VGImage with the 
   772 speed of mapping in a VGImage (starting with a drawable id) and then drawing that.
   773 
   774 @SYMTestActions
   775 Environmental settings:
   776 •   Image Size: w50 h50
   777 •   Simulated Load: 0%
   778 •   Pixel format ESgPixelFormatARGB_8888_PRE
   779 •   Number of benchmark iteration: N (may vary depending on hardware capacity)
   780 
   781 From the main test process:
   782 Spawn two processes A and B
   783 From process A:
   784 Open RSgDriver
   785 Construct TSgImageInfo object with
   786 •   Size: 50x50
   787 •   PixelFormat: ESgPixelFormatARGB_8888_PRE
   788 •   Usage: ESgUsageBitOpenVgImage;
   789 
   790 Creation of the RSgImages:
   791 For i = 0 to N
   792       Form pixel data in such way that there will be a mixture of opaque and transparent pixels.     
   793       At least one coordinate of the opaque pixel will be unique for any iteration.
   794       Creating RSgImage with initialized data, size: 50x50 and format:  VG_sARGB_8888_PRE. 
   795       Send RSgImage drawableID to process B
   796 End loop
   797 Close all RSgImages after they will have been opened in process B
   798 Close RSgDriver after process B finishes with benchmark measurement.
   799 
   800 From process B:
   801 
   802 For i = 0 to N
   803      Receive and store drawableID[i] from process A
   804 End loop
   805 
   806 Init EGL, create context and pixmap surface. Make the surface current.
   807 Creating regular VGImage:
   808 For i = 0 to N
   809     Create VGImage[i] with size: 50x50 and format:  VG_sARGB_8888_PRE
   810     SetSubData for VGImage[i] with the same data which were supplied on RSgImage creation
   811 End loop
   812 
   813 Draw regular VGImage:
   814 For j = 0 to 4
   815     Start timer
   816     For i = N to 0
   817         Draw VGImage[i]
   818     End loop i
   819     Stop timer and record time
   820 End loop j
   821 Complete all outstanding requests on the current context (vgFinish)
   822 Record max, min, average drawing time of VGImage
   823 Check that deviation between max and min time doesn’t exceed 5% (max – min / mean) < 0.05
   824 
   825 Destroy all regular VGImages
   826 
   827 Open RSgDriver
   828 Mapping in VGImage from initialized RSgImage and perform drawing:
   829 For j = 0 to 4
   830     Start timer
   831     For i = N to 0
   832         Open RSgImage[i] with drawableID[i]
   833         Create an EGLImage[i] from the RSgImage[i]
   834         Create a VGImage[i] from the EGLImage[i]
   835         Draw VGImage[i]
   836     End loop i
   837     Complete all outstanding requests on the current context (vgFinish)
   838     Stop timer and record time
   839 End loop j
   840 Record max, min, average mapping and drawing time of VGImage
   841 Check that deviation between max and min time doesn’t exceed 5% (max – min / mean) < 0.05
   842 
   843 Destroy context, surface
   844 Close all VGImages, EGLImages and RSgImages
   845 Terminate Egl environment
   846 Close RSgDriver
   847 
   848 @SYMTestExpectedResults
   849 The creation of RSgImage, EGLImage and VGImage must return no error. 
   850 The drawing speed of regular VGImage and mapping VGImage (starting from drawable id) 
   851 with following draw is made available in an easy-to-use format for further analysis and 
   852 comparison.
   853 */
   854 TVerdict CEglTest_Benchmark_DrawImage::doTestStepL()
   855     {
   856     SetTestStepID(_L("GRAPHICS-EGL-0436"));
   857     SetTestStepName(KBenchmark_DrawImage);
   858     INFO_PRINTF1(_L("CEglTest_Benchmark_DrawImage::doTestStepL"));
   859 
   860 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   861     INFO_PRINTF1(_L("CEglTest_Benchmark_DrawImage can only be run with SgImage-Lite"));
   862 #else
   863     TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KVG_KHR_EGL_image | KEGL_KHR_image_pixmap);
   864     if(ret)
   865         {
   866         // launch 2 processes
   867         Test_MultiProcessL(KEglTestStepDllName, 2, TestStepName());
   868         }
   869 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   870 
   871     RecordTestResultL();
   872     CloseTMSGraphicsStep();
   873     return TestStepResult();
   874     }
   875 
   876 void CEglTest_Benchmark_DrawImage::doProcessFunctionL(TInt aIdx)
   877     {
   878     INFO_PRINTF2(_L("CEglTest_Benchmark_DrawImage::doProcessFunctionL, Process %d"),aIdx);
   879 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   880     GetDisplayL();
   881     CreateEglSessionL(aIdx);
   882     iEglSess->InitializeL();    
   883     iEglSess->OpenSgDriverL();
   884 
   885     TSgImageInfo imageInfo;
   886     imageInfo.iUsage = ESgUsageBitOpenVgImage;
   887     imageInfo.iPixelFormat = iPixelFormat;
   888     imageInfo.iSizeInPixels = iImageSize;
   889     RArray<TSgDrawableId> sgIdImageList; 
   890     
   891     const TInt KNumAttempt = 5;
   892     const TInt KNumImagesToDraw = iNumIterations;
   893     //Create an array of SgImages and push them into cleanup stack
   894     //sgImageData takes ownership of the SgImages array. 
   895     //If leaving occurs or this object is destroyed from the cleanup stack 
   896     //it will delete all images and then the array
   897     RSgImage* sgImages = NULL;
   898     CSgImageDeleteData* sgImageData = new (ELeave)CSgImageDeleteData(sgImages, KNumImagesToDraw);
   899     CleanupStack::PushL(sgImageData);    
   900     sgImages = new (ELeave) RSgImage[KNumImagesToDraw];
   901     
   902     // the message queue will be used to pass image IDs across process boundary
   903     RMsgQueue<TSgDrawableId> messageQueue;
   904     User::LeaveIfError(messageQueue.Open(EProcSlotMsgQueueSgId, EOwnerProcess));
   905     CleanupClosePushL(messageQueue);
   906 
   907     //create  iNumIterations * KNumAttempt number of SgImages in one process and send them over to the second process
   908     INFO_PRINTF3(_L("Process %d, Start sending %d SgImage IDs to other process..."), aIdx, iNumIterations);
   909     if(aIdx == 0)
   910         {
   911         TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(KDefaultSourceFormat);
   912         for(TInt index=0; index < KNumImagesToDraw; ++index)
   913             {
   914             CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, iImageSize, index);
   915             CleanupStack::PushL(bitmap);
   916             ASSERT_EQUALS(sgImages[index].Create(imageInfo, bitmap->DataAddress(),bitmap->DataStride()), KErrNone);
   917             messageQueue.SendBlocking(sgImages[index].Id());
   918             CleanupStack::PopAndDestroy(bitmap);
   919             }
   920         }
   921     else if(aIdx == 1)
   922         {
   923         for(TInt index=0; index < KNumImagesToDraw; ++index)
   924             {
   925             TSgDrawableId sgImageId;
   926             messageQueue.ReceiveBlocking(sgImageId);
   927             sgIdImageList.AppendL(sgImageId);
   928             }
   929         }
   930     CleanupStack::PopAndDestroy(&messageQueue);
   931     INFO_PRINTF3(_L("Process %d, Finish sending %d SgImage IDs to other process..."), aIdx, iNumIterations);
   932     //We expect to reach this point from both processes simultaneously 
   933     //this is because ReceiveBlocking/SendBlocking are synchronous
   934     
   935     if(aIdx == 1)
   936         {
   937         imageInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
   938         //create a dummy surface and context for the purpose of enabling use of VG
   939         iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, CTestEglSession::EResourceCloseSgImageLate);
   940 
   941         //Creating regular VGImages
   942         //Create an array of VGImages and push them into cleanup stack
   943         //vgImageDeleteData takes ownership of the VGImages array. 
   944         //If leaving occurs or this object is destroyed from the cleanup stack 
   945         //it will delete all images and then the array
   946         VGImageFormat vgPixelFormat = EglTestConversion::PixelFormatToVgFormat(iPixelFormat);
   947         VGImage* vgImages = NULL;
   948         CVgImageDeleteData* vgImageDeleteData = new (ELeave) CVgImageDeleteData(vgImages, KNumImagesToDraw);
   949         CleanupStack::PushL(vgImageDeleteData);    
   950         vgImages = new (ELeave)VGImage[KNumImagesToDraw];
   951         for(TInt index=KNumImagesToDraw - 1; index >= 0; --index)
   952             {
   953             //we will use VG_IMAGE_QUALITY_NONANTIALIASED flag to avoid OpenVG making the quality improvements
   954             //at the expense of performance (for instance to create an extra buffer) 
   955             vgImages[index] = vgCreateImage(vgPixelFormat, iImageSize.iWidth, iImageSize.iHeight, VG_IMAGE_QUALITY_NONANTIALIASED);
   956             ASSERT_VG_TRUE(vgImages[index] !=  VG_INVALID_HANDLE);
   957             
   958             TDisplayMode bitmapMode = EglTestConversion::VgFormatToDisplayMode(EglTestConversion::PixelFormatToVgFormat(iPixelFormat));
   959             CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, iImageSize, index);
   960             CleanupStack::PushL(bitmap);
   961             // Add pixel data to the VGImage reference from the bitmap reference. 
   962             // Mind the fact that CFbsBitmap and VGImages use different coordinates origin!
   963             TUint8* address = reinterpret_cast<TUint8*>(bitmap->DataAddress());
   964             TInt stride = bitmap->DataStride();
   965             address += (iImageSize.iHeight - 1) * stride;
   966             vgImageSubData(vgImages[index], address, -stride, 
   967                     KDefaultSurfaceFormat, 0,0, iImageSize.iWidth, iImageSize.iHeight);
   968             ASSERT_VG_ERROR(VG_NO_ERROR);
   969             CleanupStack::PopAndDestroy(bitmap);
   970             }
   971 #ifdef ENABLE_BENCHMARK_VERBOSE_LOGGING
   972         iProfiler->SetStoreResultInTimingOrder(ETrue);
   973 #endif        
   974         //--------- start profiling
   975         INFO_PRINTF1(_L("Profiling of drawing of the regular VG image"));
   976         iProfiler->InitResults();
   977         for(TInt count = KNumAttempt - 1; count >= 0; --count)
   978             {
   979             for(TInt index=iNumIterations - 1; index >= 0; --index)
   980                 {
   981                 vgDrawImage(vgImages[index]);
   982 #ifdef ENABLE_CHECKING_WHILST_PROFILING
   983                 ASSERT_VG_ERROR(VG_NO_ERROR);
   984 #endif            
   985                 }
   986             vgFinish();
   987 #ifdef ENABLE_CHECKING_WHILST_PROFILING
   988             ASSERT_VG_ERROR(VG_NO_ERROR);
   989 #endif            
   990             iProfiler->MarkResultSetL();
   991             }
   992         iProfiler->ResultsAnalysis(_L("Drawing of the regular VGImages"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), KNumAttempt);   
   993 #ifdef ENABLE_BENCHMARK_VERBOSE_LOGGING
   994         iProfiler->ShowResultArrayInTimingOrder();
   995         
   996         const TInt KDeviationRegular = ((((TReal)(iProfiler->TimeMax())) - iProfiler->TimeMin()) / (TReal)(iProfiler->Mean())) * 100;
   997         INFO_PRINTF3(_L("Deviation in percentage between min and max number of images drawing ((TimeMax - TimeMin) / Mean * 100): %d, threshold: %d "), KDeviationRegular, KBenchmarkDrawImageThreshold);
   998         if(KDeviationRegular > KBenchmarkDrawImageThreshold)
   999             {
  1000             //unfortunatelly EGL test framework currently ignores the error because this is a spawned process, and not 
  1001             // the main cteststep process. We could leave, but that would be too harsh in this situation
  1002             WARN_PRINTF1(_L("***The deviation has exceeded threshold, the number of iteration needs to be increased!!!"));
  1003             }
  1004 #endif        
  1005         //--------- stop profiling
  1006         
  1007         //destroy vgImages
  1008         for(TInt index=0; index < KNumImagesToDraw; index++)
  1009             {
  1010             vgDestroyImage(vgImages[index]);
  1011             vgImages[index]=VG_INVALID_HANDLE;
  1012             ASSERT_VG_ERROR(VG_NO_ERROR);
  1013             }
  1014         
  1015         //Create an array of EglImages and push them into cleanup stack
  1016         //eglImageDeleteData takes ownership of the EglImages array. 
  1017         //If leaving occurs or this object is destroyed from the cleanup stack 
  1018         //it will delete all images and then the array
  1019         EGLImageKHR* eglImages = NULL;
  1020         CEglImageDeleteData* eglImageDeleteData = new (ELeave)CEglImageDeleteData(*this, eglImages, iDisplay, KNumImagesToDraw); 
  1021         CleanupStack::PushL(eglImageDeleteData);    
  1022         eglImages = new (ELeave) EGLImageKHR[KNumImagesToDraw];
  1023         
  1024         //---------------start profiling
  1025         INFO_PRINTF1(_L("Profiling of mapping in and drawing of the VG images with underlying RSgImage"));
  1026         iProfiler->InitResults();
  1027         for(TInt count = KNumAttempt - 1; count >= 0; --count)
  1028             {//we will run KNumAttemt times in a row and check that the set of results is consistent, 
  1029             // i.e. deviation between max and min time doesn't exceed KBenchmarkDrawImageThreshold percentage
  1030          
  1031             for(TInt index=iNumIterations - 1; index >= 0; --index)
  1032                 {
  1033 #ifdef ENABLE_CHECKING_WHILST_PROFILING
  1034                 const TInt res = sgImages[index].Open(sgIdImageList[index]);
  1035                 TESTL(res == KErrNone);
  1036                 TESTL(!sgImages[index].IsNull());
  1037                 eglImages[index]= iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImages[index],const_cast<EGLint *> (KEglImageAttribsPreservedTrue));
  1038                 ASSERT_EGL_TRUE(eglImages[index] != EGL_NO_IMAGE_KHR)
  1039                 vgImages[index] = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImages[index]);
  1040                 ASSERT_VG_TRUE(vgImages[index] != VG_INVALID_HANDLE);
  1041                 vgDrawImage(vgImages[index]);
  1042                 ASSERT_VG_ERROR(VG_NO_ERROR);
  1043 #else                
  1044                 const TInt res = sgImages[index].Open(sgIdImageList[index]);
  1045                 eglImages[index]= iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImages[index],const_cast<EGLint *> (KEglImageAttribsPreservedTrue));
  1046                 vgImages[index] = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImages[index]);
  1047                 vgDrawImage(vgImages[index]);
  1048                 
  1049 #endif //ENABLE_CHECKING_WHILST_PROFILING
  1050                 }
  1051             vgFinish();
  1052 #ifdef ENABLE_CHECKING_WHILST_PROFILING
  1053             ASSERT_VG_ERROR(VG_NO_ERROR);
  1054 #endif            
  1055             iProfiler->MarkResultSetAndSuspendL(); //mark the end of the iteration. The timer will not be resumed yet 
  1056             
  1057             // Clean Sg/Vg/Egl images. 
  1058             // This is to ensure that expanding of the images will not impact measurement
  1059             for(TInt index=iNumIterations - 1; index >= 0; --index)
  1060                 {
  1061                 sgImages[index].Close();
  1062                 vgDestroyImage(vgImages[index]);
  1063                 vgImages[index] = VG_INVALID_HANDLE;
  1064                 iEglSess->DestroyEGLImage( iDisplay, eglImages[index]);
  1065                 eglImages[index] = EGL_NO_IMAGE_KHR;
  1066                 }
  1067             
  1068             iProfiler->StartTimer();
  1069             }
  1070         //----------------stop profiling
  1071 
  1072         const TInt KDeviation = ((((TReal)(iProfiler->TimeMax())) - iProfiler->TimeMin()) / (TReal)(iProfiler->Mean())) * 100;
  1073         INFO_PRINTF3(_L("Deviation in percentage between min and max number of images drawing ((TimeMax - TimeMin) / Mean * 100): %d, threshold: %d "), KDeviation, KBenchmarkDrawImageThreshold);
  1074         if(KDeviation > KBenchmarkDrawImageThreshold)
  1075             {
  1076 			//unfortunatelly EGL test framework currently ignores the error because this is a spawned process, and not 
  1077 			// the main cteststep process. We could leave, but that would be too harsh in this situation
  1078 			WARN_PRINTF1(_L("***The deviation has exceeded threshold, the number of iteration needs to be increased!!!"));
  1079             }
  1080         
  1081         iProfiler->ResultsAnalysis(_L("Drawing VGImages with underlying RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), KNumAttempt);
  1082 #ifdef ENABLE_BENCHMARK_VERBOSE_LOGGING
  1083         iProfiler->ShowResultArrayInTimingOrder();
  1084 #endif        
  1085         sgIdImageList.Reset();
  1086         }
  1087     
  1088     //Introduce synchronization point here to make sure that RSgImages are not closed from the 
  1089     //first process while the second one is busy with benchmark measurement
  1090     Rendezvous(aIdx);
  1091     if(aIdx == 0)
  1092         {
  1093         //Destroying VGImage/EGLImage/RSgImages
  1094         //no need to profile as we have already done this before
  1095         CleanupStack::PopAndDestroy(sgImageData);  // sgImageData  
  1096         }
  1097     else
  1098         {
  1099         //Destroying VGImage/EGLImage/RSgImages
  1100         //no need to profile as we have already done this before
  1101         CleanupStack::PopAndDestroy(3, sgImageData);  // sgImageData, vgImageDeleteData, eglImageDeleteData
  1102         }
  1103     CleanAll();
  1104 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
  1105     }