|
1 // Copyright (c) 2005-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 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "tshadowperf.h" |
|
23 |
|
24 const TInt KIterationsToTest = 250; // Number of iterations to run tests |
|
25 |
|
26 //The 16 bit mbm file |
|
27 _LIT(Kmbm16bpp, "z:\\system\\data\\uibench_16bit.mbm"); |
|
28 |
|
29 CTShadowPerf::~CTShadowPerf() |
|
30 { |
|
31 } |
|
32 |
|
33 CTShadowPerf::CTShadowPerf() |
|
34 { |
|
35 SetTestStepName(KTShadowPerfName); |
|
36 } |
|
37 |
|
38 /** |
|
39 Override of base class virtual |
|
40 |
|
41 @return - TVerdict code |
|
42 */ |
|
43 TVerdict CTShadowPerf::doTestStepPreambleL() |
|
44 { |
|
45 CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL(); |
|
46 |
|
47 return TestStepResult(); |
|
48 } |
|
49 |
|
50 /** |
|
51 Override of base class pure virtual |
|
52 Our implementation only gets called if the base class doTestStepPreambleL() did |
|
53 not leave. That being the case, the current test result value will be EPass. |
|
54 |
|
55 @return - TVerdict code |
|
56 */ |
|
57 TVerdict CTShadowPerf::doTestStepL() |
|
58 { |
|
59 SetTestStepID(_L("GRAPHICS-UI-BENCH-0046")); |
|
60 ShadowAreaL(); |
|
61 RecordTestResultL(); |
|
62 SetTestStepID(_L("GRAPHICS-UI-BENCH-0047")); |
|
63 FadeAreaL(); |
|
64 RecordTestResultL(); |
|
65 SetTestStepID(_L("GRAPHICS-UI-BENCH-0077")); |
|
66 FadedShadowTestL(); |
|
67 RecordTestResultL(); |
|
68 SetTestStepID(_L("GRAPHICS-UI-BENCH-0078")); |
|
69 AntialiasedTextTestL(); |
|
70 RecordTestResultL(); |
|
71 |
|
72 return TestStepResult(); |
|
73 } |
|
74 |
|
75 /** |
|
76 @SYMTestCaseID |
|
77 GRAPHICS-UI-BENCH-0046 |
|
78 |
|
79 @SYMTestCaseDesc |
|
80 Tests how long it takes to calculate and display a shadow area with different screen modes |
|
81 |
|
82 @SYMTestActions |
|
83 Compare the results over time, and before and after changes to CFbsBitGc::ShadowArea() code. |
|
84 In particular this function calls ShadowArea() from derived classes of CFbsDrawDevice |
|
85 e.g. CDrawThirtyTwoBppBitmapCommon with TShadowMode::EShadow |
|
86 |
|
87 @SYMTestExpectedResults |
|
88 Test should pass and display total test time and time per display mode |
|
89 */ |
|
90 void CTShadowPerf::ShadowAreaL() |
|
91 { |
|
92 INFO_PRINTF1(_L("CTShadowPerf::ShadowArea")); |
|
93 _LIT(KTestName, "ShadowArea"); |
|
94 |
|
95 for (TInt dispModeIndex = KNumValidDisplayModes-1; dispModeIndex >= 0; --dispModeIndex) |
|
96 { |
|
97 SetScreenModeL(KValidDisplayModes[dispModeIndex]); |
|
98 AreaTestL(EShadow, KTestName, dispModeIndex); |
|
99 } |
|
100 } |
|
101 |
|
102 /** |
|
103 @SYMTestCaseID |
|
104 GRAPHICS-UI-BENCH-0047 |
|
105 |
|
106 @SYMTestCaseDesc |
|
107 Tests how long it takes to calculate and display a faded area with different screen modes |
|
108 |
|
109 @SYMTestActions |
|
110 Compare the results over time, and before and after changes to CFbsBitGc::FadeArea() code. |
|
111 In particular this function calls FadeArea() from derived classes of CFbsDrawDevice |
|
112 e.g. CDrawThirtyTwoBppBitmapCommon with TShadowMode::EFade |
|
113 |
|
114 @SYMTestExpectedResults |
|
115 Test should pass and display total test time and time per display mode |
|
116 */ |
|
117 void CTShadowPerf::FadeAreaL() |
|
118 { |
|
119 INFO_PRINTF1(_L("CTShadowPerf::FadeArea")); |
|
120 _LIT(KTestName, "FadeArea"); |
|
121 |
|
122 for (TInt dispModeIndex = KNumValidDisplayModes-1; dispModeIndex >= 0; --dispModeIndex) |
|
123 { |
|
124 SetScreenModeL(KValidDisplayModes[dispModeIndex]); |
|
125 AreaTestL(EFade, KTestName, dispModeIndex); |
|
126 } |
|
127 } |
|
128 |
|
129 /** |
|
130 Helper function to test the performance of shadowing and fading |
|
131 |
|
132 @param aShadowTest the shadow test to carry out |
|
133 @param aTestName the name of the test |
|
134 @param aDisplayModeIndex the display mode index |
|
135 */ |
|
136 void CTShadowPerf::AreaTestL(TShadowTest aShadowTest, const TDesC& aTestName, TInt aDisplayModeIndex) |
|
137 { |
|
138 const TRect shadowRect(25,25,50,50); |
|
139 RRegion shadowRegion(shadowRect); |
|
140 |
|
141 iGc->Clear(); |
|
142 switch (aShadowTest) |
|
143 { |
|
144 case EShadow: |
|
145 iProfiler->InitResults(); |
|
146 for (TInt count=KIterationsToTest; count>=0; --count) |
|
147 { |
|
148 iGc->ShadowArea(&shadowRegion); |
|
149 iProfiler->MarkResultSetL(); |
|
150 } |
|
151 break; |
|
152 |
|
153 case EFade: |
|
154 iProfiler->InitResults(); |
|
155 for (TInt count=KIterationsToTest; count>=0; --count) |
|
156 { |
|
157 iGc->FadeArea(&shadowRegion); |
|
158 iProfiler->MarkResultSetL(); |
|
159 } |
|
160 break; |
|
161 } |
|
162 iProfiler->ResultsAnalysis(aTestName, aShadowTest, KValidDisplayModes[aDisplayModeIndex], KValidDisplayModes[aDisplayModeIndex], KIterationsToTest); |
|
163 shadowRegion.Close(); |
|
164 } |
|
165 |
|
166 /** |
|
167 @SYMTestCaseID |
|
168 GRAPHICS-UI-BENCH-0077 |
|
169 |
|
170 @SYMTestCaseDesc |
|
171 Tests the performance of CDrawSixteenBppBitmap::WriteRgbAlphaLine function. |
|
172 |
|
173 @SYMTestActions |
|
174 Compare the results over time, and before and after changes to |
|
175 CDrawSixteenBppBitmap::WriteRgbAlphaLine and CDrawSixteenBppBitmap::Shadow code. |
|
176 |
|
177 @SYMTestExpectedResults |
|
178 Test should pass and display total test time. |
|
179 */ |
|
180 void CTShadowPerf::FadedShadowTestL() |
|
181 { |
|
182 _LIT(KTestName, "FadedShadow"); |
|
183 SetScreenModeL(EColor64K); |
|
184 CFbsBitmap* bitmap16bit = LoadBitmapL(Kmbm16bpp, 0); |
|
185 CleanupStack::PushL(bitmap16bit); |
|
186 CFbsBitmap* alpha8bit = CopyIntoNewBitmapL(bitmap16bit, EGray256); |
|
187 CleanupStack::PushL(alpha8bit); |
|
188 TRect cropTo(0,0,200,200); |
|
189 iProfiler->InitResults(); |
|
190 for (TInt count=KIterationsToTest; count>=0; --count) |
|
191 { |
|
192 iGc->Clear(); |
|
193 iGc->SetFaded(ETrue); |
|
194 iProfiler->StartTimer(); |
|
195 iGc->BitBltMasked(TPoint(0,0), bitmap16bit, cropTo, alpha8bit, EFalse); |
|
196 iProfiler->MarkResultSetL(); |
|
197 } |
|
198 iGc->SetFaded(EFalse); |
|
199 iGc->Clear(); |
|
200 CleanupStack::PopAndDestroy(2, bitmap16bit); |
|
201 iProfiler->ResultsAnalysis(KTestName, 0, EColor64K, EColor64K, KIterationsToTest); |
|
202 } |
|
203 |
|
204 /** |
|
205 @SYMTestCaseID |
|
206 GRAPHICS-UI-BENCH-0078 |
|
207 |
|
208 @SYMTestCaseDesc |
|
209 Tests the performance of CDrawSixteenBppBitmap::WriteRgbAlphaMulti function. |
|
210 |
|
211 @SYMTestActions |
|
212 Compare the results over time, and before and after changes to |
|
213 CDrawSixteenBppBitmap::WriteRgbAlphaMulti and CDrawSixteenBppBitmap:: Shadow code. |
|
214 |
|
215 @SYMTestExpectedResults |
|
216 Test should pass and display total test time |
|
217 */ |
|
218 void CTShadowPerf::AntialiasedTextTestL() |
|
219 { |
|
220 SetScreenModeL(EColor64K); |
|
221 if(iScreenDevice->isScreenDevice()) |
|
222 { |
|
223 _LIT(KTestName, "AntialiasedText"); |
|
224 _LIT(KText,"Drawing Antialiased Text"); |
|
225 CFont* font = NULL; |
|
226 CFbsScreenDevice* screenDevice = reinterpret_cast<CFbsScreenDevice*>(&(iScreenDevice->BitmapDevice())); |
|
227 TInt typefaces = screenDevice->NumTypefaces(); |
|
228 iProfiler->InitResults(); |
|
229 for (TInt count=KIterationsToTest; count>=0; --count) |
|
230 { |
|
231 for (TInt i = 0; i < typefaces; i++) |
|
232 { |
|
233 TTypefaceSupport typeface_support; |
|
234 screenDevice->TypefaceSupport(typeface_support,i); |
|
235 if (typeface_support.iIsScalable) |
|
236 { |
|
237 iGc->Clear(); |
|
238 iGc->SetFaded(ETrue); |
|
239 TPoint pos(100,30); |
|
240 TFontSpec fs; |
|
241 fs.iTypeface = typeface_support.iTypeface; |
|
242 fs.iHeight = 14; |
|
243 fs.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); |
|
244 User::LeaveIfError(screenDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fs)); |
|
245 iGc->UseFont(font); |
|
246 iProfiler->StartTimer(); |
|
247 iGc->DrawText(KText,pos); |
|
248 iProfiler->MarkResultSetL(); |
|
249 screenDevice->ReleaseFont(font); |
|
250 iGc->DiscardFont(); |
|
251 } |
|
252 } |
|
253 } |
|
254 iProfiler->ResultsAnalysis(KTestName, 0, EColor64K, EColor64K, KIterationsToTest); |
|
255 } |
|
256 } |