1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/nga/SERVER/openwfc/playbackgc.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1391 @@
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 and Graphics functions
1.18 +//
1.19 +//
1.20 +
1.21 +#include "playbackgc.h"
1.22 +
1.23 +#include <e32std.h>
1.24 +#include <s32mem.h>
1.25 +
1.26 +#include "panics.h"
1.27 +#include "ScrDev.H"
1.28 +#include "windowgroup.h"
1.29 +#include "wsfont.h"
1.30 +#include "wstop.h"
1.31 +#include "graphics/WSGRAPHICDRAWER.H"
1.32 +#include "graphics/surfaceconfiguration.h"
1.33 +#include "windowelementset.h"
1.34 +
1.35 +#include <graphics/wsgraphicscontext.h>
1.36 +#include <graphics/wsuibuffer.h>
1.37 +#include "bitgditomwsgraphicscontextmappings.h"
1.38 +
1.39 +#include "graphicscontextstate.h"
1.40 +#include "drawresource.h"
1.41 +#include "devicemap.h"
1.42 +
1.43 +CPlaybackGc * CPlaybackGc::iSelf=NULL;
1.44 +
1.45 +GLREF_C RWsRegion* InternalizeRegionL(RReadStream& aReadStream);
1.46 +
1.47 +/*CPlaybackGc*/
1.48 +
1.49 +void CPlaybackGc::InitStaticsL()
1.50 + {
1.51 + iSelf=new(ELeave) CPlaybackGc();
1.52 + iSelf->ConstructL();
1.53 + }
1.54 +
1.55 +void CPlaybackGc::DeleteStatics()
1.56 + {
1.57 + delete iSelf;
1.58 + iSelf = 0;
1.59 + }
1.60 +
1.61 +CPlaybackGc::CPlaybackGc()
1.62 + {
1.63 + }
1.64 +
1.65 +void CPlaybackGc::ConstructL()
1.66 + {
1.67 + iGcBuf = CBufSeg::NewL(512);
1.68 + }
1.69 +
1.70 +CPlaybackGc::~CPlaybackGc()
1.71 + {
1.72 + delete iPolyPoints;
1.73 + delete iGcBuf;
1.74 + iCurrentClippingRegion = NULL;
1.75 + iIntersectedRegion.Close();
1.76 + }
1.77 +
1.78 +void CPlaybackGc::Activate(CWsClientWindow * aWin, MWsGraphicsContext * aGc, const TRegion * aRegion)
1.79 + {
1.80 + iWin = aWin;
1.81 + iGc = aGc;
1.82 + iTargetRegion = aRegion;
1.83 +
1.84 + iDrawRegion = iTargetRegion;
1.85 + iMasterOrigin = iWin->Origin();
1.86 + iOrigin.SetXY(0,0);
1.87 + iSendOrigin = ETrue;
1.88 + iGc->SetBrushColor(iWin->BackColor());
1.89 + ResetClippingRect();
1.90 + }
1.91 +
1.92 +void CPlaybackGc::Deactivate()
1.93 + {
1.94 + iWin = 0;
1.95 + iGc = 0;
1.96 + iTargetRegion = 0;
1.97 + iDrawRegion = 0;
1.98 + CancelUserClippingRegion();
1.99 + }
1.100 +
1.101 +void CPlaybackGc::CancelUserClippingRegion()
1.102 + {
1.103 + if (iUserDefinedClippingRegion)
1.104 + {
1.105 + iUserDefinedClippingRegion->Destroy();
1.106 + iUserDefinedClippingRegion = 0;
1.107 + iDrawRegion = iTargetRegion;
1.108 + }
1.109 + }
1.110 +
1.111 +void CPlaybackGc::SetClippingRect(const TRect &aRect)
1.112 + {
1.113 + iClippingRect=aRect;
1.114 + iClippingRect.Move(iOrigin);
1.115 + iClippingRectSet=ETrue;
1.116 + }
1.117 +
1.118 +void CPlaybackGc::ResetClippingRect()
1.119 + {
1.120 + iClippingRectSet=EFalse;
1.121 + }
1.122 +
1.123 +void CPlaybackGc::CheckPolyData(const TAny* aDataPtr, TInt aHeaderSize, TInt aNumPoints)
1.124 + {
1.125 + TInt maxDataLen;
1.126 + if (CWsClient::iCurrentCommand.iOpcode>0)
1.127 + {
1.128 + maxDataLen=CWsClient::EndOfCommandBuffer()-static_cast<const TUint8*>(aDataPtr);
1.129 + }
1.130 + else
1.131 + {
1.132 + maxDataLen=CWsClient::iCurrentCommand.iCmdLength;
1.133 + }
1.134 + const TInt dataSize=aHeaderSize+aNumPoints*sizeof(TPoint);
1.135 + if (dataSize>maxDataLen)
1.136 + GcOwnerPanic(EWservPanicBadPolyData);
1.137 + }
1.138 +
1.139 +void CPlaybackGc::DoDrawPolygon(const TWsGcCmdDrawPolygon *aDrawPolygon)
1.140 + {
1.141 + CheckPolyData(aDrawPolygon, sizeof(TWsGcCmdDrawPolygon), aDrawPolygon->numPoints);
1.142 + TArrayWrapper<TPoint> points((TPoint*)(aDrawPolygon + 1), aDrawPolygon->numPoints);
1.143 + iGc->DrawPolygon(points, BitGdiToMWsGraphicsContextMappings::Convert(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 + if (iPolyPoints)
1.152 + {
1.153 + delete iPolyPoints;
1.154 + iPolyPoints=NULL;
1.155 + }
1.156 + if(!Rng(0, aDrawPolygon->totalNumPoints, KMaxTInt/2 - 1))
1.157 + GcOwnerPanic(EWservPanicBadPolyData);
1.158 + iPolyPoints=(TPoint *)User::AllocL(aDrawPolygon->totalNumPoints*sizeof(TPoint));
1.159 + iPolyPointListSize=aDrawPolygon->totalNumPoints;
1.160 + }
1.161 +
1.162 +void CPlaybackGc::SegmentedDrawPolygonData(const TWsGcCmdSegmentedDrawPolygonData *aDrawPolygon)
1.163 + {
1.164 + if (aDrawPolygon->index<0 || (aDrawPolygon->index + aDrawPolygon->numPoints) > iPolyPointListSize)
1.165 + GcOwnerPanic(EWservPanicBadPolyData);
1.166 + Mem::Copy(iPolyPoints+aDrawPolygon->index,aDrawPolygon+1,aDrawPolygon->numPoints*sizeof(TPoint));
1.167 + }
1.168 +
1.169 +void CPlaybackGc::EndSegmentedPolygon()
1.170 + {
1.171 + delete iPolyPoints;
1.172 + iPolyPoints=NULL;
1.173 + }
1.174 +
1.175 +void CPlaybackGc::DoDrawPolyLine(const TWsGcCmdDrawPolyLine *aDrawPolyLine, TBool aContinued)
1.176 + {
1.177 + TInt numPoints=aDrawPolyLine->numPoints;
1.178 + CheckPolyData(aDrawPolyLine, sizeof(TWsGcCmdDrawPolyLine), numPoints);
1.179 + const TPoint *points=(TPoint *)(aDrawPolyLine+1);
1.180 + if (aContinued)
1.181 + {
1.182 + numPoints++;
1.183 + points=&aDrawPolyLine->last;
1.184 + }
1.185 + TArrayWrapper<TPoint> pointsArr(points, numPoints);
1.186 + if (aDrawPolyLine->more) // more to come so don't draw the end point
1.187 + iGc->DrawPolyLineNoEndPoint(pointsArr);
1.188 + else
1.189 + iGc->DrawPolyLine(pointsArr);
1.190 + }
1.191 +
1.192 +void CPlaybackGc::GcOwnerPanic(TClientPanic aPanic)
1.193 + {
1.194 + iGc->ResetClippingRegion();
1.195 + iCurrentClippingRegion = NULL;
1.196 + EndSegmentedPolygon();
1.197 + iWin->WsOwner()->PPanic(aPanic);
1.198 + }
1.199 +
1.200 +// implementing MWsGc
1.201 +
1.202 +MWsClient& CPlaybackGc::Client()
1.203 + {
1.204 + return *(iWin->WsOwner());
1.205 + }
1.206 +
1.207 +MWsScreen& CPlaybackGc::Screen()
1.208 + {
1.209 + return *(iWin->Screen());
1.210 + }
1.211 +
1.212 +const TTime& CPlaybackGc::Now() const
1.213 + {
1.214 + return iWin->Screen()->Now();
1.215 + }
1.216 +
1.217 +void CPlaybackGc::ScheduleAnimation(const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow)
1.218 + {
1.219 + ScheduleAnimation(aRect,aFromNow,0,0);
1.220 + }
1.221 +
1.222 +void CPlaybackGc::ScheduleAnimation(const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop)
1.223 + {
1.224 + // convert window rect to screen rect
1.225 + TRect rect(aRect);
1.226 + rect.Move(iGc->Origin());
1.227 + // clip rect to window extent
1.228 + rect.Intersection(iWin->Abs());
1.229 + if (!rect.IsEmpty())
1.230 + {
1.231 + // and schedule it
1.232 + iWin->Screen()->ScheduleAnimation(ECrpAnim, rect, aFromNow, aFreq, aStop, iWin);
1.233 + }
1.234 + }
1.235 +
1.236 +void CPlaybackGc::SetGcOrigin(const TPoint& aOrigin)
1.237 + {
1.238 + iOrigin = aOrigin - iMasterOrigin;
1.239 + }
1.240 +
1.241 +void CPlaybackGc::RemoteReadDataAndDrawL(const CWsGraphicDrawer* aGraphic, CWsClient* aOwner, const TWsGcCmdUnion &aData)
1.242 + {
1.243 + TPtrC8 data;
1.244 + HBufC8* dataBuf = NULL;
1.245 + const TInt len = aData.WsGraphic->iDataLen;
1.246 +
1.247 + if ((len >= KMaxTInt / 4) || (len < 0))
1.248 + {
1.249 + aOwner->PPanic(EWservPanicBuffer);
1.250 + }
1.251 + dataBuf = HBufC8::NewLC(len);
1.252 + TPtr8 des = dataBuf->Des();
1.253 + aOwner->RemoteRead(des, 0);
1.254 +
1.255 + if(des.Size() != len)
1.256 + {
1.257 + aOwner->PPanic(EWservPanicBuffer);
1.258 + }
1.259 + data.Set(des);
1.260 + aGraphic->Draw(*this, aData.WsGraphic->iRect, data);
1.261 + CleanupStack::PopAndDestroy(dataBuf);
1.262 + }
1.263 +
1.264 +TPtrC CPlaybackGc::BufferTPtr(TText* aStart,TInt aLen, const TDesC8& aCmdData)
1.265 + {
1.266 + if ((reinterpret_cast<TUint8*>(aStart) < aCmdData.Ptr()
1.267 + || reinterpret_cast<TUint8*>(aStart+aLen) > (aCmdData.Ptr() + aCmdData.Size()) ))
1.268 + {
1.269 + GcOwnerPanic(EWservPanicBufferPtr);
1.270 + }
1.271 + TPtrC gcPtr;
1.272 + gcPtr.Set(aStart,aLen);
1.273 + return(gcPtr);
1.274 + }
1.275 +
1.276 +void CPlaybackGc::DoDrawCommand(TWsGcOpcodes aOpcode, const TDesC8& aCmdData, const TRegion *aRegion)
1.277 + {
1.278 + if (aRegion->Count()==0)
1.279 + return;
1.280 +
1.281 + TWsGcCmdUnion pData;
1.282 + // coverity[returned_pointer]
1.283 + pData.any=aCmdData.Ptr();
1.284 +
1.285 + SendClippingRegionIfRequired(aRegion);
1.286 +
1.287 + WS_ASSERT_DEBUG(!iCurrentClippingRegion, EWsPanicDrawCommandsInvalidState);
1.288 + iCurrentClippingRegion = aRegion;
1.289 +
1.290 + CGraphicsContext::TTextParameters contextParam;
1.291 +
1.292 + TBool bGcDrawingOccurred = ETrue; //most commands in here draw using the gc
1.293 +
1.294 + switch(aOpcode)
1.295 + {
1.296 + case EWsGcOpDrawWsGraphic:
1.297 + case EWsGcOpDrawWsGraphicPtr:
1.298 + {
1.299 + bGcDrawingOccurred = EFalse; //best guess if the drawer did no happen
1.300 + TRect screenRect(pData.WsGraphic->iRect);
1.301 + screenRect.Move(iGc->Origin());
1.302 + if(iCurrentClippingRegion->Intersects(screenRect))
1.303 + {
1.304 + const TInt dataLen = pData.WsGraphic->iDataLen;
1.305 + TGraphicDrawerId id;
1.306 + id.iId = pData.WsGraphic->iId;
1.307 + id.iIsUid = (pData.WsGraphic->iFlags & EWsGraphicIdUid);
1.308 + CWsClient* owner = iWin->WsOwner();
1.309 + const CWsGraphicDrawer* graphic = CWsTop::WindowServer()->ResolveGraphic(id);
1.310 + TInt lastDrawCount=GcDrawingCount();
1.311 + if(graphic && graphic->IsSharedWith(owner->SecureId()))
1.312 + {
1.313 + if(aOpcode == EWsGcOpDrawWsGraphicPtr)
1.314 + {
1.315 + TRAPD(err, RemoteReadDataAndDrawL(graphic, owner, pData))
1.316 + if(err)
1.317 + WS_PANIC_DEBUG(EWsPanicWsGraphic);
1.318 + }
1.319 + else
1.320 + graphic->Draw(*this,pData.WsGraphic->iRect,CWsClient::BufferTPtr8((TUint8*)(pData.WsGraphic+1),dataLen));
1.321 +
1.322 + WS_ASSERT_DEBUG(!iGcBuf->Size(),EWsPanicWsGraphic);
1.323 + iGcBuf->Reset();
1.324 + }
1.325 + if (lastDrawCount!=GcDrawingCount())
1.326 + {
1.327 + // Changes to the GcDrawingCount are used to tag placed and background surfaces as dirty.
1.328 + // If drawing occurs inside a CRP and perhaps PlaceSurface occurs inside the CRP
1.329 + // then we tag to count again to cause the placed surface to get marked as dirty later.
1.330 + bGcDrawingOccurred = ETrue; //some GC drawing did occurr at some point
1.331 + }
1.332 + }
1.333 + break;
1.334 + }
1.335 + case EWsGcOpMapColorsLocal:
1.336 + GcOwnerPanic(EWservPanicOpcode); //deprecated, the client should never generate this op
1.337 + break;
1.338 + case EWsGcOpDrawPolyLineLocalBufLen:
1.339 + {
1.340 + TArrayWrapper<TPoint> points(pData.DrawPolyLineLocalBufLen->points, pData.DrawPolyLineLocalBufLen->length);
1.341 + iGc->DrawPolyLine(points);
1.342 + break;
1.343 + }
1.344 + case EWsGcOpDrawPolyLineLocal:
1.345 + iGc->DrawPolyLine(pData.PointList->Array());
1.346 + break;
1.347 + case EWsGcOpDrawPolygonLocalBufLen:
1.348 + {
1.349 + TArrayWrapper<TPoint> points(pData.DrawPolygonLocalBufLen->points, pData.DrawPolygonLocalBufLen->length);
1.350 + iGc->DrawPolygon(points, BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawPolygonLocalBufLen->fillRule));
1.351 + break;
1.352 + }
1.353 + case EWsGcOpDrawPolygonLocal:
1.354 + iGc->DrawPolygon(pData.DrawPolygonLocal->pointList->Array(),BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawPolygonLocal->fillRule));
1.355 + break;
1.356 + case EWsGcOpDrawBitmapLocal:
1.357 + {
1.358 + // DrawBitmap(TPoint&, ) uses the size of the bitmap in twips, but
1.359 + // MWsGraphicsContext::DrawBitmap() takes a TRect in pixels, so we need to convert
1.360 + TRect destRect(iWin->Screen()->DeviceMap().TwipsToPixels(pData.BitmapLocal->bitmap->SizeInTwips()));
1.361 + destRect.Move(pData.BitmapLocal->pos); //pos is defined in pixels, that's why we're not converting it
1.362 + iGc->DrawBitmap(destRect, *pData.BitmapLocal->bitmap);
1.363 + break;
1.364 + }
1.365 + case EWsGcOpDrawBitmap2Local:
1.366 + iGc->DrawBitmap(pData.Bitmap2Local->rect, *pData.Bitmap2Local->bitmap);
1.367 + break;
1.368 + case EWsGcOpDrawBitmap3Local:
1.369 + iGc->DrawBitmap(pData.Bitmap3Local->rect, *pData.Bitmap3Local->bitmap, pData.Bitmap3Local->srcRect);
1.370 + break;
1.371 + case EWsGcOpDrawBitmapMaskedLocal:
1.372 + iGc->DrawBitmapMasked(pData.iBitmapMaskedLocal->iRect, *pData.iBitmapMaskedLocal->iBitmap, pData.iBitmapMaskedLocal->iSrcRect, *pData.iBitmapMaskedLocal->iMaskBitmap,pData.iBitmapMaskedLocal->iInvertMask);
1.373 + break;
1.374 + case EWsGcOpAlphaBlendBitmapsLocal:
1.375 + iGc->BitBltMasked(pData.AlphaBlendBitmapsLocal->point, *pData.AlphaBlendBitmapsLocal->iBitmap,
1.376 + pData.AlphaBlendBitmapsLocal->source, *pData.AlphaBlendBitmapsLocal->iAlpha,
1.377 + pData.AlphaBlendBitmapsLocal->alphaPoint);
1.378 + break;
1.379 + case EWsGcOpDrawText:
1.380 + if (iGc->HasFont())
1.381 + iGc->DrawText(BufferTPtr((TText *)(pData.DrawText+1),pData.DrawText->length,aCmdData), NULL, pData.DrawText->pos);
1.382 + break;
1.383 + case EWsGcOpDrawBoxTextOptimised1:
1.384 + if (iGc->HasFont())
1.385 + iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextO1+1),pData.BoxTextO1->length,aCmdData), NULL, pData.BoxTextO1->box,
1.386 + pData.BoxTextO1->baselineOffset,MWsGraphicsContext::ELeft,0);
1.387 + break;
1.388 + case EWsGcOpDrawBoxTextOptimised2:
1.389 + if (iGc->HasFont())
1.390 + iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextO2+1),pData.BoxTextO2->length,aCmdData), NULL, pData.BoxTextO2->box,
1.391 + pData.BoxTextO2->baselineOffset,BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextO2->horiz),pData.BoxTextO2->leftMrg);
1.392 + break;
1.393 + case EWsGcOpDrawTextPtr:
1.394 + if (iGc->HasFont())
1.395 + iGc->DrawText(*pData.DrawTextPtr->text, NULL, pData.DrawTextPtr->pos);
1.396 + break;
1.397 + case EWsGcOpDrawTextPtr1:
1.398 + if (iGc->HasFont())
1.399 + iGc->DrawText(*pData.DrawTextPtr->text, NULL);
1.400 + break;
1.401 + case EWsGcOpDrawBoxText:
1.402 + if (iGc->HasFont())
1.403 + iGc->DrawText(BufferTPtr((TText *)(pData.BoxText+1),pData.BoxText->length,aCmdData), NULL, pData.BoxText->box,
1.404 + pData.BoxText->baselineOffset,BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxText->horiz),pData.BoxText->leftMrg);
1.405 + break;
1.406 + case EWsGcOpDrawBoxTextPtr:
1.407 + if (iGc->HasFont())
1.408 + iGc->DrawText(*pData.DrawBoxTextPtr->text, NULL, pData.DrawBoxTextPtr->box,pData.DrawBoxTextPtr->baselineOffset,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextPtr->horiz),pData.DrawBoxTextPtr->leftMrg);
1.409 + break;
1.410 + case EWsGcOpDrawBoxTextPtr1:
1.411 + if (iGc->HasFont())
1.412 + iGc->DrawText(*pData.DrawBoxTextPtr->text, NULL, pData.DrawBoxTextPtr->box);
1.413 + break;
1.414 + case EWsGcOpDrawTextVertical:
1.415 + if (iGc->HasFont())
1.416 + iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawTextVertical+1),pData.DrawTextVertical->length,aCmdData),NULL,pData.DrawTextVertical->pos
1.417 + ,pData.DrawTextVertical->up);
1.418 + break;
1.419 + case EWsGcOpDrawTextVerticalPtr:
1.420 + if (iGc->HasFont())
1.421 + iGc->DrawTextVertical(*pData.DrawTextVerticalPtr->text,NULL,pData.DrawTextVerticalPtr->pos,pData.DrawTextVerticalPtr->up);
1.422 + break;
1.423 + case EWsGcOpDrawTextVerticalPtr1:
1.424 + if (iGc->HasFont())
1.425 + iGc->DrawTextVertical(*pData.DrawTextVerticalPtr->text,NULL,pData.DrawTextVerticalPtr->up);
1.426 + break;
1.427 + case EWsGcOpDrawBoxTextVertical:
1.428 + if (iGc->HasFont())
1.429 + iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawBoxTextVertical+1),pData.DrawBoxTextVertical->length,aCmdData), NULL,
1.430 + pData.DrawBoxTextVertical->box, pData.DrawBoxTextVertical->baselineOffset,
1.431 + pData.DrawBoxTextVertical->up,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextVertical->vert),pData.DrawBoxTextVertical->margin);
1.432 + break;
1.433 + case EWsGcOpDrawBoxTextVerticalPtr:
1.434 + if (iGc->HasFont())
1.435 + iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,NULL,pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->baselineOffset
1.436 + ,pData.DrawBoxTextVerticalPtr->width,pData.DrawBoxTextVerticalPtr->up,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextVerticalPtr->vert),pData.DrawBoxTextVerticalPtr->margin);
1.437 + break;
1.438 + case EWsGcOpDrawBoxTextVerticalPtr1:
1.439 + if (iGc->HasFont())
1.440 + iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,NULL,pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->up);
1.441 + break;
1.442 + case EWsGcOpDrawTextLocal:
1.443 + if (iGc->HasFont())
1.444 + iGc->DrawText(*pData.DrawTextLocal->desc, NULL, pData.DrawTextLocal->pos);
1.445 + break;
1.446 + case EWsGcOpDrawBoxTextLocal:
1.447 + if (iGc->HasFont())
1.448 + iGc->DrawText(*pData.BoxTextLocal->desc, NULL, pData.BoxTextLocal->box,pData.BoxTextLocal->baselineOffset,
1.449 + BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextLocal->horiz),pData.BoxTextLocal->leftMrg);
1.450 + break;
1.451 + /************* DrawText in Context function calls*********************************************/
1.452 + case EWsGcOpDrawTextInContext:
1.453 + contextParam.iStart = pData.DrawTextInContext->start;
1.454 + contextParam.iEnd = pData.DrawTextInContext->end;
1.455 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.456 + {
1.457 + iGc->DrawText(BufferTPtr((TText *)(pData.DrawTextInContext+1),pData.DrawTextInContext->length,aCmdData),BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContext->pos);
1.458 + }
1.459 + break;
1.460 + case EWsGcOpDrawBoxTextInContextOptimised1:
1.461 + contextParam.iStart = pData.BoxTextInContextO1->start;
1.462 + contextParam.iEnd = pData.BoxTextInContextO1->end;
1.463 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.464 + {
1.465 + iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextInContextO1+1),pData.BoxTextInContextO1->length,aCmdData),BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.BoxTextInContextO1->box,
1.466 + pData.BoxTextInContextO1->baselineOffset,MWsGraphicsContext::ELeft,0);
1.467 + }
1.468 + break;
1.469 + case EWsGcOpDrawBoxTextInContextOptimised2:
1.470 + contextParam.iStart = pData.BoxTextInContextO2->start;
1.471 + contextParam.iEnd = pData.BoxTextInContextO2->end;
1.472 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.473 + {
1.474 + iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextInContextO2+1),pData.BoxTextInContextO2->length,aCmdData),BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.BoxTextInContextO2->box,
1.475 + pData.BoxTextInContextO2->baselineOffset,BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextInContextO2->horiz),pData.BoxTextInContextO2->leftMrg);
1.476 + }
1.477 + break;
1.478 + case EWsGcOpDrawTextInContextPtr:
1.479 + contextParam.iStart = pData.DrawTextInContextPtr->start;
1.480 + contextParam.iEnd = pData.DrawTextInContextPtr->end;
1.481 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.482 + {
1.483 + iGc->DrawText(*pData.DrawTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContextPtr->pos);
1.484 + }
1.485 + break;
1.486 + case EWsGcOpDrawTextInContextPtr1:
1.487 + contextParam.iStart = pData.DrawTextInContextPtr->start;
1.488 + contextParam.iEnd = pData.DrawTextInContextPtr->end;
1.489 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.490 + {
1.491 + iGc->DrawText(*pData.DrawTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
1.492 + }
1.493 + break;
1.494 + case EWsGcOpDrawBoxTextInContext:
1.495 + contextParam.iStart = pData.BoxTextInContext->start;
1.496 + contextParam.iEnd = pData.BoxTextInContext->end;
1.497 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.498 + {
1.499 + iGc->DrawText(BufferTPtr((TText *)(pData.BoxTextInContext+1),pData.BoxTextInContext->length,aCmdData),
1.500 + BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.BoxTextInContext->box,pData.BoxTextInContext->baselineOffset,
1.501 + BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextInContext->horiz),pData.BoxTextInContext->leftMrg);
1.502 + }
1.503 + break;
1.504 + case EWsGcOpDrawBoxTextInContextPtr:
1.505 + contextParam.iStart = pData.DrawBoxTextInContextPtr->start;
1.506 + contextParam.iEnd = pData.DrawBoxTextInContextPtr->end;
1.507 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.508 + {
1.509 + iGc->DrawText(*pData.DrawBoxTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextInContextPtr->box,pData.DrawBoxTextInContextPtr->baselineOffset,
1.510 + BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextInContextPtr->horiz),pData.DrawBoxTextInContextPtr->leftMrg);
1.511 + }
1.512 + break;
1.513 + case EWsGcOpDrawBoxTextInContextPtr1:
1.514 + contextParam.iStart = pData.DrawBoxTextInContextPtr->start;
1.515 + contextParam.iEnd = pData.DrawBoxTextInContextPtr->end;
1.516 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.517 + {
1.518 + iGc->DrawText(*pData.DrawBoxTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextInContextPtr->box);
1.519 + }
1.520 + break;
1.521 + case EWsGcOpDrawTextInContextVertical:
1.522 + contextParam.iStart = pData.DrawTextInContextVertical->start;
1.523 + contextParam.iEnd = pData.DrawTextInContextVertical->end;
1.524 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.525 + {
1.526 + iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawTextInContextVertical+1),pData.DrawTextInContextVertical->length,aCmdData),
1.527 + BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContextVertical->pos,pData.DrawTextInContextVertical->up);
1.528 + }
1.529 + break;
1.530 + case EWsGcOpDrawTextInContextVerticalPtr:
1.531 + contextParam.iStart = pData.DrawTextInContextVerticalPtr->start;
1.532 + contextParam.iEnd = pData.DrawTextInContextVerticalPtr->end;
1.533 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.534 + {
1.535 + iGc->DrawTextVertical(*pData.DrawTextInContextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),
1.536 + pData.DrawTextInContextVerticalPtr->pos,pData.DrawTextInContextVerticalPtr->up);
1.537 + }
1.538 + break;
1.539 + case EWsGcOpDrawTextInContextVerticalPtr1:
1.540 + contextParam.iStart = pData.DrawTextInContextVerticalPtr->start;
1.541 + contextParam.iEnd = pData.DrawTextInContextVerticalPtr->end;
1.542 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.543 + {
1.544 + iGc->DrawTextVertical(*pData.DrawTextInContextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContextVerticalPtr->up);
1.545 + }
1.546 + break;
1.547 + case EWsGcOpDrawBoxTextInContextVertical:
1.548 + contextParam.iStart = pData.DrawBoxTextInContextVertical->start;
1.549 + contextParam.iEnd = pData.DrawBoxTextInContextVertical->end;
1.550 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.551 + {
1.552 + iGc->DrawTextVertical(BufferTPtr((TText *)(pData.DrawBoxTextInContextVertical+1),pData.DrawBoxTextInContextVertical->length,aCmdData),
1.553 + BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextInContextVertical->box,pData.DrawBoxTextInContextVertical->baselineOffset,
1.554 + pData.DrawBoxTextInContextVertical->up,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextInContextVertical->vert),pData.DrawBoxTextInContextVertical->margin);
1.555 + }
1.556 + break;
1.557 + case EWsGcOpDrawBoxTextInContextVerticalPtr:
1.558 + contextParam.iStart = pData.DrawBoxTextInContextVerticalPtr->start;
1.559 + contextParam.iEnd = pData.DrawBoxTextInContextVerticalPtr->end;
1.560 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.561 + {
1.562 + iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->baselineOffset
1.563 + ,pData.DrawBoxTextVerticalPtr->width,pData.DrawBoxTextVerticalPtr->up,BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawBoxTextVerticalPtr->vert),pData.DrawBoxTextVerticalPtr->margin);
1.564 + }
1.565 + break;
1.566 + case EWsGcOpDrawBoxTextInContextVerticalPtr1:
1.567 + contextParam.iStart = pData.DrawBoxTextInContextVerticalPtr->start;
1.568 + contextParam.iEnd = pData.DrawBoxTextInContextVerticalPtr->end;
1.569 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.570 + {
1.571 + iGc->DrawTextVertical(*pData.DrawBoxTextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawBoxTextVerticalPtr->box,pData.DrawBoxTextVerticalPtr->up);
1.572 + }
1.573 + break;
1.574 + case EWsGcOpDrawTextInContextLocal:
1.575 + contextParam.iStart = pData.DrawTextInContextLocal->start;
1.576 + contextParam.iEnd = pData.DrawTextInContextLocal->end;
1.577 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.578 + {
1.579 + iGc->DrawText(*pData.DrawTextInContextLocal->desc,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.DrawTextInContextLocal->pos);
1.580 + }
1.581 + break;
1.582 + case EWsGcOpDrawBoxTextInContextLocal:
1.583 + contextParam.iStart = pData.BoxTextInContextLocal->start;
1.584 + contextParam.iEnd = pData.BoxTextInContextLocal->end;
1.585 + if((contextParam.iStart < contextParam.iEnd) && (iGc->HasFont()))
1.586 + {
1.587 + iGc->DrawText(*pData.BoxTextInContextLocal->desc,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam),pData.BoxTextInContextLocal->box,pData.BoxTextInContextLocal->baselineOffset,
1.588 + BitGdiToMWsGraphicsContextMappings::Convert(pData.BoxTextInContextLocal->horiz),pData.BoxTextInContextLocal->leftMrg);
1.589 + }
1.590 + break;
1.591 + case EWsGcOpDrawLine:
1.592 + iGc->DrawLine(pData.DrawLine->pnt1,pData.DrawLine->pnt2);
1.593 + break;
1.594 + case EWsGcOpDrawTo:
1.595 + iGc->DrawLine(iLinePos,*pData.Point);
1.596 + break;
1.597 + case EWsGcOpDrawBy:
1.598 + iGc->DrawLine(iLinePos,iLinePos+(*pData.Point));
1.599 + break;
1.600 + case EWsGcOpPlot:
1.601 + iGc->Plot(*pData.Point);
1.602 + break;
1.603 + case EWsGcOpMoveTo:
1.604 + case EWsGcOpMoveBy:
1.605 + break;
1.606 + case EWsGcOpGdiBlt2Local:
1.607 + iGc->BitBlt(pData.GdiBlt2Local->pos,*pData.GdiBlt2Local->bitmap);
1.608 + break;
1.609 + case EWsGcOpGdiBlt3Local:
1.610 + iGc->BitBlt(pData.GdiBlt3Local->pos,*pData.GdiBlt3Local->bitmap, pData.GdiBlt3Local->rect);
1.611 + break;
1.612 + case EWsGcOpGdiBltMaskedLocal:
1.613 + iGc->BitBltMasked(pData.GdiBltMaskedLocal->pos,*pData.GdiBltMaskedLocal->bitmap,
1.614 + pData.GdiBltMaskedLocal->rect,*pData.GdiBltMaskedLocal->maskBitmap,
1.615 + pData.GdiBltMaskedLocal->invertMask);
1.616 + break;
1.617 + case EWsGcOpGdiWsBlt2:
1.618 + case EWsGcOpGdiWsBlt3:
1.619 + case EWsGcOpGdiWsBltMasked:
1.620 + case EWsGcOpGdiWsAlphaBlendBitmaps:
1.621 + case EWsGcOpWsDrawBitmapMasked:
1.622 + {
1.623 + CFbsBitmap* scratchBitmap = NULL;
1.624 + CFbsBitmap* scratchMaskBimap = NULL;
1.625 + TInt maskHandle=0;
1.626 + TInt handle=WsBitmapHandle(aOpcode,pData, maskHandle);
1.627 + CWsClient* owner=iWin->WsOwner();
1.628 + if (owner!=NULL)
1.629 + {
1.630 + TInt wsBmpErr = KErrNone;
1.631 + DWsBitmap *bitmap=(DWsBitmap *)owner->HandleToObj(handle, WS_HANDLE_BITMAP);
1.632 + if (!bitmap)
1.633 + wsBmpErr = KErrNotFound;
1.634 + else
1.635 + scratchBitmap=bitmap->FbsBitmap();
1.636 + if (wsBmpErr == KErrNone)
1.637 + if (aOpcode==EWsGcOpGdiWsBltMasked || aOpcode==EWsGcOpGdiWsAlphaBlendBitmaps || aOpcode==EWsGcOpWsDrawBitmapMasked)
1.638 + {
1.639 + DWsBitmap *bitmap2=(DWsBitmap *)owner->HandleToObj(maskHandle, WS_HANDLE_BITMAP);
1.640 + if (!bitmap2)
1.641 + wsBmpErr = KErrNotFound;
1.642 + else
1.643 + scratchMaskBimap=bitmap2->FbsBitmap();
1.644 + }
1.645 + if (wsBmpErr == KErrNone)
1.646 + {
1.647 + switch(aOpcode)
1.648 + {
1.649 + case EWsGcOpGdiWsBlt2:
1.650 + iGc->BitBlt(pData.GdiBlt2->pos,*scratchBitmap);
1.651 + break;
1.652 + case EWsGcOpGdiWsBlt3:
1.653 + iGc->BitBlt(pData.GdiBlt3->pos,*scratchBitmap, pData.GdiBlt3->rect);
1.654 + break;
1.655 + case EWsGcOpGdiWsBltMasked:
1.656 + {
1.657 + iGc->BitBltMasked(pData.GdiBltMasked->destination,*scratchBitmap,
1.658 + pData.GdiBltMasked->source, *scratchMaskBimap,
1.659 + pData.GdiBltMasked->invertMask);
1.660 + }
1.661 + break;
1.662 + case EWsGcOpGdiWsAlphaBlendBitmaps:
1.663 + {
1.664 + iGc->BitBltMasked(pData.AlphaBlendBitmaps->point,*scratchBitmap,
1.665 + pData.AlphaBlendBitmaps->source, *scratchMaskBimap,
1.666 + pData.AlphaBlendBitmaps->alphaPoint);
1.667 + }
1.668 + break;
1.669 + case EWsGcOpWsDrawBitmapMasked:
1.670 + {
1.671 + iGc->DrawBitmapMasked(pData.iBitmapMasked->iRect,*scratchBitmap,
1.672 + pData.iBitmapMasked->iSrcRect,*scratchMaskBimap,
1.673 + pData.iBitmapMasked->iInvertMask);
1.674 + }
1.675 + break;
1.676 + }
1.677 + }
1.678 + }
1.679 + break;
1.680 + }
1.681 + case EWsGcOpGdiBlt2:
1.682 + case EWsGcOpGdiBlt3:
1.683 + case EWsGcOpDrawBitmap:
1.684 + case EWsGcOpDrawBitmap2:
1.685 + case EWsGcOpDrawBitmap3:
1.686 + {
1.687 + TInt bitmapMaskHandle=0;
1.688 + TInt bitmapHandle = FbsBitmapHandle(aOpcode, pData, bitmapMaskHandle);
1.689 + const CFbsBitmap* bitmap = iWin->Redraw()->BitmapFromHandle(bitmapHandle);
1.690 + if(!bitmap)
1.691 + {
1.692 + WS_PANIC_DEBUG(EWsPanicBitmapNotFound);
1.693 + break;
1.694 + }
1.695 +
1.696 + switch(aOpcode)
1.697 + {
1.698 + case EWsGcOpGdiBlt2:
1.699 + iGc->BitBlt(pData.GdiBlt2->pos,*bitmap);
1.700 + break;
1.701 + case EWsGcOpGdiBlt3:
1.702 + iGc->BitBlt(pData.GdiBlt3->pos,*bitmap, pData.GdiBlt3->rect);
1.703 + break;
1.704 + case EWsGcOpDrawBitmap:
1.705 + {
1.706 + // DrawBitmap(TPoint&, ) uses the size of the bitmap in twips, but
1.707 + // MWsGraphicsContext::DrawBitmap() takes a TRect in pixels, so we need to convert
1.708 + TRect destRect(iWin->Screen()->DeviceMap().TwipsToPixels(bitmap->SizeInTwips()));
1.709 + destRect.Move(pData.Bitmap->pos); //pos is defined in pixels, that's why we're not converting it
1.710 + iGc->DrawBitmap(destRect, *bitmap);
1.711 + break;
1.712 + }
1.713 + case EWsGcOpDrawBitmap2:
1.714 + iGc->DrawBitmap(pData.Bitmap2->rect, *bitmap);
1.715 + break;
1.716 + case EWsGcOpDrawBitmap3:
1.717 + iGc->DrawBitmap(pData.Bitmap3->rect, *bitmap, pData.Bitmap3->srcRect);
1.718 + break;
1.719 + }
1.720 + break;
1.721 + }
1.722 + case EWsGcOpGdiBltMasked:
1.723 + case EWsGcOpGdiAlphaBlendBitmaps:
1.724 + case EWsGcOpDrawBitmapMasked:
1.725 + {
1.726 + TInt bitmapMaskHandle=0;
1.727 + TInt bitmapHandle = FbsBitmapHandle(aOpcode, pData, bitmapMaskHandle);
1.728 + const CFbsBitmap* bitmap = iWin->Redraw()->BitmapFromHandle(bitmapHandle);
1.729 + if(!bitmap)
1.730 + {
1.731 + WS_PANIC_DEBUG(EWsPanicBitmapNotFound);
1.732 + break;
1.733 + }
1.734 +
1.735 + CFbsBitmap* bitmapMask = iWin->Redraw()->BitmapFromHandle(bitmapMaskHandle);
1.736 + if(!bitmapMask)
1.737 + {
1.738 + WS_PANIC_DEBUG(EWsPanicBitmapNotFound);
1.739 + break;
1.740 + }
1.741 +
1.742 + switch(aOpcode)
1.743 + {
1.744 + case EWsGcOpGdiBltMasked:
1.745 + {
1.746 + iGc->BitBltMasked(pData.GdiBltMasked->destination,*bitmap,
1.747 + pData.GdiBltMasked->source, *bitmapMask,
1.748 + pData.GdiBltMasked->invertMask);
1.749 + break;
1.750 + }
1.751 + case EWsGcOpGdiAlphaBlendBitmaps:
1.752 + {
1.753 + iGc->BitBltMasked(pData.AlphaBlendBitmaps->point, *bitmap,
1.754 + pData.AlphaBlendBitmaps->source, *bitmapMask,
1.755 + pData.AlphaBlendBitmaps->alphaPoint);
1.756 + break;
1.757 + }
1.758 + case EWsGcOpDrawBitmapMasked:
1.759 + {
1.760 + iGc->DrawBitmapMasked(pData.iBitmapMasked->iRect, *bitmap,
1.761 + pData.iBitmapMasked->iSrcRect, *bitmapMask,
1.762 + pData.iBitmapMasked->iInvertMask);
1.763 + break;
1.764 + }
1.765 + }
1.766 + break;
1.767 + }
1.768 + case EWsGcOpDrawSegmentedPolygon:
1.769 + {
1.770 + TArrayWrapper<TPoint> points(iPolyPoints, iPolyPointListSize);
1.771 + iGc->DrawPolygon(points, BitGdiToMWsGraphicsContextMappings::Convert(pData.DrawSegmentedPolygon->fillRule));
1.772 + break;
1.773 + }
1.774 + case EWsGcOpDrawPolygon:
1.775 + DoDrawPolygon(pData.Polygon);
1.776 + break;
1.777 + case EWsGcOpDrawPolyLine:
1.778 + DoDrawPolyLine(pData.PolyLine, EFalse);
1.779 + break;
1.780 + case EWsGcOpDrawPolyLineContinued:
1.781 + DoDrawPolyLine(pData.PolyLine, ETrue);
1.782 + break;
1.783 + case EWsGcOpClear:
1.784 + iGc->Clear(TRect(iWin->Size()));
1.785 + break;
1.786 + case EWsGcOpClearRect:
1.787 + iGc->Clear(*pData.Rect);
1.788 + break;
1.789 + case EWsGcOpDrawRect:
1.790 + iGc->DrawRect(*pData.Rect);
1.791 + break;
1.792 + case EWsGcOpDrawEllipse:
1.793 + iGc->DrawEllipse(*pData.Rect);
1.794 + break;
1.795 + case EWsGcOpDrawRoundRect:
1.796 + iGc->DrawRoundRect(*pData.Rect,pData.RoundRect->ellipse);
1.797 + break;
1.798 + case EWsGcOpDrawArc:
1.799 + iGc->DrawArc(*pData.Rect,pData.ArcOrPie->start,pData.ArcOrPie->end);
1.800 + break;
1.801 + case EWsGcOpDrawPie:
1.802 + iGc->DrawPie(*pData.Rect,pData.ArcOrPie->start,pData.ArcOrPie->end);
1.803 + break;
1.804 + case EWsGcOpCopyRect:
1.805 + iGc->CopyRect(pData.CopyRect->pos,*pData.Rect);
1.806 + break;
1.807 + case EWsGcOpMapColors:
1.808 + GcOwnerPanic(EWservPanicOpcode); //deprecated, the client should never generate this op
1.809 + break;
1.810 + case EWsGcOpSetShadowColor:
1.811 + iGc->SetTextShadowColor(*pData.rgb);
1.812 + break;
1.813 + case EWsGcOpDrawResourceToPos:
1.814 + case EWsGcOpDrawResourceToRect:
1.815 + case EWsGcOpDrawResourceFromRectToRect:
1.816 + case EWsGcOpDrawResourceWithData:
1.817 + DoDrawResource(aOpcode, pData);
1.818 + break;
1.819 + default:
1.820 + TRAP_IGNORE(iWin->OwnerPanic(EWservPanicOpcode));
1.821 + break;
1.822 + }
1.823 + iGc->ResetClippingRegion();
1.824 + iCurrentClippingRegion = NULL;
1.825 + if (bGcDrawingOccurred)
1.826 + {
1.827 + GcDrawingDone(); //up the count (again for CRPs)
1.828 + }
1.829 + }
1.830 +/**
1.831 + Helper function for drawing resources.
1.832 + It extracts DWsDrawableSource objects which corresponds RWsDrawableResource object on the server side and then redirect call to concrete implementation.
1.833 + @param aOpcode GC opcodes
1.834 + @param aData An extra data which will be used for resource drawing
1.835 + */
1.836 +void CPlaybackGc::DoDrawResource(TWsGcOpcodes aOpcode, const TWsGcCmdUnion &aData)
1.837 + {
1.838 + CWsClient* owner=iWin->WsOwner(); // We can't just use iWsOwner - it can be null for stored commands
1.839 + if (owner!=NULL)
1.840 + {
1.841 + CWsDrawableSource *drawable = static_cast<CWsDrawableSource*>(owner->HandleToObj(*aData.Int, WS_HANDLE_DRAWABLE_SOURCE));
1.842 + if (!drawable)
1.843 + return;
1.844 +
1.845 + switch(aOpcode)
1.846 + {
1.847 + case EWsGcOpDrawResourceToPos:
1.848 + drawable->DrawResource(iGc, aData.DrawWsResourceToPos->pos, aData.DrawWsResourceToPos->rotation);
1.849 + break;
1.850 + case EWsGcOpDrawResourceToRect:
1.851 + drawable->DrawResource(iGc, aData.DrawWsResourceToRect->rect, aData.DrawWsResourceToRect->rotation);
1.852 + break;
1.853 + case EWsGcOpDrawResourceFromRectToRect:
1.854 + drawable->DrawResource(iGc, aData.DrawWsResourceFromRectToRect->rectDest, aData.DrawWsResourceFromRectToRect->rectSrc, aData.DrawWsResourceFromRectToRect->rotation);
1.855 + break;
1.856 + case EWsGcOpDrawResourceWithData:
1.857 + drawable->DrawResource(iGc, aData.DrawWsResourceWithData->rect, *aData.DrawWsResourceWithData->desc);
1.858 + break;
1.859 + default:
1.860 + break;
1.861 + }
1.862 + }
1.863 + }
1.864 +
1.865 +TInt CPlaybackGc::WsBitmapHandle(TInt aOpcode, const TWsGcCmdUnion &pData, TInt& aMaskHandle)
1.866 + {
1.867 + TInt handle=0;
1.868 + switch(aOpcode)
1.869 + {
1.870 + case EWsGcOpGdiWsBlt2:
1.871 + handle=pData.GdiBlt2->handle;
1.872 + break;
1.873 + case EWsGcOpGdiWsBlt3:
1.874 + handle=pData.GdiBlt3->handle;
1.875 + break;
1.876 + case EWsGcOpGdiWsBltMasked:
1.877 + handle=pData.GdiBltMasked->handle;
1.878 + aMaskHandle = pData.GdiBltMasked->maskHandle;
1.879 + break;
1.880 + case EWsGcOpGdiWsAlphaBlendBitmaps:
1.881 + handle=pData.AlphaBlendBitmaps->bitmapHandle;
1.882 + aMaskHandle = pData.AlphaBlendBitmaps->alphaHandle;
1.883 + break;
1.884 + case EWsGcOpWsDrawBitmapMasked:
1.885 + handle=pData.iBitmapMasked->iHandle;
1.886 + aMaskHandle=pData.iBitmapMasked->iMaskHandle;
1.887 + break;
1.888 + }
1.889 + return handle;
1.890 + }
1.891 +
1.892 +TInt CPlaybackGc::FbsBitmapHandle(TInt aOpcode, const TWsGcCmdUnion &pData, TInt& aMaskHandle)
1.893 + {
1.894 + TInt handle=0;
1.895 + aMaskHandle=0;
1.896 + switch(aOpcode)
1.897 + {
1.898 + case EWsGcOpGdiBlt2:
1.899 + handle=pData.GdiBlt2->handle;
1.900 + break;
1.901 + case EWsGcOpGdiBlt3:
1.902 + handle=pData.GdiBlt3->handle;
1.903 + break;
1.904 + case EWsGcOpGdiBltMasked:
1.905 + handle=pData.GdiBltMasked->handle;
1.906 + aMaskHandle=pData.GdiBltMasked->maskHandle;
1.907 + break;
1.908 + case EWsGcOpGdiAlphaBlendBitmaps:
1.909 + handle=pData.AlphaBlendBitmaps->bitmapHandle;
1.910 + aMaskHandle=pData.AlphaBlendBitmaps->alphaHandle;
1.911 + break;
1.912 + case EWsGcOpDrawBitmap:
1.913 + handle=pData.Bitmap->handle;
1.914 + break;
1.915 + case EWsGcOpDrawBitmap2:
1.916 + handle=pData.Bitmap2->handle;
1.917 + break;
1.918 + case EWsGcOpDrawBitmap3:
1.919 + handle=pData.Bitmap3->handle;
1.920 + break;
1.921 + case EWsGcOpDrawBitmapMasked:
1.922 + handle=pData.iBitmapMasked->iHandle;
1.923 + aMaskHandle=pData.iBitmapMasked->iMaskHandle;
1.924 + break;
1.925 + default:
1.926 + WS_ASSERT_DEBUG(EFalse, EWsPanicInvalidOperation);
1.927 + break;
1.928 + }
1.929 + return handle;
1.930 + }
1.931 +
1.932 +void CPlaybackGc::UpdateJustification(TText* aText,TInt aLen,const TDesC8& aCmdData,CGraphicsContext::TTextParameters* aParam)
1.933 + {
1.934 + iGc->UpdateJustification(BufferTPtr(aText,aLen,aCmdData), BitGdiToMWsGraphicsContextMappings::Convert(aParam));
1.935 + }
1.936 +
1.937 +void CPlaybackGc::SendOriginIfRequired()
1.938 + {
1.939 + const TPoint currentOrigin(iMasterOrigin + iOrigin);
1.940 + if (iSendOrigin || currentOrigin != iLastSentOrigin)
1.941 + {
1.942 + iGc->SetOrigin(currentOrigin);
1.943 + iLastSentOrigin = currentOrigin;
1.944 + iSendOrigin = EFalse;
1.945 + }
1.946 + }
1.947 +
1.948 +void CPlaybackGc::SendClippingRegionIfRequired(const TRegion* aRegion)
1.949 + {
1.950 + if (iUserDefinedClippingRegion || iClippingRectSet || !iWin->Screen()->ChangeTracking())
1.951 + {
1.952 + iGc->SetClippingRegion(*aRegion);
1.953 + }
1.954 + }
1.955 +
1.956 +void CPlaybackGc::DoDrawing(TWsGcOpcodes aOpcode, const TDesC8& aCmdData)
1.957 + {
1.958 + TWsGcCmdUnion pData;
1.959 + // coverity[returned_pointer]
1.960 + pData.any=aCmdData.Ptr();
1.961 +
1.962 + iIntersectedRegion.Clear();
1.963 + iIntersectedRegion.Copy(*iDrawRegion);
1.964 +
1.965 + if (iClippingRectSet)
1.966 + {
1.967 + // MWsGraphicsContext doesn't provide a SetClippingRect API. If a client calls SetClippingRect
1.968 + // the rect is passed to the render stage using MWsGraphicsContext::SetClippingRegion
1.969 + TRect clippingRectRelativeToScreen(iClippingRect);
1.970 + clippingRectRelativeToScreen.Move(iMasterOrigin);
1.971 + iIntersectedRegion.ClipRect(clippingRectRelativeToScreen);
1.972 + iIntersectedRegion.ClipRect(iWin->AbsRect());
1.973 + }
1.974 +
1.975 + SendOriginIfRequired();
1.976 +
1.977 + DoDrawCommand(aOpcode,aCmdData,&iIntersectedRegion);
1.978 +
1.979 + CGraphicsContext::TTextParameters contextParam;
1.980 + switch(aOpcode)
1.981 + {
1.982 + case EWsGcOpDrawLine:
1.983 + iLinePos=pData.DrawLine->pnt2;
1.984 + break;
1.985 + case EWsGcOpDrawTo:
1.986 + case EWsGcOpMoveTo:
1.987 + case EWsGcOpPlot:
1.988 + iLinePos=(*pData.Point);
1.989 + break;
1.990 + case EWsGcOpDrawBy:
1.991 + case EWsGcOpMoveBy:
1.992 + iLinePos+=(*pData.Point);
1.993 + break;
1.994 + case EWsGcOpDrawSegmentedPolygon:
1.995 + EndSegmentedPolygon();
1.996 + break;
1.997 + case EWsGcOpDrawText:
1.998 + UpdateJustification((TText *)(pData.DrawText+1),pData.DrawText->length,aCmdData,NULL);
1.999 + break;
1.1000 + case EWsGcOpDrawTextVertical:
1.1001 + UpdateJustification((TText *)(pData.DrawTextVertical+1),pData.DrawTextVertical->length,aCmdData,NULL);
1.1002 + break;
1.1003 + case EWsGcOpDrawBoxText:
1.1004 + UpdateJustification((TText *)(pData.BoxText+1),pData.BoxText->length,aCmdData,NULL);
1.1005 + break;
1.1006 + case EWsGcOpDrawBoxTextOptimised1:
1.1007 + UpdateJustification((TText *)(pData.BoxTextO1+1),pData.BoxTextO1->length,aCmdData,NULL);
1.1008 + break;
1.1009 + case EWsGcOpDrawBoxTextOptimised2:
1.1010 + UpdateJustification((TText *)(pData.BoxTextO2+1),pData.BoxTextO2->length,aCmdData,NULL);
1.1011 + break;
1.1012 + case EWsGcOpDrawBoxTextVertical:
1.1013 + UpdateJustification((TText *)(pData.DrawBoxTextVertical+1),pData.DrawBoxTextVertical->length,aCmdData,NULL);
1.1014 + break;
1.1015 + case EWsGcOpDrawTextLocal:
1.1016 + iGc->UpdateJustification(*pData.DrawTextLocal->desc,NULL);
1.1017 + break;
1.1018 + case EWsGcOpDrawBoxTextLocal:
1.1019 + iGc->UpdateJustification(*pData.BoxTextLocal->desc,NULL);
1.1020 + break;
1.1021 + case EWsGcOpDrawTextPtr:
1.1022 + iGc->UpdateJustification(*pData.DrawTextPtr->text,NULL);
1.1023 + break;
1.1024 + case EWsGcOpDrawTextVerticalPtr:
1.1025 + iGc->UpdateJustification(*pData.DrawTextVerticalPtr->text,NULL);
1.1026 + break;
1.1027 + case EWsGcOpDrawBoxTextPtr:
1.1028 + iGc->UpdateJustification(*pData.DrawBoxTextPtr->text,NULL);
1.1029 + break;
1.1030 + case EWsGcOpDrawBoxTextVerticalPtr:
1.1031 + iGc->UpdateJustification(*pData.DrawBoxTextVerticalPtr->text,NULL);
1.1032 + break;
1.1033 + /***************DrawTextInContext*****************************************************************/
1.1034 + case EWsGcOpDrawTextInContext:
1.1035 + contextParam.iStart = pData.DrawTextInContext->start;
1.1036 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1037 + if(contextParam.iStart < contextParam.iEnd)
1.1038 + {
1.1039 + UpdateJustification((TText *)(pData.DrawTextInContext+1),pData.DrawTextInContext->length,aCmdData,&contextParam);
1.1040 + }
1.1041 + break;
1.1042 + case EWsGcOpDrawTextInContextVertical:
1.1043 + contextParam.iStart = pData.DrawTextInContext->start;
1.1044 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1045 + if(contextParam.iStart < contextParam.iEnd)
1.1046 + {
1.1047 + UpdateJustification((TText *)(pData.DrawTextInContextVertical+1),pData.DrawTextInContextVertical->length,aCmdData,&contextParam);
1.1048 + }
1.1049 + break;
1.1050 + case EWsGcOpDrawBoxTextInContext:
1.1051 + contextParam.iStart = pData.DrawTextInContext->start;
1.1052 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1053 + if(contextParam.iStart < contextParam.iEnd)
1.1054 + {
1.1055 + UpdateJustification((TText *)(pData.BoxTextInContext+1),pData.BoxTextInContext->length,aCmdData,&contextParam);
1.1056 + }
1.1057 + break;
1.1058 + case EWsGcOpDrawBoxTextInContextOptimised1:
1.1059 + contextParam.iStart = pData.DrawTextInContext->start;
1.1060 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1061 + if(contextParam.iStart < contextParam.iEnd)
1.1062 + {
1.1063 + UpdateJustification((TText *)(pData.BoxTextInContextO1+1),pData.BoxTextInContextO1->length,aCmdData,&contextParam);
1.1064 + }
1.1065 + break;
1.1066 + case EWsGcOpDrawBoxTextInContextOptimised2:
1.1067 + contextParam.iStart = pData.DrawTextInContext->start;
1.1068 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1069 + if(contextParam.iStart < contextParam.iEnd)
1.1070 + {
1.1071 + UpdateJustification((TText *)(pData.BoxTextInContextO2+1),pData.BoxTextInContextO2->length,aCmdData,&contextParam);
1.1072 + }
1.1073 + break;
1.1074 + case EWsGcOpDrawBoxTextInContextVertical:
1.1075 + contextParam.iStart = pData.DrawTextInContext->start;
1.1076 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1077 + if(contextParam.iStart < contextParam.iEnd)
1.1078 + {
1.1079 + UpdateJustification((TText *)(pData.DrawBoxTextInContextVertical+1),pData.DrawBoxTextInContextVertical->length,aCmdData,&contextParam);
1.1080 + }
1.1081 + break;
1.1082 + case EWsGcOpDrawTextInContextLocal:
1.1083 + contextParam.iStart = pData.DrawTextInContext->start;
1.1084 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1085 + if(contextParam.iStart < contextParam.iEnd)
1.1086 + {
1.1087 + iGc->UpdateJustification(*pData.DrawTextInContextLocal->desc,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
1.1088 + }
1.1089 + break;
1.1090 + case EWsGcOpDrawBoxTextInContextLocal:
1.1091 + contextParam.iStart = pData.DrawTextInContext->start;
1.1092 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1093 + if(contextParam.iStart < contextParam.iEnd)
1.1094 + {
1.1095 + iGc->UpdateJustification(*pData.BoxTextInContextLocal->desc,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
1.1096 + }
1.1097 + break;
1.1098 + case EWsGcOpDrawTextInContextPtr:
1.1099 + contextParam.iStart = pData.DrawTextInContext->start;
1.1100 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1101 + if(contextParam.iStart < contextParam.iEnd)
1.1102 + {
1.1103 + iGc->UpdateJustification(*pData.DrawTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
1.1104 + }
1.1105 + break;
1.1106 + case EWsGcOpDrawTextInContextVerticalPtr:
1.1107 + contextParam.iStart = pData.DrawTextInContext->start;
1.1108 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1109 + if(contextParam.iStart < contextParam.iEnd)
1.1110 + {
1.1111 + iGc->UpdateJustification(*pData.DrawTextInContextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
1.1112 + }
1.1113 + break;
1.1114 + case EWsGcOpDrawBoxTextInContextPtr:
1.1115 + contextParam.iStart = pData.DrawTextInContext->start;
1.1116 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1117 + if(contextParam.iStart < contextParam.iEnd)
1.1118 + {
1.1119 + iGc->UpdateJustification(*pData.DrawBoxTextInContextPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
1.1120 + }
1.1121 + break;
1.1122 + case EWsGcOpDrawBoxTextInContextVerticalPtr:
1.1123 + contextParam.iStart = pData.DrawTextInContext->start;
1.1124 + contextParam.iEnd = pData.DrawTextInContext->end;
1.1125 + if(contextParam.iStart < contextParam.iEnd)
1.1126 + {
1.1127 + iGc->UpdateJustification(*pData.DrawBoxTextInContextVerticalPtr->text,BitGdiToMWsGraphicsContextMappings::Convert(&contextParam));
1.1128 + }
1.1129 + break;
1.1130 + }
1.1131 + }
1.1132 +
1.1133 +void CPlaybackGc::CommandL(TWsGcOpcodes aOpcode, const TDesC8& aCmdData)
1.1134 + {
1.1135 + WS_ASSERT_DEBUG(iWin,EWsPanicWindowNull);
1.1136 + TWsGcCmdUnion pData;
1.1137 + // coverity[returned_pointer]
1.1138 + pData.any=aCmdData.Ptr();
1.1139 +
1.1140 + switch(aOpcode)
1.1141 + {
1.1142 + case EWsGcOpStartSegmentedDrawPolygon:
1.1143 + StartSegmentedDrawPolygonL(pData.StartSegmentedDrawPolygon);
1.1144 + break;
1.1145 + case EWsGcOpSegmentedDrawPolygonData:
1.1146 + SegmentedDrawPolygonData(pData.SegmentedDrawPolygonData);
1.1147 + break;
1.1148 + case EWsGcOpSetClippingRegion:
1.1149 + WS_ASSERT_DEBUG(aOpcode != EWsGcOpSetClippingRegion, EWsPanicDrawCommandsInvalidState);
1.1150 + break;
1.1151 + case EWsGcOpSetClippingRect:
1.1152 + SetClippingRect(*pData.Rect);
1.1153 + break;
1.1154 + case EWsGcOpCancelClippingRect:
1.1155 + ResetClippingRect();
1.1156 + break;
1.1157 + case EWsGcOpCancelClippingRegion:
1.1158 + CancelUserClippingRegion();
1.1159 + break;
1.1160 + case EWsGcOpSetFaded: // deprecated
1.1161 + // do nothing
1.1162 + break;
1.1163 + case EWsGcOpSetFadeParams: // deprecated
1.1164 + // do nothing
1.1165 + break;
1.1166 + case EWsGcOpSetDrawMode:
1.1167 + iGc->SetDrawMode(BitGdiToMWsGraphicsContextMappings::LossyConvert((CGraphicsContext::TDrawMode)*pData.UInt));
1.1168 + break;
1.1169 + case EWsGcOpUseFont:
1.1170 + if (CWsFontCache::Instance()->UseFont(iFont, *pData.UInt))
1.1171 + {
1.1172 + CFbsBitGcFont font;
1.1173 + if(font.Duplicate(*pData.UInt) == KErrNone)
1.1174 + iGc->SetFont(&font);
1.1175 + font.Reset();
1.1176 + }
1.1177 + else
1.1178 + iGc->SetFontNoDuplicate(iFont);
1.1179 + break;
1.1180 + case EWsGcOpDiscardFont:
1.1181 + CWsFontCache::Instance()->ReleaseFont(iFont);
1.1182 + iGc->ResetFont();
1.1183 + break;
1.1184 + case EWsGcOpSetUnderlineStyle:
1.1185 + iGc->SetUnderlineStyle(BitGdiToMWsGraphicsContextMappings::Convert(*pData.SetUnderlineStyle));
1.1186 + break;
1.1187 + case EWsGcOpSetStrikethroughStyle:
1.1188 + iGc->SetStrikethroughStyle(BitGdiToMWsGraphicsContextMappings::Convert(*pData.SetStrikethroughStyle));
1.1189 + break;
1.1190 + case EWsGcOpUseBrushPattern:
1.1191 + iGc->SetBrushPattern(*pData.handle);
1.1192 + break;
1.1193 + case EWsGcOpDiscardBrushPattern:
1.1194 + iGc->ResetBrushPattern();
1.1195 + break;
1.1196 + case EWsGcOpSetBrushColor:
1.1197 + iGc->SetBrushColor(*pData.rgb);
1.1198 + break;
1.1199 + case EWsGcOpSetPenColor:
1.1200 + iGc->SetPenColor(*pData.rgb);
1.1201 + break;
1.1202 + case EWsGcOpSetPenStyle:
1.1203 + iGc->SetPenStyle(BitGdiToMWsGraphicsContextMappings::Convert((CGraphicsContext::TPenStyle)*pData.UInt));
1.1204 + break;
1.1205 + case EWsGcOpSetPenSize:
1.1206 + iGc->SetPenSize(*pData.Size);
1.1207 + break;
1.1208 + case EWsGcOpSetBrushStyle:
1.1209 + {
1.1210 + MWsGraphicsContext::TBrushStyle style = BitGdiToMWsGraphicsContextMappings::Convert((CGraphicsContext::TBrushStyle)*pData.UInt);
1.1211 + if (iGc->HasBrushPattern() || style != MWsGraphicsContext::EPatternedBrush)
1.1212 + {
1.1213 + iGc->SetBrushStyle(style);
1.1214 + }
1.1215 + break;
1.1216 + }
1.1217 + case EWsGcOpReset:
1.1218 + CWsFontCache::Instance()->ReleaseFont(iFont);
1.1219 + iGc->Reset();
1.1220 + iOrigin.SetXY(0,0);
1.1221 + iSendOrigin = ETrue; // we must call SetOrigin at next opportunity because it's likely the render stage implementation of Reset (when resetting origin) doesn't take into account the window origin
1.1222 + ResetClippingRect();
1.1223 + iGc->SetBrushColor(iWin->BackColor());
1.1224 + break;
1.1225 + case EWsGcOpSetBrushOrigin:
1.1226 + iGc->SetBrushOrigin(*pData.Point);
1.1227 + break;
1.1228 + case EWsGcOpSetDitherOrigin:
1.1229 + GcOwnerPanic(EWservPanicOpcode); //deprecated, the client should never generate this op
1.1230 + break;
1.1231 + case EWsGcOpSetWordJustification:
1.1232 + iGc->SetWordJustification(pData.SetJustification->excessWidth, pData.SetJustification->numGaps);
1.1233 + break;
1.1234 + case EWsGcOpSetCharJustification:
1.1235 + iGc->SetCharJustification(pData.SetJustification->excessWidth, pData.SetJustification->numGaps);
1.1236 + break;
1.1237 + case EWsGcOpSetOrigin:
1.1238 + SetOrigin(*pData.Point);
1.1239 + break;
1.1240 + case EWsGcOpSetOpaque: // deprecated
1.1241 + // do nothing
1.1242 + break;
1.1243 + default: // Assume remaining functions will draw
1.1244 + {
1.1245 + DoDrawing(aOpcode,aCmdData);
1.1246 + return;
1.1247 + }
1.1248 + }
1.1249 + }
1.1250 +
1.1251 +
1.1252 +void CPlaybackGc::SetOrigin(const TPoint &aOrigin)
1.1253 + {
1.1254 + iOrigin=aOrigin;
1.1255 + }
1.1256 +
1.1257 +/*------------------------------------------------------------------------------
1.1258 + Description: Retrieves graphics context information back from a given buffer
1.1259 + from a given start position.
1.1260 + -----------------------------------------------------------------------------*/
1.1261 +void CPlaybackGc::InternalizeL(const CBufBase& aBuffer,TInt& aStartPos)
1.1262 + {
1.1263 + // Open the stream used for the input from the given start position
1.1264 + // in the buffer.
1.1265 + RBufReadStream bufReadStream;
1.1266 + bufReadStream.Open(aBuffer,aStartPos);
1.1267 + CleanupClosePushL(bufReadStream);
1.1268 +
1.1269 + // Read the font/bitmap server data
1.1270 + TInternalGcStatus::InternalizeGcAttributesL(iGc, bufReadStream);
1.1271 +
1.1272 + iOrigin.iX = bufReadStream.ReadInt32L();
1.1273 + iOrigin.iY = bufReadStream.ReadInt32L();
1.1274 + iSendOrigin = ETrue;
1.1275 +
1.1276 + iClippingRectSet=bufReadStream.ReadInt8L();
1.1277 +
1.1278 + // If there is a clipping rectangle data read it.
1.1279 + if (iClippingRectSet)
1.1280 + bufReadStream>>iClippingRect;
1.1281 +
1.1282 + // Read the clipping region data
1.1283 + InternalizeClippingRegionL(bufReadStream);
1.1284 +
1.1285 + // Read the Alpha values for Brush and Pen colors.
1.1286 + InternalizeAlphaValueL(bufReadStream);
1.1287 +
1.1288 + CleanupStack::PopAndDestroy(&bufReadStream);
1.1289 + }
1.1290 +
1.1291 +/*------------------------------------------------------------------------------
1.1292 + Description: Retrieves TRgb::alpha value information back from a given buffer
1.1293 + and updates the Brushcolor with the same.
1.1294 + -----------------------------------------------------------------------------*/
1.1295 +void CPlaybackGc::InternalizeAlphaValueL(RReadStream& aReadStream)
1.1296 + {
1.1297 + TRgb brushColor(iGc->BrushColor());
1.1298 + brushColor.SetAlpha(aReadStream.ReadUint8L());
1.1299 + iGc->SetBrushColor(brushColor);
1.1300 + TRgb penColor(iGc->PenColor());
1.1301 + penColor.SetAlpha(aReadStream.ReadUint8L());
1.1302 + iGc->SetPenColor(penColor);
1.1303 + }
1.1304 +
1.1305 +/*------------------------------------------------------------------------------
1.1306 + Description: Helper method to retrieve clipping region data from a given
1.1307 + read stream.
1.1308 + -----------------------------------------------------------------------------*/
1.1309 +void CPlaybackGc::InternalizeClippingRegionL(RReadStream& aReadStream)
1.1310 + {
1.1311 + WS_ASSERT_DEBUG(iTargetRegion, EWsPanicDrawCommandsInvalidState);
1.1312 + // Read flag to indicate if client had defined a clipping region
1.1313 + TBool clipRegion = aReadStream.ReadInt8L();
1.1314 + CancelUserClippingRegion();
1.1315 + if (clipRegion)
1.1316 + {
1.1317 + // Note that this clipping region is in window relative coordinates when
1.1318 + // received from the client (and being stored) but is in screen relative
1.1319 + // coordinates after being retrieved from the redraw store.
1.1320 + iUserDefinedClippingRegion = InternalizeRegionL(aReadStream);
1.1321 + iUserDefinedClippingRegion->Offset(iWin->Origin());
1.1322 + iUserDefinedClippingRegion->Intersect(*iTargetRegion);
1.1323 + if (iUserDefinedClippingRegion->CheckError()) // fallback to no user clipping region
1.1324 + {
1.1325 + CancelUserClippingRegion();
1.1326 + }
1.1327 + else
1.1328 + {
1.1329 + iDrawRegion = iUserDefinedClippingRegion;
1.1330 + }
1.1331 + }
1.1332 + }
1.1333 +
1.1334 +/**
1.1335 +* @deprecated
1.1336 +*/
1.1337 +TInt CPlaybackGc::PlaceSurface(const TSurfaceConfiguration& /*aConfig*/)
1.1338 + {
1.1339 + return KErrNotSupported;
1.1340 + }
1.1341 +
1.1342 +/** Get the drawing occurred indication counter.
1.1343 + Callers can detect if drawing has occurred between two points
1.1344 + by detecting that this count has changed.
1.1345 + Note that the changed value does not necessarily represent the exact number of operations which occurred.
1.1346 + @return value which changes each time GC drawing occurrs.
1.1347 + **/
1.1348 +TInt CPlaybackGc::GcDrawingCount()
1.1349 + {
1.1350 + return iGcDrawingCounter;
1.1351 + }
1.1352 +
1.1353 +/** Update the drawing occurred indication counter.
1.1354 + Called internally each time a drawing operation updates the UI content
1.1355 + **/
1.1356 +void CPlaybackGc::GcDrawingDone()
1.1357 + {
1.1358 + iGcDrawingCounter++;
1.1359 + }
1.1360 +
1.1361 +
1.1362 +/**
1.1363 +This pretty much replaces the whole of what was TDrawDestination
1.1364 +This can only be sensibly called from outside a sequence of drawing commands,
1.1365 +since it negates any user defined clipping regions.
1.1366 +*/
1.1367 +void CPlaybackGc::SetTargetRegion(const TRegion* aRegion)
1.1368 + {
1.1369 + iTargetRegion = aRegion;
1.1370 + iDrawRegion = iTargetRegion;
1.1371 + CancelUserClippingRegion();
1.1372 + }
1.1373 +
1.1374 +void CPlaybackGc::Reset()
1.1375 + {
1.1376 + iGc->Reset();
1.1377 + }
1.1378 +
1.1379 +TAny * CPlaybackGc::ResolveObjectInterface(TUint aId)
1.1380 + {
1.1381 + switch (aId)
1.1382 + {
1.1383 + case MWsSurfacePlacement::EWsObjectInterfaceId:
1.1384 + return static_cast<MWsSurfacePlacement *>(this); //deprecated
1.1385 + case MWsWindow::EWsObjectInterfaceId:
1.1386 + return dynamic_cast<MWsWindow *>(iWin);
1.1387 + case MWsGraphicsContext::EWsObjectInterfaceId:
1.1388 + return static_cast<MWsGraphicsContext*>(iGc);
1.1389 + case MWsUiBuffer::EWsObjectInterfaceId:
1.1390 + case MWsFader::EWsObjectInterfaceId:
1.1391 + return iWin->Screen()->ResolveObjectInterface(aId);
1.1392 + }
1.1393 + return NULL;
1.1394 + }