Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <graphics/remotegc.h>
17 #include <graphics/commandbuffer.h>
18 #include <graphics/wsdrawresource.h>
19 #include <graphics/gdi/gdiconsts.h>
20 #include <graphics/gdi/gdistructs.h>
21 #include "graphics/windowserverconstants.h"
23 #define KDefaultShadowColor KRgbGray
25 class CRemoteGc::CPimpl : public CBase, public MWsDrawResource
28 CPimpl(CRemoteGc& aGc) : iGc(aGc) {}
29 public: //from MWsDrawResource
30 void DrawResource(const TPoint& aPos, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation=CWindowGc::EGraphicsRotationNone)
32 iGc.DrawResource(aPos, aSource, aRotation);
34 void DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation=CWindowGc::EGraphicsRotationNone)
36 iGc.DrawResource(aDestRect, aSource, aRotation);
38 void DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TRect& aSrcRect, CWindowGc::TGraphicsRotation aRotation=CWindowGc::EGraphicsRotationNone)
40 iGc.DrawResource(aDestRect, aSource, aSrcRect, aRotation);
42 void DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TDesC8& aParam)
44 iGc.DrawResource(aDestRect, aSource, aParam);
51 Creates a new remotegc.
53 @param aDevice The windowserver screendevice to use.
54 @param aCommandBufferObserver Pointer to a commandbufferobserver.
55 @return A pointer to a new instance of CRemoteGc.
57 EXPORT_C CRemoteGc* CRemoteGc::NewL(CWsScreenDevice* aDevice)
59 CRemoteGc* remoteGc = new (ELeave) CRemoteGc(aDevice);
60 CleanupStack::PushL(remoteGc);
61 remoteGc->ConstructL();
62 CleanupStack::Pop(remoteGc);
66 CRemoteGc::CRemoteGc(CWsScreenDevice* aDevice) : CWindowGc(aDevice), iCommandBufferObserver(NULL), iFont(NULL), iShadowColor(KDefaultShadowColor)
70 EXPORT_C CRemoteGc::~CRemoteGc()
72 delete iCommandBuffer;
73 delete iRemoteGcPimpl;
76 void CRemoteGc::ConstructL()
78 User::LeaveIfError(CWindowGc::Construct());
79 iCommandBuffer = CCommandBuffer::NewL();
80 iRemoteGcPimpl = new(ELeave) CPimpl(*this);
83 EXPORT_C void CRemoteGc::SetCommandBufferObserver(MCommandBufferObserver* aCommandBufferObserver)
85 iCommandBufferObserver = aCommandBufferObserver;
89 Resets the commandbuffer.
91 EXPORT_C void CRemoteGc::ResetCommandBuffer()
93 iCommandBuffer->Reset();
97 Externalizes commandbuffer sections into a format which makes it possible to send over IPC.
98 If ETrue is sent as a parameter to this method, the entire commandbuffer will be externalized,
99 otherwise only sections which has not been externalized before will be externalized. Note that if only
100 not externalized sections is asked for, the flag will be reset on that section so next call
101 to ExternalizeLC will not externalize that section.
103 @param aMsgBuf A buffer used to externalize the commandbuffer to.
104 @param aEntireBuffer If ETrue, the entire commandbuffer will be externalized, otherwise only sections which has not been externalized before.
106 EXPORT_C void CRemoteGc::ExternalizeL(RWsGraphicMsgBuf& aMsgBuf, TBool aEntireBuffer)
108 return iCommandBuffer->ExternalizeL(aMsgBuf, aEntireBuffer);
112 Prepares the remotegc to be drawn to.
114 @param aRect The rect to be drawn.
116 EXPORT_C void CRemoteGc::BeginDraw(const TRect& aRect)
119 iBoundingRect = TRect();
120 iHasBitmapCommand = EFalse;
121 iCommandBuffer->Prepare(aRect);
125 Finishes the current redraw.
126 This method should be called when drawing to the remotegc is complete.
128 EXPORT_C void CRemoteGc::EndDraw()
130 iBoundingRect.Intersection(iDrawRect);
131 const TInt err = iCommandBuffer->Finish(iDrawRect, iBoundingRect, iHasBitmapCommand);
133 if(iCommandBufferObserver && !err)
134 iCommandBufferObserver->CommandBufferUpdated(iDrawRect, iBoundingRect);
137 void CRemoteGc::Activate(RDrawableWindow &aDevice)
139 BeginDraw(aDevice.GetDrawRect());
140 CWindowGc::Activate(aDevice);
143 void CRemoteGc::Deactivate()
145 CWindowGc::Deactivate();
147 iShadowColor = KDefaultShadowColor;
151 void CRemoteGc::Clear()
153 iCommandBuffer->Write<TDrawCode>(ECommandClear);
154 iBoundingRect.BoundingRect(iDrawRect);
157 void CRemoteGc::Clear(const TRect& aRect)
159 iCommandBuffer->Write<TDrawCode>(ECommandClearRect);
160 iCommandBuffer->Write<TRect>(aRect);
161 iBoundingRect.BoundingRect(aRect);
164 void CRemoteGc::CopyRect(const TPoint &anOffset, const TRect &aRect)
166 iCommandBuffer->Write<TDrawCode>(ECommandCopyRect);
167 iCommandBuffer->Write<TPoint>(anOffset);
168 iCommandBuffer->Write<TRect>(aRect);
169 iBoundingRect.BoundingRect(iDrawRect);
172 void CRemoteGc::BitBlt(const TPoint &aPoint, const CFbsBitmap *aBitmap)
174 __ASSERT_DEBUG(aBitmap, User::Invariant());
177 iCommandBuffer->Write<TDrawCode>(ECommandBitBlt1);
178 iCommandBuffer->Write<TPoint>(aPoint);
179 iCommandBuffer->Write<TInt>(aBitmap->Handle());
180 iBoundingRect.BoundingRect(TRect(aPoint, aBitmap->SizeInPixels()));
181 iHasBitmapCommand = ETrue;
185 void CRemoteGc::BitBlt(const TPoint &aDestination, const CFbsBitmap *aBitmap, const TRect &aSource)
187 __ASSERT_DEBUG(aBitmap, User::Invariant());
190 iCommandBuffer->Write<TDrawCode>(ECommandBitBlt2);
191 iCommandBuffer->Write<TPoint>(aDestination);
192 iCommandBuffer->Write<TInt>(aBitmap->Handle());
193 iCommandBuffer->Write<TRect>(aSource);
194 iBoundingRect.BoundingRect(TRect(aDestination, aSource.Size()));
195 iHasBitmapCommand = ETrue;
199 void CRemoteGc::BitBltMasked(const TPoint& aPoint, const CFbsBitmap* aBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask)
201 __ASSERT_DEBUG(aBitmap && aMaskBitmap, User::Invariant());
202 if(aBitmap && aMaskBitmap)
204 iCommandBuffer->Write<TDrawCode>(ECommandBitBltMasked);
205 iCommandBuffer->Write<TPoint>(aPoint);
206 iCommandBuffer->Write<TInt>(aBitmap->Handle());
207 iCommandBuffer->Write<TRect>(aSourceRect);
208 iCommandBuffer->Write<TInt>(aMaskBitmap->Handle());
209 iCommandBuffer->Write<TBool>(aInvertMask);
210 iBoundingRect.BoundingRect(TRect(aPoint, aSourceRect.Size()));
211 iHasBitmapCommand = ETrue;
215 void CRemoteGc::BitBlt(const TPoint &aPoint, const CWsBitmap *aBitmap)
217 BitBlt(aPoint, reinterpret_cast<const CFbsBitmap*>(aBitmap));
220 void CRemoteGc::BitBlt(const TPoint &aDestination, const CWsBitmap *aBitmap, const TRect &aSource)
222 BitBlt(aDestination, reinterpret_cast<const CFbsBitmap*>(aBitmap), aSource);
225 void CRemoteGc::BitBltMasked(const TPoint& aPoint, const CWsBitmap *aBitmap, const TRect& aSourceRect, const CWsBitmap *aMaskBitmap, TBool aInvertMask)
227 BitBltMasked(aPoint, reinterpret_cast<const CFbsBitmap*>(aBitmap), aSourceRect, reinterpret_cast<const CFbsBitmap*>(aMaskBitmap), aInvertMask);
230 void CRemoteGc::SetFaded(TBool /*aFaded*/)
235 void CRemoteGc::SetFadingParameters(TUint8 /*aBlackMap*/,TUint8 /*aWhiteMap*/)
240 TInt CRemoteGc::AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt)
242 iCommandBuffer->Write<TDrawCode>(ECommandAlphaBlendBitmaps);
243 iCommandBuffer->Write<TPoint>(aDestPt);
244 iCommandBuffer->Write<TInt>(aSrcBmp->Handle());
245 iCommandBuffer->Write<TRect>(aSrcRect);
246 iCommandBuffer->Write<TInt>(aAlphaBmp->Handle());
247 iCommandBuffer->Write<TPoint>(aAlphaPt);
248 iBoundingRect.BoundingRect(iDrawRect);
249 iHasBitmapCommand = ETrue;
253 TInt CRemoteGc::AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt)
255 return AlphaBlendBitmaps(aDestPt, reinterpret_cast<const CFbsBitmap*>(aSrcBmp), aSrcRect, reinterpret_cast<const CFbsBitmap*>(aAlphaBmp), aAlphaPt);
258 void CRemoteGc::SetOrigin(const TPoint &aPoint)
260 iCommandBuffer->Write<TDrawCode>(ECommandSetOrigin);
261 iCommandBuffer->Write<TPoint>(aPoint);
264 void CRemoteGc::SetDrawMode(TDrawMode aDrawingMode)
266 iCommandBuffer->Write<TDrawCode>(ECommandSetDrawMode);
267 iCommandBuffer->Write<TDrawMode>(aDrawingMode);
270 void CRemoteGc::SetClippingRect(const TRect& aRect)
272 iCommandBuffer->Write<TDrawCode>(ECommandSetClippingRect);
273 iCommandBuffer->Write<TRect>(aRect);
276 void CRemoteGc::CancelClippingRect()
278 iCommandBuffer->Write<TDrawCode>(ECommandCancelClippingRect);
281 void CRemoteGc::Reset()
283 iCommandBuffer->Write<TDrawCode>(ECommandReset);
285 iShadowColor = KDefaultShadowColor;
288 void CRemoteGc::UseFont(const CFont *aFont)
290 if (iFont!=(CFbsFont *)aFont)
292 iFont=(CFbsFont *)aFont;
293 iCommandBuffer->Write<TDrawCode>(ECommandUseFont);
294 iCommandBuffer->Write<TInt>(((CFbsFont*)aFont)->Handle());
298 void CRemoteGc::DiscardFont()
301 iCommandBuffer->Write<TDrawCode>(ECommandDiscardFont);
304 void CRemoteGc::SetUnderlineStyle(TFontUnderline aUnderlineStyle)
306 iCommandBuffer->Write<TDrawCode>(ECommandSetUnderlineStyle);
307 iCommandBuffer->Write<TFontUnderline>(aUnderlineStyle);
310 void CRemoteGc::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)
312 iCommandBuffer->Write<TDrawCode>(ECommandSetStrikethroughStyle);
313 iCommandBuffer->Write<TFontStrikethrough>(aStrikethroughStyle);
316 void CRemoteGc::SetWordJustification(TInt aExcessWidth, TInt aNumGaps)
318 iCommandBuffer->Write<TDrawCode>(ECommandSetWordJustification);
319 iCommandBuffer->Write<TInt>(aExcessWidth);
320 iCommandBuffer->Write<TInt>(aNumGaps);
323 void CRemoteGc::SetCharJustification(TInt aExcessWidth, TInt aNumChars)
325 iCommandBuffer->Write<TDrawCode>(ECommandSetCharJustification);
326 iCommandBuffer->Write<TInt>(aExcessWidth);
327 iCommandBuffer->Write<TInt>(aNumChars);
330 void CRemoteGc::SetPenColor(const TRgb &aColor)
332 iCommandBuffer->Write<TDrawCode>(ECommandSetPenColor);
333 iCommandBuffer->Write<TRgb>(aColor);
336 void CRemoteGc::SetPenStyle(TPenStyle aPenStyle)
338 iCommandBuffer->Write<TDrawCode>(ECommandSetPenStyle);
339 iCommandBuffer->Write<TPenStyle>(aPenStyle);
342 void CRemoteGc::SetPenSize(const TSize& aSize)
344 iCommandBuffer->Write<TDrawCode>(ECommandSetPenSize);
345 iCommandBuffer->Write<TSize>(aSize);
348 void CRemoteGc::SetBrushColor(const TRgb &aColor)
350 iCommandBuffer->Write<TDrawCode>(ECommandSetBrushColor);
351 iCommandBuffer->Write<TRgb>(aColor);
354 void CRemoteGc::SetBrushStyle(TBrushStyle aBrushStyle)
356 iCommandBuffer->Write<TDrawCode>(ECommandSetBrushStyle);
357 iCommandBuffer->Write<TBrushStyle>(aBrushStyle);
360 void CRemoteGc::SetBrushOrigin(const TPoint &aOrigin)
362 iCommandBuffer->Write<TDrawCode>(ECommandSetBrushOrigin);
363 iCommandBuffer->Write<TPoint>(aOrigin);
366 void CRemoteGc::UseBrushPattern(const CFbsBitmap *aDevice)
368 iCommandBuffer->Write<TDrawCode>(ECommandUseBrushPattern);
369 iCommandBuffer->Write<TInt>(aDevice->Handle());
372 void CRemoteGc::DiscardBrushPattern()
374 iCommandBuffer->Write<TDrawCode>(ECommandDiscardBrushPattern);
377 void CRemoteGc::MoveTo(const TPoint &aPoint)
379 iCommandBuffer->Write<TDrawCode>(ECommandMoveTo);
380 iCommandBuffer->Write<TPoint>(aPoint);
383 void CRemoteGc::MoveBy(const TPoint &aPoint)
385 iCommandBuffer->Write<TDrawCode>(ECommandMoveBy);
386 iCommandBuffer->Write<TPoint>(aPoint);
389 void CRemoteGc::Plot(const TPoint &aPoint)
391 iCommandBuffer->Write<TDrawCode>(ECommandPlot);
392 iCommandBuffer->Write<TPoint>(aPoint);
393 iBoundingRect.BoundingRect(iDrawRect);
396 void CRemoteGc::DrawArc(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd)
398 iCommandBuffer->Write<TDrawCode>(ECommandDrawArc);
399 iCommandBuffer->Write<TRect>(aRect);
400 iCommandBuffer->Write<TPoint>(aStart);
401 iCommandBuffer->Write<TPoint>(aEnd);
402 iBoundingRect.BoundingRect(iDrawRect);
405 void CRemoteGc::DrawLine(const TPoint &aPoint1,const TPoint &aPoint2)
407 iCommandBuffer->Write<TDrawCode>(ECommandDrawLine);
408 iCommandBuffer->Write<TPoint>(aPoint1);
409 iCommandBuffer->Write<TPoint>(aPoint2);
410 iBoundingRect.BoundingRect(iDrawRect);
413 void CRemoteGc::DrawLineTo(const TPoint &aPoint)
415 iCommandBuffer->Write<TDrawCode>(ECommandDrawLineTo);
416 iCommandBuffer->Write<TPoint>(aPoint);
417 iBoundingRect.BoundingRect(iDrawRect);
420 void CRemoteGc::DrawLineBy(const TPoint &aPoint)
422 iCommandBuffer->Write<TDrawCode>(ECommandDrawLineBy);
423 iCommandBuffer->Write<TPoint>(aPoint);
424 iBoundingRect.BoundingRect(iDrawRect);
427 void CRemoteGc::DrawPolyLine(const CArrayFix<TPoint> *aPointList)
429 iCommandBuffer->Write<TDrawCode>(ECommandDrawPolyLine);
430 iCommandBuffer->Write<TInt>(aPointList->Count()); // Write number of points
432 const TInt count = aPointList->Count();
433 for(TInt i = 0; i < count; i++)
435 iCommandBuffer->Write<TPoint>(aPointList->At(i));
437 iBoundingRect.BoundingRect(iDrawRect);
440 void CRemoteGc::DrawPolyLine(const TPoint* aPointList, TInt aNumPoints)
442 iCommandBuffer->Write<TDrawCode>(ECommandDrawPolyLine);
443 iCommandBuffer->Write<TInt>(aNumPoints); // Write number of points
445 for(TInt i = 0; i < aNumPoints; i++)
447 iCommandBuffer->Write<TPoint>(aPointList[i]);
449 iBoundingRect.BoundingRect(iDrawRect);
452 void CRemoteGc::DrawPie(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd)
454 iCommandBuffer->Write<TDrawCode>(ECommandDrawPie);
455 iCommandBuffer->Write<TRect>(aRect);
456 iCommandBuffer->Write<TPoint>(aStart);
457 iCommandBuffer->Write<TPoint>(aEnd);
458 iBoundingRect.BoundingRect(iDrawRect);
461 void CRemoteGc::DrawEllipse(const TRect &aRect)
463 iCommandBuffer->Write<TDrawCode>(ECommandDrawEllipse);
464 iCommandBuffer->Write<TRect>(aRect);
465 iBoundingRect.BoundingRect(iDrawRect);
468 void CRemoteGc::DrawRect(const TRect &aRect)
470 iCommandBuffer->Write<TDrawCode>(ECommandDrawRect);
471 iCommandBuffer->Write<TRect>(aRect);
472 iBoundingRect.BoundingRect(iDrawRect);
475 void CRemoteGc::DrawRoundRect(const TRect &aRect,const TSize &aEllipse)
477 iCommandBuffer->Write<TDrawCode>(ECommandDrawRoundRect);
478 iCommandBuffer->Write<TRect>(aRect);
479 iCommandBuffer->Write<TSize>(aEllipse);
480 iBoundingRect.BoundingRect(iDrawRect);
483 TInt CRemoteGc::DrawPolygon(const CArrayFix<TPoint> *aPointList, TFillRule aFillRule)
485 iCommandBuffer->Write<TDrawCode>(ECommandDrawPolygon);
486 iCommandBuffer->Write<TInt>(aPointList->Count()); // Write number of points
488 for(TInt i = 0; i < aPointList->Count(); i++)
490 iCommandBuffer->Write<TPoint>(aPointList->At(i));
493 iCommandBuffer->Write<TFillRule>(aFillRule);
494 iBoundingRect.BoundingRect(iDrawRect);
498 TInt CRemoteGc::DrawPolygon(const TPoint* aPointList, TInt aNumPoints, TFillRule aFillRule)
500 iCommandBuffer->Write<TDrawCode>(ECommandDrawPolygon);
501 iCommandBuffer->Write<TInt>(aNumPoints); // Write number of points
503 for(TInt i = 0; i < aNumPoints; i++)
505 iCommandBuffer->Write<TPoint>(aPointList[i]);
508 iCommandBuffer->Write<TFillRule>(aFillRule);
509 iBoundingRect.BoundingRect(iDrawRect);
513 void CRemoteGc::DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aDevice)
515 iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmap1);
516 iCommandBuffer->Write<TPoint>(aTopLeft);
517 iCommandBuffer->Write<TInt>(aDevice->Handle());
518 iBoundingRect.BoundingRect(TRect(aTopLeft, aDevice->SizeInPixels()));
519 iHasBitmapCommand = ETrue;
522 void CRemoteGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice)
524 iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmap2);
525 iCommandBuffer->Write<TRect>(aDestRect);
526 iCommandBuffer->Write<TInt>(aDevice->Handle());
527 iBoundingRect.BoundingRect(aDestRect);
528 iHasBitmapCommand = ETrue;
531 void CRemoteGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice, const TRect &aSourceRect)
533 iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmap3);
534 iCommandBuffer->Write<TRect>(aDestRect);
535 iCommandBuffer->Write<TInt>(aDevice->Handle());
536 iCommandBuffer->Write<TRect>(aSourceRect);
537 iBoundingRect.BoundingRect(aDestRect);
538 iHasBitmapCommand = ETrue;
541 void CRemoteGc::DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap* aBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask)
543 iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmapMasked);
544 iCommandBuffer->Write<TRect>(aDestRect);
545 iCommandBuffer->Write<TInt>(aBitmap->Handle());
546 iCommandBuffer->Write<TRect>(aSourceRect);
547 iCommandBuffer->Write<TInt>(aMaskBitmap->Handle());
548 iCommandBuffer->Write<TBool>(aInvertMask);
549 iBoundingRect.BoundingRect(aDestRect);
550 iHasBitmapCommand = ETrue;
553 void CRemoteGc::DrawBitmapMasked(const TRect& aDestRect, const CWsBitmap* aBitmap, const TRect& aSourceRect, const CWsBitmap* aMaskBitmap, TBool aInvertMask)
555 DrawBitmapMasked(aDestRect, reinterpret_cast<const CFbsBitmap*>(aBitmap), aSourceRect, reinterpret_cast<const CFbsBitmap*>(aMaskBitmap), aInvertMask);
558 void CRemoteGc::DrawText(const TDesC &aBuf,const TPoint &aPos)
560 iCommandBuffer->Write<TDrawCode>(ECommandDrawText1);
561 iCommandBuffer->WriteText(aBuf);
562 iCommandBuffer->Write<TPoint>(aPos);
563 iBoundingRect.BoundingRect(iDrawRect);
566 void CRemoteGc::DrawText(const TDesC &aBuf, const TRect &aBox, TInt aBaselineOffset, TTextAlign aHoriz, TInt aLeftMrg)
568 iCommandBuffer->Write<TDrawCode>(ECommandDrawText2);
569 iCommandBuffer->WriteText(aBuf);
570 iCommandBuffer->Write<TRect>(aBox);
571 iCommandBuffer->Write<TInt>(aBaselineOffset);
572 iCommandBuffer->Write<TTextAlign>(aHoriz);
573 iCommandBuffer->Write<TInt>(aLeftMrg);
574 iBoundingRect.BoundingRect(aBox);
577 void CRemoteGc::DrawText(const TDesC& aText, const TPoint& aPosition, const TDrawTextParam& aParam)
579 iCommandBuffer->Write<TDrawCode>(ECommandDrawText3);
580 iCommandBuffer->WriteText(aText);
581 iCommandBuffer->Write<TPoint>(aPosition);
582 iCommandBuffer->Write<TDrawTextParam>(aParam);
583 iBoundingRect.BoundingRect(iDrawRect);
586 void CRemoteGc::MapColors(const TRect& /*aRect*/, const TRgb* /*aColors*/, TInt /*aNumPairs*/, TBool /*aMapForwards*/)
591 TInt CRemoteGc::SetClippingRegion(const TRegion &aRegion)
593 iCommandBuffer->Write<TDrawCode>(ECommandSetClippingRegion);
595 const TInt count = aRegion.Count();
596 iCommandBuffer->Write<TInt>(count);
598 for(TInt i = 0; i < count; i++)
600 iCommandBuffer->Write<TRect>(aRegion.RectangleList()[i]);
606 void CRemoteGc::CancelClippingRegion()
608 iCommandBuffer->Write<TDrawCode>(ECommandCancelClippingRegion);
611 void CRemoteGc::DrawTextVertical(const TDesC& aText, const TPoint& aPos, TBool aUp)
613 iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical1);
614 iCommandBuffer->WriteText(aText);
615 iCommandBuffer->Write<TPoint>(aPos);
616 iCommandBuffer->Write<TBool>(aUp);
617 iBoundingRect.BoundingRect(iDrawRect);
620 void CRemoteGc::DrawTextVertical(const TDesC& aText, const TRect& aBox, TInt aBaselineOffset, TBool aUp, TTextAlign aVert, TInt aMargin)
622 iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical2);
623 iCommandBuffer->WriteText(aText);
624 iCommandBuffer->Write<TRect>(aBox);
625 iCommandBuffer->Write<TInt>(aBaselineOffset);
626 iCommandBuffer->Write<TBool>(aUp);
627 iCommandBuffer->Write<TTextAlign>(aVert);
628 iCommandBuffer->Write<TInt>(aMargin);
629 iBoundingRect.BoundingRect(aBox);
632 void CRemoteGc::DrawWsGraphic(const TWsGraphicId& aId,const TRect& aDestRect)
634 iCommandBuffer->Write<TDrawCode>(ECommandDrawWsGraphic1);
635 iCommandBuffer->Write<TInt>(aId.IsUid()? aId.Uid().iUid: aId.Id());
636 iCommandBuffer->Write<TBool>(aId.IsUid());
637 iCommandBuffer->Write<TRect>(aDestRect);
638 iBoundingRect.BoundingRect(aDestRect);
641 void CRemoteGc::DrawWsGraphic(const TWsGraphicId& aId,const TRect& aDestRect,const TDesC8& aData)
643 iCommandBuffer->Write<TDrawCode>(ECommandDrawWsGraphic2);
644 iCommandBuffer->Write<TInt>(aId.IsUid()? aId.Uid().iUid: aId.Id());
645 iCommandBuffer->Write<TBool>(aId.IsUid());
646 iCommandBuffer->Write<TRect>(aDestRect);
647 iCommandBuffer->WriteText(aData);
648 iBoundingRect.BoundingRect(aDestRect);
651 void CRemoteGc::SetDitherOrigin(const TPoint& /*aPoint*/) //deprecated
653 // do nothing, does not apply to CBitmapContext which CCommandBuffer is using
656 void CRemoteGc::SetOpaque(TBool /*aDrawOpaque*/) // deprecated
658 // overrides to prevent calling CWindowGc::SetOpaque, it's specific to how wserv blends windows content
661 TInt CRemoteGc::APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput)
663 if (aUid == KGetUnderlineMetrics)
665 return APIExGetUnderlineMetrics(aOutput);
667 else if (aUid == KSetShadowColor)
669 return APIExSetShadowColor(aInput);
671 else if (aUid == KDrawTextInContextUid)
673 TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput;
674 return APIExDrawText(contextParam->iText, &contextParam->iParam, contextParam->iPosition);
676 else if (aUid == KDrawBoxTextInContextUid)
678 TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput;
679 return APIExDrawText(contextParam->iText,&contextParam->iParam,contextParam->iBox,contextParam->iBaselineOffset,contextParam->iAlign,contextParam->iMargin);
681 else if (aUid == KDrawTextInContextVerticalUid)
683 TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput;
684 return APIExDrawTextVertical(contextParam->iText, &contextParam->iParam, contextParam->iPosition,contextParam->iUp);
686 else if (aUid == KDrawBoxTextInContextVerticalUid)
688 TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput;
689 return APIExDrawTextVertical(contextParam->iText,&contextParam->iParam,contextParam->iBox,contextParam->iBaselineOffset,contextParam->iUp,contextParam->iAlign,contextParam->iMargin);
691 else if (aUid == KApiExtensionInterfaceUid)
693 return APIExInterface(aOutput, *static_cast<TUid*>(aInput));
695 /* Future cases may be placed here later.*/
698 return CBitmapContext::APIExtension(aUid, aOutput, aInput);
702 TInt CRemoteGc::APIExGetUnderlineMetrics(TAny*& aOutput)
704 const TInt width = Max(iFont->HeightInPixels() / 10,1);
705 TTwoTInt* ptr = (TTwoTInt*)aOutput;
706 ptr->iTop = 1 + width / 2;
707 ptr->iBottom = (ptr->iTop) + width;
711 TInt CRemoteGc::APIExSetShadowColor(TAny* aShadowColor)
713 const TRgb shadowColor = *(reinterpret_cast<TRgb*> (aShadowColor));
714 iCommandBuffer->Write<TDrawCode>(ECommandSetShadowColor);
715 iCommandBuffer->Write<TRgb>(shadowColor);
716 iShadowColor = shadowColor;
720 TInt CRemoteGc::APIExGetShadowColor(TAny*& aOutput)
722 TRgb* ptr = (TRgb*)aOutput;
723 ptr->SetInternal(iShadowColor.Internal());
727 TInt CRemoteGc::APIExDrawText(const TDesC &aBuf,const TTextParameters* aParam,const TPoint &aPos)
729 iCommandBuffer->Write<TDrawCode>(ECommandDrawText4);
730 iCommandBuffer->WriteText(aBuf);
731 iCommandBuffer->Write<TTextParameters>(*aParam);
732 iCommandBuffer->Write<TPoint>(aPos);
733 iBoundingRect.BoundingRect(iDrawRect);
737 TInt CRemoteGc::APIExDrawText(const TDesC &aBuf,const TTextParameters* aParam,const TRect &aBox,TInt aBaselineOffset,TTextAlign aHoriz,TInt aLeftMrg)
739 iCommandBuffer->Write<TDrawCode>(ECommandDrawText5);
740 iCommandBuffer->WriteText(aBuf);
741 iCommandBuffer->Write<TTextParameters>(*aParam);
742 iCommandBuffer->Write<TRect>(aBox);
743 iCommandBuffer->Write<TInt>(aBaselineOffset);
744 iCommandBuffer->Write<TTextAlign>(aHoriz);
745 iCommandBuffer->Write<TInt>(aLeftMrg);
746 iBoundingRect.BoundingRect(aBox);
750 TInt CRemoteGc::APIExDrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPos,TBool aUp)
752 iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical3);
753 iCommandBuffer->WriteText(aText);
754 iCommandBuffer->Write<TTextParameters>(*aParam);
755 iCommandBuffer->Write<TPoint>(aPos);
756 iCommandBuffer->Write<TBool>(aUp);
757 iBoundingRect.BoundingRect(iDrawRect);
761 TInt CRemoteGc::APIExDrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert,TInt aMargin)
763 iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical4);
764 iCommandBuffer->WriteText(aText);
765 iCommandBuffer->Write<TTextParameters>(*aParam);
766 iCommandBuffer->Write<TRect>(aBox);
767 iCommandBuffer->Write<TInt>(aBaselineOffset);
768 iCommandBuffer->Write<TBool>(aUp);
769 iCommandBuffer->Write<TTextAlign>(aVert);
770 iCommandBuffer->Write<TInt>(aMargin);
771 iBoundingRect.BoundingRect(aBox);
775 TInt CRemoteGc::APIExInterface(TAny*& aInterface, TUid aInterfaceId)
777 if(aInterfaceId == KMWsDrawResourceInterfaceUid)
779 aInterface = static_cast<MWsDrawResource*>(iRemoteGcPimpl);
782 return KErrNotSupported;
785 void CRemoteGc::DrawResource(const TPoint& aPos, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation)
787 iCommandBuffer->Write<TDrawCode>(ECommandDrawResourceToPos);
788 iCommandBuffer->Write<TSgDrawableId>(aSource.DrawableId());
789 iCommandBuffer->Write<TInt>(aSource.ScreenNumber());
790 iCommandBuffer->Write<TPoint>(aPos);
791 iCommandBuffer->Write<CWindowGc::TGraphicsRotation>(aRotation);
792 iBoundingRect.BoundingRect(iDrawRect);
793 iHasBitmapCommand = ETrue;
796 void CRemoteGc::DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation)
798 iCommandBuffer->Write<TDrawCode>(ECommandDrawResourceToRect);
799 iCommandBuffer->Write<TSgDrawableId>(aSource.DrawableId());
800 iCommandBuffer->Write<TInt>(aSource.ScreenNumber());
801 iCommandBuffer->Write<TRect>(aDestRect);
802 iCommandBuffer->Write<CWindowGc::TGraphicsRotation>(aRotation);
803 iBoundingRect.BoundingRect(aDestRect);
804 iHasBitmapCommand = ETrue;
807 void CRemoteGc::DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TRect& aSrcRect, CWindowGc::TGraphicsRotation aRotation)
809 iCommandBuffer->Write<TDrawCode>(ECommandDrawResourceFromRectToRect);
810 iCommandBuffer->Write<TSgDrawableId>(aSource.DrawableId());
811 iCommandBuffer->Write<TInt>(aSource.ScreenNumber());
812 iCommandBuffer->Write<TRect>(aDestRect);
813 iCommandBuffer->Write<TRect>(aSrcRect);
814 iCommandBuffer->Write<CWindowGc::TGraphicsRotation>(aRotation);
815 iBoundingRect.BoundingRect(aDestRect);
816 iHasBitmapCommand = ETrue;
819 void CRemoteGc::DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TDesC8& aParam)
821 iCommandBuffer->Write<TDrawCode>(ECommandDrawResourceWithData);
822 iCommandBuffer->Write<TSgDrawableId>(aSource.DrawableId());
823 iCommandBuffer->Write<TInt>(aSource.ScreenNumber());
824 iCommandBuffer->Write<TRect>(aDestRect);
825 iCommandBuffer->WriteText(aParam);
826 iBoundingRect.BoundingRect(aDestRect);
827 iHasBitmapCommand = ETrue;