sl@0
|
1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// This test application is used to test how the scaling works with CFbsBitGc drawing methods.
|
sl@0
|
15 |
// TDrawComposite template class is used for the testing. When instantiated, it expects two
|
sl@0
|
16 |
// template arguments - TDrawFunctor and TDrawParam:
|
sl@0
|
17 |
// 1. TDrawFunctor class. It represents the "functor/function object" pattern and
|
sl@0
|
18 |
// must implement "void operator()(CFbsBitGc* aGraphicsContext, TDrawParam* aPrm)" method.
|
sl@0
|
19 |
// 2. TDrawParam class. This is a template argument for
|
sl@0
|
20 |
// "void TDrawFunctor::operator()(CFbsBitGc* aGraphicsContext, TDrawParam* aPrm)" method.
|
sl@0
|
21 |
// If the overloaded "()" operator does not need a parameter, TEmpty class can be used as
|
sl@0
|
22 |
// a template parameter.
|
sl@0
|
23 |
// When you instantiate TDrawComposite template class and call TDrawComposite::Draw() method,
|
sl@0
|
24 |
// it will perform all pre- and post- drawing steps, calling
|
sl@0
|
25 |
// "void TDrawFunctor::operator()(CFbsBitGc* aGraphicsContext, TDrawParam* aPrm)"
|
sl@0
|
26 |
// at the right time.
|
sl@0
|
27 |
// If you want to do the test step by step, set "aCallGetch" parameter of TDrawComposite's
|
sl@0
|
28 |
// constructor to ETrue, when using it.
|
sl@0
|
29 |
//
|
sl@0
|
30 |
//
|
sl@0
|
31 |
|
sl@0
|
32 |
#include <hal.h>
|
sl@0
|
33 |
#include "TBitgdiScaling.h"
|
sl@0
|
34 |
|
sl@0
|
35 |
//
|
sl@0
|
36 |
//Constants
|
sl@0
|
37 |
//
|
sl@0
|
38 |
//X and Y scaling factors.
|
sl@0
|
39 |
const TInt KScalingFactorX = 3;
|
sl@0
|
40 |
const TInt KScalingFactorY = 2;
|
sl@0
|
41 |
//Test bitmap
|
sl@0
|
42 |
_LIT(KTestBmp, "z:\\system\\data\\BmCTest.mbm");
|
sl@0
|
43 |
|
sl@0
|
44 |
//This clas might be used as a TDrawParam template parameter
|
sl@0
|
45 |
class TEmpty
|
sl@0
|
46 |
{
|
sl@0
|
47 |
};
|
sl@0
|
48 |
|
sl@0
|
49 |
//This clas is used for testing CFbsBitGc drawing methods against the new scaling functionality.
|
sl@0
|
50 |
template <class TDrawFunctor, class TDrawParam> class TDrawComposite
|
sl@0
|
51 |
{
|
sl@0
|
52 |
public:
|
sl@0
|
53 |
TDrawComposite(const TPoint& aOrigin, TDrawFunctor& aFunctor,
|
sl@0
|
54 |
TDrawParam* aDrawParam, TBool aCallGetch = EFalse) :
|
sl@0
|
55 |
iOrigin(aOrigin),
|
sl@0
|
56 |
iFunctor(aFunctor),
|
sl@0
|
57 |
iPrm(aDrawParam),
|
sl@0
|
58 |
iCallGetch(aCallGetch)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
}
|
sl@0
|
61 |
void Draw(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext, CTGraphicsBase* aTest)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
__ASSERT_DEBUG(aScreenDevice, User::Invariant());
|
sl@0
|
64 |
__ASSERT_DEBUG(aGraphicsContext, User::Invariant());
|
sl@0
|
65 |
|
sl@0
|
66 |
PreDrawStep(aScreenDevice, aGraphicsContext);
|
sl@0
|
67 |
iFunctor(aGraphicsContext, iPrm);
|
sl@0
|
68 |
TInt err = aScreenDevice->SetScalingFactor(iOrigin, KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
69 |
aTest -> TEST2(err, KErrNone);
|
sl@0
|
70 |
aGraphicsContext->Activate(aScreenDevice);
|
sl@0
|
71 |
iFunctor(aGraphicsContext, iPrm);
|
sl@0
|
72 |
PostDrawStep(aScreenDevice, aGraphicsContext);
|
sl@0
|
73 |
err = aScreenDevice->SetScalingFactor(TPoint (0, 0), 1, 1, 1, 1);
|
sl@0
|
74 |
aTest -> TEST2(err, KErrNone);
|
sl@0
|
75 |
aGraphicsContext->Activate(aScreenDevice);
|
sl@0
|
76 |
}
|
sl@0
|
77 |
private:
|
sl@0
|
78 |
void PreDrawStep(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
aGraphicsContext->Clear();
|
sl@0
|
81 |
TSize screenSize = aScreenDevice->SizeInPixels();
|
sl@0
|
82 |
TRect rc(iOrigin.iX, iOrigin.iY, screenSize.iWidth - 1, screenSize.iHeight - 1);
|
sl@0
|
83 |
aGraphicsContext->DrawRect(rc);
|
sl@0
|
84 |
aScreenDevice->Update();
|
sl@0
|
85 |
}
|
sl@0
|
86 |
void PostDrawStep(CFbsScreenDevice* aScreenDevice, CFbsBitGc*)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
aScreenDevice->Update();
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
private:
|
sl@0
|
92 |
TPoint iOrigin;
|
sl@0
|
93 |
TDrawFunctor& iFunctor;
|
sl@0
|
94 |
TDrawParam* iPrm;
|
sl@0
|
95 |
TBool iCallGetch;
|
sl@0
|
96 |
};
|
sl@0
|
97 |
|
sl@0
|
98 |
//
|
sl@0
|
99 |
//TDrawTextFunctor class is used for CFbsBitGc text drawing/scaling tests
|
sl@0
|
100 |
class TDrawTextFunctor
|
sl@0
|
101 |
{
|
sl@0
|
102 |
public:
|
sl@0
|
103 |
void operator()(CFbsBitGc* aGraphicsContext, CFont* aFont)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
__ASSERT_DEBUG(aFont, User::Invariant());
|
sl@0
|
106 |
_LIT(KTestText, "ABCDEFGH-0123456789");
|
sl@0
|
107 |
_LIT(KTestText2, "ijklmnopqrst");
|
sl@0
|
108 |
TPoint textPos = TPoint(0, aFont->AscentInPixels());
|
sl@0
|
109 |
TPoint textPos2 = TPoint(3, aFont->AscentInPixels() + 3);
|
sl@0
|
110 |
TInt text2Width = aFont->TextWidthInPixels(KTestText2);
|
sl@0
|
111 |
TPoint textPos3 = TPoint(aFont->HeightInPixels() * 3, aFont->AscentInPixels() + text2Width + 3);
|
sl@0
|
112 |
|
sl@0
|
113 |
aGraphicsContext->DrawText(KTestText, textPos);
|
sl@0
|
114 |
aGraphicsContext->DrawTextVertical(KTestText2, textPos2, EFalse);
|
sl@0
|
115 |
aGraphicsContext->DrawTextVertical(KTestText2, textPos3, ETrue);
|
sl@0
|
116 |
}
|
sl@0
|
117 |
};
|
sl@0
|
118 |
|
sl@0
|
119 |
|
sl@0
|
120 |
//
|
sl@0
|
121 |
//TDrawBitmapFunctor class is used for CFbsBitGc bitmap (DrawBitmap) drawing/scaling tests
|
sl@0
|
122 |
class TDrawBitmapFunctor
|
sl@0
|
123 |
{
|
sl@0
|
124 |
public:
|
sl@0
|
125 |
void operator()(CFbsBitGc* aGraphicsContext, CFbsBitmap* aBitmap)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
__ASSERT_DEBUG(aBitmap, User::Invariant());
|
sl@0
|
128 |
TSize size = aBitmap->SizeInPixels();
|
sl@0
|
129 |
aGraphicsContext->DrawBitmap(TRect(2, 2, size.iWidth + 2, size.iHeight + 2), aBitmap);
|
sl@0
|
130 |
}
|
sl@0
|
131 |
};
|
sl@0
|
132 |
|
sl@0
|
133 |
|
sl@0
|
134 |
//
|
sl@0
|
135 |
//TBitBltMaskedFunctor class is used for CFbsBitGc::BitBltMasked drawing/scaling tests
|
sl@0
|
136 |
struct TMaskedBitmapPrm
|
sl@0
|
137 |
{
|
sl@0
|
138 |
CFbsBitmap* iBitmap;
|
sl@0
|
139 |
CFbsBitmap* iMaskBitmap;
|
sl@0
|
140 |
};
|
sl@0
|
141 |
class TBitBltMaskedFunctor
|
sl@0
|
142 |
{
|
sl@0
|
143 |
public:
|
sl@0
|
144 |
void operator()(CFbsBitGc* aGraphicsContext, TMaskedBitmapPrm* aPrm)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
__ASSERT_DEBUG(aPrm, User::Invariant());
|
sl@0
|
147 |
TSize size = aPrm->iBitmap->SizeInPixels();
|
sl@0
|
148 |
TPoint pt(2, 2);
|
sl@0
|
149 |
TPoint pt2(pt.iX + size.iWidth + 10, pt.iY);
|
sl@0
|
150 |
TRect rc(pt, size);
|
sl@0
|
151 |
aGraphicsContext->BitBlt(pt, aPrm->iBitmap);
|
sl@0
|
152 |
aGraphicsContext->BitBltMasked(pt2, aPrm->iBitmap, rc, aPrm->iMaskBitmap, EFalse);
|
sl@0
|
153 |
}
|
sl@0
|
154 |
};
|
sl@0
|
155 |
|
sl@0
|
156 |
//-------------
|
sl@0
|
157 |
CTBitgdiScaling::CTBitgdiScaling(CTestStep* aStep) :
|
sl@0
|
158 |
CTGraphicsBase(aStep)
|
sl@0
|
159 |
{
|
sl@0
|
160 |
|
sl@0
|
161 |
}
|
sl@0
|
162 |
|
sl@0
|
163 |
CTBitgdiScaling::~CTBitgdiScaling()
|
sl@0
|
164 |
{
|
sl@0
|
165 |
delete iScreenDevice;
|
sl@0
|
166 |
delete iGraphicsContext;
|
sl@0
|
167 |
delete iScreenDevice2;
|
sl@0
|
168 |
delete iGraphicsContext2;
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
void CTBitgdiScaling::ConstructL()
|
sl@0
|
172 |
{
|
sl@0
|
173 |
#if defined __WINS__ || defined __WINSCW__
|
sl@0
|
174 |
ChangeScreenDeviceL();
|
sl@0
|
175 |
#endif//defined __WINS__ || defined __WINSCW__
|
sl@0
|
176 |
|
sl@0
|
177 |
TDisplayMode theDisplayMode = (static_cast<CTBitgdiScalingStep*>(iStep))->DisplayMode();
|
sl@0
|
178 |
_LIT(KLog,"Screen Display Mode %S");
|
sl@0
|
179 |
INFO_PRINTF2(KLog,&ColorModeName(theDisplayMode));
|
sl@0
|
180 |
TInt err = CreateScreenDeviceAndContextL(theDisplayMode, iScreenDevice, iGraphicsContext);
|
sl@0
|
181 |
TEST(err == KErrNone);
|
sl@0
|
182 |
|
sl@0
|
183 |
err = CreateScreenDeviceAndContextL(theDisplayMode, iScreenDevice2, iGraphicsContext2);
|
sl@0
|
184 |
TSize size = iScreenDevice->SizeInPixels();
|
sl@0
|
185 |
_LIT(KSize,"[%d,%d] screen pixels");
|
sl@0
|
186 |
INFO_PRINTF3(KSize, size.iWidth, size.iHeight);
|
sl@0
|
187 |
TEST(err == KErrNone);
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
void CTBitgdiScaling::RunTestCaseL(TInt aCurTestCase)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
((CTBitgdiScalingStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
193 |
switch(aCurTestCase)
|
sl@0
|
194 |
{
|
sl@0
|
195 |
case 1:
|
sl@0
|
196 |
((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0032"));
|
sl@0
|
197 |
FontScalingL(iScreenDevice, iGraphicsContext);
|
sl@0
|
198 |
break;
|
sl@0
|
199 |
case 2:
|
sl@0
|
200 |
((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0033"));
|
sl@0
|
201 |
BitmapScalingL(iScreenDevice, iGraphicsContext);
|
sl@0
|
202 |
break;
|
sl@0
|
203 |
case 3:
|
sl@0
|
204 |
((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0034"));
|
sl@0
|
205 |
BitBltMaskedScalingL(iScreenDevice, iGraphicsContext);
|
sl@0
|
206 |
break;
|
sl@0
|
207 |
case 4:
|
sl@0
|
208 |
((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0035"));
|
sl@0
|
209 |
DrawingScalingL(iScreenDevice, iGraphicsContext);
|
sl@0
|
210 |
break;
|
sl@0
|
211 |
case 5:
|
sl@0
|
212 |
((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0036"));
|
sl@0
|
213 |
MapColors(iScreenDevice, iGraphicsContext);
|
sl@0
|
214 |
break;
|
sl@0
|
215 |
case 6:
|
sl@0
|
216 |
/**
|
sl@0
|
217 |
@SYMTestCaseID GRAPHICS-BITGDI-0117
|
sl@0
|
218 |
*/
|
sl@0
|
219 |
((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0117"));
|
sl@0
|
220 |
BitmapScalingL(iScreenDevice, iGraphicsContext, iScreenDevice2, iGraphicsContext2);
|
sl@0
|
221 |
break;
|
sl@0
|
222 |
case 7:
|
sl@0
|
223 |
((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0037"));
|
sl@0
|
224 |
RunTests2L();
|
sl@0
|
225 |
return;
|
sl@0
|
226 |
case 8:
|
sl@0
|
227 |
((CTBitgdiScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
228 |
((CTBitgdiScalingStep*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
229 |
TestComplete();
|
sl@0
|
230 |
break;
|
sl@0
|
231 |
}
|
sl@0
|
232 |
((CTBitgdiScalingStep*)iStep)->RecordTestResultL();
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
//This function creates screen device and graphics context objects and pushesh them on the
|
sl@0
|
236 |
//cleanup stack.
|
sl@0
|
237 |
TInt CTBitgdiScaling::CreateScreenDeviceAndContextL(TDisplayMode aDisplayMode,
|
sl@0
|
238 |
CFbsScreenDevice*& aScreenDevice,
|
sl@0
|
239 |
CFbsBitGc*& aGraphicsContext)
|
sl@0
|
240 |
{
|
sl@0
|
241 |
__ASSERT_DEBUG(!aScreenDevice, User::Invariant());
|
sl@0
|
242 |
__ASSERT_DEBUG(!aGraphicsContext, User::Invariant());
|
sl@0
|
243 |
TRAPD(err, aScreenDevice = CFbsScreenDevice::NewL(KNullDesC, aDisplayMode));
|
sl@0
|
244 |
if (err!=KErrNone)
|
sl@0
|
245 |
{
|
sl@0
|
246 |
_LIT(KLog,"Failed to create screen device for mode %S err=%d");
|
sl@0
|
247 |
INFO_PRINTF3(KLog,&ColorModeName(aDisplayMode),err);
|
sl@0
|
248 |
}
|
sl@0
|
249 |
if(err == KErrNotSupported)
|
sl@0
|
250 |
{
|
sl@0
|
251 |
return err;
|
sl@0
|
252 |
}
|
sl@0
|
253 |
TEST(err == KErrNone);
|
sl@0
|
254 |
err = aScreenDevice->CreateContext((CGraphicsContext*&)aGraphicsContext);
|
sl@0
|
255 |
if (err!=KErrNone)
|
sl@0
|
256 |
{
|
sl@0
|
257 |
_LIT(KLog,"Failed to create screen graphics context mode %S err=%d");
|
sl@0
|
258 |
INFO_PRINTF3(KLog,&ColorModeName(aDisplayMode),err);
|
sl@0
|
259 |
}
|
sl@0
|
260 |
TEST(err == KErrNone);
|
sl@0
|
261 |
aGraphicsContext->SetUserDisplayMode(aDisplayMode);
|
sl@0
|
262 |
aScreenDevice->ChangeScreenDevice(NULL);
|
sl@0
|
263 |
aScreenDevice->SetAutoUpdate(EFalse);
|
sl@0
|
264 |
return err;
|
sl@0
|
265 |
}
|
sl@0
|
266 |
|
sl@0
|
267 |
#if defined __WINS__ || defined __WINSCW__
|
sl@0
|
268 |
//This test function might be used to debug ChangeScreenDevice() call.
|
sl@0
|
269 |
void CTBitgdiScaling::ChangeScreenDeviceL()
|
sl@0
|
270 |
{
|
sl@0
|
271 |
CFbsScreenDevice* screenDevice1=NULL;
|
sl@0
|
272 |
TInt leaveErr=KErrNone;;
|
sl@0
|
273 |
TInt depth1= EColor256;
|
sl@0
|
274 |
|
sl@0
|
275 |
// Try to get a colour screendevice
|
sl@0
|
276 |
for (;depth1<EColorLast && !screenDevice1;depth1++)
|
sl@0
|
277 |
{
|
sl@0
|
278 |
TRAP(leaveErr,screenDevice1 = CFbsScreenDevice::NewL(KNullDesC, TDisplayMode(depth1)));
|
sl@0
|
279 |
}
|
sl@0
|
280 |
if (leaveErr != KErrNone || !screenDevice1)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
// Try to get a greyscale screendevice as failed to get a colour one
|
sl@0
|
283 |
for (depth1=ENone;depth1<EColor256 && !screenDevice1;depth1++)
|
sl@0
|
284 |
{
|
sl@0
|
285 |
TRAP(leaveErr,screenDevice1 = CFbsScreenDevice::NewL(KNullDesC, TDisplayMode(depth1)));
|
sl@0
|
286 |
}
|
sl@0
|
287 |
if (leaveErr != KErrNone || !screenDevice1)
|
sl@0
|
288 |
{
|
sl@0
|
289 |
INFO_PRINTF1(_L("Failed to create any screen devices. Re-leaving"));
|
sl@0
|
290 |
User::Leave(leaveErr);
|
sl@0
|
291 |
}
|
sl@0
|
292 |
}
|
sl@0
|
293 |
CleanupStack::PushL(screenDevice1);
|
sl@0
|
294 |
|
sl@0
|
295 |
CFbsBitGc* graphicsContext1 = NULL;
|
sl@0
|
296 |
User::LeaveIfError(screenDevice1->CreateContext(graphicsContext1));
|
sl@0
|
297 |
CleanupStack::PushL(graphicsContext1);
|
sl@0
|
298 |
graphicsContext1->SetUserDisplayMode(EColor256);
|
sl@0
|
299 |
screenDevice1->ChangeScreenDevice(NULL);
|
sl@0
|
300 |
screenDevice1->SetAutoUpdate(EFalse);
|
sl@0
|
301 |
|
sl@0
|
302 |
TInt err = screenDevice1->SetScalingFactor(TPoint(440, 40), 1, 1, 1, 1);
|
sl@0
|
303 |
TEST(err == KErrNone);
|
sl@0
|
304 |
graphicsContext1->Activate(screenDevice1);
|
sl@0
|
305 |
TRect rect1;
|
sl@0
|
306 |
screenDevice1->GetDrawRect(rect1);
|
sl@0
|
307 |
|
sl@0
|
308 |
CFbsScreenDevice* screenDevice2 = NULL;
|
sl@0
|
309 |
for (TInt depth2=ENone;depth2<EColorLast && ! screenDevice1;depth2++)
|
sl@0
|
310 |
if (depth2!=depth1)
|
sl@0
|
311 |
{
|
sl@0
|
312 |
TRAP(leaveErr,screenDevice2 = CFbsScreenDevice::NewL(KNullDesC, TDisplayMode(depth2)))
|
sl@0
|
313 |
}
|
sl@0
|
314 |
if (leaveErr != KErrNone || !screenDevice2)
|
sl@0
|
315 |
{
|
sl@0
|
316 |
INFO_PRINTF1(_L("Failed to create a different screen device - test skipped"));
|
sl@0
|
317 |
|
sl@0
|
318 |
}
|
sl@0
|
319 |
else
|
sl@0
|
320 |
{
|
sl@0
|
321 |
CleanupStack::PushL(screenDevice2);
|
sl@0
|
322 |
TRect rect2;
|
sl@0
|
323 |
screenDevice2->GetDrawRect(rect2);
|
sl@0
|
324 |
|
sl@0
|
325 |
screenDevice1->ChangeScreenDevice(screenDevice2);
|
sl@0
|
326 |
graphicsContext1->Activate(screenDevice1);
|
sl@0
|
327 |
screenDevice1->GetDrawRect(rect1);
|
sl@0
|
328 |
TEST(rect1 == rect2);
|
sl@0
|
329 |
TRegionFix<1> area(rect2);
|
sl@0
|
330 |
graphicsContext1->SetClippingRegion(&area);
|
sl@0
|
331 |
::CleanupStack::PopAndDestroy(screenDevice2);
|
sl@0
|
332 |
}
|
sl@0
|
333 |
::CleanupStack::PopAndDestroy(2);//screenDevice1 and graphicsContext1
|
sl@0
|
334 |
}
|
sl@0
|
335 |
#endif//defined __WINS__ || defined __WINSCW__
|
sl@0
|
336 |
|
sl@0
|
337 |
/**
|
sl@0
|
338 |
@SYMTestCaseID GRAPHICS-BITGDI-0032
|
sl@0
|
339 |
|
sl@0
|
340 |
@SYMDEF
|
sl@0
|
341 |
|
sl@0
|
342 |
@SYMTestCaseDesc FontScalingL function is used for CFbsBitGc text drawing/scaling tests
|
sl@0
|
343 |
|
sl@0
|
344 |
@SYMTestPriority High
|
sl@0
|
345 |
|
sl@0
|
346 |
@SYMTestStatus Implemented
|
sl@0
|
347 |
|
sl@0
|
348 |
@SYMTestActions Tests the drawing of some text to screen in specified height
|
sl@0
|
349 |
|
sl@0
|
350 |
@SYMTestExpectedResults Test should perform graphics operations succesfully.
|
sl@0
|
351 |
*/
|
sl@0
|
352 |
//
|
sl@0
|
353 |
void CTBitgdiScaling::FontScalingL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
354 |
{
|
sl@0
|
355 |
__ASSERT_DEBUG(aScreenDevice, User::Invariant());
|
sl@0
|
356 |
__ASSERT_DEBUG(aGraphicsContext, User::Invariant());
|
sl@0
|
357 |
INFO_PRINTF1(_L("Font Scaling"));
|
sl@0
|
358 |
const TInt KTypeFacesCnt = aScreenDevice->NumTypefaces();
|
sl@0
|
359 |
for(TInt i=0;i<KTypeFacesCnt;++i)
|
sl@0
|
360 |
{
|
sl@0
|
361 |
TTypefaceSupport typeFaceSupport;
|
sl@0
|
362 |
aScreenDevice->TypefaceSupport(typeFaceSupport, i);
|
sl@0
|
363 |
TFontSpec fontSpec;
|
sl@0
|
364 |
fontSpec.iTypeface = typeFaceSupport.iTypeface;
|
sl@0
|
365 |
fontSpec.iHeight = 14;
|
sl@0
|
366 |
CFont* font = NULL;
|
sl@0
|
367 |
User::LeaveIfError(aScreenDevice->GetNearestFontToDesignHeightInPixels(font, fontSpec));
|
sl@0
|
368 |
TDesC& fontName = fontSpec.iTypeface.iName;
|
sl@0
|
369 |
RDebug::Print(_L("%S\r\n"), &fontName);
|
sl@0
|
370 |
aGraphicsContext->UseFont(font);
|
sl@0
|
371 |
DrawTestText(aScreenDevice, aGraphicsContext, font);
|
sl@0
|
372 |
aScreenDevice->ReleaseFont(font);
|
sl@0
|
373 |
}
|
sl@0
|
374 |
}
|
sl@0
|
375 |
|
sl@0
|
376 |
/**
|
sl@0
|
377 |
@SYMTestCaseID GRAPHICS-BITGDI-0033
|
sl@0
|
378 |
|
sl@0
|
379 |
@SYMDEF
|
sl@0
|
380 |
|
sl@0
|
381 |
@SYMTestCaseDesc BitmapScalingL fucntion is used for CFbsBitGc bitmap (DrawBitmap) drawing/scaling tests
|
sl@0
|
382 |
|
sl@0
|
383 |
@SYMTestPriority High
|
sl@0
|
384 |
|
sl@0
|
385 |
@SYMTestStatus Implemented
|
sl@0
|
386 |
|
sl@0
|
387 |
@SYMTestActions Loads in a number of bitmaps then scales them to the screen
|
sl@0
|
388 |
|
sl@0
|
389 |
@SYMTestExpectedResults Test should perform graphics operations succesfully.
|
sl@0
|
390 |
*/
|
sl@0
|
391 |
void CTBitgdiScaling::BitmapScalingL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
392 |
{
|
sl@0
|
393 |
INFO_PRINTF1(_L("Bitmap Scaling"));
|
sl@0
|
394 |
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
|
sl@0
|
395 |
CleanupStack::PushL(bitmap);
|
sl@0
|
396 |
//8 - it is the number of bitmaps in mbm file - see GenBitmaps.mk where this mbm file is generated
|
sl@0
|
397 |
for(TInt i=0;i<8;i++)
|
sl@0
|
398 |
{
|
sl@0
|
399 |
bitmap->Reset();
|
sl@0
|
400 |
User::LeaveIfError(bitmap->Load(KTestBmp, i));
|
sl@0
|
401 |
TSize size = bitmap->SizeInPixels();
|
sl@0
|
402 |
TPoint ptOrigin(size.iWidth + 10, 3);
|
sl@0
|
403 |
|
sl@0
|
404 |
TDrawBitmapFunctor functor;
|
sl@0
|
405 |
TDrawComposite<TDrawBitmapFunctor, CFbsBitmap> composite(ptOrigin, functor, bitmap);
|
sl@0
|
406 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
407 |
}
|
sl@0
|
408 |
CleanupStack::PopAndDestroy(bitmap);
|
sl@0
|
409 |
}
|
sl@0
|
410 |
|
sl@0
|
411 |
/**
|
sl@0
|
412 |
@SYMTestCaseID GRAPHICS-BITGDI-0034
|
sl@0
|
413 |
|
sl@0
|
414 |
@SYMDEF
|
sl@0
|
415 |
|
sl@0
|
416 |
@SYMTestCaseDesc BitBltMaskedScalingL fucntion is used for CFbsBitGc::BitBltMasked drawing/scaling tests
|
sl@0
|
417 |
|
sl@0
|
418 |
@SYMTestPriority High
|
sl@0
|
419 |
|
sl@0
|
420 |
@SYMTestStatus Implemented
|
sl@0
|
421 |
|
sl@0
|
422 |
@SYMTestActions Loads in a number of bitmaps and their masks then scales them to the screen
|
sl@0
|
423 |
|
sl@0
|
424 |
@SYMTestExpectedResults Test should perform graphics operations succesfully.
|
sl@0
|
425 |
*/
|
sl@0
|
426 |
void CTBitgdiScaling::BitBltMaskedScalingL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
427 |
{
|
sl@0
|
428 |
INFO_PRINTF1(_L("BitBltMasked Scaling"));
|
sl@0
|
429 |
|
sl@0
|
430 |
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
|
sl@0
|
431 |
CleanupStack::PushL(bitmap);
|
sl@0
|
432 |
User::LeaveIfError(bitmap->Load(KTestBmp, 0));
|
sl@0
|
433 |
TSize size = bitmap->SizeInPixels();
|
sl@0
|
434 |
|
sl@0
|
435 |
CFbsBitmap* maskBitmap = new (ELeave) CFbsBitmap;
|
sl@0
|
436 |
CleanupStack::PushL(maskBitmap);
|
sl@0
|
437 |
User::LeaveIfError(maskBitmap->Create(size, EGray256));
|
sl@0
|
438 |
|
sl@0
|
439 |
TBitmapUtil bmpUtil(maskBitmap);
|
sl@0
|
440 |
bmpUtil.Begin(TPoint(0, 0));
|
sl@0
|
441 |
for(TInt i=0;i<size.iWidth;++i)
|
sl@0
|
442 |
{
|
sl@0
|
443 |
for(TInt j=0;j<size.iHeight;++j)
|
sl@0
|
444 |
{
|
sl@0
|
445 |
bmpUtil.SetPos(TPoint(i, j));
|
sl@0
|
446 |
bmpUtil.SetPixel(0x00555555);
|
sl@0
|
447 |
}
|
sl@0
|
448 |
}
|
sl@0
|
449 |
bmpUtil.End();
|
sl@0
|
450 |
|
sl@0
|
451 |
TPoint ptOrigin(size.iWidth * 3, 7);
|
sl@0
|
452 |
TMaskedBitmapPrm prm = {bitmap, maskBitmap};
|
sl@0
|
453 |
TBitBltMaskedFunctor functor;
|
sl@0
|
454 |
TDrawComposite<TBitBltMaskedFunctor, TMaskedBitmapPrm> composite(ptOrigin, functor, &prm);
|
sl@0
|
455 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
456 |
CleanupStack::PopAndDestroy(2);//maskBitmap and bitmap
|
sl@0
|
457 |
}
|
sl@0
|
458 |
|
sl@0
|
459 |
/**
|
sl@0
|
460 |
@SYMTestCaseID GRAPHICS-BITGDI-0035
|
sl@0
|
461 |
|
sl@0
|
462 |
@SYMDEF
|
sl@0
|
463 |
|
sl@0
|
464 |
@SYMTestCaseDesc DrawingScalingL function is used for CFbsBitGc::DrawXXX drawing/scaling tests
|
sl@0
|
465 |
|
sl@0
|
466 |
@SYMTestPriority High
|
sl@0
|
467 |
|
sl@0
|
468 |
@SYMTestStatus Implemented
|
sl@0
|
469 |
|
sl@0
|
470 |
@SYMTestActions Tests the scaling various basic graphic primitives
|
sl@0
|
471 |
|
sl@0
|
472 |
@SYMTestExpectedResults Test should perform graphics operations succesfully.
|
sl@0
|
473 |
*/
|
sl@0
|
474 |
void CTBitgdiScaling::DrawingScalingL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
475 |
{
|
sl@0
|
476 |
DrawArc(aScreenDevice, aGraphicsContext);
|
sl@0
|
477 |
DrawPie(aScreenDevice, aGraphicsContext);
|
sl@0
|
478 |
DrawRoundRect(aScreenDevice, aGraphicsContext);
|
sl@0
|
479 |
DrawPolyLineL(aScreenDevice, aGraphicsContext);
|
sl@0
|
480 |
DrawPolyLineNoEndPointL(aScreenDevice, aGraphicsContext);
|
sl@0
|
481 |
DrawPolygonL(aScreenDevice, aGraphicsContext);
|
sl@0
|
482 |
DrawEllipse(aScreenDevice, aGraphicsContext);
|
sl@0
|
483 |
DrawLine(aScreenDevice, aGraphicsContext);
|
sl@0
|
484 |
DrawRect(aScreenDevice, aGraphicsContext);
|
sl@0
|
485 |
ShadowFade(aScreenDevice, aGraphicsContext);
|
sl@0
|
486 |
}
|
sl@0
|
487 |
|
sl@0
|
488 |
//
|
sl@0
|
489 |
//TMapColorsFunctor class is used for CFbsBitGc::MapColors drawing/scaling tests
|
sl@0
|
490 |
class TMapColorsFunctor
|
sl@0
|
491 |
{
|
sl@0
|
492 |
public:
|
sl@0
|
493 |
void operator()(CFbsBitGc* aGraphicsContext, TEmpty*)
|
sl@0
|
494 |
{
|
sl@0
|
495 |
aGraphicsContext->DrawRect(TRect(7, 13, 45, 67));
|
sl@0
|
496 |
TRgb colors[] = {TRgb(0x00, 0x00, 0x00), TRgb(0xFF, 0x20, 0x20)};
|
sl@0
|
497 |
aGraphicsContext->MapColors(TRect(5, 10, 50, 70), colors);
|
sl@0
|
498 |
}
|
sl@0
|
499 |
};
|
sl@0
|
500 |
|
sl@0
|
501 |
/**
|
sl@0
|
502 |
@SYMTestCaseID GRAPHICS-BITGDI-0036
|
sl@0
|
503 |
|
sl@0
|
504 |
@SYMDEF
|
sl@0
|
505 |
|
sl@0
|
506 |
@SYMTestCaseDesc MapColors function is used for CFbsBitGc::MapColors drawing/scaling tests
|
sl@0
|
507 |
|
sl@0
|
508 |
@SYMTestPriority High
|
sl@0
|
509 |
|
sl@0
|
510 |
@SYMTestStatus Implemented
|
sl@0
|
511 |
|
sl@0
|
512 |
@SYMTestActions tests scaling of mapp3ed colours
|
sl@0
|
513 |
|
sl@0
|
514 |
@SYMTestExpectedResults Test should perform graphics operations succesfully.
|
sl@0
|
515 |
*/
|
sl@0
|
516 |
//
|
sl@0
|
517 |
void CTBitgdiScaling::MapColors(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
518 |
{
|
sl@0
|
519 |
INFO_PRINTF1(_L("MapColors scaling"));
|
sl@0
|
520 |
TMapColorsFunctor functor;
|
sl@0
|
521 |
TDrawComposite<TMapColorsFunctor, TEmpty> composite(TPoint(83, 11), functor, NULL);
|
sl@0
|
522 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
523 |
}
|
sl@0
|
524 |
|
sl@0
|
525 |
//BitmapScalingL fucntion is used for CFbsBitGc bitmap (DrawBitmap) drawing/scaling tests
|
sl@0
|
526 |
//2 screen devices used - scaled and non-scaled
|
sl@0
|
527 |
void CTBitgdiScaling::BitmapScalingL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext,
|
sl@0
|
528 |
CFbsScreenDevice* aScreenDevice2, CFbsBitGc* aGraphicsContext2,
|
sl@0
|
529 |
TBool aCallGetch)
|
sl@0
|
530 |
{
|
sl@0
|
531 |
__ASSERT_DEBUG(aScreenDevice, User::Invariant());
|
sl@0
|
532 |
__ASSERT_DEBUG(aGraphicsContext, User::Invariant());
|
sl@0
|
533 |
__ASSERT_DEBUG(aScreenDevice2, User::Invariant());
|
sl@0
|
534 |
__ASSERT_DEBUG(aGraphicsContext2, User::Invariant());
|
sl@0
|
535 |
|
sl@0
|
536 |
INFO_PRINTF1(_L("Bitmap Scaling - 2 devices"));
|
sl@0
|
537 |
|
sl@0
|
538 |
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
|
sl@0
|
539 |
CleanupStack::PushL(bitmap);
|
sl@0
|
540 |
|
sl@0
|
541 |
//8 - it is the number of bitmaps in mbm file - see GenBitmaps.mk where this mbm file is generated
|
sl@0
|
542 |
for(TInt i=0;i<8;i++)
|
sl@0
|
543 |
{
|
sl@0
|
544 |
bitmap->Reset();
|
sl@0
|
545 |
User::LeaveIfError(bitmap->Load(KTestBmp, i));
|
sl@0
|
546 |
TSize size = bitmap->SizeInPixels();
|
sl@0
|
547 |
TPoint ptOrigin(size.iWidth + 10, 3);
|
sl@0
|
548 |
|
sl@0
|
549 |
TInt err = aScreenDevice2->SetScalingFactor(ptOrigin, KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
550 |
TEST(err == KErrNone);
|
sl@0
|
551 |
aGraphicsContext2->Activate(aScreenDevice2);
|
sl@0
|
552 |
|
sl@0
|
553 |
aGraphicsContext->Clear();
|
sl@0
|
554 |
aGraphicsContext2->Clear();
|
sl@0
|
555 |
|
sl@0
|
556 |
TSize screenSize = aScreenDevice->SizeInPixels();
|
sl@0
|
557 |
TRect rc(0, 0, screenSize.iWidth - 1, screenSize.iHeight - 1);
|
sl@0
|
558 |
aGraphicsContext->DrawRect(rc);
|
sl@0
|
559 |
|
sl@0
|
560 |
aGraphicsContext->DrawBitmap(TRect(2, 2, size.iWidth + 2, size.iHeight + 2), bitmap);
|
sl@0
|
561 |
|
sl@0
|
562 |
TSize screenSize2 = aScreenDevice2->SizeInPixels();
|
sl@0
|
563 |
TRect rc2(0, 0, screenSize2.iWidth - 1, screenSize2.iHeight - 1);
|
sl@0
|
564 |
aGraphicsContext2->DrawRect(rc2);
|
sl@0
|
565 |
|
sl@0
|
566 |
aGraphicsContext2->DrawBitmap(TRect(2, 2, size.iWidth + 2, size.iHeight + 2), bitmap);
|
sl@0
|
567 |
|
sl@0
|
568 |
aScreenDevice->Update();
|
sl@0
|
569 |
aScreenDevice2->Update();
|
sl@0
|
570 |
|
sl@0
|
571 |
if(aCallGetch)
|
sl@0
|
572 |
{
|
sl@0
|
573 |
//TheTest.Getch();
|
sl@0
|
574 |
}
|
sl@0
|
575 |
}
|
sl@0
|
576 |
CleanupStack::PopAndDestroy(bitmap);
|
sl@0
|
577 |
}
|
sl@0
|
578 |
|
sl@0
|
579 |
//DrawTestText function is used for CFbsBitGc text drawing/scaling tests
|
sl@0
|
580 |
void CTBitgdiScaling::DrawTestText(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext, CFont* aFont)
|
sl@0
|
581 |
{
|
sl@0
|
582 |
__ASSERT_DEBUG(aFont, User::Invariant());
|
sl@0
|
583 |
TPoint ptOrigin(aFont->HeightInPixels() * 4, aFont->AscentInPixels() * 2);
|
sl@0
|
584 |
TDrawTextFunctor functor;
|
sl@0
|
585 |
TDrawComposite<TDrawTextFunctor, CFont> composite(ptOrigin, functor, aFont);
|
sl@0
|
586 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
587 |
}
|
sl@0
|
588 |
|
sl@0
|
589 |
//
|
sl@0
|
590 |
//TDrawArcFunctor class is used for CFbsBitGc::DrawArc drawing/scaling tests
|
sl@0
|
591 |
class TDrawArcFunctor
|
sl@0
|
592 |
{
|
sl@0
|
593 |
public:
|
sl@0
|
594 |
void operator()(CFbsBitGc* aGraphicsContext, TEmpty*)
|
sl@0
|
595 |
{
|
sl@0
|
596 |
aGraphicsContext->DrawArc(TRect(0, 0, 40, 40), TPoint(0, 20), TPoint(40, 20));
|
sl@0
|
597 |
}
|
sl@0
|
598 |
};
|
sl@0
|
599 |
|
sl@0
|
600 |
//DrawArc function is used for CFbsBitGc::DrawArc drawing/scaling tests
|
sl@0
|
601 |
void CTBitgdiScaling::DrawArc(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
602 |
{
|
sl@0
|
603 |
INFO_PRINTF1(_L("DrawArc scaling"));
|
sl@0
|
604 |
TDrawArcFunctor functor;
|
sl@0
|
605 |
TDrawComposite<TDrawArcFunctor, TEmpty> composite(TPoint(40, 0), functor, NULL);
|
sl@0
|
606 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
607 |
}
|
sl@0
|
608 |
|
sl@0
|
609 |
//
|
sl@0
|
610 |
//TDrawPieFunctor class is used for CFbsBitGc::DrawPie drawing/scaling tests
|
sl@0
|
611 |
class TDrawPieFunctor
|
sl@0
|
612 |
{
|
sl@0
|
613 |
public:
|
sl@0
|
614 |
void operator()(CFbsBitGc* aGraphicsContext, TEmpty*)
|
sl@0
|
615 |
{
|
sl@0
|
616 |
aGraphicsContext->DrawPie(TRect(0, 0, 40, 40), TPoint(0, 20), TPoint(40, 20));
|
sl@0
|
617 |
}
|
sl@0
|
618 |
};
|
sl@0
|
619 |
|
sl@0
|
620 |
//DrawPie function is used for CFbsBitGc::DrawPie drawing/scaling tests
|
sl@0
|
621 |
void CTBitgdiScaling::DrawPie(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
622 |
{
|
sl@0
|
623 |
INFO_PRINTF1(_L("DrawPie scaling"));
|
sl@0
|
624 |
TDrawPieFunctor functor;
|
sl@0
|
625 |
TDrawComposite<TDrawPieFunctor, TEmpty> composite(TPoint(40, 0), functor, NULL);
|
sl@0
|
626 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
627 |
}
|
sl@0
|
628 |
|
sl@0
|
629 |
//
|
sl@0
|
630 |
//TDrawRoundRectFunctor class is used for CFbsBitGc::DrawRoundRect drawing/scaling tests
|
sl@0
|
631 |
class TDrawRoundRectFunctor
|
sl@0
|
632 |
{
|
sl@0
|
633 |
public:
|
sl@0
|
634 |
void operator()(CFbsBitGc* aGraphicsContext, TEmpty*)
|
sl@0
|
635 |
{
|
sl@0
|
636 |
aGraphicsContext->DrawRoundRect(TRect(0, 0, 40, 40), TSize(5, 5));
|
sl@0
|
637 |
}
|
sl@0
|
638 |
};
|
sl@0
|
639 |
|
sl@0
|
640 |
//DrawRoundRect function is used for CFbsBitGc::DrawRoundRect drawing/scaling tests
|
sl@0
|
641 |
void CTBitgdiScaling::DrawRoundRect(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
642 |
{
|
sl@0
|
643 |
INFO_PRINTF1(_L("DrawRoundRect scaling"));
|
sl@0
|
644 |
TDrawRoundRectFunctor functor;
|
sl@0
|
645 |
TDrawComposite<TDrawRoundRectFunctor, TEmpty> composite(TPoint(40, 0), functor, NULL);
|
sl@0
|
646 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
647 |
}
|
sl@0
|
648 |
|
sl@0
|
649 |
//
|
sl@0
|
650 |
|
sl@0
|
651 |
typedef CArrayFixFlat<TPoint> CPointArray;
|
sl@0
|
652 |
|
sl@0
|
653 |
//TDrawPolyLineFunctor class is used for CFbsBitGc::DrawPolyLine drawing/scaling tests
|
sl@0
|
654 |
class TDrawPolyLineFunctor
|
sl@0
|
655 |
{
|
sl@0
|
656 |
public:
|
sl@0
|
657 |
void operator()(CFbsBitGc* aGraphicsContext, CPointArray* aPoints)
|
sl@0
|
658 |
{
|
sl@0
|
659 |
aGraphicsContext->DrawPolyLine(aPoints);
|
sl@0
|
660 |
}
|
sl@0
|
661 |
};
|
sl@0
|
662 |
|
sl@0
|
663 |
//DrawPolyLineL function is used for CFbsBitGc::DrawPolyLine drawing/scaling tests
|
sl@0
|
664 |
void CTBitgdiScaling::DrawPolyLineL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
665 |
{
|
sl@0
|
666 |
INFO_PRINTF1(_L("DrawPolyLine scaling"));
|
sl@0
|
667 |
CPointArray* points = new (ELeave) CPointArray (4);
|
sl@0
|
668 |
CleanupStack::PushL(points);
|
sl@0
|
669 |
TPoint pt(1, 1);
|
sl@0
|
670 |
points->AppendL(pt);
|
sl@0
|
671 |
pt.SetXY(77, 23);
|
sl@0
|
672 |
points->AppendL(pt);
|
sl@0
|
673 |
pt.SetXY(38, 63);
|
sl@0
|
674 |
points->AppendL(pt);
|
sl@0
|
675 |
pt.SetXY(70, 51);
|
sl@0
|
676 |
points->AppendL(pt);
|
sl@0
|
677 |
TDrawPolyLineFunctor functor;
|
sl@0
|
678 |
TDrawComposite<TDrawPolyLineFunctor, CPointArray> composite(TPoint(80, 0), functor,
|
sl@0
|
679 |
points);
|
sl@0
|
680 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
681 |
CleanupStack::PopAndDestroy(points);
|
sl@0
|
682 |
}
|
sl@0
|
683 |
|
sl@0
|
684 |
//
|
sl@0
|
685 |
//TDrawPolyLineNoEndPointFunctor class is used for CFbsBitGc::DrawPolyLineNoEndPoint drawing/scaling tests
|
sl@0
|
686 |
class TDrawPolyLineNoEndPointFunctor
|
sl@0
|
687 |
{
|
sl@0
|
688 |
public:
|
sl@0
|
689 |
void operator()(CFbsBitGc* aGraphicsContext, CPointArray* aPoints)
|
sl@0
|
690 |
{
|
sl@0
|
691 |
aGraphicsContext->DrawPolyLineNoEndPoint(aPoints);
|
sl@0
|
692 |
}
|
sl@0
|
693 |
};
|
sl@0
|
694 |
|
sl@0
|
695 |
//DrawPolyLineNoEndPointL function is used for CFbsBitGc::DrawPolyLineNoEndPoint drawing/scaling tests
|
sl@0
|
696 |
void CTBitgdiScaling::DrawPolyLineNoEndPointL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
697 |
{
|
sl@0
|
698 |
INFO_PRINTF1(_L("DrawPolyLineNoEndPoint scaling"));
|
sl@0
|
699 |
CPointArray* points = new (ELeave) CPointArray (4);
|
sl@0
|
700 |
CleanupStack::PushL(points);
|
sl@0
|
701 |
TPoint pt(1, 1);
|
sl@0
|
702 |
points->AppendL(pt);
|
sl@0
|
703 |
pt.SetXY(77, 23);
|
sl@0
|
704 |
points->AppendL(pt);
|
sl@0
|
705 |
pt.SetXY(38, 63);
|
sl@0
|
706 |
points->AppendL(pt);
|
sl@0
|
707 |
pt.SetXY(70, 51);
|
sl@0
|
708 |
points->AppendL(pt);
|
sl@0
|
709 |
TDrawPolyLineNoEndPointFunctor functor;
|
sl@0
|
710 |
TDrawComposite<TDrawPolyLineNoEndPointFunctor, CPointArray> composite(
|
sl@0
|
711 |
TPoint(80, 0), functor,
|
sl@0
|
712 |
points);
|
sl@0
|
713 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
714 |
CleanupStack::PopAndDestroy(points);
|
sl@0
|
715 |
}
|
sl@0
|
716 |
|
sl@0
|
717 |
//
|
sl@0
|
718 |
//TDrawPolygonFunctor class is used for CFbsBitGc::DrawPolygon drawing/scaling tests
|
sl@0
|
719 |
class TDrawPolygonFunctor
|
sl@0
|
720 |
{
|
sl@0
|
721 |
public:
|
sl@0
|
722 |
void operator()(CFbsBitGc* aGraphicsContext, CPointArray* aPoints)
|
sl@0
|
723 |
{
|
sl@0
|
724 |
aGraphicsContext->DrawPolygon(aPoints);
|
sl@0
|
725 |
}
|
sl@0
|
726 |
};
|
sl@0
|
727 |
|
sl@0
|
728 |
//DrawPolygon function is used for CFbsBitGc::DrawPolygon drawing/scaling tests
|
sl@0
|
729 |
void CTBitgdiScaling::DrawPolygonL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
730 |
{
|
sl@0
|
731 |
INFO_PRINTF1(_L("DrawPolygon scaling"));
|
sl@0
|
732 |
CPointArray* points = new (ELeave) CPointArray (6);
|
sl@0
|
733 |
CleanupStack::PushL(points);
|
sl@0
|
734 |
TPoint pt(1, 20);
|
sl@0
|
735 |
points->AppendL(pt);
|
sl@0
|
736 |
pt.SetXY(23, 3);
|
sl@0
|
737 |
points->AppendL(pt);
|
sl@0
|
738 |
pt.SetXY(61, 29);
|
sl@0
|
739 |
points->AppendL(pt);
|
sl@0
|
740 |
pt.SetXY(51, 47);
|
sl@0
|
741 |
points->AppendL(pt);
|
sl@0
|
742 |
pt.SetXY(31, 39);
|
sl@0
|
743 |
points->AppendL(pt);
|
sl@0
|
744 |
pt.SetXY(44, 17);
|
sl@0
|
745 |
points->AppendL(pt);
|
sl@0
|
746 |
TDrawPolygonFunctor functor;
|
sl@0
|
747 |
TDrawComposite<TDrawPolygonFunctor, CPointArray> composite(TPoint(80, 0), functor,
|
sl@0
|
748 |
points);
|
sl@0
|
749 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
750 |
CleanupStack::PopAndDestroy(points);
|
sl@0
|
751 |
}
|
sl@0
|
752 |
|
sl@0
|
753 |
//
|
sl@0
|
754 |
//TDrawEllipseFunctor class is used for CFbsBitGc::DrawEllipse drawing/scaling tests
|
sl@0
|
755 |
class TDrawEllipseFunctor
|
sl@0
|
756 |
{
|
sl@0
|
757 |
public:
|
sl@0
|
758 |
void operator()(CFbsBitGc* aGraphicsContext, TEmpty*)
|
sl@0
|
759 |
{
|
sl@0
|
760 |
aGraphicsContext->DrawEllipse(TRect(11, 13, 40, 70));
|
sl@0
|
761 |
}
|
sl@0
|
762 |
};
|
sl@0
|
763 |
|
sl@0
|
764 |
//DrawEllipse function is used for CFbsBitGc::DrawEllipse drawing/scaling tests
|
sl@0
|
765 |
void CTBitgdiScaling::DrawEllipse(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
766 |
{
|
sl@0
|
767 |
INFO_PRINTF1(_L("DrawEllipse scaling"));
|
sl@0
|
768 |
TDrawEllipseFunctor functor;
|
sl@0
|
769 |
TDrawComposite<TDrawEllipseFunctor, TEmpty> composite(TPoint(50, 27), functor, NULL);
|
sl@0
|
770 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
771 |
}
|
sl@0
|
772 |
|
sl@0
|
773 |
//
|
sl@0
|
774 |
//TDrawLineFunctor class is used for CFbsBitGc::DrawLine drawing/scaling tests
|
sl@0
|
775 |
class TDrawLineFunctor
|
sl@0
|
776 |
{
|
sl@0
|
777 |
public:
|
sl@0
|
778 |
void operator()(CFbsBitGc* aGraphicsContext, TEmpty*)
|
sl@0
|
779 |
{
|
sl@0
|
780 |
aGraphicsContext->DrawLine(TPoint(7, 13), TPoint(45, 67));
|
sl@0
|
781 |
aGraphicsContext->DrawLineTo(TPoint(33, 53));
|
sl@0
|
782 |
aGraphicsContext->DrawLineBy(TPoint(11, 53));
|
sl@0
|
783 |
}
|
sl@0
|
784 |
};
|
sl@0
|
785 |
|
sl@0
|
786 |
//DrawLine function is used for CFbsBitGc::DrawLineXX drawing/scaling tests
|
sl@0
|
787 |
void CTBitgdiScaling::DrawLine(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
788 |
{
|
sl@0
|
789 |
INFO_PRINTF1(_L("DrawLineXX scaling"));
|
sl@0
|
790 |
TDrawLineFunctor functor;
|
sl@0
|
791 |
TDrawComposite<TDrawLineFunctor, TEmpty> composite(TPoint(83, 11), functor, NULL);
|
sl@0
|
792 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
793 |
}
|
sl@0
|
794 |
|
sl@0
|
795 |
//
|
sl@0
|
796 |
//TDrawRectFunctor class is used for CFbsBitGc::DrawRect drawing/scaling tests
|
sl@0
|
797 |
class TDrawRectFunctor
|
sl@0
|
798 |
{
|
sl@0
|
799 |
public:
|
sl@0
|
800 |
void operator()(CFbsBitGc* aGraphicsContext, TEmpty*)
|
sl@0
|
801 |
{
|
sl@0
|
802 |
aGraphicsContext->DrawRect(TRect(7, 13, 45, 67));
|
sl@0
|
803 |
}
|
sl@0
|
804 |
};
|
sl@0
|
805 |
|
sl@0
|
806 |
//DrawRect function is used for CFbsBitGc::DrawRect drawing/scaling tests
|
sl@0
|
807 |
void CTBitgdiScaling::DrawRect(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
808 |
{
|
sl@0
|
809 |
INFO_PRINTF1(_L("DrawRect scaling"));
|
sl@0
|
810 |
TDrawRectFunctor functor;
|
sl@0
|
811 |
TDrawComposite<TDrawRectFunctor, TEmpty> composite(TPoint(83, 11), functor, NULL);
|
sl@0
|
812 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
813 |
}
|
sl@0
|
814 |
|
sl@0
|
815 |
//
|
sl@0
|
816 |
//TShadowFadeFunctor class is used for CFbsBitGc::ShadowArea/FadeArea drawing/scaling tests
|
sl@0
|
817 |
class TShadowFadeFunctor
|
sl@0
|
818 |
{
|
sl@0
|
819 |
public:
|
sl@0
|
820 |
void operator()(CFbsBitGc* aGraphicsContext, TEmpty*)
|
sl@0
|
821 |
{
|
sl@0
|
822 |
aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
823 |
|
sl@0
|
824 |
aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
|
sl@0
|
825 |
aGraphicsContext->DrawRect(TRect(1, 1, 40, 20));
|
sl@0
|
826 |
aGraphicsContext->DrawRect(TRect(20, 20, 40, 40));
|
sl@0
|
827 |
RRegion shadowRgn;
|
sl@0
|
828 |
shadowRgn.AddRect(TRect(1, 1, 40, 20));
|
sl@0
|
829 |
shadowRgn.AddRect(TRect(20, 20, 40, 40));
|
sl@0
|
830 |
aGraphicsContext->ShadowArea(&shadowRgn);
|
sl@0
|
831 |
shadowRgn.Close();
|
sl@0
|
832 |
|
sl@0
|
833 |
aGraphicsContext->SetBrushColor(TRgb(0xFF, 0x00, 0xFF));
|
sl@0
|
834 |
aGraphicsContext->DrawRect(TRect(3, 25, 17, 33));
|
sl@0
|
835 |
aGraphicsContext->DrawRect(TRect(1, 43, 67, 55));
|
sl@0
|
836 |
RRegion fadeRgn;
|
sl@0
|
837 |
fadeRgn.AddRect(TRect(3, 25, 17, 33));
|
sl@0
|
838 |
fadeRgn.AddRect(TRect(1, 43, 67, 55));
|
sl@0
|
839 |
aGraphicsContext->FadeArea(&fadeRgn);
|
sl@0
|
840 |
fadeRgn.Close();
|
sl@0
|
841 |
|
sl@0
|
842 |
aGraphicsContext->SetBrushColor(TRgb(0xFF, 0xFF, 0xFF));
|
sl@0
|
843 |
aGraphicsContext->SetBrushStyle(CGraphicsContext::ENullBrush);
|
sl@0
|
844 |
}
|
sl@0
|
845 |
};
|
sl@0
|
846 |
|
sl@0
|
847 |
//ShadowFade function is used for CFbsBitGc::ShadowArea/FadeArea drawing/scaling tests
|
sl@0
|
848 |
void CTBitgdiScaling::ShadowFade(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
|
sl@0
|
849 |
{
|
sl@0
|
850 |
INFO_PRINTF1(_L("Shadow/Fade scaling"));
|
sl@0
|
851 |
TShadowFadeFunctor functor;
|
sl@0
|
852 |
TDrawComposite<TShadowFadeFunctor, TEmpty> composite(TPoint(83, 11), functor, NULL);
|
sl@0
|
853 |
composite.Draw(aScreenDevice, aGraphicsContext, this);
|
sl@0
|
854 |
}
|
sl@0
|
855 |
|
sl@0
|
856 |
//--------------
|
sl@0
|
857 |
__CONSTRUCT_STEP__(BitgdiScaling)
|
sl@0
|
858 |
|
sl@0
|
859 |
void CTBitgdiScalingStep::TestSetupL()
|
sl@0
|
860 |
{
|
sl@0
|
861 |
iDisplayMode = GetDisplayModeL();
|
sl@0
|
862 |
}
|
sl@0
|
863 |
|
sl@0
|
864 |
TDisplayMode CTBitgdiScalingStep::GetDisplayModeL()
|
sl@0
|
865 |
{
|
sl@0
|
866 |
CFbsScreenDevice* device = NULL;
|
sl@0
|
867 |
TDisplayMode mode = EColor64K;
|
sl@0
|
868 |
TRAPD(err, device = CFbsScreenDevice::NewL(KNullDesC, mode));
|
sl@0
|
869 |
if (err == KErrNotSupported)
|
sl@0
|
870 |
{
|
sl@0
|
871 |
mode = EColor256;
|
sl@0
|
872 |
TRAP(err, device = CFbsScreenDevice::NewL(KNullDesC, mode));
|
sl@0
|
873 |
}
|
sl@0
|
874 |
if (err == KErrNotSupported)
|
sl@0
|
875 |
{
|
sl@0
|
876 |
mode = EColor16MA;
|
sl@0
|
877 |
TRAP(err, device = CFbsScreenDevice::NewL(KNullDesC, mode));
|
sl@0
|
878 |
}
|
sl@0
|
879 |
if (err == KErrNotSupported)
|
sl@0
|
880 |
{
|
sl@0
|
881 |
mode = EColor16MAP;
|
sl@0
|
882 |
TRAP(err, device = CFbsScreenDevice::NewL(KNullDesC, mode));
|
sl@0
|
883 |
}
|
sl@0
|
884 |
TESTL(err == KErrNone);
|
sl@0
|
885 |
delete device;
|
sl@0
|
886 |
return mode;
|
sl@0
|
887 |
}
|