sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __BMDRAW_H__ sl@0: #define __BMDRAW_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include "BitDrawScaling.h" sl@0: #include "BitDrawOrigin.h" sl@0: #include "BmAlphaBlend.h" sl@0: #include "BitDrawOrientation.h" sl@0: sl@0: #ifdef __ARMCC__ sl@0: #define FORCEINLINE __forceinline sl@0: #else sl@0: #define FORCEINLINE inline sl@0: #endif sl@0: sl@0: /** sl@0: Outline colour index used to get percentage of outline colour to be used to get sl@0: the final colour from lookup table sl@0: @internalComponent sl@0: */ sl@0: const TInt KOutlineColorIndex = 0; sl@0: sl@0: /** sl@0: Shadow colour index used to get percentage of shadow colour to be used to get sl@0: the final colour from lookup table sl@0: @internalComponent sl@0: */ sl@0: const TInt KShadowColorIndex = 1; sl@0: sl@0: /** sl@0: Fill colour index used to get percentage of fill colour to be used to get sl@0: the final colour from lookup table sl@0: @internalComponent sl@0: */ sl@0: const TInt KFillColorIndex = 2; sl@0: sl@0: /** sl@0: Background colour index used to get percentage of background colour to be used to get sl@0: the final colour from lookup table sl@0: @internalComponent sl@0: */ sl@0: const TInt KBackgroundColorIndex = 3; sl@0: sl@0: /** sl@0: Lookup table used for outline and shadow fonts. sl@0: @internalComponent sl@0: */ sl@0: GLREF_D const TInt FourColorBlendLookup[256][4]; sl@0: sl@0: TRgb AlphaBlend(TRgb aPrimary, TRgb aSecondary, TInt aAlphaValue); sl@0: sl@0: //Scaling settings. MScalingSettings interface operates with them. sl@0: struct TScalingSettings sl@0: { sl@0: inline TScalingSettings() : sl@0: iFactorX(1), sl@0: iFactorY(1), sl@0: iDivisorX(1), sl@0: iDivisorY(1) sl@0: { sl@0: } sl@0: TInt iFactorX; sl@0: TInt iFactorY; sl@0: TInt iDivisorX; sl@0: TInt iDivisorY; sl@0: }; sl@0: sl@0: // Drawing device origin. MDrawDeviceOrigin interface operates with it. sl@0: typedef TPoint TOrigin; sl@0: sl@0: //This class is used as a template argument by CDrawEightBppBitmapCommon::SetPixels() sl@0: //and CDrawSixteenBppBitmapCommon::SetPixels() sl@0: //Each of its methods (EvalInc() and EvalDec()) has two arguments - sl@0: //aAddr and aValue, and it is used to set *aAddr with aValue and to increment/decrement sl@0: //respectively aAddr. sl@0: template class TPixelSet sl@0: { sl@0: public: sl@0: inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const sl@0: { sl@0: *aAddr++ = aValue; sl@0: } sl@0: inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const sl@0: { sl@0: *aAddr-- = aValue; sl@0: } sl@0: }; sl@0: sl@0: //This class is used as a template argument by CDrawEightBppBitmapCommon::XORPixels(). sl@0: //and CDrawSixteenBppBitmapCommon::XORPixels() sl@0: //Each of its methods (EvalInc() and EvalDec()) has two arguments - sl@0: //aAddr and aValue, and it is used to XOR *aAddr with aValue and to increment/decrement sl@0: //respectively aAddr. sl@0: template class TPixelXor sl@0: { sl@0: public: sl@0: inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const sl@0: { sl@0: *aAddr++ ^= aValue; sl@0: } sl@0: inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const sl@0: { sl@0: *aAddr-- ^= aValue; sl@0: } sl@0: }; sl@0: sl@0: //This class is used as a template argument by CDrawEightBppBitmapCommon::ANDPixels(). sl@0: //and CDrawSixteenBppBitmapCommon::ANDPixels() sl@0: //Each of its methods (EvalInc() and EvalDec()) has two arguments - sl@0: //aAddr and aValue, and it is used to AND *aAddr with aValue and to increment/decrement sl@0: //respectively aAddr. sl@0: template class TPixelAnd sl@0: { sl@0: public: sl@0: inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const sl@0: { sl@0: *aAddr++ &= aValue; sl@0: } sl@0: inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const sl@0: { sl@0: *aAddr-- &= aValue; sl@0: } sl@0: }; sl@0: sl@0: //This class is used as a template argument by CDrawEightBppBitmapCommon::ORPixels(). sl@0: //and CDrawSixteenBppBitmapCommon::ORPixels() sl@0: //Each of its methods (EvalInc() and EvalDec()) has two arguments - sl@0: //aAddr and aValue, and it is used to OR *aAddr with aValue and to increment/decrement sl@0: //respectively aAddr. sl@0: template class TPixelOr sl@0: { sl@0: public: sl@0: inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const sl@0: { sl@0: *aAddr++ |= aValue; sl@0: } sl@0: inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const sl@0: { sl@0: *aAddr-- |= aValue; sl@0: } sl@0: }; sl@0: sl@0: //This template function should be used every time when a rectangle has to be drawn instead of sl@0: //a single pixel in EColor256/EColor64K scaled device. sl@0: //aPixelPtr - points to the pixel memory address, which contains top-left corner of the rectangle. sl@0: //aValue - the pixel value - EColor256. sl@0: //aPixelPtrRowLimit - the right end address of the scalline. sl@0: //aBitsStart - beginning address of the pixel memory. sl@0: //aBitsEnd - end address of the pixel memory. sl@0: //aLongWidth - aligned scanline width in pixels. sl@0: //aFx - X-axis scaling factor. sl@0: //aFy - Y-axis scaling factor. sl@0: //aOrientation - device's orientation. sl@0: //aOp - the operation, which must be applied to every pixel from the rectangle - template parameter. sl@0: template sl@0: inline void FillScaledRect(TPixelType* aPixelPtr, sl@0: const TPixelType aValue, sl@0: const TPixelType* aPixelPtrRowLimit, sl@0: const TPixelType* aBitsStart, sl@0: const TPixelType* aBitsEnd, sl@0: const TInt aLongWidth, sl@0: TInt aFx, sl@0: TInt aFy, sl@0: const CFbsDrawDevice::TOrientation aOrientation, sl@0: const TPixelOp& aOp) sl@0: { sl@0: if(aOrientation == CFbsDrawDevice::EOrientationNormal) sl@0: { sl@0: //for example: if aFx = 3 and aFy = 2 then sl@0: //the following pixel values have to be evaluated: sl@0: // (aPixelPtr), (aPixelPtr + 1), (aPixelPtr + 2) sl@0: // (aPixelPtr + aLongWidth), (aPixelPtr + 1 + aLongWidth), (aPixelPtr + 2 + aLongWidth) sl@0: const TPixelType* nextStop = aPixelPtr + aFx;//the address of next scaled pixel value sl@0: if(nextStop > aPixelPtrRowLimit) sl@0: {//If the address is after the end of the current row, set it to the end of row. sl@0: nextStop = aPixelPtrRowLimit; sl@0: } sl@0: do //Fill pixel rectangle [aFx,aFy] sl@0: { sl@0: while(aPixelPtr < nextStop) sl@0: {//Fill a row of up to aFx pixels. sl@0: aOp.EvalInc(aPixelPtr, aValue); sl@0: } sl@0: aPixelPtr += (aLongWidth - aFx);//Move aPixelPtr to the next row sl@0: if(aPixelPtr >= aBitsEnd) sl@0: {//If aPixelPtr points after the end of video memory - stop the operation! sl@0: break; sl@0: } sl@0: nextStop += aLongWidth;//Move nextPixelAddr to the next row sl@0: } sl@0: while(--aFy); sl@0: return; sl@0: } sl@0: if(aOrientation == CFbsDrawDevice::EOrientationRotated90) sl@0: { sl@0: //for example: if aFy = 3 and aFx = 2 then sl@0: //the following pixel values have to be evaluated: sl@0: // (aPixelPtr), (aPixelPtr - 1), sl@0: // (aPixelPtr + aLongWidth), (aPixelPtr - 1 + aLongWidth), sl@0: // (aPixelPtr + 2 * aLongWidth), (aPixelPtr - 1 + 2 * aLongWidth), sl@0: const TPixelType* pixelPtrPrevRowLimit = aPixelPtrRowLimit - aLongWidth; sl@0: const TPixelType* nextStop = aPixelPtr - aFx;//the address of next scaled pixel value sl@0: if(nextStop < pixelPtrPrevRowLimit) sl@0: {//If the address is before the beginning of the current row, set it to the beginning of row. sl@0: nextStop = pixelPtrPrevRowLimit; sl@0: } sl@0: do //Fill pixel rectangle [aFx,aFy] sl@0: { sl@0: while(aPixelPtr > nextStop) sl@0: {//Fill a row of up to aFy pixels. sl@0: aOp.EvalDec(aPixelPtr, aValue); sl@0: } sl@0: aPixelPtr += (aLongWidth + aFx);//Move aPixelPtr to the next row sl@0: if(aPixelPtr >= aBitsEnd) sl@0: {//If aPixelPtr points after the end of video memory - stop the operation! sl@0: break; sl@0: } sl@0: nextStop += aLongWidth;//Move nextPixelAddr to the next row sl@0: } sl@0: while(--aFy); sl@0: return; sl@0: } sl@0: if(aOrientation == CFbsDrawDevice::EOrientationRotated180) sl@0: { sl@0: //for example: if aFx = 3 and aFy = 2 then sl@0: //the following pixel values have to be evaluated: sl@0: // (aPixelPtr), (aPixelPtr - 1), (aPixelPtr - 2) sl@0: // (aPixelPtr - aLongWidth), (aPixelPtr + 1 - aLongWidth), (aPixelPtr + 2 - aLongWidth) sl@0: const TPixelType* pixelPtrPrevRowLimit = aPixelPtrRowLimit - aLongWidth; sl@0: const TPixelType* nextStop = aPixelPtr - aFx;//the address of next scaled pixel value sl@0: if(nextStop < pixelPtrPrevRowLimit) sl@0: {//If the address is before the beginning of the current row, set it to the beginning of row. sl@0: nextStop = pixelPtrPrevRowLimit; sl@0: } sl@0: do //Fill pixel rectangle [aFx,aFy] sl@0: { sl@0: while(aPixelPtr > nextStop) sl@0: {//Fill a row of up to aFx pixels. sl@0: aOp.EvalDec(aPixelPtr, aValue); sl@0: } sl@0: aPixelPtr -= (aLongWidth - aFx);//Move aPixelPtr to the prev row sl@0: if(aPixelPtr < aBitsStart) sl@0: {//If aPixelPtr points before the beginning of video memory - stop the operation! sl@0: break; sl@0: } sl@0: nextStop -= aLongWidth;//Move nextPixelAddr to the prev row sl@0: } sl@0: while(--aFy); sl@0: return; sl@0: } sl@0: else //if(aOrientation == CFbsDrawDevice::EOrientationRotated270) sl@0: { sl@0: //for example: if aFy = 3 and aFx = 2 then sl@0: //the following pixel values have to be evaluated: sl@0: // (aPixelPtr), (aPixelPtr + 1) sl@0: // (aPixelPtr - aLongWidth), (aPixelPtr + 1 - aLongWidth) sl@0: // (aPixelPtr - 2 * aLongWidth), (aPixelPtr + 1 - 2 * aLongWidth) sl@0: const TPixelType* nextStop = aPixelPtr + aFx;//the address of next scaled pixel value sl@0: if(nextStop > aPixelPtrRowLimit) sl@0: {//If the address is after the end of the current row, set it to the end of row. sl@0: nextStop = aPixelPtrRowLimit; sl@0: } sl@0: do //Fill pixel rectangle [aFx,aFy] sl@0: { sl@0: while(aPixelPtr < nextStop) sl@0: {//Fill a row of up to aFy pixels. sl@0: aOp.EvalInc(aPixelPtr, aValue); sl@0: } sl@0: aPixelPtr += (-aLongWidth - aFx);//Move aPixelPtr to the prev row sl@0: if(aPixelPtr < aBitsStart) sl@0: {//If aPixelPtr points befor the beginning of video memory - stop the operation! sl@0: break; sl@0: } sl@0: nextStop -= aLongWidth;//Move nextPixelAddr to the prev row sl@0: } sl@0: while(--aFy); sl@0: return; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawBitmap) : public CFbsDrawDevice, sl@0: public MScalingSettings, sl@0: public MDrawDeviceOrigin, sl@0: public MAlphaBlend, sl@0: public MOutlineAndShadowBlend, sl@0: public MDrawDeviceOrientation, sl@0: public MFastBlend sl@0: { sl@0: public: sl@0: virtual ~CDrawBitmap(); sl@0: // From CFbsDrawDevice sl@0: virtual TDisplayMode DisplayMode() const { return iDispMode; } sl@0: virtual TInt LongWidth() const; sl@0: virtual void MapColors(const TRect& aRect,const TRgb* aColors,TInt aNumPairs,TBool aMapForwards); sl@0: virtual TRgb ReadPixel(TInt aX,TInt aY) const; sl@0: virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer,TDisplayMode aDispMode) const; sl@0: virtual TUint32* ScanLineBuffer() const; sl@0: virtual TInt ScanLineBytes() const; sl@0: virtual TDisplayMode ScanLineDisplayMode() const { return iDispMode; } sl@0: virtual TSize SizeInPixels() const; sl@0: virtual TInt HorzTwipsPerThousandPixels() const { return 0; } sl@0: virtual TInt VertTwipsPerThousandPixels() const { return 0; } sl@0: virtual void OrientationsAvailable(TBool aOrientation[4]); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLine(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode,TBool aUp); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer ,CGraphicsContext::TDrawMode); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode); sl@0: virtual void SetBits(TAny* aBits); sl@0: virtual void SetDitherOrigin(const TPoint& aPoint); sl@0: virtual void SetShadowMode(TShadowMode aShadowMode) { iShadowMode = aShadowMode; } sl@0: virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap); sl@0: virtual void SetUserDisplayMode(TDisplayMode aDisplayMode) { iUserDispMode = aDisplayMode; } sl@0: virtual TBool SetOrientation(TOrientation aOrientation); sl@0: virtual void WriteRgbAlphaLine(TInt aX,TInt aY,TInt aLength, sl@0: TUint8* aRgbBuffer, TUint8* aMaskBuffer, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteRgbAlphaLine(TInt aX,TInt aY,TInt aLength, sl@0: const TUint8* aRgbBuffer1, sl@0: const TUint8* aBuffer2, sl@0: const TUint8* aMaskBuffer, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface); sl@0: virtual void GetDrawRect(TRect& aDrawRect) const; sl@0: virtual void SwapWidthAndHeight(); sl@0: // From MScalingSettings sl@0: virtual TInt Set(TInt aFactorX, TInt aFactorY, TInt aDivisorX, TInt aDivisorY); sl@0: virtual void Get(TInt& aFactorX, TInt& aFactorY, TInt& aDivisorX, TInt& aDivisorY); sl@0: virtual TBool IsScalingOff(); sl@0: // From MDrawDeviceOrigin sl@0: virtual TInt Set(const TPoint& aOrigin); sl@0: virtual void Get(TPoint& aOrigin); sl@0: // From MDrawDeviceOrientation sl@0: virtual CFbsDrawDevice::TOrientation Orientation(); sl@0: // From MFastBlend sl@0: virtual TInt FastBlendBitmap(const TPoint& aDest,CFbsDrawDevice* aSrcDrawDevice, const TRect& aSrcRect, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode); sl@0: 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: virtual TInt FastBlendBitmapMasked(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride, sl@0: const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aSrcDisplayMode, sl@0: const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,const TPoint &aMaskSrcPos,TBool aInvertMask, sl@0: CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode); sl@0: 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: virtual TInt FastBlendBitmapMaskedScaled(const TRect &aClipRect, const TRect& aDest, sl@0: const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcLinePitch, sl@0: TDisplayMode aSrcDisplayMode, const TSize &aSrcSize, sl@0: const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,TBool aInvertMask, sl@0: CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode); sl@0: protected: sl@0: CDrawBitmap(); sl@0: static TInt BitsPerPixel(TDisplayMode aDispMode); sl@0: void Clear(); sl@0: void CopyOldSettings(CFbsDrawDevice* aDrawDevice); sl@0: void DeOrientate(TInt& aX,TInt& aY) const; sl@0: TPoint DeOrientate(const TPoint& aPoint) const; sl@0: TRect DeOrientate(const TRect& aRect) const; sl@0: virtual void Shadow(TRgb& aColor) = 0; sl@0: TRgb FadeRgb(TRgb aColor); sl@0: TUint32 FadeRgb(TUint32 aColor); sl@0: void FadeRgb(TInt& aRed, TInt& aGreen, TInt& aBlue); sl@0: TUint8 FadeGray(TInt aGray256); sl@0: TUint32 Hash(TUint32 aValue,TInt aX,TInt aY) const; sl@0: TUint32 PasteInt(TUint32 aFirst,TUint32 aSecond,TInt aOffset) const; sl@0: static TAny* CopyOffset(TAny* aDestination,const TAny* aSource,TInt aWordsToCopy,TInt aSourceBitOffset); sl@0: static void ReadLineCommon(TUint32* aPixelPtr,TUint32* aBufferPtr,TInt aWordsCnt,TInt aRestPixels,TInt aBytesCnt,TInt aStartDiffBits); sl@0: virtual void SetSize(const TSize& aSize); sl@0: // Scaling related sl@0: TBool CanBeScaled() const; sl@0: TInt PixelAddressIncrement() const; sl@0: TInt LogicalPixelAddressIncrement() const; sl@0: void SetPixelInc(TInt& aPixelInc, TInt& aRowInc) const; sl@0: void IncScaledY(TInt& aY) const; sl@0: void IncScaledY(TInt& aY, TInt aYOrg) const; sl@0: //Generic set pixels operations, has to be defined here to make it compiled in VC++6.0 sl@0: template sl@0: void SetPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit, sl@0: const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const sl@0: { sl@0: TPixelSet op; sl@0: ::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth, sl@0: iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op); sl@0: } sl@0: template sl@0: void XORPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit, sl@0: const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const sl@0: { sl@0: TPixelXor op; sl@0: ::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth, sl@0: iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op); sl@0: } sl@0: template sl@0: void ANDPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit, sl@0: const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const sl@0: { sl@0: TPixelAnd op; sl@0: ::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth, sl@0: iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op); sl@0: } sl@0: template sl@0: void ORPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit, sl@0: const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const sl@0: { sl@0: TPixelOr op; sl@0: ::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth, sl@0: iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op); sl@0: } sl@0: //Origin related sl@0: TBool CanOriginBeMoved() const; sl@0: void MapColorToUserDisplayMode(TInt& red,TInt& green,TInt& blue); sl@0: protected: sl@0: virtual void InvertBuffer(TInt aLength,TUint32* aBuffer) = 0; sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const = 0; sl@0: virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const = 0; sl@0: virtual TUint32* ScanLine(TInt aY) const; sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0; sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0; sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0; sl@0: virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0; sl@0: virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0; sl@0: virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0; sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor) = 0; sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor) = 0; sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode) = 0; sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp) = 0; sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0; sl@0: virtual void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0; sl@0: virtual void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& /*aColor*/) {} sl@0: virtual void MapBufferToUserDisplayMode(TInt /*aLength*/,TUint32* /*aBuffer*/) {} sl@0: private: sl@0: void GetBlendPosAndRect(TRect &aSrcRect, const TRect &aSrcRectIn, const TSize &aSrcSize, const TPoint &aDestOffset); sl@0: void GetBlendPosAndRect(TRect &aDstRect, TRect &aSrcRect, const TRect &aDestRectIn, const TRect &aSrcRectIn, const TSize &aSrcSize); sl@0: TBool FastBlendSupported(TDisplayMode aSrcDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode, TInt aSrcLinePitch); sl@0: TBool FastBlendMaskSupported(TDisplayMode aMaskDisplayMode, TInt aMaskStride); sl@0: void DoCopyOldSettings(CFbsDrawDevice* aDrawDevice); sl@0: TInt DoFastBlendBitmap(const TPoint &aDest, const TRect& aSrcRect, const TUint8 *aSrcBase, TInt aSrcLinePitch, TDisplayMode aSrcDisplayMode, const TSize &aSrcSize); sl@0: // Scaling related sl@0: void InitLogicalCoordinates(); sl@0: void PreWriteRgb(TInt& aWidth, TInt& aHeight, TInt& aX, TInt& aY, CGraphicsContext::TDrawMode aDrawMode); sl@0: void WriteRgb(TInt& aWidth, TInt& aHeight, TInt& aX, TInt& aY, TRgb aColor, CGraphicsContext::TDrawMode aDrawMode); sl@0: void SetDefaults(); sl@0: inline TInt Origin(TInt aPhysOrg, TInt aScale) const; sl@0: inline TInt OtherSide(TInt aPhysOrg, TInt aPhysSize, TInt aScale) const; sl@0: protected: sl@0: TDisplayMode iDispMode; sl@0: TInt iLongWidth; // aligned scanline width in pixels sl@0: TPoint iDitherOrigin; sl@0: TUint32* iScanLineBuffer; sl@0: TInt iScanLineWords; sl@0: TShadowMode iShadowMode; sl@0: TSize iSize; // (0, 0, iSize.iWidth, iSize.iHeight) - drawing rectangle - physical coordinates sl@0: TUint32* iBits; sl@0: TDisplayMode iUserDispMode; sl@0: TOrientation iOrientation; // 0, 90, 180, 270 degrees sl@0: TInt iFadeMapFactor; sl@0: TInt iFadeMapOffset; sl@0: TScalingSettings iScalingSettings; // X-axis and Y-axis scaling factors sl@0: TOrigin iOrigin; // drawing device origin sl@0: TBool iScalingOff; // ETrue, if the scaling is off. sl@0: TBool iOriginIsZero; // ETrue, if the origin is (0, 0). sl@0: TRect iDrawRect; // drawing rectangle - logical coordinates sl@0: MAlphaBlend* iAlphaBlend; // Alphablending interface sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawOneBppBitmap) : public CDrawBitmap sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: virtual void InvertBuffer(TInt aLength,TUint32* aBuffer); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual void ShadowArea(const TRect& aRect); sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: protected: sl@0: virtual void SetSize(const TSize& aSize); sl@0: virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const; sl@0: virtual void Shadow(TRgb& aColor); sl@0: void ShadowBuffer(TInt aLength,TUint32* aBuffer); sl@0: private: sl@0: TUint32 ColorWord(TRgb aColor) const; sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawTwoBppBitmap) : public CDrawBitmap sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: TUint32 ColorInt(TRgb aColor) const; sl@0: void HashInt(TUint32& aInt1,TUint32& aInt2,TRgb aColor,TInt aX,TInt aY) const; sl@0: virtual void InvertBuffer(TInt aLength,TUint32* aBuffer); sl@0: void MapColors(const TRect& aRect,const TRgb* aColors,TInt aNumPairs,TBool aMapForwards); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual void ShadowArea(const TRect& aRect); sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& aColor); sl@0: virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: protected: sl@0: virtual void SetSize(const TSize& aSize); sl@0: TUint32 MapInt(TUint32 aInt,TUint32* aColorMap) const; sl@0: virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const; sl@0: virtual void Shadow(TRgb& aColor); sl@0: TUint32 ShadowWord(TUint32 aWord); sl@0: TUint32 FadeWord(TUint32 aWord); sl@0: void ShadeBuffer(TInt aLength,TUint32* aBuffer); sl@0: void ShadowBuffer(TInt aLength,TUint32* aBuffer); sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawFourBppBitmapGray) : public CDrawBitmap sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: TUint32 ColorInt(TRgb aColor) const; sl@0: TUint32 HashInt(TRgb aColor,TInt aX,TInt aY) const; sl@0: virtual void InvertBuffer(TInt aLength,TUint32* aBuffer); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual void ShadowArea(const TRect& aRect); sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& aColor); sl@0: virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: protected: sl@0: virtual void SetSize(const TSize& aSize); sl@0: void DitherBuffer(TInt x,TInt y,TInt aLength,TUint32* aBuffer); sl@0: virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const; sl@0: virtual void Shadow(TRgb& aColor); sl@0: TUint8 ShadowAndFadeGray16(TInt aGray16); sl@0: TUint32 FadeWord(TUint32 aWord); sl@0: void ShadeBuffer(TInt aLength,TUint32* aBuffer); sl@0: void ShadowBuffer(TInt aLength,TUint32* aBuffer); sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: TRgb BlendFourColors(TUint32 aOutlinePenColor, TUint32 aShadowColor, TUint32 aFillColor, sl@0: TInt aRedOutlinePenColor,TInt aRedShadowColor,TInt aRedFillColor, sl@0: TInt aGreenOutlinePenColor, TInt aGreenShadowColor, TInt aGreenFillColor, sl@0: TInt aBlueOutlinePenColor, TInt aBlueShadowColor, TInt aBlueFillColor, sl@0: TRgb aBackgroundColor, TUint8 aIndex) const; sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawFourBppBitmapColor) : public CDrawBitmap sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: TUint32 ColorInt(TRgb aColor) const; sl@0: virtual void InvertBuffer(TInt aLength,TUint32* aBuffer); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual void ShadowArea(const TRect& aRect); sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& aColor); sl@0: virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: protected: sl@0: virtual void SetSize(const TSize& aSize); sl@0: virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const; sl@0: virtual void Shadow(TRgb& aColor); sl@0: TUint32 ShadowWord(TUint32 aWord); sl@0: TUint32 FadeWord(TUint32 aWord); sl@0: void ShadowBuffer(TInt aLength,TUint32* aBuffer); sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: TRgb BlendFourColors(TUint32 aOutlinePenColor, TUint32 aShadowColor, TUint32 aFillColor, sl@0: TInt aRedOutlinePenColor,TInt aRedShadowColor,TInt aRedFillColor, sl@0: TInt aGreenOutlinePenColor, TInt aGreenShadowColor, TInt aGreenFillColor, sl@0: TInt aBlueOutlinePenColor, TInt aBlueShadowColor, TInt aBlueFillColor, sl@0: TRgb aBackgroundColor, TUint8 aIndex) const; sl@0: }; sl@0: sl@0: const TInt KInvalidValue = 0xABCDABCD; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawEightBppBitmapCommon) : public CDrawBitmap, public MFastBlit2 sl@0: { sl@0: public: sl@0: virtual void InvertBuffer(TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface); sl@0: // From MFastBlit2 sl@0: virtual TInt WriteBitmapBlock(const TPoint& aDest, sl@0: CFbsDrawDevice* aSrcDrawDevice, sl@0: const TRect& aSrcRect); sl@0: virtual TInt WriteBitmapBlock(const TPoint& aDest, sl@0: const TUint32* aSrcBase, sl@0: TInt aSrcStride, sl@0: const TSize& aSrcSize, sl@0: const TRect& aSrcRect); sl@0: virtual const TUint32* Bits() const; sl@0: protected: sl@0: virtual void SetSize(const TSize& aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: TUint8* PixelAddress(TInt aX,TInt aY) const; sl@0: void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const; sl@0: void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint8 aPixel); sl@0: void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint8 aPixel,CGraphicsContext::TDrawMode aDrawMode); sl@0: void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TUint8 aPixel,TBool aUp); sl@0: void WriteRgb(TInt aX,TInt aY,TUint8 aPixel); sl@0: void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel); sl@0: void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel); sl@0: void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel); sl@0: void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel); sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawEightBppBitmapGray) : public CDrawEightBppBitmapCommon sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual void ShadowArea(const TRect& aRect); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& aColor); sl@0: virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: protected: sl@0: virtual void Shadow(TRgb& aColor); sl@0: void ShadowBuffer(TInt aLength,TUint32* aBuffer); sl@0: TUint8 ShadowAndFade(TInt aGray256); sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawEightBppBitmapColor) : public CDrawEightBppBitmapCommon sl@0: { sl@0: public: sl@0: ~CDrawEightBppBitmapColor(); sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual TInt SetCustomPalette(const CPalette* aPalette); sl@0: virtual TInt GetCustomPalette(CPalette*& aPalette); sl@0: virtual void ShadowArea(const TRect& aRect); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& aColor); sl@0: virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: protected: sl@0: TUint8 ColorToIndex(TRgb aColor) const; sl@0: TRgb IndexToColor(TInt aIndex) const; sl@0: virtual void Shadow(TRgb& aColor); sl@0: void ShadowBuffer(TInt aLength,TUint32* aBuffer); sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: protected: sl@0: TRgb* iPalette; sl@0: TUint8* iColor4KIndex; sl@0: TUint8* iShadowIndex; sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawSixteenBppBitmapCommon) : public CDrawBitmap, public MFastBlit2 sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: virtual void InvertBuffer(TInt aLength,TUint32* aBuffer); sl@0: virtual void ShadowArea(const TRect& aRect); sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor); sl@0: virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint16 aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint16 aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TUint16 aColor,TBool aUp); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface); sl@0: // From MFastBlit2 sl@0: virtual TInt WriteBitmapBlock(const TPoint& aDest, sl@0: CFbsDrawDevice* aSrcDrawDevice, sl@0: const TRect& aSrcRect); sl@0: virtual TInt WriteBitmapBlock(const TPoint& aDest, sl@0: const TUint32* aSrcBase, sl@0: TInt aSrcStride, sl@0: const TSize& aSrcSize, sl@0: const TRect& aSrcRect); sl@0: virtual const TUint32* Bits() const; sl@0: protected: sl@0: virtual void SetSize(const TSize& aSize); sl@0: TUint16* PixelAddress(TInt aX,TInt aY) const; sl@0: virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const; sl@0: virtual TUint16 ShadowIndex(TUint16 aColor64KIndex) = 0; sl@0: virtual TUint16 FadeIndex(TUint16 aColor4KIndex) = 0; sl@0: void ShadowBuffer(TInt aLength,TUint32* aBuffer); sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawTwelveBppBitmap) : public CDrawSixteenBppBitmapCommon sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& aColor); sl@0: virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: protected: sl@0: virtual void Shadow(TRgb& aColor); sl@0: virtual TUint16 ShadowIndex(TUint16 aColor4KIndex); sl@0: virtual TUint16 FadeIndex(TUint16 aColor4KIndex); sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawSixteenBppBitmap) : public CDrawSixteenBppBitmapCommon sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& aColor); sl@0: FORCEINLINE void MapColorToUserDisplayMode(TUint16& aColor64K); sl@0: virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: virtual void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: protected: sl@0: virtual void Shadow(TRgb& aColor); sl@0: FORCEINLINE void Shadow(TInt& aRed, TInt& aGreen, TInt& aBlue); sl@0: FORCEINLINE void Shadow(TUint16& a64KColor); sl@0: virtual TUint16 ShadowIndex(TUint16 aColor64KIndex); sl@0: FORCEINLINE void ShadowIndex(TInt& aRed, TInt& aGreen, TInt& aBlue); sl@0: virtual TUint16 FadeIndex(TUint16 aColor64KIndex); sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawTwentyFourBppBitmap) : public CDrawBitmap sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: virtual void Shadow(TRgb& aColor); sl@0: virtual void InvertBuffer(TInt aLength,TUint32* aBuffer); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual void ShadowArea(const TRect& aRect); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& aColor); sl@0: virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: void BlendRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: protected: sl@0: virtual void SetSize(const TSize& aSize); sl@0: TUint8* PixelAddress(TInt aX,TInt aY) const; sl@0: TInt PixelAddressIncrement() const; sl@0: void PixelAddressIncrement(TInt& aPixelInc,TInt& aRowInc) const; sl@0: void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const; sl@0: void ShadowBuffer(TInt aLength,TUint32* aBuffer); sl@0: TUint8 ShadowComponent(TInt aRgbComponent); sl@0: TUint8 FadeComponent(TInt aRgbComponent); sl@0: TUint8 ShadowAndFade(TInt aComponent); sl@0: private: sl@0: FORCEINLINE void FadeRgb(TInt& red,TInt& green,TInt& blue); sl@0: FORCEINLINE void Shadow(TInt& red,TInt& green,TInt& blue); sl@0: FORCEINLINE TUint8 ShadowComponentInl(TInt aRgbComponent); sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: protected: sl@0: TInt iScanLineBytes; sl@0: }; sl@0: sl@0: inline TUint8* CDrawTwentyFourBppBitmap::PixelAddress(TInt aX,TInt aY) const sl@0: { sl@0: return ((TUint8*)iBits) + (aY * iScanLineBytes) + (aX * 3); sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawThirtyTwoBppBitmapCommon) : public CDrawBitmap, public MFastBlit2 sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: virtual void Shadow(TRgb& aColor); sl@0: virtual void Shadow(TUint32& aColor); sl@0: virtual void InvertBuffer(TInt aLength,TUint32* aBuffer); sl@0: virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const; sl@0: virtual void ShadowArea(const TRect& aRect); sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode); sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: virtual void MapColorToUserDisplayMode(TRgb& aColor); sl@0: virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface); sl@0: // From MFastBlit2 sl@0: virtual TInt WriteBitmapBlock(const TPoint& aDest, sl@0: CFbsDrawDevice* aSrcDrawDevice, sl@0: const TRect& aSrcRect); sl@0: virtual TInt WriteBitmapBlock(const TPoint& aDest, sl@0: const TUint32* aSrcBase, sl@0: TInt aSrcStride, sl@0: const TSize& aSrcSize, sl@0: const TRect& aSrcRect); sl@0: virtual const TUint32* Bits() const; sl@0: protected: sl@0: virtual TUint32 Color(const TRgb& aColor) = 0; sl@0: virtual TRgb RgbColor(TUint32 aColor) const = 0; sl@0: virtual void SetSize(const TSize& aSize); sl@0: FORCEINLINE TUint32* PixelAddress(TInt aX,TInt aY) const; sl@0: FORCEINLINE TInt PixelAddressIncrement() const; sl@0: void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const; sl@0: void ShadowBuffer(TInt aLength,TUint32* aBuffer); sl@0: FORCEINLINE TUint8 ShadowComponent(TInt aRgbComponent); sl@0: TUint8 FadeComponent(TInt aRgbComponent); sl@0: TUint8 ShadowAndFade(TInt aComponent); sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: }; sl@0: sl@0: FORCEINLINE TUint32* CDrawThirtyTwoBppBitmapCommon::PixelAddress(TInt aX,TInt aY) const sl@0: { sl@0: return iBits + aY * iScanLineWords + aX; sl@0: } sl@0: sl@0: FORCEINLINE TInt CDrawThirtyTwoBppBitmapCommon::PixelAddressIncrement() const sl@0: { sl@0: switch (iOrientation) sl@0: { sl@0: case EOrientationNormal: sl@0: return 1; sl@0: case EOrientationRotated90: sl@0: return iScanLineWords; sl@0: case EOrientationRotated180: sl@0: return -1; sl@0: case EOrientationRotated270: sl@0: return -iScanLineWords; sl@0: default: sl@0: return 1; sl@0: } sl@0: } sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: NONSHARABLE_CLASS(CDrawUTwentyFourBppBitmap) : public CDrawThirtyTwoBppBitmapCommon, MFastBlit sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: virtual TDisplayMode ScanLineDisplayMode() const { return EColor16MAP; } sl@0: virtual void ReadLine(TInt aX, TInt aY, TInt aLength, TAny* aBuffer, TDisplayMode aDispMode) const; sl@0: virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface); sl@0: // From MFastBlit sl@0: virtual void WriteAlphaLineEx(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: TInt aSrcX, sl@0: const TUint32* aSrcPtr, sl@0: TDisplayMode aSrcFormat, sl@0: TInt aMaskX, sl@0: const TUint32* aMaskPtr, sl@0: MAlphaBlend::TShadowing aShadowing); sl@0: virtual void WriteMaskLineEx(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: TInt aSrcX, sl@0: const TUint32* aSrcPtr, sl@0: TDisplayMode aSrcFormat, sl@0: TInt aMaskX, sl@0: const TUint32* aMaskPtr, sl@0: TBool aInvertMask); sl@0: void BlendRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor); sl@0: void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: protected: sl@0: virtual TUint32 Color(const TRgb& aColor); sl@0: virtual TRgb RgbColor(TUint32 aColor) const; sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: class CDrawThirtyTwoBppBitmapAlpha : public CDrawThirtyTwoBppBitmapCommon sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: // from CDrawThirtyTwoBppBitmap sl@0: void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer); sl@0: void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: void ShadowArea(const TRect& aRect); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: protected: sl@0: virtual TUint32 Color(const TRgb& aColor); sl@0: virtual TRgb RgbColor(TUint32 aColor) const; sl@0: using CDrawThirtyTwoBppBitmapCommon::Shadow; sl@0: void Shadow(TUint32& aColor); sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: */ sl@0: class CDrawThirtyTwoBppBitmapAlphaPM : public CDrawThirtyTwoBppBitmapCommon sl@0: { sl@0: public: sl@0: TInt Construct(TSize aSize); sl@0: TInt Construct(TSize aSize, TInt aStride); sl@0: // from CDrawThirtyTwoBppBitmap sl@0: void WriteRgb(TInt aX,TInt aY,TRgb aColor); sl@0: void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor); sl@0: void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp); sl@0: void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer); sl@0: void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor); sl@0: void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer); sl@0: void ShadowArea(const TRect& aRect); sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: // From MOutlineAndShadowBlend sl@0: virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, sl@0: TUint32 aOutlinePenColor, TUint32 aShadowColor, sl@0: TUint32 aFillColor, const TUint8* aDataBuffer); sl@0: protected: sl@0: virtual TUint32 Color(const TRgb& aColor); sl@0: virtual TRgb RgbColor(TUint32 aColor) const; sl@0: private: sl@0: virtual void WriteRgbAlphaLine(TInt aX, sl@0: TInt aY, sl@0: TInt aLength, sl@0: const TUint8* aRgbBuffer, sl@0: const TUint8* aMaskBuffer, sl@0: MAlphaBlend::TShadowing aShadowing, sl@0: CGraphicsContext::TDrawMode aDrawMode); sl@0: }; sl@0: sl@0: sl@0: sl@0: #include "CoordTransformation.inl" sl@0: sl@0: /** DO NOT have a declaration as the compiler will think the source is in the .cpp and make this non-inline sl@0: sl@0: Made a global inline to force the compiler to inline so as to gain performance. sl@0: A member inlines are not guarenteed to be inline. sl@0: sl@0: ASSERT Primary Color >= 0 && Primary Color <= 255 sl@0: If <0 or >255, after a shift right of 8-bits should prove true. sl@0: 00000001 00000000 = 256 >> 8 = 00000000 00000001 = TRUE sl@0: 11111111 11111111 = -1 >> 8 = 00000000 11111111 = TRUE sl@0: 00000000 11111111 = 255 >> 8 = 00000000 00000000 = FALSE sl@0: sl@0: sl@0: Initial AlphaValue = 0...1.0 sl@0: sl@0: R = APs + (1 - A)Pd ...so if A=0 the destination pixel is more dominant sl@0: and if A=1 the sourec pixel is more dominant sl@0: sl@0: re-adjusting... sl@0: sl@0: R = APs + Pd - APd sl@0: sl@0: R = A(Ps-Pd) + Pd sl@0: sl@0: Passed-in AlphaValue = 0...255 sl@0: AlphaValue = 257 * Passed-in AlphaValue = 0...65536 sl@0: sl@0: NOTE: AlphaValue is now a 16-bit number. the colours are 8-bit, so we shouldn't sl@0: have overflow problems. sl@0: NOTE: Negative values (Ps-Pd) shouldn't be a problem as the shifting right of sl@0: signed values duplicates the signed bit in the msb. sl@0: sl@0: R = A(Ps-Pd) + Pd sl@0: -------- sl@0: 65536 sl@0: sl@0: R = (A(Ps-Pd)) >> 16) + Pd sl@0: */ sl@0: inline TRgb AlphaBlend(TInt aPrimaryRed, TInt aPrimaryGreen, TInt aPrimaryBlue, TInt aSecondaryRed, sl@0: TInt aSecondaryGreen, TInt aSecondaryBlue, TInt aAlphaValue) sl@0: { sl@0: __ASSERT_DEBUG(!(aPrimaryRed>>8) && !(aPrimaryGreen>>8) && !(aPrimaryBlue>>8) && !(aAlphaValue>>8) && sl@0: !(aSecondaryRed>>8) && !(aSecondaryGreen>>8) && !(aSecondaryBlue>>8), sl@0: Panic(EScreenDriverPanicAlphaBlendInvariant)); sl@0: sl@0: const TInt alphaValue = aAlphaValue * 257; sl@0: return TRgb(((alphaValue * (aPrimaryRed - aSecondaryRed)) >> 16) + aSecondaryRed, sl@0: ((alphaValue * (aPrimaryGreen - aSecondaryGreen)) >> 16) + aSecondaryGreen, sl@0: ((alphaValue * (aPrimaryBlue - aSecondaryBlue)) >> 16) + aSecondaryBlue); sl@0: } sl@0: sl@0: inline TRgb AlphaBlend(TInt aPrimaryRed,TInt aPrimaryGreen,TInt aPrimaryBlue,TRgb aSecondary,TInt aAlphaValue) sl@0: { sl@0: return AlphaBlend(aPrimaryRed,aPrimaryGreen,aPrimaryBlue,aSecondary.Red(), aSecondary.Green(), aSecondary.Blue(), aAlphaValue); sl@0: } sl@0: sl@0: /** sl@0: It unpacks the 16 bit colour in to the red, green and blue colour components. sl@0: @param aColor64K The 16 bit colour which needs to be unpacked. sl@0: @param aRed Red component of aColor64K is returned into this. sl@0: @param aGreen Green component of aColor64K is returned into this. sl@0: @param aBlue Blue component of aColor64K is returned into this. sl@0: */ sl@0: FORCEINLINE void UnpackColor64K(TUint16 aColor64K, TInt& aRed, TInt& aGreen, TInt& aBlue) sl@0: { sl@0: aRed = (aColor64K&0xF800)>>8; sl@0: aRed += aRed>>5; sl@0: aGreen = (aColor64K&0x07E0)>>3; sl@0: aGreen += aGreen>>6; sl@0: aBlue = (aColor64K&0x001F)<<3; sl@0: aBlue += aBlue>>5; sl@0: } sl@0: sl@0: /** sl@0: It creates the 16 bit colour from the red, green and blue colour components. sl@0: @param aRed The Red component for creating 16 bit colour. sl@0: @param aGreen The Green component for creating 16 bit colour. sl@0: @param aBlue The Blue component for creating 16 bit colour. sl@0: @return TUint16 The 16 bit colour created from the colour components. sl@0: */ sl@0: FORCEINLINE TUint16 PackColor64K(TInt aRed, TInt aGreen, TInt aBlue) sl@0: { sl@0: TUint16 color64K = (aBlue & 0xF8) >> 3; sl@0: color64K |= (aGreen & 0xFc) << 3; sl@0: color64K |= (aRed & 0xF8) << 8; sl@0: return color64K; sl@0: } sl@0: sl@0: /** sl@0: It is an overloaded function for alpha bending which does blending for 16 bit colour. sl@0: @param aPrimaryColor64K The foreground pixel colour in 16 bit format. sl@0: @param aSecondaryColor64K The background pixel colour in 16 bit format. sl@0: @param aAlphaValue The alpha value used for blending. sl@0: @return The 16 bit blended colour. sl@0: */ sl@0: FORCEINLINE TUint16 AlphaBlend(TUint16 aPrimaryColor64K, TUint16 aSecondaryColor64K,TInt aAlphaValue) sl@0: { sl@0: TInt primaryRed; sl@0: TInt primaryGreen; sl@0: TInt primaryBlue; sl@0: TInt secondaryRed; sl@0: TInt secondaryGreen; sl@0: TInt secondaryBlue; sl@0: sl@0: UnpackColor64K(aPrimaryColor64K, primaryRed, primaryGreen, primaryBlue); sl@0: UnpackColor64K(aSecondaryColor64K, secondaryRed, secondaryGreen, secondaryBlue); sl@0: sl@0: __ASSERT_DEBUG(!(primaryRed>>8) && !(primaryGreen>>8) && !(primaryBlue>>8) && !(aAlphaValue>>8), sl@0: Panic(EScreenDriverPanicAlphaBlendInvariant)); sl@0: sl@0: const TInt alphaValue = aAlphaValue * 257; sl@0: return PackColor64K(((alphaValue * (primaryRed - secondaryRed)) >> 16) + secondaryRed, sl@0: ((alphaValue * (primaryGreen - secondaryGreen)) >> 16) + secondaryGreen, sl@0: ((alphaValue * (primaryBlue - secondaryBlue)) >> 16) + secondaryBlue); sl@0: } sl@0: sl@0: /** sl@0: It is an overloaded function for alpha bending which does blending for 16 bit colour. sl@0: @param aPrimaryRed Red component of foreground pixel colour. sl@0: @param aPrimaryGreen Green component of foreground pixel colour. sl@0: @param aPrimaryBlue Blue component of foreground pixel colour. sl@0: @param aSecondaryColor64K The background pixel colour in 16 bit format. sl@0: @param aAlphaValue The alpha value used for blending. sl@0: @return The 16 bit blended colour. sl@0: */ sl@0: FORCEINLINE TUint16 AlphaBlend(TInt aPrimaryRed,TInt aPrimaryGreen,TInt aPrimaryBlue, TUint16 aSecondaryColor64K,TInt aAlphaValue) sl@0: { sl@0: __ASSERT_DEBUG(!(aPrimaryRed>>8) && !(aPrimaryGreen>>8) && !(aPrimaryBlue>>8) && !(aAlphaValue>>8), sl@0: Panic(EScreenDriverPanicAlphaBlendInvariant)); sl@0: sl@0: if (aAlphaValue==0xFF) sl@0: return(PackColor64K(aPrimaryRed, aPrimaryGreen, aPrimaryBlue)); sl@0: TInt secondaryRed; sl@0: TInt secondaryGreen; sl@0: TInt secondaryBlue; sl@0: sl@0: UnpackColor64K(aSecondaryColor64K, secondaryRed, secondaryGreen, secondaryBlue); sl@0: sl@0: const TInt alphaValue = aAlphaValue * 257; sl@0: return PackColor64K(((alphaValue * (aPrimaryRed - secondaryRed)) >> 16) + secondaryRed, sl@0: ((alphaValue * (aPrimaryGreen - secondaryGreen)) >> 16) + secondaryGreen, sl@0: ((alphaValue * (aPrimaryBlue - secondaryBlue)) >> 16) + secondaryBlue); sl@0: } sl@0: sl@0: FORCEINLINE LOCAL_C TUint16 Conv32To16(TUint32 col) sl@0: { sl@0: TUint b = (col&0x000000ff)>>3; sl@0: TUint g = (col&0x0000fc00)>>5; sl@0: TUint r = (col&0x00f80000)>>8; sl@0: return TUint16(r|g|b); sl@0: } sl@0: sl@0: // Alpha-blends an EColor16MA pixel to an EColor64K screen using a fixed mask value. sl@0: FORCEINLINE LOCAL_C TUint16 Blend32To16(TUint32 aSrc32, TUint aMask, TUint16 aDest16) sl@0: { sl@0: __ASSERT_DEBUG(aMask < 256, Panic(EScreenDriverPanicInvalidParameter)); sl@0: sl@0: if(aMask) sl@0: { sl@0: if(aMask >= 0xFF) sl@0: return Conv32To16(aSrc32); sl@0: sl@0: // blend red and blue channel in one go sl@0: TUint32 d_rb = (aDest16 & 0xF800)<<8 | (aDest16 & 0x001F)<<3; sl@0: d_rb |= (d_rb>>5) & 0x00ff00ff; sl@0: const TUint32 s_rb = aSrc32 & 0x00FF00FF; sl@0: const TUint32 mask2 = aMask | (aMask << 16); sl@0: const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; sl@0: sl@0: // do the green channel normally sl@0: TInt32 d_g = (aDest16 & 0x07E0)>>3; sl@0: d_g |= d_g>>6; sl@0: const TInt32 s_g = (aSrc32 & 0xFF00) >> 8; sl@0: TInt g = (((aMask * (s_g - d_g)) >> 8) + d_g) & 0xFF; sl@0: sl@0: return (Conv32To16(rb | g<<8)); sl@0: } sl@0: sl@0: return aDest16; sl@0: } sl@0: sl@0: // As for Blend32To16, but assumes 0xFF and 0 alpha checks already done elsewhere sl@0: FORCEINLINE LOCAL_C TUint16 Blend32To16NoChecks(TUint32 aSrc32, TUint aMask, TUint16 aDest16) sl@0: { sl@0: // blend red and blue channel in one go sl@0: TUint32 d_rb = (aDest16 & 0xF800)<<8 | (aDest16 & 0x001F)<<3; sl@0: d_rb |= (d_rb>>5) & 0x00ff00ff; sl@0: const TUint32 s_rb = aSrc32 & 0x00FF00FF; sl@0: const TUint32 mask2 = aMask | (aMask << 16); sl@0: const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; sl@0: sl@0: // do the green channel normally sl@0: TInt32 d_g = (aDest16 & 0x07E0)>>3; sl@0: d_g |= d_g>>6; sl@0: const TInt32 s_g = (aSrc32 & 0xFF00) >> 8; sl@0: TInt g = (((aMask * (s_g - d_g)) >> 8) + d_g) & 0xFF; sl@0: sl@0: return (Conv32To16(rb | g<<8)); sl@0: } sl@0: sl@0: // Alpha-blends to an EColor64K screen using a fixed mask value. sl@0: // The source values are pre-split from a 32 bit source into the two following components: sl@0: // sl@0: // aSrcRB=aSrc32 & 0x00FF00FF; sl@0: // aSrcG=(aSrc32 & 0xFF00) >> 8; sl@0: // sl@0: // Mask is assumed not to be 0 or 255, these should be pre-checked for and never arrive here sl@0: // sl@0: FORCEINLINE LOCAL_C TUint16 BlendTo16(const TUint32 aSrcRB, const TUint32 aSrcG, TUint aMask, TUint16 aDest16) sl@0: { sl@0: // blend red and blue channel in one go sl@0: TUint32 d_rb = (aDest16 & 0xF800)<<8 | (aDest16 & 0x001F)<<3; sl@0: d_rb |= (d_rb>>5) & 0x00ff00ff; sl@0: const TUint32 mask2 = aMask | (aMask << 16); sl@0: const TUint32 rb = ((((aMask * ((0x01000100 + aSrcRB) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; sl@0: sl@0: // do the green channel normally sl@0: TInt32 d_g = (aDest16 & 0x07E0)>>3; sl@0: d_g |= d_g>>6; sl@0: const TInt32 g = (((aMask * (aSrcG - d_g)) >> 8) + d_g) & 0xFF; sl@0: sl@0: // inline conversion to 16 bit sl@0: return TUint16(((rb&0x00f80000)>>8)|((g&0x0000fc)<<3)|((rb&0x000000ff)>>3)); sl@0: } sl@0: sl@0: // Alpha-blends an EColor16MA pixel to an EColor16MU screen using a fixed mask value. sl@0: FORCEINLINE LOCAL_C TUint32 CalcAlphaPixel(const TUint32 aSrcPixel, const TUint8 aMask, TUint32 aDestPixel) sl@0: { sl@0: // (a) (mask * src + (255 - mask) * dest) / 255 This ideal formula sl@0: // (b) ((mask * (src - dest)) >> 8) + dest A faster approximation to (a) sl@0: // (c) ((mask * (256 + src - dest) >> 8) + dest - mask Equivalent to (b) but can be used on multiple colors at a time sl@0: sl@0: if(aMask) sl@0: { sl@0: if(aMask == 0xFF) sl@0: return 0xff000000|aSrcPixel; sl@0: sl@0: const TUint32 s_rb = aSrcPixel & 0x00FF00FF; sl@0: const TUint32 d_rb = aDestPixel & 0x00FF00FF; sl@0: const TUint32 mask2 = aMask | (aMask << 16); sl@0: const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; sl@0: sl@0: const TInt s_g = (aSrcPixel & 0xFF00) >> 8; sl@0: const TInt d_g = (aDestPixel & 0xFF00) >> 8; sl@0: const TInt g = ((aMask * (s_g - d_g)) >> 8) + d_g; sl@0: sl@0: return(rb | (g<<8) | 0xff000000); sl@0: } sl@0: sl@0: return aDestPixel; sl@0: sl@0: } sl@0: sl@0: // Alpha-blends an EColor16MA rgb to an EColor16MU screen using a fixed mask value. sl@0: FORCEINLINE LOCAL_C void AlphaBlendPixelToDest(TUint32 aSrcValue, const TUint8 aSourceAlpha, TUint32* aDestPtr) sl@0: { sl@0: *aDestPtr = CalcAlphaPixel(aSrcValue, aSourceAlpha, *aDestPtr); sl@0: } sl@0: sl@0: void MemFillTUint32(TUint32* tempWordPtr, TInt aCount, const TUint32 aValue); sl@0: sl@0: #endif sl@0: