os/graphics/graphicsdeviceinterface/screendriver/inc/BMDRAW.H
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __BMDRAW_H__
sl@0
    17
#define __BMDRAW_H__
sl@0
    18
sl@0
    19
#include <gdi.h>
sl@0
    20
#include <bitdraw.h>
sl@0
    21
#include "BitDrawScaling.h"
sl@0
    22
#include "BitDrawOrigin.h"
sl@0
    23
#include "BmAlphaBlend.h"
sl@0
    24
#include "BitDrawOrientation.h"
sl@0
    25
sl@0
    26
#ifdef __ARMCC__
sl@0
    27
	#define FORCEINLINE __forceinline
sl@0
    28
#else
sl@0
    29
	#define FORCEINLINE inline
sl@0
    30
#endif
sl@0
    31
sl@0
    32
/**
sl@0
    33
Outline colour index used to get percentage of outline colour to be used to get 
sl@0
    34
the final colour from lookup table
sl@0
    35
@internalComponent
sl@0
    36
*/
sl@0
    37
const TInt KOutlineColorIndex = 0;
sl@0
    38
sl@0
    39
/**
sl@0
    40
Shadow colour index used to get percentage of shadow colour to be used to get 
sl@0
    41
the final colour from lookup table
sl@0
    42
@internalComponent
sl@0
    43
*/
sl@0
    44
const TInt KShadowColorIndex = 1;
sl@0
    45
sl@0
    46
/**
sl@0
    47
Fill colour index used to get percentage of fill colour to be used to get 
sl@0
    48
the final colour from lookup table
sl@0
    49
@internalComponent
sl@0
    50
*/
sl@0
    51
const TInt KFillColorIndex = 2;
sl@0
    52
sl@0
    53
/**
sl@0
    54
Background colour index used to get percentage of background colour to be used to get 
sl@0
    55
the final colour from lookup table
sl@0
    56
@internalComponent
sl@0
    57
*/
sl@0
    58
const TInt KBackgroundColorIndex = 3;
sl@0
    59
sl@0
    60
/**
sl@0
    61
Lookup table used for outline and shadow fonts.
sl@0
    62
@internalComponent
sl@0
    63
*/
sl@0
    64
GLREF_D const TInt FourColorBlendLookup[256][4];
sl@0
    65
sl@0
    66
TRgb AlphaBlend(TRgb aPrimary, TRgb aSecondary, TInt aAlphaValue);
sl@0
    67
sl@0
    68
 //Scaling settings. MScalingSettings interface operates with them.
sl@0
    69
struct TScalingSettings
sl@0
    70
	{
sl@0
    71
	inline TScalingSettings() :
sl@0
    72
		iFactorX(1),
sl@0
    73
		iFactorY(1),
sl@0
    74
		iDivisorX(1),
sl@0
    75
		iDivisorY(1)
sl@0
    76
		{
sl@0
    77
		}
sl@0
    78
	TInt iFactorX;
sl@0
    79
	TInt iFactorY;
sl@0
    80
	TInt iDivisorX;
sl@0
    81
	TInt iDivisorY;
sl@0
    82
	};
sl@0
    83
sl@0
    84
 // Drawing device origin. MDrawDeviceOrigin interface operates with it.
sl@0
    85
typedef TPoint TOrigin;
sl@0
    86
sl@0
    87
//This class is used as a template argument by CDrawEightBppBitmapCommon::SetPixels()
sl@0
    88
//and CDrawSixteenBppBitmapCommon::SetPixels()
sl@0
    89
//Each of its methods (EvalInc() and EvalDec()) has two arguments -
sl@0
    90
//aAddr and aValue, and it is used to set *aAddr with aValue and to increment/decrement
sl@0
    91
//respectively aAddr.
sl@0
    92
template <class TPixelType> class TPixelSet
sl@0
    93
	{
sl@0
    94
public:
sl@0
    95
	inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const
sl@0
    96
		{
sl@0
    97
		*aAddr++ = aValue;
sl@0
    98
		}
sl@0
    99
	inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const
sl@0
   100
		{
sl@0
   101
		*aAddr-- = aValue;
sl@0
   102
		}
sl@0
   103
	};
sl@0
   104
sl@0
   105
//This class is used as a template argument by CDrawEightBppBitmapCommon::XORPixels().
sl@0
   106
//and CDrawSixteenBppBitmapCommon::XORPixels()
sl@0
   107
//Each of its methods (EvalInc() and EvalDec()) has two arguments -
sl@0
   108
//aAddr and aValue, and it is used to XOR *aAddr with aValue and to increment/decrement
sl@0
   109
//respectively aAddr.
sl@0
   110
template <class TPixelType> class TPixelXor
sl@0
   111
	{
sl@0
   112
public:
sl@0
   113
	inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const
sl@0
   114
		{
sl@0
   115
		*aAddr++ ^= aValue;
sl@0
   116
		}
sl@0
   117
	inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const
sl@0
   118
		{
sl@0
   119
		*aAddr-- ^= aValue;
sl@0
   120
		}
sl@0
   121
	};
sl@0
   122
sl@0
   123
//This class is used as a template argument by CDrawEightBppBitmapCommon::ANDPixels().
sl@0
   124
//and CDrawSixteenBppBitmapCommon::ANDPixels()
sl@0
   125
//Each of its methods (EvalInc() and EvalDec()) has two arguments -
sl@0
   126
//aAddr and aValue, and it is used to AND *aAddr with aValue and to increment/decrement
sl@0
   127
//respectively aAddr.
sl@0
   128
template <class TPixelType> class TPixelAnd
sl@0
   129
	{
sl@0
   130
public:
sl@0
   131
	inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const
sl@0
   132
		{
sl@0
   133
		*aAddr++ &= aValue;
sl@0
   134
		}
sl@0
   135
	inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const
sl@0
   136
		{
sl@0
   137
		*aAddr-- &= aValue;
sl@0
   138
		}
sl@0
   139
	};
sl@0
   140
sl@0
   141
//This class is used as a template argument by CDrawEightBppBitmapCommon::ORPixels().
sl@0
   142
//and CDrawSixteenBppBitmapCommon::ORPixels()
sl@0
   143
//Each of its methods (EvalInc() and EvalDec()) has two arguments -
sl@0
   144
//aAddr and aValue, and it is used to OR *aAddr with aValue and to increment/decrement
sl@0
   145
//respectively aAddr.
sl@0
   146
template <class TPixelType> class TPixelOr
sl@0
   147
	{
sl@0
   148
public:
sl@0
   149
	inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const
sl@0
   150
		{
sl@0
   151
		*aAddr++ |= aValue;
sl@0
   152
		}
sl@0
   153
	inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const
sl@0
   154
		{
sl@0
   155
		*aAddr-- |= aValue;
sl@0
   156
		}
sl@0
   157
	};
sl@0
   158
sl@0
   159
//This template function should be used every time when a rectangle has to be drawn instead of
sl@0
   160
//a single pixel in EColor256/EColor64K scaled device.
sl@0
   161
//aPixelPtr - points to the pixel memory address, which contains top-left corner of the rectangle.
sl@0
   162
//aValue - the pixel value - EColor256.
sl@0
   163
//aPixelPtrRowLimit - the right end address of the scalline.
sl@0
   164
//aBitsStart - beginning address of the pixel memory.
sl@0
   165
//aBitsEnd - end address of the pixel memory.
sl@0
   166
//aLongWidth - aligned scanline width in pixels.
sl@0
   167
//aFx - X-axis scaling factor.
sl@0
   168
//aFy - Y-axis scaling factor.
sl@0
   169
//aOrientation - device's orientation.
sl@0
   170
//aOp - the operation, which must be applied to every pixel from the rectangle - template parameter.
sl@0
   171
template <class TPixelOp, class TPixelType>
sl@0
   172
inline void FillScaledRect(TPixelType* aPixelPtr,
sl@0
   173
						   const TPixelType aValue,
sl@0
   174
						   const TPixelType* aPixelPtrRowLimit,
sl@0
   175
						   const TPixelType* aBitsStart,
sl@0
   176
						   const TPixelType* aBitsEnd,
sl@0
   177
						   const TInt aLongWidth,
sl@0
   178
						   TInt aFx,
sl@0
   179
						   TInt aFy,
sl@0
   180
						   const CFbsDrawDevice::TOrientation aOrientation,
sl@0
   181
						   const TPixelOp& aOp)
