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 __BITDRAW_H__ sl@0: #define __BITDRAW_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: enum TScreenDriverPanic sl@0: { sl@0: EScreenDriverPanicNoDevicePresent=1, sl@0: EScreenDriverPanicInvalidParameter, sl@0: EScreenDriverPanicInvalidDisplayMode, sl@0: EScreenDriverPanicInvalidWindowHandle, sl@0: EScreenDriverPanicOutOfBounds, sl@0: EScreenDriverPanicZeroLength, sl@0: EScreenDriverPanicNullPointer, sl@0: EScreenDriverPanicInvalidPointer, sl@0: EScreenDriverPanicAlphaBlendInvariant, sl@0: EScreenDriverPanicIvalidMethodCall, sl@0: EScreenDriverPanicInvalidSize, sl@0: EScreenDriverPanicInvalidHalValue, sl@0: EScreenDriverPanicInvalidScreenNo, sl@0: EScreenDriverPanicIncompatiblePreviousDevice //0 and <= 32) sl@0: @param aHeight Height of the rectangle (== number of entries in aBuffer) sl@0: @param aColor Colour to combine with the existing pixel data sl@0: @param aDrawMode Combination function for source and destination pixels. sl@0: @panic EScreenDriverPanicOutOfBounds If any part of the rectangle maps to an illegal physical coordinate sl@0: or if aLength > 32. sl@0: @panic EScreenDriverPanicNullPointer If aBuffer == NULL sl@0: @panic EScreenDriverPanicZeroLength If aLength <= 0 sl@0: */ sl@0: virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode) = 0; sl@0: sl@0: /** sl@0: Combines the current content of the device/bitmap with a supplied colour, based on a bitmask and sl@0: a draw mode. This function differs from WriteBinary, in that aLength can be greater than 32, and sl@0: the height is implicitly 1. aBuffer must contain sufficient elements to hold aLength bits sl@0: If the shadowing/fading flag is set, the resulting pixels will be shadowed/faded. sl@0: @param aX Starting X coordinate (logical coordinates) sl@0: @param aY Starting Y coordinate (logical coordinates) sl@0: @param aBuffer Array of bitmasks sl@0: @param aLength Number of pixels sl@0: @param aColor Colour to combine with existing pixels sl@0: @param aDrawMode Combination function for source and destination pixels. sl@0: @panic EScreenDriverPanicOutOfBounds If any part of the line maps to an illegal physical coordinate sl@0: @panic EScreenDriverPanicNullPointer If aBuffer == NULL sl@0: @panic EScreenDriverPanicZeroLength If aLength <= 0 sl@0: @see WriteBinary sl@0: */ sl@0: virtual void WriteBinaryLine(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode) = 0; sl@0: sl@0: /** sl@0: Similar to WriteBinaryLine, but writes a vertical, rather than a horizontal line. LIne is drawn upward sl@0: (decreasing Y) if aUp == ETrue. sl@0: @see WriteBinaryLine sl@0: */ sl@0: virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode,TBool aUp) = 0; sl@0: sl@0: /** sl@0: Write the given colour to the location [aX,aY], combining it with the existing pixel sl@0: using aDrawMode sl@0: If the shadowing/fading flag is set, the resulting pixels will be shadowed/faded. sl@0: @param aX X coordinate (logical coordinates) sl@0: @param aY Y coordinate (logical coordinates) sl@0: @param aColor Colour to write sl@0: @param aDrawMode Combination function for source and destination pixels. sl@0: @panic EScreenDriverPanicOutOfBounds If [aX,aY] maps to an illegal physical address sl@0: */ sl@0: virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode) = 0; sl@0: sl@0: /** sl@0: Write the given colour to the rectangle [aX,aY] - [aX+aLength,aY+aHeight], combining it sl@0: with the exiasting pixels using aDrawMode sl@0: If the shadowing/fading flag is set, the resulting pixels will be shadowed/faded. sl@0: @param aX X coordinate (logical coordinates) sl@0: @param aY Y coordinate (logical coordinates) sl@0: @param aLength Width of the rectangle (logical coordinates) sl@0: @param aHeight Height of the rectangle (logical coordinates) sl@0: @param aColor Colour to write sl@0: @param aDrawMode Combination function for source and destination pixels. sl@0: @panic EScreenDriverPanicOutOfBounds If any part of the rectangle maps to an illegal physical address sl@0: */ sl@0: virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode) = 0; sl@0: sl@0: /** sl@0: The method performs an alpha blending of the source data - aRgbBuffer and screen pixels, using sl@0: the data from aMaskBuffer buffer as an alpha blending factor. sl@0: The formula used for that, is: sl@0: (C1 * A + C2 * (255 - A)) / 255, where: sl@0: - C1 - a pixel from aRgbBuffer; sl@0: - C2 - a pixel from the sceen; sl@0: - A - a pixel from aMaskBuffer; sl@0: The content of source and mask buffers is preserved. sl@0: The calculated alpha blended pixel is written to the destination - the screen or a bitmap. sl@0: If the shadowing/fading flag is set, a shadow/fade copy of the source bitmap will be used. sl@0: @param aX Logical X coordinate of the start of the line. sl@0: @param aY Logical Y coordinate of the line. sl@0: @param aLength Source data - length in pixels. sl@0: @param aRgbBuffer A pointer to a line of the source bitmap data. sl@0: Must be in ERgb format. sl@0: @param aMaskBuffer Buffer containing the data which should be used as an sl@0: alpha blending factor. Must be in EGray256 format. sl@0: @param aDrawMode Combination function for source and destination pixels. sl@0: @panic EScreenDriverPanicOutOfBounds If any part of the line maps to an illegal physical address sl@0: */ sl@0: virtual void WriteRgbAlphaLine(TInt aX,TInt aY,TInt aLength,TUint8* aRgbBuffer,TUint8* aMaskBuffer, CGraphicsContext::TDrawMode aDrawMode) = 0; sl@0: sl@0: /** sl@0: Combine the data in aBuffer with existing pixels along the line [aX,aY]-[aX+aLength,aY], sl@0: using aDrawMode as the combining function. sl@0: If the shadowing/fading flag is set, the resulting pixels will be shadowed/faded. sl@0: @param aX Logical X coordinate of the start of the line. sl@0: @param aY Logical Y coordinate of the line. sl@0: @param aLength Source data - length in pixels. sl@0: @param aBuffer Source data. Must be in the format returned by ScanLineDisplayMode(). sl@0: @param aDrawMode Combination function for source and destination pixels. sl@0: @panic EScreenDriverPanicOutOfBounds If any part of the line maps to an illegal physical address sl@0: */ sl@0: virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer,CGraphicsContext::TDrawMode aDrawMode) = 0; sl@0: public: sl@0: sl@0: /** sl@0: Do any necessary initialisation on screen devices (default applies to bitmaps) sl@0: @return Success/failure code sl@0: */ sl@0: virtual TInt InitScreen() {return(KErrNone);} sl@0: sl@0: /** Sets or unsets auto-update for the screen. sl@0: sl@0: @param aValue ETrue, if the screen is set to auto-update; EFalse, otherwise. sl@0: */ sl@0: virtual void SetAutoUpdate(TBool aValue) {(void) aValue;} // To avoid compiler warning for unused parameter sl@0: sl@0: /** sl@0: Set the internal data buffer to point to the supplied buffer. No checks are made that the buffer sl@0: is appropriate for the purpose. Ownership is not taken. sl@0: @param aBits A buffer of sufficient size. sl@0: */ sl@0: virtual void SetBits(TAny*) {} sl@0: sl@0: /** sl@0: Set up a custom palette for those bit formats that support palettised colour sl@0: @param aPalette Palette to use sl@0: @return Success/failure code sl@0: */ sl@0: virtual TInt SetCustomPalette(const CPalette*) { return KErrNotSupported; } sl@0: sl@0: /** sl@0: Retrieve a custom palette, if the bit format supports it. sl@0: @param aPalette Pointer to a CPalette. The palette will be created by this function. sl@0: @return Success/failure code sl@0: */ sl@0: virtual TInt GetCustomPalette(CPalette*&) { return KErrNotSupported; } sl@0: sl@0: /** sl@0: Copies all settings (scaling, orientation, etc.) from the supplied device sl@0: and reinitialised the current device. sl@0: @param aDrawDevice Device to get settings from sl@0: */ sl@0: virtual void SetDisplayMode(CFbsDrawDevice*) {} sl@0: sl@0: /** sl@0: Set the origin point of the dither matrix (if appropriate) sl@0: @param aPoint Dither origin (logical coordiantes) sl@0: */ sl@0: virtual void SetDitherOrigin(const TPoint&) {} sl@0: sl@0: /** sl@0: Sets the user display mode - used for certain colour mapping functions sl@0: */ sl@0: virtual void SetUserDisplayMode(TDisplayMode) {} sl@0: sl@0: /** sl@0: Sets the current shadowing mode sl@0: @see TShadowMode sl@0: */ sl@0: virtual void SetShadowMode(TShadowMode) {} sl@0: sl@0: /** sl@0: Set the current fading parameters sl@0: @param aBlackMap Black point sl@0: @param aWhiteMap White point sl@0: */ sl@0: virtual void SetFadingParameters(TUint8 /*aBlackMap*/,TUint8 /*aWhiteMap*/) {} sl@0: sl@0: /** sl@0: Apply shadow processing to all the pixels in the supplied rectangle sl@0: @param aRect Area to apply shadow processing to (logical coordinates) sl@0: @panic EScreenDriverPanicOutOfBounds If any part of the rectangle maps to an illegal physical address sl@0: */ sl@0: virtual void ShadowArea(const TRect&) {} // Obeys shadow mode sl@0: sl@0: /** sl@0: Applies shadow processing to the supplied buffer sl@0: @param aLength Length of buffer in pixels sl@0: @param aBuffer Buffer to process in the format returned by ScanLineDisplayMode() sl@0: @panic EScreenDriverPanicZeroLength If aLength <= 0 sl@0: @panic EScreenDriverPanicNullPointer If aBuffer == NULL sl@0: */ sl@0: virtual void ShadowBuffer(TInt,TUint32*) {} // Obeys shadow mode sl@0: sl@0: /** sl@0: Update the screen with the update region. sl@0: */ sl@0: virtual void Update() {} sl@0: sl@0: /** sl@0: Update the screen with the union of the update and specified regions. sl@0: @param aRegion Region to update (logical coordinates) sl@0: */ sl@0: virtual void Update(const TRegion&) {} sl@0: sl@0: /** sl@0: Update the update region. sl@0: @param aRegion Region to update (logical coordinates) sl@0: */ sl@0: virtual void UpdateRegion(const TRect&) {} sl@0: public: sl@0: sl@0: /** sl@0: Blend aColor with the pixels along the line [aX,aY]-[aX+aLength,aY], using aMaskBuffer sl@0: as alpha data sl@0: If the shadowing/fading flag is set, a shadow/fade copy of the source bitmap will be used. sl@0: @param aX Logical X coordinate of the start of the line sl@0: @param aY Logical Y coordinate of the line. sl@0: @param aLength Length of line to modify sl@0: @param aColor Colour to blend with existing pixels sl@0: @param aMaskBuffer Buffer containing the data which should be used as an sl@0: alpha blending factor. sl@0: @panic EScreenDriverPanicOutOfBounds If any part of the line maps to an illegal physical address sl@0: */ sl@0: virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer) = 0; sl@0: sl@0: /** sl@0: The method performs an alpha blending of the source data - aRgbBuffer1 and aBuffer2, using sl@0: the data from aMaskBuffer buffer as an alpha blending factor. sl@0: If the shadowing/fading flag is set, the resulting pixels will be shadowed/faded. sl@0: The formula used for that, is: sl@0: (C1 * A + C2 * (255 - A)) / 255, where: sl@0: - C1 - a pixel from aRgbBuffer1; sl@0: - C2 - a pixel from aBuffer2; sl@0: - A - a pixel from aMaskBuffer; sl@0: The content of source and mask buffers is preserved. sl@0: The calculated alpha blended pixel is written to the destination - the screen or a bitmap. sl@0: If the shadowing/fading flag is set, the resulting pixels will be shadowed/faded. sl@0: @param aX Logical X coordinate of the position in the target the result should be drawn to. sl@0: @param aY Logical Y coordinate of the position in the target the result should be drawn to. sl@0: @param aLength Source data - length in pixels. sl@0: @param aRgbBuffer1 A pointer to a line of the source bitmap data 1. sl@0: Must be in ERgb format. sl@0: @param aBuffer2 A pointer to a line of the source bitmap data 2. sl@0: Must be in the format returned by ScanLineDisplayMode(). sl@0: @param aMaskBuffer Buffer containing the data which should be used as an sl@0: alpha blending factor. Must be in EGray256 format. sl@0: @param aDrawMode Drawing mode sl@0: */ 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) = 0; sl@0: /** sl@0: Retrieves a pointer to the specified CFbsDrawDevice interface extension. sl@0: @param aInterfaceId Interface identifier of the interface to be retrieved. sl@0: @param aInterface Address of pointer variable that retrieves the specified interface. sl@0: @return KErrNone If the interface is supported, KErrNotSupported otherwise. sl@0: @see BitDrawInterfaceId.h file for the IDs of supported interfaces sl@0: */ sl@0: virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface) = 0; sl@0: sl@0: /** sl@0: Gets logical coordinates of the drawing rectangle. sl@0: If the device is not scaled and with zero origin, logocal coordinates of sl@0: the drawing rectangle are the same as its physical coordinates. sl@0: If the device is rotated, drawing rectangle width and height are swapped. sl@0: Always prefer GetDrawRect() to SizeInPixels() call. SizeInPixels() will return sl@0: drawing rectangle width and height. But if the device is scaled or with nonzero origin, sl@0: GetDrawRect() will take into account and the top-left corner of the drawing rectangle too, sl@0: which may not be [0, 0]. sl@0: @param aDrawRect Upon return aRect contains drawing rectangle logical coordinates. sl@0: */ sl@0: virtual void GetDrawRect(TRect& aDrawRect) const = 0; sl@0: sl@0: /** sl@0: The method swaps bitmap device's width and height. sl@0: For example: if the size is (40, 20), the swapped size will be (20, 40). sl@0: The device's content is not preserved. sl@0: The method leaves CDrawBitmap object in a consistent state - sl@0: scaling settings will be set with their default values (the scaling is switched off), sl@0: iDitherOrigin will be set to (0,0), iOrigin to (0,0). sl@0: Note: This method is used internally by BITGDI component. Do not call it! sl@0: */ sl@0: virtual void SwapWidthAndHeight() = 0; sl@0: }; sl@0: sl@0: #endif sl@0: