os/graphics/windowing/windowserver/nga/SERVER/openwfc/playbackgc.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// GC and Graphics functions
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "playbackgc.h"
sl@0
    19
sl@0
    20
#include <e32std.h>
sl@0
    21
#include <s32mem.h> 
sl@0
    22
sl@0
    23
#include "panics.h"
sl@0
    24
#include "ScrDev.H"
sl@0
    25
#include "windowgroup.h"
sl@0
    26
#include "wsfont.h"
sl@0
    27
#include "wstop.h"
sl@0
    28
#include "graphics/WSGRAPHICDRAWER.H"
sl@0
    29
#include "graphics/surfaceconfiguration.h"
sl@0
    30
#include "windowelementset.h"
sl@0
    31
sl@0
    32
#include <graphics/wsgraphicscontext.h>
sl@0
    33
#include <graphics/wsuibuffer.h>
sl@0
    34
#include "bitgditomwsgraphicscontextmappings.h"
sl@0
    35
sl@0
    36
#include "graphicscontextstate.h"
sl@0
    37
#include "drawresource.h"
sl@0
    38
#include "devicemap.h"
sl@0
    39
sl@0
    40
CPlaybackGc * CPlaybackGc::iSelf=NULL;
sl@0
    41
sl@0
    42
GLREF_C RWsRegion* InternalizeRegionL(RReadStream& aReadStream);
sl@0
    43
sl@0
    44
/*CPlaybackGc*/
sl@0
    45
sl@0
    46
void CPlaybackGc::InitStaticsL()
sl@0
    47
	{
sl@0
    48
	iSelf=new(ELeave) CPlaybackGc();
sl@0
    49
	iSelf->ConstructL();
sl@0
    50
	}
sl@0
    51
sl@0
    52
void CPlaybackGc::DeleteStatics()
sl@0
    53
	{
sl@0
    54
	delete iSelf;
sl@0
    55
	iSelf = 0;
sl@0
    56
	}
sl@0
    57
sl@0
    58
CPlaybackGc::CPlaybackGc()
sl@0
    59
	{
sl@0
    60
	}
sl@0
    61
sl@0
    62
void CPlaybackGc::ConstructL()
sl@0
    63
	{
sl@0
    64
	iGcBuf = CBufSeg::NewL(512);
sl@0
    65
	}
sl@0
    66
sl@0
    67
CPlaybackGc::~CPlaybackGc()
sl@0
    68
	{
sl@0
    69
	delete iPolyPoints;
sl@0
    70
	delete iGcBuf;
sl@0
    71
	iCurrentClippingRegion = NULL;
sl@0
    72
	iIntersectedRegion.Close();
sl@0
    73
	}
sl@0
    74
sl@0
    75
void CPlaybackGc::Activate(CWsClientWindow * aWin, MWsGraphicsContext * aGc, const TRegion * aRegion)
sl@0
    76
	{
sl@0
    77
	iWin = aWin;
sl@0
    78
	iGc = aGc;
sl@0
    79
	iTargetRegion = aRegion;
sl@0
    80
	
sl@0
    81
	iDrawRegion = iTargetRegion;
sl@0
    82
	iMasterOrigin = iWin->Origin();
sl@0
    83
	iOrigin.SetXY(0,0);
sl@0
    84
	iSendOrigin = ETrue;
sl@0
    85
	iGc->SetBrushColor(iWin->BackColor());
sl@0
    86
	ResetClippingRect();
sl@0
    87
	}
sl@0
    88
	
sl@0
    89
void CPlaybackGc::Deactivate()
sl@0
    90
	{
sl@0
    91
	iWin = 0;
sl@0
    92
	iGc = 0;
sl@0
    93
	iTargetRegion = 0;
sl@0
    94
	iDrawRegion = 0;
sl@0
    95
	CancelUserClippingRegion();
sl@0
    96
	}
sl@0
    97
	
sl@0
    98
void CPlaybackGc::CancelUserClippingRegion()
sl@0
    99
	{
sl@0
   100
	if (iUserDefinedClippingRegion)
sl@0
   101
		{
sl@0
   102
		iUserDefinedClippingRegion->Destroy();
sl@0
   103
		iUserDefinedClippingRegion = 0;
sl@0
   104
		iDrawRegion = iTargetRegion;
sl@0
   105
		}
sl@0
   106
	}
sl@0
   107
	
sl@0
   108
void CPlaybackGc::SetClippingRect(const TRect &aRect)
sl@0
   109
	{
sl@0
   110
	iClippingRect=aRect;
sl@0
   111
	iClippingRect.Move(iOrigin);
sl@0
   112
	iClippingRectSet=ETrue;
sl@0
   113
	}
sl@0
   114
sl@0
   115
void CPlaybackGc::ResetClippingRect()
sl@0
   116
	{
sl@0
   117
	iClippingRectSet=EFalse;
sl@0
   118
	}
sl@0
   119
sl@0
   120
void CPlaybackGc::CheckPolyData(const TAny* aDataPtr, TInt aHeaderSize, TInt aNumPoints)
sl@0
   121
	{
sl@0
   122
	TInt maxDataLen;
sl@0
   123
	if (CWsClient::iCurrentCommand.iOpcode>0)
sl@0
   124
		{
sl@0
   125
		maxDataLen=CWsClient::EndOfCommandBuffer()-static_cast<const TUint8*>(aDataPtr);
sl@0
   126
		}
sl@0
   127
	else
sl@0
   128
		{
sl@0
   129
		maxDataLen=CWsClient::iCurrentCommand.iCmdLength;
sl@0
   130
		}
sl@0
   131
	const TInt dataSize=aHeaderSize+aNumPoints*sizeof(TPoint);
sl@0
   132
	if (dataSize>maxDataLen)
sl@0
   133
		GcOwnerPanic(EWservPanicBadPolyData);
sl@0
   134
	}
sl@0
   135
sl@0
   136
void CPlaybackGc::DoDrawPolygon(const TWsGcCmdDrawPolygon *aDrawPolygon)
sl@0
   137
	{
sl@0
   138
	CheckPolyData(aDrawPolygon, sizeof(TWsGcCmdDrawPolygon), aDrawPolygon->numPoints);
sl@0
   139
	TArrayWrapper<TPoint> points((TPoint*)(aDrawPolygon + 1), aDrawPolygon->numPoints);
sl@0
   140
	iGc->DrawPolygon(points, BitGdiToMWsGraphicsContextMappings::Convert(aDrawPolygon->fillRule));
sl@0
   141
	}
sl@0
   142
sl@0
   143
void CPlaybackGc::StartSegmentedDrawPolygonL(const TWsGcCmdStartSegmentedDrawPolygon *aDrawPolygon)
sl@0
   144
	{
sl@0
   145
// In case a Playback have been done before all the segment is in the RedrawStore
sl@0
   146
// (This allocation is deleted only thanks to the EWsGcOpDrawSegmentedPolygon opcode
sl@0
   147
//  which arrive after all the segments)
sl@0
   148
	if (iPolyPoints)
sl@0
   149
		{
sl@0
   150
		delete iPolyPoints;
sl@0
   151
		iPolyPoints=NULL;	
sl@0
   152
		}
sl@0
   153
	if(!Rng(0, aDrawPolygon->totalNumPoints, KMaxTInt/2 - 1))
sl@0
   154
		GcOwnerPanic(EWservPanicBadPolyData);	
sl@0
   155
	iPolyPoints=(TPoint *)User::AllocL(aDrawPolygon->totalNumPoints*sizeof(TPoint));
sl@0
   156
	iPolyPointListSize=aDrawPolygon->totalNumPoints;
sl@0
   157
	}
sl@0
   158
sl@0
   159
void CPlaybackGc::SegmentedDrawPolygonData(const TWsGcCmdSegmentedDrawPolygonData *aDrawPolygon)
sl@0
   160
	{
sl@0
   161
	if (aDrawPolygon->index<0 || (aDrawPolygon->index + aDrawPolygon->numPoints) > iPolyPointListSize)
sl@0
   162
		GcOwnerPanic(EWservPanicBadPolyData);
sl@0
   163
	Mem::Copy(iPolyPoints+aDrawPolygon->index,aDrawPolygon+1,aDrawPolygon->numPoints*sizeof(TPoint));
sl@0
   164
	}
sl@0
   165
sl@0
   166
void CPlaybackGc::EndSegmentedPolygon()
sl@0
   167
	{
sl@0
   168
	delete iPolyPoints;
sl@0
   169
	iPolyPoints=NULL;
sl@0
   170
	}
sl@0
   171
sl@0
   172
void CPlaybackGc::DoDrawPolyLine(const TWsGcCmdDrawPolyLine *aDrawPolyLine, TBool aContinued)
sl@0
   173
	{
sl@0
   174
	TInt numPoints=aDrawPolyLine->numPoints;
sl@0
   175
	CheckPolyData(aDrawPolyLine, sizeof(TWsGcCmdDrawPolyLine), numPoints);
sl@0
   176
	const TPoint *points=(TPoint *)(aDrawPolyLine+1);
sl@0
   177
	if (aContinued)
sl@0
   178
		{
sl@0
   179
		numPoints++;
sl@0
   180
		points=&aDrawPolyLine->last;
sl@0
   181
		}
sl@0
   182
	TArrayWrapper<TPoint> pointsArr(points, numPoints);
sl@0
   183
	if (aDrawPolyLine->more)	// more to come so don't draw the end point
sl@0
   184
		iGc->DrawPolyLineNoEndPoint(pointsArr);
sl@0
   185
	else
sl@0
   186
		iGc->DrawPolyLine(pointsArr);
sl@0
   187
	}
sl@0
   188
sl@0
   189
void CPlaybackGc::GcOwnerPanic(TClientPanic aPanic)
sl@0
   190
	{
sl@0
   191
	iGc->ResetClippingRegion();
sl@0
   192
	iCurrentClippingRegion = NULL;
sl@0
   193
	EndSegmentedPolygon();
sl@0
   194
	iWin->WsOwner()->PPanic(aPanic);
sl@0
   195
	}
sl@0
   196
	
sl@0
   197
// implementing MWsGc
sl@0
   198
sl@0
   199
MWsClient& CPlaybackGc::Client()
sl@0
   200
	{
sl@0
   201
	return *(iWin->WsOwner());
sl@0
   202
	}
sl@0
   203
sl@0
   204
MWsScreen& CPlaybackGc::Screen()
sl@0
   205
	{
sl@0
   206
	return *(iWin->Screen());
sl@0
   207
	}
sl@0
   208
sl@0
   209
