17 @file |
17 @file |
18 @test |
18 @test |
19 @internalComponent - Internal Symbian test code |
19 @internalComponent - Internal Symbian test code |
20 */ |
20 */ |
21 |
21 |
|
22 #include <test/graphicsfontutils.h> |
22 #include <graphics/fbsglyphdataiterator.h> |
23 #include <graphics/fbsglyphdataiterator.h> |
23 #include <graphics/fbsglyphmetricsarray.h> |
24 #include <graphics/fbsglyphmetricsarray.h> |
24 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
25 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
25 #include <sgresource/sgimage.h> |
26 #include <sgresource/sgimage.h> |
26 #include <egl/egl.h> |
27 #include <egl/egl.h> |
27 #include <vg/openvg.h> |
28 #include <vg/openvg.h> |
28 typedef EGLBoolean (*TvgCreateEGLImageTargetKHRTypefPtr) (VGeglImageKHR image); |
29 typedef EGLBoolean (*TvgCreateEGLImageTargetKHRTypefPtr) (VGeglImageKHR image); |
29 #endif |
30 #endif |
30 #include "tfbsglyphdata.h" |
31 #include "tfbsglyphdata.h" |
31 |
32 |
32 // When defined Hindi language tests are not run. |
|
33 #define UIBENCH_NO_HINDI |
|
34 |
|
35 // Size of EGLSurface used for rendering to, in pixels. |
33 // Size of EGLSurface used for rendering to, in pixels. |
36 const TSize KEglTargetSize(512, 512); |
34 const TSize KEglTargetSize(512, 512); |
37 |
35 |
38 CTFbsGlyphData::CTFbsGlyphData() |
36 CTFbsGlyphData::CTFbsGlyphData() |
39 { |
37 { |
74 |
75 |
75 SetTestStepID(_L("GRAPHICS-UI-BENCH-0179")); |
76 SetTestStepID(_L("GRAPHICS-UI-BENCH-0179")); |
76 GlyphMetricsArrayL(ETestLanguageLatin, EFalse, 50000); |
77 GlyphMetricsArrayL(ETestLanguageLatin, EFalse, 50000); |
77 RecordTestResultL(); |
78 RecordTestResultL(); |
78 |
79 |
79 #ifndef UIBENCH_NO_HINDI |
|
80 // Tests 180 and 181 require a CMap table in order to convert CharacterCodes to GlyphCodes. |
80 // Tests 180 and 181 require a CMap table in order to convert CharacterCodes to GlyphCodes. |
81 SetTestStepID(_L("GRAPHICS-UI-BENCH-0180")); |
81 SetTestStepID(_L("GRAPHICS-UI-BENCH-0180")); |
82 GlyphMetricsArrayL(ETestLanguageHindi, ETrue, 25); |
82 GlyphMetricsArrayL(ETestLanguageHindi, ETrue, 25); |
83 RecordTestResultL(); |
83 RecordTestResultL(); |
84 |
84 |
85 SetTestStepID(_L("GRAPHICS-UI-BENCH-0181")); |
85 SetTestStepID(_L("GRAPHICS-UI-BENCH-0181")); |
86 GlyphMetricsArrayL(ETestLanguageHindi, EFalse, 50000); |
86 GlyphMetricsArrayL(ETestLanguageHindi, EFalse, 50000); |
87 RecordTestResultL(); |
87 RecordTestResultL(); |
88 #endif |
|
89 |
88 |
90 SetTestStepID(_L("GRAPHICS-UI-BENCH-0182")); |
89 SetTestStepID(_L("GRAPHICS-UI-BENCH-0182")); |
91 GlyphMetricsQuerySingleGlyphL(); |
90 GlyphMetricsQuerySingleGlyphL(); |
92 RecordTestResultL(); |
91 RecordTestResultL(); |
93 |
92 |
97 |
96 |
98 SetTestStepID(_L("GRAPHICS-UI-BENCH-0184")); |
97 SetTestStepID(_L("GRAPHICS-UI-BENCH-0184")); |
99 GlyphDataIteratorOpenL(ETestLanguageLatin, EFalse, 500); |
98 GlyphDataIteratorOpenL(ETestLanguageLatin, EFalse, 500); |
100 RecordTestResultL(); |
99 RecordTestResultL(); |
101 |
100 |
102 #ifndef UIBENCH_NO_HINDI |
|
103 // Tests 185 and 186 require a CMap table in order to convert CharacterCodes to GlyphCodes. |
101 // Tests 185 and 186 require a CMap table in order to convert CharacterCodes to GlyphCodes. |
104 SetTestStepID(_L("GRAPHICS-UI-BENCH-0185")); |
102 SetTestStepID(_L("GRAPHICS-UI-BENCH-0185")); |
105 GlyphDataIteratorOpenL(ETestLanguageHindi, ETrue, 10); |
103 GlyphDataIteratorOpenL(ETestLanguageHindi, ETrue, 10); |
106 RecordTestResultL(); |
104 RecordTestResultL(); |
107 |
105 |
108 SetTestStepID(_L("GRAPHICS-UI-BENCH-0186")); |
106 SetTestStepID(_L("GRAPHICS-UI-BENCH-0186")); |
109 GlyphDataIteratorOpenL(ETestLanguageHindi, EFalse, 5000); |
107 GlyphDataIteratorOpenL(ETestLanguageHindi, EFalse, 5000); |
110 RecordTestResultL(); |
108 RecordTestResultL(); |
111 #endif |
|
112 |
109 |
113 SetTestStepID(_L("GRAPHICS-UI-BENCH-0187")); |
110 SetTestStepID(_L("GRAPHICS-UI-BENCH-0187")); |
114 GlyphDataIteratorOpenSingleFontL(); |
111 GlyphDataIteratorOpenSingleFontL(); |
115 RecordTestResultL(); |
112 RecordTestResultL(); |
116 |
113 |
344 void CTFbsGlyphData::GlyphDataIteratorOpenSingleFontL() |
341 void CTFbsGlyphData::GlyphDataIteratorOpenSingleFontL() |
345 { |
342 { |
346 _LIT(KTestName, "GlyphDataIteratorOpenSingleFont"); |
343 _LIT(KTestName, "GlyphDataIteratorOpenSingleFont"); |
347 // A cap on the max number of iterations to complete. |
344 // A cap on the max number of iterations to complete. |
348 const TInt KMaxNumIterations = 200; |
345 const TInt KMaxNumIterations = 200; |
349 #ifndef UIBENCH_NO_HINDI |
|
350 const TTestLanguage KTestLanguage = ETestLanguageHindi; |
346 const TTestLanguage KTestLanguage = ETestLanguageHindi; |
351 #else |
|
352 const TTestLanguage KTestLanguage = ETestLanguageLatin; |
|
353 #endif |
|
354 |
347 |
355 // Create some test fonts using the font factory. |
348 // Create some test fonts using the font factory. |
356 CTFontFactory* fontFactory = CTFontFactory::NewLC(); |
349 CTFontFactory* fontFactory = CTFontFactory::NewLC(); |
357 fontFactory->CreateFontsL(KTestLanguage, 1); |
350 fontFactory->CreateFontsL(KTestLanguage, 1); |
358 CFbsFont* font = fontFactory->NextFont(); |
351 CFbsFont* font = fontFactory->NextFont(); |
359 |
352 |
360 // Load the sample string data from the config file. |
353 // Load the sample string data from the config file. |
361 TInt numGlyphCodes = 0; |
354 TInt numGlyphCodes = 0; |
362 TUint* glyphCodes; |
355 TUint* glyphCodes; |
363 LoadConfigSampleDataL(KTestLanguage, ETrue, glyphCodes, numGlyphCodes); |
356 LoadConfigSampleDataL(font, KTestLanguage, ETrue, glyphCodes, numGlyphCodes); |
364 |
357 |
365 const TInt KNumRepetitions = Min<TInt>(numGlyphCodes - 1, KMaxNumIterations); |
358 const TInt KNumRepetitions = Min<TInt>(numGlyphCodes - 1, KMaxNumIterations); |
366 RFbsGlyphDataIterator iter; |
359 RFbsGlyphDataIterator iter; |
367 CleanupClosePushL(iter); |
360 CleanupClosePushL(iter); |
368 TInt iterErr = KErrNone; |
361 TInt iterErr = KErrNone; |
418 get their metrics information. |
411 get their metrics information. |
419 */ |
412 */ |
420 void CTFbsGlyphData::GlyphMetricsQueryUnrasterizedL() |
413 void CTFbsGlyphData::GlyphMetricsQueryUnrasterizedL() |
421 { |
414 { |
422 _LIT(KTestName, "GlyphMetricsQueryUnrasterized"); |
415 _LIT(KTestName, "GlyphMetricsQueryUnrasterized"); |
|
416 |
423 TBuf<128> KTestNameVariant; |
417 TBuf<128> KTestNameVariant; |
|
418 // First do the test for the iterator. To ensure fair comparison with |
|
419 // RFbsGlyphMetricsArray, cycle through each iteration to ensure the metrics |
|
420 // for each glyph is found. |
|
421 KTestNameVariant.Format(_L("%S RFbsGlyphDataIterator"), &KTestName); |
|
422 |
424 const TInt KNumFonts = 50; |
423 const TInt KNumFonts = 50; |
425 const TTestLanguage KTestLanguage = ETestLanguageLatin; |
424 const TTestLanguage KTestLanguage = ETestLanguageLatin; |
426 |
425 |
|
426 // Create some test fonts using the font factory. |
|
427 CTFontFactory* fontFactory = CTFontFactory::NewLC(); |
|
428 fontFactory->CreateFontsL(KTestLanguage, KNumFonts); |
|
429 |
427 // Load the sample string data from the config file. Both the iterator and the |
430 // Load the sample string data from the config file. Both the iterator and the |
428 // array will use this same sample data. |
431 // array will use this same sample data. |
429 TInt numGlyphCodes = 0; |
432 TInt numGlyphCodes = 0; |
430 TUint* glyphCodes; |
433 TUint* glyphCodes; |
431 LoadConfigSampleDataL(KTestLanguage, ETrue, glyphCodes, numGlyphCodes); |
434 LoadConfigSampleDataL(fontFactory->NextFont(), KTestLanguage, ETrue, glyphCodes, numGlyphCodes); |
432 |
435 |
433 // Create some test fonts using the font factory. |
|
434 CTFontFactory* fontFactory = CTFontFactory::NewLC(); |
|
435 |
|
436 // First do the test for the iterator. To ensure fair comparison with |
|
437 // RFbsGlyphMetricsArray, cycle through each iteration to ensure the metrics |
|
438 // for each glyph is found. |
|
439 KTestNameVariant.Format(_L("%S RFbsGlyphDataIterator"), &KTestName); |
|
440 fontFactory->CreateFontsL(KTestLanguage, KNumFonts); |
|
441 RFbsGlyphDataIterator iter; |
436 RFbsGlyphDataIterator iter; |
442 CleanupClosePushL(iter); |
437 CleanupClosePushL(iter); |
443 TInt iterErr = KErrNone; |
438 TInt iterErr = KErrNone; |
444 TInt rep = 0; |
439 TInt rep = 0; |
445 iProfiler->InitResults(); |
440 iProfiler->InitResults(); |
536 { |
531 { |
537 _LIT(KTestName, "GlyphMetricsQueryPreRasterized"); |
532 _LIT(KTestName, "GlyphMetricsQueryPreRasterized"); |
538 TBuf<128> KTestNameVariant; |
533 TBuf<128> KTestNameVariant; |
539 const TInt KNumIterations = 500; |
534 const TInt KNumIterations = 500; |
540 const TTestLanguage KTestLanguage = ETestLanguageLatin; |
535 const TTestLanguage KTestLanguage = ETestLanguageLatin; |
541 |
536 |
542 TInt numGlyphCodes = 0; |
537 // Create a test font using the font factory. |
|
538 CTFontFactory* fontFactory = CTFontFactory::NewLC(); |
|
539 fontFactory->CreateFontsL(ETestLanguageLatin, 1); |
|
540 CFbsFont* font = fontFactory->NextFont(); |
|
541 |
|
542 TInt numGlyphCodes = 0; |
543 TUint* glyphCodes; |
543 TUint* glyphCodes; |
544 LoadConfigSampleDataL(KTestLanguage, ETrue, glyphCodes, numGlyphCodes); |
544 LoadConfigSampleDataL(font, KTestLanguage, ETrue, glyphCodes, numGlyphCodes); |
545 |
|
546 // Create a test font using the font factory. |
|
547 CTFontFactory* fontFactory = CTFontFactory::NewLC(); |
|
548 fontFactory->CreateFontsL(ETestLanguageLatin, 1); |
|
549 CFbsFont* font = fontFactory->NextFont(); |
|
550 |
545 |
551 TInt iterErr = KErrNone; |
546 TInt iterErr = KErrNone; |
552 TInt rep = 0; |
547 TInt rep = 0; |
553 // Rasterize the glyphs first. |
548 // Rasterize the glyphs first. |
554 RFbsGlyphDataIterator iter; |
549 RFbsGlyphDataIterator iter; |
656 */ |
651 */ |
657 void CTFbsGlyphData::GlyphRenderingL() |
652 void CTFbsGlyphData::GlyphRenderingL() |
658 { |
653 { |
659 _LIT(KTestName, "GlyphRendering"); |
654 _LIT(KTestName, "GlyphRendering"); |
660 const TInt KNumIterations = 500; |
655 const TInt KNumIterations = 500; |
661 #ifndef UIBENCH_NO_HINDI |
|
662 const TTestLanguage KTestLanguage = ETestLanguageHindi; |
656 const TTestLanguage KTestLanguage = ETestLanguageHindi; |
663 #else |
|
664 const TTestLanguage KTestLanguage = ETestLanguageLatin; |
|
665 #endif |
|
666 |
657 |
667 // Create some test fonts using the font factory. |
658 // Create some test fonts using the font factory. |
668 CTFontFactory* fontFactory = CTFontFactory::NewLC(); |
659 CTFontFactory* fontFactory = CTFontFactory::NewLC(); |
669 fontFactory->CreateFontsL(KTestLanguage, 1, 20); |
660 fontFactory->CreateFontsL(KTestLanguage, 1, 20); |
670 CFbsFont* font = fontFactory->NextFont(); |
661 CFbsFont* font = fontFactory->NextFont(); |
825 CFbsBitmap* CTFbsGlyphData::GetTargetAsBitmapL() |
816 CFbsBitmap* CTFbsGlyphData::GetTargetAsBitmapL() |
826 { |
817 { |
827 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
818 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
828 // For debugging purposes only. |
819 // For debugging purposes only. |
829 // Capture the final state of the EGL Pixmap surface as an mbm. |
820 // Capture the final state of the EGL Pixmap surface as an mbm. |
830 TSize KTargetSize; |
|
831 const TSize KBufferSize = KEglTargetSize; |
|
832 const TInt KDataStride = KEglTargetSize.iWidth; |
821 const TInt KDataStride = KEglTargetSize.iWidth; |
833 |
822 |
834 TUint8* imageBuffer = reinterpret_cast<TUint8*>(User::AllocZ(KBufferSize.iHeight * KDataStride)); |
823 TUint8* imageScanline = reinterpret_cast<TUint8*>(User::AllocZL(KDataStride)); |
|
824 CleanupStack::PushL(imageScanline); |
835 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); |
825 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); |
836 CleanupStack::PushL(bitmap); |
826 CleanupStack::PushL(bitmap); |
837 User::LeaveIfError(bitmap->Create(KBufferSize, EGray256)); |
827 User::LeaveIfError(bitmap->Create(KEglTargetSize, EGray256)); |
838 vgReadPixels(imageBuffer, KDataStride, VG_A_8, 0, 0, KBufferSize.iWidth, KBufferSize.iHeight); |
|
839 TUint8* buf = imageBuffer; |
|
840 bitmap->BeginDataAccess(); |
828 bitmap->BeginDataAccess(); |
841 TUint8* dataAddress = reinterpret_cast<TUint8*>(bitmap->DataAddress()); |
829 TUint8* dataAddress = reinterpret_cast<TUint8*>(bitmap->DataAddress()); |
842 const TInt dataStride = bitmap->DataStride(); |
830 const TInt dataStride = bitmap->DataStride(); |
843 for (TInt scanline = 0; scanline < KBufferSize.iHeight; scanline++) |
831 for (TInt scanline = 0; scanline < KEglTargetSize.iHeight; scanline++) |
844 { |
832 { |
845 Mem::Copy(dataAddress, buf, KBufferSize.iWidth); |
833 vgReadPixels(imageScanline, KDataStride, VG_A_8, 0, scanline, KEglTargetSize.iWidth, 1); |
|
834 Mem::Copy(dataAddress, imageScanline, KEglTargetSize.iWidth); |
846 dataAddress += dataStride; |
835 dataAddress += dataStride; |
847 buf += KBufferSize.iWidth; |
|
848 } |
836 } |
849 bitmap->EndDataAccess(EFalse); |
837 bitmap->EndDataAccess(EFalse); |
850 User::Free(imageBuffer); |
838 CleanupStack::Pop(2); // bitmap, imageScanline |
851 CleanupStack::Pop(1); // bitmap |
|
852 return bitmap; |
839 return bitmap; |
853 #else |
840 #else |
854 return NULL; |
841 return NULL; |
855 #endif |
842 #endif |
856 } |
843 } |
857 |
844 |
858 /** |
845 /** |
859 Utility method. Loads sample glyph code data from the config ini file |
846 Utility method. Loads sample glyph code data from the config ini file |
860 into a TUint array. |
847 into a TUint array. |
861 @param aKey The key string to look for when loading the sample data from the config file |
848 @param aFont The font that the glyph codes will be associated with. |
|
849 @param aLanguage The language variant to load from the config file as sample data. |
|
850 @param aLongData Whether to use the long variant (ETrue) or short variant (EFalse) |
|
851 of the sample data for the given language. |
862 @param aGlyphCodes On success, holds an array of glyph codes, to be freed by the caller. |
852 @param aGlyphCodes On success, holds an array of glyph codes, to be freed by the caller. |
863 @param aNumGlyphCodes On success, holds the count of the glyph code array. |
853 @param aNumGlyphCodes On success, holds the count of the glyph code array. |
864 @leave KErrNotFound if the test data cannot be found or is empty in the config file. |
854 @leave KErrNotFound if the test data cannot be found or is empty in the config file. |
865 */ |
855 */ |
866 void CTFbsGlyphData::LoadConfigSampleDataL(TTestLanguage aLanguage, TBool aLongData, TUint*& aGlyphCodes, TInt& aNumGlyphCodes) |
856 void CTFbsGlyphData::LoadConfigSampleDataL(CFbsFont* aFont, TTestLanguage aLanguage, TBool aLongData, TUint*& aGlyphCodes, TInt& aNumGlyphCodes) |
867 { |
857 { |
868 // The name of the section in the config file to look-up the sample data |
858 // The name of the section in the config file to look-up the sample data |
869 _LIT(KConfigFileSampleData, "GlyphDataSampleText"); |
859 _LIT(KConfigFileSampleData, "GlyphDataSampleText"); |
870 |
860 |
871 TBuf<32> keyName = ConfigKeyNameL(aLanguage, aLongData); |
861 TBuf<32> keyName = ConfigKeyNameL(aLanguage, aLongData); |
872 |
862 |
|
863 // Setup the converter to use the passed font. |
|
864 iCharCodeConverter->UseFontL(aFont); |
|
865 |
873 // Load the sample string data from the config file. |
866 // Load the sample string data from the config file. |
874 TPtrC sampleText; |
867 TPtrC sampleText; |
875 TESTL(GetStringFromConfig(KConfigFileSampleData, keyName, sampleText)); |
868 TESTL(GetStringFromConfig(KConfigFileSampleData, keyName, sampleText)); |
876 aNumGlyphCodes = sampleText.Length(); |
869 aNumGlyphCodes = sampleText.Length(); |
877 if (aNumGlyphCodes <= 0) |
870 if (aNumGlyphCodes <= 0) |