sl@0
   182
	{
sl@0
   183
	if(aOrientation == CFbsDrawDevice::EOrientationNormal)
sl@0
   184
		{
sl@0
   185
		//for example: if aFx = 3 and aFy = 2 then
sl@0
   186
		//the following pixel values have to be evaluated:
sl@0
   187
		// (aPixelPtr), (aPixelPtr + 1),  (aPixelPtr + 2)
sl@0
   188
		// (aPixelPtr + aLongWidth), (aPixelPtr + 1 + aLongWidth), (aPixelPtr + 2 + aLongWidth)
sl@0
   189
		const TPixelType* nextStop = aPixelPtr + aFx;//the address of next scaled pixel value
sl@0
   190
		if(nextStop > aPixelPtrRowLimit)
sl@0
   191
			{//If the address is after the end of the current row, set it to the end of row.
sl@0
   192
			nextStop = aPixelPtrRowLimit;
sl@0
   193
			}
sl@0
   194
		do  //Fill pixel rectangle [aFx,aFy]
sl@0
   195
			{
sl@0
   196
			while(aPixelPtr < nextStop)
sl@0
   197
				{//Fill a row of up to aFx pixels.
sl@0
   198
				aOp.EvalInc(aPixelPtr, aValue);
sl@0
   199
				}
sl@0
   200
			aPixelPtr += (aLongWidth - aFx);//Move aPixelPtr to the next row
sl@0
   201
			if(aPixelPtr >= aBitsEnd)
sl@0
   202
				{//If aPixelPtr points after the end of video memory - stop the operation!
sl@0
   203
				break;
sl@0
   204
				}
sl@0
   205
			nextStop += aLongWidth;//Move nextPixelAddr to the next row
sl@0
   206
			}
sl@0
   207
		while(--aFy);
sl@0
   208
		return;
sl@0
   209
		}
sl@0
   210
	if(aOrientation == CFbsDrawDevice::EOrientationRotated90)
sl@0
   211
		{
sl@0
   212
		//for example: if aFy = 3 and aFx = 2 then
sl@0
   213
		//the following pixel values have to be evaluated:
sl@0
   214
		// (aPixelPtr), (aPixelPtr - 1),
sl@0
   215
		// (aPixelPtr + aLongWidth), (aPixelPtr - 1 + aLongWidth),
sl@0
   216
		// (aPixelPtr + 2 * aLongWidth), (aPixelPtr - 1 + 2 * aLongWidth),
sl@0
   217
		const TPixelType* pixelPtrPrevRowLimit = aPixelPtrRowLimit - aLongWidth;
sl@0
   218
		const TPixelType* nextStop = aPixelPtr - aFx;//the address of next scaled pixel value
sl@0
   219
		if(nextStop < pixelPtrPrevRowLimit)
sl@0
   220
			{//If the address is before the beginning of the current row, set it to the beginning of row.
sl@0
   221
			nextStop = pixelPtrPrevRowLimit;
sl@0
   222
			}
sl@0
   223
		do  //Fill pixel rectangle [aFx,aFy]
sl@0
   224
			{
sl@0
   225
			while(aPixelPtr > nextStop)
sl@0
   226
				{//Fill a row of up to aFy pixels.
sl@0
   227
				aOp.EvalDec(aPixelPtr, aValue);
sl@0
   228
				}
sl@0
   229
			aPixelPtr += (aLongWidth + aFx);//Move aPixelPtr to the next row
sl@0
   230
			if(aPixelPtr >= aBitsEnd)
sl@0
   231
				{//If aPixelPtr points after the end of video memory - stop the operation!
sl@0
   232
				break;
sl@0
   233
				}
sl@0
   234
			nextStop += aLongWidth;//Move nextPixelAddr to the next row
sl@0
   235
			}
sl@0
   236
		while(--aFy);
sl@0
   237
		return;
sl@0
   238
		}
sl@0
   239
	if(aOrientation == CFbsDrawDevice::EOrientationRotated180)
sl@0
   240
		{
sl@0
   241
		//for example: if aFx = 3 and aFy = 2 then
sl@0
   242
		//the following pixel values have to be evaluated:
sl@0
   243
		// (aPixelPtr), (aPixelPtr - 1),  (aPixelPtr - 2)
sl@0
   244
		// (aPixelPtr - aLongWidth), (aPixelPtr + 1 - aLongWidth), (aPixelPtr + 2 - aLongWidth)
sl@0
   245
		const TPixelType* pixelPtrPrevRowLimit = aPixelPtrRowLimit - aLongWidth;
sl@0
   246
		const TPixelType* nextStop = aPixelPtr - aFx;//the address of next scaled pixel value
sl@0
   247
		if(nextStop < pixelPtrPrevRowLimit)
sl@0
   248
			{//If the address is before the beginning of the current row, set it to the beginning of row.
sl@0
   249
			nextStop = pixelPtrPrevRowLimit;
sl@0
   250
			}
sl@0
   251
		do  //Fill pixel rectangle [aFx,aFy]
sl@0
   252
			{
sl@0
   253
			while(aPixelPtr > nextStop)
sl@0
   254
				{//Fill a row of up to aFx pixels.
sl@0
   255
				aOp.EvalDec(aPixelPtr, aValue);
sl@0
   256
				}
sl@0
   257
			aPixelPtr -= (aLongWidth - aFx);//Move aPixelPtr to the prev row
sl@0
   258
			if(aPixelPtr < aBitsStart)
sl@0
   259
				{//If aPixelPtr points before the beginning of video memory - stop the operation!
sl@0
   260
				break;
sl@0
   261
				}
sl@0
   262
			nextStop -= aLongWidth;//Move nextPixelAddr to the prev row
sl@0
   263
			}
sl@0
   264
		while(--aFy);
sl@0
   265
		return;
sl@0
   266
		}
sl@0
   267
	else //if(aOrientation == CFbsDrawDevice::EOrientationRotated270)
sl@0
   268
		{
sl@0
   269
		//for example: if aFy = 3 and aFx = 2 then
sl@0
   270
		//the following pixel values have to be evaluated:
sl@0
   271
		// (aPixelPtr), (aPixelPtr + 1)
sl@0
   272
		// (aPixelPtr - aLongWidth), (aPixelPtr + 1 - aLongWidth)
sl@0
   273
		// (aPixelPtr - 2 * aLongWidth), (aPixelPtr + 1 - 2 * aLongWidth)
sl@0
   274
		const TPixelType* nextStop = aPixelPtr + aFx;//the address of next scaled pixel value
sl@0
   275
		if(nextStop > aPixelPtrRowLimit)
sl@0
   276
			{//If the address is after the end of the current row, set it to the end of row.
sl@0
   277
			nextStop = aPixelPtrRowLimit;
sl@0
   278
			}
sl@0
   279
		do  //Fill pixel rectangle [aFx,aFy]
sl@0
   280
			{
sl@0
   281
			while(aPixelPtr < nextStop)
sl@0
   282
				{//Fill a row of up to aFy pixels.
sl@0
   283
				aOp.EvalInc(aPixelPtr, aValue);
sl@0
   284
				}
sl@0
   285
			aPixelPtr += (-aLongWidth - aFx);//Move aPixelPtr to the prev row
sl@0
   286
			if(aPixelPtr < aBitsStart)
sl@0
   287
				{//If aPixelPtr points befor the beginning of video memory - stop the operation!
sl@0
   288
				break;
sl@0
   289
				}
sl@0
   290
			nextStop -= aLongWidth;//Move nextPixelAddr to the prev row
sl@0
   291
			}
sl@0
   292
		while(--aFy);
sl@0
   293
		return;
sl@0
   294
		}
sl@0
   295
	}
sl@0
   296
sl@0
   297
/**
sl@0
   298
@publishedPartner
sl@0
   299
*/
sl@0
   300
NONSHARABLE_CLASS(CDrawBitmap) : public CFbsDrawDevice,
sl@0
   301
                                 public MScalingSettings,
sl@0
   302
                                 public MDrawDeviceOrigin,
sl@0
   303
                                 public MAlphaBlend,
sl@0
   304
                                 public MOutlineAndShadowBlend,
sl@0
   305
                                 public MDrawDeviceOrientation,
sl@0
   306
								 public MFastBlend
sl@0
   307
	{
sl@0
   308
public:
sl@0
   309
	virtual ~CDrawBitmap();
sl@0
   310
	// From CFbsDrawDevice
sl@0
   311
	virtual TDisplayMode DisplayMode() const { return iDispMode; }
sl@0
   312
	virtual TInt LongWidth() const;
sl@0
   313
	virtual void MapColors(const TRect& aRect,const TRgb* aColors,TInt aNumPairs,TBool aMapForwards);
sl@0
   314
	virtual TRgb ReadPixel(TInt aX,TInt aY) const;
sl@0
   315
	virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer,TDisplayMode aDispMode) const;
sl@0
   316
	virtual TUint32* ScanLineBuffer() const;
sl@0
   317
	virtual TInt ScanLineBytes() const;
sl@0
   318
	virtual TDisplayMode ScanLineDisplayMode() const { return iDispMode; }
sl@0
   319
	virtual TSize SizeInPixels() const;
sl@0
   320
	virtual TInt HorzTwipsPerThousandPixels() const { return 0; }
sl@0
   321
	virtual TInt VertTwipsPerThousandPixels() const { return 0; }
sl@0
   322
	virtual void OrientationsAvailable(TBool aOrientation[4]);
sl@0
   323
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   324
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   325
	virtual void WriteBinaryLine(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   326
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode,TBool aUp);
sl@0
   327
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer ,CGraphicsContext::TDrawMode);
sl@0
   328
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode);
sl@0
   329
	virtual void SetBits(TAny* aBits);
sl@0
   330
	virtual void SetDitherOrigin(const TPoint& aPoint);
sl@0
   331
	virtual void SetShadowMode(TShadowMode aShadowMode) { iShadowMode = aShadowMode; }
sl@0
   332
	virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap);
sl@0
   333
	virtual void SetUserDisplayMode(TDisplayMode aDisplayMode) { iUserDispMode = aDisplayMode; }
sl@0
   334
	virtual TBool SetOrientation(TOrientation aOrientation);