const TTime& CPlaybackGc::Now() const
sl@0
   210
	{
sl@0
   211
	return iWin->Screen()->Now();
sl@0
   212
	}
sl@0
   213
	
sl@0
   214
void CPlaybackGc::ScheduleAnimation(const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow)
sl@0
   215
	{
sl@0
   216
	ScheduleAnimation(aRect,aFromNow,0,0);
sl@0
   217
	}
sl@0
   218
sl@0
   219
void CPlaybackGc::ScheduleAnimation(const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop)
sl@0
   220
	{
sl@0
   221
	// convert window rect to screen rect
sl@0
   222
	TRect rect(aRect);
sl@0
   223
	rect.Move(iGc->Origin());
sl@0
   224
	// clip rect to window extent
sl@0
   225
	rect.Intersection(iWin->Abs());
sl@0
   226
	if (!rect.IsEmpty())
sl@0
   227
		{
sl@0
   228
		// and schedule it
sl@0
   229
		iWin->Screen()->ScheduleAnimation(ECrpAnim, rect, aFromNow, aFreq, aStop, iWin);
sl@0
   230
		}
sl@0
   231
	}
sl@0
   232
sl@0
   233
void CPlaybackGc::SetGcOrigin(const TPoint& aOrigin) 
sl@0
   234
	{
sl@0
   235
	iOrigin = aOrigin - iMasterOrigin;
sl@0
   236
	} 
sl@0
   237
sl@0
   238
void CPlaybackGc::RemoteReadDataAndDrawL(const CWsGraphicDrawer* aGraphic, CWsClient* aOwner, const TWsGcCmdUnion &aData)
sl@0
   239
	{
sl@0
   240
	TPtrC8 data;
sl@0
   241
	HBufC8* dataBuf = NULL;
sl@0
   242
	const TInt len = aData.WsGraphic->iDataLen;
sl@0
   243
	
sl@0
   244
	if ((len >= KMaxTInt / 4) || (len < 0))
sl@0
   245
		{
sl@0
   246
		aOwner->PPanic(EWservPanicBuffer);	
sl@0
   247
		}	
sl@0
   248
	dataBuf = HBufC8::NewLC(len);
sl@0
   249
	TPtr8 des = dataBuf->Des();
sl@0
   250
	aOwner->RemoteRead(des, 0);
sl@0
   251
sl@0
   252
	if(des.Size() != len)
sl@0
   253
		{
sl@0
   254
		aOwner->PPanic(EWservPanicBuffer);
sl@0
   255
		}
sl@0
   256
	data.Set(des);																
sl@0
   257
	aGraphic->Draw(*this, aData.WsGraphic->iRect, data);
sl@0
   258
	CleanupStack::PopAndDestroy(dataBuf);		
sl@0
   259
	}
sl@0
   260
sl@0
   261
TPtrC CPlaybackGc::BufferTPtr(TText* aStart,TInt aLen, const TDesC8& aCmdData)
sl@0
   262
	{
sl@0
   263
	if ((reinterpret_cast<TUint8*>(aStart) < aCmdData.Ptr()
sl@0
   264
									|| reinterpret_cast<TUint8*>(aStart+aLen) > (aCmdData.Ptr() + aCmdData.Size()) ))
sl@0
   265
		{
sl@0
   266
		GcOwnerPanic(EWservPanicBufferPtr);
sl@0
   267
		}
sl@0
   268
	TPtrC gcPtr;
sl@0
   269
	gcPtr.Set(aStart,aLen);
sl@0
   270
	return(gcPtr);
sl@0
   271
	} 
sl@0
   272
sl@0
   273
void CPlaybackGc::DoDrawCommand(TWsGcOpcodes aOpcode, const TDesC8& aCmdData, const TRegion *aRegion)
sl@0
   274
	{
sl@0
   275
    if (aRegion->Count()==0)
sl@0
   276
        return;
sl@0
   277
sl@0
   278
    TWsGcCmdUnion pData;
sl@0
   279
	// coverity[returned_pointer]
sl@0
   280
	pData.any=aCmdData.Ptr();
sl@0
   281
sl@0
   282
	SendClippingRegionIfRequired(aRegion);
sl@0
   283
sl@0
   284
	WS_ASSERT_DEBUG(!iCurrentClippingRegion, EWsPanicDrawCommandsInvalidState);
sl@0
   285
	iCurrentClippingRegion = aRegion;
sl@0
   286
sl@0
   287
	CGraphicsContext::TTextParameters contextParam;
sl@0
   288
	
sl@0
   289
	TBool bGcDrawingOccurred = ETrue;	//most commands in here draw using the gc
sl@0
   290
	
sl@0
   291
	switch(aOpcode)
sl@0
   292
		{
sl@0
   293
		case EWsGcOpDrawWsGraphic:
sl@0
   294
		case EWsGcOpDrawWsGraphicPtr:
sl@0
   295
			{
sl@0
   296
			bGcDrawingOccurred = EFalse;	//best guess if the drawer did no happen 
sl@0
   297
			TRect screenRect(pData.WsGraphic->iRect);
sl@0
   298
			screenRect.Move(iGc->Origin());
sl@0
   299
			if(iCurrentClippingRegion->Intersects(screenRect))
sl@0
   300
				{
sl@0
   301
				const TInt dataLen = pData.WsGraphic->iDataLen;
sl@0
   302
				TGraphicDrawerId id;
sl@0
   303
				id.iId = pData.WsGraphic->iId;
sl@0
   304
				id.iIsUid = (pData.WsGraphic->iFlags & EWsGraphicIdUid);
sl@0
   305
				CWsClient* owner = iWin->WsOwner();
sl@0
   306
				const CWsGraphicDrawer* graphic = CWsTop::WindowServer()->ResolveGraphic(id);
sl@0
   307
				TInt lastDrawCount=GcDrawingCount();
sl@0
   308
				if(graphic && graphic->IsSharedWith(owner->SecureId()))
sl@0
   309
					{
sl@0
   310
					if(aOpcode == EWsGcOpDrawWsGraphicPtr)
sl@0
   311
						{
sl@0
   312
						TRAPD(err, RemoteReadDataAndDrawL(graphic, owner, pData))
sl@0
   313
						if(err)
sl@0
   314
							WS_PANIC_DEBUG(EWsPanicWsGraphic);
sl@0
   315
						}
sl@0
   316
					else
sl@0
   317
						graphic->Draw(*this,pData.WsGraphic->iRect,CWsClient::BufferTPtr8((TUint8*)(pData.WsGraphic+1),dataLen));
sl@0
   318
	
sl@0
   319
					WS_ASSERT_DEBUG(!iGcBuf->Size(),EWsPanicWsGraphic);
sl@0
   320
					iGcBuf->Reset();
sl@0
   321
					}
sl@0
   322
				if (lastDrawCount!=GcDrawingCount())
sl@0
   323
					{
sl@0
   324
					// Changes to the GcDrawingCount are used to tag placed and background surfaces as dirty.
sl@0
   325
					// If drawing occurs inside a CRP and perhaps PlaceSurface occurs inside the CRP 
sl@0
   326
					// then we tag to count again to cause the placed surface to get marked as dirty later.
sl@0
   327
					bGcDrawingOccurred = ETrue;	//some GC drawing did occurr at some point
sl@0
   328
					}
sl@0
   329
				}
sl@0
   330
			break;
sl@0
   331
			}
sl@0
   332
		case EWsGcOpMapColorsLocal:
sl@0
   333
			GcOwnerPanic(EWservPanicOpcode); //deprecated, the client should never generate this op
sl@0
   334
			break;
sl@0
   335
		case EWsGcOpDrawPolyLineLocalBufLen:
sl@0
   336
			{
sl@0
   337
			TArrayWrapper<TPoint> points(pData.DrawPolyLineLocalBufLen->points, pData.DrawPolyLineLocalBufLen->length);
sl@0
   338
			iGc->DrawPolyLine(points);
sl@0
   339
			break;
sl@0
   340
			}
sl@0
   341
		case EWsGcOpDrawPolyLineLocal:
sl@0
   342
			iGc->DrawPolyLine(pData.PointList->Array());
sl@0
   343
			break;
sl@0
   344
		case EWsGcOpDrawPolygonLocalBufLen:
sl@0
   345
			{
sl@0
   346
			TArrayWrapper<TPoint> points(pData.DrawPolygonLocalBufLen->points, pData.DrawPolygonLocalBufLen->length);
sl@0
   347
			iGc->DrawPolygon(points, BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawPolygonLocalBufLen->fillRule));
sl@0
   348
			break;
sl@0
   349
			}
sl@0
   350
		case EWsGcOpDrawPolygonLocal:
sl@0
   351
			iGc->DrawPolygon(pData.DrawPolygonLocal->pointList->Array(),BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawPolygonLocal->fillRule));
sl@0
   352
			break;
sl@0
   353
		case EWsGcOpDrawBitmapLocal:
sl@0
   354
			{
sl@0
   355
			// DrawBitmap(TPoint&, ) uses the size of the bitmap in twips, but 
sl@0
   356
			// MWsGraphicsContext::DrawBitmap() takes a TRect in pixels, so we need to convert
sl@0
   357
			TRect destRect(iWin->Screen()->DeviceMap().TwipsToPixels(pData.BitmapLocal->bitmap->SizeInTwips()));
sl@0
   358
			destRect.Move(pData.BitmapLocal->pos); //pos is defined in pixels, that's why we're not converting it
sl@0
   359
			iGc->DrawBitmap(destRect, *pData.BitmapLocal->bitmap);
sl@0
   360
			break;
sl@0
   361
			}
sl@0
   362
		case EWsGcOpDrawBitmap2Local:
sl@0
   363
			iGc->DrawBitmap(pData.Bitmap2Local->rect, *pData.Bitmap2Local->bitmap);
sl@0
   364
			break;
sl@0
   365
		case EWsGcOpDrawBitmap3Local:
sl@0
   366
			iGc->DrawBitmap(pData.Bitmap3Local->rect, *pData.Bitmap3Local->bitmap, pData.Bitmap3Local->srcRect);
sl@0
   367
			break;
sl@0
   368
		case EWsGcOpDrawBitmapMaskedLocal:
sl@0
   369
			iGc->DrawBitmapMasked(pData.iBitmapMaskedLocal->iRect, *pData.iBitmapMaskedLocal->iBitmap, pData.iBitmapMaskedLocal->iSrcRect, *pData.iBitmapMaskedLocal->iMaskBitmap,pData.iBitmapMaskedLocal->iInvertMask);
sl@0
   370
			break;
sl@0
   371
		case EWsGcOpAlphaBlendBitmapsLocal:
