os/graphics/graphicsdeviceinterface/bitgdi/sbit/DRAWBMP.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/bitgdi/sbit/DRAWBMP.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,497 @@
     1.4 +// Copyright (c) 1997-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 +#include <fntstore.h>
    1.20 +#include <bitmap.h>
    1.21 +#include <bitstd.h>
    1.22 +#include <bitdev.h>
    1.23 +#include "BITPANIC.H"
    1.24 +#include <bitdrawinterfaceid.h>
    1.25 +#include <bmalphablend.h>
    1.26 +#include <bitdraw.h>
    1.27 +#include <graphics/fbsrasterizer.h>
    1.28 +#include <graphics/bitmap.inl>
    1.29 +#include <graphics/gdi/gdiinline.inl>
    1.30 +
    1.31 +/**
    1.32 +Draws a bitmap.
    1.33 +
    1.34 +The function has 3 overloads. The first draws the bitmap given the top
    1.35 +left hand corner, doing a compress/stretch based on its internally
    1.36 +stored size in twips. The second does a compress/stretch to fit a
    1.37 +given rectangle. The third takes a rectangular section of the source
    1.38 +bitmap and does a compress/stretch to fit a given destination
    1.39 +rectangle.The functions provide a concrete implementation of the pure
    1.40 +virtual function <code>CGraphicsContext::DrawBitmap()</code>. The
    1.41 +function behaviour is the same as documented in that class.
    1.42 +*/
    1.43 +EXPORT_C void CFbsBitGc::DrawBitmap(const TPoint& aPos,const CFbsBitmap* aSource)
    1.44 +	{
    1.45 +	if (aSource == NULL || !aSource->Handle())
    1.46 +		return;
    1.47 +
    1.48 +	aSource->BeginDataAccess();
    1.49 +	const TSize bitmapTwips = aSource->SizeInTwips();
    1.50 +	if (bitmapTwips.iWidth == 0 || bitmapTwips.iHeight == 0)
    1.51 +		{
    1.52 +		aSource->EndDataAccess(ETrue);
    1.53 +		return;
    1.54 +		}
    1.55 +
    1.56 +	TSize scrpixels;
    1.57 +	scrpixels.iWidth = iDevice->HorizontalTwipsToPixels(bitmapTwips.iWidth);
    1.58 +	scrpixels.iHeight = iDevice->VerticalTwipsToPixels(bitmapTwips.iHeight);
    1.59 +
    1.60 +	DrawBitmap(TRect(aPos, scrpixels), aSource, TRect(aSource->SizeInPixels()));
    1.61 +	aSource->EndDataAccess(ETrue);
    1.62 +	}
    1.63 +
    1.64 +EXPORT_C void CFbsBitGc::DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource)
    1.65 +	{
    1.66 +	if (aSource == NULL || !aSource->Handle())
    1.67 +		return;
    1.68 +
    1.69 +	aSource->BeginDataAccess();
    1.70 +	DrawBitmap(aDestRect, aSource, TRect(aSource->SizeInPixels()));
    1.71 +	aSource->EndDataAccess(ETrue);
    1.72 +	}
    1.73 +
    1.74 +EXPORT_C void CFbsBitGc::DrawBitmap(const TRect& aDestRect,
    1.75 +									const CFbsBitmap* aSource,
    1.76 +									const TRect& aSourceRect)
    1.77 +	{
    1.78 +	if (CheckDevice(aDestRect) || aSourceRect.IsEmpty() || aSource == NULL || !aSource->Handle())
    1.79 +		return;
    1.80 +	
    1.81 +	aSource->BeginDataAccess();
    1.82 +	//aSourceRect should be in the bounds of the bitmap
    1.83 +	TSize bitmapSize(aSource->SizeInPixels());
    1.84 +	if ( aSourceRect.iTl.iX < 0
    1.85 +			|| aSourceRect.iTl.iY < 0
    1.86 +			|| aSourceRect.iBr.iX > bitmapSize.iWidth
    1.87 +			|| aSourceRect.iBr.iY > bitmapSize.iHeight)
    1.88 +		{
    1.89 +		aSource->EndDataAccess(ETrue);
    1.90 +		return;
    1.91 +		}
    1.92 +
    1.93 +	TRect destRect(aDestRect);
    1.94 +	destRect.Move(iOrigin);
    1.95 +	AddRect(destRect);
    1.96 +
    1.97 +	TRect clippedDestRect(destRect);
    1.98 +	if (UserClipRect(clippedDestRect))
    1.99 +		{
   1.100 +		aSource->EndDataAccess(ETrue);
   1.101 +		return;
   1.102 +		}
   1.103 +
   1.104 +	CFbsBitGcBitmap* srce = (CFbsBitGcBitmap*)aSource;
   1.105 +	SetupDevice();
   1.106 +	iDevice->DrawingBegin();
   1.107 +
   1.108 +	CBitwiseBitmap* bmp = srce->Address();
   1.109 +	BG_ASSERT_DEBUG(bmp,EBitgdiPanicInvalidBitmap);
   1.110 +
   1.111 +	CFbsRasterizer* rasterizer = PrepareRasterizerForExtendedBitmap(*aSource, destRect, aSourceRect);
   1.112 +
   1.113 +	const TPoint ditherOrigin(iDitherOrigin + aDestRect.iTl);
   1.114 +
   1.115 +	const TInt limit = iDefaultRegionPtr->Count();
   1.116 +	CGraphicsAccelerator* ga = GraphicsAccelerator();
   1.117 +	if (ga && iShadowMode==CFbsDrawDevice::ENoShadow && iDrawMode==EDrawModePEN)
   1.118 +		{
   1.119 +		TInt gaOperationResult = KErrUnknown;
   1.120 +		TAcceleratedBitmapSpec bitmapSpec(const_cast<CFbsBitmap*>(aSource));
   1.121 +		iDevice->DrawingEnd();
   1.122 +
   1.123 +		if (destRect.Size() == aSourceRect.Size())
   1.124 +			{
   1.125 +			const TPoint offset(aSourceRect.iTl - destRect.iTl);
   1.126 +			for(TInt count=0;count<limit;count++)
   1.127 +				{
   1.128 +				iClipRect=(*iDefaultRegionPtr)[count];
   1.129 +				if(!iClipRect.Intersects(clippedDestRect))
   1.130 +					continue;
   1.131 +				iClipRect.Intersection(clippedDestRect);
   1.132 +
   1.133 +				TRect clippedSrceRect(iClipRect);
   1.134 +				clippedSrceRect.Move(offset);
   1.135 +				gaOperationResult = ga->Operation(TGopBitBlt(iClipRect.iTl,bitmapSpec,clippedSrceRect));
   1.136 +				if (gaOperationResult!=KErrNone)
   1.137 +					break;
   1.138 +				}
   1.139 +			iDevice->iDrawDevice->UpdateRegion(iClipRect);
   1.140 +			}
   1.141 +		else
   1.142 +			{
   1.143 +			RRegion clippedRegion;
   1.144 +			for(TInt clipIt=0;clipIt<limit;clipIt++)
   1.145 +				{
   1.146 +				TRect clipRect((*iDefaultRegionPtr)[clipIt]);
   1.147 +				clipRect.Intersection(clippedDestRect);
   1.148 +				if (!clipRect.IsEmpty())
   1.149 +					clippedRegion.AddRect(clipRect);
   1.150 +				}
   1.151 +			TRect srcCopy(aSourceRect);	// Needed because TGopScaledBitBlt takes a non-const value
   1.152 +			// const_cast needed because Operation takes a non-const region ptr :(
   1.153 +			gaOperationResult = ga->Operation(TGopScaledBitBlt(destRect,bitmapSpec,srcCopy),clippedRegion.Count(),const_cast<TRect*>(clippedRegion.RectangleList()));
   1.154 +			if (gaOperationResult==KErrNone) 	 
   1.155 +				iDevice->iDrawDevice->Update(clippedRegion);
   1.156 +			clippedRegion.Close();
   1.157 +			}
   1.158 +		if(gaOperationResult == KErrNone)
   1.159 +			goto finish;
   1.160 +		iDevice->DrawingBegin();
   1.161 +		
   1.162 +		}
   1.163 +//
   1.164 +	{	// to stop error from gccxml build about previous jump to finish skipping initialisation of opaqueSource 
   1.165 +	const TBool opaqueSource = (!IsAlphaChannel(aSource->DisplayMode())) && (iDrawMode == EDrawModePEN);
   1.166 +	if (opaqueSource)
   1.167 +		{
   1.168 +		iDrawMode = EDrawModeWriteAlpha;
   1.169 +		}
   1.170 +
   1.171 +	for (TInt count = 0; count < limit; count++)
   1.172 +		{
   1.173 +		iClipRect = (*iDefaultRegionPtr)[count];
   1.174 +		if (!iClipRect.Intersects(clippedDestRect))
   1.175 +			continue;
   1.176 +
   1.177 +		iClipRect.Intersection(clippedDestRect);
   1.178 +		DoDrawBitmap(destRect,bmp,aSource->DataAddress(),aSource->DataStride(),aSourceRect,ditherOrigin);
   1.179 +
   1.180 +		iDevice->iDrawDevice->UpdateRegion(iClipRect);
   1.181 +		}
   1.182 +	if (opaqueSource)
   1.183 +		{
   1.184 +		iDrawMode = EDrawModePEN;
   1.185 +		}
   1.186 +
   1.187 +	}
   1.188 +	iDevice->DrawingEnd();
   1.189 +	
   1.190 +finish:
   1.191 +	if (rasterizer)
   1.192 +		{
   1.193 +		rasterizer->EndBitmap(aSource->SerialNumber());
   1.194 +		}
   1.195 +	aSource->EndDataAccess(ETrue);
   1.196 +	}
   1.197 +
   1.198 +
   1.199 +void CFbsBitGc::DoDrawBitmap(const TRect& aDestRect,
   1.200 +							 CBitwiseBitmap* aBitmap,
   1.201 +							 TUint32* aBase,
   1.202 +							 TInt aStride,
   1.203 +							 const TRect& aSrceRect,
   1.204 +							 const TPoint& aDitherOrigin)
   1.205 +	{
   1.206 +	CFbsDrawDevice* drawDevice = iDevice->iDrawDevice;
   1.207 +#ifdef _DEBUG
   1.208 +	TRect deviceDestRect;
   1.209 +	drawDevice->GetDrawRect(deviceDestRect);
   1.210 +#endif
   1.211 +	BG_ASSERT_DEBUG(iClipRect.iTl.iX >= deviceDestRect.iTl.iX, EBitgdiPanicOutOfBounds);
   1.212 +	BG_ASSERT_DEBUG(iClipRect.iTl.iY >= deviceDestRect.iTl.iY, EBitgdiPanicOutOfBounds);
   1.213 +	BG_ASSERT_DEBUG(iClipRect.iBr.iX <= deviceDestRect.iBr.iX, EBitgdiPanicOutOfBounds);
   1.214 +	BG_ASSERT_DEBUG(iClipRect.iBr.iY <= deviceDestRect.iBr.iY, EBitgdiPanicOutOfBounds);
   1.215 +
   1.216 +	if (aDestRect.Size() == aSrceRect.Size())
   1.217 +		{
   1.218 +		TRect clippedRect(aDestRect);
   1.219 +		clippedRect.Intersection(iClipRect);
   1.220 +
   1.221 +		if (!clippedRect.IsEmpty())
   1.222 +			{
   1.223 +			const TPoint destPoint(clippedRect.iTl);
   1.224 +			clippedRect.Move(aSrceRect.iTl - aDestRect.iTl);
   1.225 +			DoBitBlt(destPoint,aBitmap,aBase,aStride,clippedRect);
   1.226 +			}
   1.227 +
   1.228 +		return;
   1.229 +		}
   1.230 +	MFastBlend* fastBlend=NULL;
   1.231 +	if (FastBlendInterface(aBitmap,NULL,fastBlend)==KErrNone)
   1.232 +		{
   1.233 +		if (fastBlend->FastBlendBitmapScaled(iClipRect, aDestRect, aSrceRect, aBase, aStride, aBitmap->DisplayMode(), aBitmap->SizeInPixels(), iDrawMode, iShadowMode)== KErrNone)
   1.234 +			{
   1.235 +			return;
   1.236 +			}
   1.237 +		}
   1.238 +
   1.239 +	TUint32* scanLineBuffer = drawDevice->ScanLineBuffer();
   1.240 +	const TInt scanLineBytes = drawDevice->ScanLineBytes();
   1.241 +	TPtr8 scanLineDes(REINTERPRET_CAST(TUint8*,scanLineBuffer),scanLineBytes,scanLineBytes);
   1.242 +
   1.243 +	// For EColor16MU targets, don't use EColor16MAP when draw mode is EDrawModeWriteAlpha.
   1.244 +	// Format conversion provides no performance gain and WriteLine expects EColor16MU 
   1.245 +	// in this case.
   1.246 +	const TDisplayMode dispMode = drawDevice->DisplayMode() == EColor16MU && iDrawMode == EDrawModeWriteAlpha ? EColor16MU : drawDevice->ScanLineDisplayMode();
   1.247 +
   1.248 +	TLinearDDA xLine;
   1.249 +	TInt bitmapXStart = 0;
   1.250 +	xLine.Construct(TPoint(aSrceRect.iTl.iX,aDestRect.iTl.iX),
   1.251 +					TPoint(aSrceRect.iBr.iX,aDestRect.iBr.iX),TLinearDDA::ELeft);
   1.252 +	xLine.JumpToYCoord(bitmapXStart,iClipRect.iTl.iX);
   1.253 +
   1.254 +	TLinearDDA yLine;
   1.255 +	TPoint yCoord(aSrceRect.iTl.iY,aDestRect.iTl.iY);
   1.256 +	yLine.Construct(yCoord,TPoint(aSrceRect.iBr.iY,aDestRect.iBr.iY),TLinearDDA::ELeft);
   1.257 +	TInt dummy;
   1.258 +	yLine.JumpToYCoord2(dummy,iClipRect.iTl.iY);
   1.259 +	yCoord.SetXY(dummy,iClipRect.iTl.iY);
   1.260 +
   1.261 +	TBool finished = EFalse;
   1.262 +	TPoint ditherOrigin(aDitherOrigin + iClipRect.iTl);
   1.263 +	const TInt srceWidth = aSrceRect.Width();
   1.264 +	const TInt destWidth = aDestRect.Width();
   1.265 +	const TInt clipWidth = iClipRect.Width();
   1.266 +	const TInt clipStrch = iClipRect.iTl.iX - aDestRect.iTl.iX;
   1.267 +
   1.268 +	TLineScanningPosition lineScanPos(aBase);
   1.269 +	while (yCoord.iY < iClipRect.iBr.iY && !finished)
   1.270 +		{
   1.271 +		aBitmap->StretchScanLine(scanLineDes,TPoint(bitmapXStart,yCoord.iX),
   1.272 +								 clipStrch,clipWidth,destWidth,aSrceRect.iTl.iX,
   1.273 +								 srceWidth,ditherOrigin,dispMode,aBase,lineScanPos);
   1.274 +		if (yCoord.iY==iClipRect.iTl.iY)
   1.275 +			aBitmap->SetCompressionBookmark(lineScanPos, aBase,NULL);
   1.276 +		drawDevice->WriteLine(iClipRect.iTl.iX,yCoord.iY,clipWidth, scanLineBuffer,iDrawMode);
   1.277 +		finished = yLine.NextStep(yCoord);
   1.278 +		ditherOrigin.iY++;
   1.279 +		}
   1.280 +	}
   1.281 +
   1.282 +/** The method draws a specified rectangle from a bitmap and
   1.283 +its mask into another rectangle and does a compress/stretch
   1.284 +to fit a given destination rectangle.
   1.285 +
   1.286 +@note When using this function with a 256 Mask bitmap, it blends.
   1.287 +Otherwise (e.g. with a 4bpp mask), this function masks rather than blends.
   1.288 +If a user wants to blend the source into the destination they should use
   1.289 +CFbsBitGc::AlphaBlendBitmaps() instead.
   1.290 +
   1.291 +@publishedAll
   1.292 +@released
   1.293 +
   1.294 +@param aDestRect The rectangle within which the masked bitmap is to be drawn.
   1.295 +@param aBitmap A pointer to the source bitmap.
   1.296 +@param aSourceRect The rectangle in the source bitmap that is copied to the
   1.297 +destination rectangle.
   1.298 +@param aMaskBitmap A pointer to the mask bitmap.
   1.299 +@param aInvertMask If false, a source pixel that is masked by a black pixel
   1.300 +is not transferred to the destination rectangle. If true, then a source pixel
   1.301 +that is masked by a white pixel is not transferred to the destination rectangle.
   1.302 +
   1.303 +@pre aBitmap != NULL
   1.304 +@pre aBitmap->Handle() != 0
   1.305 +@pre aMaskBitmap != NULL
   1.306 +@pre aMaskBitmap->Handle() != 0
   1.307 +@pre !aSourceRect.IsEmpty()
   1.308 +@pre aSourceRect should be in the bounds of the bitmap
   1.309 +*/
   1.310 +EXPORT_C void CFbsBitGc::DrawBitmapMasked(const TRect& aDestRect,
   1.311 +						 const CFbsBitmap* aBitmap,
   1.312 +						 const TRect& aSourceRect,
   1.313 +						 const CFbsBitmap* aMaskBitmap,
   1.314 +						 TBool aInvertMask)
   1.315 +	{
   1.316 +	if (aBitmap == NULL || !aBitmap->Handle() || aMaskBitmap == NULL ||
   1.317 +		!aMaskBitmap->Handle() || aSourceRect.IsEmpty() || CheckDevice(aDestRect))
   1.318 +		{
   1.319 +		return;
   1.320 +		}
   1.321 +	
   1.322 +	aBitmap->BeginDataAccess();
   1.323 +	aMaskBitmap->BeginDataAccess();
   1.324 +	
   1.325 +	//aSourceRect should be in the bounds of the bitmap
   1.326 +	TSize bitmapSize(aBitmap->SizeInPixels());
   1.327 +	if ( aSourceRect.iTl.iX < 0
   1.328 +			|| aSourceRect.iTl.iY < 0
   1.329 +			|| aSourceRect.iBr.iX > bitmapSize.iWidth
   1.330 +			|| aSourceRect.iBr.iY > bitmapSize.iHeight)
   1.331 +		{
   1.332 +		aBitmap->EndDataAccess(ETrue);
   1.333 +		aMaskBitmap->EndDataAccess(ETrue);
   1.334 +		return;
   1.335 +		}   		
   1.336 +	
   1.337 +	TRect destRect(aDestRect);
   1.338 +	destRect.Move(iOrigin);
   1.339 +	AddRect(destRect);
   1.340 +	TRect clippedDestRect(destRect);
   1.341 +	if (UserClipRect(clippedDestRect))
   1.342 +		{
   1.343 +		aBitmap->EndDataAccess(ETrue);
   1.344 +		aMaskBitmap->EndDataAccess(ETrue);
   1.345 +		return;
   1.346 +		}
   1.347 +
   1.348 +	SetupDevice();
   1.349 +	const TBool opaqueSource = (!IsAlphaChannel(aBitmap->DisplayMode())) && (iDrawMode == EDrawModePEN);
   1.350 +	iDevice->DrawingBegin();
   1.351 +
   1.352 +	CBitwiseBitmap* srcebmp = ((CFbsBitGcBitmap*)aBitmap)->Address();
   1.353 +	CBitwiseBitmap* maskbmp = ((CFbsBitGcBitmap*)aMaskBitmap)->Address();
   1.354 +	BG_ASSERT_DEBUG(srcebmp,EBitgdiPanicInvalidBitmap);
   1.355 +	BG_ASSERT_DEBUG(maskbmp,EBitgdiPanicInvalidBitmap);
   1.356 +
   1.357 +	CFbsRasterizer* rasterizer = PrepareRasterizerForExtendedBitmap(*aBitmap, destRect, aSourceRect);
   1.358 +	CFbsRasterizer* maskRasterizer = NULL;
   1.359 +	if (srcebmp != maskbmp)
   1.360 +		{
   1.361 +		if (aMaskBitmap->SizeInPixels().iWidth >= aBitmap->SizeInPixels().iWidth
   1.362 +			&& aMaskBitmap->SizeInPixels().iHeight >= aBitmap->SizeInPixels().iHeight)
   1.363 +			{
   1.364 +			// Mask is not tiled. Pass same region of interest as source bitmap to rasterizer.
   1.365 +			maskRasterizer = PrepareRasterizerForExtendedBitmap(*aMaskBitmap, destRect, aSourceRect);
   1.366 +			}
   1.367 +		else
   1.368 +			{
   1.369 +			// Mask is tiled. Do not pass any region of interest to rasterizer.
   1.370 +			maskRasterizer = PrepareRasterizerForExtendedBitmap(*aMaskBitmap);
   1.371 +			}
   1.372 +		}
   1.373 +
   1.374 +	const TPoint ditherOrigin(iDitherOrigin + aDestRect.iTl);
   1.375 +	const TInt limit = iDefaultRegionPtr->Count();
   1.376 +//
   1.377 +	CGraphicsAccelerator* ga = GraphicsAccelerator();
   1.378 +	if (ga && iShadowMode==CFbsDrawDevice::ENoShadow && (aMaskBitmap->DisplayMode()!=EGray2 || !aInvertMask) && iDrawMode==EDrawModePEN)
   1.379 +		{
   1.380 +		TInt gaOperationResult = KErrUnknown;
   1.381 +		TAcceleratedBitmapSpec bitmapSpec(const_cast<CFbsBitmap*>(aBitmap));
   1.382 +		iDevice->DrawingEnd();
   1.383 +		TAcceleratedBitmapSpec maskSpec(const_cast<CFbsBitmap*>(aMaskBitmap));
   1.384 +		const TPoint offset(aSourceRect.iTl - destRect.iTl);
   1.385 +
   1.386 +		if (destRect.Size() == aSourceRect.Size())
   1.387 +			{
   1.388 +			for(TInt count=0;count<limit;count++)
   1.389 +				{
   1.390 +				iClipRect=(*iDefaultRegionPtr)[count];
   1.391 +				if(!iClipRect.Intersects(clippedDestRect))
   1.392 +					continue;
   1.393 +				iClipRect.Intersection(clippedDestRect);
   1.394 +
   1.395 +				TRect clippedSrceRect(iClipRect);
   1.396 +				clippedSrceRect.Move(offset);
   1.397 +
   1.398 +				gaOperationResult = ga->Operation(TGopBitBltMasked(iClipRect.iTl,bitmapSpec,clippedSrceRect,maskSpec)); 	 
   1.399 +				if (gaOperationResult!=KErrNone) 	 
   1.400 +					break; 	 
   1.401 +				iDevice->iDrawDevice->UpdateRegion(iClipRect);
   1.402 +				}
   1.403 +			}
   1.404 +		else
   1.405 +			{
   1.406 +			RRegion clippedRegion;
   1.407 +			for(TInt clipIt=0;clipIt<limit;clipIt++)
   1.408 +				{
   1.409 +				TRect clipRect((*iDefaultRegionPtr)[clipIt]);
   1.410 +				clipRect.Intersection(clippedDestRect);
   1.411 +				if (!clipRect.IsEmpty())
   1.412 +					clippedRegion.AddRect(clipRect);
   1.413 +				}
   1.414 +			TRect srcCopy(aSourceRect);	// Needed because TGopScaledBitBltMasked takes a non-const value
   1.415 +			// const_cast needed because Operation takes a non-const region ptr :(
   1.416 +			gaOperationResult = ga->Operation(TGopScaledBitBltMasked(destRect,bitmapSpec,srcCopy,maskSpec),clippedRegion.Count(),const_cast<TRect*>(clippedRegion.RectangleList()));
   1.417 +			if (gaOperationResult==KErrNone) 	 
   1.418 +				iDevice->iDrawDevice->Update(clippedRegion);
   1.419 +			clippedRegion.Close();
   1.420 +			} 	 
   1.421 +		if (gaOperationResult==KErrNone) 	 
   1.422 +			goto finish;
   1.423 +		iDevice->DrawingBegin(); 	 
   1.424 +		}
   1.425 +//
   1.426 +	if (opaqueSource)
   1.427 +		iDrawMode = EDrawModeWriteAlpha;
   1.428 +	for (TInt count = 0; count < limit; count++)
   1.429 +		{
   1.430 +		iClipRect = (*iDefaultRegionPtr)[count];
   1.431 +		if (!iClipRect.Intersects(clippedDestRect))
   1.432 +			continue;
   1.433 +		iClipRect.Intersection(clippedDestRect);
   1.434 +		DoDrawBitmapMasked(destRect,
   1.435 +					   srcebmp,
   1.436 +					   aBitmap->DataAddress(),
   1.437 +					   aSourceRect,
   1.438 +					   maskbmp,
   1.439 +					   aMaskBitmap->DataAddress(),
   1.440 +					   aInvertMask, ditherOrigin);
   1.441 +		iDevice->iDrawDevice->UpdateRegion(iClipRect);
   1.442 +		}
   1.443 +	if (opaqueSource)
   1.444 +		iDrawMode = EDrawModePEN;
   1.445 +	iDevice->DrawingEnd();
   1.446 +finish:
   1.447 +	if (rasterizer)
   1.448 +		{
   1.449 +		rasterizer->EndBitmap(aBitmap->SerialNumber());
   1.450 +		}
   1.451 +	if (maskRasterizer)
   1.452 +		{
   1.453 +		maskRasterizer->EndBitmap(aMaskBitmap->SerialNumber());
   1.454 +		}
   1.455 +	aBitmap->EndDataAccess(ETrue);
   1.456 +	aMaskBitmap->EndDataAccess(ETrue);
   1.457 +	}
   1.458 +
   1.459 +/** The method draws a specified rectangle from a bitmap and
   1.460 +its mask into another rectangle and does a compress/stretch
   1.461 +to fit a given destination rectangle.
   1.462 +
   1.463 +This is an overload, which takes CWsBitmap* as argument, which
   1.464 +in turn calls the other overload.
   1.465 +
   1.466 +Note: A pointer to CWsBitmap must have the same pointer value as a pointer
   1.467 +to the associated CFbsBitmap, otherwise code in BitGdi component will be
   1.468 +Broken.
   1.469 +
   1.470 +@note When using this function with a 256 Mask bitmap, it blends.
   1.471 +Otherwise (e.g. with a 4bpp mask), this function masks rather than blends.
   1.472 +If a user wants to blend the source into the destination they should use
   1.473 +CFbsBitGc::AlphaBlendBitmaps() instead.
   1.474 +
   1.475 +@publishedAll
   1.476 +@released
   1.477 +
   1.478 +@param aDestRect The rectangle within which the masked bitmap is to be drawn.
   1.479 +@param aBitmap A pointer to the source bitmap.
   1.480 +@param aSourceRect The rectangle in the source bitmap that is copied to the
   1.481 +destination rectangle.
   1.482 +@param aMaskBitmap A pointer to the mask bitmap.
   1.483 +@param aInvertMask If false, a source pixel that is masked by a black pixel
   1.484 +is not transferred to the destination rectangle. If true, then a source pixel
   1.485 +that is masked by a white pixel is not transferred to the destination rectangle.
   1.486 +
   1.487 +@pre aBitmap != NULL
   1.488 +@pre aBitmap->Handle() != 0
   1.489 +@pre aMaskBitmap != NULL
   1.490 +@pre aMaskBitmap->Handle() != 0
   1.491 +@pre !aSourceRect.IsEmpty()
   1.492 +*/
   1.493 +EXPORT_C void CFbsBitGc::DrawBitmapMasked(const TRect& aDestRect,
   1.494 +						 const CWsBitmap* aBitmap,
   1.495 +						 const TRect& aSourceRect,
   1.496 +						 const CWsBitmap* aMaskBitmap,
   1.497 +						 TBool aInvertMask)
   1.498 +	{
   1.499 +	DrawBitmapMasked(aDestRect,REINTERPRET_CAST(const CFbsBitmap*,aBitmap),aSourceRect,REINTERPRET_CAST(const CFbsBitmap*,aMaskBitmap),aInvertMask);
   1.500 +	}