sl@0
   335
	virtual void WriteRgbAlphaLine(TInt aX,TInt aY,TInt aLength,
sl@0
   336
                                   TUint8* aRgbBuffer, TUint8* aMaskBuffer,
sl@0
   337
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   338
	virtual void WriteRgbAlphaLine(TInt aX,TInt aY,TInt aLength,
sl@0
   339
								const TUint8* aRgbBuffer1,
sl@0
   340
								const TUint8* aBuffer2,
sl@0
   341
								const TUint8* aMaskBuffer,
sl@0
   342
								CGraphicsContext::TDrawMode aDrawMode);
sl@0
   343
	virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
sl@0
   344
	virtual void GetDrawRect(TRect& aDrawRect) const;
sl@0
   345
	virtual void SwapWidthAndHeight();
sl@0
   346
	// From MScalingSettings
sl@0
   347
	virtual TInt Set(TInt aFactorX, TInt aFactorY, TInt aDivisorX, TInt aDivisorY);
sl@0
   348
	virtual void Get(TInt& aFactorX, TInt& aFactorY, TInt& aDivisorX, TInt& aDivisorY);
sl@0
   349
	virtual TBool IsScalingOff();
sl@0
   350
	// From MDrawDeviceOrigin
sl@0
   351
	virtual TInt Set(const TPoint& aOrigin);
sl@0
   352
	virtual void Get(TPoint& aOrigin);
sl@0
   353
	// From MDrawDeviceOrientation
sl@0
   354
	virtual CFbsDrawDevice::TOrientation Orientation();	
sl@0
   355
	// From MFastBlend
sl@0
   356
	virtual TInt FastBlendBitmap(const TPoint& aDest,CFbsDrawDevice* aSrcDrawDevice, const TRect& aSrcRect, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode);
sl@0
   357
	virtual TInt FastBlendBitmap(const TPoint& aDest,const TUint32* aSrcBase, TInt aSrcStride, const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode);
sl@0
   358
	virtual TInt FastBlendBitmapMasked(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride,
sl@0
   359
							const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aSrcDisplayMode,
sl@0
   360
							const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,const TPoint &aMaskSrcPos,TBool aInvertMask,
sl@0
   361
							CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode);
sl@0
   362
	virtual TInt FastBlendBitmapScaled(const TRect &aClipRect, const TRect& aDest, const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcLinePitch, TDisplayMode aSrcDisplayMode, const TSize &aSrcSize, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode);
sl@0
   363
	virtual TInt FastBlendBitmapMaskedScaled(const TRect &aClipRect, const TRect& aDest,
sl@0
   364
							const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcLinePitch,
sl@0
   365
							TDisplayMode aSrcDisplayMode, const TSize &aSrcSize,
sl@0
   366
							const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,TBool aInvertMask,
sl@0
   367
							CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode);
sl@0
   368
protected:
sl@0
   369
	CDrawBitmap();
sl@0
   370
	static TInt BitsPerPixel(TDisplayMode aDispMode);
sl@0
   371
	void Clear();
sl@0
   372
	void CopyOldSettings(CFbsDrawDevice* aDrawDevice);
sl@0
   373
	void DeOrientate(TInt& aX,TInt& aY) const;
sl@0
   374
	TPoint DeOrientate(const TPoint& aPoint) const;
sl@0
   375
	TRect DeOrientate(const TRect& aRect) const;
sl@0
   376
	virtual void Shadow(TRgb& aColor) = 0;
sl@0
   377
	TRgb FadeRgb(TRgb aColor);
sl@0
   378
	TUint32 FadeRgb(TUint32 aColor);
sl@0
   379
	void FadeRgb(TInt& aRed, TInt& aGreen, TInt& aBlue);
sl@0
   380
	TUint8 FadeGray(TInt aGray256);
sl@0
   381
	TUint32 Hash(TUint32 aValue,TInt aX,TInt aY) const;
sl@0
   382
	TUint32 PasteInt(TUint32 aFirst,TUint32 aSecond,TInt aOffset) const;
sl@0
   383
	static TAny* CopyOffset(TAny* aDestination,const TAny* aSource,TInt aWordsToCopy,TInt aSourceBitOffset);
sl@0
   384
	static void ReadLineCommon(TUint32* aPixelPtr,TUint32* aBufferPtr,TInt aWordsCnt,TInt aRestPixels,TInt aBytesCnt,TInt aStartDiffBits);
sl@0
   385
	virtual void SetSize(const TSize& aSize);
sl@0
   386
	// Scaling related
sl@0
   387
	TBool CanBeScaled() const;
sl@0
   388
	TInt PixelAddressIncrement() const;
sl@0
   389
	TInt LogicalPixelAddressIncrement() const;
sl@0
   390
	void SetPixelInc(TInt& aPixelInc, TInt& aRowInc) const;
sl@0
   391
	void IncScaledY(TInt& aY) const;
sl@0
   392
	void IncScaledY(TInt& aY, TInt aYOrg) const;
sl@0
   393
	//Generic set pixels operations, has to be defined here to make it compiled in VC++6.0
sl@0
   394
	template <class TPixelType>
sl@0
   395
	void SetPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit,
sl@0
   396
				   const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const
sl@0
   397
		{
sl@0
   398
		TPixelSet<TPixelType> op;
sl@0
   399
		::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth,
sl@0
   400
						 iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op);
sl@0
   401
		}
sl@0
   402
	template <class TPixelType>
sl@0
   403
	void XORPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit,
sl@0
   404
				   const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const
sl@0
   405
		{
sl@0
   406
		TPixelXor<TPixelType> op;
sl@0
   407
		::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth,
sl@0
   408
						 iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op);
sl@0
   409
		}
sl@0
   410
	template <class TPixelType>
sl@0
   411
	void ANDPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit,
sl@0
   412
				   const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const
sl@0
   413
		{
sl@0
   414
		TPixelAnd<TPixelType> op;
sl@0
   415
		::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth,
sl@0
   416
						 iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op);
sl@0
   417
		}
sl@0
   418
	template <class TPixelType>
sl@0
   419
	void ORPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit,
sl@0
   420
				  const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const
sl@0
   421
		{
sl@0
   422
		TPixelOr<TPixelType> op;
sl@0
   423
		::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth,
sl@0
   424
						 iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op);
sl@0
   425
		}
sl@0
   426
	//Origin related
sl@0
   427
	TBool CanOriginBeMoved() const;
sl@0
   428
	void MapColorToUserDisplayMode(TInt& red,TInt& green,TInt& blue);
sl@0
   429
protected:
sl@0
   430
	virtual void InvertBuffer(TInt aLength,TUint32* aBuffer) = 0;
sl@0
   431
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const = 0;
sl@0
   432
	virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const = 0;
sl@0
   433
	virtual TUint32* ScanLine(TInt aY) const;
sl@0
   434
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0;
sl@0
   435
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0;
sl@0
   436
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0;
sl@0
   437
	virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0;
sl@0
   438
	virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0;
sl@0
   439
	virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0;
sl@0
   440
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor) = 0;
sl@0
   441
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor) = 0;
sl@0
   442
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode) = 0;
sl@0
   443
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp) = 0;
sl@0
   444
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0;
sl@0
   445
	virtual void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   446
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0;
sl@0
   447
	virtual void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   448
	virtual void MapColorToUserDisplayMode(TRgb& /*aColor*/) {}
sl@0
   449
	virtual void MapBufferToUserDisplayMode(TInt /*aLength*/,TUint32* /*aBuffer*/) {}
sl@0
   450
private:
sl@0
   451
	void GetBlendPosAndRect(TRect &aSrcRect, const TRect &aSrcRectIn, const TSize &aSrcSize, const TPoint &aDestOffset);
sl@0
   452
	void GetBlendPosAndRect(TRect &aDstRect, TRect &aSrcRect, const TRect &aDestRectIn, const TRect &aSrcRectIn, const TSize &aSrcSize);
sl@0
   453
	TBool FastBlendSupported(TDisplayMode aSrcDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode, TInt aSrcLinePitch);
sl@0
   454
	TBool FastBlendMaskSupported(TDisplayMode aMaskDisplayMode, TInt aMaskStride);
sl@0
   455
	void DoCopyOldSettings(CFbsDrawDevice* aDrawDevice);
sl@0
   456
	TInt DoFastBlendBitmap(const TPoint &aDest, const TRect& aSrcRect, const TUint8 *aSrcBase, TInt aSrcLinePitch, TDisplayMode aSrcDisplayMode, const TSize &aSrcSize);
sl@0
   457
	// Scaling related
sl@0
   458
	void InitLogicalCoordinates();
sl@0
   459
	void PreWriteRgb(TInt& aWidth, TInt& aHeight, TInt& aX, TInt& aY, CGraphicsContext::TDrawMode aDrawMode);
sl@0
   460
	void WriteRgb(TInt& aWidth, TInt& aHeight, TInt& aX, TInt& aY, TRgb aColor, CGraphicsContext::TDrawMode aDrawMode);
sl@0
   461
	void SetDefaults();
sl@0
   462
	inline TInt Origin(TInt aPhysOrg, TInt aScale) const;
sl@0
   463
	inline TInt OtherSide(TInt aPhysOrg, TInt aPhysSize, TInt aScale) const;
sl@0
   464
protected:
sl@0
   465
	TDisplayMode iDispMode;
sl@0
   466
	TInt iLongWidth; // aligned scanline width in pixels
sl@0
   467
	TPoint iDitherOrigin;
sl@0
   468
	TUint32* iScanLineBuffer;
sl@0
   469
	TInt iScanLineWords;
sl@0
   470
	TShadowMode iShadowMode;
sl@0
   471
	TSize iSize; // (0, 0, iSize.iWidth, iSize.iHeight) - drawing rectangle - physical coordinates
sl@0
   472
	TUint32* iBits;
sl@0
   473
	TDisplayMode iUserDispMode;
sl@0
   474
	TOrientation iOrientation; // 0, 90, 180, 270 degrees
sl@0
   475
	TInt iFadeMapFactor;
sl@0
   476
	TInt iFadeMapOffset;
sl@0
   477
	TScalingSettings iScalingSettings; // X-axis and Y-axis scaling factors
sl@0
   478
	TOrigin iOrigin; // drawing device origin
sl@0
   479
	TBool iScalingOff; // ETrue, if the scaling is off.
sl@0
   480
	TBool iOriginIsZero; // ETrue, if the origin is (0, 0).
sl@0
   481
	TRect iDrawRect; // drawing rectangle - logical coordinates
sl@0
   482
    MAlphaBlend* iAlphaBlend; // Alphablending interface
sl@0
   483
	};
sl@0
   484
sl@0
   485
/**
sl@0
   486
@publishedPartner
sl@0
   487
*/
sl@0
   488