sl@0
   372
			iGc->BitBltMasked(pData.AlphaBlendBitmapsLocal->point, *pData.AlphaBlendBitmapsLocal->iBitmap,
sl@0
   373
						                  pData.AlphaBlendBitmapsLocal->source, *pData.AlphaBlendBitmapsLocal->iAlpha,
sl@0
   374
						                  pData.AlphaBlendBitmapsLocal->alphaPoint);
sl@0
   375
			break;
sl@0
   376
		case EWsGcOpDrawText:
sl@0
   377
			if (iGc->HasFont())
sl@0
   378
				iGc->DrawText(BufferTPtr((TText *)(pData.DrawText+1),pData.DrawText->length,aCmdData), NULL, pData.DrawText->pos);
sl@0
   379
			break;
sl@0
   380
		case EWsGcOpDrawBoxTextOptimised1:
sl@0
   381
			if (iGc->HasFont())
sl@0
   382
				iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextO1+1),pData.BoxTextO1->length,aCmdData), NULL, pData.BoxTextO1->box,
sl@0
   383
							  pData.BoxTextO1->baselineOffset,MWsGraphicsContext::ELeft,0);
sl@0
   384
			break;
sl@0
   385
		case EWsGcOpDrawBoxTextOptimised2:
sl@0
   386
			if (iGc->HasFont())
sl@0
   387
				iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextO2+1),pData.BoxTextO2->length,aCmdData), NULL, pData.BoxTextO2->box,
sl@0
   388
							  pData.BoxTextO2->baselineOffset,BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextO2->horiz),pData.BoxTextO2->leftMrg);
sl@0
   389
			break;
sl@0
   390
		case EWsGcOpDrawTextPtr:
sl@0
   391
			if (iGc->HasFont())
sl@0
   392
				iGc->DrawText(*pData.DrawTextPtr->text, NULL, pData.DrawTextPtr->pos);
sl@0
   393
			break;
sl@0
   394
		case EWsGcOpDrawTextPtr1:
sl@0
   395
			if (iGc->HasFont())
sl@0
   396
				iGc->DrawText(*pData.DrawTextPtr->text, NULL);
sl@0
   397
			break;
sl@0
   398
		case EWsGcOpDrawBoxText:
sl@0
   399
			if (iGc->HasFont())
sl@0
   400
				iGc->DrawText(BufferTPtr((TText *)(pData.BoxText+1),pData.BoxText->length,aCmdData), NULL, pData.BoxText->box,
sl@0
   401
							  pData.BoxText->baselineOffset,BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxText->horiz),pData.BoxText->leftMrg);
sl@0
   402
			break;
sl@0
   403
		case EWsGcOpDrawBoxTextPtr:
sl@0
   404
			if (iGc->HasFont())
sl@0
   405
				iGc->DrawText(*pData.DrawBoxTextPtr->text, NULL, pData.DrawBoxTextPtr->box,pData.DrawBoxTextPtr->baselineOffset,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextPtr->horiz),pData.DrawBoxTextPtr->leftMrg);
sl@0
   406
			break;
sl@0
   407
		case EWsGcOpDrawBoxTextPtr1:
sl@0
   408
			if (iGc->HasFont())
sl@0
   409
				iGc->DrawText(*pData.DrawBoxTextPtr->text, NULL, pData.DrawBoxTextPtr->box);
sl@0
   410
			break;
sl@0
   411
		case EWsGcOpDrawTextVertical:
sl@0
   412
			if (iGc->HasFont())
sl@0
   413
				iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawTextVertical+1),pData.DrawTextVertical->length,aCmdData),NULL,pData.DrawTextVertical->pos
sl@0
   414
							          ,pData.DrawTextVertical->up);
sl@0
   415
			break;
sl@0
   416
		case EWsGcOpDrawTextVerticalPtr:
sl@0
   417
			if (iGc->HasFont())
sl@0
   418
				iGc->DrawTextVertical(*pData.DrawTextVerticalPtr->text,NULL,pData.DrawTextVerticalPtr->pos,pData.DrawTextVerticalPtr->up);
sl@0
   419
			break;
sl@0
   420
		case EWsGcOpDrawTextVerticalPtr1:
sl@0
   421
			if (iGc->HasFont())
sl@0
   422
				iGc->DrawTextVertical(*pData.DrawTextVerticalPtr->text,NULL,pData.DrawTextVerticalPtr->up);
sl@0
   423
			break;
sl@0
   424
		case EWsGcOpDrawBoxTextVertical:
sl@0
   425
			if (iGc->HasFont())
sl@0
   426
				iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawBoxTextVertical+1),pData.DrawBoxTextVertical->length,aCmdData), NULL,
sl@0
   427
									  pData.DrawBoxTextVertical->box,	pData.DrawBoxTextVertical->baselineOffset,
sl@0
   428
									  pData.DrawBoxTextVertical->up,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextVertical->vert),pData.DrawBoxTextVertical->margin);
sl@0
   429
			break;
sl@0
   430
		case EWsGcOpDrawBoxTextVerticalPtr:
sl@0
   431
			if (iGc->HasFont())
sl@0
   432
				iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,NULL,pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->baselineOffset
sl@0
   433
									  ,pData.DrawBoxTextVerticalPtr->width,pData.DrawBoxTextVerticalPtr->up,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextVerticalPtr->vert),pData.DrawBoxTextVerticalPtr->margin);
sl@0
   434
			break;
sl@0
   435
		case EWsGcOpDrawBoxTextVerticalPtr1:
sl@0
   436
			if (iGc->HasFont())
sl@0
   437
				iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,NULL,pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->up);
sl@0
   438
			break;
sl@0
   439
		case EWsGcOpDrawTextLocal:
sl@0
   440
			if (iGc->HasFont())
sl@0
   441
				iGc->DrawText(*pData.DrawTextLocal->desc, NULL, pData.DrawTextLocal->pos);
sl@0
   442
			break;
sl@0
   443
		case EWsGcOpDrawBoxTextLocal:
sl@0
   444
			if (iGc->HasFont())
sl@0
   445
				iGc->DrawText(*pData.BoxTextLocal->desc, NULL, pData.BoxTextLocal->box,pData.BoxTextLocal->baselineOffset,
sl@0
   446
							  BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextLocal->horiz),pData.BoxTextLocal->leftMrg);
sl@0
   447
			break;
sl@0
   448
		/************* DrawText in Context function calls*********************************************/
sl@0
   449
		case EWsGcOpDrawTextInContext:
sl@0
   450
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
   451
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
   452
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   453
				{
sl@0
   454
				iGc->DrawText(BufferTPtr((TText *)(pData.DrawTextInContext+1),pData.DrawTextInContext->length,aCmdData),BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContext->pos);
sl@0
   455
				}
sl@0
   456
			break;
sl@0
   457
		case EWsGcOpDrawBoxTextInContextOptimised1:
sl@0
   458
			contextParam.iStart = pData.BoxTextInContextO1->start;
sl@0
   459
			contextParam.iEnd = pData.BoxTextInContextO1->end;
sl@0
   460
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   461
				{
sl@0
   462
				iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextInContextO1+1),pData.BoxTextInContextO1->length,aCmdData),BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.BoxTextInContextO1->box,
sl@0
   463
							  pData.BoxTextInContextO1->baselineOffset,MWsGraphicsContext::ELeft,0);
sl@0
   464
				}
sl@0
   465
			break;
sl@0
   466
		case EWsGcOpDrawBoxTextInContextOptimised2:
sl@0
   467
			contextParam.iStart = pData.BoxTextInContextO2->start;
sl@0
   468
			contextParam.iEnd = pData.BoxTextInContextO2->end;
sl@0
   469
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   470
				{
sl@0
   471
				iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextInContextO2+1),pData.BoxTextInContextO2->length,aCmdData),BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.BoxTextInContextO2->box,
sl@0
   472
							  pData.BoxTextInContextO2->baselineOffset,BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextInContextO2->horiz),pData.BoxTextInContextO2->leftMrg);
sl@0
   473
				}
sl@0
   474
			break;
sl@0
   475
		case EWsGcOpDrawTextInContextPtr:
sl@0
   476
			contextParam.iStart = pData.DrawTextInContextPtr->start;
sl@0
   477
			contextParam.iEnd = pData.DrawTextInContextPtr->end;
sl@0
   478
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   479
				{
sl@0
   480
				iGc->DrawText(*pData.DrawTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContextPtr->pos);
sl@0
   481
				}
sl@0
   482
			break;
sl@0
   483
		case EWsGcOpDrawTextInContextPtr1:
sl@0
   484
			contextParam.iStart = pData.DrawTextInContextPtr->start;
sl@0
   485
			contextParam.iEnd = pData.DrawTextInContextPtr->end;
sl@0
   486
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   487
				{
sl@0
   488
				iGc->DrawText(*pData.DrawTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
sl@0
   489
				}
sl@0
   490
			break;
sl@0
   491
		case EWsGcOpDrawBoxTextInContext:
sl@0
   492
			contextParam.iStart = pData.BoxTextInContext->start;
sl@0
   493
			contextParam.iEnd = pData.BoxTextInContext->end;
sl@0
   494
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   495
				{
sl@0
   496
				iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextInContext+1),pData.BoxTextInContext->length,aCmdData),
sl@0
   497
							  BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.BoxTextInContext->box,pData.BoxTextInContext->baselineOffset,
sl@0
   498
							  BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextInContext->horiz),pData.BoxTextInContext->leftMrg);
sl@0
   499
				}
sl@0
   500
			break;
sl@0
   501
		case EWsGcOpDrawBoxTextInContextPtr:
sl@0
   502
			contextParam.iStart = pData.DrawBoxTextInContextPtr->start;
sl@0
   503
			contextParam.iEnd = pData.DrawBoxTextInContextPtr->end;
sl@0
   504
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   505
				{
sl@0
   506
				iGc->DrawText(*pData.DrawBoxTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextInContextPtr->box,pData.DrawBoxTextInContextPtr->baselineOffset,
sl@0
   507
							  BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextInContextPtr->horiz),pData.DrawBoxTextInContextPtr->leftMrg);
sl@0
   508
				}
sl@0
   509
			break;
sl@0
   510
		case EWsGcOpDrawBoxTextInContextPtr1:
sl@0
   511
			contextParam.iStart = pData.DrawBoxTextInContextPtr->start;
sl@0
   512
			contextParam.iEnd = pData.DrawBoxTextInContextPtr->end;
sl@0
   513
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   514
				{
sl@0
   515
				iGc->DrawText(*pData.DrawBoxTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextInContextPtr->box);
sl@0
   516
				}
