|
1 // Copyright (c) 2008-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 "ttranslucent.h" |
|
23 |
|
24 const TInt KIterationsToTest = 100; |
|
25 |
|
26 // |
|
27 // CTTranslucent |
|
28 // |
|
29 CTTranslucent::CTTranslucent() |
|
30 { |
|
31 SetTestStepName(KTTranslucent); |
|
32 } |
|
33 |
|
34 CTTranslucent::~CTTranslucent() |
|
35 { |
|
36 iWindowArray.ResetAndDestroy(); |
|
37 iWindowArray.Close(); |
|
38 delete iTopWindow; |
|
39 delete iBottomWindow; |
|
40 delete iBitmap; |
|
41 |
|
42 delete iGc; |
|
43 delete iScreen; |
|
44 iWindowGroup.Close(); |
|
45 iWsSession.Close(); |
|
46 } |
|
47 |
|
48 /** |
|
49 Override of base class virtual |
|
50 |
|
51 @return - TVerdict code |
|
52 */ |
|
53 TVerdict CTTranslucent::doTestStepPreambleL() |
|
54 { |
|
55 CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL(); |
|
56 SetScreenModeL(EColor16MU); |
|
57 return TestStepResult(); |
|
58 } |
|
59 |
|
60 TVerdict CTTranslucent::doTestStepL() |
|
61 { |
|
62 User::LeaveIfError(iWsSession.Connect()); |
|
63 |
|
64 iWindowGroup=RWindowGroup(iWsSession); |
|
65 User::LeaveIfError(iWindowGroup.Construct(2, ETrue)); // meaningless handle; enable focus |
|
66 |
|
67 // construct screen device and graphics context |
|
68 iScreen=new (ELeave) CWsScreenDevice(iWsSession); // make device for this session |
|
69 User::LeaveIfError(iScreen->Construct()); // and complete its construction |
|
70 User::LeaveIfError(iScreen->CreateContext(iGc)); // create graphics context |
|
71 |
|
72 iScreenRect = TRect(0,0,iScreen->SizeInPixels().iWidth, iScreen->SizeInPixels().iHeight); |
|
73 |
|
74 // Construct a gradient bitmap for use by bitmap test |
|
75 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
76 CleanupStack::PushL(bitmap); |
|
77 User::LeaveIfError(bitmap->Create(TSize(80,80), EColor16MA)); |
|
78 CTe_graphicsperformanceSuiteStepBase::VerticalGradientAlphaL(bitmap, TRgb(0x000000ff), TRgb(0xff000000)); |
|
79 delete iBitmap; |
|
80 iBitmap = bitmap; |
|
81 CleanupStack::Pop(bitmap); |
|
82 |
|
83 /** |
|
84 @SYMTestCaseID GRAPHICS-UI-BENCH-0132 |
|
85 @SYMPREQ PREQ1841 |
|
86 @SYMTestCaseDesc Measures time taken to redraw 2, 8, 32 and 144 blank translucent |
|
87 partially overlapping windows. |
|
88 @SYMTestActions |
|
89 1. Create blank translucent partially overlapping windows. |
|
90 2. Cover them all with an "ontop" window. |
|
91 3. Hide the "ontop" window and measure time taken to redraw all overlapping windows underneath. |
|
92 4. Repeat KIterationsToTest times and calculate average time per iteration. |
|
93 |
|
94 @SYMTestExpectedResults |
|
95 As the number of windows increases, so should the time taken to redraw them. |
|
96 */ |
|
97 SetTestStepID(_L("GRAPHICS-UI-BENCH-0132")); |
|
98 RunTestCaseL(_L("Redraw-BlankWindows2"), EBlankWindows, 2, 1); |
|
99 RunTestCaseL(_L("Redraw-BlankWindows8"), EBlankWindows, 2, 4); |
|
100 RunTestCaseL(_L("Redraw-BlankWindows32"), EBlankWindows, 4, 8); |
|
101 RunTestCaseL(_L("Redraw-BlankWindows144"), EBlankWindows, 12, 12); |
|
102 RecordTestResultL(); |
|
103 |
|
104 /** |
|
105 @SYMTestCaseID GRAPHICS-UI-BENCH-0133 |
|
106 @SYMPREQ PREQ1841 |
|
107 @SYMTestCaseDesc Measures time taken to redraw 2, 8, 32 and 144 translucent |
|
108 partially overlapping windows containing drawn text. |
|
109 @SYMTestActions |
|
110 1. Create translucent partially overlapping windows. |
|
111 2. Cover them all with an "ontop" window. |
|
112 3. Hide the "ontop" window and measure time taken to redraw all overlapping windows underneath. |
|
113 4. Repeat KIterationsToTest times and calculate average time per iteration. |
|
114 |
|
115 @SYMTestExpectedResults |
|
116 As the number of windows increases, so should the time taken to redraw them. |
|
117 */ |
|
118 SetTestStepID(_L("GRAPHICS-UI-BENCH-0133")); |
|
119 RunTestCaseL(_L("Redraw-TextWindows2"), ETextWindows, 2, 1); |
|
120 RunTestCaseL(_L("Redraw-TextWindows8"), ETextWindows, 2, 4); |
|
121 RunTestCaseL(_L("Redraw-TextWindows32"), ETextWindows, 4, 8); |
|
122 RunTestCaseL(_L("Redraw-TextWindows144"), ETextWindows, 12, 12); |
|
123 RecordTestResultL(); |
|
124 |
|
125 /** |
|
126 @SYMTestCaseID GRAPHICS-UI-BENCH-0134 |
|
127 @SYMPREQ PREQ1841 |
|
128 @SYMTestCaseDesc Measures time taken to redraw 2, 8, 32 and 144 translucent |
|
129 partially overlapping windows containing drawn ellipsis. |
|
130 @SYMTestActions |
|
131 1. Create translucent partially overlapping windows. |
|
132 2. Cover them all with an "ontop" window. |
|
133 3. Hide the "ontop" window and measure time taken to redraw all overlapping windows underneath. |
|
134 4. Repeat KIterationsToTest times and calculate average time per iteration. |
|
135 |
|
136 @SYMTestExpectedResults |
|
137 As the number of windows increases, so should the time taken to redraw them. |
|
138 */ |
|
139 SetTestStepID(_L("GRAPHICS-UI-BENCH-0134")); |
|
140 RunTestCaseL(_L("Redraw-EllipseWindows2"), EEllipseWindows, 2, 1); |
|
141 RunTestCaseL(_L("Redraw-EllipseWindows8"), EEllipseWindows, 2, 4); |
|
142 RunTestCaseL(_L("Redraw-EllipseWindows32"), EEllipseWindows, 4, 8); |
|
143 RunTestCaseL(_L("Redraw-EllipseWindows144"), EEllipseWindows, 12, 12); |
|
144 RecordTestResultL(); |
|
145 |
|
146 /** |
|
147 @SYMTestCaseID GRAPHICS-UI-BENCH-0135 |
|
148 @SYMPREQ PREQ1841 |
|
149 @SYMTestCaseDesc Measures time taken to redraw 2, 8, 32 and 144 translucent |
|
150 partially overlapping windows containing bitmaps. |
|
151 @SYMTestActions |
|
152 1. Create translucent partially overlapping windows. |
|
153 2. Cover them all with an "ontop" window. |
|
154 3. Hide the "ontop" window and measure time taken to redraw all overlapping windows underneath. |
|
155 4. Repeat KIterationsToTest times and calculate average time per iteration. |
|
156 |
|
157 @SYMTestExpectedResults |
|
158 As the number of windows increases, so should the time taken to redraw them. |
|
159 */ |
|
160 SetTestStepID(_L("GRAPHICS-UI-BENCH-0135")); |
|
161 RunTestCaseL(_L("Redraw-BitmapWindows2"), EBitmapWindows, 2, 1); |
|
162 RunTestCaseL(_L("Redraw-BitmapWindows8"), EBitmapWindows, 2, 4); |
|
163 RunTestCaseL(_L("Redraw-BitmapWindows32"), EBitmapWindows, 4, 8); |
|
164 RunTestCaseL(_L("Redraw-BitmapWindows144"), EBitmapWindows, 12, 12); |
|
165 RecordTestResultL(); |
|
166 |
|
167 return TestStepResult(); |
|
168 } |
|
169 |
|
170 void CTTranslucent::RunTestCaseL(const TDesC& aTestName, TTestCase aTestCase, TInt aHorizontalWindows, TInt aVerticalWindows) |
|
171 { |
|
172 iTestCase = aTestCase; |
|
173 |
|
174 ConstructWindowsL(aHorizontalWindows, aVerticalWindows); |
|
175 iWsSession.Finish(); // Make sure all windows are drawn in their initial state/positions |
|
176 |
|
177 iProfiler->InitResults(); |
|
178 |
|
179 // Measure time taken to redraw all overlapping translucent windows |
|
180 // and repeat KIterationsToTest times |
|
181 for (int i = 0; i < KIterationsToTest; i++) |
|
182 { |
|
183 iProfiler->StartTimer(); |
|
184 iTopWindow->Window().SetVisible(EFalse); // hide ontop window to cause overlapping translucent windows to be redrawn |
|
185 iWsSession.Finish(); |
|
186 iProfiler->MarkResultSetL(); |
|
187 |
|
188 iTopWindow->Window().SetVisible(ETrue); // show ontop window |
|
189 iWsSession.Finish(); |
|
190 } |
|
191 |
|
192 iProfiler->ResultsAnalysis(aTestName, 0, 0, ScreenDevice()->BitmapDevice().DisplayMode(), KIterationsToTest); |
|
193 |
|
194 DestroyWindows(); |
|
195 } |
|
196 |
|
197 void CTTranslucent::ConstructWindowsL(TInt aHorizontalWindows, TInt aVerticalWindows) |
|
198 { |
|
199 // Create a yellow opaque window to use as the background for the translucent windows |
|
200 iBottomWindow = new (ELeave) CWin(iWsSession, iWindowGroup); |
|
201 iBottomWindow->ConstructL(iScreenRect); |
|
202 iBottomWindow->Window().SetBackgroundColor(TRgb(255, 255, 0)); |
|
203 iBottomWindow->Window().SetOrdinalPosition(-1); |
|
204 iBottomWindow->Window().Invalidate(); |
|
205 iBottomWindow->Window().BeginRedraw(); |
|
206 iBottomWindow->Window().EndRedraw(); |
|
207 iBottomWindow->Window().Activate(); |
|
208 |
|
209 // Create some green partially overlapping translucent windows. |
|
210 // Each window has roughly the same aspect ratio as the screen. |
|
211 // Each window is the same size for every test, regardless of how many windows are being created. |
|
212 |
|
213 // Maximum number of windows horizontally and vertically that we want to be able to fit onto |
|
214 // the screen. Window size is calculated based on screen width/height and number of windows we want |
|
215 // to fit in with the desired overlap. |
|
216 // KMaxWindows * KMaxWindows gives the total maximum number of windows that will fit on screen without |
|
217 // being clipped. |
|
218 const TInt KMaxWindows = 12; |
|
219 |
|
220 // Calculate 1/4 width of each window |
|
221 const TInt KQuarterWidth = iScreenRect.Width() / (KMaxWindows + 3); |
|
222 // Calculate 1/4 height of each window |
|
223 const TInt KQuarterHeight = iScreenRect.Height() / (KMaxWindows + 3); |
|
224 |
|
225 TRect rect(0, 0, 0, 0); |
|
226 TInt x = 0; |
|
227 TInt y = 0; |
|
228 // Calculate size used for all translucent windows |
|
229 TSize size(KQuarterWidth*4, KQuarterHeight*4); |
|
230 TInt hCount = 0; |
|
231 TInt vCount = 0; |
|
232 for (hCount = 0; hCount < aHorizontalWindows; hCount++) |
|
233 { |
|
234 y = 0; |
|
235 for (vCount = 0; vCount < aVerticalWindows; vCount++) |
|
236 { |
|
237 // Construct a vertical column of windows |
|
238 CWin* win = new(ELeave) CWin(iWsSession, iWindowGroup); |
|
239 CleanupStack::PushL(win); |
|
240 iWindowArray.AppendL(win); |
|
241 CleanupStack::Pop(win); |
|
242 rect.iTl = TPoint(x, y); |
|
243 rect.SetSize(size); |
|
244 win->ConstructL(rect); |
|
245 User::LeaveIfError(win->Window().SetTransparencyAlphaChannel()); |
|
246 win->Window().SetBackgroundColor(TRgb(0, 255, 0, 16)); |
|
247 |
|
248 TRect clipRect(size); |
|
249 DrawWindowL(win, clipRect); |
|
250 win->Window().Activate(); |
|
251 y+=KQuarterHeight; |
|
252 } |
|
253 x+=KQuarterWidth; |
|
254 } |
|
255 |
|
256 // Create a red opaque window ontop of all the others |
|
257 iTopWindow = new (ELeave) CWin(iWsSession, iWindowGroup); |
|
258 iTopWindow->ConstructL(iScreenRect); |
|
259 iTopWindow->Window().SetBackgroundColor(TRgb(255, 0, 0)); |
|
260 iTopWindow->Window().SetOrdinalPosition(0); |
|
261 iTopWindow->Window().Invalidate(); |
|
262 iTopWindow->Window().BeginRedraw(); |
|
263 iTopWindow->Window().EndRedraw(); |
|
264 iTopWindow->Window().Activate(); |
|
265 } |
|
266 |
|
267 void CTTranslucent::DestroyWindows() |
|
268 { |
|
269 iWindowArray.ResetAndDestroy(); |
|
270 delete iTopWindow; |
|
271 iTopWindow = NULL; |
|
272 delete iBottomWindow; |
|
273 iBottomWindow = NULL; |
|
274 } |
|
275 |
|
276 void CTTranslucent::DrawWindowL(CWin* aWindow, const TRect& aRect) |
|
277 { |
|
278 iGc->Activate(aWindow->Window()); |
|
279 iGc->SetClippingRect(aRect); |
|
280 aWindow->Window().Invalidate(); |
|
281 aWindow->Window().BeginRedraw(); |
|
282 |
|
283 // Draw the whole window |
|
284 switch(iTestCase) |
|
285 { |
|
286 case EBlankWindows: |
|
287 break; // Don't draw anything on the blank windows |
|
288 |
|
289 case ETextWindows: |
|
290 { |
|
291 CFont* font; |
|
292 TFontSpec fontSpec; |
|
293 fontSpec.iHeight = 300; |
|
294 User::LeaveIfError(iGc->Device()->GetNearestFontToDesignHeightInTwips(font, fontSpec)); |
|
295 iGc->UseFont(font); |
|
296 iGc->DrawText(_L("Text"), TPoint(0,20)); |
|
297 iGc->DrawText(_L("window"), TPoint(0,40)); |
|
298 iGc->DiscardFont(); |
|
299 iGc->Device()->ReleaseFont(font); |
|
300 break; |
|
301 } |
|
302 |
|
303 case EEllipseWindows: |
|
304 iGc->SetPenColor(TRgb(0, 0, 0, 255)); |
|
305 iGc->SetBrushColor(TRgb(128, 128, 255, 128)); |
|
306 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
307 iGc->DrawEllipse(TRect(0,0,79,79)); |
|
308 iGc->DrawEllipse(TRect(10,10,69,69)); |
|
309 iGc->DrawEllipse(TRect(20,20,59,59)); |
|
310 iGc->DrawEllipse(TRect(30,30,49,49)); |
|
311 iGc->SetBrushColor(TRgb(255, 0, 0, 150)); |
|
312 iGc->SetBrushStyle(CGraphicsContext::EDiamondCrossHatchBrush); |
|
313 iGc->DrawEllipse(TRect(0,0,20,15)); |
|
314 iGc->DrawEllipse(TRect(30,10,50,30)); |
|
315 break; |
|
316 case EBitmapWindows: |
|
317 iGc->BitBlt(TPoint(0,0), iBitmap); |
|
318 break; |
|
319 } |
|
320 |
|
321 aWindow->Window().EndRedraw(); |
|
322 iGc->Deactivate(); |
|
323 } |
|
324 |
|
325 // |
|
326 // CWin |
|
327 // |
|
328 CTTranslucent::CWin::CWin(RWsSession& aWsSession, RWindowGroup& aWindowGroup) |
|
329 :iWsSession(aWsSession), iWindowGroup(aWindowGroup) |
|
330 { |
|
331 } |
|
332 |
|
333 CTTranslucent::CWin::~CWin() |
|
334 { |
|
335 iWindow.Close(); |
|
336 } |
|
337 |
|
338 void CTTranslucent::CWin::ConstructL (const TRect& aRect) |
|
339 { |
|
340 iWindow=RWindow(iWsSession); |
|
341 User::LeaveIfError(iWindow.Construct(iWindowGroup, (TUint32)this)); |
|
342 iRect = aRect; |
|
343 iWindow.SetExtent(iRect.iTl, iRect.Size()); |
|
344 } |
|
345 |
|
346 RWindow& CTTranslucent::CWin::Window() |
|
347 { |
|
348 return iWindow; |
|
349 } |