NONSHARABLE_CLASS(CDrawOneBppBitmap) : public CDrawBitmap
sl@0
   489
	{
sl@0
   490
public:
sl@0
   491
	TInt Construct(TSize aSize);
sl@0
   492
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   493
	virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   494
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
   495
	virtual void ShadowArea(const TRect& aRect);
sl@0
   496
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   497
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   498
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   499
	virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   500
	virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   501
	virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   502
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
   503
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   504
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   505
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
   506
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   507
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   508
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
   509
protected:
sl@0
   510
	virtual void SetSize(const TSize& aSize);
sl@0
   511
	virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
sl@0
   512
	virtual void Shadow(TRgb& aColor);
sl@0
   513
	void ShadowBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   514
private:
sl@0
   515
	TUint32 ColorWord(TRgb aColor) const;
sl@0
   516
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
   517
                                   TInt aY,
sl@0
   518
                                   TInt aLength,
sl@0
   519
                                   const TUint8* aRgbBuffer,
sl@0
   520
                                   const TUint8* aMaskBuffer,
sl@0
   521
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
   522
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   523
	// From MOutlineAndShadowBlend
sl@0
   524
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
   525
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
   526
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
   527
	};
sl@0
   528
sl@0
   529
/**
sl@0
   530
@publishedPartner
sl@0
   531
*/
sl@0
   532
NONSHARABLE_CLASS(CDrawTwoBppBitmap) : public CDrawBitmap
sl@0
   533
	{
sl@0
   534
public:
sl@0
   535
	TInt Construct(TSize aSize);
sl@0
   536
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   537
	TUint32 ColorInt(TRgb aColor) const;
sl@0
   538
	void HashInt(TUint32& aInt1,TUint32& aInt2,TRgb aColor,TInt aX,TInt aY) const;
sl@0
   539
	virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   540
	void MapColors(const TRect& aRect,const TRgb* aColors,TInt aNumPairs,TBool aMapForwards);
sl@0
   541
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
   542
	virtual void ShadowArea(const TRect& aRect);
sl@0
   543
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   544
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   545
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   546
	virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   547
	virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   548
	virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   549
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
   550
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   551
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   552
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
   553
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   554
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   555
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
   556
	virtual void MapColorToUserDisplayMode(TRgb& aColor);
sl@0
   557
	virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
   558
protected:
sl@0
   559
	virtual void SetSize(const TSize& aSize);
sl@0
   560
	TUint32 MapInt(TUint32 aInt,TUint32* aColorMap) const;
sl@0
   561
	virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
sl@0
   562
	virtual void Shadow(TRgb& aColor);
sl@0
   563
	TUint32 ShadowWord(TUint32 aWord);
sl@0
   564
	TUint32 FadeWord(TUint32 aWord);
sl@0
   565
	void ShadeBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   566
	void ShadowBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   567
private:
sl@0
   568
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
   569
                                   TInt aY,
sl@0
   570
                                   TInt aLength,
sl@0
   571
                                   const TUint8* aRgbBuffer,
sl@0
   572
                                   const TUint8* aMaskBuffer,
sl@0
   573
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
   574
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   575
	// From MOutlineAndShadowBlend
sl@0
   576
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
   577
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
   578
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
   579
	};
sl@0
   580
sl@0
   581
/**
sl@0
   582
@publishedPartner
sl@0
   583
*/
sl@0
   584
NONSHARABLE_CLASS(CDrawFourBppBitmapGray) : public CDrawBitmap
sl@0
   585
	{
sl@0
   586
public:
sl@0
   587
	TInt Construct(TSize aSize);
sl@0
   588
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   589
	TUint32 ColorInt(TRgb aColor) const;
sl@0
   590
	TUint32 HashInt(TRgb aColor,TInt aX,TInt aY) const;
sl@0
   591
	virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   592
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
   593
	virtual void ShadowArea(const TRect& aRect);
sl@0
   594
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   595
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   596
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   597
	virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   598
	virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   599
	virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   600
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
   601
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   602
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   603
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
   604
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   605
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   606
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
   607
	virtual void MapColorToUserDisplayMode(TRgb& aColor);
sl@0
   608
	virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
   609
protected:
sl@0
   610
	virtual void SetSize(const TSize& aSize);
sl@0
   611
	void DitherBuffer(TInt x,TInt y,TInt aLength,TUint32* aBuffer);
sl@0
   612
	virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
sl@0
   613
	virtual void Shadow(TRgb& aColor);
sl@0
   614
	TUint8 ShadowAndFadeGray16(TInt aGray16);
sl@0
   615
	TUint32 FadeWord(TUint32 aWord);
sl@0
   616
	void ShadeBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   617
	void ShadowBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   618
private:
sl@0
   619
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
   620
                                   TInt aY,
sl@0
   621
                                   TInt aLength,
sl@0
   622
                                   const TUint8* aRgbBuffer,
sl@0
   623
                                   const TUint8* aMaskBuffer,
sl@0
   624
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
   625
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   626
	// From MOutlineAndShadowBlend
sl@0
   627
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
   628
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
   629
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
   630
	TRgb BlendFourColors(TUint32 aOutlinePenColor, TUint32 aShadowColor, TUint32 aFillColor,
sl@0
   631
						TInt aRedOutlinePenColor,TInt aRedShadowColor,TInt aRedFillColor,
sl@0
   632
						TInt aGreenOutlinePenColor, TInt aGreenShadowColor, TInt aGreenFillColor,
sl@0
   633
						TInt aBlueOutlinePenColor, TInt aBlueShadowColor, TInt aBlueFillColor,
sl@0
   634
						TRgb aBackgroundColor, TUint8 aIndex) const;
sl@0
   635
	};
sl@0
   636
sl@0
   637
/**
sl@0
   638
@publishedPartner
sl@0
   639
*/
sl@0
   640
NONSHARABLE_CLASS(CDrawFourBppBitmapColor) : public CDrawBitmap
sl@0
   641
	{
sl@0
   642
public:
sl@0
   643
	TInt Construct(TSize aSize);
sl@0
   644
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   645
	TUint32 ColorInt(TRgb aColor) const;
sl@0
   646
	virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   647
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
   648
	virtual void ShadowArea(const TRect& aRect);
sl@0
   649
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   650
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   651
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   652
	virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   653
	virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   654
	virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   655
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
   656
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   657
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   658
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
   659
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   660
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   661
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
   662
	virtual void MapColorToUserDisplayMode(TRgb& aColor);
sl@0
   663
	virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
   664
protected:
sl@0
   665
	virtual void SetSize(const TSize& aSize);
sl@0
   666
	virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
sl@0
   667
	virtual void Shadow(TRgb& aColor);
sl@0
   668
	TUint32 ShadowWord(TUint32 aWord);
sl@0
   669
	TUint32 FadeWord(TUint32 aWord);
sl@0
   670
	void ShadowBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   671
private:
sl@0
   672
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
   673
                                   TInt aY,
sl@0
   674
                                   TInt aLength,
sl@0
   675
                                   const TUint8* aRgbBuffer,
sl@0
   676
                                   const TUint8* aMaskBuffer,
sl@0
   677
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
   678
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   679
	// From MOutlineAndShadowBlend
sl@0
   680
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
   681
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
   682
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
   683
	TRgb BlendFourColors(TUint32 aOutlinePenColor, TUint32 aShadowColor, TUint32 aFillColor,
sl@0
   684
						TInt aRedOutlinePenColor,TInt aRedShadowColor,TInt aRedFillColor,
sl@0
   685
						TInt aGreenOutlinePenColor, TInt aGreenShadowColor, TInt aGreenFillColor,
sl@0
   686
						TInt aBlueOutlinePenColor, TInt aBlueShadowColor, TInt aBlueFillColor,
sl@0
   687
						TRgb aBackgroundColor, TUint8 aIndex) const;
sl@0
   688
	};
sl@0
   689
sl@0
   690
const TInt KInvalidValue = 0xABCDABCD;
sl@0
   691
sl@0
   692
/**
sl@0
   693
@publishedPartner
sl@0
   694
*/
sl@0
   695
NONSHARABLE_CLASS(CDrawEightBppBitmapCommon) : public CDrawBitmap, public MFastBlit2
sl@0
   696
	{
sl@0
   697
public:
sl@0
   698
	virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   699
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   700
	virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   701
	virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   702
	virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   703
	virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);	
sl@0
   704
	// From MFastBlit2
sl@0
   705
	virtual TInt WriteBitmapBlock(const TPoint& aDest,
sl@0
   706
									CFbsDrawDevice* aSrcDrawDevice,
sl@0
   707
									const TRect& aSrcRect);
sl@0
   708
	virtual TInt WriteBitmapBlock(const TPoint& aDest,
sl@0
   709
									const TUint32* aSrcBase,
sl@0
   710
									TInt aSrcStride,
sl@0
   711
									const TSize& aSrcSize,
sl@0
   712
									const TRect& aSrcRect);
sl@0
   713
	virtual const TUint32* Bits() const;
sl@0
   714
protected:
sl@0
   715
	virtual void SetSize(const TSize& aSize);
sl@0
   716
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   717
	TUint8* PixelAddress(TInt aX,TInt aY) const;
sl@0
   718
	void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
sl@0
   719
	void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint8 aPixel);
sl@0
   720
	void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint8 aPixel,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   721
	void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TUint8 aPixel,TBool aUp);
sl@0
   722
	void WriteRgb(TInt aX,TInt aY,TUint8 aPixel);
sl@0
   723
	void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel);
sl@0
   724
	void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel);
sl@0
   725
	void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel);
sl@0
   726
	void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel);
sl@0
   727
	};
sl@0
   728
sl@0
   729
/**
sl@0
   730
@publishedPartner
sl@0
   731
*/
sl@0
   732
