--- a/graphicstest/uibench/src/tfbsglyphdata.cpp Tue Jul 20 13:27:44 2010 +0300
+++ b/graphicstest/uibench/src/tfbsglyphdata.cpp Fri Jul 30 11:41:40 2010 +0300
@@ -19,6 +19,7 @@
@internalComponent - Internal Symbian test code
*/
+#include <test/graphicsfontutils.h>
#include <graphics/fbsglyphdataiterator.h>
#include <graphics/fbsglyphmetricsarray.h>
#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
@@ -29,9 +30,6 @@
#endif
#include "tfbsglyphdata.h"
-// When defined Hindi language tests are not run.
-#define UIBENCH_NO_HINDI
-
// Size of EGLSurface used for rendering to, in pixels.
const TSize KEglTargetSize(512, 512);
@@ -50,11 +48,14 @@
User::LeaveIfError(iFbs.Connect());
User::LeaveIfError(iSgDriver.Open());
#endif
+ iCharCodeConverter = CCharCodeConverter::NewL();
return CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
}
TVerdict CTFbsGlyphData::doTestStepPostambleL()
{
+ delete iCharCodeConverter;
+ iCharCodeConverter = NULL;
#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
iSgDriver.Close();
iFbs.Disconnect();
@@ -76,7 +77,6 @@
GlyphMetricsArrayL(ETestLanguageLatin, EFalse, 50000);
RecordTestResultL();
-#ifndef UIBENCH_NO_HINDI
// Tests 180 and 181 require a CMap table in order to convert CharacterCodes to GlyphCodes.
SetTestStepID(_L("GRAPHICS-UI-BENCH-0180"));
GlyphMetricsArrayL(ETestLanguageHindi, ETrue, 25);
@@ -85,7 +85,6 @@
SetTestStepID(_L("GRAPHICS-UI-BENCH-0181"));
GlyphMetricsArrayL(ETestLanguageHindi, EFalse, 50000);
RecordTestResultL();
-#endif
SetTestStepID(_L("GRAPHICS-UI-BENCH-0182"));
GlyphMetricsQuerySingleGlyphL();
@@ -99,7 +98,6 @@
GlyphDataIteratorOpenL(ETestLanguageLatin, EFalse, 500);
RecordTestResultL();
-#ifndef UIBENCH_NO_HINDI
// Tests 185 and 186 require a CMap table in order to convert CharacterCodes to GlyphCodes.
SetTestStepID(_L("GRAPHICS-UI-BENCH-0185"));
GlyphDataIteratorOpenL(ETestLanguageHindi, ETrue, 10);
@@ -108,7 +106,6 @@
SetTestStepID(_L("GRAPHICS-UI-BENCH-0186"));
GlyphDataIteratorOpenL(ETestLanguageHindi, EFalse, 5000);
RecordTestResultL();
-#endif
SetTestStepID(_L("GRAPHICS-UI-BENCH-0187"));
GlyphDataIteratorOpenSingleFontL();
@@ -169,7 +166,7 @@
// Load the sample string data from the config file.
TInt numGlyphCodes = 0;
TUint* glyphCodes;
- LoadConfigSampleDataL(aLanguage, aLongData, glyphCodes, numGlyphCodes);
+ LoadConfigSampleDataL(fontFactory->NextFont(), aLanguage, aLongData, glyphCodes, numGlyphCodes);
// Run the test.
TInt err = KErrNone;
@@ -294,7 +291,7 @@
// Load the sample string data from the config file.
TInt numGlyphCodes = 0;
TUint* glyphCodes;
- LoadConfigSampleDataL(aLanguage, aLongData, glyphCodes, numGlyphCodes);
+ LoadConfigSampleDataL(fontFactory->NextFont(), aLanguage, aLongData, glyphCodes, numGlyphCodes);
// Run the test.
TInt err = KErrNotFound;
@@ -346,11 +343,7 @@
_LIT(KTestName, "GlyphDataIteratorOpenSingleFont");
// A cap on the max number of iterations to complete.
const TInt KMaxNumIterations = 200;
-#ifndef UIBENCH_NO_HINDI
const TTestLanguage KTestLanguage = ETestLanguageHindi;
-#else
- const TTestLanguage KTestLanguage = ETestLanguageLatin;
-#endif
// Create some test fonts using the font factory.
CTFontFactory* fontFactory = CTFontFactory::NewLC();
@@ -360,7 +353,7 @@
// Load the sample string data from the config file.
TInt numGlyphCodes = 0;
TUint* glyphCodes;
- LoadConfigSampleDataL(KTestLanguage, ETrue, glyphCodes, numGlyphCodes);
+ LoadConfigSampleDataL(font, KTestLanguage, ETrue, glyphCodes, numGlyphCodes);
const TInt KNumRepetitions = Min<TInt>(numGlyphCodes - 1, KMaxNumIterations);
RFbsGlyphDataIterator iter;
@@ -420,24 +413,26 @@
void CTFbsGlyphData::GlyphMetricsQueryUnrasterizedL()
{
_LIT(KTestName, "GlyphMetricsQueryUnrasterized");
+
TBuf<128> KTestNameVariant;
+ // First do the test for the iterator. To ensure fair comparison with
+ // RFbsGlyphMetricsArray, cycle through each iteration to ensure the metrics
+ // for each glyph is found.
+ KTestNameVariant.Format(_L("%S RFbsGlyphDataIterator"), &KTestName);
+
const TInt KNumFonts = 50;
const TTestLanguage KTestLanguage = ETestLanguageLatin;
+ // Create some test fonts using the font factory.
+ CTFontFactory* fontFactory = CTFontFactory::NewLC();
+ fontFactory->CreateFontsL(KTestLanguage, KNumFonts);
+
// Load the sample string data from the config file. Both the iterator and the
// array will use this same sample data.
TInt numGlyphCodes = 0;
TUint* glyphCodes;
- LoadConfigSampleDataL(KTestLanguage, ETrue, glyphCodes, numGlyphCodes);
-
- // Create some test fonts using the font factory.
- CTFontFactory* fontFactory = CTFontFactory::NewLC();
+ LoadConfigSampleDataL(fontFactory->NextFont(), KTestLanguage, ETrue, glyphCodes, numGlyphCodes);
- // First do the test for the iterator. To ensure fair comparison with
- // RFbsGlyphMetricsArray, cycle through each iteration to ensure the metrics
- // for each glyph is found.
- KTestNameVariant.Format(_L("%S RFbsGlyphDataIterator"), &KTestName);
- fontFactory->CreateFontsL(KTestLanguage, KNumFonts);
RFbsGlyphDataIterator iter;
CleanupClosePushL(iter);
TInt iterErr = KErrNone;
@@ -538,15 +533,15 @@
TBuf<128> KTestNameVariant;
const TInt KNumIterations = 500;
const TTestLanguage KTestLanguage = ETestLanguageLatin;
-
- TInt numGlyphCodes = 0;
+
+ // Create a test font using the font factory.
+ CTFontFactory* fontFactory = CTFontFactory::NewLC();
+ fontFactory->CreateFontsL(ETestLanguageLatin, 1);
+ CFbsFont* font = fontFactory->NextFont();
+
+ TInt numGlyphCodes = 0;
TUint* glyphCodes;
- LoadConfigSampleDataL(KTestLanguage, ETrue, glyphCodes, numGlyphCodes);
-
- // Create a test font using the font factory.
- CTFontFactory* fontFactory = CTFontFactory::NewLC();
- fontFactory->CreateFontsL(ETestLanguageLatin, 1);
- CFbsFont* font = fontFactory->NextFont();
+ LoadConfigSampleDataL(font, KTestLanguage, ETrue, glyphCodes, numGlyphCodes);
TInt iterErr = KErrNone;
TInt rep = 0;
@@ -658,11 +653,7 @@
{
_LIT(KTestName, "GlyphRendering");
const TInt KNumIterations = 500;
-#ifndef UIBENCH_NO_HINDI
const TTestLanguage KTestLanguage = ETestLanguageHindi;
-#else
- const TTestLanguage KTestLanguage = ETestLanguageLatin;
-#endif
// Create some test fonts using the font factory.
CTFontFactory* fontFactory = CTFontFactory::NewLC();
@@ -748,7 +739,7 @@
TInt numGlyphCodes = 0;
TUint* glyphCodes;
- LoadConfigSampleDataL(KTestLanguage, EFalse, glyphCodes, numGlyphCodes);
+ LoadConfigSampleDataL(font, KTestLanguage, EFalse, glyphCodes, numGlyphCodes);
// Set up an identity matrix compatible with the Symbian co-ordinate system.
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
@@ -827,28 +818,24 @@
#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
// For debugging purposes only.
// Capture the final state of the EGL Pixmap surface as an mbm.
- TSize KTargetSize;
- const TSize KBufferSize = KEglTargetSize;
const TInt KDataStride = KEglTargetSize.iWidth;
-
- TUint8* imageBuffer = reinterpret_cast<TUint8*>(User::AllocZ(KBufferSize.iHeight * KDataStride));
+
+ TUint8* imageScanline = reinterpret_cast<TUint8*>(User::AllocZL(KDataStride));
+ CleanupStack::PushL(imageScanline);
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
CleanupStack::PushL(bitmap);
- User::LeaveIfError(bitmap->Create(KBufferSize, EGray256));
- vgReadPixels(imageBuffer, KDataStride, VG_A_8, 0, 0, KBufferSize.iWidth, KBufferSize.iHeight);
- TUint8* buf = imageBuffer;
+ User::LeaveIfError(bitmap->Create(KEglTargetSize, EGray256));
bitmap->BeginDataAccess();
TUint8* dataAddress = reinterpret_cast<TUint8*>(bitmap->DataAddress());
const TInt dataStride = bitmap->DataStride();
- for (TInt scanline = 0; scanline < KBufferSize.iHeight; scanline++)
+ for (TInt scanline = 0; scanline < KEglTargetSize.iHeight; scanline++)
{
- Mem::Copy(dataAddress, buf, KBufferSize.iWidth);
+ vgReadPixels(imageScanline, KDataStride, VG_A_8, 0, scanline, KEglTargetSize.iWidth, 1);
+ Mem::Copy(dataAddress, imageScanline, KEglTargetSize.iWidth);
dataAddress += dataStride;
- buf += KBufferSize.iWidth;
}
bitmap->EndDataAccess(EFalse);
- User::Free(imageBuffer);
- CleanupStack::Pop(1); // bitmap
+ CleanupStack::Pop(2); // bitmap, imageScanline
return bitmap;
#else
return NULL;
@@ -858,18 +845,24 @@
/**
Utility method. Loads sample glyph code data from the config ini file
into a TUint array.
-@param aKey The key string to look for when loading the sample data from the config file
+@param aFont The font that the glyph codes will be associated with.
+@param aLanguage The language variant to load from the config file as sample data.
+@param aLongData Whether to use the long variant (ETrue) or short variant (EFalse)
+ of the sample data for the given language.
@param aGlyphCodes On success, holds an array of glyph codes, to be freed by the caller.
@param aNumGlyphCodes On success, holds the count of the glyph code array.
@leave KErrNotFound if the test data cannot be found or is empty in the config file.
*/
-void CTFbsGlyphData::LoadConfigSampleDataL(TTestLanguage aLanguage, TBool aLongData, TUint*& aGlyphCodes, TInt& aNumGlyphCodes)
+void CTFbsGlyphData::LoadConfigSampleDataL(CFbsFont* aFont, TTestLanguage aLanguage, TBool aLongData, TUint*& aGlyphCodes, TInt& aNumGlyphCodes)
{
// The name of the section in the config file to look-up the sample data
_LIT(KConfigFileSampleData, "GlyphDataSampleText");
-
+
TBuf<32> keyName = ConfigKeyNameL(aLanguage, aLongData);
+ // Setup the converter to use the passed font.
+ iCharCodeConverter->UseFontL(aFont);
+
// Load the sample string data from the config file.
TPtrC sampleText;
TESTL(GetStringFromConfig(KConfigFileSampleData, keyName, sampleText));
@@ -881,7 +874,7 @@
aGlyphCodes = new(ELeave) TUint[aNumGlyphCodes];
for (TInt code = 0; code < aNumGlyphCodes; ++code)
{
- aGlyphCodes[code] = sampleText[code];
+ aGlyphCodes[code] = iCharCodeConverter->GlyphCodeL(sampleText[code]);
}
}