1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/nonnga/SERVER/playbackgc.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1063 @@
1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// GC.CPP
1.18 +// GC and Graphics functions
1.19 +//
1.20 +//
1.21 +
1.22 +#include "playbackgc.h"
1.23 +
1.24 +#include <e32std.h>
1.25 +#include <s32mem.h>
1.26 +
1.27 +#include "backedupwindow.h"
1.28 +#include "panics.h"
1.29 +#include "ScrDev.H"
1.30 +#include "windowgroup.h"
1.31 +#include "wsfont.h"
1.32 +#include "wstop.h"
1.33 +#include "Graphics/WSGRAPHICDRAWER.H"
1.34 +
1.35 +#if defined(__WINS__) && defined(_DEBUG)
1.36 +# include "offscreenbitmap.h"
1.37 +# define DEBUGOSB { CWsOffScreenBitmap * ofb = iWin->Screen()->OffScreenBitmap(); if (ofb) ofb->Update(); }
1.38 +#else
1.39 +# define DEBUGOSB
1.40 +#endif
1.41 +
1.42 +CPlaybackGc * CPlaybackGc::iSelf=NULL;
1.43 +
1.44 +GLREF_C RWsRegion* InternalizeRegionL(RReadStream& aReadStream);
1.45 +
1.46 +/*CPlaybackGc*/
1.47 +
1.48 +void CPlaybackGc::InitStaticsL()
1.49 + {
1.50 + iSelf=new(ELeave) CPlaybackGc();
1.51 + iSelf->ConstructL();
1.52 + }
1.53 +
1.54 +void CPlaybackGc::DeleteStatics()
1.55 + {
1.56 + delete iSelf;
1.57 + iSelf = 0;
1.58 + }
1.59 +
1.60 +CPlaybackGc::CPlaybackGc()
1.61 + {
1.62 + }
1.63 +
1.64 +void CPlaybackGc::ConstructL()
1.65 + {
1.66 + iSelf->iScratchBitmap=new(ELeave) CFbsBitmap();
1.67 + iSelf->iScratchMaskBitmap=new(ELeave) CFbsBitmap();
1.68 + iGcBuf = CBufSeg::NewL(512);
1.69 + }
1.70 +
1.71 +CPlaybackGc::~CPlaybackGc()
1.72 + {
1.73 + delete iPolyPoints;
1.74 + delete iGcBuf;
1.75 + iCurrentClippingRegion = NULL;
1.76 + delete iScratchBitmap;
1.77 + delete iScratchMaskBitmap;
1.78 + }
1.79 +
1.80 +void CPlaybackGc::Activate(CWsClientWindow * aWin, CFbsBitGc * aGc, const TRegion * aRegion)
1.81 + {
1.82 + iWin = aWin;
1.83 + iGc = aGc;
1.84 + iTargetRegion = aRegion;
1.85 +
1.86 + iDrawRegion = iTargetRegion;
1.87 + iMasterOrigin = iWin->Origin();
1.88 + iOrigin.SetXY(0,0);
1.89 + iGc->SetBrushColor(iWin->BackColor());
1.90 + ResetClippingRect();
1.91 + }
1.92 +
1.93 +void CPlaybackGc::Deactivate()
1.94 + {
1.95 + iWin = 0;
1.96 + iGc = 0;
1.97 + iTargetRegion = 0;
1.98 + iDrawRegion = 0;
1.99 + CancelUserClippingRegion();
1.100 + }
1.101 +
1.102 +void CPlaybackGc::CancelUserClippingRegion()
1.103 + {
1.104 + if (iUserDefinedClippingRegion)
1.105 + {
1.106 + iUserDefinedClippingRegion->Destroy();
1.107 + iUserDefinedClippingRegion = 0;
1.108 + iDrawRegion = iTargetRegion;
1.109 + }
1.110 + }
1.111 +
1.112 +void CPlaybackGc::SetClippingRect(const TRect &aRect)
1.113 + {
1.114 + iClippingRect=aRect;
1.115 + iClippingRect.Move(iOrigin);
1.116 + iClippingRectSet=ETrue;
1.117 + }
1.118 +
1.119 +void CPlaybackGc::ResetClippingRect()
1.120 + {
1.121 + iClippingRectSet=EFalse;
1.122 + }
1.123 +
1.124 +void CPlaybackGc::CheckPolyData(const TAny* aDataPtr, TInt aHeaderSize, TInt aNumPoints)
1.125 + {
1.126 + TInt maxDataLen;
1.127 + if (CWsClient::iCurrentCommand.iOpcode>0)
1.128 + {
1.129 + maxDataLen=CWsClient::EndOfCommandBuffer()-static_cast<const TUint8*>(aDataPtr);
1.130 + }
1.131 + else
1.132 + {
1.133 + maxDataLen=CWsClient::iCurrentCommand.iCmdLength;
1.134 + }
1.135 + const TInt dataSize=aHeaderSize+aNumPoints*sizeof(TPoint);
1.136 + if (dataSize>maxDataLen)
1.137 + GcOwnerPanic(EWservPanicBadPolyData);
1.138 + }
1.139 +
1.140 +void CPlaybackGc::DoDrawPolygon(const TWsGcCmdDrawPolygon *aDrawPolygon)
1.141 + {
1.142 + CheckPolyData(aDrawPolygon, sizeof(TWsGcCmdDrawPolygon), aDrawPolygon->numPoints);
1.143 + iGc->DrawPolygon((TPoint *)(aDrawPolygon+1),aDrawPolygon->numPoints,aDrawPolygon->fillRule);
1.144 + }
1.145 +
1.146 +void CPlaybackGc::StartSegmentedDrawPolygonL(const TWsGcCmdStartSegmentedDrawPolygon *aDrawPolygon)
1.147 + {
1.148 + // In case a Playback have been done before all the segment is in the RedrawStore
1.149 + // (This allocation is deleted only thanks to the EWsGcOpDrawSegmentedPolygon opcode
1.150 + // which arrive after all the segments)
1.151 + delete iPolyPoints;
1.152 + iPolyPoints=NULL;
1.153 +
1.154 + iPolyPoints=(TPoint *)User::AllocL(aDrawPolygon->totalNumPoints*sizeof(TPoint));
1.155 + iPolyPointListSize=aDrawPolygon->totalNumPoints;
1.156 + }
1.157 +
1.158 +void CPlaybackGc::SegmentedDrawPolygonData(const TWsGcCmdSegmentedDrawPolygonData *aDrawPolygon)
1.159 + {
1.160 + if (aDrawPolygon->index<0 || (aDrawPolygon->index + aDrawPolygon->numPoints) > iPolyPointListSize)
1.161 + GcOwnerPanic(EWservPanicBadPolyData);
1.162 + Mem::Copy(iPolyPoints+aDrawPolygon->index,aDrawPolygon+1,aDrawPolygon->numPoints*sizeof(TPoint));
1.163 + }
1.164 +
1.165 +void CPlaybackGc::EndSegmentedPolygon()
1.166 + {
1.167 + delete iPolyPoints;
1.168 + iPolyPoints=NULL;
1.169 + }
1.170 +
1.171 +void CPlaybackGc::DoDrawPolyLine(const TWsGcCmdDrawPolyLine *aDrawPolyLine, TBool aContinued)
1.172 + {
1.173 + TInt numPoints=aDrawPolyLine->numPoints;
1.174 + CheckPolyData(aDrawPolyLine, sizeof(TWsGcCmdDrawPolyLine), numPoints);
1.175 + const TPoint *points=(TPoint *)(aDrawPolyLine+1);
1.176 + if (aContinued)
1.177 + {
1.178 + numPoints++;
1.179 + points=&aDrawPolyLine->last;
1.180 + }
1.181 + if (aDrawPolyLine->more) // more to come so don't draw the end point
1.182 + iGc->DrawPolyLineNoEndPoint(points,numPoints);
1.183 + else
1.184 + iGc->DrawPolyLine(points,numPoints);
1.185 + }
1.186 +
1.187 +void CPlaybackGc::GcOwnerPanic(TClientPanic aPanic)
1.188 + {
1.189 + iGc->SetClippingRegion(NULL);
1.190 + iCurrentClippingRegion = NULL;
1.191 + EndSegmentedPolygon();
1.192 + iWin->WsOwner()->PPanic(aPanic);
1.193 + }
1.194 +
1.195 +// implementing MWsGc
1.196 +
1.197 +MWsClient& CPlaybackGc::Client()
1.198 + {
1.199 + return *(iWin->WsOwner());
1.200 + }
1.201 +
1.202 +MWsScreen& CPlaybackGc::Screen()
1.203 + {
1.204 + return *(iWin->Screen());
1.205 + }
1.206 +
1.207 +TPoint CPlaybackGc::GcOrigin() const
1.208 + {
1.209 + return (iMasterOrigin + iOrigin);
1.210 + }
1.211 +
1.212 +const TRegion& CPlaybackGc::ClippingRegion()
1.213 + {
1.214 + WS_ASSERT_ALWAYS(iCurrentClippingRegion,EWsPanicDrawCommandsInvalidState);
1.215 + return* iCurrentClippingRegion;
1.216 + }
1.217 +
1.218 +CFbsBitGc& CPlaybackGc::BitGc()
1.219 + {
1.220 + return *iGc;
1.221 + }
1.222 +
1.223 +TInt CPlaybackGc::PushBitGcSettings()
1.224 + {
1.225 + // the buf format is len+data where data is written by the GC's ExternalizeL()
1.226 + CBufBase& buf = *iGcBuf;
1.227 + const TInt start = buf.Size();
1.228 + RBufWriteStream out(buf,start);
1.229 + TRAPD(err,out.WriteInt32L(0));
1.230 + if(!err)
1.231 + {
1.232 + TRAP(err,iGc->ExternalizeL(out));
1.233 + }
1.234 + if(err) //rollback addition
1.235 + {
1.236 + buf.Delete(start,buf.Size()-start);
1.237 + }
1.238 + else //fixup len
1.239 + {
1.240 + TRAP_IGNORE(out.CommitL();) // can't see this failing
1.241 + TPckgBuf<TInt32> pckg(buf.Size()-sizeof(TInt32)-start);
1.242 + buf.Write(start,pckg);
1.243 + }
1.244 + return err;
1.245 + }
1.246 +
1.247 +void CPlaybackGc::PopBitGcSettings()
1.248 + {
1.249 + CBufBase& buf = *iGcBuf;
1.250 + TInt ofs = 0;
1.251 + FOREVER
1.252 + {
1.253 + TInt chunk = 0;
1.254 + RBufReadStream in(buf,ofs);
1.255 + TRAPD(err,chunk = in.ReadInt32L());
1.256 + if(err)
1.257 + {
1.258 + WS_ASSERT_DEBUG(err != 0, EWsPanicWsGraphic);
1.259 + return;
1.260 + }
1.261 + if(ofs+sizeof(TInt32)+chunk >= buf.Size()) // the last chunk?
1.262 + {
1.263 + TRAP_IGNORE(iGc->InternalizeL(in));
1.264 + buf.Delete(ofs,buf.Size()-ofs);
1.265 + return;
1.266 + }
1.267 + ofs += chunk + sizeof(TInt32);
1.268 + }
1.269 + }
1.270 +
1.271 +const TTime& CPlaybackGc::Now() const
1.272 + {
1.273 + return iWin->Screen()->Now();
1.274 + }
1.275 +
1.276 +void CPlaybackGc::ScheduleAnimation(const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow)
1.277 + {
1.278 + ScheduleAnimation(aRect,aFromNow,0,0);
1.279 + }
1.280 +
1.281 +void CPlaybackGc::ScheduleAnimation(const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop)
1.282 + {
1.283 + // convert window rect to screen rect
1.284 + TRect rect(aRect);
1.285 + rect.Move(GcOrigin());
1.286 + // clip rect to window extent
1.287 + rect.Intersection(iWin->Abs());
1.288 + if (!rect.IsEmpty())
1.289 + {
1.290 + // and schedule it
1.291 + iWin->Screen()->ScheduleAnimation(rect,aFromNow,aFreq,aStop);
1.292 + }
1.293 + }
1.294 +
1.295 +void CPlaybackGc::SetGcOrigin(const TPoint& aOrigin)
1.296 + {
1.297 + iOrigin = aOrigin - iMasterOrigin;
1.298 + }
1.299 +
1.300 +
1.301 +void CPlaybackGc::RemoteReadDataAndDrawL(const CWsGraphicDrawer* aGraphic, CWsClient* aOwner, const TWsGcCmdUnion &aData)
1.302 + {
1.303 + TPtrC8 data;
1.304 + HBufC8* dataBuf = NULL;
1.305 + const TInt len = aData.WsGraphic->iDataLen;
1.306 +
1.307 + if ((len >= KMaxTInt / 4) || (len < 0))
1.308 + {
1.309 + aOwner->PPanic(EWservPanicBuffer);
1.310 + }
1.311 + dataBuf = HBufC8::NewLC(len);
1.312 + TPtr8 des = dataBuf->Des();
1.313 + aOwner->RemoteRead(des, 0);
1.314 +
1.315 + if(des.Size() != len)
1.316 + {
1.317 + aOwner->PPanic(EWservPanicBuffer);
1.318 + }
1.319 + data.Set(des);
1.320 + aGraphic->Draw(*this, aData.WsGraphic->iRect, data);
1.321 + CleanupStack::PopAndDestroy(dataBuf);
1.322 + }
1.323 +
1.324 +TPtrC CPlaybackGc::BufferTPtr(TText* aStart,TInt aLen, const TDesC8& aCmdData)
1.325 + {
1.326 + if ((reinterpret_cast<TUint8*>(aStart) < aCmdData.Ptr()
1.327 + || reinterpret_cast<TUint8*>(aStart+aLen) > (aCmdData.Ptr() + aCmdData.Size()) ))
1.328 + {
1.329 + GcOwnerPanic(EWservPanicBufferPtr);
1.330 + }
1.331 + TPtrC gcPtr;
1.332 + gcPtr.Set(aStart,aLen);
1.333 + return(gcPtr);
1.334 + }
1.335 +
1.336 +void CPlaybackGc::DoDrawCommand(TWsGcOpcodes aOpcode, const TDesC8& aCmdData, const TRegion *aRegion)
1.337 + {
1.338 + TWsGcCmdUnion pData;
1.339 + pData.any=aCmdData.Ptr();
1.340 +
1.341 + if (aRegion)
1.342 + {
1.343 + WS_ASSERT_DEBUG(iWin,EWsPanicWindowNull);
1.344 + if (aRegion->Count()==0)
1.345 + return;
1.346 + iGc->SetClippingRegion(aRegion);
1.347 + WS_ASSERT_DEBUG(!iCurrentClippingRegion, EWsPanicDrawCommandsInvalidState);
1.348 + iCurrentClippingRegion = aRegion;
1.349 + }
1.350 + switch(aOpcode)
1.351 + {
1.352 + case EWsGcOpDrawWsGraphic:
1.353 + case EWsGcOpDrawWsGraphicPtr:
1.354 + {
1.355 + TRect screenRect(pData.WsGraphic->iRect);
1.356 + screenRect.Move(GcOrigin());
1.357 + if(iCurrentClippingRegion->Intersects(screenRect))
1.358 + {
1.359 + const TInt dataLen = pData.WsGraphic->iDataLen;
1.360 + TGraphicDrawerId id;
1.361 + id.iId = pData.WsGraphic->iId;
1.362 + id.iIsUid = (pData.WsGraphic->iFlags & EWsGraphicIdUid);
1.363 + CWsClient* owner = iWin->WsOwner();
1.364 + const CWsGraphicDrawer* graphic = owner->WindowServer().ResolveGraphic(id);
1.365 + if(graphic && graphic->IsSharedWith(owner->SecureId()))
1.366 + {
1.367 + if(aOpcode == EWsGcOpDrawWsGraphicPtr)
1.368 + {
1.369 + TRAPD(err, RemoteReadDataAndDrawL(graphic, owner, pData))
1.370 + if(err)
1.371 + WS_PANIC_DEBUG(EWsPanicWsGraphic);
1.372 + }
1.373 + else
1.374 + graphic->Draw(*this,pData.WsGraphic->iRect,CWsClient::BufferTPtr8((TUint8*)(pData.WsGraphic+1),dataLen));
1.375 +
1.376 + WS_ASSERT_DEBUG(!iGcBuf->Size(),EWsPanicWsGraphic);
1.377 + iGcBuf->Reset();
1.378 + }
1.379 + }
1.380 + break;
1.381 + }
1.382 + case EWsGcOpMapColorsLocal:
1.383 + iGc->MapColors(pData.MapColorsLocal->rect, pData.MapColorsLocal->colors,pData.MapColorsLocal->numPairs,pData.MapColorsLocal->mapForwards);
1.384 + break;
1.385 + case EWsGcOpDrawPolyLineLocalBufLen:
1.386 + iGc->DrawPolyLine(pData.DrawPolyLineLocalBufLen->points,pData.DrawPolyLineLocalBufLen->length);
1.387 + break;
1.388 + case EWsGcOpDrawPolyLineLocal:
1.389 + iGc->DrawPolyLine(pData.PointList);
1.390 + break;
1.391 + case EWsGcOpDrawPolygonLocalBufLen:
1.392 + iGc->DrawPolygon(pData.DrawPolygonLocalBufLen->points,pData.DrawPolygonLocalBufLen->length,pData.DrawPolygonLocalBufLen->fillRule);
1.393 + break;
1.394 + case EWsGcOpDrawPolygonLocal:
1.395 + iGc->DrawPolygon(pData.DrawPolygonLocal->pointList,pData.DrawPolygonLocal->fillRule);
1.396 + break;
1.397 + case EWsGcOpDrawBitmapLocal:
1.398 + iGc->DrawBitmap(pData.BitmapLocal->pos, pData.BitmapLocal->bitmap);
1.399 + break;
1.400 + case EWsGcOpDrawBitmap2Local:
1.401 + iGc->DrawBitmap(pData.Bitmap2Local->rect, pData.Bitmap2Local->bitmap);
1.402 + break;
1.403 + case EWsGcOpDrawBitmap3Local:
1.404 + iGc->DrawBitmap(pData.Bitmap3Local->rect, pData.Bitmap3Local->bitmap, pData.Bitmap3Local->srcRect);
1.405 + break;
1.406 + case EWsGcOpDrawBitmapMaskedLocal:
1.407 + iGc->DrawBitmapMasked(pData.iBitmapMaskedLocal->iRect, pData.iBitmapMaskedLocal->iBitmap, pData.iBitmapMaskedLocal->iSrcRect, pData.iBitmapMaskedLocal->iMaskBitmap,pData.iBitmapMaskedLocal->iInvertMask);
1.408 + break;
1.409 + case EWsGcOpAlphaBlendBitmapsLocal:
1.410 + iGc->AlphaBlendBitmaps(pData.AlphaBlendBitmapsLocal->point,pData.AlphaBlendBitmapsLocal->iBitmap,
1.411 + pData.AlphaBlendBitmapsLocal->source, pData.AlphaBlendBitmapsLocal->iAlpha,
1.412 + pData.AlphaBlendBitmapsLocal->alphaPoint);
1.413 +
1.414 + break;
1.415 + case EWsGcOpDrawText:
1.416 + iGc->DrawText(BufferTPtr((TText *)(pData.DrawText+1),pData.DrawText->length,aCmdData),pData.DrawText->pos);
1.417 + break;
1.418 + case EWsGcOpDrawBoxTextOptimised1:
1.419 + iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextO1+1),pData.BoxTextO1->length,aCmdData),pData.BoxTextO1->box,
1.420 + pData.BoxTextO1->baselineOffset,CGraphicsContext::ELeft,0);
1.421 + break;
1.422 + case EWsGcOpDrawBoxTextOptimised2:
1.423 + iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextO2+1),pData.BoxTextO2->length,aCmdData),pData.BoxTextO2->box,
1.424 + pData.BoxTextO2->baselineOffset,pData.BoxTextO2->horiz,pData.BoxTextO2->leftMrg);
1.425 + break;
1.426 + case EWsGcOpDrawTextPtr:
1.427 + iGc->DrawText(*pData.DrawTextPtr->text,pData.DrawTextPtr->pos);
1.428 + break;
1.429 + case EWsGcOpDrawTextPtr1:
1.430 + iGc->DrawText(*pData.DrawTextPtr->text);
1.431 + break;
1.432 + case EWsGcOpDrawBoxText:
1.433 + iGc->DrawText(BufferTPtr((TText *)(pData.BoxText+1),pData.BoxText->length,aCmdData),pData.BoxText->box,pData.BoxText->baselineOffset,pData.BoxText->width,pData.BoxText->horiz,pData.BoxText->leftMrg);
1.434 + break;
1.435 + case EWsGcOpDrawBoxTextPtr:
1.436 + iGc->DrawText(*pData.DrawBoxTextPtr->text,pData.DrawBoxTextPtr->box,pData.DrawBoxTextPtr->baselineOffset,pData.DrawBoxTextPtr->width,pData.DrawBoxTextPtr->horiz,pData.DrawBoxTextPtr->leftMrg);
1.437 + break;
1.438 + case EWsGcOpDrawBoxTextPtr1:
1.439 + iGc->DrawText(*pData.DrawBoxTextPtr->text,pData.DrawBoxTextPtr->box);
1.440 + break;
1.441 + case EWsGcOpDrawTextVertical:
1.442 + iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawTextVertical+1),pData.DrawTextVertical->length,aCmdData),pData.DrawTextVertical->pos
1.443 + ,pData.DrawTextVertical->up);
1.444 + break;
1.445 + case EWsGcOpDrawTextVerticalPtr:
1.446 + iGc->DrawTextVertical(*pData.DrawTextVerticalPtr->text,pData.DrawTextVerticalPtr->pos,pData.DrawTextVerticalPtr->up);
1.447 + break;
1.448 + case EWsGcOpDrawTextVerticalPtr1:
1.449 + iGc->DrawTextVertical(*pData.DrawTextVerticalPtr->text,pData.DrawTextVerticalPtr->up);
1.450 + break;
1.451 + case EWsGcOpDrawBoxTextVertical:
1.452 + iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawBoxTextVertical+1),pData.DrawBoxTextVertical->length,aCmdData),
1.453 + pData.DrawBoxTextVertical->box, pData.DrawBoxTextVertical->baselineOffset,
1.454 + pData.DrawBoxTextVertical->up,(CGraphicsContext::TTextAlign)pData.DrawBoxTextVertical->vert,pData.DrawBoxTextVertical->margin);
1.455 + break;
1.456 + case EWsGcOpDrawBoxTextVerticalPtr:
1.457 + iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->baselineOffset
1.458 + ,pData.DrawBoxTextVerticalPtr->width,pData.DrawBoxTextVerticalPtr->up,pData.DrawBoxTextVerticalPtr->vert,pData.DrawBoxTextVerticalPtr->margin);
1.459 + break;
1.460 + case EWsGcOpDrawBoxTextVerticalPtr1:
1.461 + iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->up);
1.462 + break;
1.463 + case EWsGcOpDrawTextLocal:
1.464 + iGc->DrawText(*pData.DrawTextLocal->desc,pData.DrawTextLocal->pos);
1.465 + break;
1.466 + case EWsGcOpDrawBoxTextLocal:
1.467 + iGc->DrawText(*pData.BoxTextLocal->desc,pData.BoxTextLocal->box,pData.BoxTextLocal->baselineOffset,
1.468 + pData.BoxTextLocal->horiz,pData.BoxTextLocal->leftMrg);
1.469 + break;
1.470 + case EWsGcOpDrawLine:
1.471 + iGc->DrawLine(pData.DrawLine->pnt1,pData.DrawLine->pnt2);
1.472 + break;
1.473 + case EWsGcOpDrawTo:
1.474 + iGc->DrawLine(iLinePos,*pData.Point);
1.475 + break;
1.476 + case EWsGcOpDrawBy:
1.477 + iGc->DrawLine(iLinePos,iLinePos+(*pData.Point));
1.478 + break;
1.479 + case EWsGcOpPlot:
1.480 + iGc->Plot(*pData.Point);
1.481 + break;
1.482 + case EWsGcOpMoveTo:
1.483 + case EWsGcOpMoveBy:
1.484 + break;
1.485 + case EWsGcOpGdiBlt2Local:
1.486 + iGc->BitBlt(pData.GdiBlt2Local->pos,pData.GdiBlt2Local->bitmap);
1.487 + break;
1.488 + case EWsGcOpGdiBlt3Local:
1.489 + iGc->BitBlt(pData.GdiBlt3Local->pos,pData.GdiBlt3Local->bitmap, pData.GdiBlt3Local->rect);
1.490 + break;
1.491 + case EWsGcOpGdiBltMaskedLocal:
1.492 + iGc->BitBltMasked(pData.GdiBltMaskedLocal->pos,pData.GdiBltMaskedLocal->bitmap,
1.493 + pData.GdiBltMaskedLocal->rect,pData.GdiBltMaskedLocal->maskBitmap,
1.494 + pData.GdiBltMaskedLocal->invertMask);
1.495 + break;
1.496 + case EWsGcOpGdiWsBlt2:
1.497 + case EWsGcOpGdiWsBlt3:
1.498 + case EWsGcOpGdiWsBltMasked:
1.499 + case EWsGcOpGdiWsAlphaBlendBitmaps:
1.500 + case EWsGcOpWsDrawBitmapMasked:
1.501 + {
1.502 + // Andy - we continually duplicate bitmaps in here, and yet we already have them
1.503 + // somewhere as pointers so can't we both simplify and optimize this?
1.504 + CFbsBitmap* scratchBitmap=iScratchBitmap;
1.505 + CFbsBitmap* scratchMaskBimap=iScratchMaskBitmap;
1.506 + TInt maskHandle=0;
1.507 + TInt handle=WsBitmapHandle(aOpcode,pData, maskHandle);
1.508 + CWsClient* owner=iWin->WsOwner();
1.509 + if (owner!=NULL)
1.510 + {
1.511 + TInt wsBmpErr = KErrNone;
1.512 + DWsBitmap *bitmap=(DWsBitmap *)owner->HandleToObj(handle, WS_HANDLE_BITMAP);
1.513 + if (!bitmap)
1.514 + wsBmpErr = KErrNotFound;
1.515 + else
1.516 + scratchBitmap=bitmap->FbsBitmap();
1.517 + if (wsBmpErr == KErrNone)
1.518 + if (aOpcode==EWsGcOpGdiWsBltMasked || aOpcode==EWsGcOpGdiWsAlphaBlendBitmaps || aOpcode==EWsGcOpWsDrawBitmapMasked)
1.519 + {
1.520 + DWsBitmap *bitmap2=(DWsBitmap *)owner->HandleToObj(maskHandle, WS_HANDLE_BITMAP);
1.521 + if (!bitmap2)
1.522 + wsBmpErr = KErrNotFound;
1.523 + else
1.524 + scratchMaskBimap=bitmap2->FbsBitmap();
1.525 + }
1.526 + if (wsBmpErr == KErrNone)
1.527 + {
1.528 + switch(aOpcode)
1.529 + {
1.530 + case EWsGcOpGdiWsBlt2:
1.531 + iGc->BitBlt(pData.GdiBlt2->pos,scratchBitmap);
1.532 + break;
1.533 + case EWsGcOpGdiWsBlt3:
1.534 + iGc->BitBlt(pData.GdiBlt3->pos,scratchBitmap, pData.GdiBlt3->rect);
1.535 + break;
1.536 + case EWsGcOpGdiWsBltMasked:
1.537 + {
1.538 + iGc->BitBltMasked(pData.GdiBltMasked->destination,scratchBitmap,
1.539 + pData.GdiBltMasked->source, scratchMaskBimap,
1.540 + pData.GdiBltMasked->invertMask);
1.541 + }
1.542 + break;
1.543 + case EWsGcOpGdiWsAlphaBlendBitmaps:
1.544 + {
1.545 + iGc->AlphaBlendBitmaps(pData.AlphaBlendBitmaps->point,scratchBitmap,
1.546 + pData.AlphaBlendBitmaps->source, scratchMaskBimap,
1.547 + pData.AlphaBlendBitmaps->alphaPoint);
1.548 + }
1.549 + break;
1.550 + case EWsGcOpWsDrawBitmapMasked:
1.551 + {
1.552 + iGc->DrawBitmapMasked(pData.iBitmapMasked->iRect,scratchBitmap,
1.553 + pData.iBitmapMasked->iSrcRect,scratchMaskBimap,
1.554 + pData.iBitmapMasked->iInvertMask);
1.555 + }
1.556 + break;
1.557 + }
1.558 + }
1.559 + }
1.560 + break;
1.561 + }
1.562 + case EWsGcOpGdiBlt2:
1.563 + case EWsGcOpGdiBlt3:
1.564 + case EWsGcOpGdiBltMasked:
1.565 + case EWsGcOpGdiAlphaBlendBitmaps:
1.566 + case EWsGcOpDrawBitmap:
1.567 + case EWsGcOpDrawBitmap2:
1.568 + case EWsGcOpDrawBitmap3:
1.569 + case EWsGcOpDrawBitmapMasked:
1.570 + {
1.571 + TInt maskHandle=0;
1.572 + TInt ret = iScratchBitmap->Duplicate(FbsBitmapHandle(aOpcode, pData,maskHandle));
1.573 + if (ret == KErrNone)
1.574 + {
1.575 + switch(aOpcode)
1.576 + {
1.577 + case EWsGcOpGdiBlt2:
1.578 + iGc->BitBlt(pData.GdiBlt2->pos,iScratchBitmap);
1.579 + break;
1.580 + case EWsGcOpGdiBlt3:
1.581 + iGc->BitBlt(pData.GdiBlt3->pos,iScratchBitmap, pData.GdiBlt3->rect);
1.582 + break;
1.583 + case EWsGcOpGdiBltMasked:
1.584 + {
1.585 + ret = iScratchMaskBitmap->Duplicate(pData.GdiBltMasked->maskHandle);
1.586 + if (ret == KErrNone)
1.587 + {
1.588 + iGc->BitBltMasked(pData.GdiBltMasked->destination,iScratchBitmap,
1.589 + pData.GdiBltMasked->source, iScratchMaskBitmap,
1.590 + pData.GdiBltMasked->invertMask);
1.591 + iScratchMaskBitmap->Reset();
1.592 + }
1.593 + }
1.594 + break;
1.595 + case EWsGcOpGdiAlphaBlendBitmaps:
1.596 + {
1.597 + ret = iScratchMaskBitmap->Duplicate(pData.AlphaBlendBitmaps->alphaHandle);
1.598 + if (ret == KErrNone)
1.599 + {
1.600 + iGc->AlphaBlendBitmaps(pData.AlphaBlendBitmaps->point, iScratchBitmap,
1.601 + pData.AlphaBlendBitmaps->source, iScratchMaskBitmap,
1.602 + pData.AlphaBlendBitmaps->alphaPoint);
1.603 + iScratchMaskBitmap->Reset();
1.604 + }
1.605 + break;
1.606 + }
1.607 + case EWsGcOpDrawBitmap:
1.608 + iGc->DrawBitmap(pData.Bitmap->pos, iScratchBitmap);
1.609 + break;
1.610 + case EWsGcOpDrawBitmap2:
1.611 + iGc->DrawBitmap(pData.Bitmap2->rect, iScratchBitmap);
1.612 + break;
1.613 + case EWsGcOpDrawBitmap3:
1.614 + iGc->DrawBitmap(pData.Bitmap3->rect, iScratchBitmap, pData.Bitmap3->srcRect);
1.615 + break;
1.616 + case EWsGcOpDrawBitmapMasked:
1.617 + {
1.618 + ret = iScratchMaskBitmap->Duplicate(pData.iBitmapMasked->iMaskHandle);
1.619 + if (ret == KErrNone)
1.620 + {
1.621 + iGc->DrawBitmapMasked(pData.iBitmapMasked->iRect, iScratchBitmap,
1.622 + pData.iBitmapMasked->iSrcRect, iScratchMaskBitmap,
1.623 + pData.iBitmapMasked->iInvertMask);
1.624 + iScratchMaskBitmap->Reset();
1.625 + }
1.626 + }
1.627 + break;
1.628 + }
1.629 + iScratchBitmap->Reset();
1.630 + }
1.631 + break;
1.632 + }
1.633 + case EWsGcOpDrawSegmentedPolygon:
1.634 + iGc->DrawPolygon(iPolyPoints,iPolyPointListSize,pData.DrawSegmentedPolygon->fillRule);
1.635 + break;
1.636 + case EWsGcOpDrawPolygon:
1.637 + DoDrawPolygon(pData.Polygon);
1.638 + break;
1.639 + case EWsGcOpDrawPolyLine:
1.640 + DoDrawPolyLine(pData.PolyLine, EFalse);
1.641 + break;
1.642 + case EWsGcOpDrawPolyLineContinued:
1.643 + DoDrawPolyLine(pData.PolyLine, ETrue);
1.644 + break;
1.645 + case EWsGcOpClear:
1.646 + iGc->Clear(TRect(iWin->Size()));
1.647 + break;
1.648 + case EWsGcOpClearRect:
1.649 + iGc->Clear(*pData.Rect);
1.650 + break;
1.651 + case EWsGcOpDrawRect:
1.652 + iGc->DrawRect(*pData.Rect);
1.653 + break;
1.654 + case EWsGcOpDrawEllipse:
1.655 + iGc->DrawEllipse(*pData.Rect);
1.656 + break;
1.657 + case EWsGcOpDrawRoundRect:
1.658 + iGc->DrawRoundRect(*pData.Rect,pData.RoundRect->ellipse);
1.659 + break;
1.660 + case EWsGcOpDrawArc:
1.661 + iGc->DrawArc(*pData.Rect,pData.ArcOrPie->start,pData.ArcOrPie->end);
1.662 + break;
1.663 + case EWsGcOpDrawPie:
1.664 + iGc->DrawPie(*pData.Rect,pData.ArcOrPie->start,pData.ArcOrPie->end);
1.665 + break;
1.666 + case EWsGcOpCopyRect:
1.667 + iGc->CopyRect(pData.CopyRect->pos,*pData.Rect);
1.668 + break;
1.669 + case EWsGcOpMapColors:
1.670 + iGc->MapColors(pData.MapColors->rect,(TRgb *)(pData.MapColors+1),pData.MapColors->numPairs,pData.MapColors->mapForwards);
1.671 + break;
1.672 + default:
1.673 + TRAP_IGNORE(iWin->OwnerPanic(EWservPanicOpcode));
1.674 + break;
1.675 + }
1.676 + // DEBUGOSB // comment in for per-draw-command debug osb updates
1.677 + iGc->SetClippingRegion(NULL);
1.678 + iCurrentClippingRegion = NULL;
1.679 + }
1.680 +
1.681 +TInt CPlaybackGc::WsBitmapHandle(TInt aOpcode, const TWsGcCmdUnion &pData, TInt& aMaskHandle)
1.682 + {
1.683 + TInt handle=0;
1.684 + switch(aOpcode)
1.685 + {
1.686 + case EWsGcOpGdiWsBlt2:
1.687 + handle=pData.GdiBlt2->handle;
1.688 + break;
1.689 + case EWsGcOpGdiWsBlt3:
1.690 + handle=pData.GdiBlt3->handle;
1.691 + break;
1.692 + case EWsGcOpGdiWsBltMasked:
1.693 + handle=pData.GdiBltMasked->handle;
1.694 + aMaskHandle = pData.GdiBltMasked->maskHandle;
1.695 + break;
1.696 + case EWsGcOpGdiWsAlphaBlendBitmaps:
1.697 + handle=pData.AlphaBlendBitmaps->bitmapHandle;
1.698 + aMaskHandle = pData.AlphaBlendBitmaps->alphaHandle;
1.699 + break;
1.700 + case EWsGcOpWsDrawBitmapMasked:
1.701 + handle=pData.iBitmapMasked->iHandle;
1.702 + aMaskHandle=pData.iBitmapMasked->iMaskHandle;
1.703 + break;
1.704 + }
1.705 + return handle;
1.706 + }
1.707 +
1.708 +TInt CPlaybackGc::FbsBitmapHandle(TInt aOpcode, const TWsGcCmdUnion &pData, TInt& aMaskHandle)
1.709 + {
1.710 + TInt handle=0;
1.711 + aMaskHandle=0;
1.712 + switch(aOpcode)
1.713 + {
1.714 + case EWsGcOpGdiWsBlt2:
1.715 + case EWsGcOpGdiWsBlt3:
1.716 + case EWsGcOpGdiWsBltMasked:
1.717 + case EWsGcOpGdiWsAlphaBlendBitmaps:
1.718 + {
1.719 + TInt maskHandle = 0;
1.720 + DWsBitmap *bitmap=(DWsBitmap *)iWin->WsOwner()->HandleToObj(WsBitmapHandle(aOpcode,pData, maskHandle), WS_HANDLE_BITMAP);
1.721 + WS_ASSERT_DEBUG(bitmap, EWsPanicDrawCommandsInvalidState);
1.722 + if (bitmap)
1.723 + handle=bitmap->FbsBitmap()->Handle();
1.724 + if (aOpcode==EWsGcOpGdiWsBltMasked || aOpcode==EWsGcOpGdiWsAlphaBlendBitmaps)
1.725 + {
1.726 + DWsBitmap *bitmap2=(DWsBitmap *)iWin->WsOwner()->HandleToObj(maskHandle, WS_HANDLE_BITMAP);
1.727 + WS_ASSERT_DEBUG(bitmap2, EWsPanicDrawCommandsInvalidState);
1.728 + if (bitmap2)
1.729 + aMaskHandle=bitmap2->FbsBitmap()->Handle();
1.730 + }
1.731 + break;
1.732 + }
1.733 + case EWsGcOpGdiBlt2:
1.734 + handle=pData.GdiBlt2->handle;
1.735 + break;
1.736 + case EWsGcOpGdiBlt3:
1.737 + handle=pData.GdiBlt3->handle;
1.738 + break;
1.739 + case EWsGcOpGdiBltMasked:
1.740 + handle=pData.GdiBltMasked->handle;
1.741 + aMaskHandle=pData.GdiBltMasked->maskHandle;
1.742 + break;
1.743 + case EWsGcOpGdiAlphaBlendBitmaps:
1.744 + handle=pData.AlphaBlendBitmaps->bitmapHandle;
1.745 + aMaskHandle=pData.AlphaBlendBitmaps->alphaHandle;
1.746 + break;
1.747 + case EWsGcOpDrawBitmap:
1.748 + handle=pData.Bitmap->handle;
1.749 + break;
1.750 + case EWsGcOpDrawBitmap2:
1.751 + handle=pData.Bitmap2->handle;
1.752 + break;
1.753 + case EWsGcOpDrawBitmap3:
1.754 + handle=pData.Bitmap3->handle;
1.755 + break;
1.756 + case EWsGcOpDrawBitmapMasked:
1.757 + handle=pData.iBitmapMasked->iHandle;
1.758 + aMaskHandle=pData.iBitmapMasked->iMaskHandle;
1.759 + break;
1.760 + }
1.761 + return handle;
1.762 + }
1.763 +
1.764 +
1.765 +void CPlaybackGc::UpdateJustification(TText* aText,TInt aLen, const TDesC8& aCmdData)
1.766 + {
1.767 + iGc->UpdateJustification(BufferTPtr(aText,aLen,aCmdData));
1.768 + }
1.769 +
1.770 +void CPlaybackGc::DoDrawing(TWsGcOpcodes aOpcode, const TDesC8& aCmdData)
1.771 + {
1.772 + TWsGcCmdUnion pData;
1.773 + pData.any=aCmdData.Ptr();
1.774 +
1.775 + // Andy. We do this every time? Shouldn't this be set up for us already by the render stage?
1.776 + // infact, aren't we breaking the render stage by doing it here?
1.777 + iGc->SetUserDisplayMode(iWin->DisplayMode());
1.778 + if (iClippingRectSet)
1.779 + {
1.780 + iGc->SetOrigin(iMasterOrigin);
1.781 + iGc->SetClippingRect(iClippingRect);
1.782 + }
1.783 + iGc->SetOrigin(iMasterOrigin + iOrigin);
1.784 +
1.785 + DoDrawCommand(aOpcode,aCmdData,iDrawRegion);
1.786 +
1.787 + iGc->CancelClippingRect();
1.788 + iGc->SetUserDisplayMode(ENone);
1.789 + switch(aOpcode)
1.790 + {
1.791 + case EWsGcOpDrawLine:
1.792 + iLinePos=pData.DrawLine->pnt2;
1.793 + break;
1.794 + case EWsGcOpDrawTo:
1.795 + case EWsGcOpMoveTo:
1.796 + case EWsGcOpPlot:
1.797 + iLinePos=(*pData.Point);
1.798 + break;
1.799 + case EWsGcOpDrawBy:
1.800 + case EWsGcOpMoveBy:
1.801 + iLinePos+=(*pData.Point);
1.802 + break;
1.803 + case EWsGcOpDrawSegmentedPolygon:
1.804 + EndSegmentedPolygon();
1.805 + break;
1.806 + case EWsGcOpDrawText:
1.807 + UpdateJustification((TText *)(pData.DrawText+1),pData.DrawText->length,aCmdData);
1.808 + break;
1.809 + case EWsGcOpDrawTextVertical:
1.810 + UpdateJustification((TText *)(pData.DrawTextVertical+1),pData.DrawTextVertical->length,aCmdData);
1.811 + break;
1.812 + case EWsGcOpDrawBoxText:
1.813 + UpdateJustification((TText *)(pData.BoxText+1),pData.BoxText->length,aCmdData);
1.814 + break;
1.815 + case EWsGcOpDrawBoxTextOptimised1:
1.816 + UpdateJustification((TText *)(pData.BoxTextO1+1),pData.BoxTextO1->length,aCmdData);
1.817 + break;
1.818 + case EWsGcOpDrawBoxTextOptimised2:
1.819 + UpdateJustification((TText *)(pData.BoxTextO2+1),pData.BoxTextO2->length,aCmdData);
1.820 + break;
1.821 + case EWsGcOpDrawBoxTextVertical:
1.822 + UpdateJustification((TText *)(pData.DrawBoxTextVertical+1),pData.DrawBoxTextVertical->length,aCmdData);
1.823 + break;
1.824 + case EWsGcOpDrawTextLocal:
1.825 + iGc->UpdateJustification(*pData.DrawTextLocal->desc);
1.826 + break;
1.827 + case EWsGcOpDrawBoxTextLocal:
1.828 + iGc->UpdateJustification(*pData.BoxTextLocal->desc);
1.829 + break;
1.830 + case EWsGcOpDrawTextPtr:
1.831 + iGc->UpdateJustification(*pData.DrawTextPtr->text);
1.832 + break;
1.833 + case EWsGcOpDrawTextVerticalPtr:
1.834 + iGc->UpdateJustification(*pData.DrawTextVerticalPtr->text);
1.835 + break;
1.836 + case EWsGcOpDrawBoxTextPtr:
1.837 + iGc->UpdateJustification(*pData.DrawBoxTextPtr->text);
1.838 + break;
1.839 + case EWsGcOpDrawBoxTextVerticalPtr:
1.840 + iGc->UpdateJustification(*pData.DrawBoxTextVerticalPtr->text);
1.841 + break;
1.842 + }
1.843 + }
1.844 +
1.845 +void CPlaybackGc::CommandL(TWsGcOpcodes aOpcode, const TDesC8& aCmdData)
1.846 + {
1.847 + TWsGcCmdUnion pData;
1.848 + pData.any=aCmdData.Ptr();
1.849 +
1.850 + switch(aOpcode)
1.851 + {
1.852 + case EWsGcOpStartSegmentedDrawPolygon:
1.853 + StartSegmentedDrawPolygonL(pData.StartSegmentedDrawPolygon);
1.854 + break;
1.855 + case EWsGcOpSegmentedDrawPolygonData:
1.856 + SegmentedDrawPolygonData(pData.SegmentedDrawPolygonData);
1.857 + break;
1.858 + case EWsGcOpSetClippingRegion:
1.859 + WS_ASSERT_DEBUG(aOpcode != EWsGcOpSetClippingRegion, EWsPanicDrawCommandsInvalidState);
1.860 + break;
1.861 + case EWsGcOpSetClippingRect:
1.862 + SetClippingRect(*pData.Rect);
1.863 + break;
1.864 + case EWsGcOpCancelClippingRect:
1.865 + ResetClippingRect();
1.866 + break;
1.867 + case EWsGcOpCancelClippingRegion:
1.868 + CancelUserClippingRegion();
1.869 + break;
1.870 + case EWsGcOpSetFaded:
1.871 + iGc->SetFaded(*pData.Bool);
1.872 + break;
1.873 + case EWsGcOpSetFadeParams:
1.874 + iGc->SetFadingParameters(WservEncoding::ExtractFirst8BitValue(*pData.UInt),WservEncoding::ExtractSecond8BitValue(*pData.UInt));
1.875 + break;
1.876 + case EWsGcOpSetDrawMode:
1.877 + iGc->SetDrawMode((CGraphicsContext::TDrawMode)*pData.UInt);
1.878 + break;
1.879 + case EWsGcOpUseFont:
1.880 + if (CWsFontCache::Instance()->UseFont(iFont, *pData.UInt))
1.881 + iGc->UseFont(*pData.UInt);
1.882 + else
1.883 + iGc->UseFontNoDuplicate(iFont);
1.884 + break;
1.885 + case EWsGcOpDiscardFont:
1.886 + CWsFontCache::Instance()->ReleaseFont(iFont);
1.887 + iGc->DiscardFont();
1.888 + break;
1.889 + case EWsGcOpSetUnderlineStyle:
1.890 + iGc->SetUnderlineStyle(*pData.SetUnderlineStyle);
1.891 + break;
1.892 + case EWsGcOpSetStrikethroughStyle:
1.893 + iGc->SetStrikethroughStyle(*pData.SetStrikethroughStyle);
1.894 + break;
1.895 + case EWsGcOpUseBrushPattern:
1.896 + iGc->UseBrushPattern(*pData.handle);
1.897 + break;
1.898 + case EWsGcOpDiscardBrushPattern:
1.899 + iGc->DiscardBrushPattern();
1.900 + break;
1.901 + case EWsGcOpSetBrushColor:
1.902 + iGc->SetBrushColor(*pData.rgb);
1.903 + break;
1.904 + case EWsGcOpSetPenColor:
1.905 + iGc->SetPenColor(*pData.rgb);
1.906 + break;
1.907 + case EWsGcOpSetPenStyle:
1.908 + iGc->SetPenStyle((CGraphicsContext::TPenStyle)*pData.UInt);
1.909 + break;
1.910 + case EWsGcOpSetPenSize:
1.911 + iGc->SetPenSize(*pData.Size);
1.912 + break;
1.913 + case EWsGcOpSetBrushStyle:
1.914 + iGc->SetBrushStyle((CGraphicsContext::TBrushStyle)*pData.UInt);
1.915 + break;
1.916 + case EWsGcOpReset:
1.917 + CWsFontCache::Instance()->ReleaseFont(iFont);
1.918 + iGc->Reset();
1.919 + iOrigin.SetXY(0,0);
1.920 + ResetClippingRect();
1.921 + iGc->SetBrushColor(iWin->BackColor());
1.922 + break;
1.923 + case EWsGcOpSetBrushOrigin:
1.924 + iGc->SetBrushOrigin(*pData.Point);
1.925 + break;
1.926 + case EWsGcOpSetDitherOrigin:
1.927 + iGc->SetDitherOrigin(*pData.Point);
1.928 + break;
1.929 + case EWsGcOpSetWordJustification:
1.930 + iGc->SetWordJustification(pData.SetJustification->excessWidth, pData.SetJustification->numGaps);
1.931 + break;
1.932 + case EWsGcOpSetCharJustification:
1.933 + iGc->SetCharJustification(pData.SetJustification->excessWidth, pData.SetJustification->numGaps);
1.934 + break;
1.935 + case EWsGcOpSetOrigin:
1.936 + SetOrigin(*pData.Point);
1.937 + break;
1.938 + case EWsGcOpSetOpaque:
1.939 + // Andy - opaque drawing has not been implemented yet.
1.940 + //SetOpaque(*pData.Bool);
1.941 + break;
1.942 + case EWsGcOpSetShadowColor:
1.943 + iGc->SetShadowColor(*pData.rgb);
1.944 + break;
1.945 + default: // Assume remaining functions will draw
1.946 + {
1.947 + DoDrawing(aOpcode,aCmdData);
1.948 + return;
1.949 + }
1.950 + }
1.951 + }
1.952 +
1.953 +void CPlaybackGc::SetOrigin(const TPoint &aOrigin)
1.954 + {
1.955 + iOrigin=aOrigin;
1.956 + }
1.957 +
1.958 +/*------------------------------------------------------------------------------
1.959 + Description: Retrieves graphics context information back from a given buffer
1.960 + from a given start position.
1.961 + -----------------------------------------------------------------------------*/
1.962 +void CPlaybackGc::InternalizeL(const CBufBase& aBuffer,TInt& aStartPos)
1.963 + {
1.964 + // Open the stream used for the input from the given start position
1.965 + // in the buffer.
1.966 + RBufReadStream bufReadStream;
1.967 + bufReadStream.Open(aBuffer,aStartPos);
1.968 + CleanupClosePushL(bufReadStream);
1.969 +
1.970 + // Read the font/bitmap server data
1.971 + iGc->InternalizeL(bufReadStream);
1.972 +
1.973 + iOrigin.iX = bufReadStream.ReadInt32L();
1.974 + iOrigin.iY = bufReadStream.ReadInt32L();
1.975 +
1.976 + iClippingRectSet=bufReadStream.ReadInt8L();
1.977 +
1.978 + // If there is a clipping rectangle data read it.
1.979 + if (iClippingRectSet)
1.980 + bufReadStream>>iClippingRect;
1.981 +
1.982 + // Force FbsBitGc to reset its user clipping rect in case orientation has changed.
1.983 + // The user clipping rect of FbsBitGc will be set to iClippingRect later before
1.984 + // drawing the command.
1.985 + iGc->CancelClippingRect();
1.986 +
1.987 + // Read the clipping region data
1.988 + InternalizeClippingRegionL(bufReadStream);
1.989 +
1.990 + // Read the Alpha values for Brush and Pen colors.
1.991 + InternalizeAlphaValueL(bufReadStream);
1.992 +
1.993 + CleanupStack::PopAndDestroy(&bufReadStream);
1.994 + }
1.995 +
1.996 +/*------------------------------------------------------------------------------
1.997 + Description: Retrieves TRgb::alpha value information back from a given buffer
1.998 + and updates the Brushcolor with the same.
1.999 + -----------------------------------------------------------------------------*/
1.1000 +void CPlaybackGc::InternalizeAlphaValueL(RReadStream& aReadStream)
1.1001 + {
1.1002 + TRgb brushColor(iGc->BrushColor());
1.1003 + brushColor.SetAlpha(aReadStream.ReadUint8L());
1.1004 + iGc->SetBrushColor(brushColor);
1.1005 + TRgb penColor(iGc->PenColor());
1.1006 + penColor.SetAlpha(aReadStream.ReadUint8L());
1.1007 + iGc->SetPenColor(penColor);
1.1008 + }
1.1009 +
1.1010 +/*------------------------------------------------------------------------------
1.1011 + Description: Helper method to retrieve clipping region data from a given
1.1012 + read stream.
1.1013 + -----------------------------------------------------------------------------*/
1.1014 +void CPlaybackGc::InternalizeClippingRegionL(RReadStream& aReadStream)
1.1015 + {
1.1016 + WS_ASSERT_DEBUG(iTargetRegion, EWsPanicDrawCommandsInvalidState);
1.1017 + // Read flag to indicate if client had defined a clipping region
1.1018 + TBool clipRegion = aReadStream.ReadInt8L();
1.1019 + CancelUserClippingRegion();
1.1020 + if (clipRegion)
1.1021 + {
1.1022 + // Note that this clipping region is in window relative coordinates when
1.1023 + // received from the client (and being stored) but is in screen relative
1.1024 + // coordinates after being retrieved from the redraw store.
1.1025 + iUserDefinedClippingRegion = InternalizeRegionL(aReadStream);
1.1026 + iUserDefinedClippingRegion->Offset(iWin->Origin());
1.1027 + iUserDefinedClippingRegion->Intersect(*iTargetRegion);
1.1028 + if (iUserDefinedClippingRegion->CheckError()) // fallback to no user clipping region
1.1029 + {
1.1030 + CancelUserClippingRegion();
1.1031 + }
1.1032 + else
1.1033 + {
1.1034 + iDrawRegion = iUserDefinedClippingRegion;
1.1035 + }
1.1036 + }
1.1037 + }
1.1038 +
1.1039 +/**
1.1040 +This pretty much replaces the whole of what was TDrawDestination
1.1041 +This can only be sensibly called from outside a sequence of drawing commands,
1.1042 +since it negates any user defined clipping regions.
1.1043 +*/
1.1044 +void CPlaybackGc::SetTargetRegion(const TRegion* aRegion)
1.1045 + {
1.1046 + iTargetRegion = aRegion;
1.1047 + iDrawRegion = iTargetRegion;
1.1048 + CancelUserClippingRegion();
1.1049 + }
1.1050 +
1.1051 +void CPlaybackGc::Reset()
1.1052 + {
1.1053 + iGc->Reset();
1.1054 + }
1.1055 +
1.1056 +TAny * CPlaybackGc::ResolveObjectInterface(TUint aId)
1.1057 + {
1.1058 + switch (aId)
1.1059 + {
1.1060 + case MWsWindow::EWsObjectInterfaceId:
1.1061 + return dynamic_cast<MWsWindow *>(iWin);
1.1062 + case MWsFader::EWsObjectInterfaceId:
1.1063 + return iWin->Screen()->Fader();
1.1064 + }
1.1065 + return NULL;
1.1066 + }