os/graphics/graphicsdeviceinterface/bitgdi/tbit/TBitgdiNegScaling.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "TBitgdiScaling.h"
    17 //#pragma warning(disable: 4127)
    18 
    19 //X and Y scaling factors.
    20 const TInt KScalingFactorX = 2;
    21 const TInt KScalingFactorY = 3;
    22 //Test bitmap
    23 _LIT(KTestBmp, "z:\\system\\data\\BmCTest.mbm");
    24 typedef CArrayFixFlat<TPoint> CPointArray;
    25 
    26 
    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)
    29 	{
    30 	TTypefaceSupport typeFaceSupport;
    31 	aScreenDevice->TypefaceSupport(typeFaceSupport, 0);
    32 	TFontSpec fontSpec;
    33 	fontSpec.iTypeface = typeFaceSupport.iTypeface;
    34 	fontSpec.iHeight = 10;
    35 	CFont* font = NULL;
    36 	User::LeaveIfError(aScreenDevice->GetNearestFontToDesignHeightInPixels(font, fontSpec));
    37 	aGraphicsContext->UseFont(font);
    38 	return font;
    39 	}
    40 
    41 //Clears the screen and displays after that the scaling origin point.
    42 static void Clear(CFbsBitGc* aGraphicsContext)
    43 	{
    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));
    52 	}
    53 
    54 //CFbsBitGc::DrawBitmap() test
    55 void CTBitgdiScaling::TestDrawBitmapL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
    56 	{
    57 	INFO_PRINTF1(_L("DrawBitmap() - (0, 0) coord"));
    58 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
    59 	CleanupStack::PushL(bitmap);
    60 
    61 	bitmap->Reset();
    62 	User::LeaveIfError(bitmap->Load(KTestBmp, 0));
    63 
    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();
    69 
    70 	CleanupStack::PopAndDestroy(bitmap);
    71 	}
    72 
    73 //CFbsBitGc::Clear(), CFbsBitGc::Clear(const TRect& aRect), CFbsBitGc::DrawLine() test
    74 void CTBitgdiScaling::TestClear(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
    75 	{
    76 	INFO_PRINTF1(_L("Clear(), DrawLine() - Neg.coord."));
    77 	aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
    78 
    79 	TRect drawRect;
    80 	aScreenDevice->GetDrawRect(drawRect);
    81 
    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();
    86 
    87 	//RDebug::Print(_L("Clear\r\n"));
    88 	aGraphicsContext->SetBrushColor(KRgbWhite);
    89 	::Clear(aGraphicsContext);
    90 	aScreenDevice->Update();
    91 
    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();
    96 
    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();
   102 
   103 	drawRect.Grow(1, 1);
   104 	CGraphicsContext::TPenStyle penStyle[] = 
   105 		{
   106 		CGraphicsContext::ENullPen, 
   107 		CGraphicsContext::ESolidPen, 
   108 		CGraphicsContext::EDottedPen, 
   109 		CGraphicsContext::EDashedPen, 
   110 		CGraphicsContext::EDotDashPen, 
   111 		CGraphicsContext::EDotDotDashPen
   112 		};
   113 	struct TLineProps
   114 		{
   115 		TLineProps(const TPoint& aPt1, const TPoint& aPt2) : 
   116 			iPt1(aPt1), 
   117 			iPt2(aPt2) 
   118 			{
   119 			}
   120 		TPoint iPt1;
   121 		TPoint iPt2;
   122 		};
   123 	TLineProps lineProps[] = 
   124 		{
   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))
   127 		};
   128 	for(TInt jj=0;jj<TInt(sizeof(lineProps)/sizeof(lineProps[0]));++jj)
   129 		{
   130 		for(TInt ii=0;ii<TInt(sizeof(penStyle)/sizeof(penStyle[0]));++ii)
   131 			{
   132 			aGraphicsContext->SetPenStyle(penStyle[ii]);
   133 
   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();
   140 
   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();
   147 			}
   148 		}
   149 	}
   150 
   151 //CFbsBitGc::Bitblt(), CFbsBitGc::BitbltMasked(), CFbsBitGc::DrawBitmap() test
   152 void CTBitgdiScaling::TestBitbltL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   153 	{
   154 	INFO_PRINTF1(_L("Bitblt(), BitbltMasked(), DrawBitmap() - Neg.coord."));
   155 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   156 	CleanupStack::PushL(bitmap);
   157 	bitmap->Reset();
   158 	User::LeaveIfError(bitmap->Load(KTestBmp, 0));
   159 	TSize bmpSize = bitmap->SizeInPixels();
   160 	TInt ii,jj;
   161 
   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)
   168 		{
   169 		for(jj=0;jj<bmpSize.iHeight;++jj)
   170 			{
   171 			bmpUtil.SetPos(TPoint(ii,jj));
   172 			bmpUtil.SetPixel(0xAA555555);
   173 			}
   174 		}
   175 	bmpUtil.End();
   176 
   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)
   183 		{
   184 		for(jj=0;jj<bmpSize.iHeight;++jj)
   185 			{
   186 			bmpUtil2.SetPos(TPoint(ii,jj));
   187 			bmpUtil2.SetPixel(0xBBBBBB);
   188 			}
   189 		}
   190 	bmpUtil2.End();
   191 
   192 	TRect drawRect;
   193 	aScreenDevice->GetDrawRect(drawRect);
   194 
   195 	for(TInt x=drawRect.iTl.iX;x<(drawRect.iBr.iX-bmpSize.iWidth);x+=10)
   196 		{
   197 		for(TInt y=drawRect.iTl.iY;y<(drawRect.iBr.iY-bmpSize.iHeight);y+=10)
   198 			{
   199 			::Clear(aGraphicsContext);
   200 
   201 			//RDebug::Print(_L("BitBlt %d, %d\r\n"), x, y);
   202 			aGraphicsContext->BitBlt(TPoint(x, y), bitmap);
   203 
   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);
   207 
   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);
   211 
   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);
   215 
   216 			aScreenDevice->Update();
   217 			}
   218 		}
   219 	CleanupStack::PopAndDestroy(3);//bitmap & maskBitmap & maskBitmap2
   220 	}
   221 
   222 //CFbsBitGc::DrawArc(), CFbsBitGc::DrawPie(), CFbsBitGc::DrawRoundRect() test
   223 void CTBitgdiScaling::TestArcPie(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   224 	{
   225 	INFO_PRINTF1(_L("DrawArc(), DrawPie(), DrawRoundRect() - Neg.coord."));
   226 
   227 	TRect drawRect;
   228 	aScreenDevice->GetDrawRect(drawRect);
   229 
   230 	const TSize arcSize(20, 20);
   231 
   232 	for(TInt x=drawRect.iTl.iX;x<(drawRect.iBr.iX-arcSize.iWidth);x+=10)
   233 		{
   234 		for(TInt y=drawRect.iTl.iY;y<(drawRect.iBr.iY-arcSize.iHeight);y+=10)
   235 			{
   236 			::Clear(aGraphicsContext);
   237 			aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
   238 			aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
   239 			aGraphicsContext->SetPenSize(TSize(1, 1));
   240 			TPoint pt(x, y);
   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);
   252 			
   253 			TRect rc2(TPoint(x + arcSize.iWidth + 1, y), arcSize);
   254 			
   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();
   258 			}
   259 		}
   260 	}
   261 
   262 //CFbsBitGc::DrawPolyLine(), CFbsBitGc::DrawPolygon() test
   263 void CTBitgdiScaling::TestPolyL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   264 	{
   265 	INFO_PRINTF1(_L("DrawPolyLine(), DrawPolygon() - Neg.coord."));
   266 
   267 	TRect drawRect;
   268 	aScreenDevice->GetDrawRect(drawRect);
   269 
   270 	for(TInt x=drawRect.iTl.iX;x<drawRect.iBr.iX;x+=10)
   271 		{
   272 		for(TInt y=drawRect.iTl.iY;y<drawRect.iBr.iY;y+=10)
   273 			{
   274 			::Clear(aGraphicsContext);
   275 			aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
   276 			aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
   277 			aGraphicsContext->SetPenSize(TSize(1, 1));
   278 			
   279 			CPointArray* points = new (ELeave) CPointArray (10);
   280 			CleanupStack::PushL(points);
   281 			TPoint pt(x, y);
   282 			points->AppendL(pt);
   283 			pt.SetXY(x + 20, y + 20);
   284 			points->AppendL(pt);
   285 			pt.SetXY(x + 20, y + 40);
   286 			points->AppendL(pt);
   287 			pt.SetXY(x - 5, y + 14);
   288 			points->AppendL(pt);
   289 			pt.SetXY(x, y);
   290 			points->AppendL(pt);
   291 			
   292 			TPoint pointList[3];
   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);
   303 			
   304 			aScreenDevice->Update();
   305 			CleanupStack::PopAndDestroy(points);
   306 			}
   307 		}
   308 	}
   309 
   310 //CFbsBitGc::DrawEllipse(), CFbsBitGc::DrawLine(), CFbsBitGc::DrawRect() test
   311 void CTBitgdiScaling::TestEllipseLineRect(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   312 	{
   313 	INFO_PRINTF1(_L("DrawEllipse(), DrawLine() - Neg.coord."));
   314 
   315 	TRect drawRect;
   316 	aScreenDevice->GetDrawRect(drawRect);
   317 
   318 	for(TInt x=drawRect.iTl.iX;x<drawRect.iBr.iX;x+=10)
   319 		{
   320 		for(TInt y=drawRect.iTl.iY;y<drawRect.iBr.iY;y+=10)
   321 			{
   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();
   335 			}
   336 		}
   337 	}
   338 
   339 //CFbsBitGc::DrawText() test
   340 void CTBitgdiScaling::TestText(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext, CFont*)
   341 	{
   342 	INFO_PRINTF1(_L("DrawText() - Neg.coord."));
   343 
   344 	TRect drawRect;
   345 	aScreenDevice->GetDrawRect(drawRect);
   346 
   347 	_LIT(KText,"T1234567890QWERTY");
   348 	for(TInt xx=(drawRect.iTl.iX-40);xx<(drawRect.iBr.iX+40);xx+=22)
   349 		{
   350 		for(TInt yy=(drawRect.iTl.iY-40);yy<(drawRect.iBr.iY+40);yy+=17)
   351 			{
   352 			::Clear(aGraphicsContext);
   353 			aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
   354 			aGraphicsContext->SetPenColor(TRgb::Gray256(0x00));
   355 			aGraphicsContext->SetPenSize(TSize(1,1));
   356 
   357 			//RDebug::Print(_L("DrawText %d, %d\r\n"), xx, yy);
   358 			aGraphicsContext->DrawText(KText, TPoint(xx,yy));
   359 			aScreenDevice->Update();
   360 			}
   361 		}
   362 	}
   363 
   364 //CFbsBitGc::DrawTextVertical() test
   365 void CTBitgdiScaling::TestTextVertical(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext, CFont*)
   366 	{
   367 	INFO_PRINTF1(_L("DrawTextVertical() - Neg.coord."));
   368 
   369 	TRect drawRect;
   370 	aScreenDevice->GetDrawRect(drawRect);
   371 
   372 	for(TInt x=(drawRect.iTl.iX-40);x<(drawRect.iBr.iX+40);x+=22)
   373 		{
   374 		for(TInt y=(drawRect.iTl.iY-40);y<(drawRect.iBr.iY+40);y+=17)
   375 			{
   376 			::Clear(aGraphicsContext);
   377 			aGraphicsContext->SetPenStyle(CGraphicsContext::ESolidPen);
   378 			aGraphicsContext->SetPenColor(TRgb(0x00, 0x00, 0x00));
   379 			aGraphicsContext->SetPenSize(TSize(1, 1));
   380 			
   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);
   387 			
   388 			aScreenDevice->Update();
   389 			}
   390 		}
   391 	}
   392 
   393 //CFbsBitGc::MapColors() test
   394 void CTBitgdiScaling::TestMapColors(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   395 	{
   396 	INFO_PRINTF1(_L("MapColors() - Neg.coord."));
   397 
   398 	::Clear(aGraphicsContext);
   399 
   400 	aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
   401 	aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
   402 
   403 	TRect rc(-10, -10, 10, 10);
   404 	aGraphicsContext->DrawRect(rc);
   405 	aScreenDevice->Update();
   406 
   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();
   411 	}
   412 
   413 //CFbsBitGc::ShadowArea(), CFbsBitGc::FadeArea() test
   414 void CTBitgdiScaling::TestShadowFade(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   415 	{
   416 	INFO_PRINTF1(_L("ShadowArea(), FadeArea() - Neg.coord."));
   417 
   418 	TRect drawRect;
   419 	aScreenDevice->GetDrawRect(drawRect);
   420 
   421 	for(TInt x=(drawRect.iTl.iX - 20);x<(drawRect.iBr.iX+37);x+=17)
   422 		{
   423 		for(TInt y=(drawRect.iTl.iY-20);y<(drawRect.iBr.iY+37);y+=19)
   424 			{
   425 			TRect rc1(x, y, x + 20, y + 25);
   426 			TRect rc2(x + 20, y + 5, x + 45, y + 20);
   427 
   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);
   435 
   436 			RRegion shadowRgn;
   437 			shadowRgn.AddRect(rc1);
   438 			shadowRgn.AddRect(rc2);
   439 			//RDebug::Print(_L("ShadowArea\r\n"));
   440 			aGraphicsContext->ShadowArea(&shadowRgn);
   441 			shadowRgn.Close();
   442 
   443 			aScreenDevice->Update();
   444 
   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);
   451 
   452 			RRegion fadeRgn;
   453 			fadeRgn.AddRect(rc1);
   454 			fadeRgn.AddRect(rc2);
   455 			//RDebug::Print(_L("FadeArea\r\n"));
   456 			aGraphicsContext->FadeArea(&fadeRgn);
   457 			fadeRgn.Close();
   458 
   459 			aScreenDevice->Update();
   460 			}
   461 		}
   462 	}
   463 
   464 /**
   465 	@SYMTestCaseID GRAPHICS-CODEBASE-BITGDI-0004
   466  
   467 	@SYMPREQ PGM027
   468    
   469 	@SYMTestCaseDesc  TestMove
   470  
   471 	@SYMTestPriority 1
   472   
   473 	@SYMTestStatus Implemented
   474    
   475 	@SYMTestActions Draw the line using using DrawLine and move the line using MoveLine(),MoveBy()
   476 	Then test the same for all orientaion.
   477    
   478 	@SYMTestExpectedResults Test should perform graphics operations succesfully.
   479 
   480  */
   481 
   482 void CTBitgdiScaling::TestMove(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   483 	{
   484 	INFO_PRINTF1(_L("CODEBASE TEST 1 - TestMove Started"));
   485 	TRect drawRect;
   486 	aScreenDevice->GetDrawRect(drawRect);
   487 	for(TInt x=drawRect.iTl.iX;x<drawRect.iBr.iX;x+=10)
   488 		{
   489 		for(TInt y=drawRect.iTl.iY;y<drawRect.iBr.iY;y+=10)
   490 			{
   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();
   506 
   507 			}
   508 		}
   509 	INFO_PRINTF1(_L("CODEBASE TEST 1 - TestMove Finished"));
   510 	}
   511 
   512 /**
   513 	@SYMTestCaseID GRAPHICS-CODEBASE-BITGDI-0005
   514  
   515 	@SYMPREQ PGM027
   516    
   517 	@SYMTestCaseDesc  TestEllipseRect
   518  
   519 	@SYMTestPriority 1
   520   
   521 	@SYMTestStatus Implemented
   522    
   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.
   526    
   527 	@SYMTestExpectedResults Test should perform graphics operations succesfully.
   528 
   529  */
   530  
   531 void CTBitgdiScaling::TestEllipseRect(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   532 	{
   533 	INFO_PRINTF1(_L(" TestEllipseRect Started"));
   534 	TRect drawRect;
   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"));
   573 
   574 	}
   575 	
   576 /**
   577 	@SYMTestCaseID GRAPHICS-CODEBASE-BITGDI-0006
   578  
   579 	@SYMPREQ PGM027
   580    
   581 	@SYMTestCaseDesc  TestDrawBitmapNegL
   582  
   583 	@SYMTestPriority 1
   584   
   585 	@SYMTestStatus Implemented
   586    
   587 	@SYMTestActions Draw the Bitmap using DrawBitmap() with the TRect passing negative values.
   588 	then test the same for all orientaion.
   589    
   590 	@SYMTestExpectedResults Test should perform graphics operations succesfully.
   591 
   592  */
   593  
   594 void CTBitgdiScaling::TestDrawBitmapNegL(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   595 	{
   596 	INFO_PRINTF1(_L(" TestDrawBitmapNegL Started"));
   597 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   598 	CleanupStack::PushL(bitmap);
   599 
   600 	bitmap->Reset();
   601 	User::LeaveIfError(bitmap->Load(KTestBmp, 0));
   602 
   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();
   608 
   609 	CleanupStack::PopAndDestroy(bitmap);
   610 	INFO_PRINTF1(_L(" TestDrawBitmapNegL Finished"));
   611 	}
   612 /**
   613 	@SYMTestCaseID GRAPHICS-CODEBASE-BITGDI-0007
   614  
   615 	@SYMPREQ PGM027
   616    
   617 	@SYMTestCaseDesc  TestMapColorsZero
   618  
   619 	@SYMTestPriority 1
   620   
   621 	@SYMTestStatus Implemented
   622    
   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.
   625    
   626 	@SYMTestExpectedResults Test should perform graphics operations succesfully.
   627 
   628  */	
   629 void CTBitgdiScaling::TestMapColorsZero(CFbsScreenDevice* aScreenDevice, CFbsBitGc* aGraphicsContext)
   630 	{
   631 	INFO_PRINTF1(_L(" TestMapColorsZero Started"));
   632 
   633 	::Clear(aGraphicsContext);
   634 
   635 	aGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
   636 	aGraphicsContext->SetBrushColor(TRgb(0xBB, 0x34, 0x55));
   637 
   638 	TRect rc(0, 0, 0, 0);
   639 	aGraphicsContext->DrawRect(rc);
   640 	aScreenDevice->Update();
   641 
   642 	TRgb colors[] = {TRgb(0xCC, 0x33, 0x66), TRgb(0x00, 0x00, 0xFF)};
   643 
   644 	aGraphicsContext->MapColors(rc, colors);
   645 	aScreenDevice->Update();
   646 	INFO_PRINTF1(_L(" TestMapColorsZero Finished"));
   647 	}
   648 
   649 /**
   650   @SYMTestCaseID GRAPHICS-BITGDI-0037
   651  
   652   @SYMDEF             
   653 
   654   @SYMTestCaseDesc tests drawing various graphic primitives to the screen device set to different orientations
   655    
   656   @SYMTestPriority High
   657 
   658   @SYMTestStatus Implemented
   659 
   660   @SYMTestActions Iterates through a series of screen rotations and draws graphic primitives to the screen
   661  
   662   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   663 */	
   664 void CTBitgdiScaling::RunTests2L()
   665 	{
   666 	CFont* font = ::SetFontL(iScreenDevice, iGraphicsContext);
   667 	iGraphicsContext->Clear();
   668 	//Scaling origin
   669 	const TPoint ptOrigin(73, 53);
   670 	TInt err = iScreenDevice->SetScalingFactor(ptOrigin, KScalingFactorX, KScalingFactorY, 1, 1);
   671 	TEST2(err, KErrNone);
   672 	iGraphicsContext->Activate(iScreenDevice);
   673 	
   674 	const CFbsBitGc::TGraphicsOrientation KOrientation[] = 
   675 		{
   676 		CFbsBitGc::EGraphicsOrientationNormal,
   677 		CFbsBitGc::EGraphicsOrientationRotated90,
   678 		CFbsBitGc::EGraphicsOrientationRotated180,
   679 		CFbsBitGc::EGraphicsOrientationRotated270
   680 		};
   681 
   682 	for(TInt ii=0;ii<TInt(sizeof(KOrientation)/sizeof(KOrientation[0]));++ii)
   683 		{
   684 		if(!iGraphicsContext->SetOrientation(KOrientation[ii]))
   685 			{
   686 			continue;
   687 			}
   688 		_LIT(KRotation,"===EOrientation%S===");
   689 		INFO_PRINTF2(KRotation,&RotationName(KOrientation[ii]));
   690 		RDebug::Print(KRotation,&RotationName(KOrientation[ii]));
   691 		TRect drawRect;
   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);
   695 
   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();
   726 		}
   727 
   728 	iGraphicsContext->Clear();
   729 	iScreenDevice->ReleaseFont(font);
   730 	iGraphicsContext->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
   731 	}