NONSHARABLE_CLASS(CDrawEightBppBitmapGray) : public CDrawEightBppBitmapCommon
sl@0
   733
	{
sl@0
   734
public:
sl@0
   735
	TInt Construct(TSize aSize);
sl@0
   736
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   737
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
   738
	virtual void ShadowArea(const TRect& aRect);
sl@0
   739
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   740
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   741
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   742
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   743
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
   744
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   745
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   746
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
   747
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
   748
	virtual void MapColorToUserDisplayMode(TRgb& aColor);
sl@0
   749
	virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
   750
protected:
sl@0
   751
	virtual void Shadow(TRgb& aColor);
sl@0
   752
	void ShadowBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   753
	TUint8 ShadowAndFade(TInt aGray256);
sl@0
   754
private:
sl@0
   755
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
   756
                                   TInt aY,
sl@0
   757
                                   TInt aLength,
sl@0
   758
                                   const TUint8* aRgbBuffer,
sl@0
   759
                                   const TUint8* aMaskBuffer,
sl@0
   760
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
   761
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   762
	// From MOutlineAndShadowBlend
sl@0
   763
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
   764
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
   765
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
   766
	};
sl@0
   767
sl@0
   768
/**
sl@0
   769
@publishedPartner
sl@0
   770
*/
sl@0
   771
NONSHARABLE_CLASS(CDrawEightBppBitmapColor) : public CDrawEightBppBitmapCommon
sl@0
   772
	{
sl@0
   773
public:
sl@0
   774
	~CDrawEightBppBitmapColor();
sl@0
   775
	TInt Construct(TSize aSize);
sl@0
   776
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   777
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
   778
	virtual TInt SetCustomPalette(const CPalette* aPalette);
sl@0
   779
	virtual TInt GetCustomPalette(CPalette*& aPalette);
sl@0
   780
	virtual void ShadowArea(const TRect& aRect);
sl@0
   781
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   782
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   783
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   784
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   785
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
   786
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   787
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   788
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
   789
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
   790
	virtual void MapColorToUserDisplayMode(TRgb& aColor);
sl@0
   791
	virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
   792
	// From MOutlineAndShadowBlend
sl@0
   793
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
   794
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
   795
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
   796
protected:
sl@0
   797
	TUint8 ColorToIndex(TRgb aColor) const;
sl@0
   798
	TRgb IndexToColor(TInt aIndex) const;
sl@0
   799
	virtual void Shadow(TRgb& aColor);
sl@0
   800
	void ShadowBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   801
private:
sl@0
   802
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
   803
                                   TInt aY,
sl@0
   804
                                   TInt aLength,
sl@0
   805
                                   const TUint8* aRgbBuffer,
sl@0
   806
                                   const TUint8* aMaskBuffer,
sl@0
   807
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
   808
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   809
protected:
sl@0
   810
	TRgb* iPalette;
sl@0
   811
	TUint8* iColor4KIndex;
sl@0
   812
	TUint8* iShadowIndex;
sl@0
   813
	};
sl@0
   814
sl@0
   815
/**
sl@0
   816
@publishedPartner
sl@0
   817
*/
sl@0
   818
NONSHARABLE_CLASS(CDrawSixteenBppBitmapCommon) : public CDrawBitmap, public MFastBlit2
sl@0
   819
	{
sl@0
   820
public:
sl@0
   821
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   822
	virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   823
	virtual void ShadowArea(const TRect& aRect);
sl@0
   824
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor);
sl@0
   825
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor);
sl@0
   826
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor);
sl@0
   827
	virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   828
	virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   829
	virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   830
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint16 aColor);
sl@0
   831
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint16 aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   832
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TUint16 aColor,TBool aUp);
sl@0
   833
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor);
sl@0
   834
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   835
	virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
sl@0
   836
	// From MFastBlit2
sl@0
   837
	virtual TInt WriteBitmapBlock(const TPoint& aDest,
sl@0
   838
									CFbsDrawDevice* aSrcDrawDevice,
sl@0
   839
									const TRect& aSrcRect);
sl@0
   840
	virtual TInt WriteBitmapBlock(const TPoint& aDest,
sl@0
   841
									const TUint32* aSrcBase,
sl@0
   842
									TInt aSrcStride,
sl@0
   843
									const TSize& aSrcSize,
sl@0
   844
									const TRect& aSrcRect);
sl@0
   845
	virtual const TUint32* Bits() const;
sl@0
   846
protected:
sl@0
   847
	virtual void SetSize(const TSize& aSize);
sl@0
   848
	TUint16* PixelAddress(TInt aX,TInt aY) const;
sl@0
   849
	virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
sl@0
   850
	virtual TUint16 ShadowIndex(TUint16 aColor64KIndex) = 0;
sl@0
   851
	virtual TUint16 FadeIndex(TUint16 aColor4KIndex) = 0;
sl@0
   852
	void ShadowBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   853
	};
sl@0
   854
sl@0
   855
/**
sl@0
   856
@publishedPartner
sl@0
   857
*/
sl@0
   858
NONSHARABLE_CLASS(CDrawTwelveBppBitmap) : public CDrawSixteenBppBitmapCommon
sl@0
   859
	{
sl@0
   860
public:
sl@0
   861
	TInt Construct(TSize aSize);
sl@0
   862
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   863
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
   864
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   865
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   866
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   867
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
   868
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   869
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   870
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
   871
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   872
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
   873
	virtual void MapColorToUserDisplayMode(TRgb& aColor);
sl@0
   874
	virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
   875
	// From MOutlineAndShadowBlend
sl@0
   876
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
   877
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
   878
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
   879
protected:
sl@0
   880
	virtual void Shadow(TRgb& aColor);
sl@0
   881
	virtual TUint16 ShadowIndex(TUint16 aColor4KIndex);
sl@0
   882
	virtual TUint16 FadeIndex(TUint16 aColor4KIndex);
sl@0
   883
private:
sl@0
   884
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
   885
                                   TInt aY,
sl@0
   886
                                   TInt aLength,
sl@0
   887
                                   const TUint8* aRgbBuffer,
sl@0
   888
                                   const TUint8* aMaskBuffer,
sl@0
   889
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
   890
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   891
	};
sl@0
   892
sl@0
   893
/**
sl@0
   894
@publishedPartner
sl@0
   895
*/
sl@0
   896
NONSHARABLE_CLASS(CDrawSixteenBppBitmap) : public CDrawSixteenBppBitmapCommon
sl@0
   897
	{
sl@0
   898
public:
sl@0
   899
	TInt Construct(TSize aSize);
sl@0
   900
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   901
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
   902
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   903
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   904
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   905
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
   906
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   907
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   908
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
   909
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   910
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
   911
	virtual void MapColorToUserDisplayMode(TRgb& aColor);
sl@0
   912
	FORCEINLINE void MapColorToUserDisplayMode(TUint16& aColor64K);
sl@0
   913
	virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
   914
	virtual void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
   915
	// From MOutlineAndShadowBlend
sl@0
   916
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
   917
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
   918
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
   919
protected:
sl@0
   920
	virtual void Shadow(TRgb& aColor);
sl@0
   921
	FORCEINLINE void Shadow(TInt& aRed, TInt& aGreen, TInt& aBlue);
sl@0
   922
	FORCEINLINE void Shadow(TUint16& a64KColor);
sl@0
   923
	virtual TUint16 ShadowIndex(TUint16 aColor64KIndex);
sl@0
   924
	FORCEINLINE void ShadowIndex(TInt& aRed, TInt& aGreen, TInt& aBlue);
sl@0
   925
	virtual TUint16 FadeIndex(TUint16 aColor64KIndex);
sl@0
   926
private:
sl@0
   927
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
   928
                                   TInt aY,
sl@0
   929
                                   TInt aLength,
sl@0
   930
                                   const TUint8* aRgbBuffer,
sl@0
   931
                                   const TUint8* aMaskBuffer,
sl@0
   932
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
   933
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   934
	};
sl@0
   935
sl@0
   936
/**
sl@0
   937
@publishedPartner
sl@0
   938
*/
sl@0
   939
NONSHARABLE_CLASS(CDrawTwentyFourBppBitmap) : public CDrawBitmap
sl@0
   940
	{
sl@0
   941
public:
sl@0
   942
	TInt Construct(TSize aSize);
sl@0
   943
	TInt Construct(TSize aSize, TInt aStride);
sl@0
   944
	virtual void Shadow(TRgb& aColor);
sl@0
   945
	virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   946
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
   947
	virtual void ShadowArea(const TRect& aRect);
sl@0
   948
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
   949
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   950
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
   951
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
   952
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   953
	virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   954
	virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   955
	virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
   956
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   957
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   958
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   959
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   960
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
   961
	virtual void MapColorToUserDisplayMode(TRgb& aColor);
sl@0
   962
	virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
   963
	// From MOutlineAndShadowBlend
sl@0
   964
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
   965
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
   966
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
   967
	void BlendRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
   968
protected:
sl@0
   969
	virtual void SetSize(const TSize& aSize);
sl@0
   970
	TUint8* PixelAddress(TInt aX,TInt aY) const;
sl@0
   971
	TInt PixelAddressIncrement() const;
sl@0
   972
	void PixelAddressIncrement(TInt& aPixelInc,TInt& aRowInc) const;
sl@0
   973
	void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
sl@0
   974
	void ShadowBuffer(TInt aLength,TUint32* aBuffer);
sl@0
   975
	TUint8 ShadowComponent(TInt aRgbComponent);
sl@0
   976
	TUint8 FadeComponent(TInt aRgbComponent);
sl@0
   977
	TUint8 ShadowAndFade(TInt aComponent);
sl@0
   978
private:
sl@0
   979
	FORCEINLINE void FadeRgb(TInt& red,TInt& green,TInt& blue);
sl@0
   980
	FORCEINLINE void Shadow(TInt& red,TInt& green,TInt& blue);
sl@0
   981
	FORCEINLINE TUint8 ShadowComponentInl(TInt aRgbComponent);
sl@0
   982
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
   983
                                   TInt aY,
sl@0
   984
                                   TInt aLength,
sl@0
   985
                                   const TUint8* aRgbBuffer,
sl@0
   986
                                   const TUint8* aMaskBuffer,
sl@0
   987
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
   988
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
   989
protected:
sl@0
   990
	TInt iScanLineBytes;
sl@0
   991
	};
