os/graphics/egl/egltest/src/egltestcommoninisettings.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) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     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 "egltestcommoninisettings.h"
    23 
    24 EXPORT_C CEglTestCommonIniSettings* CEglTestCommonIniSettings::NewL()
    25 	{
    26 	CEglTestCommonIniSettings* self = CEglTestCommonIniSettings::NewLC();
    27 	CleanupStack::Pop(self);
    28 	return self;
    29 	}
    30 
    31 EXPORT_C CEglTestCommonIniSettings* CEglTestCommonIniSettings::NewLC()
    32 	{
    33 	CEglTestCommonIniSettings* self = new(ELeave) CEglTestCommonIniSettings;
    34 	CleanupStack::PushL(self);
    35 	self->ConstructL();
    36 	return self;
    37 	}
    38 
    39 void CEglTestCommonIniSettings::ConstructL()
    40 	{
    41 	iIniData = CIniData::NewL(KConfigFileName);
    42 	}
    43 
    44 EXPORT_C CEglTestCommonIniSettings::~CEglTestCommonIniSettings()
    45 	{
    46 	delete iIniData;
    47 	}
    48 
    49 EXPORT_C VGImageFormat CEglTestCommonIniSettings::GetVgFormat(const TDesC& aSectioName, const TInt aWhich)
    50 	{
    51     TBuf<20> bufVgPixelFormatNameKey;
    52     bufVgPixelFormatNameKey.Format(KKeyFormatX, aWhich);    
    53     TBuf16<100> bufPixelValue16;
    54     TPtrC16 ptrPixelValue16(bufPixelValue16);
    55     if(!iIniData->FindVar(aSectioName,bufVgPixelFormatNameKey,ptrPixelValue16))
    56         {
    57         return VG_IMAGE_FORMAT_INVALID;
    58         }
    59 
    60     _LIT(K565,"VG_sRGB_565");
    61     _LIT(KX8888,"VG_sXRGB_8888");
    62     _LIT(KA8888,"VG_sARGB_8888");
    63     _LIT(KA8888PRE,"VG_sARGB_8888_PRE");
    64     
    65     if(!ptrPixelValue16.Compare(K565))
    66         {
    67         return VG_sRGB_565;
    68         }
    69     if(!ptrPixelValue16.Compare(KX8888))
    70         {
    71         return VG_sXRGB_8888;
    72         }
    73     if(!ptrPixelValue16.Compare(KA8888))
    74         {
    75         return VG_sARGB_8888;
    76         }
    77     if(!ptrPixelValue16.Compare(KA8888PRE))
    78         {
    79         return VG_sARGB_8888_PRE;
    80         }   
    81     
    82     return VG_IMAGE_FORMAT_INVALID;
    83 	}
    84 
    85 EXPORT_C TUidPixelFormat CEglTestCommonIniSettings::GetPixelFormat(const TDesC& aSectioName, const TInt aWhich)
    86 	{
    87 	TBuf<20> bufPixelNameKey;
    88 	bufPixelNameKey.Format(KKeyFormatX, aWhich);	
    89 	TBuf16<100> bufPixelValue16;
    90 	TPtrC16 ptrPixelValue16(bufPixelValue16);
    91 	if(!iIniData->FindVar(aSectioName,bufPixelNameKey,ptrPixelValue16))
    92 		{
    93 		return EUidPixelFormatUnknown;
    94 		}
    95 	
    96 	_LIT(K565,"EUidPixelFormatRGB_565");
    97 	_LIT(KX8888,"EUidPixelFormatXRGB_8888");
    98 	_LIT(KA8888,"EUidPixelFormatARGB_8888");
    99 	_LIT(KA8888PRE,"EUidPixelFormatARGB_8888_PRE");
   100     _LIT(KA8,"EUidPixelFormatA_8");
   101 	
   102 	if(!ptrPixelValue16.Compare(K565))
   103 		{
   104 		return EUidPixelFormatRGB_565;
   105 		}
   106 	if(!ptrPixelValue16.Compare(KX8888))
   107 		{
   108 		return EUidPixelFormatXRGB_8888;
   109 		}
   110 	if(!ptrPixelValue16.Compare(KA8888))
   111 		{
   112 		return EUidPixelFormatARGB_8888;
   113 		}
   114 	if(!ptrPixelValue16.Compare(KA8888PRE))
   115 		{
   116 		return EUidPixelFormatARGB_8888_PRE;
   117 		}	
   118     if(!ptrPixelValue16.Compare(KA8))
   119         {
   120         return EUidPixelFormatA_8;
   121         }   
   122 	return EUidPixelFormatUnknown;
   123 	}
   124 
   125 EXPORT_C TInt CEglTestCommonIniSettings::GetNumberOfFormats(const TDesC& aSectioName)
   126 	{
   127 	TInt numFormats = 0;
   128 	if(iIniData->FindVar(aSectioName,KKeyNumFormats,numFormats))
   129 		{
   130 		return numFormats;
   131 		}
   132 	return 0;
   133 	}
   134 
   135 EXPORT_C TInt CEglTestCommonIniSettings::GetNumberOfIterations(const TDesC& aSectioName)
   136     {
   137     _LIT(KKeyNumIterations, "NumIterations"); 
   138     TInt numIterations = 0;
   139     if(iIniData->FindVar(aSectioName, KKeyNumIterations, numIterations))
   140         {
   141         return numIterations;
   142         }
   143     return 0;
   144     }
   145 
   146 EXPORT_C TSize CEglTestCommonIniSettings::GetImageSize(const TDesC& aSectioName)
   147     {
   148     _LIT(KKeyBufferWidth, "ImageWidth");
   149     _LIT(KKeyBufferHeight, "ImageHeight");
   150     TSize size(0, 0);
   151     if(iIniData->FindVar(aSectioName, KKeyBufferWidth, size.iWidth) && 
   152             iIniData->FindVar(aSectioName, KKeyBufferHeight, size.iHeight))
   153         {
   154         return size;
   155         }
   156     return TSize(0,0);
   157    }
   158 
   159 EXPORT_C TSize CEglTestCommonIniSettings::GetWindowSize(const TDesC& aSectioName)
   160     {
   161     _LIT(KKeyWindowWidth, "WindowWidth");
   162     _LIT(KKeyWindowHeight, "WindowHeight");
   163     TSize size(0, 0);
   164     if(iIniData->FindVar(aSectioName, KKeyWindowWidth, size.iWidth) && 
   165             iIniData->FindVar(aSectioName, KKeyWindowHeight, size.iHeight))
   166         {
   167         return size;
   168         }
   169 	return TSize(0,0);
   170    }
   171 
   172 EXPORT_C TInt CEglTestCommonIniSettings::GetThresholdGPUUsedMemory(const TDesC& aSectioName)
   173     {
   174     _LIT(KKeyThresholdGPUUsedMemory, "ThresholdGPUUsedMemory");
   175     TInt thresholdGPUUsedMemory = 0;
   176     if(iIniData->FindVar(aSectioName, KKeyThresholdGPUUsedMemory, thresholdGPUUsedMemory))
   177         {
   178         return thresholdGPUUsedMemory;
   179         }
   180     return 0;
   181    }
   182 
   183 EXPORT_C TInt CEglTestCommonIniSettings::GetThresholdLastIteration(const TDesC& aSectioName)
   184     {
   185     _LIT(KKeyThresholdLastIteration, "ThresholdLastIteration");
   186     TInt thresholdLastIteration = 0;
   187     if(iIniData->FindVar(aSectioName, KKeyThresholdLastIteration, thresholdLastIteration))
   188         {
   189         return thresholdLastIteration;
   190         }
   191     return 0;
   192    }