graphicsdeviceinterface/screendriver/inc/BmAlphaBlend.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __BMALPHABLEND_H__
       
    17 #define __BMALPHABLEND_H__
       
    18 
       
    19 /**
       
    20 MAlphaBlend interface provides only one method, which does an alpha blending using the 
       
    21 supplied as arguments source and mask bitmap scanline data and writes the result to 
       
    22 the screen. The content of the source and mask bitmap scanlines is preserved.
       
    23 @internalComponent
       
    24 */
       
    25 class MAlphaBlend
       
    26     {
       
    27 public:
       
    28     /**
       
    29     TShadowing enum values are used in alpha blending implementations to specify when
       
    30     the shadowing/fading has to be done: before or after tha alpha blending.
       
    31     @internalComponent
       
    32     */
       
    33     enum TShadowing
       
    34         {
       
    35         EShdwBefore,
       
    36         EShdwAfter
       
    37         };
       
    38 
       
    39     /**
       
    40     The method performs an alpha blending of the source data - aRgbBuffer and the screen 
       
    41     pixels, using the data from aMaskBuffer buffer as an alpha blending factor.
       
    42     The formula used for that, is:
       
    43     (C1 * A + C2 * (255 - A)) / 255, where:
       
    44     - C1 - a pixel from aRgbBuffer1;
       
    45     - C2 - a pixel from screen;
       
    46     - A  - a pixel from aMaskBuffer;
       
    47     The content of source and mask buffers is preserved.
       
    48     The calculated alpha blended pixel is written to the destination - the screen or a bitmap.
       
    49     @param aX Logical X coordinate of the position in the target the result should be drawn to.
       
    50     @param aY Logical Y coordinate of the position in the target the result should be drawn to.
       
    51     @param aLength Source data - length in pixels.
       
    52     @param aRgbBuffer A pointer to a line of the source bitmap data.
       
    53     @param aMaskBuffer Buffer containing the data which should be used as an 
       
    54                        alpha blending factor.
       
    55     @param aShadowing It says when the shadowing/fading has to be done - before or after the
       
    56                       alpha blending transformation.
       
    57                       Before: A shadow/fade copy of the source bitmap will be used.
       
    58                       After: The result pixels will be shadowed/faded.
       
    59     @param aDrawMode	The mode for rendering the source image to the destination.
       
    60     */
       
    61 	virtual void WriteRgbAlphaLine(TInt aX,
       
    62                                    TInt aY,
       
    63                                    TInt aLength,
       
    64                                    const TUint8* aRgbBuffer,
       
    65                                    const TUint8* aMaskBuffer,
       
    66                                    TShadowing aShadowing,
       
    67                                    CGraphicsContext::TDrawMode aDrawMode) = 0;
       
    68     };
       
    69 
       
    70 
       
    71 /**
       
    72 MFastBlit provides optimised blitting for a number of special cases.  It is similar to
       
    73 MAlphaBlend except that instead of taking generic buffers as parameters, it takes pointers
       
    74 to scanlines in their native format.
       
    75 @internalTechnology
       
    76 */
       
    77 class MFastBlit
       
    78 	{
       
    79 public:
       
    80 	/**
       
    81 	Performs Alpha blending.Acceptable source formats are EColor64K and EColor16MU.
       
    82 	Mask format must be EGray256.
       
    83 	@param aX Logical X coordinate of the position in the target the result should be drawn to.
       
    84 	@param aY Logical Y coordinate of the position in the target the result should be drawn to.
       
    85 	@param aLength Source data - length in pixels.
       
    86 	@param aSrcX X coordinate of the position of the first pixel in the source bitmap to use.
       
    87 	@param aSrcPtr Pointer to the start of the current scanline of the source bitmap.
       
    88 	@param aSrcFormat Pixel format of the source bitmap.
       
    89 	@param aMaskX X coordinate of the position of the first pixel in the mask to use.
       
    90 	@param aMaskPtr Pointer to the start of the current scanline of the mask bitmap.
       
    91 	@param aShadowing It says when the shadowing/fading has to be done - before or after the
       
    92                       alpha blending transformation.
       
    93                       Before: A shadow/fade copy of the source bitmap will be used.
       
    94                       After: The result pixels will be shadowed/faded.
       
    95 	*/
       
    96 	virtual void WriteAlphaLineEx(	TInt aX,
       
    97 									TInt aY,
       
    98 									TInt aLength, 
       
    99 									TInt aSrcX,
       
   100 									const TUint32* aSrcPtr,
       
   101 									TDisplayMode aSrcFormat,
       
   102 									TInt aMaskX,
       
   103 									const TUint32* aMaskPtr,
       
   104 									MAlphaBlend::TShadowing aShadowing) = 0;
       
   105 
       
   106 	/**
       
   107 	Performs masked blitting.  Acceptable source formats are EColor64K and EColor16MU.
       
   108 	Mask format must be EGray2.
       
   109 	@param aX Logical X coordinate of the position in the target the result should be drawn to.
       
   110 	@param aY Logical Y coordinate of the position in the target the result should be drawn to.
       
   111 	@param aLength Source data - length in pixels.
       
   112 	@param aSrcX X coordinate of the position of the first pixel in the source bitmap to use.
       
   113 	@param aSrcPtr Pointer to the start of the current scanline of the source bitmap.
       
   114 	@param aSrcFormat Pixel format of the source bitmap.
       
   115 	@param aMaskX X coordinate of the position of the first pixel in the mask to use.
       
   116 	@param aMaskPtr Pointer to the start of the current scanline of the mask bitmap.
       
   117 	@param aInvertMask Specifies if the mask shuld be inverted.
       
   118 	*/				
       
   119 	virtual void WriteMaskLineEx(	TInt aX,
       
   120 									TInt aY,
       
   121 									TInt aLength, 
       
   122 									TInt aSrcX,
       
   123 									const TUint32* aSrcPtr,
       
   124 									TDisplayMode aSrcFormat,
       
   125 									TInt aMaskX,
       
   126 									const TUint32* aMaskPtr,
       
   127 									TBool aInvertMask) = 0;
       
   128 
       
   129 	};
       
   130 
       
   131 
       
   132 
       
   133 /**
       
   134 MFastBlit2 provides optimised blitting for a number of special cases.
       
   135 It is used for basic blitting where source and destination pixel formats match.
       
   136 @internalTechnology
       
   137 */
       
   138 class MFastBlit2
       
   139 	{
       
   140 public:
       
   141 	/**
       
   142 	Performs basic blitting.
       
   143 	Source and destination pixel formats must match.
       
   144 	Assumes that aSrcRect is contained by the source device.
       
   145 	Assumes that the resulting destination rectangle is contained by the destination device.
       
   146 	@param aDest           Logical coordinates of the position in the target that the result should be drawn to.
       
   147 	@param aSrcDrawDevice  Draw device that will act as the source of the blit.
       
   148 	@param aSrcRect        The rectangular region of the source to be blitted.
       
   149 	@return                KErrNone unless an error occurs in which case no blitting occurs and a standard error code is returned.
       
   150 	*/
       
   151 	virtual TInt WriteBitmapBlock(const TPoint& aDest,
       
   152 	                              CFbsDrawDevice* aSrcDrawDevice,
       
   153 	                              const TRect& aSrcRect) = 0;
       
   154 	                              
       
   155 	/**
       
   156 	Performs basic blitting.
       
   157 	Source and destination pixel formats must match.
       
   158 	Assumes that aSrcRect is contained by the source device.
       
   159 	Assumes that the resulting destination rectangle is contained by the destination device.
       
   160 	@param aDest       Logical coordinates of the position in the target that the result should be drawn to.
       
   161 	@param aSrcBase    Base address of the source bitmap.
       
   162 	@param aSrcStride  Length in bytes between scanlines of the source bitmap.
       
   163 	@param aSrcSize    Size of the source bitmap in pixels.
       
   164 	@param aSrcRect    The rectangular region of the source to be blitted.
       
   165 	@return            KErrNone unless an error occurs in which case no blitting occurs and a standard error code is returned.
       
   166 	*/				
       
   167 	virtual TInt WriteBitmapBlock(const TPoint& aDest,
       
   168 	                              const TUint32* aSrcBase,
       
   169 	                              TInt aSrcStride,
       
   170 	                              const TSize& aSrcSize,
       
   171 	                              const TRect& aSrcRect) = 0;
       
   172 	/**
       
   173 	Returns a pointer to the first pixel.
       
   174 	@return a pointer to the first pixel.
       
   175 	*/				
       
   176 	virtual const TUint32* Bits() const = 0;
       
   177 	};
       
   178 
       
   179 /**
       
   180 MOutlineAndShadowBlend provides blending of outline pen, shadow, fill and the background colour.
       
   181 It is used to draw the fonts with outline and shadow effects.
       
   182 @internalTechnology
       
   183 */
       
   184 class MOutlineAndShadowBlend
       
   185 	{
       
   186 	public:
       
   187 		/**
       
   188 		Performs blending of outline, shadow, fill and background colours and draws to the 
       
   189 		screen. It uses pen colour as outline colour, brush colour as fill colour and pixel
       
   190 		colour as background colour. Transparency is supported for modes higher than EColor256,
       
   191 		alpha value of pen colour is used for same in these modes and other modes ignore this 
       
   192 		value.
       
   193 		@param aX Logical X coordinate of the start of the line.
       
   194 		@param aY Logical Y coordinate of the line.
       
   195 		@param aLength Length in pixels to modify.
       
   196 		@param aOutlinePenColor	Outline pen colour of the font.
       
   197 		@param aShadowColor Shadow colour of the font.
       
   198 		@param aFillColor Fill colour of the font.
       
   199 		@param aDataBuffer Buffer containing the data.
       
   200 		@return	KErrNone if it is successful, otherwise a standard error code is returned.
       
   201 		*/
       
   202 		virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, 
       
   203 		                                   TUint32 aOutlinePenColor, TUint32 aShadowColor, 
       
   204 		                                   TUint32 aFillColor, const TUint8* aDataBuffer) = 0;
       
   205 	};
       
   206 
       
   207 class MFastBlend
       
   208 	{
       
   209 public:
       
   210 	/**
       
   211 	Performs blended blitting.
       
   212 	The interface can selectively supports various combinations of source and destination.
       
   213 	Assumes that aSrcRect is contained by the source device.
       
   214 	Assumes that the resulting destination rectangle is contained by the destination device.
       
   215 	@param aDest           Logical coordinates of the position in the target that the result should be drawn to.
       
   216 	@param aSrcDrawDevice  Draw device that will act as the source of the blit.
       
   217 	@param aSrcRect        The rectangular region of the source to be blitted.
       
   218 	@param aDrawMode	Current draw mode
       
   219 	@param aShadowMode	Current shadow mode
       
   220 	@return                if display modes supported KErrNone, else KErrNotSupported.
       
   221 	*/
       
   222 	virtual TInt FastBlendBitmap(const TPoint& aDest,
       
   223 	                              CFbsDrawDevice* aSrcDrawDevice,
       
   224 	                              const TRect& aSrcRect,
       
   225 	                              CGraphicsContext::TDrawMode aDrawMode,
       
   226 	                              TInt aShadowMode) = 0;
       
   227 	/**
       
   228 	Performs blended blitting.
       
   229 	The interface can selectively supports various combinations of source and destination.
       
   230 	Assumes that aSrcRect is contained by the source device.
       
   231 	Assumes that the resulting destination rectangle is contained by the destination device.
       
   232 	@param aDest		Logical coordinates of the position in the target that the result should be drawn to.
       
   233 	@param aSrcBase		Base address of the source bitmap.
       
   234 	@param aSrcStride	Length in bytes between scanlines of the source bitmap.
       
   235 	@param aSrcSize		Size of the source bitmap in pixels.
       
   236 	@param aSrcRect		The rectangular region of the source to be blitted.
       
   237 	@param aSrcDisplayMode Display mode of the source bitmap
       
   238 	@param aDrawMode	Current draw mode
       
   239 	@param aShadowMode	Current shadow mode
       
   240 	@return				if display modes supported KErrNone, else KErrNotSupported.
       
   241 	*/
       
   242 	virtual TInt FastBlendBitmap(const TPoint& aDest,const TUint32* aSrcBase,TInt aSrcStride,
       
   243 	                              const TSize& aSrcSize,const TRect& aSrcRect,TDisplayMode aSrcDisplayMode,
       
   244 	                              CGraphicsContext::TDrawMode aDrawMode,TInt aShadowMode) = 0;
       
   245 	/**
       
   246 	Performs blended blitting.
       
   247 	The interface can selectively supports various combinations of source and destination.
       
   248 	Assumes that aSrcRect is contained by the source device.
       
   249 	Assumes that the resulting destination rectangle is contained by the destination device.
       
   250 	@param aDest		Logical coordinates of the position in the target that the result should be drawn to.
       
   251 	@param aSrcBase		Base address of the source bitmap.
       
   252 	@param aSrcStride	Length in bytes between scanlines of the source bitmap.
       
   253 	@param aSrcSize		Size of the source bitmap in pixels.
       
   254 	@param aSrcRect		The rectangular region of the source to be blitted.
       
   255 	@param aSrcDisplayMode Display mode of the source bitmap
       
   256 	@param aMaskBase	Base address of the source bitmap.
       
   257 	@param aMaskStride	Length in bytes between scanlines of the source bitmap.
       
   258 	@param aMaskDisplayMode Display mode of the source bitmap
       
   259 	@param aMaskSize	Size of the source bitmap in pixels.
       
   260 	@param aInvertMask	If true invert the logic of an EGray2 mask
       
   261 	@param aDrawMode	Current draw mode
       
   262 	@param aShadowMode	Current shadow mode
       
   263 	@return				if display modes supported KErrNone, else KErrNotSupported.
       
   264 	*/
       
   265 	virtual TInt FastBlendBitmapMasked(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride,
       
   266 							const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aSrcDisplayMode,
       
   267 							const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,const TPoint &aMaskSrcPos, TBool aInvertMask,
       
   268 							CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)=0;
       
   269 	/**
       
   270 	Performs scaled blended blitting.
       
   271 	The interface can selectively supports various combinations of source and destination.
       
   272 	Assumes that aClipRect is contained by the source device.
       
   273 	Assumes that the resulting destination rectangle is contained by the destination device.
       
   274 	@param aClipRect	The target rectangle to clip drawing to
       
   275 	@param aDest		Logical coordinates of the position in the target that the result should be drawn to.
       
   276 	@param aSrcRect		Source rectangle
       
   277 	@param aSrcBase		Base address of the source bitmap.
       
   278 	@param aSrcStride	Length in bytes between scanlines of the source bitmap.
       
   279 	@param aSrcDisplayMode Display mode of the source bitmap
       
   280 	@param aSrcSize		Size of the source bitmap in pixels.
       
   281 	@param aDrawMode	Current draw mode
       
   282 	@param aShadowMode	Current shadow mode
       
   283 	@return				if display modes supported KErrNone, else KErrNotSupported.
       
   284 	*/
       
   285 	virtual TInt FastBlendBitmapScaled(const TRect &aClipRect, const TRect& aDest,
       
   286 							const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcStride,
       
   287 							TDisplayMode aSrcDisplayMode, const TSize &aSrcSize,
       
   288 							CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode) = 0;
       
   289 	/**
       
   290 	Performs scaled blended blitting.
       
   291 	The interface can selectively supports various combinations of source and destination.
       
   292 	Assumes that aClipRect is contained by the source device.
       
   293 	Assumes that the resulting destination rectangle is contained by the destination device.
       
   294 	@param aClipRect	The target rectangle to clip drawing to
       
   295 	@param aDest		Logical coordinates of the position in the target that the result should be drawn to.
       
   296 	@param aSrcRect		Source rectangle
       
   297 	@param aSrcBase		Base address of the source bitmap.
       
   298 	@param aSrcStride	Length in bytes between scanlines of the source bitmap.
       
   299 	@param aSrcDisplayMode Display mode of the source bitmap
       
   300 	@param aSrcSize		Size of the source bitmap in pixels.
       
   301 	@param aMaskBase	Base address of the source bitmap.
       
   302 	@param aMaskStride	Length in bytes between scanlines of the source bitmap.
       
   303 	@param aMaskDisplayMode Display mode of the source bitmap
       
   304 	@param aMaskSize	Size of the source bitmap in pixels.
       
   305 	@param aInvertMask	If true invert the logic of an EGray2 mask
       
   306 	@param aDrawMode	Current draw mode
       
   307 	@param aShadowMode	Current shadow mode
       
   308 	@return				if display modes supported KErrNone, else KErrNotSupported.
       
   309 	*/
       
   310 	virtual TInt FastBlendBitmapMaskedScaled(const TRect &aClipRect, const TRect& aDest,
       
   311 							const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcStride,
       
   312 							TDisplayMode aSrcDisplayMode, const TSize &aSrcSize,
       
   313 							const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,TBool aInvertMask,
       
   314 							CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode) = 0;
       
   315 	};
       
   316 
       
   317 #endif//__BMALPHABLEND_H__