First public contribution.
1 // Copyright (c) 1996-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.
14 // Test alpha channel transparent windows
15 // Test that draw operations with non-opaque colours do alpha blending in EColor64K and EColor16MA display modes
16 // Test that alpha channel transparent windows are drawn correctly when windows move, redraw, change visibility, etc.
17 // In the draw operation tests, the left window draws opaque pink on white background, the right window blends semi-transparent red on white background,
18 // and the results are compared.
19 // In the transparent window tests, the right window contains several transparent windows, which are moved, redrawn, visibility changed, etc,
20 // the left window contains a single window in which we draw what we expect the right window to look like. The results are compared.
21 // In each case, the left and right windows should be identical
26 #include "TALPHAWIN.H"
35 EOpDrawTextAntiAliased,
48 EAlphaTransparency = 0x8,
49 ETransparencyFactor = 0x10,
50 // defaults to non-transparent
54 // defaults to semi-transparent
57 EModeColor16MA = 0x100,
66 TRgb ColourFromDrawState(TInt aDrawState)
68 TInt red = (aDrawState & ERed) ? 255 : 0;
69 TInt green = (aDrawState & EGreen) ? 255 : 0;
70 TInt blue = (aDrawState & EBlue) ? 255 : 0;
72 if (aDrawState & EOpaque)
74 if (aDrawState & ETransparent)
76 return TRgb(red, green, blue, alpha);
85 CTAlphaWin::CTAlphaWin(CTestStep* aStep):
86 CTWsGraphicsBase(aStep)
90 CTAlphaWin::~CTAlphaWin()
96 void CTAlphaWin::ConstructL()
98 if(TransparencySupportedL() == KErrNotSupported)
101 TSize winSize = BaseWin->Size();
103 iTestWin[0] = CTAlphaWindow::NewL(this, TestWin, TPoint(0,0), winSize, ERed | EGreen | EBlue | EOpaque);
104 iTestWin[1] = CTAlphaWindow::NewL(this, TestWin, TPoint(0,0), TSize(winSize.iWidth/2, winSize.iHeight/2), ERed | EAlphaTransparency);
105 iTestWin[2] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/3,0), TSize(winSize.iWidth/2, winSize.iHeight/2), EGreen | EAlphaTransparency);
106 iTestWin[3] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/6, winSize.iHeight/3), TSize(winSize.iWidth/2, winSize.iHeight/2), EBlue | EAlphaTransparency);
107 iTestWin[4] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/4,winSize.iHeight/6), TSize(winSize.iWidth/3,winSize.iHeight/3), ERed | EGreen | EBlue | EAlphaTransparency | ETransparent);
109 iRefWin = CTAlphaRefWin::NewL(BaseWin, TPoint(0,0), winSize, iTestWin);
110 //Clearing the windows
115 void CTAlphaWin::ConfigureDisplayModes(TDisplayMode aRequiredMode = EColor16M)
120 iTestWin[i]->BaseWin()->SetRequiredDisplayMode(aRequiredMode);
122 iRefWin->BaseWin()->SetRequiredDisplayMode(aRequiredMode);
126 void CTAlphaWin::TestSemiTransparentDrawingL()
128 TSize winSize = BaseWin->Size();
130 // In this window, we draw opaque pink
131 CTDrawOpWin* drawWin = CTDrawOpWin::NewL(this, BaseWin, TPoint(0,0), winSize, TRgb(255,127,127,255));
133 // In this window, we blend semi-transparent red
134 CTDrawOpWin* blendWin = CTDrawOpWin::NewL(this, TestWin, TPoint(0,0), winSize, TRgb(255,0,0,128));
136 const TInt tolerance = 9;//8 - wouldn't be enough!! The defect DEF112334 was raised
137 for (TInt i=EOpDrawRect; i<ENumDrawOps; i++)
140 // User::After(1000000);// helpful when debugging
141 drawWin->SetDrawOp(i);
142 blendWin->SetDrawOp(i);
146 TheClient->WaitForRedrawsToFinish();
148 if((i == EOpDrawTextAntiAliased) && (TheClient->iScreen->DisplayMode() == EColor16MA) || (TheClient->iScreen->DisplayMode() == EColor16MAP))
150 TSize winSize=BaseWin->Size();
151 TRect rect1(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize);
152 TRect rect2(TestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize);
154 CheckRectL(rect1, rect2, winSize, TheClient->iScreen->DisplayMode(), tolerance, _L("CTAlphaWin::TestSemiTransparentDrawingL()"));
158 CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestSemiTransparentDrawingL()"));
165 void CTAlphaWin::TestTransparentDrawingL()
167 TSize winSize = BaseWin->Size();
169 // In this window, we draw opaque white
170 CTDrawOpWin* drawWin = CTDrawOpWin::NewL(this, BaseWin, TPoint(0,0), winSize, TRgb(255,255,255,255));
172 // In this window, we blend transparent red
173 CTDrawOpWin* blendWin = CTDrawOpWin::NewL(this, TestWin, TPoint(0,0), winSize, TRgb(255,0,0,0));
175 for (TInt i=EOpDrawRect; i<ENumDrawOps; i++)
177 //User::After(1000000);// helpful when debugging
178 drawWin->SetDrawOp(i);
179 blendWin->SetDrawOp(i);
183 TheClient->WaitForRedrawsToFinish();
184 CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestTransparentDrawingL()"));
190 void CTAlphaWin::CheckRectL(const TRect& aRect1, const TRect& aRect2, TSize aSize, TDisplayMode aRequiredMode, TInt aTolerance, const TDesC& aErrorMsg)
192 CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
193 CleanupStack::PushL(bmp1);
194 User::LeaveIfError(bmp1->Create(aSize, aRequiredMode));
196 CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
197 CleanupStack::PushL(bmp2);
198 User::LeaveIfError(bmp2->Create(aSize, aRequiredMode));
200 User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bmp1, aRect1));
201 User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bmp2, aRect2));
203 TRgb *rgbBuf1=(TRgb *)User::AllocL(aSize.iWidth*sizeof(TRgb));
204 TRgb *rgbBuf2=(TRgb *)User::Alloc(aSize.iWidth*sizeof(TRgb));
208 User::Leave(KErrNoMemory);
211 TInt maxDeviation = 0;
212 for(TInt yy = 0; yy < aSize.iHeight && equal; yy++)
214 TPtr8 ptr1((TUint8 *)rgbBuf1,aSize.iWidth*sizeof(TRgb));
215 bmp1->GetScanLine(ptr1, TPoint(0, yy), aSize.iWidth, ERgb);
216 TPtr8 ptr2((TUint8 *)rgbBuf2,aSize.iWidth*sizeof(TRgb));
217 bmp2->GetScanLine(ptr2, TPoint(0, yy), aSize.iWidth, ERgb);
219 TRgb *rgbBufCur1 = rgbBuf1;
220 TRgb *rgbBufCur2 = rgbBuf2;
221 for(TInt ii = 0; ii < aSize.iWidth; ii++)
223 TInt delta = Abs(rgbBufCur1->Red()-rgbBufCur2->Red());
224 TInt delta1 = Abs(rgbBufCur1->Green()-rgbBufCur2->Green());
225 TInt delta2 = Abs(rgbBufCur1->Blue()-rgbBufCur2->Blue());
227 if((delta > aTolerance) || (delta1 > aTolerance) || (delta2 > aTolerance))
231 TInt maxItermedia = Max(delta1, delta2);
232 maxItermedia = Max(maxItermedia, delta);
233 maxDeviation = Max(maxItermedia, maxDeviation);
243 CleanupStack::PopAndDestroy(2,bmp1);
247 INFO_PRINTF3(_L("%S CheckRectA failed, max deviation %d"), &aErrorMsg, maxDeviation);
249 else if(maxDeviation)
251 INFO_PRINTF4(_L("%S CheckRectA passed with tolerance %d, max deviation %d"), &aErrorMsg, aTolerance, maxDeviation);
257 void CTAlphaWin::TestCondition()
259 // User::After(1000000);// helpful when debugging
262 TheClient->WaitForRedrawsToFinish();
263 CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestCondition()"));
266 void CTAlphaWin::TestConditionL()
270 TheClient->WaitForRedrawsToFinish();
272 const TInt tolerance = 9;
273 TSize winSize=BaseWin->Size();
274 TRect rect1(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize);
275 TRect rect2(TestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize);
276 CheckRectL(rect1, rect2, winSize, TheClient->iScreen->DisplayMode(), tolerance, _L("CTAlphaWin::TestCondition()"));
279 void CTAlphaWin::TestInitialConfiguration()
281 if(TheClient->iScreen->DisplayMode() == EColor64K)
291 void CTAlphaWin::TestMove()
293 // Test moving windows, both in front and behind
294 for (TInt i = 0; i<5; i++)
296 TPoint pos = iTestWin[i]->Position();
297 pos += TPoint(10,10);
298 iTestWin[i]->SetPos(pos);
301 for (TInt j = 0; j<5; j++)
303 TPoint pos = iTestWin[j]->Position();
304 pos -= TPoint(10,10);
305 iTestWin[j]->SetPos(pos);
311 void CTAlphaWin::TestRedraw()
313 // Test redrawing windows, both in front and behind
314 for (TInt i=0; i<5; i++)
316 iTestWin[i]->DrawNow();
322 void CTAlphaWin::TestInvisible()
324 // Test making windows visible and invisible, both in front and behind
325 for (TInt i=0; i<5; i++)
327 iTestWin[i]->SetVisible(EFalse);
329 iTestWin[i]->SetVisible(ETrue);
334 void CTAlphaWin::TestChildrenL()
336 struct CTAlphaWinChildren: public TCleanupItem
338 static void Destroy(TAny* trg)
340 static_cast<CTAlphaWindow*>(trg)->DestroyChildren();
342 CTAlphaWinChildren(CTAlphaWindow*trg): TCleanupItem(Destroy,trg)
346 CleanupStack::PushL(CTAlphaWinChildren(iTestWin[2]));
347 iTestWin[2]->CreateChildrenL(3);
350 CleanupStack::PopAndDestroy(iTestWin[2]);
354 void CTAlphaWin::TestAntiAliasedTextTransparentL()
358 for (TInt i=0; i<5; i++)
360 iTestWin[i]->SetVisible(EFalse);
362 iRefWin->SetVisible(EFalse);
363 TheClient->iWs.Flush();
365 //Create a new test window on the left
366 //Create a transparent window:
367 TSize winSize = BaseWin->Size();
369 RWindow theWin(TestWin->Client()->iWs);
370 User::LeaveIfError(theWin.Construct(*(TestWin->WinTreeNode()),(TUint32)&theWin));
372 theWin.SetExtent(TPoint(0,0), winSize);
373 theWin.SetBackgroundColor(TRgb(127,0,255,127));
374 TDisplayMode mode = EColor16MAP;
375 theWin.SetRequiredDisplayMode(mode);
376 theWin.SetVisible(ETrue);
377 theWin.SetTransparencyAlphaChannel();
379 TheClient->iWs.Flush();
380 CleanupClosePushL(theWin);
382 //get windows screen device.
383 CWsScreenDevice *device;
384 device = new (ELeave)CWsScreenDevice(TestWin->Client()->iWs);//(TheClient->iWs);
385 User::LeaveIfError(device->Construct(iTest->ScreenNumber()));
386 CleanupStack::PushL(device);
391 fs1.iTypeface.iName = KTestFontTypefaceName;
393 fs1.iFontStyle.SetBitmapType(EDefaultGlyphBitmap);
394 int error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font1,fs1);
397 TheClient->iScreen->ReleaseFont(font1);
398 User::Panic(_L("font not created"),error);
400 fs1.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
401 error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font2,fs1);
404 TheClient->iScreen->ReleaseFont(font1);
405 TheClient->iScreen->ReleaseFont(font2);
406 User::Panic(_L("font not created"),error);
410 device->CreateContext(gc);
411 CleanupStack::PushL(gc);
414 theWin.BeginRedraw();
415 gc->Activate(theWin);
417 gc->SetPenStyle( CGraphicsContext::ESolidPen );
418 gc->SetPenColor( TRgb( 0, 0, 0, 127 ) );
420 //draw text for anti-aliasing needs an open font (scalable).
421 int typefaces = TheClient->iScreen->NumTypefaces();
424 gc->SetBrushStyle( CGraphicsContext::ENullBrush );
425 gc->DrawText(_L("Test"),TPoint(10,20));
428 gc->DrawText(_L("Test"),TPoint(10,60));
431 //destruction and tidying up
434 TheClient->iWs.Flush();
436 TheClient->iScreen->ReleaseFont(font1);
437 TheClient->iScreen->ReleaseFont(font2);
438 CleanupStack::PopAndDestroy(gc);//gc
439 CleanupStack::PopAndDestroy(device);//device
441 //do not close the test window yet since there is a comparison
444 //now do the same on an off screen bitmap. Then create a window
445 //and put the bitmap onto it.
446 //create a colour bitmap
448 CFbsBitmap *bitmapOne;
449 bitmapOne = new (ELeave)CFbsBitmap();
450 CleanupStack::PushL(bitmapOne);
451 User::LeaveIfError(bitmapOne->Create(winSize,mode));
453 CFbsBitmapDevice *deviceOne=CFbsBitmapDevice::NewL(bitmapOne);
454 CleanupStack::PushL(deviceOne);
458 fs1.iFontStyle.SetBitmapType(EDefaultGlyphBitmap);
459 error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font3,fs1);
462 TheClient->iScreen->ReleaseFont(font3);
463 User::Panic(_L("font not created"),error);
465 fs1.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
466 error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font4,fs1);
469 TheClient->iScreen->ReleaseFont(font3);
470 TheClient->iScreen->ReleaseFont(font4);
471 User::Panic(_L("font not created"),error);
473 CFbsBitGc *bGcOne = CFbsBitGc::NewL();
474 CleanupStack::PushL(bGcOne);
476 bGcOne->Activate(deviceOne);
478 bGcOne->SetBrushStyle(CGraphicsContext::ESolidBrush);
479 bGcOne->SetBrushColor(TRgb(127,0,255,127));
480 bGcOne->DrawRect(TRect(0,0,winSize.iWidth,winSize.iHeight));
482 bGcOne->SetPenStyle(CGraphicsContext::ESolidPen);
483 bGcOne->SetPenColor(TRgb(0,0,0,127));
485 bGcOne->UseFont(font3);
486 bGcOne->SetBrushStyle( CGraphicsContext::ENullBrush );
487 bGcOne->DrawText(_L("Test"),TPoint(10,20));
488 bGcOne->DiscardFont();
489 bGcOne->UseFont(font4);
490 bGcOne->DrawText(_L("Test"),TPoint(10,60));
491 bGcOne->DiscardFont();
492 //destruction and tidying up
494 CFont::TMeasureTextOutput textSize;
495 font4->MeasureText(_L("Test"),NULL,&textSize);
497 TheClient->iScreen->ReleaseFont(font3);
498 TheClient->iScreen->ReleaseFont(font4);
500 //display at the left
501 RWindow refWin(BaseWin->Client()->iWs);
502 CleanupClosePushL(refWin);
503 User::LeaveIfError(refWin.Construct(*(BaseWin->WinTreeNode()),(TUint32)&refWin));
505 refWin.SetExtent(TPoint(0,0), winSize);
506 refWin.SetRequiredDisplayMode(mode);
507 refWin.SetVisible(ETrue);
508 refWin.SetTransparencyAlphaChannel();
510 TheClient->iWs.Flush();
512 //a gc for the ref win
513 CWsScreenDevice *refDevice;
514 refDevice = new (ELeave)CWsScreenDevice(BaseWin->Client()->iWs);
515 User::LeaveIfError(refDevice->Construct(iTest->ScreenNumber()));
516 CleanupStack::PushL(refDevice);
518 refDevice->CreateContext(gcRef);
519 CleanupStack::PushL(gcRef);
522 refWin.BeginRedraw();
523 gcRef->Activate(refWin);
524 gcRef->BitBlt(TPoint(0,0), bitmapOne);
527 TheClient->iWs.Flush();
529 TPoint refPos = refWin.AbsPosition();
530 TPoint winPos = theWin.AbsPosition();
532 //Compare the anti-aliased text areas
533 TInt textLength=textSize.iBounds.iBr.iX;
534 TInt textHeight=Abs(textSize.iBounds.iTl.iY);
536 TRect rect1(refPos.iX+10,refPos.iY+60-textHeight,
537 refPos.iX+10+textLength,refPos.iY+60);
538 TRect rect2(winPos.iX+10,winPos.iY+60-textHeight,
539 winPos.iX+10+textLength,winPos.iY+60);
541 TBool match = refDevice->RectCompare(rect1,rect2);
544 CleanupStack::PopAndDestroy(gcRef);
545 CleanupStack::PopAndDestroy(refDevice);
546 CleanupStack::PopAndDestroy(&refWin);
548 CleanupStack::PopAndDestroy(bGcOne);
549 CleanupStack::PopAndDestroy(deviceOne);
550 CleanupStack::PopAndDestroy(bitmapOne);
551 CleanupStack::PopAndDestroy(&theWin);//theWin
558 CTDrawOpWin* CTDrawOpWin::NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TRgb aDrawColour)
560 CTDrawOpWin* theWin = new(ELeave) CTDrawOpWin(aTest,aDrawColour);
562 theWin->ConstructL(*aParent);
563 theWin->SetExtL(aPos, aSize);
564 theWin->AssignGC(*TheClient->iGc);
565 if (TheClient->iScreen->DisplayMode() == EColor16MA)
567 theWin->BaseWin()->SetRequiredDisplayMode(EColor16MA);
571 theWin->BaseWin()->SetRequiredDisplayMode(EColor64K);
580 CTDrawOpWin::CTDrawOpWin(CTAlphaWin* aTest, TRgb aDrawColour)
581 : iTest(aTest), iDrawColour(aDrawColour)
585 void CTDrawOpWin::SetDrawOp(TInt aDrawOp)
591 void CTDrawOpWin::Draw()
593 _LIT(KText,"Text test");
595 iGc->SetPenColor(iDrawColour);
596 iGc->SetBrushColor(iDrawColour);
600 TInt bottom = size.iHeight - 5;
601 TInt right = size.iWidth - 5;
602 TInt square = Min(bottom-top,right-left);
607 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
608 iGc->SetPenStyle(CGraphicsContext::ENullPen);
609 iGc->DrawRect(TRect(left,top,right,bottom));
613 //!! The endpoint of the line is drawn twice, with the result that it is darker when we do blending
614 //!! Not intending to fix at the moment
616 iGc->SetPenStyle(CGraphicsContext::ESolidPen);
617 iGc->SetPenSize(TSize(4,4));
618 // The lines must not overlap, otherwise the blended lines will be darker at the overlap
619 iGc->DrawLine(TPoint(left+5,top), TPoint(left+square,top));
620 iGc->DrawLine(TPoint(left+5,top+5), TPoint(left+square,top+square));
621 iGc->DrawLine(TPoint(left,top+5), TPoint(left,top+square));
625 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
626 iGc->SetPenStyle(CGraphicsContext::ENullPen);
627 iGc->DrawEllipse(TRect(left,top,right,bottom));
630 case EOpDrawTextVertical:
632 iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
633 iGc->SetPenStyle(CGraphicsContext::ESolidPen);
635 TFontSpec fontSpec(KTestFontTypefaceName,200);
636 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(font, fontSpec));
638 if (iDrawOp==EOpDrawText)
639 iGc->DrawText(KText(), TPoint(5,30));
641 iGc->DrawTextVertical(KText(), TPoint(5,30), EFalse);
643 TheClient->iScreen->ReleaseFont(font);
646 case EOpDrawTextAntiAliased:
648 iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
649 iGc->SetPenStyle(CGraphicsContext::ESolidPen);
651 TFontSpec fontSpec(KTestFontTypefaceName,600);
652 fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
653 fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
655 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(font, fontSpec));
657 iGc->DrawText(KText(), TPoint(5,30));
659 TheClient->iScreen->ReleaseFont(font);
664 case EOpBitBltMasked:
677 CTAlphaWindow::~CTAlphaWindow()
682 CTAlphaWindow* CTAlphaWindow::NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TInt aDrawState)
684 CTAlphaWindow* theWin = new (ELeave) CTAlphaWindow(aTest);
686 theWin->ConstructL(*aParent);
687 theWin->SetExtL(aPos, aSize);
688 theWin->SetDrawState(aDrawState);
690 theWin->AssignGC(*TheClient->iGc);
693 theWin->iDrawState |= EActive;
699 void CTAlphaWindow::SetDrawState(TInt aDrawState)
701 TBool active = iDrawState & EActive;
702 iDrawState = aDrawState & 0x7fffffff;
704 TRgb colour = ColourFromDrawState(iDrawState);
705 ((RWindow*) DrawableWin())->SetBackgroundColor(colour);
707 if (iDrawState & EModeColor16MA)
708 BaseWin()->SetRequiredDisplayMode(EColor16MA);
710 BaseWin()->SetRequiredDisplayMode(EColor64K);
712 BaseWin()->SetVisible(! (iDrawState & EInvisible));
716 if (iDrawState & EAlphaTransparency)
717 ((RWindow*) DrawableWin())->SetTransparencyAlphaChannel();
718 else if (iDrawState & ETransparencyFactor)
719 ((RWindow*) DrawableWin())->SetTransparencyFactor(TRgb(128,128,128));
723 iDrawState |= EActive;
726 void CTAlphaWindow::SetVisible(TBool aVisible)
729 iDrawState &= ~EInvisible;
731 iDrawState |= EInvisible;
732 BaseWin()->SetVisible(aVisible);
735 void CTAlphaWindow::CreateChildrenL(TInt aDepth)
741 iChild1 = CTAlphaWindow::NewL(iTest, this, TPoint(size.iWidth/3,0), TSize(2*size.iWidth/3, 2*size.iHeight/3), ERed | EGreen | EBlue | EOpaque);
742 iChild2 = CTAlphaWindow::NewL(iTest, this, TPoint(0,size.iHeight/3), TSize(2*size.iWidth/3, 2*size.iHeight/3), ERed | EGreen | EBlue | EAlphaTransparency);
743 iChild2->CreateChildrenL(aDepth-1);
747 void CTAlphaWindow::DestroyChildren()
751 iChild1->DestroyChildren();
757 iChild2->DestroyChildren();
763 TInt CTAlphaWindow::DrawState()
768 void CTAlphaWindow::Draw()
770 // we draw a diagonal line from top left to bottom right
771 // we use the complementary colour to the window background colour
772 TInt red = (iDrawState & ERed) ? 0 : 255;
773 TInt green = (iDrawState & EGreen) ? 0 : 255;
774 TInt blue = (iDrawState & EBlue) ? 0 : 255;
775 TRgb color(red,green,blue);
778 iGc->SetPenColor(color);
779 iGc->SetPenSize(TSize(4,4));
780 iGc->DrawLine(TPoint(0,0), TPoint(size.iWidth, size.iHeight));
788 CTAlphaRefWin::CTAlphaRefWin(TFixedArray<CTAlphaWindow*,5>& aAlphaWin)
789 : iAlphaWin(aAlphaWin)
792 CTAlphaRefWin* CTAlphaRefWin::NewL(CTWinBase* aParent, TPoint aPos, TSize aSize, TFixedArray<CTAlphaWindow*,5>& aAlphaWin)
794 CTAlphaRefWin* theWin = new(ELeave) CTAlphaRefWin(aAlphaWin);
796 theWin->ConstructL(*aParent);
797 theWin->SetExtL(aPos, aSize);
798 theWin->AssignGC(*TheClient->iGc);
799 theWin->BaseWin()->SetRequiredDisplayMode(EColor64K);
807 void CTAlphaRefWin::Draw()
809 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
810 iGc->SetBrushColor(KRgbWhite);
813 // Note, the order of the windows in the array must correspond to their z-order
814 for (TInt i=0; i<5; i++)
815 DrawWindow(iAlphaWin[i], iAlphaWin[i]->Position());
818 void CTAlphaRefWin::DrawWindow(CTAlphaWindow* aWindow, TPoint aPos)
820 TInt drawState = aWindow->DrawState();
821 if ( (drawState & EInvisible) || ! (drawState & EActive) )
824 TRgb colour = ColourFromDrawState(drawState);
825 if (drawState & EOpaque)
826 colour.SetAlpha(255);
827 if (drawState & ETransparent)
829 iGc->SetBrushColor(colour);
832 TPoint br = tl + aWindow->Size();
836 TInt red = (drawState & ERed) ? 0 : 255;
837 TInt green = (drawState & EGreen) ? 0 : 255;
838 TInt blue = (drawState & EBlue) ? 0 : 255;
839 colour = TRgb(red,green,blue);
841 iGc->SetClippingRect(rect);
844 iGc->SetPenColor(colour);
845 iGc->SetPenSize(TSize(4,4));
846 iGc->DrawLine(tl, br);
848 iGc->CancelClippingRect();
850 if (aWindow->iChild1)
851 DrawWindow(aWindow->iChild1, aPos + aWindow->iChild1->Position() );
852 if (aWindow->iChild2)
853 DrawWindow(aWindow->iChild2, aPos + aWindow->iChild2->Position() );
860 void CTAlphaWin::RunTestCaseL(TInt /*aCurTestCase*/)
862 //User::After(TTimeIntervalMicroSeconds32(1000 * 1000));
863 ((CTAlphaWinStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
864 switch (++iTest->iState)
868 @SYMTestCaseID GRAPHICS-WSERV-0278
874 @SYMTestCaseDesc Semi-transparent drawing
876 @SYMTestPriority High
878 @SYMTestStatus Implemented
880 @SYMTestActions Use draw operations with semi-transparent pen or brush colours
882 @SYMTestExpectedResults Draw operations must do alpha blending
887 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0278"));
888 if(TransparencySupportedL() == KErrNotSupported)
890 LOG_MESSAGE(_L("Test(1) complete - Transparency not supported\n"));
894 TDisplayMode mode = TheClient->iScreen->DisplayMode();
895 if (mode < EColor64K)
897 LOG_MESSAGE(_L("Test(1) complete - Display mode < EColor64K\n"));
901 _LIT(KSemiTrans64K,"(1) Semi transparent drawing Color64K");
902 iTest->LogSubTest(KSemiTrans64K);
903 TestSemiTransparentDrawingL();
909 @SYMTestCaseID GRAPHICS-WSERV-0287
915 @SYMTestCaseDesc Invisible. All windows are in EColor16MA display mode.
917 @SYMTestPriority High
919 @SYMTestStatus Implemented
921 @SYMTestActions Transparent alpha channel windows are made invisible and visible both in front and behind one another
923 @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
927 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0287"));
928 ConfigureDisplayModes(EColor16MA);
929 if(TransparencySupportedL()==KErrNone)
931 _LIT(KInvisible16MA,"(2) Invisible Color16MA");
932 iTest->LogSubTest(KInvisible16MA);
939 @SYMTestCaseID GRAPHICS-WSERV-0280
945 @SYMTestCaseDesc Initial Configuration. All windows are in EColor64K display mode.
947 @SYMTestPriority High
949 @SYMTestStatus Implemented
951 @SYMTestActions Several windows are set to be transparent alpha channel, and given semi-transparent or transparent background colours
953 @SYMTestExpectedResults The transparent window configuration matches a reference drawing created using only alpha blending
956 //Test 3 to 6 can't be run without transparency support
958 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0280"));
959 ConfigureDisplayModes(EColor64K);
960 if(TransparencySupportedL()==KErrNone)
962 _LIT(KInitialConfiguration64K,"(3) Initial configuration Color64K");
963 iTest->LogSubTest(KInitialConfiguration64K);
964 TestInitialConfiguration();
969 @SYMTestCaseID GRAPHICS-WSERV-0281
975 @SYMTestCaseDesc Move. All windows are in EColor64K display mode.
977 @SYMTestPriority High
979 @SYMTestStatus Implemented
981 @SYMTestActions Transparent alpha channel windows are moved both in front and behind one another
983 @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
987 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0281"));
988 if(TransparencySupportedL()==KErrNone)
990 _LIT(KMove64K,"(4) Move Color64K");
991 iTest->LogSubTest(KMove64K);
997 @SYMTestCaseID GRAPHICS-WSERV-0282
1003 @SYMTestCaseDesc Redraw. All windows are in EColor64K display mode.
1005 @SYMTestPriority High
1007 @SYMTestStatus Implemented
1009 @SYMTestActions Transparent alpha channel windows are redrawn both in front and behind one another
1011 @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
1015 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0282"));
1016 if(TransparencySupportedL()==KErrNone)
1018 _LIT(KRedraw64K,"(5) Redraw Color64K");
1019 iTest->LogSubTest(KRedraw64K);
1025 @SYMTestCaseID GRAPHICS-WSERV-0283-0001
1031 @SYMTestCaseDesc Invisible. All windows are in EColor64K display mode.
1033 @SYMTestPriority High
1035 @SYMTestStatus Implemented
1037 @SYMTestActions Transparent alpha channel windows are made invisible and visible both in front and behind one another
1039 @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
1043 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0283-0001"));
1044 if(TransparencySupportedL()==KErrNone)
1046 _LIT(KInvisible64K,"(6) Invisible Color64K");
1047 iTest->LogSubTest(KInvisible64K);
1053 @SYMTestCaseID GRAPHICS-WSERV-0283-0002
1059 @SYMTestCaseDesc Children. All windows are in EColor64K display mode.
1061 @SYMTestPriority High
1063 @SYMTestStatus Implemented
1065 @SYMTestActions Transparent alpha channel windows are given child windows, both transparent and non-transparent,
1066 and are then moved, redrawn, set visible or invisible both in front and behind one another
1068 @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
1072 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0283-0002"));
1073 _LIT(KChildren64K,"(7)Children Color64K");
1074 iTest->LogSubTest(KChildren64K);
1079 @SYMTestCaseID GRAPHICS-WSERV-0356
1085 @SYMTestCaseDesc Initial Configuration. All windows are in EColor64k Dispaly Mode
1087 @SYMTestPriority High
1089 @SYMTestStatus Implemented
1091 @SYMTestActions Tests Anti-aliasing of text
1093 @SYMTestExpectedResults Anti-alisaing should behave correctly
1097 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0356"));
1098 _LIT(KAntiAliasedText64K,"(8) AntiAliasedText DEF082251 Color64K");
1099 iTest->LogSubTest(KAntiAliasedText64K);
1100 TestAntiAliasedTextTransparentL();
1105 @SYMTestCaseID GRAPHICS-WSERV-0284
1111 @SYMTestCaseDesc Initial Configuration. All windows are in EColor16MA display mode.
1113 @SYMTestPriority High
1115 @SYMTestStatus Implemented
1117 @SYMTestActions Several windows are set to be transparent alpha channel, and given semi-transparent or transparent background colours
1119 @SYMTestExpectedResults The transparent window configuration matches a reference drawing created using only alpha blending
1124 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0284"));
1125 ConfigureDisplayModes(EColor16MA);
1126 TDisplayMode mode1 = TheClient->iScreen->DisplayMode();
1127 _LIT(KInitialConfiguration16MA,"(9)Initial configuration Color16MA");
1128 iTest->LogSubTest(KInitialConfiguration16MA);
1129 TestInitialConfiguration();
1134 @SYMTestCaseID GRAPHICS-WSERV-0285
1140 @SYMTestCaseDesc Move. All windows are in EColor16MA display mode.
1142 @SYMTestPriority High
1144 @SYMTestStatus Implemented
1146 @SYMTestActions Transparent alpha channel windows are moved both in front and behind one another
1148 @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
1152 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0285"));
1153 _LIT(KMove16MA,"(10)Move Color16MA");
1154 iTest->LogSubTest(KMove16MA);
1159 @SYMTestCaseID GRAPHICS-WSERV-0286
1165 @SYMTestCaseDesc Redraw. All windows are in EColor16MA display mode.
1167 @SYMTestPriority High
1169 @SYMTestStatus Implemented
1171 @SYMTestActions Transparent alpha channel windows are redrawn both in front and behind one another
1173 @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
1177 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0286"));
1178 _LIT(KRedraw16MA,"(11)Redraw Color16MA");
1179 iTest->LogSubTest(KRedraw16MA);
1185 @SYMTestCaseID GRAPHICS-WSERV-0279
1191 @SYMTestCaseDesc Transparent drawing
1193 @SYMTestPriority High
1195 @SYMTestStatus Implemented
1197 @SYMTestActions Use draw operations with transparent pen or brush colours
1199 @SYMTestExpectedResults Draw operations with transparent pen or brush colours should leave the destination unchanged
1204 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0279"));
1205 ConfigureDisplayModes(EColor64K);
1206 _LIT(KTrans64K,"(12) Transparent drawing Color64K");
1207 iTest->LogSubTest(KTrans64K);
1208 TestTransparentDrawingL();
1214 @SYMTestCaseID GRAPHICS-WSERV-0288
1220 @SYMTestCaseDesc Children. All windows are in EColor16MA display mode.
1222 @SYMTestPriority High
1224 @SYMTestStatus Implemented
1226 @SYMTestActions Transparent alpha channel windows are given child windows, both transparent and non-transparent,
1227 and are then moved, redrawn, set visible or invisible both in front and behind one another
1229 @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
1233 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0288"));
1234 _LIT(KChildren16MA,"(13) Children Color16MA");
1235 iTest->LogSubTest(KChildren16MA);
1240 @SYMTestCaseID GRAPHICS-WSERV-0357
1246 @SYMTestCaseDesc Initial Configuration. All windows are in EColor16MA Dispaly Mode
1248 @SYMTestPriority High
1250 @SYMTestStatus Implemented
1252 @SYMTestActions Tests Anti-aliasing of text
1254 @SYMTestExpectedResults Anti-alisaing should behave correctly
1258 ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0357"));
1259 _LIT(KAntiAliasedText16MA,"(14) AntiAliasedText DEF082251 Color16MA");
1260 iTest->LogSubTest(KAntiAliasedText16MA);
1261 TestAntiAliasedTextTransparentL();
1264 ((CTAlphaWinStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1265 ((CTAlphaWinStep*)iStep)->CloseTMSGraphicsStep();
1269 ((CTAlphaWinStep*)iStep)->RecordTestResultL();
1272 __WS_CONSTRUCT_STEP__(AlphaWin)