sl@0
   992
sl@0
   993
inline TUint8* CDrawTwentyFourBppBitmap::PixelAddress(TInt aX,TInt aY) const
sl@0
   994
	{
sl@0
   995
	return ((TUint8*)iBits) + (aY * iScanLineBytes) + (aX * 3);
sl@0
   996
	}
sl@0
   997
sl@0
   998
/**
sl@0
   999
@publishedPartner
sl@0
  1000
*/
sl@0
  1001
NONSHARABLE_CLASS(CDrawThirtyTwoBppBitmapCommon) : public CDrawBitmap, public MFastBlit2
sl@0
  1002
	{
sl@0
  1003
public:
sl@0
  1004
	TInt Construct(TSize aSize, TInt aStride);
sl@0
  1005
	virtual void Shadow(TRgb& aColor);
sl@0
  1006
	virtual void Shadow(TUint32& aColor);
sl@0
  1007
	virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
sl@0
  1008
	virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
sl@0
  1009
	virtual void ShadowArea(const TRect& aRect);
sl@0
  1010
	virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
  1011
	virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
  1012
	virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
sl@0
  1013
	virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
  1014
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
  1015
	virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
  1016
	virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
  1017
	virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
  1018
	virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
  1019
	virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
  1020
	virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
  1021
	virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
  1022
	virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
  1023
	virtual void MapColorToUserDisplayMode(TRgb& aColor);
sl@0
  1024
	virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
  1025
	virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
sl@0
  1026
	// From MFastBlit2
sl@0
  1027
	virtual TInt WriteBitmapBlock(const TPoint& aDest,
sl@0
  1028
									CFbsDrawDevice* aSrcDrawDevice,
sl@0
  1029
									const TRect& aSrcRect);
sl@0
  1030
	virtual TInt WriteBitmapBlock(const TPoint& aDest,
sl@0
  1031
									const TUint32* aSrcBase,
sl@0
  1032
									TInt aSrcStride,
sl@0
  1033
									const TSize& aSrcSize,
sl@0
  1034
									const TRect& aSrcRect);
sl@0
  1035
	virtual const TUint32* Bits() const;
sl@0
  1036
protected:
sl@0
  1037
	virtual TUint32 Color(const TRgb& aColor) = 0;
sl@0
  1038
	virtual TRgb RgbColor(TUint32 aColor) const = 0;
sl@0
  1039
	virtual void SetSize(const TSize& aSize);
sl@0
  1040
	FORCEINLINE TUint32* PixelAddress(TInt aX,TInt aY) const;
sl@0
  1041
	FORCEINLINE TInt PixelAddressIncrement() const;
sl@0
  1042
	void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
sl@0
  1043
	void ShadowBuffer(TInt aLength,TUint32* aBuffer);
sl@0
  1044
	FORCEINLINE TUint8 ShadowComponent(TInt aRgbComponent);
sl@0
  1045
	TUint8 FadeComponent(TInt aRgbComponent);
sl@0
  1046
	TUint8 ShadowAndFade(TInt aComponent);
sl@0
  1047
private:
sl@0
  1048
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
  1049
                                   TInt aY,
sl@0
  1050
                                   TInt aLength,
sl@0
  1051
                                   const TUint8* aRgbBuffer,
sl@0
  1052
                                   const TUint8* aMaskBuffer,
sl@0
  1053
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
  1054
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
  1055
	};
sl@0
  1056
sl@0
  1057
FORCEINLINE TUint32* CDrawThirtyTwoBppBitmapCommon::PixelAddress(TInt aX,TInt aY) const
sl@0
  1058
	{
sl@0
  1059
	return iBits + aY * iScanLineWords + aX;
sl@0
  1060
	}
sl@0
  1061
sl@0
  1062
FORCEINLINE TInt CDrawThirtyTwoBppBitmapCommon::PixelAddressIncrement() const
sl@0
  1063
	{
sl@0
  1064
	switch (iOrientation)
sl@0
  1065
		{
sl@0
  1066
	case EOrientationNormal:
sl@0
  1067
		return 1;
sl@0
  1068
	case EOrientationRotated90:
sl@0
  1069
		return iScanLineWords;
sl@0
  1070
	case EOrientationRotated180:
sl@0
  1071
		return -1;
sl@0
  1072
	case EOrientationRotated270:
sl@0
  1073
		return -iScanLineWords;
sl@0
  1074
	default:
sl@0
  1075
		return 1;
sl@0
  1076
		}
sl@0
  1077
	}
sl@0
  1078
sl@0
  1079
sl@0
  1080
/**
sl@0
  1081
@publishedPartner
sl@0
  1082
*/
sl@0
  1083
NONSHARABLE_CLASS(CDrawUTwentyFourBppBitmap) : public CDrawThirtyTwoBppBitmapCommon, MFastBlit
sl@0
  1084
	{
sl@0
  1085
public:
sl@0
  1086
	TInt Construct(TSize aSize);
sl@0
  1087
	TInt Construct(TSize aSize, TInt aStride);
sl@0
  1088
	virtual TDisplayMode ScanLineDisplayMode() const { return EColor16MAP; }
sl@0
  1089
	virtual void ReadLine(TInt aX, TInt aY, TInt aLength, TAny* aBuffer, TDisplayMode aDispMode) const;
sl@0
  1090
	virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
sl@0
  1091
	// From MFastBlit
sl@0
  1092
	virtual void WriteAlphaLineEx(TInt aX,
sl@0
  1093
						TInt aY,
sl@0
  1094
						TInt aLength,
sl@0
  1095
						TInt aSrcX,
sl@0
  1096
						const TUint32* aSrcPtr,
sl@0
  1097
						TDisplayMode aSrcFormat,
sl@0
  1098
						TInt aMaskX,
sl@0
  1099
						const TUint32* aMaskPtr,
sl@0
  1100
						MAlphaBlend::TShadowing aShadowing);
sl@0
  1101
	virtual void WriteMaskLineEx(TInt aX,
sl@0
  1102
						TInt aY,
sl@0
  1103
						TInt aLength,
sl@0
  1104
						TInt aSrcX,
sl@0
  1105
						const TUint32* aSrcPtr,
sl@0
  1106
						TDisplayMode aSrcFormat,
sl@0
  1107
						TInt aMaskX,
sl@0
  1108
						const TUint32* aMaskPtr,
sl@0
  1109
						TBool aInvertMask);
sl@0
  1110
	void BlendRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
  1111
	void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
  1112
	// From MOutlineAndShadowBlend
sl@0
  1113
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
  1114
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
  1115
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
  1116
protected:
sl@0
  1117
	virtual TUint32 Color(const TRgb& aColor);
sl@0
  1118
	virtual TRgb RgbColor(TUint32 aColor) const;
sl@0
  1119
private:
sl@0
  1120
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
  1121
                                   TInt aY,
sl@0
  1122
                                   TInt aLength,
sl@0
  1123
                                   const TUint8* aRgbBuffer,
sl@0
  1124
                                   const TUint8* aMaskBuffer,
sl@0
  1125
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
  1126
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
  1127
	};
sl@0
  1128
sl@0
  1129
sl@0
  1130
/**
sl@0
  1131
@publishedPartner
sl@0
  1132
*/
sl@0
  1133
class CDrawThirtyTwoBppBitmapAlpha : public CDrawThirtyTwoBppBitmapCommon
sl@0
  1134
	{
sl@0
  1135
public:
sl@0
  1136
	TInt Construct(TSize aSize);
sl@0
  1137
	TInt Construct(TSize aSize, TInt aStride);
sl@0
  1138
	// from CDrawThirtyTwoBppBitmap
sl@0
  1139
	void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
  1140
	void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
  1141
	void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
  1142
	void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
  1143
	void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
sl@0
  1144
	void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
  1145
	void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
  1146
	void ShadowArea(const TRect& aRect);
sl@0
  1147
	// From MOutlineAndShadowBlend
sl@0
  1148
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
  1149
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
  1150
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
  1151
protected:
sl@0
  1152
	virtual TUint32 Color(const TRgb& aColor);
sl@0
  1153
	virtual TRgb RgbColor(TUint32 aColor) const;
sl@0
  1154
	using CDrawThirtyTwoBppBitmapCommon::Shadow;
sl@0
  1155
	void Shadow(TUint32& aColor);
sl@0
  1156
private:
sl@0
  1157
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
  1158
                                   TInt aY,
sl@0
  1159
                                   TInt aLength,
sl@0
  1160
                                   const TUint8* aRgbBuffer,
sl@0
  1161
                                   const TUint8* aMaskBuffer,
sl@0
  1162
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
  1163
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
  1164
	};
sl@0
  1165
sl@0
  1166
sl@0
  1167
/**
sl@0
  1168
@publishedPartner
sl@0
  1169
*/
sl@0
  1170
class CDrawThirtyTwoBppBitmapAlphaPM : public CDrawThirtyTwoBppBitmapCommon
sl@0
  1171
	{
sl@0
  1172
public:
sl@0
  1173
	TInt Construct(TSize aSize);
sl@0
  1174
	TInt Construct(TSize aSize, TInt aStride);
sl@0
  1175
	// from CDrawThirtyTwoBppBitmap
sl@0
  1176
	void WriteRgb(TInt aX,TInt aY,TRgb aColor);
sl@0
  1177
	void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
sl@0
  1178
	void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
sl@0
  1179
	void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
sl@0
  1180
	void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
sl@0
  1181
	void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
sl@0
  1182
	void ShadowArea(const TRect& aRect);
sl@0
  1183
	virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer,
sl@0
  1184
		CGraphicsContext::TDrawMode aDrawMode);
sl@0
  1185
	// From MOutlineAndShadowBlend
sl@0
  1186
	virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
