First public contribution.
1 // Copyright (c) 2004-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "TBitgdiScaling.h"
17 //#pragma warning(disable: 4127)
19 //X and Y scaling factors.
20 const TInt KScalingFactorX = 2;
21 const TInt KScalingFactorY = 3;
23 _LIT(KTestBmp, "z:\\system\\data\\BmCTest.mbm");
24 typedef CArrayFixFlat<TPoint> CPointArray;
27 //Choises one of the installed fonts and sets it as a default font for the graphics context.
28 static CFont* SetFontL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
30 TTypefaceSupport typeFaceSupport;
31 aScreenDevice->TypefaceSupport(typeFaceSupport, 0);
33 fontSpec.iTypeface = typeFaceSupport.iTypeface;
34 fontSpec.iHeight = 10;
36 User::LeaveIfError(aScreenDevice->GetNearestFontToDesignHeightInPixels(font, fontSpec));
37 aGraphicsContext->UseFont(font);
41 //Clears the screen and displays after that the scaling origin point.
42 static void Clear(CFbsBitGc* aGraphicsContext)
44 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
45 aGraphicsContext->SetBrushColor(KRgbWhite);
46 aGraphicsContext->Clear();
47 aGraphicsContext->SetPenSize(TSize(2, 2));
48 aGraphicsContext->SetPenColor(TRgb(0xFF, 0x00, 0x00));
49 aGraphicsContext->Plot(TPoint(0, 0));
50 aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
51 aGraphicsContext->DrawText(_L("Scaling Origin"), TPoint(0, 0));
54 //CFbsBitGc::DrawBitmap() test
55 void CTBitgdiScaling::TestDrawBitmapL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
57 INFO_PRINTF1(_L("DrawBitmap() - (0, 0) coord"));
58 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
59 CleanupStack::PushL(bitmap);
62 User::LeaveIfError(bitmap->Load(KTestBmp, 0));
64 ::Clear(aGraphicsContext);
65 TSize size = bitmap->SizeInPixels();
66 //RDebug::Print(_L("DrawBitmap %d, %d, %d, %d\r\n"), 0, 0, size.iWidth, size.iHeight);
67 aGraphicsContext->DrawBitmap(TRect(0, 0, size.iWidth, size.iHeight), bitmap);
68 aScreenDevice->Update();
70 CleanupStack::PopAndDestroy(bitmap);
73 //CFbsBitGc::Clear(), CFbsBitGc::Clear(const TRect& aRect), CFbsBitGc::DrawLine() test
74 void CTBitgdiScaling::TestClear(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
76 INFO_PRINTF1(_L("Clear(), DrawLine() - Neg.coord."));
77 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
80 aScreenDevice->GetDrawRect(drawRect);
82 //RDebug::Print(_L("DrawRect %d, %d, %d, %d\r\n"), drawRect.iTl.iX, drawRect.iTl.iY, drawRect.iBr.iX, drawRect.iBr.iY);
83 aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
84 aGraphicsContext->DrawRect(drawRect);
85 aScreenDevice->Update();
87 //RDebug::Print(_L("Clear\r\n"));
88 aGraphicsContext->SetBrushColor(KRgbWhite);
89 ::Clear(aGraphicsContext);
90 aScreenDevice->Update();
92 //RDebug::Print(_L("DrawRect %d, %d, %d, %d\r\n"), drawRect.iTl.iX, drawRect.iTl.iY, drawRect.iBr.iX, drawRect.iBr.iY);
93 aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
94 aGraphicsContext->DrawRect(drawRect);
95 aScreenDevice->Update();
97 //RDebug::Print(_L("Clear(TRect) %d, %d, %d, %d\r\n"), drawRect.iTl.iX, drawRect.iTl.iY, drawRect.iBr.iX, drawRect.iBr.iY);
98 aGraphicsContext->SetBrushColor(KRgbWhite);
99 drawRect.Shrink(1, 1);
100 aGraphicsContext->Clear(drawRect);
101 aScreenDevice->Update();
104 CGraphicsContext::TPenStyle penStyle[] =
106 CGraphicsContext::ENullPen,
107 CGraphicsContext::ESolidPen,
108 CGraphicsContext::EDottedPen,
109 CGraphicsContext::EDashedPen,
110 CGraphicsContext::EDotDashPen,
111 CGraphicsContext::EDotDotDashPen
115 TLineProps(const TPoint& aPt1, const TPoint& aPt2) :
123 TLineProps lineProps[] =
125 TLineProps(drawRect.iTl, drawRect.iBr - TPoint(1, 1)),
126 TLineProps(TPoint(drawRect.iTl.iX, drawRect.iBr.iY - 1), TPoint(drawRect.iBr.iX - 1, drawRect.iTl.iY))
128 for(TInt jj=0;jj<TInt(sizeof(lineProps)/sizeof(lineProps[0]));++jj)
130 for(TInt ii=0;ii<TInt(sizeof(penStyle)/sizeof(penStyle[0]));++ii)
132 aGraphicsContext->SetPenStyle(penStyle[ii]);
134 //RDebug::Print(_L("DrawLine %d, %d, %d, %d\r\n"), lineProps[jj].iPt1.iX, lineProps[jj].iPt1.iY, lineProps[jj].iPt2.iX, lineProps[jj].iPt2.iY);
135 ::Clear(aGraphicsContext);
136 aGraphicsContext->SetPenColor(TRgb(0x00, 0xFF, 0x00));
137 aGraphicsContext->SetPenSize(TSize(1, 1));
138 aGraphicsContext->DrawLine(lineProps[jj].iPt1, lineProps[jj].iPt2);
139 aScreenDevice->Update();
141 //RDebug::Print(_L("DrawLine %d, %d, %d, %d\r\n"), lineProps[jj].iPt1.iX, lineProps[jj].iPt1.iY, lineProps[jj].iPt2.iX, lineProps[jj].iPt2.iY);
142 ::Clear(aGraphicsContext);
143 aGraphicsContext->SetPenColor(TRgb(0x00, 0xFF, 0x00));
144 aGraphicsContext->SetPenSize(TSize(2, 2));
145 aGraphicsContext->DrawLine(lineProps[jj].iPt1, lineProps[jj].iPt2);
146 aScreenDevice->Update();
151 //CFbsBitGc::Bitblt(), CFbsBitGc::BitbltMasked(), CFbsBitGc::DrawBitmap() test
152 void CTBitgdiScaling::TestBitbltL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
154 INFO_PRINTF1(_L("Bitblt(), BitbltMasked(), DrawBitmap() - Neg.coord."));
155 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
156 CleanupStack::PushL(bitmap);
158 User::LeaveIfError(bitmap->Load(KTestBmp, 0));
159 TSize bmpSize = bitmap->SizeInPixels();
162 CFbsBitmap* maskBitmap = new (ELeave) CFbsBitmap;
163 CleanupStack::PushL(maskBitmap);
164 User::LeaveIfError(maskBitmap->Create(bmpSize, EGray256));
165 TBitmapUtil bmpUtil(maskBitmap);
166 bmpUtil.Begin(TPoint(0, 0));
167 for(ii=0;ii<bmpSize.iWidth;++ii)
169 for(jj=0;jj<bmpSize.iHeight;++jj)
171 bmpUtil.SetPos(TPoint(ii,jj));
172 bmpUtil.SetPixel(0xAA555555);
177 CFbsBitmap* maskBitmap2 = new (ELeave) CFbsBitmap;
178 CleanupStack::PushL(maskBitmap2);
179 User::LeaveIfError(maskBitmap2->Create(bmpSize, EGray16));
180 TBitmapUtil bmpUtil2(maskBitmap2);
181 bmpUtil2.Begin(TPoint(0, 0));
182 for(ii=0;ii<bmpSize.iWidth;++ii)
184 for(jj=0;jj<bmpSize.iHeight;++jj)
186 bmpUtil2.SetPos(TPoint(ii,jj));
187 bmpUtil2.SetPixel(0xBBBBBB);
193 aScreenDevice->GetDrawRect(drawRect);
195 for(TInt x=drawRect.iTl.iX;x<(drawRect.iBr.iX-bmpSize.iWidth);x+=10)
197 for(TInt y=drawRect.iTl.iY;y<(drawRect.iBr.iY-bmpSize.iHeight);y+=10)
199 ::Clear(aGraphicsContext);
201 //RDebug::Print(_L("BitBlt %d, %d\r\n"), x, y);
202 aGraphicsContext->BitBlt(TPoint(x, y), bitmap);
204 TRect rc(TPoint(x + bmpSize.iWidth + 1, y + bmpSize.iHeight + 1), bmpSize);
205 //RDebug::Print(_L("DrawBitmap %d, %d, %d, %d\r\n"), rc.iTl.iX, rc.iTl.iY, rc.iBr.iX, rc.iBr.iY);
206 aGraphicsContext->DrawBitmap(rc, bitmap);
208 TRect rc2(TPoint(x + bmpSize.iWidth * 2 + 1, y + bmpSize.iHeight * 2 + 1), bmpSize);
209 //RDebug::Print(_L("BitBltMasked %d, %d, %d, %d\r\n"), rc2.iTl.iX, rc2.iTl.iY, rc2.iBr.iX, rc2.iBr.iY);
210 aGraphicsContext->BitBltMasked(rc2.iTl, bitmap, TRect(0, 0, bmpSize.iWidth, bmpSize.iHeight), maskBitmap, EFalse);
212 TRect rc3(TPoint(x + bmpSize.iWidth * 3 + 1, y + bmpSize.iHeight * 3 + 1), bmpSize);
213 //RDebug::Print(_L("BitBltMasked %d, %d, %d, %d\r\n"), rc3.iTl.iX, rc3.iTl.iY, rc3.iBr.iX, rc3.iBr.iY);
214 aGraphicsContext->BitBltMasked(rc3.iTl, bitmap, TRect(0, 0, bmpSize.iWidth, bmpSize.iHeight), maskBitmap2, EFalse);
216 aScreenDevice->Update();
219 CleanupStack::PopAndDestroy(3);//bitmap & maskBitmap & maskBitmap2
222 //CFbsBitGc::DrawArc(), CFbsBitGc::DrawPie(), CFbsBitGc::DrawRoundRect() test
223 void CTBitgdiScaling::TestArcPie(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
225 INFO_PRINTF1(_L("DrawArc(), DrawPie(), DrawRoundRect() - Neg.coord."));
228 aScreenDevice->GetDrawRect(drawRect);
230 const TSize arcSize(20, 20);
232 for(TInt x=drawRect.iTl.iX;x<(drawRect.iBr.iX-arcSize.iWidth);x+=10)
234 for(TInt y=drawRect.iTl.iY;y<(drawRect.iBr.iY-arcSize.iHeight);y+=10)
236 ::Clear(aGraphicsContext);
237 aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
238 aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
239 aGraphicsContext->SetPenSize(TSize(1, 1));
241 TRect rc(pt, arcSize);
242 TPoint pt1(x, y + arcSize.iHeight / 2);
243 TPoint pt2(x + arcSize.iWidth, y + arcSize.iHeight / 2);
244 //RDebug::Print(_L("DrawArc %d, %d, %d, %d || %d, %d, %d, %d\r\n"), rc.iTl.iX, rc.iTl.iY, rc.iBr.iX, rc.iBr.iY, pt1.iX, pt1.iY, pt2.iX, pt2.iY);
245 aGraphicsContext->DrawArc(rc, pt1, pt2);
246 //RDebug::Print(_L("DrawArc %d, %d, %d, %d || %d, %d, %d, %d\r\n"), rc.iTl.iX, rc.iTl.iY, rc.iBr.iX, rc.iBr.iY, pt2.iX, pt2.iY, pt1.iX, pt1.iY);
247 aGraphicsContext->DrawArc(rc, pt2, pt1);
248 //RDebug::Print(_L("DrawPie %d, %d, %d, %d || %d, %d, %d, %d\r\n"), rc.iTl.iX, rc.iTl.iY, rc.iBr.iX, rc.iBr.iY, pt1.iX, pt1.iY, pt2.iX, pt2.iY);
249 aGraphicsContext->DrawPie(rc, pt1, pt2);
250 //RDebug::Print(_L("DrawPie %d, %d, %d, %d || %d, %d, %d, %d\r\n"), rc.iTl.iX, rc.iTl.iY, rc.iBr.iX, rc.iBr.iY, pt2.iX, pt2.iY, pt1.iX, pt1.iY);
251 aGraphicsContext->DrawPie(rc, pt2, pt1);
253 TRect rc2(TPoint(x + arcSize.iWidth + 1, y), arcSize);
255 //RDebug::Print(_L("DrawRoundRect %d, %d, %d, %d\r\n"), rc.iTl.iX, rc.iTl.iY, rc.iBr.iX, rc.iBr.iY);
256 aGraphicsContext->DrawRoundRect(rc2, TSize(4, 4));
257 aScreenDevice->Update();
262 //CFbsBitGc::DrawPolyLine(), CFbsBitGc::DrawPolygon() test
263 void CTBitgdiScaling::TestPolyL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
265 INFO_PRINTF1(_L("DrawPolyLine(), DrawPolygon() - Neg.coord."));
268 aScreenDevice->GetDrawRect(drawRect);
270 for(TInt x=drawRect.iTl.iX;x<drawRect.iBr.iX;x+=10)
272 for(TInt y=drawRect.iTl.iY;y<drawRect.iBr.iY;y+=10)
274 ::Clear(aGraphicsContext);
275 aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
276 aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
277 aGraphicsContext->SetPenSize(TSize(1, 1));
279 CPointArray* points = new (ELeave) CPointArray (10);
280 CleanupStack::PushL(points);
283 pt.SetXY(x + 20, y + 20);
285 pt.SetXY(x + 20, y + 40);
287 pt.SetXY(x - 5, y + 14);
293 pointList[0].SetXY(10,10);
294 pointList[1].SetXY(50,50);
295 pointList[2].SetXY(75,75);
296 aGraphicsContext->DrawPolyLine(pointList,3);
297 //RDebug::Print(_L("DrawPolyLine %d, %d\r\n"), x, y);
298 aGraphicsContext->DrawPolyLine(points);
299 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
300 aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
301 //RDebug::Print(_L("DrawPolygon %d, %d\r\n"), x, y);
302 aGraphicsContext->DrawPolygon(points, CGraphicsContext::EWinding);
304 aScreenDevice->Update();
305 CleanupStack::PopAndDestroy(points);
310 //CFbsBitGc::DrawEllipse(), CFbsBitGc::DrawLine(), CFbsBitGc::DrawRect() test
311 void CTBitgdiScaling::TestEllipseLineRect(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
313 INFO_PRINTF1(_L("DrawEllipse(), DrawLine() - Neg.coord."));
316 aScreenDevice->GetDrawRect(drawRect);
318 for(TInt x=drawRect.iTl.iX;x<drawRect.iBr.iX;x+=10)
320 for(TInt y=drawRect.iTl.iY;y<drawRect.iBr.iY;y+=10)
322 ::Clear(aGraphicsContext);
323 aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
324 aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
325 aGraphicsContext->SetPenSize(TSize(1, 1));
326 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
327 aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
328 //RDebug::Print(_L("DrawEllipse %d, %d %d %d\r\n"), x, y, x + 20, y + 10);
329 aGraphicsContext->DrawEllipse(TRect(x, y, x + 20, y + 10));
330 //RDebug::Print(_L("DrawEllipse %d, %d %d %d\r\n"), x + 20, y + 10, x + 40, y);
331 aGraphicsContext->DrawLine(TPoint(x + 20, y + 10), TPoint(x + 40, y));
332 //RDebug::Print(_L("DrawRect %d, %d %d %d\r\n"), x + 42, y, x + 52, y + 20);
333 aGraphicsContext->DrawRect(TRect(x + 42, y, x + 52, y + 20));
334 aScreenDevice->Update();
339 //CFbsBitGc::DrawText() test
340 void CTBitgdiScaling::TestText(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext, CFont*)
342 INFO_PRINTF1(_L("DrawText() - Neg.coord."));
345 aScreenDevice->GetDrawRect(drawRect);
347 _LIT(KText,"T1234567890QWERTY");
348 for(TInt xx=(drawRect.iTl.iX-40);xx<(drawRect.iBr.iX+40);xx+=22)
350 for(TInt yy=(drawRect.iTl.iY-40);yy<(drawRect.iBr.iY+40);yy+=17)
352 ::Clear(aGraphicsContext);
353 aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
354 aGraphicsContext->SetPenColor(TRgb::Gray256(0x00));
355 aGraphicsContext->SetPenSize(TSize(1,1));
357 //RDebug::Print(_L("DrawText %d, %d\r\n"), xx, yy);
358 aGraphicsContext->DrawText(KText, TPoint(xx,yy));
359 aScreenDevice->Update();
364 //CFbsBitGc::DrawTextVertical() test
365 void CTBitgdiScaling::TestTextVertical(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext, CFont*)
367 INFO_PRINTF1(_L("DrawTextVertical() - Neg.coord."));
370 aScreenDevice->GetDrawRect(drawRect);
372 for(TInt x=(drawRect.iTl.iX-40);x<(drawRect.iBr.iX+40);x+=22)
374 for(TInt y=(drawRect.iTl.iY-40);y<(drawRect.iBr.iY+40);y+=17)
376 ::Clear(aGraphicsContext);
377 aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
378 aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
379 aGraphicsContext->SetPenSize(TSize(1, 1));
381 //RDebug::Print(_L("DrawTextVertical %d, %d Down\r\n"), x, y);
382 aGraphicsContext->DrawTextVertical(_L("Test text"), TPoint(x, y), ETrue);
383 //RDebug::Print(_L("DrawTextVertical %d, %d Up\r\n"), x + 10, y);
384 aGraphicsContext->DrawTextVertical(_L("Test text"), TPoint(x + 10, y), EFalse);
385 aGraphicsContext->DrawTextVertical(_L("Test text "),drawRect, EFalse);
386 aGraphicsContext->DrawTextVertical(_L("Test text "),drawRect, ETrue);
388 aScreenDevice->Update();
393 //CFbsBitGc::MapColors() test
394 void CTBitgdiScaling::TestMapColors(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
396 INFO_PRINTF1(_L("MapColors() - Neg.coord."));
398 ::Clear(aGraphicsContext);
400 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
401 aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
403 TRect rc(-10, -10, 10, 10);
404 aGraphicsContext->DrawRect(rc);
405 aScreenDevice->Update();
407 TRgb colors[] = {TRgb(0xCC, 0x33, 0x66), TRgb(0x00, 0x00, 0xFF)};
408 //RDebug::Print(_L("MapColors %d, %d, %d, %d\r\n"), rc.iTl.iX, rc.iTl.iY, rc.iBr.iX, rc.iBr.iY);
409 aGraphicsContext->MapColors(rc, colors);
410 aScreenDevice->Update();
413 //CFbsBitGc::ShadowArea(), CFbsBitGc::FadeArea() test
414 void CTBitgdiScaling::TestShadowFade(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
416 INFO_PRINTF1(_L("ShadowArea(), FadeArea() - Neg.coord."));
419 aScreenDevice->GetDrawRect(drawRect);
421 for(TInt x=(drawRect.iTl.iX - 20);x<(drawRect.iBr.iX+37);x+=17)
423 for(TInt y=(drawRect.iTl.iY-20);y<(drawRect.iBr.iY+37);y+=19)
425 TRect rc1(x, y, x + 20, y + 25);
426 TRect rc2(x + 20, y + 5, x + 45, y + 20);
428 ::Clear(aGraphicsContext);
429 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
430 aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
431 //RDebug::Print(_L("MapColors %d, %d, %d, %d\r\n"), rc1.iTl.iX, rc1.iTl.iY, rc1.iBr.iX, rc1.iBr.iY);
432 aGraphicsContext->DrawRect(rc1);
433 //RDebug::Print(_L("MapColors %d, %d, %d, %d\r\n"), rc2.iTl.iX, rc2.iTl.iY, rc2.iBr.iX, rc2.iBr.iY);
434 aGraphicsContext->DrawRect(rc2);
437 shadowRgn.AddRect(rc1);
438 shadowRgn.AddRect(rc2);
439 //RDebug::Print(_L("ShadowArea\r\n"));
440 aGraphicsContext->ShadowArea(&shadowRgn);
443 aScreenDevice->Update();
445 ::Clear(aGraphicsContext);
446 aGraphicsContext->SetBrushColor(TRgb(0xFF, 0x00, 0xFF));
447 //RDebug::Print(_L("MapColors %d, %d, %d, %d\r\n"), rc1.iTl.iX, rc1.iTl.iY, rc1.iBr.iX, rc1.iBr.iY);
448 aGraphicsContext->DrawRect(rc1);
449 //RDebug::Print(_L("MapColors %d, %d, %d, %d\r\n"), rc2.iTl.iX, rc2.iTl.iY, rc2.iBr.iX, rc2.iBr.iY);
450 aGraphicsContext->DrawRect(rc2);
453 fadeRgn.AddRect(rc1);
454 fadeRgn.AddRect(rc2);
455 //RDebug::Print(_L("FadeArea\r\n"));
456 aGraphicsContext->FadeArea(&fadeRgn);
459 aScreenDevice->Update();
465 @SYMTestCaseID GRAPHICS-CODEBASE-BITGDI-0004
469 @SYMTestCaseDesc TestMove
473 @SYMTestStatus Implemented
475 @SYMTestActions Draw the line using using DrawLine and move the line using MoveLine(),MoveBy()
476 Then test the same for all orientaion.
478 @SYMTestExpectedResults Test should perform graphics operations succesfully.
482 void CTBitgdiScaling::TestMove(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
484 INFO_PRINTF1(_L("CODEBASE TEST 1 - TestMove Started"));
486 aScreenDevice->GetDrawRect(drawRect);
487 for(TInt x=drawRect.iTl.iX;x<drawRect.iBr.iX;x+=10)
489 for(TInt y=drawRect.iTl.iY;y<drawRect.iBr.iY;y+=10)
491 ::Clear(aGraphicsContext);
492 aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
493 aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
494 aGraphicsContext->SetPenSize(TSize(1, 1));
495 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
496 aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
497 aGraphicsContext->DrawLine(TPoint(x + 20, y + 10), TPoint(x + 40, y));
498 aGraphicsContext->MoveTo(TPoint(100,100));
499 aGraphicsContext->DrawLine(TPoint(x + 40, y + 50), TPoint(x + 70, y));
500 aGraphicsContext->MoveTo(TPoint(100,100));
501 aGraphicsContext->MoveBy(TPoint(0,-70));
502 aGraphicsContext->DrawLineBy(TPoint(0,60));
503 aGraphicsContext->MoveBy(TPoint(-70,70));
504 aGraphicsContext->DrawLineBy(TPoint(60,0));
505 aScreenDevice->Update();
509 INFO_PRINTF1(_L("CODEBASE TEST 1 - TestMove Finished"));
513 @SYMTestCaseID GRAPHICS-CODEBASE-BITGDI-0005
517 @SYMTestCaseDesc TestEllipseRect
521 @SYMTestStatus Implemented
523 @SYMTestActions Draw the Rectangle with black color and pass the same rectagle in to the
524 DrawEllipse() with red color brush then check for Ellipse and Rectangle color are properly
525 drawn respectively then test the same for all orientaion.
527 @SYMTestExpectedResults Test should perform graphics operations succesfully.
531 void CTBitgdiScaling::TestEllipseRect(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
533 INFO_PRINTF1(_L(" TestEllipseRect Started"));
535 aScreenDevice->GetDrawRect(drawRect);
536 aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
537 aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
538 aGraphicsContext->SetPenSize(TSize(4,4));
539 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
540 aGraphicsContext->SetBrushColor(TRgb(0x00, 0x00, 0x255));
541 TRect rrect1(20, 20, 40, 40);
542 aGraphicsContext->DrawRect(rrect1);
543 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
544 aGraphicsContext->SetBrushColor(TRgb(0x255, 0x00, 0x00));
545 TRect erect1(20, 20, 40, 40);
546 aGraphicsContext->DrawEllipse(erect1);
547 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
548 aGraphicsContext->SetBrushColor(TRgb(0x00, 0x00, 0x255));
549 TRect rrect2(40, 40, 60, 60);
550 aGraphicsContext->DrawRect(rrect2);
551 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
552 aGraphicsContext->SetBrushColor(TRgb(0x255, 0x00, 0x00));
553 TRect erect2(40, 40, 60, 60);
554 aGraphicsContext->DrawEllipse(erect2);
555 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
556 aGraphicsContext->SetBrushColor(TRgb(0x00, 0x00, 0x255));
557 TRect rllrect3(60, 60, 80, 80);
558 aGraphicsContext->DrawRect(rllrect3);
559 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
560 aGraphicsContext->SetBrushColor(TRgb(0x255, 0x00, 0x00));
561 TRect ellrect3(60, 60, 80, 80);
562 aGraphicsContext->DrawEllipse(ellrect3);
563 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
564 aGraphicsContext->SetBrushColor(TRgb(0x00, 0x00, 0x255));
565 TRect rllrect4(80, 80,100,100);
566 aGraphicsContext->DrawRect(rllrect4);
567 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
568 aGraphicsContext->SetBrushColor(TRgb(0x255, 0x00, 0x00));
569 TRect ellrect4(80, 80,100,100);
570 aGraphicsContext->DrawEllipse(ellrect4);
571 aScreenDevice->Update();
572 INFO_PRINTF1(_L(" TestEllipseRect Finished"));
577 @SYMTestCaseID GRAPHICS-CODEBASE-BITGDI-0006
581 @SYMTestCaseDesc TestDrawBitmapNegL
585 @SYMTestStatus Implemented
587 @SYMTestActions Draw the Bitmap using DrawBitmap() with the TRect passing negative values.
588 then test the same for all orientaion.
590 @SYMTestExpectedResults Test should perform graphics operations succesfully.
594 void CTBitgdiScaling::TestDrawBitmapNegL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
596 INFO_PRINTF1(_L(" TestDrawBitmapNegL Started"));
597 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
598 CleanupStack::PushL(bitmap);
601 User::LeaveIfError(bitmap->Load(KTestBmp, 0));
603 ::Clear(aGraphicsContext);
604 TSize size = bitmap->SizeInPixels();
605 //RDebug::Print(_L("DrawBitmap %d, %d, %d, %d\r\n"), 0, 0, size.iWidth, size.iHeight);
606 aGraphicsContext->DrawBitmap(TRect(-100,-100, size.iWidth, size.iHeight), bitmap);
607 aScreenDevice->Update();
609 CleanupStack::PopAndDestroy(bitmap);
610 INFO_PRINTF1(_L(" TestDrawBitmapNegL Finished"));
613 @SYMTestCaseID GRAPHICS-CODEBASE-BITGDI-0007
617 @SYMTestCaseDesc TestMapColorsZero
621 @SYMTestStatus Implemented
623 @SYMTestActions Mapthe pixels in the specified rectangle which size is zero using MapColors() with the TRect passing negative values.
624 then test the same for all orientaion.
626 @SYMTestExpectedResults Test should perform graphics operations succesfully.
629 void CTBitgdiScaling::TestMapColorsZero(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
631 INFO_PRINTF1(_L(" TestMapColorsZero Started"));
633 ::Clear(aGraphicsContext);
635 aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
636 aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
638 TRect rc(0, 0, 0, 0);
639 aGraphicsContext->DrawRect(rc);
640 aScreenDevice->Update();
642 TRgb colors[] = {TRgb(0xCC, 0x33, 0x66), TRgb(0x00, 0x00, 0xFF)};
644 aGraphicsContext->MapColors(rc, colors);
645 aScreenDevice->Update();
646 INFO_PRINTF1(_L(" TestMapColorsZero Finished"));
650 @SYMTestCaseID GRAPHICS-BITGDI-0037
654 @SYMTestCaseDesc tests drawing various graphic primitives to the screen device set to different orientations
656 @SYMTestPriority High
658 @SYMTestStatus Implemented
660 @SYMTestActions Iterates through a series of screen rotations and draws graphic primitives to the screen
662 @SYMTestExpectedResults Test should perform graphics operations succesfully.
664 void CTBitgdiScaling::RunTests2L()
666 CFont* font = ::SetFontL(iScreenDevice, iGraphicsContext);
667 iGraphicsContext->Clear();
669 const TPoint ptOrigin(73, 53);
670 TInt err = iScreenDevice->SetScalingFactor(ptOrigin, KScalingFactorX, KScalingFactorY, 1, 1);
671 TEST2(err, KErrNone);
672 iGraphicsContext->Activate(iScreenDevice);
674 const CFbsBitGc::TGraphicsOrientation KOrientation[] =
676 CFbsBitGc::EGraphicsOrientationNormal,
677 CFbsBitGc::EGraphicsOrientationRotated90,
678 CFbsBitGc::EGraphicsOrientationRotated180,
679 CFbsBitGc::EGraphicsOrientationRotated270
682 for(TInt ii=0;ii<TInt(sizeof(KOrientation)/sizeof(KOrientation[0]));++ii)
684 if(!iGraphicsContext->SetOrientation(KOrientation[ii]))
688 _LIT(KRotation,"===EOrientation%S===");
689 INFO_PRINTF2(KRotation,&RotationName(KOrientation[ii]));
690 RDebug::Print(KRotation,&RotationName(KOrientation[ii]));
692 iScreenDevice->GetDrawRect(drawRect);
693 INFO_PRINTF5(_L("Drawing rectangle: %d %d %d %d"),
694 drawRect.iTl.iX, drawRect.iTl.iY, drawRect.iBr.iX, drawRect.iBr.iY);
696 TestDrawBitmapL(iScreenDevice, iGraphicsContext);
697 TestClear(iScreenDevice, iGraphicsContext);
698 TestBitbltL(iScreenDevice, iGraphicsContext);
699 TestArcPie(iScreenDevice, iGraphicsContext);
700 TestPolyL(iScreenDevice, iGraphicsContext);
701 TestEllipseLineRect(iScreenDevice, iGraphicsContext);
702 TestText(iScreenDevice, iGraphicsContext, font);
703 iGraphicsContext->SetUnderlineStyle(EUnderlineOn);
704 TestText(iScreenDevice, iGraphicsContext, font);
705 iGraphicsContext->SetStrikethroughStyle(EStrikethroughOn);
706 TestText(iScreenDevice, iGraphicsContext, font);
707 iGraphicsContext->SetUnderlineStyle(EUnderlineOff);
708 iGraphicsContext->SetStrikethroughStyle(EStrikethroughOff);
709 TestTextVertical(iScreenDevice, iGraphicsContext, font);
710 TestMapColors(iScreenDevice, iGraphicsContext);
711 TestShadowFade(iScreenDevice, iGraphicsContext);
712 ((CTBitgdiScalingStep*)iStep)->RecordTestResultL();
713 ((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-BITGDI-0004"));
714 TestMove(iScreenDevice, iGraphicsContext);
715 ((CTBitgdiScalingStep*)iStep)->RecordTestResultL();
716 ((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-BITGDI-0005"));
717 TestEllipseRect(iScreenDevice, iGraphicsContext);
718 ((CTBitgdiScalingStep*)iStep)->RecordTestResultL();
719 ((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-BITGDI-0007"));
720 TestMapColorsZero(iScreenDevice, iGraphicsContext);
721 ((CTBitgdiScalingStep*)iStep)->RecordTestResultL();
722 ((CTBitgdiScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-BITGDI-0007"));
723 TestDrawBitmapNegL(iScreenDevice, iGraphicsContext);
724 ((CTBitgdiScalingStep*)iStep)->RecordTestResultL();
725 iGraphicsContext->Clear();
728 iGraphicsContext->Clear();
729 iScreenDevice->ReleaseFont(font);
730 iGraphicsContext->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);