|
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 #ifndef __TE_GRAPHICSPERFORMANCE_STEP_BASE__ |
|
23 #define __TE_GRAPHICSPERFORMANCE_STEP_BASE__ |
|
24 |
|
25 #include <e32math.h> |
|
26 #include <bitdev.h> |
|
27 #include <test/tprofiler.h> |
|
28 #include <test/testexecutestepbase.h> |
|
29 #include <test/ttmsgraphicsstep.h> |
|
30 #include "te_graphicsperformanceSuiteDefs.h" |
|
31 #include "tdisplaymode_mapping.h" |
|
32 |
|
33 TSize GetPixmapSizeInPixels(); |
|
34 |
|
35 // Define TRgb constants to be used in test cases |
|
36 #define TRANSPARENT_BLACK TRgb(0,0,0,0) |
|
37 #define BLACK_SEMI_TRANSPARENT TRgb(0,0,0,0x40) |
|
38 #define RED_SEMI_TRANSPARENT TRgb(0xff,0,0,0x40) |
|
39 #define GREEN_SEMI_TRANSPARENT TRgb(0,0xff,0,0x40) |
|
40 #define BLUE_SEMI_TRANSPARENT TRgb(0,0,0xff,0x40) |
|
41 #define YELLOW_SEMI_TRANSPARENT TRgb(0xff,0xff,0,0x40) |
|
42 |
|
43 /** |
|
44 Creates a virtual bitmap device if a real screen device of the specified display mode is not supported by the hardware |
|
45 */ |
|
46 class CVirtualBitmapDevice : public CBase |
|
47 { |
|
48 public: |
|
49 virtual ~CVirtualBitmapDevice(); |
|
50 static CVirtualBitmapDevice* NewL(TDisplayMode aDisplayMode, TBool aForceOffscreen); |
|
51 void Update(); |
|
52 CBitmapDevice& BitmapDevice(); |
|
53 CFbsBitmap& Bitmap(); |
|
54 virtual int CreateContext(CGraphicsContext *&aGc); |
|
55 virtual TSize SizeInPixels() const; |
|
56 TInt isScreenDevice(); |
|
57 private: |
|
58 void ConstructL(TDisplayMode aDisplayMode, TBool aForceOffscreen); |
|
59 |
|
60 private: |
|
61 CBitmapDevice* iBitmapDevice; // The virtual or real screen device |
|
62 CFbsBitmap* iBitmap; // Virtual bitmap |
|
63 TBool iIsScreenDevice; // ETrue if the hardware supports the screen device at the specified display mode |
|
64 }; |
|
65 |
|
66 /** |
|
67 Creates a virtual bitmap device if a real screen device of the specified display mode is not supported by the hardware. |
|
68 It is similar to CVirtualBitmapDevice but it uses CFbsDrawDevice directly. |
|
69 */ |
|
70 class CVirtualDrawDevice : public CBase |
|
71 { |
|
72 public: |
|
73 virtual ~CVirtualDrawDevice(); |
|
74 static CVirtualDrawDevice* NewL(TDisplayMode aDisplayMode); |
|
75 CFbsDrawDevice& DrawDevice(); |
|
76 TBool IsDrawDevice(); |
|
77 private: |
|
78 void ConstructL(TDisplayMode aDisplayMode); |
|
79 TInt ByteSize(const TSize& aSize, TDisplayMode aDisplayMode); |
|
80 |
|
81 private: |
|
82 CFbsDrawDevice* iDrawDevice; // The virtual or real screen device |
|
83 TUint8* iDeviceMemory; // Used for virtual draw device |
|
84 TSize iSize; // Used for Clear |
|
85 TBool iIsDrawDevice; // ETrue if the hardware supports the screen device at the specified display mode |
|
86 }; |
|
87 |
|
88 /**************************************************************************** |
|
89 * The reason to have a new step base is that it is very much possible |
|
90 * that the all individual test steps have project related common variables |
|
91 * and members |
|
92 * and this is the place to define these common variable and members. |
|
93 * |
|
94 ****************************************************************************/ |
|
95 class CTe_graphicsperformanceSuiteStepBase : public CTTMSGraphicsStep |
|
96 { |
|
97 public: |
|
98 static const TDesC& ColorModeName(TDisplayMode aMode); |
|
99 virtual ~CTe_graphicsperformanceSuiteStepBase(); |
|
100 CTe_graphicsperformanceSuiteStepBase(); |
|
101 CVirtualBitmapDevice* ScreenDevice(); |
|
102 |
|
103 void SetScreenModeL(TDisplayMode aScreenMode, TBool aForceUseOffscreen=EFalse); |
|
104 CFbsBitmap* CreateSoftwareBitmapLC(const TSize& aSize, TDisplayMode aMode); |
|
105 void CopyBitmapL(CFbsBitmap* aDst, CFbsBitmap* aSrc); |
|
106 CFbsBitmap* CopyIntoNewBitmapL(CFbsBitmap* aSrc, TDisplayMode aDisplayMode); |
|
107 CFbsBitmap* LoadBitmapL(const TDesC& aName, TInt aIndex); |
|
108 static TRgb InterpolateColour(TRgb aLo, TRgb aHi, TInt aX, TInt aN); |
|
109 static void VerticalGradientAlphaL(CFbsBitmap* aBitmap, TRgb aLo, TRgb aHi); |
|
110 void SetDrawDeviceModeL(TDisplayMode aScreenMode); |
|
111 TInt GetDrawDeviceInterfaceL(TInt aInterfaceId, TAny *&aInterface); |
|
112 void ClearDrawDeviceL(TRgb aColor); |
|
113 CFbsBitmap* CreateCheckedBoardL(TDisplayMode aDisplayMode, TSize aSize, TSize aChecksPerAxis) const; |
|
114 virtual CFbsBitmap* GetTargetAsBitmapL(); |
|
115 TInt WriteTargetOutput(TPtrC aName); |
|
116 static void ExtractListL(TPtrC aList, RArray<TPtrC>& aListItems); |
|
117 |
|
118 protected: |
|
119 // From CTestStep |
|
120 virtual TVerdict doTestStepPreambleL(); |
|
121 virtual TVerdict doTestStepPostambleL(); |
|
122 TUint32 TimeMax(); |
|
123 TUint32 TimeMin(); |
|
124 |
|
125 private: |
|
126 //TBool IsFoundScreenMode(TDisplayMode aScreenMode); |
|
127 |
|
128 protected: |
|
129 CVirtualBitmapDevice * iScreenDevice; |
|
130 CFbsBitGc* iGc; |
|
131 CVirtualDrawDevice* iDrawDevice; |
|
132 CTProfiler* iProfiler; |
|
133 |
|
134 private: |
|
135 TSize iScreenSize; |
|
136 TInt iDoProfiling; |
|
137 TInt iCPUSpeed; |
|
138 CActiveScheduler* iScheduler; |
|
139 |
|
140 // Sanity checking flag as read in from the ini file. If ETrue, WriteTargetOutput() will generate |
|
141 // a bitmap of the target, otherwise it will perform no operation. |
|
142 TBool iShowBitmaps; |
|
143 __PROFILERMEMBERS |
|
144 }; |
|
145 |
|
146 // Define 16 RGB colors |
|
147 #define KRgbBlack TRgb(0x000000) |
|
148 #define KRgbDarkGray TRgb(0x555555) |
|
149 #define KRgbDarkRed TRgb(0x000080) |
|
150 #define KRgbDarkGreen TRgb(0x008000) |
|
151 #define KRgbDarkYellow TRgb(0x008080) |
|
152 #define KRgbDarkBlue TRgb(0x800000) |
|
153 #define KRgbDarkMagenta TRgb(0x800080) |
|
154 #define KRgbDarkCyan TRgb(0x808000) |
|
155 #define KRgbRed TRgb(0x0000ff) |
|
156 #define KRgbGreen TRgb(0x00ff00) |
|
157 #define KRgbYellow TRgb(0x00ffff) |
|
158 #define KRgbBlue TRgb(0xff0000) |
|
159 #define KRgbMagenta TRgb(0xff00ff) |
|
160 #define KRgbCyan TRgb(0xffff00) |
|
161 #define KRgbGray TRgb(0xaaaaaa) |
|
162 #define KRgbWhite TRgb(0xffffff) |
|
163 |
|
164 // A 16 RGB color table |
|
165 const TRgb KColor16Table[] = |
|
166 { |
|
167 KRgbWhite, |
|
168 KRgbGray, |
|
169 KRgbCyan, |
|
170 KRgbMagenta, |
|
171 KRgbBlue, |
|
172 KRgbYellow, |
|
173 KRgbGreen, |
|
174 KRgbRed, |
|
175 KRgbDarkCyan, |
|
176 KRgbDarkMagenta, |
|
177 KRgbDarkBlue, |
|
178 KRgbDarkYellow, |
|
179 KRgbDarkGreen, |
|
180 KRgbDarkRed, |
|
181 KRgbDarkGray, |
|
182 KRgbBlack, |
|
183 }; |
|
184 |
|
185 #endif |