sl@0
  1187
	                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
sl@0
  1188
	                                   TUint32 aFillColor, const TUint8* aDataBuffer);
sl@0
  1189
protected:
sl@0
  1190
	virtual TUint32 Color(const TRgb& aColor);
sl@0
  1191
	virtual TRgb RgbColor(TUint32 aColor) const;
sl@0
  1192
private:
sl@0
  1193
	virtual void WriteRgbAlphaLine(TInt aX,
sl@0
  1194
                                   TInt aY,
sl@0
  1195
                                   TInt aLength,
sl@0
  1196
                                   const TUint8* aRgbBuffer,
sl@0
  1197
                                   const TUint8* aMaskBuffer,
sl@0
  1198
                                   MAlphaBlend::TShadowing aShadowing,
sl@0
  1199
                                   CGraphicsContext::TDrawMode aDrawMode);
sl@0
  1200
	};
sl@0
  1201
sl@0
  1202
sl@0
  1203
sl@0
  1204
#include "CoordTransformation.inl"
sl@0
  1205
sl@0
  1206
/** DO NOT have a declaration as the compiler will think the source is in the .cpp and make this non-inline
sl@0
  1207
sl@0
  1208
 Made a global inline to force the compiler to inline so as to gain performance.
sl@0
  1209
 A member inlines are not guarenteed to be inline.
sl@0
  1210
sl@0
  1211
 ASSERT Primary Color >= 0 && Primary Color <= 255
sl@0
  1212
 If <0 or >255, after a shift right of 8-bits should prove true.
sl@0
  1213
 00000001 00000000 = 256 >> 8 = 00000000 00000001 = TRUE
sl@0
  1214
 11111111 11111111 = -1  >> 8 = 00000000 11111111 = TRUE
sl@0
  1215
 00000000 11111111 = 255 >> 8 = 00000000 00000000 = FALSE
sl@0
  1216
sl@0
  1217
sl@0
  1218
 Initial AlphaValue = 0...1.0
sl@0
  1219
sl@0
  1220
 R = APs + (1 - A)Pd ...so if A=0 the destination pixel is more dominant
sl@0
  1221
                        and if A=1 the sourec pixel is more dominant
sl@0
  1222
sl@0
  1223
 re-adjusting...
sl@0
  1224
sl@0
  1225
 R = APs + Pd - APd
sl@0
  1226
sl@0
  1227
 R = A(Ps-Pd) + Pd
sl@0
  1228
sl@0
  1229
 Passed-in AlphaValue = 0...255
sl@0
  1230
 AlphaValue = 257 * Passed-in AlphaValue = 0...65536
sl@0
  1231
sl@0
  1232
 NOTE: AlphaValue is now a 16-bit number. the colours are 8-bit, so we shouldn't
sl@0
  1233
 have overflow problems.
sl@0
  1234
 NOTE: Negative values (Ps-Pd) shouldn't be a problem as the shifting right of
sl@0
  1235
       signed values duplicates the signed bit in the msb.
sl@0
  1236
sl@0
  1237
 R = A(Ps-Pd) + Pd
sl@0
  1238
     --------
sl@0
  1239
      65536
sl@0
  1240
sl@0
  1241
 R = (A(Ps-Pd)) >> 16) + Pd
sl@0
  1242
*/
sl@0
  1243
inline TRgb AlphaBlend(TInt aPrimaryRed, TInt aPrimaryGreen, TInt aPrimaryBlue, TInt aSecondaryRed,
sl@0
  1244
						TInt aSecondaryGreen, TInt aSecondaryBlue, TInt aAlphaValue)
sl@0
  1245
	{
sl@0
  1246
	__ASSERT_DEBUG(!(aPrimaryRed>>8) && !(aPrimaryGreen>>8) && !(aPrimaryBlue>>8) && !(aAlphaValue>>8) && 
sl@0
  1247
					!(aSecondaryRed>>8) && !(aSecondaryGreen>>8) && !(aSecondaryBlue>>8),
sl@0
  1248
					Panic(EScreenDriverPanicAlphaBlendInvariant));
sl@0
  1249
sl@0
  1250
	const TInt alphaValue = aAlphaValue * 257;
sl@0
  1251
	return TRgb(((alphaValue * (aPrimaryRed   - aSecondaryRed))   >> 16) + aSecondaryRed,
sl@0
  1252
	     		((alphaValue * (aPrimaryGreen - aSecondaryGreen)) >> 16) + aSecondaryGreen,
sl@0
  1253
	     		((alphaValue * (aPrimaryBlue  - aSecondaryBlue))  >> 16) + aSecondaryBlue);
sl@0
  1254
	}
sl@0
  1255
sl@0
  1256
inline TRgb AlphaBlend(TInt aPrimaryRed,TInt aPrimaryGreen,TInt aPrimaryBlue,TRgb aSecondary,TInt aAlphaValue)
sl@0
  1257
	{
sl@0
  1258
	return AlphaBlend(aPrimaryRed,aPrimaryGreen,aPrimaryBlue,aSecondary.Red(), aSecondary.Green(), aSecondary.Blue(), aAlphaValue);
sl@0
  1259
	}
sl@0
  1260
sl@0
  1261
/**
sl@0
  1262
It unpacks the 16 bit colour in to the red, green and blue colour components.
sl@0
  1263
@param aColor64K The 16 bit colour which needs to be unpacked.
sl@0
  1264
@param aRed   Red component of aColor64K is returned into this.
sl@0
  1265
@param aGreen Green component of aColor64K is returned into this.
sl@0
  1266
@param aBlue Blue component of aColor64K is returned into this.
sl@0
  1267
*/
sl@0
  1268
FORCEINLINE void UnpackColor64K(TUint16 aColor64K, TInt& aRed, TInt& aGreen, TInt& aBlue)
sl@0
  1269
	{
sl@0
  1270
	aRed  = (aColor64K&0xF800)>>8;
sl@0
  1271
	aRed += aRed>>5;
sl@0
  1272
	aGreen  = (aColor64K&0x07E0)>>3;
sl@0
  1273
	aGreen += aGreen>>6;
sl@0
  1274
	aBlue  = (aColor64K&0x001F)<<3;
sl@0
  1275
	aBlue += aBlue>>5;
sl@0
  1276
	}
sl@0
  1277
sl@0
  1278
/**
sl@0
  1279
It creates the 16 bit colour from the red, green and blue colour components.
sl@0
  1280
@param aRed   The Red component for creating 16 bit colour.
sl@0
  1281
@param aGreen The Green component for creating 16 bit colour.
sl@0
  1282
@param aBlue The Blue component for creating 16 bit colour.
sl@0
  1283
@return TUint16 The 16 bit colour created from the colour components.
sl@0
  1284
*/
sl@0
  1285
FORCEINLINE TUint16 PackColor64K(TInt aRed, TInt aGreen, TInt aBlue)
sl@0
  1286
	{
sl@0
  1287
	TUint16 color64K = (aBlue & 0xF8) >> 3;
sl@0
  1288
	color64K |= (aGreen & 0xFc) << 3;
sl@0
  1289
	color64K |= (aRed & 0xF8) << 8;
sl@0
  1290
	return color64K;
sl@0
  1291
	}
sl@0
  1292
sl@0
  1293
/**
sl@0
  1294
It is an overloaded function for alpha bending which does blending for 16 bit colour.
sl@0
  1295
@param aPrimaryColor64K   The foreground pixel colour in 16 bit format.
sl@0
  1296
@param aSecondaryColor64K The background pixel colour in 16 bit format.
sl@0
  1297
@param aAlphaValue The alpha value used for blending.
sl@0
  1298
@return The 16 bit blended colour.
sl@0
  1299
*/
sl@0
  1300
FORCEINLINE TUint16 AlphaBlend(TUint16 aPrimaryColor64K, TUint16 aSecondaryColor64K,TInt aAlphaValue)
sl@0
  1301
	{
sl@0
  1302
	TInt primaryRed;
sl@0
  1303
	TInt primaryGreen;
sl@0
  1304
	TInt primaryBlue;
sl@0
  1305
	TInt secondaryRed;
sl@0
  1306
	TInt secondaryGreen;
sl@0
  1307
	TInt secondaryBlue;
sl@0
  1308
sl@0
  1309
	UnpackColor64K(aPrimaryColor64K, primaryRed, primaryGreen, primaryBlue);
sl@0
  1310
	UnpackColor64K(aSecondaryColor64K, secondaryRed, secondaryGreen, secondaryBlue);
sl@0
  1311
sl@0
  1312
	__ASSERT_DEBUG(!(primaryRed>>8) && !(primaryGreen>>8) && !(primaryBlue>>8) && !(aAlphaValue>>8),
sl@0
  1313
					Panic(EScreenDriverPanicAlphaBlendInvariant));
sl@0
  1314
sl@0
  1315
	const TInt alphaValue = aAlphaValue * 257;
sl@0
  1316
	return PackColor64K(((alphaValue * (primaryRed   - secondaryRed))   >> 16) + secondaryRed,
sl@0
  1317
	     		((alphaValue * (primaryGreen - secondaryGreen)) >> 16) + secondaryGreen,
sl@0
  1318
	     		((alphaValue * (primaryBlue  - secondaryBlue))  >> 16) + secondaryBlue);
sl@0
  1319
	}
sl@0
  1320
sl@0
  1321
/**
sl@0
  1322
It is an overloaded function for alpha bending which does blending for 16 bit colour.
sl@0
  1323
@param aPrimaryRed  Red component of foreground pixel colour.
sl@0
  1324
@param aPrimaryGreen  Green component of foreground pixel colour.
sl@0
  1325
@param aPrimaryBlue  Blue component of foreground pixel colour.
sl@0
  1326
@param aSecondaryColor64K The background pixel colour in 16 bit format.
sl@0
  1327
@param aAlphaValue The alpha value used for blending.
sl@0
  1328
@return The 16 bit blended colour.
sl@0
  1329
*/
sl@0
  1330