sl@0
   517
			break;
sl@0
   518
		case EWsGcOpDrawTextInContextVertical:
sl@0
   519
			contextParam.iStart = pData.DrawTextInContextVertical->start;
sl@0
   520
			contextParam.iEnd = pData.DrawTextInContextVertical->end;
sl@0
   521
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   522
				{
sl@0
   523
				iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawTextInContextVertical+1),pData.DrawTextInContextVertical->length,aCmdData),
sl@0
   524
									  BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContextVertical->pos,pData.DrawTextInContextVertical->up);
sl@0
   525
				}
sl@0
   526
			break;
sl@0
   527
		case EWsGcOpDrawTextInContextVerticalPtr:
sl@0
   528
			contextParam.iStart = pData.DrawTextInContextVerticalPtr->start;
sl@0
   529
			contextParam.iEnd = pData.DrawTextInContextVerticalPtr->end;
sl@0
   530
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   531
				{
sl@0
   532
				iGc->DrawTextVertical(*pData.DrawTextInContextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),
sl@0
   533
									  pData.DrawTextInContextVerticalPtr->pos,pData.DrawTextInContextVerticalPtr->up);
sl@0
   534
				}
sl@0
   535
			break;
sl@0
   536
		case EWsGcOpDrawTextInContextVerticalPtr1:
sl@0
   537
			contextParam.iStart = pData.DrawTextInContextVerticalPtr->start;
sl@0
   538
			contextParam.iEnd = pData.DrawTextInContextVerticalPtr->end;
sl@0
   539
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   540
				{
sl@0
   541
				iGc->DrawTextVertical(*pData.DrawTextInContextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContextVerticalPtr->up);
sl@0
   542
				}
sl@0
   543
			break;
sl@0
   544
		case EWsGcOpDrawBoxTextInContextVertical:
sl@0
   545
			contextParam.iStart = pData.DrawBoxTextInContextVertical->start;
sl@0
   546
			contextParam.iEnd = pData.DrawBoxTextInContextVertical->end;
sl@0
   547
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   548
				{
sl@0
   549
				iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawBoxTextInContextVertical+1),pData.DrawBoxTextInContextVertical->length,aCmdData),
sl@0
   550
									  BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextInContextVertical->box,pData.DrawBoxTextInContextVertical->baselineOffset,
sl@0
   551
									  pData.DrawBoxTextInContextVertical->up,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextInContextVertical->vert),pData.DrawBoxTextInContextVertical->margin);
sl@0
   552
				}
sl@0
   553
			break;
sl@0
   554
		case EWsGcOpDrawBoxTextInContextVerticalPtr:
sl@0
   555
			contextParam.iStart = pData.DrawBoxTextInContextVerticalPtr->start;
sl@0
   556
			contextParam.iEnd = pData.DrawBoxTextInContextVerticalPtr->end;
sl@0
   557
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   558
				{
sl@0
   559
				iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->baselineOffset
sl@0
   560
									  ,pData.DrawBoxTextVerticalPtr->width,pData.DrawBoxTextVerticalPtr->up,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextVerticalPtr->vert),pData.DrawBoxTextVerticalPtr->margin);
sl@0
   561
				}
sl@0
   562
			break;
sl@0
   563
		case EWsGcOpDrawBoxTextInContextVerticalPtr1:
sl@0
   564
			contextParam.iStart = pData.DrawBoxTextInContextVerticalPtr->start;
sl@0
   565
			contextParam.iEnd = pData.DrawBoxTextInContextVerticalPtr->end;
sl@0
   566
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   567
				{
sl@0
   568
				iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->up);
sl@0
   569
				}
sl@0
   570
			break;
sl@0
   571
		case EWsGcOpDrawTextInContextLocal:
sl@0
   572
			contextParam.iStart = pData.DrawTextInContextLocal->start;
sl@0
   573
			contextParam.iEnd = pData.DrawTextInContextLocal->end;
sl@0
   574
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   575
				{
sl@0
   576
				iGc->DrawText(*pData.DrawTextInContextLocal->desc,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContextLocal->pos);
sl@0
   577
				}
sl@0
   578
			break;
sl@0
   579
		case EWsGcOpDrawBoxTextInContextLocal:
sl@0
   580
			contextParam.iStart = pData.BoxTextInContextLocal->start;
sl@0
   581
			contextParam.iEnd = pData.BoxTextInContextLocal->end;
sl@0
   582
			if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
sl@0
   583
				{
sl@0
   584
				iGc->DrawText(*pData.BoxTextInContextLocal->desc,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.BoxTextInContextLocal->box,pData.BoxTextInContextLocal->baselineOffset,
sl@0
   585
							  BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextInContextLocal->horiz),pData.BoxTextInContextLocal->leftMrg);
sl@0
   586
				}
sl@0
   587
			break;
sl@0
   588
		case EWsGcOpDrawLine:
sl@0
   589
			iGc->DrawLine(pData.DrawLine->pnt1,pData.DrawLine->pnt2);
sl@0
   590
			break;
sl@0
   591
		case EWsGcOpDrawTo:
sl@0
   592
			iGc->DrawLine(iLinePos,*pData.Point);
sl@0
   593
			break;
sl@0
   594
		case EWsGcOpDrawBy:
sl@0
   595
			iGc->DrawLine(iLinePos,iLinePos+(*pData.Point));
sl@0
   596
			break;
sl@0
   597
		case EWsGcOpPlot:
sl@0
   598
			iGc->Plot(*pData.Point);
sl@0
   599
			break;
sl@0
   600
		case EWsGcOpMoveTo:
sl@0
   601
		case EWsGcOpMoveBy:
sl@0
   602
			break;
sl@0
   603
		case EWsGcOpGdiBlt2Local:
sl@0
   604
			iGc->BitBlt(pData.GdiBlt2Local->pos,*pData.GdiBlt2Local->bitmap);
sl@0
   605
			break;
sl@0
   606
		case EWsGcOpGdiBlt3Local:
sl@0
   607
			iGc->BitBlt(pData.GdiBlt3Local->pos,*pData.GdiBlt3Local->bitmap, pData.GdiBlt3Local->rect);
sl@0
   608
			break;
sl@0
   609
		case EWsGcOpGdiBltMaskedLocal:
sl@0
   610
			iGc->BitBltMasked(pData.GdiBltMaskedLocal->pos,*pData.GdiBltMaskedLocal->bitmap,
sl@0
   611
								pData.GdiBltMaskedLocal->rect,*pData.GdiBltMaskedLocal->maskBitmap,
sl@0
   612
								pData.GdiBltMaskedLocal->invertMask);
sl@0
   613
			break;
sl@0
   614
		case EWsGcOpGdiWsBlt2:
sl@0
   615
		case EWsGcOpGdiWsBlt3:
sl@0
   616
		case EWsGcOpGdiWsBltMasked:
sl@0
   617
		case EWsGcOpGdiWsAlphaBlendBitmaps:
sl@0
   618
		case EWsGcOpWsDrawBitmapMasked:
sl@0
   619
			{
sl@0
   620
			CFbsBitmap* scratchBitmap = NULL;
sl@0
   621
			CFbsBitmap* scratchMaskBimap = NULL;
sl@0
   622
			TInt maskHandle=0;
sl@0
   623
			TInt handle=WsBitmapHandle(aOpcode,pData, maskHandle);
sl@0
   624
			CWsClient* owner=iWin->WsOwner();
sl@0
   625
			if (owner!=NULL)
sl@0
   626
				{
sl@0
   627
				TInt wsBmpErr = KErrNone;
sl@0
   628
				DWsBitmap *bitmap=(DWsBitmap *)owner->HandleToObj(handle, WS_HANDLE_BITMAP);
sl@0
   629
				if (!bitmap)
sl@0
   630
					wsBmpErr = KErrNotFound;
sl@0
   631
				else
sl@0
   632
					scratchBitmap=bitmap->FbsBitmap();
sl@0
   633
				if (wsBmpErr == KErrNone)
sl@0
   634
					if (aOpcode==EWsGcOpGdiWsBltMasked || aOpcode==EWsGcOpGdiWsAlphaBlendBitmaps || aOpcode==EWsGcOpWsDrawBitmapMasked)
sl@0
   635
						{
sl@0
   636
						DWsBitmap *bitmap2=(DWsBitmap *)owner->HandleToObj(maskHandle, WS_HANDLE_BITMAP);
sl@0
   637
						if (!bitmap2)
sl@0
   638
							wsBmpErr = KErrNotFound;
sl@0
   639
						else
sl@0
   640
							scratchMaskBimap=bitmap2->FbsBitmap();
sl@0
   641
						}
sl@0
   642
				if (wsBmpErr == KErrNone)
sl@0
   643
					{
sl@0
   644
					switch(aOpcode)
sl@0
   645
						{
sl@0
   646
						case EWsGcOpGdiWsBlt2:
sl@0
   647
							iGc->BitBlt(pData.GdiBlt2->pos,*scratchBitmap);
sl@0
   648
							break;
sl@0
   649
						case EWsGcOpGdiWsBlt3:
sl@0
   650
							iGc->BitBlt(pData.GdiBlt3->pos,*scratchBitmap, pData.GdiBlt3->rect);
sl@0
   651
							break;
sl@0
   652
						case EWsGcOpGdiWsBltMasked:
sl@0
   653
							{
sl@0
   654
							iGc->BitBltMasked(pData.GdiBltMasked->destination,*scratchBitmap,
sl@0
   655
											pData.GdiBltMasked->source, *scratchMaskBimap,
sl@0
   656
											pData.GdiBltMasked->invertMask);
sl@0
   657
							}
sl@0
   658
							break;
sl@0
   659
						case EWsGcOpGdiWsAlphaBlendBitmaps:
sl@0
   660
							{
sl@0
   661
							iGc->BitBltMasked(pData.AlphaBlendBitmaps->point,*scratchBitmap,
sl@0
   662
											   pData.AlphaBlendBitmaps->source, *scratchMaskBimap,
sl@0
   663
											   pData.AlphaBlendBitmaps->alphaPoint);
sl@0
   664
							}
sl@0
   665
							break;
sl@0
   666
						case EWsGcOpWsDrawBitmapMasked:
sl@0
   667
							{
sl@0
   668
							iGc->DrawBitmapMasked(pData.iBitmapMasked->iRect,*scratchBitmap, 
sl@0
   669
												pData.iBitmapMasked->iSrcRect,*scratchMaskBimap,
sl@0
   670
												pData.iBitmapMasked->iInvertMask);
sl@0
   671
							}
sl@0
   672
							break;
sl@0
   673
						}
sl@0
   674
					}
sl@0
   675
				}
sl@0
   676
			break;
sl@0
   677
			}
