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