egl/egltest/src/egltest_benchmark_sgimage.cpp
changeset 0 5d03bc08d59c
child 26 15986eb6c500
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 //data will be used to cleanup VgImages if leaving occurs
       
    40 NONSHARABLE_CLASS(CVgImageDeleteData) : public CBase
       
    41     {
       
    42 public:
       
    43     CVgImageDeleteData(VGImage*& aVgImages, TInt aNumVgImages) :
       
    44         iVgImages(aVgImages),
       
    45         iNumVgImages(aNumVgImages)
       
    46         {
       
    47         }
       
    48     ~CVgImageDeleteData();
       
    49 private:    
       
    50     VGImage*& iVgImages;//the ownership will be transferred and cleanup function will destroy this array
       
    51     TInt iNumVgImages;
       
    52     };
       
    53 
       
    54 CVgImageDeleteData::~CVgImageDeleteData()
       
    55     {
       
    56     if(iVgImages)
       
    57         {
       
    58         for(TInt count=iNumVgImages-1; count >= 0; --count)
       
    59             {
       
    60             vgDestroyImage(iVgImages[count]);
       
    61             }
       
    62         delete [] iVgImages;
       
    63         }
       
    64     }
       
    65 
       
    66 //data will be used to cleanup RSgImages if leaving occurs
       
    67 NONSHARABLE_CLASS(CSgImageDeleteData) : public CBase
       
    68     {
       
    69 public:
       
    70     CSgImageDeleteData(RSgImage*& aSgImages, TInt aNumSgImages) :
       
    71         iSgImages(aSgImages),
       
    72         iNumSgImages(aNumSgImages)
       
    73         {
       
    74         }
       
    75     ~CSgImageDeleteData();
       
    76 private:    
       
    77     RSgImage*& iSgImages;//the ownership will be transferred and cleanup function will destroy this array
       
    78     TInt iNumSgImages;
       
    79     };
       
    80 
       
    81 CSgImageDeleteData::~CSgImageDeleteData()
       
    82     {
       
    83     if(iSgImages)
       
    84         {
       
    85         for(TInt count=iNumSgImages-1; count >= 0; --count)
       
    86             {
       
    87             iSgImages[count].Close();
       
    88             }
       
    89         delete [] iSgImages;
       
    90         }
       
    91     }
       
    92 
       
    93 //data will be used to cleanup EGLImages if leaving occurs
       
    94 NONSHARABLE_CLASS(CEglImageDeleteData) : public CBase
       
    95     {
       
    96 public:
       
    97     CEglImageDeleteData(CEglTestStep& aImageBaseStep, 
       
    98             EGLImageKHR*& aEglImages, EGLDisplay& aDisplay, TInt aNumEglImages) : 
       
    99         iImageBaseStep(aImageBaseStep), iEglImages(aEglImages), iDisplay(aDisplay), iNumEglImages(aNumEglImages)
       
   100         {
       
   101         }
       
   102     ~CEglImageDeleteData();
       
   103 private:    
       
   104 	CEglTestStep& iImageBaseStep; //not owned by this object
       
   105     EGLImageKHR*& iEglImages; //the ownership will be transferred and cleanup function will destroy this array
       
   106     EGLDisplay iDisplay; //not owned by this object
       
   107     TInt iNumEglImages;
       
   108     };
       
   109 
       
   110 CEglImageDeleteData::~CEglImageDeleteData()
       
   111     {
       
   112     if(iEglImages)
       
   113         {
       
   114         CTestEglSession* eglSession = iImageBaseStep.GetEglSess(); 
       
   115         for(TInt count=iNumEglImages-1; count >= 0; --count)
       
   116             {    
       
   117             eglSession->DestroyEGLImage( iDisplay, iEglImages[count]);
       
   118             }
       
   119         delete [] iEglImages;
       
   120         }
       
   121     }
       
   122 
       
   123 CEglTest_Benchmark_Base::~CEglTest_Benchmark_Base()
       
   124     {
       
   125     delete iProfiler;
       
   126     }
       
   127 
       
   128 TVerdict CEglTest_Benchmark_Base::doTestStepPreambleL()
       
   129     {
       
   130     TVerdict verdict = CEglTestStep::doTestStepPreambleL();
       
   131     iProfiler = CTProfiler::NewL(*this);
       
   132     //read all parameters from config
       
   133     CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
       
   134     CleanupStack::PushL(iniParser);
       
   135     iNumIterations = iniParser->GetNumberOfIterations(KBenchmarkSection);
       
   136     if(!iNumIterations)
       
   137         {
       
   138         ERR_PRINTF1(_L("The number iterations is not specified in INI file, the test will not be executed!"));
       
   139         User::Leave(KErrArgument);      
       
   140         }
       
   141     
       
   142     iImageSize = iniParser->GetImageSize(KBenchmarkSection);
       
   143     if(iImageSize == TSize(0,0))
       
   144         {
       
   145         ERR_PRINTF1(_L("The image size whether is not specified in INI file or is TSize(0,0), the test will not be executed!"));
       
   146         User::Leave(KErrArgument);      
       
   147         }
       
   148     iPixelFormat = iniParser->GetPixelFormat(KBenchmarkSection, 0);
       
   149     if(iPixelFormat == EUidPixelFormatUnknown)
       
   150         {
       
   151         ERR_PRINTF1(_L("The image pixel format is not specified in INI file, the test will not be executed!"));
       
   152         User::Leave(KErrArgument);      
       
   153         }
       
   154     CleanupStack::PopAndDestroy(iniParser);
       
   155     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);
       
   156     return verdict;
       
   157     }
       
   158 
       
   159 TVerdict CEglTest_Benchmark_Base::doTestStepPostambleL()
       
   160     {
       
   161     delete iProfiler; //we need to delete here to keep happy heap checking in the base class 
       
   162     iProfiler = NULL;
       
   163     return CEglTestStep::doTestStepPostambleL();
       
   164     }
       
   165 
       
   166 //-------
       
   167 
       
   168 /**
       
   169 @SYMTestCaseID GRAPHICS-EGL-0434
       
   170 
       
   171 @SYMTestPriority 1
       
   172 
       
   173 @SYMPREQ 2637
       
   174 
       
   175 @SYMTestCaseDesc
       
   176     Performance test - Creating and destroying VGImage
       
   177 @SYMTestActions
       
   178 Creating regular VGImage
       
   179 Init EGL, create context and surface
       
   180 For i = 0 to N
       
   181     Start timer
       
   182     Create VGImage[i] with size: 50x50 and format:  VG_sARGB_8888_PRE
       
   183     Stop timer and record time
       
   184 End loop
       
   185 Record average time of creating VGImage
       
   186 
       
   187 Closing regular VGImage
       
   188 For i = N to 0
       
   189     Start timer
       
   190     Destroy VGImage[i]
       
   191     Stop timer and record time
       
   192 End loop
       
   193 Record average time of destroying VGImage
       
   194 Destroy context, surface and terminate EGL
       
   195 
       
   196 Creating VGImage from uninitialized RSgImage
       
   197 Open RSgDriver
       
   198 Construct TSgImageInfo object with
       
   199 •   Size: 50x50
       
   200 •   PixelFormat: ESgPixelFormatARGB_8888_PRE
       
   201 •   Usage: ESgUsageBitOpenVgImage;
       
   202 
       
   203 For i = 0 to N
       
   204     Start timer
       
   205     Create RSgImage[i] with arguments TSgImageInfo but without initialized data
       
   206     Stop timer and record time
       
   207 
       
   208     Start timer
       
   209     Create an EGLImage[i] from the RSgImage[i]
       
   210     Stop timer and record time
       
   211 
       
   212     Start timer
       
   213     Create a VGImage[i] from the EGLImage[i]
       
   214     Stop timer and record time
       
   215 
       
   216     Record total time of  RSgImage[i], EGLImage[i] and VGImage[i] creation
       
   217 End loop
       
   218 Record average creation time of RSgImage, EGLImage, VGImage and the whole RSgImage-EGLImage-VGImage chain
       
   219 
       
   220 Destroying VGImage from RSgImage
       
   221 For i = N to 0
       
   222     Start timer
       
   223     Close VGImage[i]
       
   224     Stop timer and record time
       
   225 
       
   226     Start timer
       
   227     Close EGLImage[i]
       
   228     Stop timer and record time
       
   229 
       
   230     Start timer
       
   231     Close RSgImage[i]
       
   232     Stop timer and record time
       
   233 
       
   234     Record total time for closing VGImage[i], EGLImage[i] and RSgImage[i]
       
   235 End loop
       
   236 Record average closing time of RSgImage, EGLImage, VGImage, and the whole 
       
   237 VGImage-EGLImage-RSgImage chain
       
   238 
       
   239 Creating VGImage from initialized RSgImage
       
   240 For i = 0 to N
       
   241     Start timer
       
   242     Create RSgImage[i] with arguments TSgImageInfo a stride of 200 and a  pointer to a 
       
   243     data array of size 10000 bytes
       
   244     Stop timer and record time
       
   245 
       
   246     Start timer
       
   247     Create an EGLImage[i] from the RSgImage[i]
       
   248     Stop timer and record time
       
   249 
       
   250     Start timer
       
   251     Create a VGImage[i] from the EGLImage[i]
       
   252     Stop timer and record time
       
   253 
       
   254     Record total time for RSgImage[i], EGLImage[i] and VGImage[i] creation
       
   255 End loop
       
   256 Record average creation time of RSgImage, EGLImage, VGImage and the whole 
       
   257 RSgImage-EGLImage-VGImage chain
       
   258 Close all VGImages, EGLImages and RSgImages
       
   259 Close RSgDriver
       
   260 
       
   261 @SYMTestExpectedResults
       
   262 The creation of RSgImage, EGLImage and VGImage must return no error. 
       
   263 The average time shall be made available in an easy-to-use format for further 
       
   264 analysis and comparison.
       
   265 */
       
   266 TVerdict CEglTest_Benchmark_CreateCloseImage::doTestStepL()
       
   267     {
       
   268     SetTestStepID(_L("GRAPHICS-EGL-0434"));
       
   269     INFO_PRINTF1(_L("CEglTest_Benchmark_CreateCloseImage::doTestStepL"));
       
   270 
       
   271 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   272 	INFO_PRINTF1(_L("CEglTest_Benchmark_CreateCloseImage can only be run with SgImage-Lite"));
       
   273 	RecordTestResultL();
       
   274 	CloseTMSGraphicsStep();
       
   275 	return TestStepResult();
       
   276 #else
       
   277     TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KVG_KHR_EGL_image | KEGL_KHR_image_pixmap);
       
   278     if(!ret)
       
   279         {
       
   280         // The extension is not supported
       
   281         RecordTestResultL();
       
   282         CloseTMSGraphicsStep();
       
   283         return TestStepResult();
       
   284         }
       
   285  
       
   286     ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
       
   287     GetDisplayL();
       
   288     CreateEglSessionL();
       
   289     iEglSess->InitializeL();
       
   290     iEglSess->OpenSgDriverL();
       
   291  //----create pixmap and make context curent
       
   292     TSgImageInfo imageInfo;
       
   293     imageInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
       
   294     imageInfo.iPixelFormat = iPixelFormat;
       
   295     imageInfo.iSizeInPixels = iImageSize;
       
   296     //create a dummy surface and context for the purpose of enabling use of VG
       
   297     iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, CTestEglSession::EResourceCloseSgImageLate);
       
   298 
       
   299     //Creating regular VGImages
       
   300     //Create an array of VGImages and push them into cleanup stack
       
   301     //vgImageDeleteData takes ownership of the VGImages array. 
       
   302     //If leaving occurs or this object is destroyed from the cleanup stack 
       
   303     //it will delete all images and then the array
       
   304     VGImageFormat vgPixelFormat = EglTestConversion::PixelFormatToVgFormat(iPixelFormat);
       
   305     VGImage* vgImages = NULL;
       
   306     CVgImageDeleteData* vgImageDeleteData = new (ELeave) CVgImageDeleteData(vgImages, iNumIterations);
       
   307     CleanupStack::PushL(vgImageDeleteData);    
       
   308     vgImages = new (ELeave)VGImage[iNumIterations];
       
   309     //-------   start profiling
       
   310     iProfiler->InitResults();
       
   311     for(TInt count=iNumIterations - 1; count >= 0; --count)
       
   312         {
       
   313         //we will use VG_IMAGE_QUALITY_NONANTIALIASED flag to avoid OpenVG making the quality improvements
       
   314         //at the expense of performance (for instance to create an extra buffer) 
       
   315         vgImages[count] = vgCreateImage(vgPixelFormat, iImageSize.iWidth, iImageSize.iHeight, VG_IMAGE_QUALITY_NONANTIALIASED);
       
   316         //we will check the images later, to avoid interfering with the profiler
       
   317         iProfiler->MarkResultSetL();
       
   318         }
       
   319     iProfiler->ResultsAnalysis(_L("Creating regular VGImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   320     
       
   321     //check that we created all VgImages
       
   322     for(TInt count=iNumIterations - 1; count >= 0; --count)
       
   323         {
       
   324         ASSERT_VG_TRUE(vgImages[count] !=  VG_INVALID_HANDLE);
       
   325         }    
       
   326     //Closing regular VGImage
       
   327     iProfiler->InitResults();
       
   328     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   329         {
       
   330         vgDestroyImage(vgImages[count]);
       
   331         iProfiler->MarkResultSetL();
       
   332         }
       
   333     iProfiler->ResultsAnalysis(_L("Closing regular VGImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   334 
       
   335 //---  Creating VGImage from uninitialized RSgImage  
       
   336     //Create an array of SgImages and push them into cleanup stack
       
   337     //sgImageData takes ownership of the SgImages array. 
       
   338     //If leaving occurs or this object is destroyed from the cleanup stack 
       
   339     //it will delete all images and then the array
       
   340     imageInfo.iUsage = ESgUsageBitOpenVgImage;
       
   341     RSgImage* sgImages = NULL;
       
   342     CSgImageDeleteData* sgImageData = new (ELeave)CSgImageDeleteData(sgImages, iNumIterations);
       
   343     CleanupStack::PushL(sgImageData);    
       
   344     sgImages = new (ELeave) RSgImage[iNumIterations];
       
   345     
       
   346     iProfiler->InitResults();
       
   347     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   348         {
       
   349         const TInt res = sgImages[count].Create(imageInfo, NULL);
       
   350 #ifdef ENABLE_CHECKING_WHILST_PROFILING
       
   351         TESTL(res == KErrNone);
       
   352 #endif
       
   353         iProfiler->MarkResultSetL();
       
   354         }
       
   355     iProfiler->ResultsAnalysis(_L("Creating uninitialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   356     
       
   357     //check that we created all sgImages successfully
       
   358     for(TInt count=iNumIterations - 1; count >= 0; --count)
       
   359         {
       
   360         TESTL(!sgImages[count].IsNull());
       
   361         }    
       
   362     
       
   363     //Create an array of EglImages and push them into cleanup stack
       
   364     //eglImageDeleteData takes ownership of the EglImages array. 
       
   365     //If leaving occurs or this object is destroyed from the cleanup stack 
       
   366     //it will delete all images and then the array
       
   367     EGLImageKHR* eglImages = NULL;
       
   368     CEglImageDeleteData* eglImageDeleteData = new (ELeave)CEglImageDeleteData(*this, eglImages, iDisplay, iNumIterations); 
       
   369     CleanupStack::PushL(eglImageDeleteData);    
       
   370     eglImages = new (ELeave) EGLImageKHR[iNumIterations];
       
   371     
       
   372     iProfiler->InitResults();
       
   373     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   374         {//we will use preserved flag as sgImage supposedly has some content
       
   375         eglImages[count]= iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImages[count],const_cast<EGLint *> (KEglImageAttribsPreservedTrue));
       
   376         iProfiler->MarkResultSetL();
       
   377         }
       
   378     iProfiler->ResultsAnalysis(_L("Creating EGLImage from uninitialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   379 
       
   380     //check that we created all EglImages successfully
       
   381     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   382         {
       
   383         ASSERT_EGL_TRUE(eglImages[count] != EGL_NO_IMAGE_KHR)
       
   384         }
       
   385     
       
   386     iProfiler->InitResults();
       
   387     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   388         {
       
   389         vgImages[count] = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImages[count]);
       
   390         iProfiler->MarkResultSetL();
       
   391         }   
       
   392     iProfiler->ResultsAnalysis(_L("Creating VGImage from EGLImage, which in turn based on uninitialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   393     
       
   394     //check that we created all sgImages successfully
       
   395     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   396         {
       
   397         ASSERT_VG_TRUE(vgImages[count] != VG_INVALID_HANDLE);
       
   398         }
       
   399     
       
   400     //Destroying VGImage/EGLImage/RSgImages
       
   401     iProfiler->InitResults();
       
   402     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   403         {
       
   404         vgDestroyImage(vgImages[count]);
       
   405         iProfiler->MarkResultSetL();
       
   406         }
       
   407     iProfiler->ResultsAnalysis(_L("Destroying VGImage which based on RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
       
   408     
       
   409     iProfiler->InitResults();
       
   410     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   411         {
       
   412         const TBool res = iEglSess->DestroyEGLImage(iDisplay, eglImages[count]);
       
   413 #ifdef ENABLE_CHECKING_WHILST_PROFILING
       
   414         ASSERT_EGL_TRUE(res)
       
   415 #endif
       
   416         iProfiler->MarkResultSetL();
       
   417         }
       
   418     iProfiler->ResultsAnalysis(_L("Destroying EGLImage which in turn based on RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
       
   419     
       
   420     iProfiler->InitResults();
       
   421     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   422         {
       
   423         sgImages[count].Close();
       
   424         iProfiler->MarkResultSetL();
       
   425         }   
       
   426     iProfiler->ResultsAnalysis(_L("Closing RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
       
   427     
       
   428     //Creating initialized VGImage from initialized RSgImage
       
   429     const TInt KDataStride = iImageSize.iWidth * EglTestConversion::BytePerPixel(iPixelFormat);
       
   430     const TInt KDataSizeInByte = KDataStride *  iImageSize.iHeight;
       
   431     TInt* data = new (ELeave) TInt[KDataSizeInByte];
       
   432     User::LeaveIfNull(data);
       
   433     CleanupStack::PushL(data);
       
   434     
       
   435     Mem::Fill(data, KDataSizeInByte / 2, 0xff);
       
   436     Mem::FillZ(data + KDataSizeInByte / 2, KDataSizeInByte / 2);
       
   437     
       
   438     iProfiler->InitResults();
       
   439     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   440         {
       
   441         const TInt res = sgImages[count].Create(imageInfo, data, KDataStride);
       
   442 #ifdef ENABLE_CHECKING_WHILST_PROFILING
       
   443         TESTL(res == KErrNone);
       
   444 #endif
       
   445         iProfiler->MarkResultSetL();
       
   446         }
       
   447     iProfiler->ResultsAnalysis(_L("Creating initialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
       
   448     
       
   449     //check that we created all sgImages successfully
       
   450     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   451         {
       
   452         TESTL(!sgImages[count].IsNull());
       
   453         }
       
   454     
       
   455     iProfiler->InitResults();
       
   456     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   457         {//we will use preserved flag as sgImage supposedly has some content
       
   458         eglImages[count]= iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, 
       
   459                 &sgImages[count], const_cast<EGLint *> (KEglImageAttribsPreservedTrue));
       
   460         iProfiler->MarkResultSetL();
       
   461         }
       
   462     iProfiler->ResultsAnalysis(_L("Creating EGLImage from initialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
       
   463 
       
   464     //check that we created all EglImages successfully
       
   465     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   466         {
       
   467         ASSERT_EGL_TRUE(eglImages[count] != EGL_NO_IMAGE_KHR)
       
   468         }
       
   469     
       
   470     iProfiler->InitResults();
       
   471     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   472         {
       
   473         vgImages[count] = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImages[count]);
       
   474         iProfiler->MarkResultSetL();
       
   475         }   
       
   476     iProfiler->ResultsAnalysis(_L("Creating VGImage from EGLImage which in turn based on initialized RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
       
   477 
       
   478     //check that we created all VgImages successfully
       
   479     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   480         {
       
   481         ASSERT_VG_TRUE(vgImages[count] != VG_INVALID_HANDLE);
       
   482         }
       
   483     
       
   484     CleanupStack::PopAndDestroy(data);    
       
   485     //Destroying VGImage/EGLImage/RSgImages
       
   486     //no need to profile as we have already done this before
       
   487     CleanupStack::PopAndDestroy(3, vgImageDeleteData);  // vgImageDeleteData, sgImageData, eglImageDeleteData  
       
   488     
       
   489     CleanAll();
       
   490     RecordTestResultL();
       
   491     CloseTMSGraphicsStep();
       
   492     return TestStepResult();
       
   493 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   494     }
       
   495 
       
   496 /**
       
   497 @SYMTestCaseID GRAPHICS-EGL-0435
       
   498 
       
   499 @SYMTestPriority 1
       
   500 
       
   501 @SYMPREQ 2637
       
   502 
       
   503 @SYMTestCaseDesc
       
   504     Performance test – Creating and destroying VGImage from an RSgImage via Open
       
   505 @SYMTestActions
       
   506 Environmental settings:
       
   507 •   Image Size: w50 h50
       
   508 •   Simulated Load: 0%
       
   509 •   Pixel format ESgPixelFormatARGB_8888_PRE
       
   510 •   Number of benchmark iteration: N
       
   511 
       
   512 The method of creation of the RSgImage is similar to the case taken from GRAPHICS-EGL-RSGIMAGE_LITE-0406
       
   513 
       
   514 From Process A:
       
   515 Open the RSgDriver
       
   516 Create an RSgImage
       
   517 Spawn a client process B, passing in the drawable ID of the RSgImage
       
   518 Wait for process B to exit
       
   519 
       
   520 From process B:
       
   521 Open RSgDriver
       
   522 For i = 0 to N
       
   523     Start timer
       
   524     Open RSgImage[i]
       
   525     Stop timer and record time
       
   526 
       
   527     Start timer
       
   528     Create an EGLImage[i] from the RSgImage[i]
       
   529     Stop timer and record time
       
   530 
       
   531     Start timer
       
   532     Create a VGImage[i] from the EGLImage[i]
       
   533     Stop timer and record time
       
   534 
       
   535     Record total time of RSgImage[i] open and EGLImage[i] and VGImage[i] creation
       
   536 End loop
       
   537 Record average opening time of RSgImage, and average creation time of EGLImage, 
       
   538 VGImage and the whole RSgImage-EGLImage-VGImage chain
       
   539 For i = N to 0
       
   540     Start timer
       
   541     Close VGImage[i]
       
   542     Stop timer and record time
       
   543 
       
   544     Start timer
       
   545     Close EGLImage[i]
       
   546     Stop timer and record time
       
   547 
       
   548     Start timer
       
   549     Close RSgImage[i]
       
   550     Stop timer and record time
       
   551 
       
   552     Record total time for closing VGImage[i], EGLImage[i] and RSgImage[i]
       
   553 End loop
       
   554 Record average closing time of RSgImage, EGLImage, VGImage, and the whole VGImage-EGLImage-RSgImage chain
       
   555 
       
   556 Close RSgDriver
       
   557 Exit
       
   558 
       
   559 @SYMTestExpectedResults
       
   560     The creation/opening of RSgImage, EGLImage and VGImage must return no error. 
       
   561     The average time shall be made available in an easy-to-use format 
       
   562     for further analysis and comparison. All allocated image memory should be freed
       
   563 */
       
   564 TVerdict CEglTest_Benchmark_Multi_Process_CreateCloseImage::doTestStepL()
       
   565     {
       
   566     SetTestStepID(_L("GRAPHICS-EGL-0435"));
       
   567     SetTestStepName(KBenchmark_Multi_Process_CreateCloseImage);
       
   568     INFO_PRINTF1(_L("CEglTest_Benchmark_Multi_Process_CreateCloseImage::doTestStepL"));
       
   569 
       
   570 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   571 	INFO_PRINTF1(_L("CEglTest_Benchmark_Multi_Process_CreateCloseImage can only be run with SgImage-Lite"));
       
   572 	RecordTestResultL();
       
   573 	CloseTMSGraphicsStep();
       
   574 	return TestStepResult();
       
   575 #else
       
   576     TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KVG_KHR_EGL_image | KEGL_KHR_image_pixmap);
       
   577     if(!ret)
       
   578         {
       
   579         // The extension is not supported
       
   580         RecordTestResultL();
       
   581         CloseTMSGraphicsStep();
       
   582         return TestStepResult();
       
   583         }
       
   584 
       
   585     // launch 2 processes
       
   586     Test_MultiProcessL(KEglTestStepDllName, 2, TestStepName());
       
   587     
       
   588     RecordTestResultL();
       
   589     CloseTMSGraphicsStep();
       
   590     return TestStepResult();
       
   591 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   592     }
       
   593 
       
   594 void CEglTest_Benchmark_Multi_Process_CreateCloseImage::doProcessFunctionL(TInt aIdx)
       
   595     {
       
   596     INFO_PRINTF2(_L("CEglTest_Benchmark_Multi_Process_CreateCloseImage::doProcessFunctionL, Process %d"),aIdx);
       
   597 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   598     GetDisplayL();
       
   599     CreateEglSessionL(aIdx);
       
   600     iEglSess->InitializeL();    
       
   601     iEglSess->OpenSgDriverL();
       
   602 
       
   603     TSgImageInfo imageInfo;
       
   604     imageInfo.iUsage = ESgUsageBitOpenVgImage;
       
   605     imageInfo.iPixelFormat = iPixelFormat;
       
   606     imageInfo.iSizeInPixels = iImageSize;
       
   607     RArray<TSgDrawableId> sgIdImageList; 
       
   608     
       
   609     //Create an array of SgImages and push them into cleanup stack
       
   610     //sgImageData takes ownership of the SgImages array. 
       
   611     //If leaving occurs or this object is destroyed from the cleanup stack 
       
   612     //it will delete all images and then the array
       
   613     RSgImage* sgImages = NULL;
       
   614     CSgImageDeleteData* sgImageData = new (ELeave)CSgImageDeleteData(sgImages, iNumIterations);
       
   615     CleanupStack::PushL(sgImageData);    
       
   616     sgImages = new (ELeave) RSgImage[iNumIterations];
       
   617     
       
   618     RMsgQueue<TSgDrawableId> messageQueue;
       
   619     User::LeaveIfError(messageQueue.Open(EProcSlotMsgQueueSgId, EOwnerProcess));
       
   620     CleanupClosePushL(messageQueue);
       
   621 
       
   622     //create  iNumIterations number of SgImages in one process and send them over to the second process
       
   623     INFO_PRINTF3(_L("Process %d, Start sending %d SgImage IDs to other process..."), aIdx, iNumIterations);
       
   624     if(aIdx == 0)
       
   625         {
       
   626         for(TInt count=0; count < iNumIterations; ++count)
       
   627             {
       
   628             const TInt res = sgImages[count].Create(imageInfo, NULL);
       
   629             TESTL(res == KErrNone);
       
   630             messageQueue.SendBlocking(sgImages[count].Id());
       
   631             }
       
   632         }
       
   633     else if(aIdx == 1)
       
   634         {
       
   635         for(TInt count=0; count < iNumIterations; ++count)
       
   636             {
       
   637             TSgDrawableId sgImageId;
       
   638             messageQueue.ReceiveBlocking(sgImageId);
       
   639             sgIdImageList.AppendL(sgImageId);
       
   640             }
       
   641         }
       
   642     INFO_PRINTF3(_L("Process %d, Finish sending %d SgImage IDs to other process..."), aIdx, iNumIterations);
       
   643     
       
   644     CleanupStack::PopAndDestroy(&messageQueue); 
       
   645     
       
   646     // Wait for both processes to reach this point
       
   647     // This is to be sure that there is no context 
       
   648     //switching whilst the profiling occurs
       
   649     Rendezvous(aIdx);
       
   650     if(aIdx == 1)
       
   651         {
       
   652         imageInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
       
   653         //create a dummy surface and context for the purpose of enabling use of VG
       
   654         iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, CTestEglSession::EResourceCloseSgImageLate);
       
   655         
       
   656         iProfiler->InitResults();
       
   657         for(TInt count=iNumIterations-1; count >= 0; --count)
       
   658             {
       
   659             const TInt res = sgImages[count].Open(sgIdImageList[count]);
       
   660 #ifdef ENABLE_CHECKING_WHILST_PROFILING
       
   661             TESTL(res == KErrNone);
       
   662 #endif            
       
   663             iProfiler->MarkResultSetL();
       
   664             }
       
   665         iProfiler->ResultsAnalysis(_L("Open RSgImage from another process"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   666         
       
   667         //check that we created all sgImages successfully
       
   668         for(TInt count=iNumIterations-1; count >= 0; --count)
       
   669             {
       
   670             TESTL(!sgImages[count].IsNull());
       
   671             }
       
   672         
       
   673         //Create an array of EglImages and push them into cleanup stack
       
   674         //eglImageDeleteData takes ownership of EglImages array. 
       
   675         //If leaving occurs or this object is destroyed from the cleanup stack 
       
   676         //it will delete all images and then the array
       
   677         EGLImageKHR* eglImages = NULL;
       
   678         CEglImageDeleteData* eglImageDeleteData = new (ELeave)CEglImageDeleteData(*this, eglImages, iDisplay, iNumIterations); 
       
   679         CleanupStack::PushL(eglImageDeleteData);    
       
   680         eglImages = new (ELeave) EGLImageKHR[iNumIterations];
       
   681         
       
   682         iProfiler->InitResults();
       
   683         for(TInt count=iNumIterations-1; count >= 0; --count)
       
   684             {//we will use preserved flag as sgImage supposedly has some content
       
   685             eglImages[count]= iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImages[count],const_cast<EGLint *> (KEglImageAttribsPreservedTrue));
       
   686             iProfiler->MarkResultSetL();
       
   687             }
       
   688         iProfiler->ResultsAnalysis(_L("Creating EGLImage from RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   689         
       
   690         //check that we created all EglImages successfully
       
   691         for(TInt count=iNumIterations-1; count >= 0; --count)
       
   692             {
       
   693             ASSERT_EGL_TRUE(eglImages[count] != EGL_NO_IMAGE_KHR)
       
   694             }
       
   695         
       
   696         //Create an array of VGImages and push them into cleanup stack
       
   697         //vgImageDeleteData takes ownership of VgImages array. 
       
   698         //If leaving occurs or this object is destroyed from the cleanup stack 
       
   699         //it will delete all images and then the array
       
   700         VGImage* vgImages = NULL;
       
   701         CVgImageDeleteData* vgImageDeleteData = new (ELeave) CVgImageDeleteData(vgImages, iNumIterations);
       
   702         CleanupStack::PushL(vgImageDeleteData);
       
   703         vgImages = new (ELeave) VGImage[iNumIterations];
       
   704         
       
   705         iProfiler->InitResults();
       
   706         for(TInt count=iNumIterations-1; count >= 0; --count)
       
   707             {
       
   708             vgImages[count] = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImages[count]);
       
   709             iProfiler->MarkResultSetL();
       
   710             }   
       
   711         iProfiler->ResultsAnalysis(_L("Creating VGImage from EGLImage, which in turn based on SgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   712 
       
   713         //check that we created all VgImages successfully
       
   714         for(TInt count=iNumIterations-1; count >= 0; --count)
       
   715             {
       
   716             ASSERT_VG_TRUE(vgImages[count] != VG_INVALID_HANDLE);
       
   717             }   
       
   718         
       
   719         sgIdImageList.Reset();
       
   720         
       
   721         //Destroying VGImage/EglImage/RSgImages
       
   722         iProfiler->InitResults();
       
   723         for(TInt count=iNumIterations-1; count >= 0; --count)
       
   724             {
       
   725             vgDestroyImage(vgImages[count]);
       
   726             iProfiler->MarkResultSetL();
       
   727             }
       
   728         iProfiler->ResultsAnalysis(_L("Destroying VGImage based on EGLImage which in turn based on RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
       
   729         
       
   730         iProfiler->InitResults();
       
   731         for(TInt count=iNumIterations-1; count >= 0; --count)
       
   732             {
       
   733             const TBool res = iEglSess->DestroyEGLImage(iDisplay, eglImages[count]);
       
   734 #ifdef ENABLE_CHECKING_WHILST_PROFILING
       
   735             ASSERT_EGL_TRUE(res);
       
   736 #endif            
       
   737             iProfiler->MarkResultSetL();
       
   738             }
       
   739         iProfiler->ResultsAnalysis(_L("Destroying EGLImage which based on RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
       
   740         
       
   741         iProfiler->InitResults();
       
   742         for(TInt count=iNumIterations-1; count >= 0; --count)
       
   743             {
       
   744             sgImages[count].Close();
       
   745             iProfiler->MarkResultSetL();
       
   746             }   
       
   747         iProfiler->ResultsAnalysis(_L("Closing RSgImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);    
       
   748         CleanupStack::PopAndDestroy(2, eglImageDeleteData); //eglImageDeleteData, vgImageDeleteData     
       
   749         }
       
   750 
       
   751     // Wait for both processes to reach this point
       
   752     Rendezvous(aIdx);
       
   753     CleanupStack::PopAndDestroy(sgImageData);
       
   754     CleanAll();
       
   755 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   756     }
       
   757 
       
   758 
       
   759 /**
       
   760 @SYMTestCaseID GRAPHICS-EGL-0436
       
   761 
       
   762 @SYMTestPriority 1
       
   763 
       
   764 @SYMPREQ 2637
       
   765 
       
   766 @SYMTestCaseDesc
       
   767     Performance test - Drawing VGImage
       
   768 @SYMTestActions
       
   769 Environmental settings:
       
   770 •   Image Size: w50 h50
       
   771 •   Simulated Load: 0%
       
   772 •   Pixel format ESgPixelFormatARGB_8888_PRE
       
   773 •   Number of benchmark iteration: N (may vary depending on hardware capacity)
       
   774 
       
   775 Creating regular VGImage
       
   776 Init EGL, create context and surface
       
   777 For i = 0 to N
       
   778     Create VGImage[i] with size: 50x50 and format:  VG_sARGB_8888_PRE
       
   779     SetSubData for VGImage[i] 
       
   780 End loop
       
   781 
       
   782 Draw VGImage
       
   783 For i = N to 0
       
   784     Start timer
       
   785     Draw VGImage[i]
       
   786     Stop timer and record time
       
   787 End loop
       
   788 Record average time of drawing VGImage
       
   789 
       
   790 Closing regular VGImage
       
   791 For i = N to 0
       
   792     Destroy VGImage[i]
       
   793 End loop
       
   794 
       
   795 Creating VGImage from initialized RSgImage
       
   796 Open RSgDriver
       
   797 Construct TSgImageInfo object with
       
   798 •   Size: 50x50
       
   799 •   PixelFormat: ESgPixelFormatARGB_8888_PRE
       
   800 •   Usage: ESgUsageBitOpenVgImage;
       
   801 
       
   802 For i = N to 0
       
   803     Create RSgImage[i] with arguments TSgImageInfo with initialized data which were supplied to regular VGImage 
       
   804     Create an EGLImage[i] from the RSgImage[i]
       
   805     Create a VGImage[i] from the EGLImage[i]
       
   806 End loop
       
   807 
       
   808 Draw VGImage which is based on RSgImage
       
   809 For i = N to 0
       
   810     Start timer
       
   811     Draw VGImage[i]
       
   812     Stop timer and record time
       
   813 End loop
       
   814 Record average time of drawing VGImage
       
   815 
       
   816 Close all VGImages, EGLImages and RSgImages
       
   817 Close RSgDriver
       
   818 
       
   819 @SYMTestExpectedResults
       
   820 The creation of RSgImage, EGLImage and VGImage must return no error. 
       
   821 The average drawing time of regular VGImage and VGImage with underlying RSgImage is 
       
   822 made available in an easy-to-use format for further analysis and comparison.
       
   823 */
       
   824 TVerdict CEglTest_Benchmark_DrawImage::doTestStepL()
       
   825     {
       
   826     SetTestStepID(_L("GRAPHICS-EGL-0436"));
       
   827     INFO_PRINTF1(_L("CEglTest_Benchmark_DrawImage::doTestStepL"));
       
   828 
       
   829 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   830     INFO_PRINTF1(_L("CEglTest_Benchmark_DrawImage can only be run with SgImage-Lite"));
       
   831     RecordTestResultL();
       
   832     CloseTMSGraphicsStep();
       
   833     return TestStepResult();
       
   834 #else
       
   835     TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KVG_KHR_EGL_image | KEGL_KHR_image_pixmap);
       
   836     if(!ret)
       
   837         {
       
   838         // The extension is not supported
       
   839         RecordTestResultL();
       
   840         CloseTMSGraphicsStep();
       
   841         return TestStepResult();
       
   842         }
       
   843  
       
   844     ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
       
   845     GetDisplayL();
       
   846     CreateEglSessionL();
       
   847     iEglSess->InitializeL();
       
   848     iEglSess->OpenSgDriverL();
       
   849  //----create pixmap and make context curent
       
   850     TSgImageInfo imageInfo;
       
   851     imageInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
       
   852     imageInfo.iPixelFormat = iPixelFormat;
       
   853     imageInfo.iSizeInPixels = iImageSize;
       
   854     //create a dummy surface and context for the purpose of enabling use of VG
       
   855     iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, CTestEglSession::EResourceCloseSgImageLate);
       
   856 
       
   857     const TInt KDataStride = iImageSize.iWidth * EglTestConversion::BytePerPixel(iPixelFormat);
       
   858     const TInt KDataSizeInByte = KDataStride *  iImageSize.iHeight;
       
   859     TInt* data = new (ELeave) TInt[KDataSizeInByte];
       
   860     User::LeaveIfNull(data);
       
   861     CleanupStack::PushL(data);
       
   862     
       
   863     Mem::Fill(data, KDataSizeInByte / 2, 0xff);
       
   864     Mem::FillZ(data + KDataSizeInByte / 2, KDataSizeInByte / 2);
       
   865 
       
   866     //Creating regular VGImages
       
   867     //Create an array of VGImages and push them into cleanup stack
       
   868     //vgImageDeleteData takes ownership of the VGImages array. 
       
   869     //If leaving occurs or this object is destroyed from the cleanup stack 
       
   870     //it will delete all images and then the array
       
   871     VGImageFormat vgPixelFormat = EglTestConversion::PixelFormatToVgFormat(iPixelFormat);
       
   872     VGImage* vgImages = NULL;
       
   873     CVgImageDeleteData* vgImageDeleteData = new (ELeave) CVgImageDeleteData(vgImages, iNumIterations);
       
   874     CleanupStack::PushL(vgImageDeleteData);    
       
   875     vgImages = new (ELeave)VGImage[iNumIterations];
       
   876     for(TInt count=iNumIterations - 1; count >= 0; --count)
       
   877         {
       
   878         //we will use VG_IMAGE_QUALITY_NONANTIALIASED flag to avoid OpenVG making the quality improvements
       
   879         //at the expense of performance (for instance to create an extra buffer) 
       
   880         vgImages[count] = vgCreateImage(vgPixelFormat, iImageSize.iWidth, iImageSize.iHeight, VG_IMAGE_QUALITY_NONANTIALIASED);
       
   881         ASSERT_VG_TRUE(vgImages[count] !=  VG_INVALID_HANDLE);
       
   882         
       
   883         vgImageSubData(vgImages[count],
       
   884                 data, KDataStride,
       
   885                 vgPixelFormat,
       
   886                 0, 0, iImageSize.iWidth, iImageSize.iHeight);
       
   887         ASSERT_VG_ERROR(VG_NO_ERROR);
       
   888         }
       
   889     
       
   890     //--------- start profiling
       
   891     iProfiler->InitResults();
       
   892     for(TInt count=iNumIterations - 1; count >= 0; --count)
       
   893         {
       
   894         vgDrawImage(vgImages[count]);
       
   895 #ifdef ENABLE_CHECKING_WHILST_PROFILING
       
   896         ASSERT_VG_ERROR(VG_NO_ERROR);
       
   897 #endif            
       
   898         iProfiler->MarkResultSetL();
       
   899         }
       
   900     iProfiler->ResultsAnalysis(_L("Drawing regular VGImage"), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   901     //--------- stop profiling
       
   902     
       
   903     //destroy vgImages
       
   904     for(TInt count=iNumIterations - 1; count >= 0; --count)
       
   905         {
       
   906         vgDestroyImage(vgImages[count]);
       
   907         ASSERT_VG_ERROR(VG_NO_ERROR);
       
   908         vgImages[count]=VG_INVALID_HANDLE;
       
   909         }
       
   910     
       
   911     //Create an array of SgImages and push them into cleanup stack
       
   912     //sgImageData takes ownership of the SgImages array. 
       
   913     //If leaving occurs or this object is destroyed from the cleanup stack 
       
   914     //it will delete all images and then the array
       
   915     imageInfo.iUsage = ESgUsageBitOpenVgImage;
       
   916     RSgImage* sgImages = NULL;
       
   917     CSgImageDeleteData* sgImageData = new (ELeave)CSgImageDeleteData(sgImages, iNumIterations);
       
   918     CleanupStack::PushL(sgImageData);    
       
   919     sgImages = new (ELeave) RSgImage[iNumIterations];
       
   920     
       
   921     //Create an array of EglImages and push them into cleanup stack
       
   922     //eglImageDeleteData takes ownership of the EglImages array. 
       
   923     //If leaving occurs or this object is destroyed from the cleanup stack 
       
   924     //it will delete all images and then the array
       
   925     EGLImageKHR* eglImages = NULL;
       
   926     CEglImageDeleteData* eglImageDeleteData = new (ELeave)CEglImageDeleteData(*this, eglImages, iDisplay, iNumIterations); 
       
   927     CleanupStack::PushL(eglImageDeleteData);    
       
   928     eglImages = new (ELeave) EGLImageKHR[iNumIterations];
       
   929     
       
   930     //Creating VGImage from initialized RSgImage
       
   931     for(TInt count=iNumIterations-1; count >= 0; --count)
       
   932         {
       
   933         const TInt res = sgImages[count].Create(imageInfo, data, KDataStride);
       
   934         TESTL(res == KErrNone);
       
   935         TESTL(!sgImages[count].IsNull());
       
   936 
       
   937         eglImages[count]= iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImages[count],const_cast<EGLint *> (KEglImageAttribsPreservedTrue));
       
   938         ASSERT_EGL_TRUE(eglImages[count] != EGL_NO_IMAGE_KHR)
       
   939 
       
   940         vgImages[count] = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImages[count]);
       
   941         ASSERT_VG_TRUE(vgImages[count] != VG_INVALID_HANDLE);
       
   942         }
       
   943     
       
   944     //---------------start profiling
       
   945     iProfiler->InitResults();
       
   946     for(TInt count=iNumIterations - 1; count >= 0; --count)
       
   947         {
       
   948         vgDrawImage(vgImages[count]);
       
   949 #ifdef ENABLE_CHECKING_WHILST_PROFILING
       
   950         ASSERT_VG_ERROR(VG_NO_ERROR);
       
   951 #endif            
       
   952         iProfiler->MarkResultSetL();
       
   953         }
       
   954     iProfiler->ResultsAnalysis(_L("Drawing VGImage with underlying RSgImage "), 0, EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), EglTestConversion::PixelFormatToDisplayMode(iPixelFormat), iNumIterations);   
       
   955     //----------------stop profiling
       
   956     
       
   957     //Destroying VGImage/EGLImage/RSgImages
       
   958     //no need to profile as we have already done this before
       
   959     CleanupStack::PopAndDestroy(4, data);  // data, vgImageDeleteData, sgImageData, eglImageDeleteData  
       
   960     
       
   961     CleanAll();
       
   962     RecordTestResultL();
       
   963     CloseTMSGraphicsStep();
       
   964     return TestStepResult();
       
   965 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   966     }