sl@0
   678
		case EWsGcOpGdiBlt2:
sl@0
   679
		case EWsGcOpGdiBlt3:
sl@0
   680
        case EWsGcOpDrawBitmap:
sl@0
   681
        case EWsGcOpDrawBitmap2:
sl@0
   682
        case EWsGcOpDrawBitmap3:
sl@0
   683
            {
sl@0
   684
			TInt bitmapMaskHandle=0;
sl@0
   685
            TInt bitmapHandle = FbsBitmapHandle(aOpcode, pData, bitmapMaskHandle);
sl@0
   686
            const CFbsBitmap* bitmap = iWin->Redraw()->BitmapFromHandle(bitmapHandle);
sl@0
   687
			if(!bitmap)
sl@0
   688
			    {
sl@0
   689
			    WS_PANIC_DEBUG(EWsPanicBitmapNotFound);
sl@0
   690
			    break;
sl@0
   691
			    }
sl@0
   692
			
sl@0
   693
            switch(aOpcode)
sl@0
   694
                {
sl@0
   695
                case EWsGcOpGdiBlt2:
sl@0
   696
                    iGc->BitBlt(pData.GdiBlt2->pos,*bitmap);
sl@0
   697
                    break;
sl@0
   698
                case EWsGcOpGdiBlt3:
sl@0
   699
                    iGc->BitBlt(pData.GdiBlt3->pos,*bitmap, pData.GdiBlt3->rect);
sl@0
   700
                    break;
sl@0
   701
                case EWsGcOpDrawBitmap:
sl@0
   702
                    {
sl@0
   703
                    // DrawBitmap(TPoint&, ) uses the size of the bitmap in twips, but 
sl@0
   704
                    // MWsGraphicsContext::DrawBitmap() takes a TRect in pixels, so we need to convert
sl@0
   705
                    TRect destRect(iWin->Screen()->DeviceMap().TwipsToPixels(bitmap->SizeInTwips()));
sl@0
   706
                    destRect.Move(pData.Bitmap->pos); //pos is defined in pixels, that's why we're not converting it
sl@0
   707
                    iGc->DrawBitmap(destRect, *bitmap);
sl@0
   708
                    break;
sl@0
   709
                    }
sl@0
   710
                case EWsGcOpDrawBitmap2:
sl@0
   711
                    iGc->DrawBitmap(pData.Bitmap2->rect, *bitmap);
sl@0
   712
                    break;
sl@0
   713
                case EWsGcOpDrawBitmap3:
sl@0
   714
                    iGc->DrawBitmap(pData.Bitmap3->rect, *bitmap, pData.Bitmap3->srcRect);
sl@0
   715
                    break;
sl@0
   716
                }
sl@0
   717
			break;
sl@0
   718
            }
sl@0
   719
        case EWsGcOpGdiBltMasked:
sl@0
   720
        case EWsGcOpGdiAlphaBlendBitmaps:
sl@0
   721
        case EWsGcOpDrawBitmapMasked:
sl@0
   722
            {
sl@0
   723
            TInt bitmapMaskHandle=0;
sl@0
   724
            TInt bitmapHandle = FbsBitmapHandle(aOpcode, pData, bitmapMaskHandle);
sl@0
   725
            const CFbsBitmap* bitmap = iWin->Redraw()->BitmapFromHandle(bitmapHandle);
sl@0
   726
            if(!bitmap)
sl@0
   727
                {
sl@0
   728
                WS_PANIC_DEBUG(EWsPanicBitmapNotFound);
sl@0
   729
                break;
sl@0
   730
                }
sl@0
   731
            
sl@0
   732
            CFbsBitmap* bitmapMask = iWin->Redraw()->BitmapFromHandle(bitmapMaskHandle);
sl@0
   733
            if(!bitmapMask)
sl@0
   734
                {
sl@0
   735
                WS_PANIC_DEBUG(EWsPanicBitmapNotFound);
sl@0
   736
                break;
sl@0
   737
                }
sl@0
   738
                        
sl@0
   739
            switch(aOpcode)
sl@0
   740
                {
sl@0
   741
                case EWsGcOpGdiBltMasked:
sl@0
   742
                    {
sl@0
   743
                    iGc->BitBltMasked(pData.GdiBltMasked->destination,*bitmap,
sl@0
   744
                                        pData.GdiBltMasked->source, *bitmapMask,
sl@0
   745
                                        pData.GdiBltMasked->invertMask);
sl@0
   746
                    break;
sl@0
   747
                    }
sl@0
   748
                case EWsGcOpGdiAlphaBlendBitmaps:
sl@0
   749
                    {
sl@0
   750
                    iGc->BitBltMasked(pData.AlphaBlendBitmaps->point, *bitmap,
sl@0
   751
                                        pData.AlphaBlendBitmaps->source, *bitmapMask,
sl@0
   752
                                        pData.AlphaBlendBitmaps->alphaPoint);
sl@0
   753
                    break;
sl@0
   754
                    }
sl@0
   755
                case EWsGcOpDrawBitmapMasked:
sl@0
   756
                    {
sl@0
   757
                    iGc->DrawBitmapMasked(pData.iBitmapMasked->iRect, *bitmap, 
sl@0
   758
                                        pData.iBitmapMasked->iSrcRect, *bitmapMask,
sl@0
   759
                                        pData.iBitmapMasked->iInvertMask);
sl@0
   760
                    break;
sl@0
   761
                    }
sl@0
   762
                }
sl@0
   763
			break;
sl@0
   764
			}
sl@0
   765
		case EWsGcOpDrawSegmentedPolygon:
sl@0
   766
			{
sl@0
   767
			TArrayWrapper<TPoint> points(iPolyPoints, iPolyPointListSize);
sl@0
   768
			iGc->DrawPolygon(points, BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawSegmentedPolygon->fillRule));
sl@0
   769
			break;
sl@0
   770
			}
sl@0
   771
		case EWsGcOpDrawPolygon:
sl@0
   772
			DoDrawPolygon(pData.Polygon);
sl@0
   773
			break;
sl@0
   774
		case EWsGcOpDrawPolyLine:
sl@0
   775
			DoDrawPolyLine(pData.PolyLine, EFalse);
sl@0
   776
			break;
sl@0
   777
		case EWsGcOpDrawPolyLineContinued:
sl@0
   778
			DoDrawPolyLine(pData.PolyLine, ETrue);
sl@0
   779
			break;
sl@0
   780
		case EWsGcOpClear:
sl@0
   781
			iGc->Clear(TRect(iWin->Size()));
sl@0
   782
			break;
sl@0
   783
		case EWsGcOpClearRect:
sl@0
   784
			iGc->Clear(*pData.Rect);
sl@0
   785
			break;
sl@0
   786
		case EWsGcOpDrawRect:
sl@0
   787
			iGc->DrawRect(*pData.Rect);
sl@0
   788
			break;
sl@0
   789
		case EWsGcOpDrawEllipse:
sl@0
   790
			iGc->DrawEllipse(*pData.Rect);
sl@0
   791
			break;
sl@0
   792
		case EWsGcOpDrawRoundRect:
sl@0
   793
			iGc->DrawRoundRect(*pData.Rect,pData.RoundRect->ellipse);
sl@0
   794
			break;
sl@0
   795
		case EWsGcOpDrawArc:
sl@0
   796
			iGc->DrawArc(*pData.Rect,pData.ArcOrPie->start,pData.ArcOrPie->end);
sl@0
   797
			break;
sl@0
   798
		case EWsGcOpDrawPie:
sl@0
   799
			iGc->DrawPie(*pData.Rect,pData.ArcOrPie->start,pData.ArcOrPie->end);
sl@0
   800
			break;
sl@0
   801
		case EWsGcOpCopyRect:
sl@0
   802
			iGc->CopyRect(pData.CopyRect->pos,*pData.Rect);
sl@0
   803
			break;
sl@0
   804
		case EWsGcOpMapColors:
sl@0
   805
			GcOwnerPanic(EWservPanicOpcode); //deprecated, the client should never generate this op
sl@0
   806
			break;
sl@0
   807
		case EWsGcOpSetShadowColor:
sl@0
   808
			iGc->SetTextShadowColor(*pData.rgb);
sl@0
   809
			break;
sl@0
   810
		case EWsGcOpDrawResourceToPos:
sl@0
   811
		case EWsGcOpDrawResourceToRect:
sl@0
   812
		case EWsGcOpDrawResourceFromRectToRect:
sl@0
   813
		case EWsGcOpDrawResourceWithData:
sl@0
   814
			DoDrawResource(aOpcode, pData);
sl@0
   815
			break;
sl@0
   816
		default:
sl@0
   817
			TRAP_IGNORE(iWin->OwnerPanic(EWservPanicOpcode));
sl@0
   818
			break;
sl@0
   819
		}
sl@0
   820
	iGc->ResetClippingRegion();
sl@0
   821
	iCurrentClippingRegion = NULL;
sl@0
   822
	if (bGcDrawingOccurred)
sl@0
   823
		{
sl@0
   824
		GcDrawingDone();	//up the count (again for CRPs)
sl@0
   825
		}
sl@0
   826
	}
sl@0
   827
/**
sl@0
   828
 Helper function for drawing resources. 
sl@0
   829
 It extracts DWsDrawableSource objects which corresponds RWsDrawableResource object on the server side and then redirect call to concrete implementation. 
sl@0
   830
 @param aOpcode GC opcodes
sl@0
   831
 @param aData An extra data which will be used for resource drawing 
sl@0
   832
 */
sl@0
   833
