os/graphics/windowing/windowserver/test/tauto/TAlphaChannel.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
sl@0
     2
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
// All rights reserved.
sl@0
     4
// This component and the accompanying materials are made available
sl@0
     5
// under the terms of "Eclipse Public License v1.0"
sl@0
     6
// which accompanies this distribution, and is available
sl@0
     7
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
//
sl@0
     9
// Initial Contributors:
sl@0
    10
// Nokia Corporation - initial contribution.
sl@0
    11
//
sl@0
    12
// Contributors:
sl@0
    13
//
sl@0
    14
// Description:
sl@0
    15
// TBITMAP.H
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
 @test
sl@0
    22
 @internalComponent - Internal Symbian test code
sl@0
    23
*/
sl@0
    24
sl@0
    25
#ifndef __TALPHACHANNEL_H__
sl@0
    26
#define __TALPHACHANNEL_H__
sl@0
    27
sl@0
    28
#include "AUTO.H"
sl@0
    29
#include "../tlib/testbase.h"
sl@0
    30
#include "TGraphicsHarness.h"
sl@0
    31
sl@0
    32
class CTAlphaChannel;
sl@0
    33
sl@0
    34
/**
sl@0
    35
	Introduces a base class for transparent windows (both background and foreground)
sl@0
    36
*/
sl@0
    37
class CTWinAlpha : public CTWin
sl@0
    38
	{
sl@0
    39
public:
sl@0
    40
	void Draw(); //we have to overridden it to avoid panic in a based class
sl@0
    41
public:
sl@0
    42
	TInt iState;
sl@0
    43
	};
sl@0
    44
sl@0
    45
enum {ETransparencyFactor, ETransparencyAlpha, ENonTransparentAlpha};
sl@0
    46
sl@0
    47
/**
sl@0
    48
	Introduces a foreground transparent windows.
sl@0
    49
	In order to set any instance of class as transparent it has to be created with 
sl@0
    50
	ETransparencyAlpha parameter
sl@0
    51
*/
sl@0
    52
class CTWinAlphaForeground : public CTWin
sl@0
    53
	{
sl@0
    54
public:
sl@0
    55
	static CTWinAlphaForeground* NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize, 
sl@0
    56
		CTWinBase* aParent, CWindowGc& aGc, TDisplayMode* aMode, TRgb aCol, TInt aTransparencyType = ENonTransparentAlpha);
sl@0
    57
	~CTWinAlphaForeground();
sl@0
    58
		
sl@0
    59
private:
sl@0
    60
	CTWinAlphaForeground(CTAlphaChannel& aTest);
sl@0
    61
	
sl@0
    62
public:
sl@0
    63
	void Draw();
sl@0
    64
	void SetBackgroundColor(TRgb aColor);
sl@0
    65
	void SetDisplayMode(TDisplayMode aDisplayMode);
sl@0
    66
	void StartAnimationL();
sl@0
    67
	void CreateBackedWindowL();
sl@0
    68
	inline void SetDrawOpaque(TBool aDrawOpaque = ETrue)
sl@0
    69
		{
sl@0
    70
		iDrawOpaque = aDrawOpaque;
sl@0
    71
		}
sl@0
    72
		
sl@0
    73
protected:
sl@0
    74
	void DrawTable(CBitmapContext& aGc) const;
sl@0
    75
	void DrawPrimitivesInCell(CBitmapContext& aGc, const TRect& aRect, 
sl@0
    76
								CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA);
sl@0
    77
	void DrawTextInCell(CBitmapContext& aGc, const TRect& aRect);
sl@0
    78
	void PrepareForDrawingL();
sl@0
    79
	void CalculateTableMargin();
sl@0
    80
	void SetPoligonLocation(const TPoint &ptOffset);
sl@0
    81
	void CreateBackgroundBitmapL(const TDisplayMode& aDispMode);
sl@0
    82
	void CleanBackgroundBitmap();
sl@0
    83
	
sl@0
    84
protected:
sl@0
    85
	TInt iRows[4];
