1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/egl/egltest/src/egltestcommoninisettings.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,192 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 +*/
1.23 +
1.24 +#include <test/tefunit.h> // for ASSERT macros
1.25 +#include "egltestcommoninisettings.h"
1.26 +
1.27 +EXPORT_C CEglTestCommonIniSettings* CEglTestCommonIniSettings::NewL()
1.28 + {
1.29 + CEglTestCommonIniSettings* self = CEglTestCommonIniSettings::NewLC();
1.30 + CleanupStack::Pop(self);
1.31 + return self;
1.32 + }
1.33 +
1.34 +EXPORT_C CEglTestCommonIniSettings* CEglTestCommonIniSettings::NewLC()
1.35 + {
1.36 + CEglTestCommonIniSettings* self = new(ELeave) CEglTestCommonIniSettings;
1.37 + CleanupStack::PushL(self);
1.38 + self->ConstructL();
1.39 + return self;
1.40 + }
1.41 +
1.42 +void CEglTestCommonIniSettings::ConstructL()
1.43 + {
1.44 + iIniData = CIniData::NewL(KConfigFileName);
1.45 + }
1.46 +
1.47 +EXPORT_C CEglTestCommonIniSettings::~CEglTestCommonIniSettings()
1.48 + {
1.49 + delete iIniData;
1.50 + }
1.51 +
1.52 +EXPORT_C VGImageFormat CEglTestCommonIniSettings::GetVgFormat(const TDesC& aSectioName, const TInt aWhich)
1.53 + {
1.54 + TBuf<20> bufVgPixelFormatNameKey;
1.55 + bufVgPixelFormatNameKey.Format(KKeyFormatX, aWhich);
1.56 + TBuf16<100> bufPixelValue16;
1.57 + TPtrC16 ptrPixelValue16(bufPixelValue16);
1.58 + if(!iIniData->FindVar(aSectioName,bufVgPixelFormatNameKey,ptrPixelValue16))
1.59 + {
1.60 + return VG_IMAGE_FORMAT_INVALID;
1.61 + }
1.62 +
1.63 + _LIT(K565,"VG_sRGB_565");
1.64 + _LIT(KX8888,"VG_sXRGB_8888");
1.65 + _LIT(KA8888,"VG_sARGB_8888");
1.66 + _LIT(KA8888PRE,"VG_sARGB_8888_PRE");
1.67 +
1.68 + if(!ptrPixelValue16.Compare(K565))
1.69 + {
1.70 + return VG_sRGB_565;
1.71 + }
1.72 + if(!ptrPixelValue16.Compare(KX8888))
1.73 + {
1.74 + return VG_sXRGB_8888;
1.75 + }
1.76 + if(!ptrPixelValue16.Compare(KA8888))
1.77 + {
1.78 + return VG_sARGB_8888;
1.79 + }
1.80 + if(!ptrPixelValue16.Compare(KA8888PRE))
1.81 + {
1.82 + return VG_sARGB_8888_PRE;
1.83 + }
1.84 +
1.85 + return VG_IMAGE_FORMAT_INVALID;
1.86 + }
1.87 +
1.88 +EXPORT_C TUidPixelFormat CEglTestCommonIniSettings::GetPixelFormat(const TDesC& aSectioName, const TInt aWhich)
1.89 + {
1.90 + TBuf<20> bufPixelNameKey;
1.91 + bufPixelNameKey.Format(KKeyFormatX, aWhich);
1.92 + TBuf16<100> bufPixelValue16;
1.93 + TPtrC16 ptrPixelValue16(bufPixelValue16);
1.94 + if(!iIniData->FindVar(aSectioName,bufPixelNameKey,ptrPixelValue16))
1.95 + {
1.96 + return EUidPixelFormatUnknown;
1.97 + }
1.98 +
1.99 + _LIT(K565,"EUidPixelFormatRGB_565");
1.100 + _LIT(KX8888,"EUidPixelFormatXRGB_8888");
1.101 + _LIT(KA8888,"EUidPixelFormatARGB_8888");
1.102 + _LIT(KA8888PRE,"EUidPixelFormatARGB_8888_PRE");
1.103 + _LIT(KA8,"EUidPixelFormatA_8");
1.104 +
1.105 + if(!ptrPixelValue16.Compare(K565))
1.106 + {
1.107 + return EUidPixelFormatRGB_565;
1.108 + }
1.109 + if(!ptrPixelValue16.Compare(KX8888))
1.110 + {
1.111 + return EUidPixelFormatXRGB_8888;
1.112 + }
1.113 + if(!ptrPixelValue16.Compare(KA8888))
1.114 + {
1.115 + return EUidPixelFormatARGB_8888;
1.116 + }
1.117 + if(!ptrPixelValue16.Compare(KA8888PRE))
1.118 + {
1.119 + return EUidPixelFormatARGB_8888_PRE;
1.120 + }
1.121 + if(!ptrPixelValue16.Compare(KA8))
1.122 + {
1.123 + return EUidPixelFormatA_8;
1.124 + }
1.125 + return EUidPixelFormatUnknown;
1.126 + }
1.127 +
1.128 +EXPORT_C TInt CEglTestCommonIniSettings::GetNumberOfFormats(const TDesC& aSectioName)
1.129 + {
1.130 + TInt numFormats = 0;
1.131 + if(iIniData->FindVar(aSectioName,KKeyNumFormats,numFormats))
1.132 + {
1.133 + return numFormats;
1.134 + }
1.135 + return 0;
1.136 + }
1.137 +
1.138 +EXPORT_C TInt CEglTestCommonIniSettings::GetNumberOfIterations(const TDesC& aSectioName)
1.139 + {
1.140 + _LIT(KKeyNumIterations, "NumIterations");
1.141 + TInt numIterations = 0;
1.142 + if(iIniData->FindVar(aSectioName, KKeyNumIterations, numIterations))
1.143 + {
1.144 + return numIterations;
1.145 + }
1.146 + return 0;
1.147 + }
1.148 +
1.149 +EXPORT_C TSize CEglTestCommonIniSettings::GetImageSize(const TDesC& aSectioName)
1.150 + {
1.151 + _LIT(KKeyBufferWidth, "ImageWidth");
1.152 + _LIT(KKeyBufferHeight, "ImageHeight");
1.153 + TSize size(0, 0);
1.154 + if(iIniData->FindVar(aSectioName, KKeyBufferWidth, size.iWidth) &&
1.155 + iIniData->FindVar(aSectioName, KKeyBufferHeight, size.iHeight))
1.156 + {
1.157 + return size;
1.158 + }
1.159 + return TSize(0,0);
1.160 + }
1.161 +
1.162 +EXPORT_C TSize CEglTestCommonIniSettings::GetWindowSize(const TDesC& aSectioName)
1.163 + {
1.164 + _LIT(KKeyWindowWidth, "WindowWidth");
1.165 + _LIT(KKeyWindowHeight, "WindowHeight");
1.166 + TSize size(0, 0);
1.167 + if(iIniData->FindVar(aSectioName, KKeyWindowWidth, size.iWidth) &&
1.168 + iIniData->FindVar(aSectioName, KKeyWindowHeight, size.iHeight))
1.169 + {
1.170 + return size;
1.171 + }
1.172 + return TSize(0,0);
1.173 + }
1.174 +
1.175 +EXPORT_C TInt CEglTestCommonIniSettings::GetThresholdGPUUsedMemory(const TDesC& aSectioName)
1.176 + {
1.177 + _LIT(KKeyThresholdGPUUsedMemory, "ThresholdGPUUsedMemory");
1.178 + TInt thresholdGPUUsedMemory = 0;
1.179 + if(iIniData->FindVar(aSectioName, KKeyThresholdGPUUsedMemory, thresholdGPUUsedMemory))
1.180 + {
1.181 + return thresholdGPUUsedMemory;
1.182 + }
1.183 + return 0;
1.184 + }
1.185 +
1.186 +EXPORT_C TInt CEglTestCommonIniSettings::GetThresholdLastIteration(const TDesC& aSectioName)
1.187 + {
1.188 + _LIT(KKeyThresholdLastIteration, "ThresholdLastIteration");
1.189 + TInt thresholdLastIteration = 0;
1.190 + if(iIniData->FindVar(aSectioName, KKeyThresholdLastIteration, thresholdLastIteration))
1.191 + {
1.192 + return thresholdLastIteration;
1.193 + }
1.194 + return 0;
1.195 + }