void CPlaybackGc::DoDrawResource(TWsGcOpcodes aOpcode, const TWsGcCmdUnion &aData)
sl@0
   834
	{
sl@0
   835
	CWsClient* owner=iWin->WsOwner(); // We can't just use iWsOwner - it can be null for stored commands
sl@0
   836
	if (owner!=NULL)
sl@0
   837
		{
sl@0
   838
		CWsDrawableSource *drawable = static_cast<CWsDrawableSource*>(owner->HandleToObj(*aData.Int, WS_HANDLE_DRAWABLE_SOURCE));
sl@0
   839
		if (!drawable)
sl@0
   840
			return;
sl@0
   841
		
sl@0
   842
		switch(aOpcode)
sl@0
   843
			{
sl@0
   844
		case EWsGcOpDrawResourceToPos:
sl@0
   845
			drawable->DrawResource(iGc, aData.DrawWsResourceToPos->pos, aData.DrawWsResourceToPos->rotation);
sl@0
   846
			break;
sl@0
   847
		case EWsGcOpDrawResourceToRect:
sl@0
   848
			drawable->DrawResource(iGc, aData.DrawWsResourceToRect->rect, aData.DrawWsResourceToRect->rotation);
sl@0
   849
			break;
sl@0
   850
		case EWsGcOpDrawResourceFromRectToRect:
sl@0
   851
			drawable->DrawResource(iGc, aData.DrawWsResourceFromRectToRect->rectDest, aData.DrawWsResourceFromRectToRect->rectSrc, aData.DrawWsResourceFromRectToRect->rotation);
sl@0
   852
			break;
sl@0
   853
		case EWsGcOpDrawResourceWithData:
sl@0
   854
			drawable->DrawResource(iGc, aData.DrawWsResourceWithData->rect, *aData.DrawWsResourceWithData->desc);
sl@0
   855
			break;
sl@0
   856
		default:
sl@0
   857
			break;
sl@0
   858
			}
sl@0
   859
		}
sl@0
   860
	}
sl@0
   861
sl@0
   862
TInt CPlaybackGc::WsBitmapHandle(TInt aOpcode, const TWsGcCmdUnion &pData, TInt& aMaskHandle) 
sl@0
   863
	{
sl@0
   864
	TInt handle=0;
sl@0
   865
	switch(aOpcode)
sl@0
   866
		{
sl@0
   867
		case EWsGcOpGdiWsBlt2:
sl@0
   868
			handle=pData.GdiBlt2->handle;
sl@0
   869
			break;
sl@0
   870
		case EWsGcOpGdiWsBlt3:
sl@0
   871
			handle=pData.GdiBlt3->handle;
sl@0
   872
			break;
sl@0
   873
		case EWsGcOpGdiWsBltMasked:
sl@0
   874
			handle=pData.GdiBltMasked->handle;
sl@0
   875
			aMaskHandle = pData.GdiBltMasked->maskHandle;
sl@0
   876
			break;
sl@0
   877
		case EWsGcOpGdiWsAlphaBlendBitmaps:
sl@0
   878
			handle=pData.AlphaBlendBitmaps->bitmapHandle;
sl@0
   879
			aMaskHandle = pData.AlphaBlendBitmaps->alphaHandle;
sl@0
   880
			break;
sl@0
   881
		case EWsGcOpWsDrawBitmapMasked:
sl@0
   882
			handle=pData.iBitmapMasked->iHandle;
sl@0
   883
			aMaskHandle=pData.iBitmapMasked->iMaskHandle;
sl@0
   884
			break;
sl@0
   885
		}
sl@0
   886
	return handle;
sl@0
   887
	}		
sl@0
   888
sl@0
   889
TInt CPlaybackGc::FbsBitmapHandle(TInt aOpcode, const TWsGcCmdUnion &pData, TInt& aMaskHandle)
sl@0
   890
	{
sl@0
   891
	TInt handle=0;
sl@0
   892
	aMaskHandle=0;
sl@0
   893
	switch(aOpcode)
sl@0
   894
		{
sl@0
   895
		case EWsGcOpGdiBlt2:
sl@0
   896
			handle=pData.GdiBlt2->handle;
sl@0
   897
			break;
sl@0
   898
		case EWsGcOpGdiBlt3:
sl@0
   899
			handle=pData.GdiBlt3->handle;
sl@0
   900
			break;
sl@0
   901
		case EWsGcOpGdiBltMasked:
sl@0
   902
			handle=pData.GdiBltMasked->handle;
sl@0
   903
			aMaskHandle=pData.GdiBltMasked->maskHandle;
sl@0
   904
			break;
sl@0
   905
		case EWsGcOpGdiAlphaBlendBitmaps:
sl@0
   906
			handle=pData.AlphaBlendBitmaps->bitmapHandle;
sl@0
   907
			aMaskHandle=pData.AlphaBlendBitmaps->alphaHandle;
sl@0
   908
			break;
sl@0
   909
		case EWsGcOpDrawBitmap:
sl@0
   910
			handle=pData.Bitmap->handle;
sl@0
   911
			break;
sl@0
   912
		case EWsGcOpDrawBitmap2:
sl@0
   913
			handle=pData.Bitmap2->handle;
sl@0
   914
			break;
sl@0
   915
		case EWsGcOpDrawBitmap3:
sl@0
   916
			handle=pData.Bitmap3->handle;
sl@0
   917
			break;
sl@0
   918
		case EWsGcOpDrawBitmapMasked:
sl@0
   919
			handle=pData.iBitmapMasked->iHandle;
sl@0
   920
			aMaskHandle=pData.iBitmapMasked->iMaskHandle;
sl@0
   921
			break;
sl@0
   922
		default:
sl@0
   923
			WS_ASSERT_DEBUG(EFalse, EWsPanicInvalidOperation);
sl@0
   924
			break;
sl@0
   925
		}
sl@0
   926
	return handle;
sl@0
   927
	}
sl@0
   928
sl@0
   929
void CPlaybackGc::UpdateJustification(TText* aText,TInt aLen,const TDesC8& aCmdData,CGraphicsContext::TTextParameters* aParam)
sl@0
   930
	{
sl@0
   931
	iGc->UpdateJustification(BufferTPtr(aText,aLen,aCmdData), BitGdiToMWsGraphicsContextMappings::Convert(aParam));
sl@0
   932
	}
sl@0
   933
sl@0
   934
void CPlaybackGc::SendOriginIfRequired()
sl@0
   935
    {
sl@0
   936
    const TPoint currentOrigin(iMasterOrigin + iOrigin); 
sl@0
   937
    if (iSendOrigin || currentOrigin != iLastSentOrigin)
sl@0
   938
        {
sl@0
   939
        iGc->SetOrigin(currentOrigin);
sl@0
   940
        iLastSentOrigin = currentOrigin;
sl@0
   941
        iSendOrigin = EFalse;
sl@0
   942
        }
sl@0
   943
    }
sl@0
   944
sl@0
   945
void CPlaybackGc::SendClippingRegionIfRequired(const TRegion* aRegion)
sl@0
   946
    {
sl@0
   947
    if (iUserDefinedClippingRegion || iClippingRectSet || !iWin->Screen()->ChangeTracking())
sl@0
   948
        {
sl@0
   949
        iGc->SetClippingRegion(*aRegion);
sl@0
   950
        }
sl@0
   951
    }
sl@0
   952
sl@0
   953
