1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsdeviceinterface/screendriver/inc/BmAlphaBlend.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,317 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __BMALPHABLEND_H__
1.20 +#define __BMALPHABLEND_H__
1.21 +
1.22 +/**
1.23 +MAlphaBlend interface provides only one method, which does an alpha blending using the
1.24 +supplied as arguments source and mask bitmap scanline data and writes the result to
1.25 +the screen. The content of the source and mask bitmap scanlines is preserved.
1.26 +@internalComponent
1.27 +*/
1.28 +class MAlphaBlend
1.29 + {
1.30 +public:
1.31 + /**
1.32 + TShadowing enum values are used in alpha blending implementations to specify when
1.33 + the shadowing/fading has to be done: before or after tha alpha blending.
1.34 + @internalComponent
1.35 + */
1.36 + enum TShadowing
1.37 + {
1.38 + EShdwBefore,
1.39 + EShdwAfter
1.40 + };
1.41 +
1.42 + /**
1.43 + The method performs an alpha blending of the source data - aRgbBuffer and the screen
1.44 + pixels, using the data from aMaskBuffer buffer as an alpha blending factor.
1.45 + The formula used for that, is:
1.46 + (C1 * A + C2 * (255 - A)) / 255, where:
1.47 + - C1 - a pixel from aRgbBuffer1;
1.48 + - C2 - a pixel from screen;
1.49 + - A - a pixel from aMaskBuffer;
1.50 + The content of source and mask buffers is preserved.
1.51 + The calculated alpha blended pixel is written to the destination - the screen or a bitmap.
1.52 + @param aX Logical X coordinate of the position in the target the result should be drawn to.
1.53 + @param aY Logical Y coordinate of the position in the target the result should be drawn to.
1.54 + @param aLength Source data - length in pixels.
1.55 + @param aRgbBuffer A pointer to a line of the source bitmap data.
1.56 + @param aMaskBuffer Buffer containing the data which should be used as an
1.57 + alpha blending factor.
1.58 + @param aShadowing It says when the shadowing/fading has to be done - before or after the
1.59 + alpha blending transformation.
1.60 + Before: A shadow/fade copy of the source bitmap will be used.
1.61 + After: The result pixels will be shadowed/faded.
1.62 + @param aDrawMode The mode for rendering the source image to the destination.
1.63 + */
1.64 + virtual void WriteRgbAlphaLine(TInt aX,
1.65 + TInt aY,
1.66 + TInt aLength,
1.67 + const TUint8* aRgbBuffer,
1.68 + const TUint8* aMaskBuffer,
1.69 + TShadowing aShadowing,
1.70 + CGraphicsContext::TDrawMode aDrawMode) = 0;
1.71 + };
1.72 +
1.73 +
1.74 +/**
1.75 +MFastBlit provides optimised blitting for a number of special cases. It is similar to
1.76 +MAlphaBlend except that instead of taking generic buffers as parameters, it takes pointers
1.77 +to scanlines in their native format.
1.78 +@internalTechnology
1.79 +*/
1.80 +class MFastBlit
1.81 + {
1.82 +public:
1.83 + /**
1.84 + Performs Alpha blending.Acceptable source formats are EColor64K and EColor16MU.
1.85 + Mask format must be EGray256.
1.86 + @param aX Logical X coordinate of the position in the target the result should be drawn to.
1.87 + @param aY Logical Y coordinate of the position in the target the result should be drawn to.
1.88 + @param aLength Source data - length in pixels.
1.89 + @param aSrcX X coordinate of the position of the first pixel in the source bitmap to use.
1.90 + @param aSrcPtr Pointer to the start of the current scanline of the source bitmap.
1.91 + @param aSrcFormat Pixel format of the source bitmap.
1.92 + @param aMaskX X coordinate of the position of the first pixel in the mask to use.
1.93 + @param aMaskPtr Pointer to the start of the current scanline of the mask bitmap.
1.94 + @param aShadowing It says when the shadowing/fading has to be done - before or after the
1.95 + alpha blending transformation.
1.96 + Before: A shadow/fade copy of the source bitmap will be used.
1.97 + After: The result pixels will be shadowed/faded.
1.98 + */
1.99 + virtual void WriteAlphaLineEx( TInt aX,
1.100 + TInt aY,
1.101 + TInt aLength,
1.102 + TInt aSrcX,
1.103 + const TUint32* aSrcPtr,
1.104 + TDisplayMode aSrcFormat,
1.105 + TInt aMaskX,
1.106 + const TUint32* aMaskPtr,
1.107 + MAlphaBlend::TShadowing aShadowing) = 0;
1.108 +
1.109 + /**
1.110 + Performs masked blitting. Acceptable source formats are EColor64K and EColor16MU.
1.111 + Mask format must be EGray2.
1.112 + @param aX Logical X coordinate of the position in the target the result should be drawn to.
1.113 + @param aY Logical Y coordinate of the position in the target the result should be drawn to.
1.114 + @param aLength Source data - length in pixels.
1.115 + @param aSrcX X coordinate of the position of the first pixel in the source bitmap to use.
1.116 + @param aSrcPtr Pointer to the start of the current scanline of the source bitmap.
1.117 + @param aSrcFormat Pixel format of the source bitmap.
1.118 + @param aMaskX X coordinate of the position of the first pixel in the mask to use.
1.119 + @param aMaskPtr Pointer to the start of the current scanline of the mask bitmap.
1.120 + @param aInvertMask Specifies if the mask shuld be inverted.
1.121 + */
1.122 + virtual void WriteMaskLineEx( TInt aX,
1.123 + TInt aY,
1.124 + TInt aLength,
1.125 + TInt aSrcX,
1.126 + const TUint32* aSrcPtr,
1.127 + TDisplayMode aSrcFormat,
1.128 + TInt aMaskX,
1.129 + const TUint32* aMaskPtr,
1.130 + TBool aInvertMask) = 0;
1.131 +
1.132 + };
1.133 +
1.134 +
1.135 +
1.136 +/**
1.137 +MFastBlit2 provides optimised blitting for a number of special cases.
1.138 +It is used for basic blitting where source and destination pixel formats match.
1.139 +@internalTechnology
1.140 +*/
1.141 +class MFastBlit2
1.142 + {
1.143 +public:
1.144 + /**
1.145 + Performs basic blitting.
1.146 + Source and destination pixel formats must match.
1.147 + Assumes that aSrcRect is contained by the source device.
1.148 + Assumes that the resulting destination rectangle is contained by the destination device.
1.149 + @param aDest Logical coordinates of the position in the target that the result should be drawn to.
1.150 + @param aSrcDrawDevice Draw device that will act as the source of the blit.
1.151 + @param aSrcRect The rectangular region of the source to be blitted.
1.152 + @return KErrNone unless an error occurs in which case no blitting occurs and a standard error code is returned.
1.153 + */
1.154 + virtual TInt WriteBitmapBlock(const TPoint& aDest,
1.155 + CFbsDrawDevice* aSrcDrawDevice,
1.156 + const TRect& aSrcRect) = 0;
1.157 +
1.158 + /**
1.159 + Performs basic blitting.
1.160 + Source and destination pixel formats must match.
1.161 + Assumes that aSrcRect is contained by the source device.
1.162 + Assumes that the resulting destination rectangle is contained by the destination device.
1.163 + @param aDest Logical coordinates of the position in the target that the result should be drawn to.
1.164 + @param aSrcBase Base address of the source bitmap.
1.165 + @param aSrcStride Length in bytes between scanlines of the source bitmap.
1.166 + @param aSrcSize Size of the source bitmap in pixels.
1.167 + @param aSrcRect The rectangular region of the source to be blitted.
1.168 + @return KErrNone unless an error occurs in which case no blitting occurs and a standard error code is returned.
1.169 + */
1.170 + virtual TInt WriteBitmapBlock(const TPoint& aDest,
1.171 + const TUint32* aSrcBase,
1.172 + TInt aSrcStride,
1.173 + const TSize& aSrcSize,
1.174 + const TRect& aSrcRect) = 0;
1.175 + /**
1.176 + Returns a pointer to the first pixel.
1.177 + @return a pointer to the first pixel.
1.178 + */
1.179 + virtual const TUint32* Bits() const = 0;
1.180 + };
1.181 +
1.182 +/**
1.183 +MOutlineAndShadowBlend provides blending of outline pen, shadow, fill and the background colour.
1.184 +It is used to draw the fonts with outline and shadow effects.
1.185 +@internalTechnology
1.186 +*/
1.187 +class MOutlineAndShadowBlend
1.188 + {
1.189 + public:
1.190 + /**
1.191 + Performs blending of outline, shadow, fill and background colours and draws to the
1.192 + screen. It uses pen colour as outline colour, brush colour as fill colour and pixel
1.193 + colour as background colour. Transparency is supported for modes higher than EColor256,
1.194 + alpha value of pen colour is used for same in these modes and other modes ignore this
1.195 + value.
1.196 + @param aX Logical X coordinate of the start of the line.
1.197 + @param aY Logical Y coordinate of the line.
1.198 + @param aLength Length in pixels to modify.
1.199 + @param aOutlinePenColor Outline pen colour of the font.
1.200 + @param aShadowColor Shadow colour of the font.
1.201 + @param aFillColor Fill colour of the font.
1.202 + @param aDataBuffer Buffer containing the data.
1.203 + @return KErrNone if it is successful, otherwise a standard error code is returned.
1.204 + */
1.205 + virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
1.206 + TUint32 aOutlinePenColor, TUint32 aShadowColor,
1.207 + TUint32 aFillColor, const TUint8* aDataBuffer) = 0;
1.208 + };
1.209 +
1.210 +class MFastBlend
1.211 + {
1.212 +public:
1.213 + /**
1.214 + Performs blended blitting.
1.215 + The interface can selectively supports various combinations of source and destination.
1.216 + Assumes that aSrcRect is contained by the source device.
1.217 + Assumes that the resulting destination rectangle is contained by the destination device.
1.218 + @param aDest Logical coordinates of the position in the target that the result should be drawn to.
1.219 + @param aSrcDrawDevice Draw device that will act as the source of the blit.
1.220 + @param aSrcRect The rectangular region of the source to be blitted.
1.221 + @param aDrawMode Current draw mode
1.222 + @param aShadowMode Current shadow mode
1.223 + @return if display modes supported KErrNone, else KErrNotSupported.
1.224 + */
1.225 + virtual TInt FastBlendBitmap(const TPoint& aDest,
1.226 + CFbsDrawDevice* aSrcDrawDevice,
1.227 + const TRect& aSrcRect,
1.228 + CGraphicsContext::TDrawMode aDrawMode,
1.229 + TInt aShadowMode) = 0;
1.230 + /**
1.231 + Performs blended blitting.
1.232 + The interface can selectively supports various combinations of source and destination.
1.233 + Assumes that aSrcRect is contained by the source device.
1.234 + Assumes that the resulting destination rectangle is contained by the destination device.
1.235 + @param aDest Logical coordinates of the position in the target that the result should be drawn to.
1.236 + @param aSrcBase Base address of the source bitmap.
1.237 + @param aSrcStride Length in bytes between scanlines of the source bitmap.
1.238 + @param aSrcSize Size of the source bitmap in pixels.
1.239 + @param aSrcRect The rectangular region of the source to be blitted.
1.240 + @param aSrcDisplayMode Display mode of the source bitmap
1.241 + @param aDrawMode Current draw mode
1.242 + @param aShadowMode Current shadow mode
1.243 + @return if display modes supported KErrNone, else KErrNotSupported.
1.244 + */
1.245 + virtual TInt FastBlendBitmap(const TPoint& aDest,const TUint32* aSrcBase,TInt aSrcStride,
1.246 + const TSize& aSrcSize,const TRect& aSrcRect,TDisplayMode aSrcDisplayMode,
1.247 + CGraphicsContext::TDrawMode aDrawMode,TInt aShadowMode) = 0;
1.248 + /**
1.249 + Performs blended blitting.
1.250 + The interface can selectively supports various combinations of source and destination.
1.251 + Assumes that aSrcRect is contained by the source device.
1.252 + Assumes that the resulting destination rectangle is contained by the destination device.
1.253 + @param aDest Logical coordinates of the position in the target that the result should be drawn to.
1.254 + @param aSrcBase Base address of the source bitmap.
1.255 + @param aSrcStride Length in bytes between scanlines of the source bitmap.
1.256 + @param aSrcSize Size of the source bitmap in pixels.
1.257 + @param aSrcRect The rectangular region of the source to be blitted.
1.258 + @param aSrcDisplayMode Display mode of the source bitmap
1.259 + @param aMaskBase Base address of the source bitmap.
1.260 + @param aMaskStride Length in bytes between scanlines of the source bitmap.
1.261 + @param aMaskDisplayMode Display mode of the source bitmap
1.262 + @param aMaskSize Size of the source bitmap in pixels.
1.263 + @param aInvertMask If true invert the logic of an EGray2 mask
1.264 + @param aDrawMode Current draw mode
1.265 + @param aShadowMode Current shadow mode
1.266 + @return if display modes supported KErrNone, else KErrNotSupported.
1.267 + */
1.268 + virtual TInt FastBlendBitmapMasked(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride,
1.269 + const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aSrcDisplayMode,
1.270 + const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,const TPoint &aMaskSrcPos, TBool aInvertMask,
1.271 + CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)=0;
1.272 + /**
1.273 + Performs scaled blended blitting.
1.274 + The interface can selectively supports various combinations of source and destination.
1.275 + Assumes that aClipRect is contained by the source device.
1.276 + Assumes that the resulting destination rectangle is contained by the destination device.
1.277 + @param aClipRect The target rectangle to clip drawing to
1.278 + @param aDest Logical coordinates of the position in the target that the result should be drawn to.
1.279 + @param aSrcRect Source rectangle
1.280 + @param aSrcBase Base address of the source bitmap.
1.281 + @param aSrcStride Length in bytes between scanlines of the source bitmap.
1.282 + @param aSrcDisplayMode Display mode of the source bitmap
1.283 + @param aSrcSize Size of the source bitmap in pixels.
1.284 + @param aDrawMode Current draw mode
1.285 + @param aShadowMode Current shadow mode
1.286 + @return if display modes supported KErrNone, else KErrNotSupported.
1.287 + */
1.288 + virtual TInt FastBlendBitmapScaled(const TRect &aClipRect, const TRect& aDest,
1.289 + const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcStride,
1.290 + TDisplayMode aSrcDisplayMode, const TSize &aSrcSize,
1.291 + CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode) = 0;
1.292 + /**
1.293 + Performs scaled blended blitting.
1.294 + The interface can selectively supports various combinations of source and destination.
1.295 + Assumes that aClipRect is contained by the source device.
1.296 + Assumes that the resulting destination rectangle is contained by the destination device.
1.297 + @param aClipRect The target rectangle to clip drawing to
1.298 + @param aDest Logical coordinates of the position in the target that the result should be drawn to.
1.299 + @param aSrcRect Source rectangle
1.300 + @param aSrcBase Base address of the source bitmap.
1.301 + @param aSrcStride Length in bytes between scanlines of the source bitmap.
1.302 + @param aSrcDisplayMode Display mode of the source bitmap
1.303 + @param aSrcSize Size of the source bitmap in pixels.
1.304 + @param aMaskBase Base address of the source bitmap.
1.305 + @param aMaskStride Length in bytes between scanlines of the source bitmap.
1.306 + @param aMaskDisplayMode Display mode of the source bitmap
1.307 + @param aMaskSize Size of the source bitmap in pixels.
1.308 + @param aInvertMask If true invert the logic of an EGray2 mask
1.309 + @param aDrawMode Current draw mode
1.310 + @param aShadowMode Current shadow mode
1.311 + @return if display modes supported KErrNone, else KErrNotSupported.
1.312 + */
1.313 + virtual TInt FastBlendBitmapMaskedScaled(const TRect &aClipRect, const TRect& aDest,
1.314 + const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcStride,
1.315 + TDisplayMode aSrcDisplayMode, const TSize &aSrcSize,
1.316 + const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,TBool aInvertMask,
1.317 + CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode) = 0;
1.318 + };
1.319 +
1.320 +#endif//__BMALPHABLEND_H__