|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <graphics/remotegc.h> |
|
17 #include <graphics/commandbuffer.h> |
|
18 #include <graphics/wsdrawresource.h> |
|
19 #include <graphics/gdi/gdiconsts.h> |
|
20 #include <graphics/gdi/gdistructs.h> |
|
21 #include "graphics/windowserverconstants.h" |
|
22 |
|
23 #define KDefaultShadowColor KRgbGray |
|
24 |
|
25 class CRemoteGc::CPimpl : public CBase, public MWsDrawResource |
|
26 { |
|
27 public: |
|
28 CPimpl(CRemoteGc& aGc) : iGc(aGc) {} |
|
29 public: //from MWsDrawResource |
|
30 void DrawResource(const TPoint& aPos, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation=CWindowGc::EGraphicsRotationNone) |
|
31 { |
|
32 iGc.DrawResource(aPos, aSource, aRotation); |
|
33 } |
|
34 void DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation=CWindowGc::EGraphicsRotationNone) |
|
35 { |
|
36 iGc.DrawResource(aDestRect, aSource, aRotation); |
|
37 } |
|
38 void DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TRect& aSrcRect, CWindowGc::TGraphicsRotation aRotation=CWindowGc::EGraphicsRotationNone) |
|
39 { |
|
40 iGc.DrawResource(aDestRect, aSource, aSrcRect, aRotation); |
|
41 } |
|
42 void DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TDesC8& aParam) |
|
43 { |
|
44 iGc.DrawResource(aDestRect, aSource, aParam); |
|
45 } |
|
46 private: |
|
47 CRemoteGc& iGc; |
|
48 }; |
|
49 |
|
50 /** |
|
51 Creates a new remotegc. |
|
52 |
|
53 @param aDevice The windowserver screendevice to use. |
|
54 @param aCommandBufferObserver Pointer to a commandbufferobserver. |
|
55 @return A pointer to a new instance of CRemoteGc. |
|
56 */ |
|
57 EXPORT_C CRemoteGc* CRemoteGc::NewL(CWsScreenDevice* aDevice) |
|
58 { |
|
59 CRemoteGc* remoteGc = new (ELeave) CRemoteGc(aDevice); |
|
60 CleanupStack::PushL(remoteGc); |
|
61 remoteGc->ConstructL(); |
|
62 CleanupStack::Pop(remoteGc); |
|
63 return remoteGc; |
|
64 } |
|
65 |
|
66 CRemoteGc::CRemoteGc(CWsScreenDevice* aDevice) : CWindowGc(aDevice), iCommandBufferObserver(NULL), iFont(NULL), iShadowColor(KDefaultShadowColor) |
|
67 { |
|
68 } |
|
69 |
|
70 EXPORT_C CRemoteGc::~CRemoteGc() |
|
71 { |
|
72 delete iCommandBuffer; |
|
73 delete iRemoteGcPimpl; |
|
74 } |
|
75 |
|
76 void CRemoteGc::ConstructL() |
|
77 { |
|
78 User::LeaveIfError(CWindowGc::Construct()); |
|
79 iCommandBuffer = CCommandBuffer::NewL(); |
|
80 iRemoteGcPimpl = new(ELeave) CPimpl(*this); |
|
81 } |
|
82 |
|
83 EXPORT_C void CRemoteGc::SetCommandBufferObserver(MCommandBufferObserver* aCommandBufferObserver) |
|
84 { |
|
85 iCommandBufferObserver = aCommandBufferObserver; |
|
86 } |
|
87 |
|
88 /** |
|
89 Resets the commandbuffer. |
|
90 */ |
|
91 EXPORT_C void CRemoteGc::ResetCommandBuffer() |
|
92 { |
|
93 iCommandBuffer->Reset(); |
|
94 } |
|
95 |
|
96 /** |
|
97 Externalizes commandbuffer sections into a format which makes it possible to send over IPC. |
|
98 If ETrue is sent as a parameter to this method, the entire commandbuffer will be externalized, |
|
99 otherwise only sections which has not been externalized before will be externalized. Note that if only |
|
100 not externalized sections is asked for, the flag will be reset on that section so next call |
|
101 to ExternalizeLC will not externalize that section. |
|
102 |
|
103 @param aMsgBuf A buffer used to externalize the commandbuffer to. |
|
104 @param aEntireBuffer If ETrue, the entire commandbuffer will be externalized, otherwise only sections which has not been externalized before. |
|
105 */ |
|
106 EXPORT_C void CRemoteGc::ExternalizeL(RWsGraphicMsgBuf& aMsgBuf, TBool aEntireBuffer) |
|
107 { |
|
108 return iCommandBuffer->ExternalizeL(aMsgBuf, aEntireBuffer); |
|
109 } |
|
110 |
|
111 /** |
|
112 Prepares the remotegc to be drawn to. |
|
113 |
|
114 @param aRect The rect to be drawn. |
|
115 */ |
|
116 EXPORT_C void CRemoteGc::BeginDraw(const TRect& aRect) |
|
117 { |
|
118 iDrawRect = aRect; |
|
119 iBoundingRect = TRect(); |
|
120 iHasBitmapCommand = EFalse; |
|
121 iCommandBuffer->Prepare(aRect); |
|
122 } |
|
123 |
|
124 /** |
|
125 Finishes the current redraw. |
|
126 This method should be called when drawing to the remotegc is complete. |
|
127 */ |
|
128 EXPORT_C void CRemoteGc::EndDraw() |
|
129 { |
|
130 iBoundingRect.Intersection(iDrawRect); |
|
131 const TInt err = iCommandBuffer->Finish(iDrawRect, iBoundingRect, iHasBitmapCommand); |
|
132 |
|
133 if(iCommandBufferObserver && !err) |
|
134 iCommandBufferObserver->CommandBufferUpdated(iDrawRect, iBoundingRect); |
|
135 } |
|
136 |
|
137 void CRemoteGc::Activate(RDrawableWindow &aDevice) |
|
138 { |
|
139 BeginDraw(aDevice.GetDrawRect()); |
|
140 CWindowGc::Activate(aDevice); |
|
141 } |
|
142 |
|
143 void CRemoteGc::Deactivate() |
|
144 { |
|
145 CWindowGc::Deactivate(); |
|
146 iFont = NULL; |
|
147 iShadowColor = KDefaultShadowColor; |
|
148 EndDraw(); |
|
149 } |
|
150 |
|
151 void CRemoteGc::Clear() |
|
152 { |
|
153 iCommandBuffer->Write<TDrawCode>(ECommandClear); |
|
154 iBoundingRect.BoundingRect(iDrawRect); |
|
155 } |
|
156 |
|
157 void CRemoteGc::Clear(const TRect& aRect) |
|
158 { |
|
159 iCommandBuffer->Write<TDrawCode>(ECommandClearRect); |
|
160 iCommandBuffer->Write<TRect>(aRect); |
|
161 iBoundingRect.BoundingRect(aRect); |
|
162 } |
|
163 |
|
164 void CRemoteGc::CopyRect(const TPoint &anOffset, const TRect &aRect) |
|
165 { |
|
166 iCommandBuffer->Write<TDrawCode>(ECommandCopyRect); |
|
167 iCommandBuffer->Write<TPoint>(anOffset); |
|
168 iCommandBuffer->Write<TRect>(aRect); |
|
169 iBoundingRect.BoundingRect(iDrawRect); |
|
170 } |
|
171 |
|
172 void CRemoteGc::BitBlt(const TPoint &aPoint, const CFbsBitmap *aBitmap) |
|
173 { |
|
174 __ASSERT_DEBUG(aBitmap, User::Invariant()); |
|
175 if(aBitmap) |
|
176 { |
|
177 iCommandBuffer->Write<TDrawCode>(ECommandBitBlt1); |
|
178 iCommandBuffer->Write<TPoint>(aPoint); |
|
179 iCommandBuffer->Write<TInt>(aBitmap->Handle()); |
|
180 iBoundingRect.BoundingRect(TRect(aPoint, aBitmap->SizeInPixels())); |
|
181 iHasBitmapCommand = ETrue; |
|
182 } |
|
183 } |
|
184 |
|
185 void CRemoteGc::BitBlt(const TPoint &aDestination, const CFbsBitmap *aBitmap, const TRect &aSource) |
|
186 { |
|
187 __ASSERT_DEBUG(aBitmap, User::Invariant()); |
|
188 if(aBitmap) |
|
189 { |
|
190 iCommandBuffer->Write<TDrawCode>(ECommandBitBlt2); |
|
191 iCommandBuffer->Write<TPoint>(aDestination); |
|
192 iCommandBuffer->Write<TInt>(aBitmap->Handle()); |
|
193 iCommandBuffer->Write<TRect>(aSource); |
|
194 iBoundingRect.BoundingRect(TRect(aDestination, aSource.Size())); |
|
195 iHasBitmapCommand = ETrue; |
|
196 } |
|
197 } |
|
198 |
|
199 void CRemoteGc::BitBltMasked(const TPoint& aPoint, const CFbsBitmap* aBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask) |
|
200 { |
|
201 __ASSERT_DEBUG(aBitmap && aMaskBitmap, User::Invariant()); |
|
202 if(aBitmap && aMaskBitmap) |
|
203 { |
|
204 iCommandBuffer->Write<TDrawCode>(ECommandBitBltMasked); |
|
205 iCommandBuffer->Write<TPoint>(aPoint); |
|
206 iCommandBuffer->Write<TInt>(aBitmap->Handle()); |
|
207 iCommandBuffer->Write<TRect>(aSourceRect); |
|
208 iCommandBuffer->Write<TInt>(aMaskBitmap->Handle()); |
|
209 iCommandBuffer->Write<TBool>(aInvertMask); |
|
210 iBoundingRect.BoundingRect(TRect(aPoint, aSourceRect.Size())); |
|
211 iHasBitmapCommand = ETrue; |
|
212 } |
|
213 } |
|
214 |
|
215 void CRemoteGc::BitBlt(const TPoint &aPoint, const CWsBitmap *aBitmap) |
|
216 { |
|
217 BitBlt(aPoint, reinterpret_cast<const CFbsBitmap*>(aBitmap)); |
|
218 } |
|
219 |
|
220 void CRemoteGc::BitBlt(const TPoint &aDestination, const CWsBitmap *aBitmap, const TRect &aSource) |
|
221 { |
|
222 BitBlt(aDestination, reinterpret_cast<const CFbsBitmap*>(aBitmap), aSource); |
|
223 } |
|
224 |
|
225 void CRemoteGc::BitBltMasked(const TPoint& aPoint, const CWsBitmap *aBitmap, const TRect& aSourceRect, const CWsBitmap *aMaskBitmap, TBool aInvertMask) |
|
226 { |
|
227 BitBltMasked(aPoint, reinterpret_cast<const CFbsBitmap*>(aBitmap), aSourceRect, reinterpret_cast<const CFbsBitmap*>(aMaskBitmap), aInvertMask); |
|
228 } |
|
229 |
|
230 void CRemoteGc::SetFaded(TBool /*aFaded*/) |
|
231 { |
|
232 // deprecated |
|
233 } |
|
234 |
|
235 void CRemoteGc::SetFadingParameters(TUint8 /*aBlackMap*/,TUint8 /*aWhiteMap*/) |
|
236 { |
|
237 // deprecated |
|
238 } |
|
239 |
|
240 TInt CRemoteGc::AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt) |
|
241 { |
|
242 iCommandBuffer->Write<TDrawCode>(ECommandAlphaBlendBitmaps); |
|
243 iCommandBuffer->Write<TPoint>(aDestPt); |
|
244 iCommandBuffer->Write<TInt>(aSrcBmp->Handle()); |
|
245 iCommandBuffer->Write<TRect>(aSrcRect); |
|
246 iCommandBuffer->Write<TInt>(aAlphaBmp->Handle()); |
|
247 iCommandBuffer->Write<TPoint>(aAlphaPt); |
|
248 iBoundingRect.BoundingRect(iDrawRect); |
|
249 iHasBitmapCommand = ETrue; |
|
250 return KErrNone; |
|
251 } |
|
252 |
|
253 TInt CRemoteGc::AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt) |
|
254 { |
|
255 return AlphaBlendBitmaps(aDestPt, reinterpret_cast<const CFbsBitmap*>(aSrcBmp), aSrcRect, reinterpret_cast<const CFbsBitmap*>(aAlphaBmp), aAlphaPt); |
|
256 } |
|
257 |
|
258 void CRemoteGc::SetOrigin(const TPoint &aPoint) |
|
259 { |
|
260 iCommandBuffer->Write<TDrawCode>(ECommandSetOrigin); |
|
261 iCommandBuffer->Write<TPoint>(aPoint); |
|
262 } |
|
263 |
|
264 void CRemoteGc::SetDrawMode(TDrawMode aDrawingMode) |
|
265 { |
|
266 iCommandBuffer->Write<TDrawCode>(ECommandSetDrawMode); |
|
267 iCommandBuffer->Write<TDrawMode>(aDrawingMode); |
|
268 } |
|
269 |
|
270 void CRemoteGc::SetClippingRect(const TRect& aRect) |
|
271 { |
|
272 iCommandBuffer->Write<TDrawCode>(ECommandSetClippingRect); |
|
273 iCommandBuffer->Write<TRect>(aRect); |
|
274 } |
|
275 |
|
276 void CRemoteGc::CancelClippingRect() |
|
277 { |
|
278 iCommandBuffer->Write<TDrawCode>(ECommandCancelClippingRect); |
|
279 } |
|
280 |
|
281 void CRemoteGc::Reset() |
|
282 { |
|
283 iCommandBuffer->Write<TDrawCode>(ECommandReset); |
|
284 iFont = NULL; |
|
285 iShadowColor = KDefaultShadowColor; |
|
286 } |
|
287 |
|
288 void CRemoteGc::UseFont(const CFont *aFont) |
|
289 { |
|
290 if (iFont!=(CFbsFont *)aFont) |
|
291 { |
|
292 iFont=(CFbsFont *)aFont; |
|
293 iCommandBuffer->Write<TDrawCode>(ECommandUseFont); |
|
294 iCommandBuffer->Write<TInt>(((CFbsFont*)aFont)->Handle()); |
|
295 } |
|
296 } |
|
297 |
|
298 void CRemoteGc::DiscardFont() |
|
299 { |
|
300 iFont = NULL; |
|
301 iCommandBuffer->Write<TDrawCode>(ECommandDiscardFont); |
|
302 } |
|
303 |
|
304 void CRemoteGc::SetUnderlineStyle(TFontUnderline aUnderlineStyle) |
|
305 { |
|
306 iCommandBuffer->Write<TDrawCode>(ECommandSetUnderlineStyle); |
|
307 iCommandBuffer->Write<TFontUnderline>(aUnderlineStyle); |
|
308 } |
|
309 |
|
310 void CRemoteGc::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle) |
|
311 { |
|
312 iCommandBuffer->Write<TDrawCode>(ECommandSetStrikethroughStyle); |
|
313 iCommandBuffer->Write<TFontStrikethrough>(aStrikethroughStyle); |
|
314 } |
|
315 |
|
316 void CRemoteGc::SetWordJustification(TInt aExcessWidth, TInt aNumGaps) |
|
317 { |
|
318 iCommandBuffer->Write<TDrawCode>(ECommandSetWordJustification); |
|
319 iCommandBuffer->Write<TInt>(aExcessWidth); |
|
320 iCommandBuffer->Write<TInt>(aNumGaps); |
|
321 } |
|
322 |
|
323 void CRemoteGc::SetCharJustification(TInt aExcessWidth, TInt aNumChars) |
|
324 { |
|
325 iCommandBuffer->Write<TDrawCode>(ECommandSetCharJustification); |
|
326 iCommandBuffer->Write<TInt>(aExcessWidth); |
|
327 iCommandBuffer->Write<TInt>(aNumChars); |
|
328 } |
|
329 |
|
330 void CRemoteGc::SetPenColor(const TRgb &aColor) |
|
331 { |
|
332 iCommandBuffer->Write<TDrawCode>(ECommandSetPenColor); |
|
333 iCommandBuffer->Write<TRgb>(aColor); |
|
334 } |
|
335 |
|
336 void CRemoteGc::SetPenStyle(TPenStyle aPenStyle) |
|
337 { |
|
338 iCommandBuffer->Write<TDrawCode>(ECommandSetPenStyle); |
|
339 iCommandBuffer->Write<TPenStyle>(aPenStyle); |
|
340 } |
|
341 |
|
342 void CRemoteGc::SetPenSize(const TSize& aSize) |
|
343 { |
|
344 iCommandBuffer->Write<TDrawCode>(ECommandSetPenSize); |
|
345 iCommandBuffer->Write<TSize>(aSize); |
|
346 } |
|
347 |
|
348 void CRemoteGc::SetBrushColor(const TRgb &aColor) |
|
349 { |
|
350 iCommandBuffer->Write<TDrawCode>(ECommandSetBrushColor); |
|
351 iCommandBuffer->Write<TRgb>(aColor); |
|
352 } |
|
353 |
|
354 void CRemoteGc::SetBrushStyle(TBrushStyle aBrushStyle) |
|
355 { |
|
356 iCommandBuffer->Write<TDrawCode>(ECommandSetBrushStyle); |
|
357 iCommandBuffer->Write<TBrushStyle>(aBrushStyle); |
|
358 } |
|
359 |
|
360 void CRemoteGc::SetBrushOrigin(const TPoint &aOrigin) |
|
361 { |
|
362 iCommandBuffer->Write<TDrawCode>(ECommandSetBrushOrigin); |
|
363 iCommandBuffer->Write<TPoint>(aOrigin); |
|
364 } |
|
365 |
|
366 void CRemoteGc::UseBrushPattern(const CFbsBitmap *aDevice) |
|
367 { |
|
368 iCommandBuffer->Write<TDrawCode>(ECommandUseBrushPattern); |
|
369 iCommandBuffer->Write<TInt>(aDevice->Handle()); |
|
370 } |
|
371 |
|
372 void CRemoteGc::DiscardBrushPattern() |
|
373 { |
|
374 iCommandBuffer->Write<TDrawCode>(ECommandDiscardBrushPattern); |
|
375 } |
|
376 |
|
377 void CRemoteGc::MoveTo(const TPoint &aPoint) |
|
378 { |
|
379 iCommandBuffer->Write<TDrawCode>(ECommandMoveTo); |
|
380 iCommandBuffer->Write<TPoint>(aPoint); |
|
381 } |
|
382 |
|
383 void CRemoteGc::MoveBy(const TPoint &aPoint) |
|
384 { |
|
385 iCommandBuffer->Write<TDrawCode>(ECommandMoveBy); |
|
386 iCommandBuffer->Write<TPoint>(aPoint); |
|
387 } |
|
388 |
|
389 void CRemoteGc::Plot(const TPoint &aPoint) |
|
390 { |
|
391 iCommandBuffer->Write<TDrawCode>(ECommandPlot); |
|
392 iCommandBuffer->Write<TPoint>(aPoint); |
|
393 iBoundingRect.BoundingRect(iDrawRect); |
|
394 } |
|
395 |
|
396 void CRemoteGc::DrawArc(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd) |
|
397 { |
|
398 iCommandBuffer->Write<TDrawCode>(ECommandDrawArc); |
|
399 iCommandBuffer->Write<TRect>(aRect); |
|
400 iCommandBuffer->Write<TPoint>(aStart); |
|
401 iCommandBuffer->Write<TPoint>(aEnd); |
|
402 iBoundingRect.BoundingRect(iDrawRect); |
|
403 } |
|
404 |
|
405 void CRemoteGc::DrawLine(const TPoint &aPoint1,const TPoint &aPoint2) |
|
406 { |
|
407 iCommandBuffer->Write<TDrawCode>(ECommandDrawLine); |
|
408 iCommandBuffer->Write<TPoint>(aPoint1); |
|
409 iCommandBuffer->Write<TPoint>(aPoint2); |
|
410 iBoundingRect.BoundingRect(iDrawRect); |
|
411 } |
|
412 |
|
413 void CRemoteGc::DrawLineTo(const TPoint &aPoint) |
|
414 { |
|
415 iCommandBuffer->Write<TDrawCode>(ECommandDrawLineTo); |
|
416 iCommandBuffer->Write<TPoint>(aPoint); |
|
417 iBoundingRect.BoundingRect(iDrawRect); |
|
418 } |
|
419 |
|
420 void CRemoteGc::DrawLineBy(const TPoint &aPoint) |
|
421 { |
|
422 iCommandBuffer->Write<TDrawCode>(ECommandDrawLineBy); |
|
423 iCommandBuffer->Write<TPoint>(aPoint); |
|
424 iBoundingRect.BoundingRect(iDrawRect); |
|
425 } |
|
426 |
|
427 void CRemoteGc::DrawPolyLine(const CArrayFix<TPoint> *aPointList) |
|
428 { |
|
429 iCommandBuffer->Write<TDrawCode>(ECommandDrawPolyLine); |
|
430 iCommandBuffer->Write<TInt>(aPointList->Count()); // Write number of points |
|
431 |
|
432 const TInt count = aPointList->Count(); |
|
433 for(TInt i = 0; i < count; i++) |
|
434 { |
|
435 iCommandBuffer->Write<TPoint>(aPointList->At(i)); |
|
436 } |
|
437 iBoundingRect.BoundingRect(iDrawRect); |
|
438 } |
|
439 |
|
440 void CRemoteGc::DrawPolyLine(const TPoint* aPointList, TInt aNumPoints) |
|
441 { |
|
442 iCommandBuffer->Write<TDrawCode>(ECommandDrawPolyLine); |
|
443 iCommandBuffer->Write<TInt>(aNumPoints); // Write number of points |
|
444 |
|
445 for(TInt i = 0; i < aNumPoints; i++) |
|
446 { |
|
447 iCommandBuffer->Write<TPoint>(aPointList[i]); |
|
448 } |
|
449 iBoundingRect.BoundingRect(iDrawRect); |
|
450 } |
|
451 |
|
452 void CRemoteGc::DrawPie(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd) |
|
453 { |
|
454 iCommandBuffer->Write<TDrawCode>(ECommandDrawPie); |
|
455 iCommandBuffer->Write<TRect>(aRect); |
|
456 iCommandBuffer->Write<TPoint>(aStart); |
|
457 iCommandBuffer->Write<TPoint>(aEnd); |
|
458 iBoundingRect.BoundingRect(iDrawRect); |
|
459 } |
|
460 |
|
461 void CRemoteGc::DrawEllipse(const TRect &aRect) |
|
462 { |
|
463 iCommandBuffer->Write<TDrawCode>(ECommandDrawEllipse); |
|
464 iCommandBuffer->Write<TRect>(aRect); |
|
465 iBoundingRect.BoundingRect(iDrawRect); |
|
466 } |
|
467 |
|
468 void CRemoteGc::DrawRect(const TRect &aRect) |
|
469 { |
|
470 iCommandBuffer->Write<TDrawCode>(ECommandDrawRect); |
|
471 iCommandBuffer->Write<TRect>(aRect); |
|
472 iBoundingRect.BoundingRect(iDrawRect); |
|
473 } |
|
474 |
|
475 void CRemoteGc::DrawRoundRect(const TRect &aRect,const TSize &aEllipse) |
|
476 { |
|
477 iCommandBuffer->Write<TDrawCode>(ECommandDrawRoundRect); |
|
478 iCommandBuffer->Write<TRect>(aRect); |
|
479 iCommandBuffer->Write<TSize>(aEllipse); |
|
480 iBoundingRect.BoundingRect(iDrawRect); |
|
481 } |
|
482 |
|
483 TInt CRemoteGc::DrawPolygon(const CArrayFix<TPoint> *aPointList, TFillRule aFillRule) |
|
484 { |
|
485 iCommandBuffer->Write<TDrawCode>(ECommandDrawPolygon); |
|
486 iCommandBuffer->Write<TInt>(aPointList->Count()); // Write number of points |
|
487 |
|
488 for(TInt i = 0; i < aPointList->Count(); i++) |
|
489 { |
|
490 iCommandBuffer->Write<TPoint>(aPointList->At(i)); |
|
491 } |
|
492 |
|
493 iCommandBuffer->Write<TFillRule>(aFillRule); |
|
494 iBoundingRect.BoundingRect(iDrawRect); |
|
495 return KErrNone; |
|
496 } |
|
497 |
|
498 TInt CRemoteGc::DrawPolygon(const TPoint* aPointList, TInt aNumPoints, TFillRule aFillRule) |
|
499 { |
|
500 iCommandBuffer->Write<TDrawCode>(ECommandDrawPolygon); |
|
501 iCommandBuffer->Write<TInt>(aNumPoints); // Write number of points |
|
502 |
|
503 for(TInt i = 0; i < aNumPoints; i++) |
|
504 { |
|
505 iCommandBuffer->Write<TPoint>(aPointList[i]); |
|
506 } |
|
507 |
|
508 iCommandBuffer->Write<TFillRule>(aFillRule); |
|
509 iBoundingRect.BoundingRect(iDrawRect); |
|
510 return KErrNone; |
|
511 } |
|
512 |
|
513 void CRemoteGc::DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aDevice) |
|
514 { |
|
515 iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmap1); |
|
516 iCommandBuffer->Write<TPoint>(aTopLeft); |
|
517 iCommandBuffer->Write<TInt>(aDevice->Handle()); |
|
518 iBoundingRect.BoundingRect(TRect(aTopLeft, aDevice->SizeInPixels())); |
|
519 iHasBitmapCommand = ETrue; |
|
520 } |
|
521 |
|
522 void CRemoteGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice) |
|
523 { |
|
524 iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmap2); |
|
525 iCommandBuffer->Write<TRect>(aDestRect); |
|
526 iCommandBuffer->Write<TInt>(aDevice->Handle()); |
|
527 iBoundingRect.BoundingRect(aDestRect); |
|
528 iHasBitmapCommand = ETrue; |
|
529 } |
|
530 |
|
531 void CRemoteGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice, const TRect &aSourceRect) |
|
532 { |
|
533 iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmap3); |
|
534 iCommandBuffer->Write<TRect>(aDestRect); |
|
535 iCommandBuffer->Write<TInt>(aDevice->Handle()); |
|
536 iCommandBuffer->Write<TRect>(aSourceRect); |
|
537 iBoundingRect.BoundingRect(aDestRect); |
|
538 iHasBitmapCommand = ETrue; |
|
539 } |
|
540 |
|
541 void CRemoteGc::DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap* aBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask) |
|
542 { |
|
543 iCommandBuffer->Write<TDrawCode>(ECommandDrawBitmapMasked); |
|
544 iCommandBuffer->Write<TRect>(aDestRect); |
|
545 iCommandBuffer->Write<TInt>(aBitmap->Handle()); |
|
546 iCommandBuffer->Write<TRect>(aSourceRect); |
|
547 iCommandBuffer->Write<TInt>(aMaskBitmap->Handle()); |
|
548 iCommandBuffer->Write<TBool>(aInvertMask); |
|
549 iBoundingRect.BoundingRect(aDestRect); |
|
550 iHasBitmapCommand = ETrue; |
|
551 } |
|
552 |
|
553 void CRemoteGc::DrawBitmapMasked(const TRect& aDestRect, const CWsBitmap* aBitmap, const TRect& aSourceRect, const CWsBitmap* aMaskBitmap, TBool aInvertMask) |
|
554 { |
|
555 DrawBitmapMasked(aDestRect, reinterpret_cast<const CFbsBitmap*>(aBitmap), aSourceRect, reinterpret_cast<const CFbsBitmap*>(aMaskBitmap), aInvertMask); |
|
556 } |
|
557 |
|
558 void CRemoteGc::DrawText(const TDesC &aBuf,const TPoint &aPos) |
|
559 { |
|
560 iCommandBuffer->Write<TDrawCode>(ECommandDrawText1); |
|
561 iCommandBuffer->WriteText(aBuf); |
|
562 iCommandBuffer->Write<TPoint>(aPos); |
|
563 iBoundingRect.BoundingRect(iDrawRect); |
|
564 } |
|
565 |
|
566 void CRemoteGc::DrawText(const TDesC &aBuf, const TRect &aBox, TInt aBaselineOffset, TTextAlign aHoriz, TInt aLeftMrg) |
|
567 { |
|
568 iCommandBuffer->Write<TDrawCode>(ECommandDrawText2); |
|
569 iCommandBuffer->WriteText(aBuf); |
|
570 iCommandBuffer->Write<TRect>(aBox); |
|
571 iCommandBuffer->Write<TInt>(aBaselineOffset); |
|
572 iCommandBuffer->Write<TTextAlign>(aHoriz); |
|
573 iCommandBuffer->Write<TInt>(aLeftMrg); |
|
574 iBoundingRect.BoundingRect(aBox); |
|
575 } |
|
576 |
|
577 void CRemoteGc::DrawText(const TDesC& aText, const TPoint& aPosition, const TDrawTextParam& aParam) |
|
578 { |
|
579 iCommandBuffer->Write<TDrawCode>(ECommandDrawText3); |
|
580 iCommandBuffer->WriteText(aText); |
|
581 iCommandBuffer->Write<TPoint>(aPosition); |
|
582 iCommandBuffer->Write<TDrawTextParam>(aParam); |
|
583 iBoundingRect.BoundingRect(iDrawRect); |
|
584 } |
|
585 |
|
586 void CRemoteGc::MapColors(const TRect& /*aRect*/, const TRgb* /*aColors*/, TInt /*aNumPairs*/, TBool /*aMapForwards*/) |
|
587 { |
|
588 //deprecated |
|
589 } |
|
590 |
|
591 TInt CRemoteGc::SetClippingRegion(const TRegion &aRegion) |
|
592 { |
|
593 iCommandBuffer->Write<TDrawCode>(ECommandSetClippingRegion); |
|
594 |
|
595 const TInt count = aRegion.Count(); |
|
596 iCommandBuffer->Write<TInt>(count); |
|
597 |
|
598 for(TInt i = 0; i < count; i++) |
|
599 { |
|
600 iCommandBuffer->Write<TRect>(aRegion.RectangleList()[i]); |
|
601 } |
|
602 |
|
603 return KErrNone; |
|
604 } |
|
605 |
|
606 void CRemoteGc::CancelClippingRegion() |
|
607 { |
|
608 iCommandBuffer->Write<TDrawCode>(ECommandCancelClippingRegion); |
|
609 } |
|
610 |
|
611 void CRemoteGc::DrawTextVertical(const TDesC& aText, const TPoint& aPos, TBool aUp) |
|
612 { |
|
613 iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical1); |
|
614 iCommandBuffer->WriteText(aText); |
|
615 iCommandBuffer->Write<TPoint>(aPos); |
|
616 iCommandBuffer->Write<TBool>(aUp); |
|
617 iBoundingRect.BoundingRect(iDrawRect); |
|
618 } |
|
619 |
|
620 void CRemoteGc::DrawTextVertical(const TDesC& aText, const TRect& aBox, TInt aBaselineOffset, TBool aUp, TTextAlign aVert, TInt aMargin) |
|
621 { |
|
622 iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical2); |
|
623 iCommandBuffer->WriteText(aText); |
|
624 iCommandBuffer->Write<TRect>(aBox); |
|
625 iCommandBuffer->Write<TInt>(aBaselineOffset); |
|
626 iCommandBuffer->Write<TBool>(aUp); |
|
627 iCommandBuffer->Write<TTextAlign>(aVert); |
|
628 iCommandBuffer->Write<TInt>(aMargin); |
|
629 iBoundingRect.BoundingRect(aBox); |
|
630 } |
|
631 |
|
632 void CRemoteGc::DrawWsGraphic(const TWsGraphicId& aId,const TRect& aDestRect) |
|
633 { |
|
634 iCommandBuffer->Write<TDrawCode>(ECommandDrawWsGraphic1); |
|
635 iCommandBuffer->Write<TInt>(aId.IsUid()? aId.Uid().iUid: aId.Id()); |
|
636 iCommandBuffer->Write<TBool>(aId.IsUid()); |
|
637 iCommandBuffer->Write<TRect>(aDestRect); |
|
638 iBoundingRect.BoundingRect(aDestRect); |
|
639 } |
|
640 |
|
641 void CRemoteGc::DrawWsGraphic(const TWsGraphicId& aId,const TRect& aDestRect,const TDesC8& aData) |
|
642 { |
|
643 iCommandBuffer->Write<TDrawCode>(ECommandDrawWsGraphic2); |
|
644 iCommandBuffer->Write<TInt>(aId.IsUid()? aId.Uid().iUid: aId.Id()); |
|
645 iCommandBuffer->Write<TBool>(aId.IsUid()); |
|
646 iCommandBuffer->Write<TRect>(aDestRect); |
|
647 iCommandBuffer->WriteText(aData); |
|
648 iBoundingRect.BoundingRect(aDestRect); |
|
649 } |
|
650 |
|
651 void CRemoteGc::SetDitherOrigin(const TPoint& /*aPoint*/) //deprecated |
|
652 { |
|
653 // do nothing, does not apply to CBitmapContext which CCommandBuffer is using |
|
654 } |
|
655 |
|
656 void CRemoteGc::SetOpaque(TBool /*aDrawOpaque*/) // deprecated |
|
657 { |
|
658 // overrides to prevent calling CWindowGc::SetOpaque, it's specific to how wserv blends windows content |
|
659 } |
|
660 |
|
661 TInt CRemoteGc::APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput) |
|
662 { |
|
663 if (aUid == KGetUnderlineMetrics) |
|
664 { |
|
665 return APIExGetUnderlineMetrics(aOutput); |
|
666 } |
|
667 else if (aUid == KSetShadowColor) |
|
668 { |
|
669 return APIExSetShadowColor(aInput); |
|
670 } |
|
671 else if (aUid == KDrawTextInContextUid) |
|
672 { |
|
673 TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput; |
|
674 return APIExDrawText(contextParam->iText, &contextParam->iParam, contextParam->iPosition); |
|
675 } |
|
676 else if (aUid == KDrawBoxTextInContextUid) |
|
677 { |
|
678 TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput; |
|
679 return APIExDrawText(contextParam->iText,&contextParam->iParam,contextParam->iBox,contextParam->iBaselineOffset,contextParam->iAlign,contextParam->iMargin); |
|
680 } |
|
681 else if (aUid == KDrawTextInContextVerticalUid) |
|
682 { |
|
683 TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput; |
|
684 return APIExDrawTextVertical(contextParam->iText, &contextParam->iParam, contextParam->iPosition,contextParam->iUp); |
|
685 } |
|
686 else if (aUid == KDrawBoxTextInContextVerticalUid) |
|
687 { |
|
688 TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput; |
|
689 return APIExDrawTextVertical(contextParam->iText,&contextParam->iParam,contextParam->iBox,contextParam->iBaselineOffset,contextParam->iUp,contextParam->iAlign,contextParam->iMargin); |
|
690 } |
|
691 else if (aUid == KApiExtensionInterfaceUid) |
|
692 { |
|
693 return APIExInterface(aOutput, *static_cast<TUid*>(aInput)); |
|
694 } |
|
695 /* Future cases may be placed here later.*/ |
|
696 else |
|
697 { |
|
698 return CBitmapContext::APIExtension(aUid, aOutput, aInput); |
|
699 } |
|
700 } |
|
701 |
|
702 TInt CRemoteGc::APIExGetUnderlineMetrics(TAny*& aOutput) |
|
703 { |
|
704 const TInt width = Max(iFont->HeightInPixels() / 10,1); |
|
705 TTwoTInt* ptr = (TTwoTInt*)aOutput; |
|
706 ptr->iTop = 1 + width / 2; |
|
707 ptr->iBottom = (ptr->iTop) + width; |
|
708 return KErrNone; |
|
709 } |
|
710 |
|
711 TInt CRemoteGc::APIExSetShadowColor(TAny* aShadowColor) |
|
712 { |
|
713 const TRgb shadowColor = *(reinterpret_cast<TRgb*> (aShadowColor)); |
|
714 iCommandBuffer->Write<TDrawCode>(ECommandSetShadowColor); |
|
715 iCommandBuffer->Write<TRgb>(shadowColor); |
|
716 iShadowColor = shadowColor; |
|
717 return KErrNone; |
|
718 } |
|
719 |
|
720 TInt CRemoteGc::APIExGetShadowColor(TAny*& aOutput) |
|
721 { |
|
722 TRgb* ptr = (TRgb*)aOutput; |
|
723 ptr->SetInternal(iShadowColor.Internal()); |
|
724 return KErrNone; |
|
725 } |
|
726 |
|
727 TInt CRemoteGc::APIExDrawText(const TDesC &aBuf,const TTextParameters* aParam,const TPoint &aPos) |
|
728 { |
|
729 iCommandBuffer->Write<TDrawCode>(ECommandDrawText4); |
|
730 iCommandBuffer->WriteText(aBuf); |
|
731 iCommandBuffer->Write<TTextParameters>(*aParam); |
|
732 iCommandBuffer->Write<TPoint>(aPos); |
|
733 iBoundingRect.BoundingRect(iDrawRect); |
|
734 return KErrNone; |
|
735 } |
|
736 |
|
737 TInt CRemoteGc::APIExDrawText(const TDesC &aBuf,const TTextParameters* aParam,const TRect &aBox,TInt aBaselineOffset,TTextAlign aHoriz,TInt aLeftMrg) |
|
738 { |
|
739 iCommandBuffer->Write<TDrawCode>(ECommandDrawText5); |
|
740 iCommandBuffer->WriteText(aBuf); |
|
741 iCommandBuffer->Write<TTextParameters>(*aParam); |
|
742 iCommandBuffer->Write<TRect>(aBox); |
|
743 iCommandBuffer->Write<TInt>(aBaselineOffset); |
|
744 iCommandBuffer->Write<TTextAlign>(aHoriz); |
|
745 iCommandBuffer->Write<TInt>(aLeftMrg); |
|
746 iBoundingRect.BoundingRect(aBox); |
|
747 return KErrNone; |
|
748 } |
|
749 |
|
750 TInt CRemoteGc::APIExDrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPos,TBool aUp) |
|
751 { |
|
752 iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical3); |
|
753 iCommandBuffer->WriteText(aText); |
|
754 iCommandBuffer->Write<TTextParameters>(*aParam); |
|
755 iCommandBuffer->Write<TPoint>(aPos); |
|
756 iCommandBuffer->Write<TBool>(aUp); |
|
757 iBoundingRect.BoundingRect(iDrawRect); |
|
758 return KErrNone; |
|
759 } |
|
760 |
|
761 TInt CRemoteGc::APIExDrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert,TInt aMargin) |
|
762 { |
|
763 iCommandBuffer->Write<TDrawCode>(ECommandDrawTextVertical4); |
|
764 iCommandBuffer->WriteText(aText); |
|
765 iCommandBuffer->Write<TTextParameters>(*aParam); |
|
766 iCommandBuffer->Write<TRect>(aBox); |
|
767 iCommandBuffer->Write<TInt>(aBaselineOffset); |
|
768 iCommandBuffer->Write<TBool>(aUp); |
|
769 iCommandBuffer->Write<TTextAlign>(aVert); |
|
770 iCommandBuffer->Write<TInt>(aMargin); |
|
771 iBoundingRect.BoundingRect(aBox); |
|
772 return KErrNone; |
|
773 } |
|
774 |
|
775 TInt CRemoteGc::APIExInterface(TAny*& aInterface, TUid aInterfaceId) |
|
776 { |
|
777 if(aInterfaceId == KMWsDrawResourceInterfaceUid) |
|
778 { |
|
779 aInterface = static_cast<MWsDrawResource*>(iRemoteGcPimpl); |
|
780 return KErrNone; |
|
781 } |
|
782 return KErrNotSupported; |
|
783 } |
|
784 |
|
785 void CRemoteGc::DrawResource(const TPoint& aPos, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation) |
|
786 { |
|
787 iCommandBuffer->Write<TDrawCode>(ECommandDrawResourceToPos); |
|
788 iCommandBuffer->Write<TSgDrawableId>(aSource.DrawableId()); |
|
789 iCommandBuffer->Write<TInt>(aSource.ScreenNumber()); |
|
790 iCommandBuffer->Write<TPoint>(aPos); |
|
791 iCommandBuffer->Write<CWindowGc::TGraphicsRotation>(aRotation); |
|
792 iBoundingRect.BoundingRect(iDrawRect); |
|
793 iHasBitmapCommand = ETrue; |
|
794 } |
|
795 |
|
796 void CRemoteGc::DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, CWindowGc::TGraphicsRotation aRotation) |
|
797 { |
|
798 iCommandBuffer->Write<TDrawCode>(ECommandDrawResourceToRect); |
|
799 iCommandBuffer->Write<TSgDrawableId>(aSource.DrawableId()); |
|
800 iCommandBuffer->Write<TInt>(aSource.ScreenNumber()); |
|
801 iCommandBuffer->Write<TRect>(aDestRect); |
|
802 iCommandBuffer->Write<CWindowGc::TGraphicsRotation>(aRotation); |
|
803 iBoundingRect.BoundingRect(aDestRect); |
|
804 iHasBitmapCommand = ETrue; |
|
805 } |
|
806 |
|
807 void CRemoteGc::DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TRect& aSrcRect, CWindowGc::TGraphicsRotation aRotation) |
|
808 { |
|
809 iCommandBuffer->Write<TDrawCode>(ECommandDrawResourceFromRectToRect); |
|
810 iCommandBuffer->Write<TSgDrawableId>(aSource.DrawableId()); |
|
811 iCommandBuffer->Write<TInt>(aSource.ScreenNumber()); |
|
812 iCommandBuffer->Write<TRect>(aDestRect); |
|
813 iCommandBuffer->Write<TRect>(aSrcRect); |
|
814 iCommandBuffer->Write<CWindowGc::TGraphicsRotation>(aRotation); |
|
815 iBoundingRect.BoundingRect(aDestRect); |
|
816 iHasBitmapCommand = ETrue; |
|
817 } |
|
818 |
|
819 void CRemoteGc::DrawResource(const TRect& aDestRect, const RWsDrawableSource& aSource, const TDesC8& aParam) |
|
820 { |
|
821 iCommandBuffer->Write<TDrawCode>(ECommandDrawResourceWithData); |
|
822 iCommandBuffer->Write<TSgDrawableId>(aSource.DrawableId()); |
|
823 iCommandBuffer->Write<TInt>(aSource.ScreenNumber()); |
|
824 iCommandBuffer->Write<TRect>(aDestRect); |
|
825 iCommandBuffer->WriteText(aParam); |
|
826 iBoundingRect.BoundingRect(aDestRect); |
|
827 iHasBitmapCommand = ETrue; |
|
828 } |
|
829 |