windowing/windowserver/nonnga/remotegc/RemoteGc.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2006-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 #include "RemoteGc.h"
       
    17 #include "RemoteGcUtils.h"
       
    18 #include "CommandBuffer.h"
       
    19 #include <graphics/gdi/gdiconsts.h>
       
    20 
       
    21 /**
       
    22 Creates a new remotegc.
       
    23 
       
    24 @param aDevice The windowserver screendevice to use.
       
    25 @param aCommandBufferObserver Pointer to a commandbufferobserver.
       
    26 @return A pointer to a new instance of CRemoteGc.
       
    27 */
       
    28 EXPORT_C CRemoteGc* CRemoteGc::NewL(CWsScreenDevice* aDevice)
       
    29 	{
       
    30 	CRemoteGc* remoteGc = new (ELeave) CRemoteGc(aDevice);
       
    31 	CleanupStack::PushL(remoteGc);
       
    32 	remoteGc->ConstructL();
       
    33 	CleanupStack::Pop(remoteGc);
       
    34 	return remoteGc;
       
    35 	}
       
    36 
       
    37 CRemoteGc::CRemoteGc(CWsScreenDevice* aDevice) : CWindowGc(aDevice), iCommandBufferObserver(NULL)
       
    38 	{	
       
    39 	}
       
    40 	
       
    41 EXPORT_C CRemoteGc::~CRemoteGc()
       
    42 	{
       
    43 	delete iCommandBuffer;	
       
    44 	}
       
    45 	
       
    46 void CRemoteGc::ConstructL()
       
    47 	{
       
    48 	User::LeaveIfError(CWindowGc::Construct());
       
    49 	iCommandBuffer = CCommandBuffer::NewL();
       
    50 	}
       
    51 	
       
    52 EXPORT_C void CRemoteGc::SetCommandBufferObserver(MCommandBufferObserver* aCommandBufferObserver)
       
    53 	{
       
    54 	iCommandBufferObserver = aCommandBufferObserver;
       
    55 	}
       
    56 
       
    57 /**
       
    58 Resets the commandbuffer.
       
    59 */
       
    60 EXPORT_C void CRemoteGc::ResetCommandBuffer()
       
    61 	{
       
    62 	iCommandBuffer->Reset();
       
    63 	}
       
    64 
       
    65 /**
       
    66 Externalizes commandbuffer sections into a format which makes it possible to send over IPC.
       
    67 If ETrue is sent as a parameter to this method, the entire commandbuffer will be externalized,
       
    68 otherwise only sections which has not been externalized before will be externalized. Note that if only
       
    69 not externalized sections is asked for, the flag will be reset on that section so next call
       
    70 to ExternalizeLC will not externalize that section.
       
    71 
       
    72 @param aMsgBuf A buffer used to externalize the commandbuffer to.
       
    73 @param aEntireBuffer If ETrue, the entire commandbuffer will be externalized, otherwise only sections which has not been externalized before.
       
    74 */	
       
    75 EXPORT_C void CRemoteGc::ExternalizeL(RWsGraphicMsgBuf& aMsgBuf, TBool aEntireBuffer)
       
    76 	{
       
    77 	return iCommandBuffer->ExternalizeL(aMsgBuf, aEntireBuffer);
       
    78 	}
       
    79 
       
    80 /**
       
    81 Prepares the remotegc to be drawn to.
       
    82 
       
    83 @param aRect The rect to be drawn.
       
    84 */
       
    85 EXPORT_C void CRemoteGc::BeginDraw(const TRect& aRect)
       
    86 	{
       
    87 	iDrawRect = aRect;
       
    88 	iBoundingRect = TRect();
       
    89 	iHasBitmapCommand = EFalse;
       
    90 	iCommandBuffer->Prepare(aRect);
       
    91 	}
       
    92  
       
    93 /**
       
    94 Finishes the current redraw.
       
    95 This method should be called when drawing to the remotegc is complete.
       
    96 */
       
    97 EXPORT_C void CRemoteGc::EndDraw()
       
    98 	{
       
    99 	iBoundingRect.Intersection(iDrawRect);
       
   100 	const TInt err = iCommandBuffer->Finish(iDrawRect, iBoundingRect, iHasBitmapCommand);
       
   101 
       
   102 	if(iCommandBufferObserver && !err)
       
   103 		iCommandBufferObserver->CommandBufferUpdated(iDrawRect, iBoundingRect); 
       
   104  	}
       
   105 
       
   106 void CRemoteGc::Activate(RDrawableWindow &aDevice)
       
   107 	{
       
   108 	BeginDraw(aDevice.GetDrawRect());
       
   109 	CWindowGc::Activate(aDevice);
       
   110 	}
       
   111 	
       
   112 void CRemoteGc::Deactivate()
       
   113 	{	
       
   114 	CWindowGc::Deactivate();
       
   115 	EndDraw();
       
   116 	}
       
   117 	
       
   118 void CRemoteGc::Clear()
       
   119 	{
       
   120 	iCommandBuffer->Write<TDrawCode>(ECommandClear);
       
   121 	iBoundingRect.BoundingRect(iDrawRect);
       
   122 	}
       
   123 	
       
   124 void CRemoteGc::Clear(const TRect& aRect)
       
   125 	{
       
   126 	iCommandBuffer->Write<TDrawCode>(ECommandClearRect);
       
   127 	iCommandBuffer->Write<TRect>(aRect);
       
   128 	iBoundingRect.BoundingRect(aRect);
       
   129 	}
       
   130 	
       
   131 void CRemoteGc::CopyRect(const TPoint &anOffset, const TRect &aRect)
       
   132 	{
       
   133 	iCommandBuffer->Write<TDrawCode>(ECommandCopyRect);
       
   134 	iCommandBuffer->Write<TPoint>(anOffset);
       
   135 	iCommandBuffer->Write<TRect>(aRect);
       
   136 	iBoundingRect.BoundingRect(iDrawRect);
       
   137 	}
       
   138 
       
   139 void CRemoteGc::BitBlt(const TPoint &aPoint, const CFbsBitmap *aBitmap)
       
   140 	{
       
   141 	__ASSERT_DEBUG(aBitmap, User::Invariant());
       
   142 	if(aBitmap)
       
   143 		{
       
   144 		iCommandBuffer->Write<TDrawCode>(ECommandBitBlt1);
       
   145 		iCommandBuffer->Write<TPoint>(aPoint);
       
   146 		iCommandBuffer->Write<TInt>(aBitmap->Handle());
       
   147 		iBoundingRect.BoundingRect(TRect(aPoint, aBitmap->SizeInPixels()));
       
   148 		iHasBitmapCommand = ETrue;
       
   149 		}
       
   150 	}
       
   151 	
       
   152 void CRemoteGc::BitBlt(const TPoint &aDestination, const CFbsBitmap *aBitmap, const TRect &aSource)
       
   153 	{
       
   154 	__ASSERT_DEBUG(aBitmap, User::Invariant());
       
   155 	if(aBitmap)
       
   156 		{	
       
   157 		iCommandBuffer->Write<TDrawCode>(ECommandBitBlt2);
       
   158 		iCommandBuffer->Write<TPoint>(aDestination);
       
   159 		iCommandBuffer->Write<TInt>(aBitmap->Handle());
       
   160 		iCommandBuffer->Write<TRect>(aSource);
       
   161 		iBoundingRect.BoundingRect(TRect(aDestination, aSource.Size()));
       
   162 		iHasBitmapCommand = ETrue;
       
   163 		}
       
   164 	}
       
   165 	
       
   166 void CRemoteGc::BitBltMasked(const TPoint& aPoint, const CFbsBitmap* aBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask)
       
   167 	{
       
   168 	__ASSERT_DEBUG(aBitmap && aMaskBitmap, User::Invariant());
       
   169 	if(aBitmap && aMaskBitmap)
       
   170 		{
       
   171 		iCommandBuffer->Write<TDrawCode>(ECommandBitBltMasked);
       
   172 		iCommandBuffer->Write<TPoint>(aPoint);
       
   173 		iCommandBuffer->Write<TInt>(aBitmap->Handle());
       
   174 		iCommandBuffer->Write<TRect>(aSourceRect);
       
   175 		iCommandBuffer->Write<TInt>(aMaskBitmap->Handle());
       
   176 		iCommandBuffer->Write<TBool>(aInvertMask);
       
   177 		iBoundingRect.BoundingRect(TRect(aPoint, aSourceRect.Size()));
       
   178 		iHasBitmapCommand = ETrue;
       
   179 		}
       
   180 	}
       
   181 
       
   182 void CRemoteGc::BitBlt(const TPoint &aPoint, const CWsBitmap *aBitmap)
       
   183 	{
       
   184 	BitBlt(aPoint, reinterpret_cast<const CFbsBitmap*>(aBitmap));		
       
   185 	}
       
   186 	
       
   187 void CRemoteGc::BitBlt(const TPoint &aDestination, const CWsBitmap *aBitmap, const TRect &aSource)
       
   188 	{
       
   189 	BitBlt(aDestination, reinterpret_cast<const CFbsBitmap*>(aBitmap), aSource);
       
   190 	}
       
   191 	
       
   192 void CRemoteGc::BitBltMasked(const TPoint& aPoint, const CWsBitmap *aBitmap, const TRect& aSourceRect, const CWsBitmap *aMaskBitmap, TBool aInvertMask)
       
   193 	{		
       
   194 	BitBltMasked(aPoint, reinterpret_cast<const CFbsBitmap*>(aBitmap), aSourceRect, reinterpret_cast<const CFbsBitmap*>(aMaskBitmap), aInvertMask);
       
   195 	}
       
   196 
       
   197 void CRemoteGc::SetFaded(TBool aFaded)
       
   198 	{
       
   199 	iCommandBuffer->Write<TDrawCode>(ECommandSetFaded);
       
   200 	iCommandBuffer->Write<TBool>(aFaded);
       
   201 	}
       
   202 	
       
   203 void CRemoteGc::SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap)
       
   204 	{
       
   205 	iCommandBuffer->Write<TDrawCode>(ECommandSetFadingParameters);
       
   206 	iCommandBuffer->Write<TUint8>(aBlackMap);
       
   207 	iCommandBuffer->Write<TUint8>(aWhiteMap);
       
   208 	}
       
   209 	
       
   210 TInt CRemoteGc::AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt)
       
   211 	{
       
   212 	iCommandBuffer->Write<TDrawCode>(ECommandAlphaBlendBitmaps);
       
   213 	iCommandBuffer->Write<TPoint>(aDestPt);
       
   214 	iCommandBuffer->Write<TInt>(aSrcBmp->Handle());
       
   215 	iCommandBuffer->Write<TRect>(aSrcRect);
       
   216 	iCommandBuffer->Write<TInt>(aAlphaBmp->Handle());
       
   217 	iCommandBuffer->Write<TPoint>(aAlphaPt);
       
   218 	iBoundingRect.BoundingRect(iDrawRect);
       
   219 	iHasBitmapCommand = ETrue;
       
   220 	return KErrNone;
       
   221 	}
       
   222 	
       
   223 TInt CRemoteGc::AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt)
       
   224 	{
       
   225 	return AlphaBlendBitmaps(aDestPt, reinterpret_cast<const CFbsBitmap*>(aSrcBmp), aSrcRect, reinterpret_cast<const CFbsBitmap*>(aAlphaBmp), aAlphaPt);
       
   226 	}
       
   227 
       
   228 void CRemoteGc::SetOrigin(const TPoint &aPoint)
       
   229 	{
       
   230 	iCommandBuffer->Write<TDrawCode>(ECommandSetOrigin);
       
   231 	iCommandBuffer->Write<TPoint>(aPoint);
       
   232 	}
       
   233 	
       
   234 void CRemoteGc::SetDrawMode(TDrawMode aDrawingMode)
       
   235 	{
       
   236 	iCommandBuffer->Write<TDrawCode>(ECommandSetDrawMode);
       
   237 	iCommandBuffer->Write<TDrawMode>(aDrawingMode);		
       
   238 	}
       
   239 	
       
   240 void CRemoteGc::SetClippingRect(const TRect& aRect)
       
   241 	{
       
   242 	iCommandBuffer->Write<TDrawCode>(ECommandSetClippingRect);
       
   243 	iCommandBuffer->Write<TRect>(aRect);		
       
   244 	}
       
   245 	
       
   246 void CRemoteGc::CancelClippingRect()
       
   247 	{
       
   248 	iCommandBuffer->Write<TDrawCode>(ECommandCancelClippingRect);		
       
   249 	}
       
   250 	
       
   251 void CRemoteGc::Reset()
       
   252 	{
       
   253 	iCommandBuffer->Write<TDrawCode>(ECommandReset);			
       
   254 	}
       
   255 	
       
   256 void CRemoteGc::UseFont(const CFont *aFont)
       
   257 	{
       
   258 	iCommandBuffer->Write<TDrawCode>(ECommandUseFont);
       
   259 	iCommandBuffer->Write<TInt>(((CFbsFont*)aFont)->Handle());
       
   260 	}
       
   261 	
       
   262 void CRemoteGc::DiscardFont()
       
   263 	{
       
   264 	iCommandBuffer->Write<TDrawCode>(ECommandDiscardFont);
       
   265 	}
       
   266 	
       
   267 void CRemoteGc::SetUnderlineStyle(TFontUnderline aUnderlineStyle)
       
   268 	{
       
   269 	iCommandBuffer->Write<TDrawCode>(ECommandSetUnderlineStyle);
       
   270 	iCommandBuffer->Write<TFontUnderline>(aUnderlineStyle);
       
   271 	}
       
   272 	
       
   273 void CRemoteGc::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)
       
   274 	{
       
   275 	iCommandBuffer->Write<TDrawCode>(ECommandSetStrikethroughStyle);
       
   276 	iCommandBuffer->Write<TFontStrikethrough>(aStrikethroughStyle);
       
   277 	}
       
   278 	
       
   279 void CRemoteGc::SetWordJustification(TInt aExcessWidth, TInt aNumGaps)
       
   280 	{
       
   281 	iCommandBuffer->Write<TDrawCode>(ECommandSetWordJustification);
       
   282 	iCommandBuffer->Write<TInt>(aExcessWidth);
       
   283 	iCommandBuffer->Write<TInt>(aNumGaps);
       
   284 	}
       
   285 	
       
   286 void CRemoteGc::SetCharJustification(TInt aExcessWidth, TInt aNumChars)
       
   287 	{
       
   288 	iCommandBuffer->Write<TDrawCode>(ECommandSetCharJustification);
       
   289 	iCommandBuffer->Write<TInt>(aExcessWidth);
       
   290 	iCommandBuffer->Write<TInt>(aNumChars);	
       
   291 	}
       
   292 
       
   293 void CRemoteGc::SetPenColor(const TRgb &aColor)
       
   294 	{
       
   295 	iCommandBuffer->Write<TDrawCode>(ECommandSetPenColor);
       
   296 	iCommandBuffer->Write<TRgb>(aColor);		
       
   297 	}
       
   298 	
       
   299 void CRemoteGc::SetPenStyle(TPenStyle aPenStyle)
       
   300 	{
       
   301 	iCommandBuffer->Write<TDrawCode>(ECommandSetPenStyle);
       
   302 	iCommandBuffer->Write<TPenStyle>(aPenStyle);			
       
   303 	}
       
   304 	
       
   305 void CRemoteGc::SetPenSize(const TSize& aSize)
       
   306 	{
       
   307 	iCommandBuffer->Write<TDrawCode>(ECommandSetPenSize);
       
   308 	iCommandBuffer->Write<TSize>(aSize);			
       
   309 	}
       
   310 
       
   311 void CRemoteGc::SetBrushColor(const TRgb &aColor)
       
   312 	{
       
   313 	iCommandBuffer->Write<TDrawCode>(ECommandSetBrushColor);
       
   314 	iCommandBuffer->Write<TRgb>(aColor);
       
   315 	}
       
   316 
       
   317 void CRemoteGc::SetBrushStyle(TBrushStyle aBrushStyle)
       
   318 	{
       
   319 	iCommandBuffer->Write<TDrawCode>(ECommandSetBrushStyle);
       
   320 	iCommandBuffer->Write<TBrushStyle>(aBrushStyle);		
       
   321 	}
       
   322 	
       
   323 void CRemoteGc::SetBrushOrigin(const TPoint &aOrigin)
       
   324 	{
       
   325 	iCommandBuffer->Write<TDrawCode>(ECommandSetBrushOrigin);
       
   326 	iCommandBuffer->Write<TPoint>(aOrigin);			
       
   327 	}
       
   328 	
       
   329 void CRemoteGc::UseBrushPattern(const CFbsBitmap *aDevice)
       
   330 	{
       
   331 	iCommandBuffer->Write<TDrawCode>(ECommandUseBrushPattern);
       
   332 	iCommandBuffer->Write<TInt>(aDevice->Handle());		
       
   333 	}
       
   334 	
       
   335 void CRemoteGc::DiscardBrushPattern()
       
   336 	{
       
   337 	iCommandBuffer->Write<TDrawCode>(ECommandDiscardBrushPattern);	
       
   338 	}
       
   339 
       
   340 void CRemoteGc::MoveTo(const TPoint &aPoint)
       
   341 	{
       
   342 	iCommandBuffer->Write<TDrawCode>(ECommandMoveTo);
       
   343 	iCommandBuffer->Write<TPoint>(aPoint);
       
   344 	}
       
   345 	
       
   346 void CRemoteGc::MoveBy(const TPoint &aPoint)
       
   347 	{
       
   348 	iCommandBuffer->Write<TDrawCode>(ECommandMoveBy);
       
   349 	iCommandBuffer->Write<TPoint>(aPoint);
       
   350 	}
       
   351 	
       
   352 void CRemoteGc::Plot(const TPoint &aPoint)
       
   353 	{
       
   354 	iCommandBuffer->Write<TDrawCode>(ECommandPlot);
       
   355 	iCommandBuffer->Write<TPoint>(aPoint);
       
   356 	iBoundingRect.BoundingRect(iDrawRect);
       
   357 	}
       
   358 	
       
   359 void CRemoteGc::DrawArc(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd)
       
   360 	{
       
   361 	iCommandBuffer->Write<TDrawCode>(ECommandDrawArc);
       
   362 	iCommandBuffer->Write<TRect>(aRect);
       
   363 	iCommandBuffer->Write<TPoint>(aStart);
       
   364 	iCommandBuffer->Write<TPoint>(aEnd);
       
   365 	iBoundingRect.BoundingRect(iDrawRect);
       
   366 	}
       
   367 	
       
   368 void CRemoteGc::DrawLine(const TPoint &aPoint1,const TPoint &aPoint2)
       
   369 	{
       
   370 	iCommandBuffer->Write<TDrawCode>(ECommandDrawLine);
       
   371 	iCommandBuffer->Write<TPoint>(aPoint1);
       
   372 	iCommandBuffer->Write<TPoint>(aPoint2);
       
   373 	iBoundingRect.BoundingRect(iDrawRect);
       
   374 	}
       
   375 	
       
   376 void CRemoteGc::DrawLineTo(const TPoint &aPoint)
       
   377 	{
       
   378 	iCommandBuffer->Write<TDrawCode>(ECommandDrawLineTo);
       
   379 	iCommandBuffer->Write<TPoint>(aPoint);
       
   380 	iBoundingRect.BoundingRect(iDrawRect);
       
   381 	}
       
   382 	
       
   383 void CRemoteGc::DrawLineBy(const TPoint &aPoint)
       
   384 	{
       
   385 	iCommandBuffer->Write<TDrawCode>(ECommandDrawLineBy);
       
   386 	iCommandBuffer->Write<TPoint>(aPoint);
       
   387 	iBoundingRect.BoundingRect(iDrawRect);
       
   388 	}
       
   389 
       
   390 void CRemoteGc::DrawPolyLine(const CArrayFix<TPoint> *aPointList)
       
   391 	{
       
   392 	iCommandBuffer->Write<TDrawCode>(ECommandDrawPolyLine);
       
   393 	iCommandBuffer->Write<TInt>(aPointList->Count()); // Write number of points
       
   394 	
       
   395 	const TInt count = aPointList->Count();
       
   396 	for(TInt i = 0; i < count; i++)	
       
   397 		{
       
   398 		iCommandBuffer->Write<TPoint>(aPointList->At(i));
       
   399 		}
       
   400 	iBoundingRect.BoundingRect(iDrawRect);
       
   401 	}
       
   402 
       
   403 void CRemoteGc::DrawPolyLine(const TPoint* aPointList, TInt aNumPoints)
       
   404 	{
       
   405 	iCommandBuffer->Write<TDrawCode>(ECommandDrawPolyLine);
       
   406 	iCommandBuffer->Write<TInt>(aNumPoints); // Write number of points
       
   407 	
       
   408 	for(TInt i = 0; i < aNumPoints; i++)	
       
   409 		{
       
   410 		iCommandBuffer->Write<TPoint>(aPointList[i]);
       
   411 		}
       
   412 	iBoundingRect.BoundingRect(iDrawRect);
       
   413 	}
       
   414 
       
   415 void CRemoteGc::DrawPie(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd)
       
   416 	{
       
   417 	iCommandBuffer->Write<TDrawCode>(ECommandDrawPie);
       
   418 	iCommandBuffer->Write<TRect>(aRect);
       
   419 	iCommandBuffer->Write<TPoint>(aStart);
       
   420 	iCommandBuffer->Write<TPoint>(aEnd);
       
   421 	iBoundingRect.BoundingRect(iDrawRect);
       
   422 	}
       
   423 	
       
   424 void CRemoteGc::DrawEllipse(const TRect &aRect)
       
   425 	{
       
   426 	iCommandBuffer->Write<TDrawCode>(ECommandDrawEllipse);
       
   427 	iCommandBuffer->Write<TRect>(aRect);
       
   428 	iBoundingRect.BoundingRect(iDrawRect);
       
   429 	}
       
   430 	
       
   431 void CRemoteGc::DrawRect(const TRect &aRect)
       
   432 	{
       
   433 	iCommandBuffer->Write<TDrawCode>(ECommandDrawRect);
       
   434 	iCommandBuffer->Write<TRect>(aRect);
       
   435 	iBoundingRect.BoundingRect(iDrawRect);
       
   436 	}
       
   437 	
       
   438 void CRemoteGc::DrawRoundRect(const TRect &aRect,const TSize &aEllipse)
       
   439 	{
       
   440 	iCommandBuffer->Write<TDrawCode>(ECommandDrawRoundRect);
       
   441 	iCommandBuffer->Write<TRect>(aRect);
       
   442 	iCommandBuffer->Write<TSize>(aEllipse);
       
   443 	iBoundingRect.BoundingRect(iDrawRect);
       
   444 	}
       
   445 
       
   446 TInt CRemoteGc::DrawPolygon(const CArrayFix<TPoint> *aPointList, TFillRule aFillRule)
       
   447 	{
       
   448 	iCommandBuffer->Write<TDrawCode>(ECommandDrawPolygon);
       
   449 	iCommandBuffer->Write<TInt>(aPointList->Count()); // Write number of points
       
   450 	
       
   451 	for(TInt i = 0; i < aPointList->Count(); i++)	
       
   452 		{
       
   453 		iCommandBuffer->Write<TPoint>(aPointList->At(i));
       
   454 		}
       
   455 		
       
   456 	iCommandBuffer->Write<TFillRule>(aFillRule);
       
   457 	iBoundingRect.BoundingRect(iDrawRect);
       
   458 	return KErrNone;
       
   459 	}
       
   460 	
       
   461 TInt CRemoteGc::DrawPolygon(const TPoint* aPointList, TInt aNumPoints, TFillRule aFillRule)
       
   462 	{
       
   463 	iCommandBuffer->Write<TDrawCode>(ECommandDrawPolygon);
       
   464 	iCommandBuffer->Write<TInt>(aNumPoints); // Write number of points
       
   465 	
       
   466 	for(TInt i = 0; i < aNumPoints; i++)	
       
   467 		{
       
   468 		iCommandBuffer->Write<TPoint>(aPointList[i]);
       
   469 		}
       
   470 		
       
   471 	iCommandBuffer->Write<TFillRule>(aFillRule);
       
   472 	iBoundingRect.BoundingRect(iDrawRect);
       
   473 	return KErrNone;
       
   474 	}
       
   475 
       
   476 void CRemoteGc::DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aDevice)
       
   477 	{
       
   478 	iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmap1);
       
   479 	iCommandBuffer->Write<TPoint>(aTopLeft);
       
   480 	iCommandBuffer->Write<TInt>(aDevice->Handle());
       
   481 	iBoundingRect.BoundingRect(TRect(aTopLeft, aDevice->SizeInPixels()));
       
   482 	iHasBitmapCommand = ETrue;
       
   483 	}
       
   484 	
       
   485 void CRemoteGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice)
       
   486 	{
       
   487 	iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmap2);
       
   488 	iCommandBuffer->Write<TRect>(aDestRect);
       
   489 	iCommandBuffer->Write<TInt>(aDevice->Handle());
       
   490 	iBoundingRect.BoundingRect(aDestRect);
       
   491 	iHasBitmapCommand = ETrue;
       
   492 	}
       
   493 	
       
   494 void CRemoteGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice, const TRect &aSourceRect)
       
   495 	{
       
   496 	iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmap3);
       
   497 	iCommandBuffer->Write<TRect>(aDestRect);
       
   498 	iCommandBuffer->Write<TInt>(aDevice->Handle());
       
   499 	iCommandBuffer->Write<TRect>(aSourceRect);
       
   500 	iBoundingRect.BoundingRect(aDestRect);
       
   501 	iHasBitmapCommand = ETrue;
       
   502 	}
       
   503 	
       
   504 void CRemoteGc::DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap* aBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask)
       
   505 	{
       
   506 	iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmapMasked);
       
   507 	iCommandBuffer->Write<TRect>(aDestRect);
       
   508 	iCommandBuffer->Write<TInt>(aBitmap->Handle());
       
   509 	iCommandBuffer->Write<TRect>(aSourceRect);
       
   510 	iCommandBuffer->Write<TInt>(aMaskBitmap->Handle());
       
   511 	iCommandBuffer->Write<TBool>(aInvertMask);
       
   512 	iBoundingRect.BoundingRect(aDestRect);
       
   513 	iHasBitmapCommand = ETrue;
       
   514 	}
       
   515 	
       
   516 void CRemoteGc::DrawBitmapMasked(const TRect& aDestRect, const CWsBitmap* aBitmap, const TRect& aSourceRect, const CWsBitmap* aMaskBitmap, TBool aInvertMask)
       
   517 	{
       
   518 	DrawBitmapMasked(aDestRect, reinterpret_cast<const CFbsBitmap*>(aBitmap), aSourceRect, reinterpret_cast<const CFbsBitmap*>(aMaskBitmap), aInvertMask);
       
   519 	}
       
   520 
       
   521 void CRemoteGc::DrawText(const TDesC &aBuf,const TPoint &aPos)
       
   522 	{
       
   523 	iCommandBuffer->Write<TDrawCode>(ECommandDrawText1);
       
   524 	iCommandBuffer->WriteText(aBuf);
       
   525 	iCommandBuffer->Write<TPoint>(aPos);
       
   526 	iBoundingRect.BoundingRect(iDrawRect);
       
   527 	}
       
   528 
       
   529 void CRemoteGc::DrawText(const TDesC &aBuf, const TRect &aBox, TInt aBaselineOffset, TTextAlign aHoriz, TInt aLeftMrg)
       
   530 	{
       
   531 	iCommandBuffer->Write<TDrawCode>(ECommandDrawText2);
       
   532 	iCommandBuffer->WriteText(aBuf);
       
   533 	iCommandBuffer->Write<TRect>(aBox);
       
   534 	iCommandBuffer->Write<TInt>(aBaselineOffset);
       
   535 	iCommandBuffer->Write<TTextAlign>(aHoriz);
       
   536 	iCommandBuffer->Write<TInt>(aLeftMrg);
       
   537 	iBoundingRect.BoundingRect(aBox);
       
   538 	}
       
   539 	
       
   540 void CRemoteGc::DrawText(const TDesC& aText, const TPoint& aPosition, const TDrawTextParam& aParam)
       
   541 	{
       
   542 	iCommandBuffer->Write<TDrawCode>(ECommandDrawText3);
       
   543 	iCommandBuffer->WriteText(aText);
       
   544 	iCommandBuffer->Write<TPoint>(aPosition);
       
   545 	iCommandBuffer->Write<TDrawTextParam>(aParam);
       
   546 	iBoundingRect.BoundingRect(iDrawRect);
       
   547 	}
       
   548 
       
   549 void CRemoteGc::MapColors(const TRect& aRect, const TRgb* aColors, TInt aNumPairs, TBool aMapForwards)
       
   550 	{
       
   551 	iCommandBuffer->Write<TDrawCode>(ECommandMapColors);
       
   552 	iCommandBuffer->Write<TRect>(aRect);	
       
   553 	iCommandBuffer->Write<TInt>(aNumPairs);
       
   554 	
       
   555 	for(TInt i = 0; i < aNumPairs; i++)	
       
   556 		{
       
   557 		iCommandBuffer->Write<TRgb>(aColors[i]);
       
   558 		iCommandBuffer->Write<TRgb>(aColors[i+1]);
       
   559 		}
       
   560 		
       
   561 	iCommandBuffer->Write<TBool>(aMapForwards);
       
   562 	}
       
   563 
       
   564 TInt CRemoteGc::SetClippingRegion(const TRegion &aRegion)
       
   565 	{
       
   566 	iCommandBuffer->Write<TDrawCode>(ECommandSetClippingRegion);
       
   567 	
       
   568 	const TInt count = aRegion.Count();
       
   569 	iCommandBuffer->Write<TInt>(count);
       
   570 	
       
   571 	for(TInt i = 0; i < count; i++)	
       
   572 		{
       
   573 		iCommandBuffer->Write<TRect>(aRegion.RectangleList()[i]);
       
   574 		}
       
   575 		
       
   576 	return KErrNone;
       
   577 	}
       
   578 	
       
   579 void CRemoteGc::CancelClippingRegion()
       
   580 	{
       
   581 	iCommandBuffer->Write<TDrawCode>(ECommandCancelClippingRegion);
       
   582 	}
       
   583 	
       
   584 void CRemoteGc::DrawTextVertical(const TDesC& aText, const TPoint& aPos, TBool aUp)
       
   585 	{
       
   586 	iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical1);
       
   587 	iCommandBuffer->WriteText(aText);
       
   588 	iCommandBuffer->Write<TPoint>(aPos);	
       
   589 	iCommandBuffer->Write<TBool>(aUp);
       
   590 	iBoundingRect.BoundingRect(iDrawRect);
       
   591 	}
       
   592 	
       
   593 void CRemoteGc::DrawTextVertical(const TDesC& aText, const TRect& aBox, TInt aBaselineOffset, TBool aUp, TTextAlign aVert, TInt aMargin)
       
   594 	{
       
   595 	iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical2);
       
   596 	iCommandBuffer->WriteText(aText);
       
   597 	iCommandBuffer->Write<TRect>(aBox);
       
   598 	iCommandBuffer->Write<TInt>(aBaselineOffset);
       
   599 	iCommandBuffer->Write<TBool>(aUp);
       
   600 	iCommandBuffer->Write<TTextAlign>(aVert);
       
   601 	iCommandBuffer->Write<TInt>(aMargin);
       
   602 	iBoundingRect.BoundingRect(aBox);
       
   603 	}
       
   604 	
       
   605 void CRemoteGc::DrawWsGraphic(const TWsGraphicId& aId,const TRect& aDestRect)
       
   606 	{
       
   607 	iCommandBuffer->Write<TDrawCode>(ECommandDrawWsGraphic1);
       
   608 	iCommandBuffer->Write<TInt>(aId.IsUid()? aId.Uid().iUid: aId.Id());
       
   609 	iCommandBuffer->Write<TBool>(aId.IsUid());
       
   610 	iCommandBuffer->Write<TRect>(aDestRect);
       
   611 	iBoundingRect.BoundingRect(aDestRect);
       
   612 	}
       
   613 	
       
   614 void CRemoteGc::DrawWsGraphic(const TWsGraphicId& aId,const TRect& aDestRect,const TDesC8& aData)
       
   615 	{
       
   616 	iCommandBuffer->Write<TDrawCode>(ECommandDrawWsGraphic2);
       
   617 	iCommandBuffer->Write<TInt>(aId.IsUid()? aId.Uid().iUid: aId.Id());
       
   618 	iCommandBuffer->Write<TBool>(aId.IsUid());
       
   619 	iCommandBuffer->Write<TRect>(aDestRect);
       
   620 	iCommandBuffer->WriteText(aData);
       
   621 	iBoundingRect.BoundingRect(aDestRect);
       
   622 	}
       
   623 
       
   624 void CRemoteGc::SetDitherOrigin(const TPoint& /*aPoint*/)
       
   625 	{
       
   626 	// do nothing, does not apply to CBitmapContext which CCommandBuffer is using
       
   627 	}
       
   628 
       
   629 void CRemoteGc::SetOpaque(TBool /*aDrawOpaque*/)
       
   630 	{
       
   631 	// overrides to prevent calling CWindowGc::SetOpaque, it's specific to how wserv blends windows content
       
   632 	}
       
   633 
       
   634 TInt CRemoteGc::APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput)
       
   635 	{
       
   636 	if (aUid == KSetShadowColor)
       
   637 		{
       
   638 		return APIExSetShadowColor(aInput);
       
   639 		}
       
   640 	/* Future cases may be placed here later.*/
       
   641 	else
       
   642 		{
       
   643 		return CBitmapContext::APIExtension(aUid, aOutput, aInput);
       
   644 		}
       
   645 	}
       
   646 
       
   647 TInt CRemoteGc::APIExSetShadowColor(TAny* aShadowColor)
       
   648 	{
       
   649 	const TRgb shadowColor = *(reinterpret_cast<TRgb*> (aShadowColor));
       
   650 	iCommandBuffer->Write<TDrawCode>(ECommandSetShadowColor);
       
   651 	iCommandBuffer->Write<TRgb>(shadowColor);
       
   652 	return KErrNone;
       
   653 	}