1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
788 The time to create an aliased font is obtained. |
788 The time to create an aliased font is obtained. |
789 */ |
789 */ |
790 SetTestStepID(_L("GRAPHICS-UI-BENCH-0140")); |
790 SetTestStepID(_L("GRAPHICS-UI-BENCH-0140")); |
791 AliasedFontCreationL(); |
791 AliasedFontCreationL(); |
792 RecordTestResultL(); |
792 RecordTestResultL(); |
|
793 CloseTMSGraphicsStep(); |
793 return TestStepResult(); |
794 return TestStepResult(); |
794 } |
795 } |
795 |
796 |
796 // Measure performance for font duplication |
797 // Measure performance for font duplication |
797 void CTFbsFontHandlePerf::FontDuplicateL() |
798 void CTFbsFontHandlePerf::FontDuplicateL() |
855 // Install the dummy rasterizer. |
856 // Install the dummy rasterizer. |
856 COpenFontRasterizer* dummyRasterizer = CDummyRasterizer::NewL(); |
857 COpenFontRasterizer* dummyRasterizer = CDummyRasterizer::NewL(); |
857 CleanupStack::PushL(dummyRasterizer); |
858 CleanupStack::PushL(dummyRasterizer); |
858 fontStore->InstallRasterizerL(dummyRasterizer); |
859 fontStore->InstallRasterizerL(dummyRasterizer); |
859 CleanupStack::Pop(); |
860 CleanupStack::Pop(); |
860 |
861 |
|
862 // Check font files exist before testing |
|
863 TRAPD(err, DoAddAndRemoveFilesL(aTestOpenFont, fontStore)); |
|
864 if (err != KErrNone) |
|
865 { |
|
866 _LIT(KLog,"Failed to load font files. Error code: %d"); |
|
867 INFO_PRINTF2(KLog,err); |
|
868 User::Leave(err); |
|
869 } |
|
870 |
|
871 // Perform the iterations to test |
861 iProfiler->InitResults(); |
872 iProfiler->InitResults(); |
862 for(TInt count=KIterationsToTest; count>=0; --count) |
873 for(TInt count=KIterationsToTest; count>=0; --count) |
863 { |
874 { |
864 if (aTestOpenFont) |
875 DoAddAndRemoveFilesL(aTestOpenFont, fontStore); |
865 { |
|
866 //Add font files to fontstore |
|
867 TUid id1 = fontStore->AddFileL(KFontDummy); |
|
868 TUid id2 = fontStore->AddFileL(KFontDummy_b); |
|
869 TUid id3 = fontStore->AddFileL(KFontDummy_i); |
|
870 TUid id4 = fontStore->AddFileL(KFontDummy_bi); |
|
871 //Remove font files from fontstore |
|
872 fontStore->RemoveFile(id1); |
|
873 fontStore->RemoveFile(id2); |
|
874 fontStore->RemoveFile(id3); |
|
875 fontStore->RemoveFile(id4); |
|
876 } |
|
877 else |
|
878 { |
|
879 //Add & remove font file to fontstore |
|
880 TUid id1=TUid::Null(); |
|
881 TRAPD(err,id1=fontStore->AddFileL(KBitmapFont)); |
|
882 if (err!=KErrNone) |
|
883 { |
|
884 _LIT(KLog,"Loading font file %S gave error %d"); |
|
885 INFO_PRINTF3(KLog,&KBitmapFont,err); |
|
886 User::Leave(err); |
|
887 } |
|
888 fontStore->RemoveFile(id1); |
|
889 // total of 4 times, for comparison with Open Font test |
|
890 TUid id2 = fontStore->AddFileL(KBitmapFont); |
|
891 fontStore->RemoveFile(id2); |
|
892 TUid id3 = fontStore->AddFileL(KBitmapFont); |
|
893 fontStore->RemoveFile(id3); |
|
894 TUid id4 = fontStore->AddFileL(KBitmapFont); |
|
895 fontStore->RemoveFile(id4); |
|
896 } |
|
897 |
|
898 iProfiler->MarkResultSetL(); |
876 iProfiler->MarkResultSetL(); |
899 } |
877 } |
|
878 |
900 TInt64 duration=iProfiler->GetTrimedMean(); |
879 TInt64 duration=iProfiler->GetTrimedMean(); |
901 if (aTestOpenFont) |
880 if (aTestOpenFont) |
902 { |
881 { |
903 iProfiler->ResultsAnalysis(KAddRemoveOpenFontFiles, 0, 0, 0, KIterationsToTest); |
882 iProfiler->ResultsAnalysis(KAddRemoveOpenFontFiles, 0, 0, 0, KIterationsToTest); |
904 } |
883 } |
908 } |
887 } |
909 CleanupStack::PopAndDestroy(fontStore); |
888 CleanupStack::PopAndDestroy(fontStore); |
910 |
889 |
911 heap->Close(); |
890 heap->Close(); |
912 } |
891 } |
|
892 |
|
893 // Do the add and removing files. |
|
894 void CTFbsFontHandlePerf::DoAddAndRemoveFilesL(TBool aTestOpenFont, CFontStore* aFontStore) |
|
895 { |
|
896 if (aTestOpenFont) |
|
897 { |
|
898 //Add font files to fontstore |
|
899 TUid id1 = aFontStore->AddFileL(KFontDummy); |
|
900 TUid id2 = aFontStore->AddFileL(KFontDummy_b); |
|
901 TUid id3 = aFontStore->AddFileL(KFontDummy_i); |
|
902 TUid id4 = aFontStore->AddFileL(KFontDummy_bi); |
|
903 //Remove font files from fontstore |
|
904 aFontStore->RemoveFile(id1); |
|
905 aFontStore->RemoveFile(id2); |
|
906 aFontStore->RemoveFile(id3); |
|
907 aFontStore->RemoveFile(id4); |
|
908 } |
|
909 else |
|
910 { |
|
911 //Add & remove font file to fontstore a total of 4 times, for comparison with Open Font test |
|
912 TUid id1 = aFontStore->AddFileL(KBitmapFont); |
|
913 aFontStore->RemoveFile(id1); |
|
914 TUid id2 = aFontStore->AddFileL(KBitmapFont); |
|
915 aFontStore->RemoveFile(id2); |
|
916 TUid id3 = aFontStore->AddFileL(KBitmapFont); |
|
917 aFontStore->RemoveFile(id3); |
|
918 TUid id4 = aFontStore->AddFileL(KBitmapFont); |
|
919 aFontStore->RemoveFile(id4); |
|
920 } |
|
921 } |
913 |
922 |
914 // Add fontfile that is already opened. |
923 // Add fontfile that is already opened. |
915 void CTFbsFontHandlePerf::AddingOpenedFontFilesL(TBool aTestOpenFont) |
924 void CTFbsFontHandlePerf::AddingOpenedFontFilesL(TBool aTestOpenFont) |
916 { |
925 { |
917 RHeap* heap = UserHeap::ChunkHeap(NULL,0x10000,0x10000); |
926 RHeap* heap = UserHeap::ChunkHeap(NULL,0x10000,0x10000); |