1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TAlphaChannel.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,218 @@
1.4 +
1.5 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// under the terms of "Eclipse Public License v1.0"
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +// TBITMAP.H
1.19 +//
1.20 +//
1.21 +
1.22 +/**
1.23 + @file
1.24 + @test
1.25 + @internalComponent - Internal Symbian test code
1.26 +*/
1.27 +
1.28 +#ifndef __TALPHACHANNEL_H__
1.29 +#define __TALPHACHANNEL_H__
1.30 +
1.31 +#include "AUTO.H"
1.32 +#include "../tlib/testbase.h"
1.33 +#include "TGraphicsHarness.h"
1.34 +
1.35 +class CTAlphaChannel;
1.36 +
1.37 +/**
1.38 + Introduces a base class for transparent windows (both background and foreground)
1.39 +*/
1.40 +class CTWinAlpha : public CTWin
1.41 + {
1.42 +public:
1.43 + void Draw(); //we have to overridden it to avoid panic in a based class
1.44 +public:
1.45 + TInt iState;
1.46 + };
1.47 +
1.48 +enum {ETransparencyFactor, ETransparencyAlpha, ENonTransparentAlpha};
1.49 +
1.50 +/**
1.51 + Introduces a foreground transparent windows.
1.52 + In order to set any instance of class as transparent it has to be created with
1.53 + ETransparencyAlpha parameter
1.54 +*/
1.55 +class CTWinAlphaForeground : public CTWin
1.56 + {
1.57 +public:
1.58 + static CTWinAlphaForeground* NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize,
1.59 + CTWinBase* aParent, CWindowGc& aGc, TDisplayMode* aMode, TRgb aCol, TInt aTransparencyType = ENonTransparentAlpha);
1.60 + ~CTWinAlphaForeground();
1.61 +
1.62 +private:
1.63 + CTWinAlphaForeground(CTAlphaChannel& aTest);
1.64 +
1.65 +public:
1.66 + void Draw();
1.67 + void SetBackgroundColor(TRgb aColor);
1.68 + void SetDisplayMode(TDisplayMode aDisplayMode);
1.69 + void StartAnimationL();
1.70 + void CreateBackedWindowL();
1.71 + inline void SetDrawOpaque(TBool aDrawOpaque = ETrue)
1.72 + {
1.73 + iDrawOpaque = aDrawOpaque;
1.74 + }
1.75 +
1.76 +protected:
1.77 + void DrawTable(CBitmapContext& aGc) const;
1.78 + void DrawPrimitivesInCell(CBitmapContext& aGc, const TRect& aRect,
1.79 + CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA);
1.80 + void DrawTextInCell(CBitmapContext& aGc, const TRect& aRect);
1.81 + void PrepareForDrawingL();
1.82 + void CalculateTableMargin();
1.83 + void SetPoligonLocation(const TPoint &ptOffset);
1.84 + void CreateBackgroundBitmapL(const TDisplayMode& aDispMode);
1.85 + void CleanBackgroundBitmap();
1.86 +
1.87 +protected:
1.88 + TInt iRows[4];
1.89 + TInt iCol; // width of the first column
1.90 + CFbsBitmap* iBitmapBackground;
1.91 + CFbsBitmapDevice* iBitmapDeviceBackground;
1.92 + CBitmapContext* iBitmapContextBackground;
1.93 + TRgb iBackgroundColor;
1.94 + CArrayFix<TPoint>* iPolygon;
1.95 + TBuf<16> iTitle1;
1.96 + TBuf<16> iTitle2;
1.97 + TBool iDrawOpaque; // this value will set to CWindowGc before drawing, should have any effect on drawing with alpha channel
1.98 +
1.99 +private:
1.100 + CTAlphaChannel& iTest;
1.101 + };
1.102 +
1.103 +/** Test base class, which exersices drawing graphics operations with alpha channel */
1.104 +class CTAlphaChannel : public CTWsGraphicsBase
1.105 + {
1.106 +friend class CTWinAlphaForeground;
1.107 +public:
1.108 + CTAlphaChannel(CTestStep* aStep);
1.109 + ~CTAlphaChannel();
1.110 + void ConstructL();
1.111 + void DrawTestWindowsNow(TBool aDrawBackgroundWin = EFalse);
1.112 +
1.113 + void SetWindow64K();
1.114 + void SetOpaqueWindow16MA();
1.115 + void SetTransparentWindow16MA();
1.116 + TInt SetWindow16MAWithMask();
1.117 + TInt SetWindow64KWithMask();
1.118 + CGraphicsContext::TDrawMode GetDrawMode(TInt aIndex) const;
1.119 + TRgb GetBrush(TInt aIndex) const;
1.120 + TRgb GetPen(TInt aIndex) const;
1.121 +
1.122 + // test functions
1.123 + void SetDisplayModeConfiguration(TInt aConfig);
1.124 + void SetPositionConfiguration(TInt aConfig);
1.125 + void SetColourConfiguration(TInt aConfig);
1.126 + void DoMoving();
1.127 + void DoMoveBehind();
1.128 + void DoInvisibility();
1.129 + void TestMoving();
1.130 + void TestMovingOverlapping();
1.131 + void TestFading();
1.132 + void TestChangingTransparencyFactor();
1.133 + void TestInvisibility();
1.134 + void TestMoveUnderneath();
1.135 + void TestMoveBehindInvisible();
1.136 + void TestRedrawBehind();
1.137 + void TestAnimationL();
1.138 + void TestBackedWindowL();
1.139 + void TestEffectSetOpaque();
1.140 + void TestChildWindowL();
1.141 + void TestMultipleChildrenL();
1.142 + void TestTransparentMovingUnderOpaqueL();
1.143 + void TestSetOrdinalPosition();
1.144 +
1.145 +protected:
1.146 +//from CTGraphicsStep
1.147 + virtual void RunTestCaseL(TInt aCurTestCase);
1.148 + void CreateForegroundWindowsL(const TSize& aSize, TDisplayMode aMode);
1.149 + void DestroyForegroundWindows();
1.150 + void DrawOffscreenBitmapsL(const TRgb& aPen, const TRgb& aBrush,
1.151 + CGraphicsContext* aBitmapContext64K, CGraphicsContext* aBitmapContext16MA,
1.152 + CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA);
1.153 + void CalculateSizePrimitives(const TSize& aSize);
1.154 +protected:
1.155 + TRgb iPenTable;
1.156 + CGraphicsContext::TBrushStyle iBrushStyle;
1.157 + CGraphicsContext::TPenStyle iPenStyle;
1.158 + TSize iSizeForegroundWindow;
1.159 +private:
1.160 + CTWinAlpha* iBackgroundWindow;
1.161 + CTWinAlphaForeground* iForegroundWindowBottom;
1.162 + CTWinAlphaForeground* iForegroundWindowOpaque;
1.163 + CTWinAlphaForeground* iForegroundWindowSemiTrans;
1.164 + CTWinAlphaForeground* iForegroundWindowTrans;
1.165 + CTWinAlphaForeground* iForegroundWindowTop;
1.166 +
1.167 + CArrayPtrFlat<CTWinAlphaForeground> iArrWindow;
1.168 +
1.169 +
1.170 + CFbsBitmap* iBitmap64K_1;
1.171 + CFbsBitmap* iBitmap16MA_1;
1.172 + CFbsBitmap* iBitmap64K_2;
1.173 + CFbsBitmap* iBitmap16MA_2;
1.174 + CFbsBitmap* iBitmap64K_3;
1.175 + CFbsBitmap* iBitmap16MA_3;
1.176 + CFbsBitmap* iBitmapMask;
1.177 + CFbsBitmap* iBitmapGray256Mask;
1.178 +
1.179 + CFbsBitmapDevice* iBitmapDevice64K_1;
1.180 + CFbsBitmapDevice* iBitmapDevice16MA_1;
1.181 + CFbsBitmapDevice* iBitmapDevice64K_2;
1.182 + CFbsBitmapDevice* iBitmapDevice16MA_2;
1.183 + CFbsBitmapDevice* iBitmapDevice64K_3;
1.184 + CFbsBitmapDevice* iBitmapDevice16MA_3;
1.185 +
1.186 + CGraphicsContext* iBitmapContext64K_1;
1.187 + CGraphicsContext* iBitmapContext16MA_1;
1.188 + CGraphicsContext* iBitmapContext64K_2;
1.189 + CGraphicsContext* iBitmapContext16MA_2;
1.190 + CGraphicsContext* iBitmapContext64K_3;
1.191 + CGraphicsContext* iBitmapContext16MA_3;
1.192 +
1.193 + TBuf<256> iText;
1.194 + CFont* iFont; // for true type font, needs to exercise anti-aliasing
1.195 + CFont* iFont1; // title font
1.196 +
1.197 + TSize iBitmapSize;
1.198 + TSize iRectangleSize;
1.199 + TSize iEllipseSize ;
1.200 + TSize iTriangleSize ;
1.201 + TInt iFirstCellWidth ;
1.202 + TInt iFirstCellHeight;
1.203 + TBool iDrawText; // if true output text, graphics primitives otherwise
1.204 + TBool iIsFading;
1.205 + TUint8 iBlackFading;
1.206 + TUint8 iWhiteFading;
1.207 + };
1.208 +
1.209 +class CTAlphaChannelStep : public CTGraphicsStep
1.210 + {
1.211 +public:
1.212 + CTAlphaChannelStep();
1.213 +protected:
1.214 + //from CTGraphicsStep
1.215 + virtual CTGraphicsBase* CreateTestL();
1.216 + };
1.217 +
1.218 +_LIT(KTAlphaChannelStep,"TAlphaChannel");
1.219 +
1.220 +
1.221 +#endif