void CPlaybackGc::DoDrawing(TWsGcOpcodes aOpcode, const TDesC8& aCmdData)
sl@0
   954
	{
sl@0
   955
	TWsGcCmdUnion pData;
sl@0
   956
	// coverity[returned_pointer]
sl@0
   957
	pData.any=aCmdData.Ptr();
sl@0
   958
sl@0
   959
	iIntersectedRegion.Clear();
sl@0
   960
	iIntersectedRegion.Copy(*iDrawRegion);
sl@0
   961
	
sl@0
   962
	if (iClippingRectSet)
sl@0
   963
		{
sl@0
   964
	    // MWsGraphicsContext doesn't provide a SetClippingRect API. If a client calls SetClippingRect
sl@0
   965
	    // the rect is passed to the render stage using MWsGraphicsContext::SetClippingRegion
sl@0
   966
        TRect clippingRectRelativeToScreen(iClippingRect);
sl@0
   967
        clippingRectRelativeToScreen.Move(iMasterOrigin);
sl@0
   968
		iIntersectedRegion.ClipRect(clippingRectRelativeToScreen);
sl@0
   969
        iIntersectedRegion.ClipRect(iWin->AbsRect());
sl@0
   970
		}
sl@0
   971
sl@0
   972
	SendOriginIfRequired();
sl@0
   973
	
sl@0
   974
	DoDrawCommand(aOpcode,aCmdData,&iIntersectedRegion);
sl@0
   975
sl@0
   976
	CGraphicsContext::TTextParameters contextParam;
sl@0
   977
	switch(aOpcode)
sl@0
   978
		{
sl@0
   979
		case EWsGcOpDrawLine:
sl@0
   980
			iLinePos=pData.DrawLine->pnt2;
sl@0
   981
			break;
sl@0
   982
		case EWsGcOpDrawTo:
sl@0
   983
		case EWsGcOpMoveTo:
sl@0
   984
		case EWsGcOpPlot:
sl@0
   985
			iLinePos=(*pData.Point);
sl@0
   986
			break;
sl@0
   987
		case EWsGcOpDrawBy:
sl@0
   988
		case EWsGcOpMoveBy:
sl@0
   989
			iLinePos+=(*pData.Point);
sl@0
   990
			break;
sl@0
   991
		case EWsGcOpDrawSegmentedPolygon:
sl@0
   992
			EndSegmentedPolygon();
sl@0
   993
			break;
sl@0
   994
		case EWsGcOpDrawText:
sl@0
   995
			UpdateJustification((TText *)(pData.DrawText+1),pData.DrawText->length,aCmdData,NULL);
sl@0
   996
			break;
sl@0
   997
		case EWsGcOpDrawTextVertical:
sl@0
   998
			UpdateJustification((TText *)(pData.DrawTextVertical+1),pData.DrawTextVertical->length,aCmdData,NULL);
sl@0
   999
			break;
sl@0
  1000
		case EWsGcOpDrawBoxText:
sl@0
  1001
			UpdateJustification((TText *)(pData.BoxText+1),pData.BoxText->length,aCmdData,NULL);
sl@0
  1002
			break;
sl@0
  1003
		case EWsGcOpDrawBoxTextOptimised1:
sl@0
  1004
			UpdateJustification((TText *)(pData.BoxTextO1+1),pData.BoxTextO1->length,aCmdData,NULL);
sl@0
  1005
			break;
sl@0
  1006
		case EWsGcOpDrawBoxTextOptimised2:
sl@0
  1007
			UpdateJustification((TText *)(pData.BoxTextO2+1),pData.BoxTextO2->length,aCmdData,NULL);
sl@0
  1008
			break;
sl@0
  1009
		case EWsGcOpDrawBoxTextVertical:
sl@0
  1010
			UpdateJustification((TText *)(pData.DrawBoxTextVertical+1),pData.DrawBoxTextVertical->length,aCmdData,NULL);
sl@0
  1011
			break;
sl@0
  1012
		case EWsGcOpDrawTextLocal:
sl@0
  1013
			iGc->UpdateJustification(*pData.DrawTextLocal->desc,NULL);
sl@0
  1014
			break;
sl@0
  1015
		case EWsGcOpDrawBoxTextLocal:
sl@0
  1016
			iGc->UpdateJustification(*pData.BoxTextLocal->desc,NULL);
sl@0
  1017
			break;
sl@0
  1018
		case EWsGcOpDrawTextPtr:
sl@0
  1019
			iGc->UpdateJustification(*pData.DrawTextPtr->text,NULL);
sl@0
  1020
			break;
sl@0
  1021
		case EWsGcOpDrawTextVerticalPtr:
sl@0
  1022
			iGc->UpdateJustification(*pData.DrawTextVerticalPtr->text,NULL);
sl@0
  1023
			break;
sl@0
  1024
		case EWsGcOpDrawBoxTextPtr:
sl@0
  1025
			iGc->UpdateJustification(*pData.DrawBoxTextPtr->text,NULL);
sl@0
  1026
			break;
sl@0
  1027
		case EWsGcOpDrawBoxTextVerticalPtr:
sl@0
  1028
			iGc->UpdateJustification(*pData.DrawBoxTextVerticalPtr->text,NULL);
sl@0
  1029
			break;
sl@0
  1030
		/***************DrawTextInContext*****************************************************************/
sl@0
  1031
		case EWsGcOpDrawTextInContext:
sl@0
  1032
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1033
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1034
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1035
				{
sl@0
  1036
				UpdateJustification((TText *)(pData.DrawTextInContext+1),pData.DrawTextInContext->length,aCmdData,&contextParam);
sl@0
  1037
				}
sl@0
  1038
			break;
sl@0
  1039
		case EWsGcOpDrawTextInContextVertical:
sl@0
  1040
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1041
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1042
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1043
				{
sl@0
  1044
				UpdateJustification((TText *)(pData.DrawTextInContextVertical+1),pData.DrawTextInContextVertical->length,aCmdData,&contextParam);
sl@0
  1045
				}
sl@0
  1046
			break;
sl@0
  1047
		case EWsGcOpDrawBoxTextInContext:
sl@0
  1048
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1049
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1050
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1051
				{
sl@0
  1052
				UpdateJustification((TText *)(pData.BoxTextInContext+1),pData.BoxTextInContext->length,aCmdData,&contextParam);
sl@0
  1053
				}
sl@0
  1054
			break;
sl@0
  1055
		case EWsGcOpDrawBoxTextInContextOptimised1:
sl@0
  1056
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1057
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1058
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1059
				{
sl@0
  1060
				UpdateJustification((TText *)(pData.BoxTextInContextO1+1),pData.BoxTextInContextO1->length,aCmdData,&contextParam);
sl@0
  1061
				}
sl@0
  1062
			break;
sl@0
  1063
		case EWsGcOpDrawBoxTextInContextOptimised2:
sl@0
  1064
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1065
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1066
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1067
				{
sl@0
  1068
				UpdateJustification((TText *)(pData.BoxTextInContextO2+1),pData.BoxTextInContextO2->length,aCmdData,&contextParam);
sl@0
  1069
				}
sl@0
  1070
			break;
sl@0
  1071
		case EWsGcOpDrawBoxTextInContextVertical:
sl@0
  1072
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1073
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1074
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1075
				{
sl@0
  1076
				UpdateJustification((TText *)(pData.DrawBoxTextInContextVertical+1),pData.DrawBoxTextInContextVertical->length,aCmdData,&contextParam);
sl@0
  1077
				}
sl@0
  1078
			break;
sl@0
  1079
		case EWsGcOpDrawTextInContextLocal:
sl@0
  1080
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1081
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1082
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1083
				{
sl@0
  1084
				iGc->UpdateJustification(*pData.DrawTextInContextLocal->desc,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
sl@0
  1085
				}
sl@0
  1086
			break;
sl@0
  1087
		case EWsGcOpDrawBoxTextInContextLocal:
sl@0
  1088
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1089
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1090
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1091
				{
sl@0
  1092
				iGc->UpdateJustification(*pData.BoxTextInContextLocal->desc,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
sl@0
  1093
				}
sl@0
  1094
			break;
sl@0
  1095
		case EWsGcOpDrawTextInContextPtr:
sl@0
  1096
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1097
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1098
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1099
				{
sl@0
  1100
				iGc->UpdateJustification(*pData.DrawTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
sl@0
  1101
				}
sl@0
  1102
			break;
sl@0
  1103
		case EWsGcOpDrawTextInContextVerticalPtr:
sl@0
  1104
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1105
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1106
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1107
				{
sl@0
  1108
				iGc->UpdateJustification(*pData.DrawTextInContextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
sl@0
  1109
				}
sl@0
  1110
			break;
sl@0
  1111
		case EWsGcOpDrawBoxTextInContextPtr:
sl@0
  1112
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1113
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1114
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1115
				{
sl@0
  1116
				iGc->UpdateJustification(*pData.DrawBoxTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
sl@0
  1117
				}
sl@0
  1118
			break;
sl@0
  1119
		case EWsGcOpDrawBoxTextInContextVerticalPtr:
sl@0
  1120
			contextParam.iStart = pData.DrawTextInContext->start;
sl@0
  1121
			contextParam.iEnd = pData.DrawTextInContext->end;
sl@0
  1122
			if(contextParam.iStart < contextParam.iEnd)
sl@0
  1123
				{
sl@0
  1124
				iGc->UpdateJustification(*pData.DrawBoxTextInContextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
sl@0
  1125
				}
sl@0
  1126
			break;
sl@0
  1127
		}
sl@0
  1128
	}
sl@0
  1129
sl@0
  1130
void CPlaybackGc::CommandL(TWsGcOpcodes aOpcode, const TDesC8& aCmdData)
sl@0
  1131
	{
sl@0
  1132
    WS_ASSERT_DEBUG(iWin,EWsPanicWindowNull);
sl@0
  1133
	TWsGcCmdUnion pData;
sl@0
  1134
	// coverity[returned_pointer]
sl@0
  1135
	pData.any=aCmdData.Ptr();
sl@0
  1136
	
sl@0
  1137
	switch(aOpcode)
sl@0
  1138
		{
sl@0
  1139
	case EWsGcOpStartSegmentedDrawPolygon:
sl@0
  1140
		StartSegmentedDrawPolygonL(pData.StartSegmentedDrawPolygon);
sl@0
  1141
		break;
sl@0
  1142
	case EWsGcOpSegmentedDrawPolygonData:
sl@0
  1143
		SegmentedDrawPolygonData(pData.SegmentedDrawPolygonData);
sl@0
  1144
		break;
sl@0
  1145
	case EWsGcOpSetClippingRegion:
sl@0
  1146
		WS_ASSERT_DEBUG(aOpcode != EWsGcOpSetClippingRegion, EWsPanicDrawCommandsInvalidState);
sl@0
  1147
		break;
sl@0
  1148
	case EWsGcOpSetClippingRect:
sl@0
  1149
		SetClippingRect(*pData.Rect);
sl@0
  1150
		break;
sl@0
  1151
	case EWsGcOpCancelClippingRect:
sl@0
  1152
		ResetClippingRect();
sl@0
  1153
		break;
sl@0
  1154
	case EWsGcOpCancelClippingRegion:
sl@0
  1155
		CancelUserClippingRegion();
sl@0
  1156
		break;
sl@0
  1157
	case EWsGcOpSetFaded: // deprecated
sl@0
  1158
		// do nothing
sl@0
  1159
		break;
sl@0
  1160
	case EWsGcOpSetFadeParams: // deprecated
sl@0
  1161
		// do nothing
sl@0
  1162
		break;
sl@0
  1163
	case EWsGcOpSetDrawMode:
sl@0
  1164
		iGc->SetDrawMode(BitGdiToMWsGraphicsContextMappings::LossyConvert((CGraphicsContext::TDrawMode)*pData.UInt));
sl@0
  1165
		break;
sl@0
  1166
	case EWsGcOpUseFont:
sl@0
  1167
		if (CWsFontCache::Instance()->UseFont(iFont, *pData.UInt))
sl@0
  1168
			{
sl@0
  1169
			CFbsBitGcFont font;
sl@0
  1170
			if(font.Duplicate(*pData.UInt) == KErrNone)
sl@0
  1171
				iGc->SetFont(&font);
sl@0
  1172
			font.Reset();
sl@0
  1173
			}
sl@0
  1174
		else
sl@0
  1175
			iGc->SetFontNoDuplicate(iFont);
sl@0
  1176
		break;
sl@0
  1177
	case EWsGcOpDiscardFont:
sl@0
  1178
		CWsFontCache::Instance()->ReleaseFont(iFont);
sl@0
  1179
		iGc->ResetFont();
sl@0
  1180
		break;
sl@0
  1181
	case EWsGcOpSetUnderlineStyle:
sl@0
  1182
		iGc->SetUnderlineStyle(BitGdiToMWsGraphicsContextMappings::Convert(*pData.SetUnderlineStyle));
sl@0
  1183
		break;
sl@0
  1184
	case EWsGcOpSetStrikethroughStyle:
sl@0
  1185
		iGc->SetStrikethroughStyle(BitGdiToMWsGraphicsContextMappings::Convert(*pData.SetStrikethroughStyle));
sl@0
  1186
		break;
sl@0
  1187
	case EWsGcOpUseBrushPattern:
sl@0
  1188
		iGc->SetBrushPattern(*pData.handle);
sl@0
  1189
		break;
sl@0
  1190
	case EWsGcOpDiscardBrushPattern:
sl@0
  1191
		iGc->ResetBrushPattern();
sl@0
  1192
		break;
sl@0
  1193
	case EWsGcOpSetBrushColor:
sl@0
  1194
		iGc->SetBrushColor(*pData.rgb);
sl@0
  1195
		break;
sl@0
  1196
	case EWsGcOpSetPenColor:
sl@0
  1197
		iGc->SetPenColor(*pData.rgb);
sl@0
  1198
		break;
sl@0
  1199
	case EWsGcOpSetPenStyle:
sl@0
  1200
		iGc->SetPenStyle(BitGdiToMWsGraphicsContextMappings::Convert((CGraphicsContext::TPenStyle)*pData.UInt));
sl@0
  1201
		break;
sl@0
  1202
	case EWsGcOpSetPenSize:
sl@0
  1203
		iGc->SetPenSize(*pData.Size);
sl@0
  1204
		break;
sl@0
  1205
	case EWsGcOpSetBrushStyle:
sl@0
  1206
		{
sl@0
  1207
		MWsGraphicsContext::TBrushStyle style = BitGdiToMWsGraphicsContextMappings::Convert((CGraphicsContext::TBrushStyle)*pData.UInt); 
sl@0
  1208
		if (iGc->HasBrushPattern() || style != MWsGraphicsContext::EPatternedBrush)
sl@0
  1209
			{
sl@0
  1210
			iGc->SetBrushStyle(style);
sl@0
  1211
			}
sl@0
  1212
		break;
sl@0
  1213
		}
sl@0
  1214
	case EWsGcOpReset:
sl@0
  1215
		CWsFontCache::Instance()->ReleaseFont(iFont);
sl@0
  1216
		iGc->Reset();
sl@0
  1217
		iOrigin.SetXY(0,0);
sl@0
  1218
		iSendOrigin = ETrue; // we must call SetOrigin at next opportunity because it's likely the render stage implementation of Reset (when resetting origin) doesn't take into account the window origin
sl@0
  1219
		ResetClippingRect();
sl@0
  1220
		iGc->SetBrushColor(iWin->BackColor());
sl@0
  1221
		break;
sl@0
  1222
	case EWsGcOpSetBrushOrigin:
sl@0
  1223
		iGc->SetBrushOrigin(*pData.Point);
sl@0
  1224
		break;
sl@0
  1225
	case EWsGcOpSetDitherOrigin:
sl@0
  1226
		GcOwnerPanic(EWservPanicOpcode); //deprecated, the client should never generate this op
sl@0
  1227
		break;
sl@0
  1228
	case EWsGcOpSetWordJustification:
sl@0
  1229
		iGc->SetWordJustification(pData.SetJustification->excessWidth, pData.SetJustification->numGaps);
sl@0
  1230
		break;
sl@0
  1231
	case EWsGcOpSetCharJustification:
sl@0
  1232
		iGc->SetCharJustification(pData.SetJustification->excessWidth, pData.SetJustification->numGaps);
sl@0
  1233
		break;
sl@0
  1234
	case EWsGcOpSetOrigin:
sl@0
  1235
		SetOrigin(*pData.Point);
sl@0
  1236
		break;
sl@0
  1237
	case EWsGcOpSetOpaque: // deprecated
sl@0
  1238
		// do nothing
sl@0
  1239
		break;
sl@0
  1240
	default:	// Assume remaining functions will draw
sl@0
  1241
		{
sl@0
  1242
		DoDrawing(aOpcode,aCmdData);
sl@0
  1243
		return;
sl@0
  1244
		}
sl@0
  1245
		}
sl@0
  1246
	}
sl@0
  1247
sl@0
  1248
sl@0
  1249
void CPlaybackGc::SetOrigin(const TPoint &aOrigin)
sl@0
  1250
	{
sl@0
  1251
	iOrigin=aOrigin;
sl@0
  1252
	}
sl@0
  1253
	
sl@0
  1254
/*------------------------------------------------------------------------------
sl@0
  1255
  Description: Retrieves graphics context information back from a given buffer
sl@0
  1256
               from a given start position.
sl@0
  1257
 -----------------------------------------------------------------------------*/
sl@0
  1258
void CPlaybackGc::InternalizeL(const CBufBase& aBuffer,TInt& aStartPos)
sl@0
  1259
	{
sl@0
  1260
	// Open the stream used for the input from the given start position
sl@0
  1261
	// in the buffer.
sl@0
  1262
	RBufReadStream bufReadStream;
sl@0
  1263
	bufReadStream.Open(aBuffer,aStartPos);
sl@0
  1264
	CleanupClosePushL(bufReadStream);
sl@0
  1265
	
sl@0
  1266
	// Read the font/bitmap server data
sl@0
  1267
	TInternalGcStatus::InternalizeGcAttributesL(iGc, bufReadStream);
sl@0
  1268
sl@0
  1269
	iOrigin.iX = bufReadStream.ReadInt32L();
sl@0
  1270
	iOrigin.iY = bufReadStream.ReadInt32L();
sl@0
  1271
	iSendOrigin = ETrue;
sl@0
  1272
sl@0
  1273
	iClippingRectSet=bufReadStream.ReadInt8L();
sl@0
  1274
	
sl@0
  1275
	// If there is a clipping rectangle data read it.
sl@0
  1276
	if (iClippingRectSet)
sl@0
  1277
		bufReadStream>>iClippingRect;
sl@0
  1278
		
sl@0
  1279
	// Read the clipping region data
sl@0
  1280
	InternalizeClippingRegionL(bufReadStream);
sl@0
  1281
sl@0
  1282
	// Read the Alpha values for Brush and Pen colors.
sl@0
  1283
	InternalizeAlphaValueL(bufReadStream);
sl@0
  1284
	
sl@0
  1285
	CleanupStack::PopAndDestroy(&bufReadStream);
sl@0
  1286
	}
sl@0
  1287
sl@0
  1288
/*------------------------------------------------------------------------------
sl@0
  1289
  Description: Retrieves TRgb::alpha value information back from a given buffer
sl@0
  1290
               and updates the Brushcolor with the same.
sl@0
  1291
 -----------------------------------------------------------------------------*/
sl@0
  1292
void CPlaybackGc::InternalizeAlphaValueL(RReadStream& aReadStream)
sl@0
  1293
	{
sl@0
  1294
	TRgb brushColor(iGc->BrushColor());
sl@0
  1295
	brushColor.SetAlpha(aReadStream.ReadUint8L());
sl@0
  1296
	iGc->SetBrushColor(brushColor);
sl@0
  1297
	TRgb penColor(iGc->PenColor());
sl@0
  1298
	penColor.SetAlpha(aReadStream.ReadUint8L());
sl@0
  1299
	iGc->SetPenColor(penColor);
sl@0
  1300
	}
sl@0
  1301
sl@0
  1302
/*------------------------------------------------------------------------------
sl@0
  1303
  Description: Helper method to retrieve clipping region data from a given
sl@0
  1304
               read stream.
sl@0
  1305
 -----------------------------------------------------------------------------*/
sl@0
  1306
void CPlaybackGc::InternalizeClippingRegionL(RReadStream& aReadStream)
sl@0
  1307
	{
sl@0
  1308
	WS_ASSERT_DEBUG(iTargetRegion, EWsPanicDrawCommandsInvalidState);
sl@0
  1309
	// Read flag to indicate if client had defined a clipping region
sl@0
  1310
	TBool clipRegion = aReadStream.ReadInt8L();
sl@0
  1311
	CancelUserClippingRegion();
sl@0
  1312
	if (clipRegion)
sl@0
  1313
		{
sl@0
  1314
		// Note that this clipping region is in window relative coordinates when
sl@0
  1315
		// received from the client (and being stored) but is in screen relative
sl@0
  1316
		// coordinates after being retrieved from the redraw store.
sl@0
  1317
		iUserDefinedClippingRegion = InternalizeRegionL(aReadStream);
sl@0
  1318
		iUserDefinedClippingRegion->Offset(iWin->Origin());
sl@0
  1319
		iUserDefinedClippingRegion->Intersect(*iTargetRegion);
sl@0
  1320
		if (iUserDefinedClippingRegion->CheckError()) // fallback to no user clipping region
sl@0
  1321
			{
sl@0
  1322
			CancelUserClippingRegion();
sl@0
  1323
			}
sl@0
  1324
		else
sl@0
  1325
			{
sl@0
  1326
			iDrawRegion = iUserDefinedClippingRegion;
sl@0
  1327
			}
sl@0
  1328
		}
sl@0
  1329
	}
sl@0
  1330
sl@0
  1331
/**
sl@0
  1332
* @deprecated
sl@0
  1333
*/
sl@0
  1334
TInt CPlaybackGc::PlaceSurface(const TSurfaceConfiguration& /*aConfig*/)
sl@0
  1335
    {
sl@0
  1336
    return KErrNotSupported;
sl@0
  1337
    }
sl@0
  1338
sl@0
  1339
/**	Get the drawing occurred indication counter.	
sl@0
  1340
  	Callers can detect if drawing has occurred between two points 
sl@0
  1341
 	by detecting that this count has changed.
sl@0
  1342
 	Note that the changed value does not necessarily represent the exact number of operations which occurred.
sl@0
  1343
  	@return value which changes each time GC drawing occurrs.
sl@0
  1344
 **/
sl@0
  1345
TInt CPlaybackGc::GcDrawingCount()
sl@0
  1346
	{
sl@0
  1347
	return iGcDrawingCounter;
sl@0
  1348
	}
sl@0
  1349
sl@0
  1350
/**	Update the drawing occurred indication counter.	
sl@0
  1351
 	Called internally each time a drawing operation updates the UI content 
sl@0
  1352
 **/
sl@0
  1353
void CPlaybackGc::GcDrawingDone()
sl@0
  1354
	{
sl@0
  1355
	iGcDrawingCounter++;
sl@0
  1356
	}
sl@0
  1357
sl@0
  1358
sl@0
  1359
/**
sl@0
  1360
This pretty much replaces the whole of what was TDrawDestination
sl@0
  1361
This can only be sensibly called from outside a sequence of drawing commands,
sl@0
  1362
since it negates any user defined clipping regions.
sl@0
  1363
*/
sl@0
  1364
void CPlaybackGc::SetTargetRegion(const TRegion* aRegion)
sl@0
  1365
	{
sl@0
  1366
	iTargetRegion = aRegion;
sl@0
  1367
	iDrawRegion = iTargetRegion;
sl@0
  1368
	CancelUserClippingRegion();
sl@0
  1369
	}
sl@0
  1370
	
sl@0
  1371
void CPlaybackGc::Reset()
sl@0
  1372
	{
sl@0
  1373
	iGc->Reset();
sl@0
  1374
	}
sl@0
  1375
sl@0
  1376
TAny * CPlaybackGc::ResolveObjectInterface(TUint aId)
sl@0
  1377
	{
sl@0
  1378
	switch (aId)
sl@0
  1379
		{
sl@0
  1380
	    case MWsSurfacePlacement::EWsObjectInterfaceId:
sl@0
  1381
	        return static_cast<MWsSurfacePlacement *>(this); //deprecated
sl@0
  1382
		case MWsWindow::EWsObjectInterfaceId:
sl@0
  1383
			return dynamic_cast<MWsWindow *>(iWin);
sl@0
  1384
		case MWsGraphicsContext::EWsObjectInterfaceId:
sl@0
  1385
			return static_cast<MWsGraphicsContext*>(iGc);
sl@0
  1386
		case MWsUiBuffer::EWsObjectInterfaceId:
sl@0
  1387
		case MWsFader::EWsObjectInterfaceId:	
sl@0
  1388
			return iWin->Screen()->ResolveObjectInterface(aId);
sl@0
  1389
		}
sl@0
  1390
	return NULL;
sl@0
  1391
	}