FORCEINLINE TUint16 AlphaBlend(TInt aPrimaryRed,TInt aPrimaryGreen,TInt aPrimaryBlue, TUint16 aSecondaryColor64K,TInt aAlphaValue)
sl@0
  1331
	{
sl@0
  1332
	__ASSERT_DEBUG(!(aPrimaryRed>>8) && !(aPrimaryGreen>>8) && !(aPrimaryBlue>>8) && !(aAlphaValue>>8),
sl@0
  1333
					Panic(EScreenDriverPanicAlphaBlendInvariant));
sl@0
  1334
sl@0
  1335
	if (aAlphaValue==0xFF)
sl@0
  1336
		return(PackColor64K(aPrimaryRed, aPrimaryGreen, aPrimaryBlue));
sl@0
  1337
	TInt secondaryRed;
sl@0
  1338
	TInt secondaryGreen;
sl@0
  1339
	TInt secondaryBlue;
sl@0
  1340
sl@0
  1341
	UnpackColor64K(aSecondaryColor64K, secondaryRed, secondaryGreen, secondaryBlue);
sl@0
  1342
sl@0
  1343
	const TInt alphaValue = aAlphaValue * 257;
sl@0
  1344
	return PackColor64K(((alphaValue * (aPrimaryRed   - secondaryRed))   >> 16) + secondaryRed,
sl@0
  1345
	     		((alphaValue * (aPrimaryGreen - secondaryGreen)) >> 16) + secondaryGreen,
sl@0
  1346
	     		((alphaValue * (aPrimaryBlue  - secondaryBlue))  >> 16) + secondaryBlue);
sl@0
  1347
	}
sl@0
  1348
sl@0
  1349
FORCEINLINE LOCAL_C TUint16 Conv32To16(TUint32 col)
sl@0
  1350
	{
sl@0
  1351
	TUint b = (col&0x000000ff)>>3;
sl@0
  1352
	TUint g = (col&0x0000fc00)>>5;
sl@0
  1353
	TUint r = (col&0x00f80000)>>8;
sl@0
  1354
	return TUint16(r|g|b);
sl@0
  1355
	}
sl@0
  1356
sl@0
  1357
// Alpha-blends an EColor16MA pixel to an EColor64K screen using a fixed mask value.
sl@0
  1358
FORCEINLINE LOCAL_C TUint16 Blend32To16(TUint32 aSrc32, TUint aMask, TUint16 aDest16)
sl@0
  1359
	{
sl@0
  1360
	__ASSERT_DEBUG(aMask < 256, Panic(EScreenDriverPanicInvalidParameter));
sl@0
  1361
sl@0
  1362
	if(aMask)
sl@0
  1363
		{
sl@0
  1364
		if(aMask >= 0xFF)
sl@0
  1365
			return Conv32To16(aSrc32);
sl@0
  1366
sl@0
  1367
		// blend red and blue channel in one go
sl@0
  1368
		TUint32 d_rb = (aDest16 & 0xF800)<<8 | (aDest16 & 0x001F)<<3;
sl@0
  1369
		d_rb |= (d_rb>>5) & 0x00ff00ff;
sl@0
  1370
		const TUint32 s_rb = aSrc32 & 0x00FF00FF;
sl@0
  1371
		const TUint32 mask2 = aMask | (aMask << 16);
sl@0
  1372
		const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
sl@0
  1373
sl@0
  1374
		// do the green channel normally
sl@0
  1375
		TInt32 d_g  = (aDest16 & 0x07E0)>>3;
sl@0
  1376
		d_g |= d_g>>6;
sl@0
  1377
		const TInt32 s_g = (aSrc32 & 0xFF00) >> 8;
sl@0
  1378
		TInt g = (((aMask * (s_g - d_g)) >> 8) + d_g) & 0xFF;
sl@0
  1379
sl@0
  1380
		return (Conv32To16(rb | g<<8));
sl@0
  1381
		}
sl@0
  1382
sl@0
  1383
	return aDest16;
sl@0
  1384
	}
sl@0
  1385
sl@0
  1386
// As for Blend32To16, but assumes 0xFF and 0 alpha checks already done elsewhere
sl@0
  1387
FORCEINLINE LOCAL_C TUint16 Blend32To16NoChecks(TUint32 aSrc32, TUint aMask, TUint16 aDest16)
sl@0
  1388
	{
sl@0
  1389
	// blend red and blue channel in one go
sl@0
  1390
	TUint32 d_rb = (aDest16 & 0xF800)<<8 | (aDest16 & 0x001F)<<3;
sl@0
  1391
	d_rb |= (d_rb>>5) & 0x00ff00ff;
sl@0
  1392
	const TUint32 s_rb = aSrc32 & 0x00FF00FF;
sl@0
  1393
	const TUint32 mask2 = aMask | (aMask << 16);
sl@0
  1394
	const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
sl@0
  1395
sl@0
  1396
	// do the green channel normally
sl@0
  1397
	TInt32 d_g  = (aDest16 & 0x07E0)>>3;
sl@0
  1398
	d_g |= d_g>>6;
sl@0
  1399
	const TInt32 s_g = (aSrc32 & 0xFF00) >> 8;
sl@0
  1400
	TInt g = (((aMask * (s_g - d_g)) >> 8) + d_g) & 0xFF;
sl@0
  1401
sl@0
  1402
	return (Conv32To16(rb | g<<8));
sl@0
  1403
	}
sl@0
  1404
sl@0
  1405
// Alpha-blends to an EColor64K screen using a fixed mask value.
sl@0
  1406
// The source values are pre-split from a 32 bit source into the two following components:
sl@0
  1407
//
sl@0
  1408
// aSrcRB=aSrc32 & 0x00FF00FF;
sl@0
  1409
// aSrcG=(aSrc32 & 0xFF00) >> 8;
sl@0
  1410
//
sl@0
  1411
// Mask is assumed not to be 0 or 255, these should be pre-checked for and never arrive here
sl@0
  1412
//
sl@0
  1413
FORCEINLINE LOCAL_C TUint16 BlendTo16(const TUint32 aSrcRB, const TUint32 aSrcG, TUint aMask, TUint16 aDest16)
sl@0
  1414
	{
sl@0
  1415
	// blend red and blue channel in one go
sl@0
  1416
	TUint32 d_rb = (aDest16 & 0xF800)<<8 | (aDest16 & 0x001F)<<3;
sl@0
  1417
	d_rb |= (d_rb>>5) & 0x00ff00ff;
sl@0
  1418
	const TUint32 mask2 = aMask | (aMask << 16);
sl@0
  1419
	const TUint32 rb = ((((aMask * ((0x01000100 + aSrcRB) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
sl@0
  1420
sl@0
  1421
	// do the green channel normally
sl@0
  1422
	TInt32 d_g  = (aDest16 & 0x07E0)>>3;
sl@0
  1423
	d_g |= d_g>>6;
sl@0
  1424
	const TInt32 g = (((aMask * (aSrcG - d_g)) >> 8) + d_g) & 0xFF;
sl@0
  1425
sl@0
  1426
	// inline conversion to 16 bit
sl@0
  1427
	return TUint16(((rb&0x00f80000)>>8)|((g&0x0000fc)<<3)|((rb&0x000000ff)>>3));
sl@0
  1428
	}
sl@0
  1429
sl@0
  1430
// Alpha-blends an EColor16MA pixel to an EColor16MU screen using a fixed mask value.
sl@0
  1431
FORCEINLINE LOCAL_C TUint32 CalcAlphaPixel(const TUint32 aSrcPixel, const TUint8 aMask, TUint32 aDestPixel)
sl@0
  1432
	{
sl@0
  1433
	// (a)  (mask * src + (255 - mask) * dest) / 255           This ideal formula
sl@0
  1434
	// (b)  ((mask * (src - dest)) >> 8) + dest                A faster approximation to (a)
sl@0
  1435
	// (c)  ((mask * (256 + src - dest) >> 8) + dest - mask    Equivalent to (b) but can be used on multiple colors at a time
sl@0
  1436
sl@0
  1437
	if(aMask)
sl@0
  1438
		{
sl@0
  1439
		if(aMask == 0xFF)
sl@0
  1440
			return 0xff000000|aSrcPixel;
sl@0
  1441
sl@0
  1442
		const TUint32 s_rb = aSrcPixel & 0x00FF00FF;
sl@0
  1443
		const TUint32 d_rb = aDestPixel & 0x00FF00FF;
sl@0
  1444
		const TUint32 mask2 = aMask | (aMask << 16);
sl@0
  1445
		const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
sl@0
  1446
sl@0
  1447
		const TInt s_g = (aSrcPixel & 0xFF00) >> 8;
sl@0
  1448
		const TInt d_g = (aDestPixel & 0xFF00) >> 8;
sl@0
  1449
		const TInt g = ((aMask * (s_g - d_g)) >> 8) + d_g;
sl@0
  1450
sl@0
  1451
		return(rb | (g<<8) | 0xff000000);
sl@0
  1452
		}
sl@0
  1453
sl@0
  1454
	return aDestPixel;
sl@0
  1455
sl@0
  1456
	}
sl@0
  1457
sl@0
  1458
// Alpha-blends an EColor16MA rgb to an EColor16MU screen using a fixed mask value.
sl@0
  1459
FORCEINLINE LOCAL_C void AlphaBlendPixelToDest(TUint32 aSrcValue, const TUint8 aSourceAlpha, TUint32* aDestPtr)
sl@0
  1460
 {
sl@0
  1461
 *aDestPtr = CalcAlphaPixel(aSrcValue, aSourceAlpha, *aDestPtr);
sl@0
  1462
 }
sl@0
  1463
sl@0
  1464
void MemFillTUint32(TUint32* tempWordPtr, TInt aCount,  const TUint32 aValue);
sl@0
  1465
sl@0
  1466
#endif
sl@0
  1467