sl@0
    86
	TInt iCol; // width of the first column
sl@0
    87
	CFbsBitmap* iBitmapBackground;
sl@0
    88
	CFbsBitmapDevice* iBitmapDeviceBackground;
sl@0
    89
	CBitmapContext*  iBitmapContextBackground;
sl@0
    90
	TRgb iBackgroundColor;
sl@0
    91
	CArrayFix<TPoint>* iPolygon;
sl@0
    92
	TBuf<16> iTitle1;
sl@0
    93
	TBuf<16> iTitle2;
sl@0
    94
	TBool iDrawOpaque; // this value will set to CWindowGc before drawing, should have any effect on drawing with alpha channel
sl@0
    95
	
sl@0
    96
private:
sl@0
    97
	CTAlphaChannel& iTest;
sl@0
    98
	};
sl@0
    99
sl@0
   100
/** Test base class, which exersices drawing graphics operations with alpha channel */
sl@0
   101
class CTAlphaChannel : public CTWsGraphicsBase
sl@0
   102
	{
sl@0
   103
friend class CTWinAlphaForeground;	
sl@0
   104
public:
sl@0
   105
	CTAlphaChannel(CTestStep* aStep);
sl@0
   106
	~CTAlphaChannel();
sl@0
   107
	void ConstructL();
sl@0
   108
	void DrawTestWindowsNow(TBool aDrawBackgroundWin = EFalse);
sl@0
   109
	
sl@0
   110
	void SetWindow64K();
sl@0
   111
	void SetOpaqueWindow16MA();
sl@0
   112
	void SetTransparentWindow16MA();
sl@0
   113
	TInt SetWindow16MAWithMask();
sl@0
   114
	TInt SetWindow64KWithMask();
sl@0
   115
	CGraphicsContext::TDrawMode GetDrawMode(TInt aIndex) const;
sl@0
   116
	TRgb GetBrush(TInt aIndex) const;
sl@0
   117
	TRgb GetPen(TInt aIndex) const;
sl@0
   118
sl@0
   119
	// test functions
sl@0
   120
	void SetDisplayModeConfiguration(TInt aConfig);
sl@0
   121
	void SetPositionConfiguration(TInt aConfig);
sl@0
   122
	void SetColourConfiguration(TInt aConfig);
sl@0
   123
	void DoMoving();
sl@0
   124
	void DoMoveBehind();
sl@0
   125
	void DoInvisibility();
sl@0
   126
	void TestMoving();
sl@0
   127
	void TestMovingOverlapping();
sl@0
   128
	void TestFading();
sl@0
   129
	void TestChangingTransparencyFactor();
sl@0
   130
	void TestInvisibility();
sl@0
   131
	void TestMoveUnderneath();
sl@0
   132
	void TestMoveBehindInvisible();
sl@0
   133
	void TestRedrawBehind();
sl@0
   134
	void TestAnimationL();
sl@0
   135
	void TestBackedWindowL();
sl@0
   136
	void TestEffectSetOpaque();
sl@0
   137
	void TestChildWindowL();
sl@0
   138
	void TestMultipleChildrenL();
sl@0
   139
	void TestTransparentMovingUnderOpaqueL();
sl@0
   140
	void TestSetOrdinalPosition();
sl@0
   141
	
sl@0
   142
protected:
sl@0
   143
//from 	CTGraphicsStep
sl@0
   144
	virtual void RunTestCaseL(TInt aCurTestCase);
sl@0
   145
	void CreateForegroundWindowsL(const TSize& aSize, TDisplayMode aMode);
sl@0
   146
	void DestroyForegroundWindows();
sl@0
   147
	void DrawOffscreenBitmapsL(const TRgb& aPen, const TRgb& aBrush, 
sl@0
   148
										CGraphicsContext* aBitmapContext64K, CGraphicsContext* aBitmapContext16MA, 
sl@0
   149
										CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA);
sl@0
   150
	void CalculateSizePrimitives(const TSize& aSize);
sl@0
   151
protected:
sl@0
   152
	TRgb iPenTable;
sl@0
   153
	CGraphicsContext::TBrushStyle	iBrushStyle;
sl@0
   154
	CGraphicsContext::TPenStyle iPenStyle;
sl@0
   155
	TSize iSizeForegroundWindow;
sl@0
   156
private:
sl@0
   157
	CTWinAlpha*	iBackgroundWindow;
sl@0
   158
	CTWinAlphaForeground*	iForegroundWindowBottom;
sl@0
   159
	CTWinAlphaForeground*	iForegroundWindowOpaque;
sl@0
   160
	CTWinAlphaForeground*	iForegroundWindowSemiTrans;
sl@0
   161
	CTWinAlphaForeground*	iForegroundWindowTrans;
sl@0
   162
	CTWinAlphaForeground*	iForegroundWindowTop;
sl@0
   163
	
sl@0
   164
	CArrayPtrFlat<CTWinAlphaForeground> iArrWindow;	
sl@0
   165
	
sl@0
   166
	
sl@0
   167
	CFbsBitmap* iBitmap64K_1;
sl@0
   168
	CFbsBitmap* iBitmap16MA_1;
sl@0
   169
	CFbsBitmap* iBitmap64K_2;
sl@0
   170
	CFbsBitmap* iBitmap16MA_2;
sl@0
   171
	CFbsBitmap* iBitmap64K_3;
sl@0
   172
	CFbsBitmap* iBitmap16MA_3;
sl@0
   173
	CFbsBitmap* iBitmapMask;
sl@0
   174
	CFbsBitmap* iBitmapGray256Mask;
sl@0
   175
	
sl@0
   176
	CFbsBitmapDevice* iBitmapDevice64K_1;
sl@0
   177
	CFbsBitmapDevice* iBitmapDevice16MA_1;
sl@0
   178
	CFbsBitmapDevice* iBitmapDevice64K_2;
sl@0
   179
	CFbsBitmapDevice* iBitmapDevice16MA_2;
sl@0
   180
	CFbsBitmapDevice* iBitmapDevice64K_3;
sl@0
   181
	CFbsBitmapDevice* iBitmapDevice16MA_3;
sl@0
   182
sl@0
   183
	CGraphicsContext* iBitmapContext64K_1;
sl@0
   184
	CGraphicsContext* iBitmapContext16MA_1;
sl@0
   185
	CGraphicsContext* iBitmapContext64K_2;
sl@0
   186
	CGraphicsContext* iBitmapContext16MA_2;
sl@0
   187
	CGraphicsContext* iBitmapContext64K_3;
sl@0
   188
	CGraphicsContext* iBitmapContext16MA_3;
sl@0
   189
sl@0
   190
	TBuf<256> iText;
sl@0
   191
	CFont* iFont; // for true type font, needs to exercise anti-aliasing 
sl@0
   192
	CFont* iFont1; // title font
sl@0
   193
sl@0
   194
	TSize iBitmapSize;
sl@0
   195
	TSize iRectangleSize;
sl@0
   196
	TSize iEllipseSize ;
sl@0
   197
	TSize iTriangleSize ;
sl@0
   198
	TInt iFirstCellWidth ;
sl@0
   199
	TInt iFirstCellHeight;
sl@0
   200
	TBool iDrawText; // if true output text, graphics primitives otherwise
sl@0
   201
	TBool iIsFading;
sl@0
   202
	TUint8 iBlackFading;
sl@0
   203
	TUint8 iWhiteFading;
sl@0
   204
	};
sl@0
   205
	
sl@0
   206
class CTAlphaChannelStep : public CTGraphicsStep
sl@0
   207
	{
sl@0
   208
public:
sl@0
   209
	CTAlphaChannelStep();
sl@0
   210
protected:	
sl@0
   211
	//from CTGraphicsStep
sl@0
   212
	virtual CTGraphicsBase* CreateTestL();
sl@0
   213
	};
sl@0
   214
sl@0
   215
_LIT(KTAlphaChannelStep,"TAlphaChannel");
sl@0
   216
sl@0
   217
sl@0
   218
#endif