|
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/WSGRAPHICMSGBUF.H" |
|
17 #include "DrawSection.h" |
|
18 #include "CommandBuffer.h" |
|
19 #include "BitmapCache.h" |
|
20 #include "FontsCache.h" |
|
21 #include "DrawableCache.h" |
|
22 #include <graphics/wsgraphicscontext.h> |
|
23 #include <graphics/wsdrawablesourceprovider.h> |
|
24 #include <graphics/wsdrawresource.h> |
|
25 #include "../SERVER/bitgditomwsgraphicscontextmappings.h" |
|
26 |
|
27 const TInt KBufferSize = 1024; |
|
28 |
|
29 EXPORT_C CCommandBuffer* CCommandBuffer::NewL() |
|
30 { |
|
31 CCommandBuffer* buffer = new (ELeave) CCommandBuffer; |
|
32 CleanupStack::PushL(buffer); |
|
33 buffer->ConstructL(); |
|
34 CleanupStack::Pop(buffer); |
|
35 return buffer; |
|
36 } |
|
37 |
|
38 CCommandBuffer::CCommandBuffer() |
|
39 { |
|
40 } |
|
41 |
|
42 EXPORT_C CCommandBuffer::~CCommandBuffer() |
|
43 { |
|
44 iDrawSections.ResetAndDestroy(); |
|
45 iDrawSections.Close(); |
|
46 iBufReadStream.Close(); |
|
47 iClippingRegion.Close(); |
|
48 iIntersectedRegion.Close(); |
|
49 delete iRecordSegBuf; |
|
50 delete iBitmapCache; |
|
51 delete iFontCache; |
|
52 } |
|
53 |
|
54 void CCommandBuffer::ConstructL() |
|
55 { |
|
56 iBitmapCache = new (ELeave) CBitmapCache; |
|
57 iRecordSegBuf = CBufSeg::NewL(KBufferSize); |
|
58 iFontCache = new (ELeave) CFontsCache; |
|
59 } |
|
60 |
|
61 /** |
|
62 Resets the entire commandbuffer. |
|
63 */ |
|
64 void CCommandBuffer::Reset() |
|
65 { |
|
66 if(iRecordSegBuf) |
|
67 iRecordSegBuf->Reset(); |
|
68 |
|
69 iError = KErrNone; |
|
70 iOrigin = TPoint(0,0); |
|
71 iClippingRegion.Clear(); |
|
72 iDrawSections.ResetAndDestroy(); |
|
73 } |
|
74 |
|
75 /** |
|
76 Externalizes commandbuffer sections into a format which makes it possible to send over IPC. |
|
77 If ETrue is sent as a parameter to this method, the entire commandbuffer will be externalized, |
|
78 otherwise only sections which has not been externalized before will be externalized. Note that if only |
|
79 not externalized sections is asked for, the flag will be reset on that section so next call |
|
80 to ExternalizeLC will not externalize that section. |
|
81 |
|
82 @param aMsgBuf A buffer used to externalize the commandbuffer to. |
|
83 @param aEntireBuffer If ETrue, the entire commandbuffer will be externalized, otherwise only sections which has not been externalized before. |
|
84 */ |
|
85 void CCommandBuffer::ExternalizeL(RWsGraphicMsgBuf& aMsgBuf, TBool aEntireBuffer) |
|
86 { |
|
87 // Add drawsections to aMsgBuf |
|
88 const TInt sectionCount = iDrawSections.Count(); |
|
89 for(TInt j = 0; j < sectionCount; j++) |
|
90 { |
|
91 CDrawSection* section = iDrawSections[j]; |
|
92 if(aEntireBuffer || !section->HasBeenExternalized()) |
|
93 { |
|
94 section->ExternalizeL(aMsgBuf); |
|
95 section->SetHasBeenExternalized(ETrue); |
|
96 } |
|
97 } |
|
98 } |
|
99 |
|
100 /** |
|
101 Internalizes the entire commandbuffer from buffer containing information about all drawsections and drawcommands. |
|
102 |
|
103 @param aBuf A buffer containing information about all drawsections and drawcommands. |
|
104 */ |
|
105 EXPORT_C void CCommandBuffer::InternalizeL(const TDesC8& aBuf) |
|
106 { |
|
107 // Reset the commandbuffer |
|
108 iRecordSegBuf->Reset(); |
|
109 InternalizeAppendL(aBuf); |
|
110 } |
|
111 |
|
112 /** |
|
113 Internalizes and appends from a buffer containing information about some drawsections and drawcommands. |
|
114 |
|
115 @param aBuf A buffer containing information about some drawsections and drawcommands. |
|
116 */ |
|
117 EXPORT_C void CCommandBuffer::InternalizeAppendL(const TDesC8& aBuf) |
|
118 { |
|
119 // Reset the commandbuffer |
|
120 TWsGraphicMsgBufParser parser(aBuf); |
|
121 |
|
122 // Load drawsections |
|
123 const TInt count = parser.Count(); |
|
124 for(TInt i = 0; i < count; i++) |
|
125 { |
|
126 CDrawSection* drawSection = CDrawSection::NewL();; |
|
127 CleanupStack::PushL(drawSection); |
|
128 User::LeaveIfError(drawSection->LoadL(parser, i)); |
|
129 iDrawSections.AppendL(drawSection); |
|
130 CleanupStack::Pop(drawSection); |
|
131 } |
|
132 |
|
133 // Tidy the iDrawSection array so completely blocked sections will be removed |
|
134 Tidy(); |
|
135 } |
|
136 |
|
137 /** |
|
138 @return the current active clipping region of the commandbuffer. |
|
139 */ |
|
140 EXPORT_C const TRegion& CCommandBuffer::ClippingRegion() const |
|
141 { |
|
142 return *iActiveMasterClippingRegion; |
|
143 } |
|
144 |
|
145 /** |
|
146 Prepares to record new drawcommands for a drawsection. |
|
147 This method is called from CRemoteGc::Activate(). |
|
148 */ |
|
149 void CCommandBuffer::Prepare(const TRect& aDrawRect) |
|
150 { |
|
151 iDrawSectionRect = aDrawRect; |
|
152 iError = KErrNone; |
|
153 if(iRecordSegBuf) |
|
154 iRecordSegBuf->Delete(0, iRecordSegBuf->Size()); // Reset record buffer |
|
155 else |
|
156 TRAP(iError, iRecordSegBuf = CBufSeg::NewL(KBufferSize)); |
|
157 } |
|
158 |
|
159 /** |
|
160 Finishes the recording of drawcommands for a drawsection. |
|
161 This method is called from CRemoteGc::Deactivate(). |
|
162 |
|
163 @param aDrawRect The drawrect of the recorded drawcommands. |
|
164 @param aBoundingRect The boundingrect of the recorded drawcommands. |
|
165 */ |
|
166 TInt CCommandBuffer::Finish(const TRect& aDrawRect, const TRect& aBoundingRect, TBool aHasBitmapCommand) |
|
167 { |
|
168 // If some error occured during the recording of this section, dont add the section |
|
169 if(!iError) |
|
170 { |
|
171 CDrawSection* drawSection = NULL; |
|
172 TRAP(iError, drawSection = CDrawSection::NewL(aDrawRect, aBoundingRect, aHasBitmapCommand)) |
|
173 if(iError) |
|
174 return iError; |
|
175 |
|
176 // If boundingRect is empty clear the drawcommands added |
|
177 if(aBoundingRect.IsEmpty()) |
|
178 iRecordSegBuf->Delete(0, iRecordSegBuf->Size()); |
|
179 |
|
180 iRecordSegBuf->Compress(); |
|
181 drawSection->SetBuffer(iRecordSegBuf); //Takes ownership of the memory allocated by iRecordSegBuf |
|
182 iRecordSegBuf = NULL; |
|
183 if(CheckForDuplicate(*drawSection)) |
|
184 { |
|
185 delete drawSection; |
|
186 return KErrAlreadyExists; |
|
187 } |
|
188 |
|
189 iError = iDrawSections.Append(drawSection); |
|
190 if(iError) |
|
191 delete drawSection; |
|
192 else |
|
193 { |
|
194 Tidy(); |
|
195 if(iDrawSections.Count() == 0 || AllSectionsExternalized()) |
|
196 return KErrGeneral; |
|
197 } |
|
198 } |
|
199 |
|
200 return iError; |
|
201 } |
|
202 |
|
203 /** |
|
204 Remove drawsections that is completely blocked by another drawsection. |
|
205 */ |
|
206 void CCommandBuffer::Tidy() |
|
207 { |
|
208 RRegion region; |
|
209 TInt count = 0; |
|
210 for(TInt i = 0; i < (count = iDrawSections.Count()); i++) |
|
211 { |
|
212 TRect rect1 = iDrawSections[i]->DrawRect(); |
|
213 region.Clear(); |
|
214 region.AddRect(rect1); |
|
215 for(TInt j = i + 1; j < count; j++) |
|
216 { |
|
217 TRect rect2 = iDrawSections[j]->DrawRect(); |
|
218 region.SubRect(rect2); |
|
219 } |
|
220 |
|
221 if(region.IsEmpty()) |
|
222 { |
|
223 delete iDrawSections[i]; |
|
224 iDrawSections.Remove(i--); |
|
225 } |
|
226 } |
|
227 region.Close(); |
|
228 // coverity[extend_simple_error] |
|
229 } |
|
230 |
|
231 /** |
|
232 @return ETrue if all sections in the commandbuffer have been externalized, otherwise EFalse. |
|
233 */ |
|
234 TBool CCommandBuffer::AllSectionsExternalized() const |
|
235 { |
|
236 const TInt count = iDrawSections.Count(); |
|
237 for(TInt i = 0; i < count; i++) |
|
238 { |
|
239 if(!iDrawSections[i]->HasBeenExternalized()) |
|
240 return EFalse; |
|
241 } |
|
242 return ETrue; |
|
243 } |
|
244 |
|
245 /** |
|
246 Checks if there exists any duplicate of aDrawSection already in the iDrawSection array. |
|
247 |
|
248 @param aDrawSection The drawsection to look for a duplicate of. |
|
249 @return ETrue if a duplicate was found, otherwise EFalse. |
|
250 */ |
|
251 TBool CCommandBuffer::CheckForDuplicate(const CDrawSection& aDrawSection) const |
|
252 { |
|
253 const TInt count = iDrawSections.Count(); |
|
254 for(TInt i = 0; i < count; i++) |
|
255 { |
|
256 if(!iDrawSections[i]->IsIdentical(aDrawSection)) |
|
257 continue; |
|
258 |
|
259 // Check if there is some drawsection that overlaps the section we found identical, |
|
260 // if that is the case it is not a duplicate |
|
261 for(TInt j = i + 1; j < count; j++) |
|
262 { |
|
263 TRect compareRect = iDrawSections[j]->DrawRect(); |
|
264 if(aDrawSection.DrawRect().Intersects(compareRect)) |
|
265 return EFalse; //Found a drawrect that overlapped, no duplicate exists then |
|
266 } |
|
267 |
|
268 // Found duplicate |
|
269 return ETrue; |
|
270 } |
|
271 |
|
272 return EFalse; |
|
273 } |
|
274 |
|
275 /** |
|
276 Updates the clippingregion for a specific drawsection. |
|
277 |
|
278 @param aDrawSectionIndex The index in iDrawSections of the drawsection to update the clippingregion for. |
|
279 */ |
|
280 void CCommandBuffer::UpdateClippingRegion(TInt aDrawSectionIndex) |
|
281 { |
|
282 __ASSERT_DEBUG(aDrawSectionIndex < iDrawSections.Count(), User::Invariant()); |
|
283 |
|
284 iDrawSectionClippingRegion.Clear(); |
|
285 if (iMasterClippingRegion) |
|
286 { |
|
287 iDrawSectionClippingRegion.Copy(*iMasterClippingRegion); |
|
288 } |
|
289 else |
|
290 { |
|
291 TRect rect = iMasterClippingRect; |
|
292 rect.Move(iMasterOrigin); |
|
293 iDrawSectionClippingRegion.AddRect(rect); |
|
294 } |
|
295 |
|
296 const TInt count = iDrawSections.Count(); |
|
297 for(TInt i = aDrawSectionIndex + 1; i < count; ++i) |
|
298 { |
|
299 TRect rect = iDrawSections[i]->DrawRect(); |
|
300 rect.Move(iMasterOrigin); |
|
301 iDrawSectionClippingRegion.SubRect(rect); |
|
302 } |
|
303 |
|
304 if (iDrawSectionClippingRegion.CheckError()) |
|
305 iActiveMasterClippingRegion = iMasterClippingRegion; |
|
306 else |
|
307 iActiveMasterClippingRegion = &iDrawSectionClippingRegion; |
|
308 } |
|
309 |
|
310 /** |
|
311 Writes data of a specific length to the recordbuffer. |
|
312 |
|
313 @param aPtr The data to write. |
|
314 @param aLength The length of the data to write. |
|
315 */ |
|
316 void CCommandBuffer::Write(const TUint8* aPtr, TUint aLength) |
|
317 { |
|
318 if(iError) |
|
319 return; |
|
320 |
|
321 TRAP(iError, iRecordSegBuf->InsertL(iRecordSegBuf->Size(), aPtr, aLength)) |
|
322 if(iError) |
|
323 return; |
|
324 } |
|
325 |
|
326 /** |
|
327 Writes text to the recordbuffer. |
|
328 |
|
329 @param aText The text to write to the recordbuffer. |
|
330 */ |
|
331 void CCommandBuffer::WriteText(const TDesC8 &aText) |
|
332 { |
|
333 if(iError) |
|
334 return; |
|
335 |
|
336 // Append the total size of the text |
|
337 Write<TInt>(aText.Size()); |
|
338 if(iError) |
|
339 return; |
|
340 |
|
341 TRAP(iError, DoWriteTextL(aText)); |
|
342 } |
|
343 |
|
344 /** |
|
345 Writes text to the recordbuffer. |
|
346 |
|
347 @param aText The text to write to the recordbuffer. |
|
348 */ |
|
349 void CCommandBuffer::WriteText(const TDesC16 &aText) |
|
350 { |
|
351 if(iError) |
|
352 return; |
|
353 |
|
354 // Append the total size of the text |
|
355 Write<TInt>(aText.Size()); |
|
356 if(iError) |
|
357 return; |
|
358 |
|
359 TPtrC8 textPtr(reinterpret_cast<const TUint8*>(aText.Ptr()),aText.Size()); |
|
360 TRAP(iError, DoWriteTextL(textPtr)); |
|
361 } |
|
362 |
|
363 /** |
|
364 Writes text to the recordbuffer. |
|
365 |
|
366 @param aText The text to write to the recordbuffer. |
|
367 */ |
|
368 void CCommandBuffer::DoWriteTextL(const TDesC8 &aText) |
|
369 { |
|
370 iRecordSegBuf->InsertL(iRecordSegBuf->Size(), aText, aText.Size()); |
|
371 } |
|
372 |
|
373 /** |
|
374 Reads data with a specific length from iBufReadStream. |
|
375 |
|
376 @param aPtr The read data is written to this paramenter. |
|
377 @param aLength The length of the data to be read. |
|
378 */ |
|
379 void CCommandBuffer::ReadL(TUint8* aPtr, TUint aLength) |
|
380 { |
|
381 iBufReadStream.ReadL(aPtr, aLength); |
|
382 } |
|
383 |
|
384 /** |
|
385 Reads text from iBufReadStream. |
|
386 |
|
387 @param aText The read text is put into this 8-bit buffer. |
|
388 */ |
|
389 void CCommandBuffer::ReadTextLC(TPtrC8& aText) |
|
390 { |
|
391 DoReadTextLC(aText,EFalse); |
|
392 } |
|
393 |
|
394 /** |
|
395 Reads text from iBufReadStream. |
|
396 |
|
397 @param aText The read text is put into this 16-bit buffer. |
|
398 */ |
|
399 void CCommandBuffer::ReadTextLC(TPtrC16& aText) |
|
400 { |
|
401 TPtrC8 text8; |
|
402 DoReadTextLC(text8,ETrue); |
|
403 aText.Set(reinterpret_cast<const TUint16*>(text8.Ptr()),text8.Size()/2); |
|
404 } |
|
405 |
|
406 /** |
|
407 Reads text from iBufReadStream; used by ReadTextLC |
|
408 |
|
409 @internalComponent |
|
410 */ |
|
411 void CCommandBuffer::DoReadTextLC(TPtrC8& aText,TBool a16Bit) |
|
412 { |
|
413 ASSERT(iBufRead); |
|
414 |
|
415 TInt textSize; |
|
416 ReadL<TInt>(textSize); // Read the length of the text |
|
417 if(0 > textSize) |
|
418 { |
|
419 User::Leave(KErrArgument); |
|
420 } |
|
421 |
|
422 // attempt to do it inline |
|
423 const TInt pos = iBufReadStream.Source()->TellL(MStreamBuf::ERead).Offset(); |
|
424 if(!a16Bit || !(pos & 1)) // check 16bit-aligned |
|
425 { |
|
426 const TPtrC8 remaining = iBufRead->Ptr(pos); |
|
427 if(remaining.Size() >= textSize) // can do inline! |
|
428 { |
|
429 CleanupStack::PushL((TAny*)NULL); // have to push something |
|
430 iBufReadStream.Source()->SeekL(MStreamBuf::ERead,textSize); |
|
431 aText.Set(remaining.Ptr(),textSize); |
|
432 return; |
|
433 } |
|
434 } |
|
435 |
|
436 // have to copy into a continuous segment |
|
437 HBufC8* buf = HBufC8::NewLC(textSize); |
|
438 TPtr8 textPtr8(buf->Des()); |
|
439 iBufReadStream.ReadL(textPtr8,textSize); |
|
440 aText.Set(*buf); |
|
441 } |
|
442 |
|
443 /** |
|
444 Compares the commands in one buffer to those in another |
|
445 @param aBuffer The buffer to compare to |
|
446 @return ETrue if they are an exact match, EFalse otherwise |
|
447 */ |
|
448 EXPORT_C TBool CCommandBuffer::IsIdentical(const CCommandBuffer & aBuffer) const |
|
449 { |
|
450 for(TInt i = 0; i < iDrawSections.Count(); ++i) |
|
451 { |
|
452 if (!iDrawSections[i]->IsIdentical(*aBuffer.iDrawSections[i])) |
|
453 return EFalse; |
|
454 } |
|
455 return ETrue; |
|
456 } |
|
457 |
|
458 /** |
|
459 @internalTechnology |
|
460 */ |
|
461 EXPORT_C TInt CCommandBuffer::Play(const TPoint& /*aPosition*/, const TRect& /*aDrawRect*/, const MWsGraphicResolver& /*aWsGraphicResolver*/, CBitmapContext& /*aContext*/) //Stub implementation to maintain compatibility with classic wserv |
|
462 { |
|
463 ASSERT(0); |
|
464 return KErrNotSupported; |
|
465 } |
|
466 |
|
467 /** |
|
468 @internalTechnology |
|
469 */ |
|
470 EXPORT_C TInt CCommandBuffer::Play(const TPoint& /*aMasterOrigin*/, const TRegion* /*aMasterClippingRegion*/, const TRect& /*aMasterClippingRect*/, const MWsGraphicResolver& /*aWsGraphicResolver*/, CBitmapContext& /*aBitmapContext*/) //Stub implementation to maintain compatibility with WSERV2 |
|
471 { |
|
472 ASSERT(0); |
|
473 return KErrNotSupported; |
|
474 } |
|
475 |
|
476 /** |
|
477 Draws draw commands that are within a specific rect to a graphics context with a specific offset. |
|
478 |
|
479 @post The draw commands have been executed on the provided graphics context |
|
480 |
|
481 @param aOffset The offset applied on all drawing operations. |
|
482 @param aClippingRegion The region to which all draw commands are clipped |
|
483 @param aSourceRect Draws only draw commands that are within this rect relative to the original coordinate system, i.e. before Position is applied |
|
484 @param aWsGraphicResolver The resolver to be used for DrawGraphic() calls. |
|
485 @param aGraphicsContext The graphics context to draw to. |
|
486 @publishedPartner |
|
487 */ |
|
488 EXPORT_C TInt CCommandBuffer::Play(const TPoint& aOffset, const TRegion* aClippingRegion, const TRect& aSourceRect, const MWsGraphicResolver& aWsGraphicResolver, MWsGraphicsContext& aGraphicsContext) |
|
489 { |
|
490 iMasterOrigin = aOffset; |
|
491 iMasterClippingRegion = aClippingRegion; |
|
492 iMasterClippingRect = aSourceRect; |
|
493 |
|
494 Reset(aGraphicsContext); |
|
495 TRAPD(err, { |
|
496 iDrawableCache = new(ELeave) CRenderStageDrawableCache(aGraphicsContext.ObjectInterface<MWsDrawableSourceProvider>()); |
|
497 DoPlayL(aWsGraphicResolver, aGraphicsContext); |
|
498 }); |
|
499 delete iDrawableCache; |
|
500 iDrawableCache = NULL; |
|
501 return err; |
|
502 } |
|
503 |
|
504 /** |
|
505 Draws draw commands that are within a specific rect to a graphics context with a specific offset. |
|
506 |
|
507 @post The draw commands have been executed on the provided graphics context |
|
508 |
|
509 @param aOffset The offset applied on all drawing operations. |
|
510 @param aClippingRegion The region to which all draw commands are clipped |
|
511 @param aSourceRect Draws only draw commands that are within this rect relative to the original coordinate system, i.e. before Position is applied |
|
512 @param aWsSession The session used to create the graphics context (WindowsGc) |
|
513 @param aWindowGc The graphics context to draw to. |
|
514 @publishedPartner |
|
515 */ |
|
516 EXPORT_C TInt CCommandBuffer::Play(const TPoint& aOffset, const TRegion* aClippingRegion, const TRect& aSourceRect, RWsSession& aWsSession, CWindowGc& aWindowGc) |
|
517 { |
|
518 iMasterOrigin = aOffset; |
|
519 iMasterClippingRegion = aClippingRegion; |
|
520 iMasterClippingRect = aSourceRect; |
|
521 |
|
522 Reset(aWindowGc); |
|
523 |
|
524 //Create a null version of MWsGraphicResolver which will never be used in this instance of the call to Play |
|
525 MWsGraphicResolver* graphicResolver = NULL; |
|
526 |
|
527 TRAPD(err, { |
|
528 iDrawableCache = new(ELeave) CWindowDrawableCache(aWsSession); |
|
529 DoPlayL(*graphicResolver, aWindowGc); |
|
530 }); |
|
531 delete iDrawableCache; |
|
532 iDrawableCache = NULL; |
|
533 return err; |
|
534 } |
|
535 |
|
536 /** |
|
537 Draws drawcommands that are within a specific rect. |
|
538 |
|
539 @param aWsGraphicResolver Any DrawWsGraphic commands will use this to draw themselves |
|
540 @param aGraphicsContext The graphics context to draw to. |
|
541 */ |
|
542 template<typename ContextType> void CCommandBuffer::DoPlayL(const MWsGraphicResolver& aWsGraphicResolver, ContextType& aGraphicsContext) |
|
543 { |
|
544 const TInt sections = iDrawSections.Count(); |
|
545 if(sections == 0) |
|
546 User::Leave(KErrEof); |
|
547 |
|
548 iBitmapCache->BeginUpdate(); |
|
549 iFontCache->BeginUpdate(); |
|
550 for(TInt i = 0; i < sections; i++) |
|
551 { |
|
552 UpdateClippingRegion(i); |
|
553 DrawSectionL(*iDrawSections[i], aWsGraphicResolver, aGraphicsContext); |
|
554 } |
|
555 iFontCache->EndUpdate(); |
|
556 iBitmapCache->EndUpdate(); |
|
557 } |
|
558 |
|
559 /** |
|
560 Draws a specific drawsection. |
|
561 |
|
562 @param aDrawSection The drawsection to be drawn. |
|
563 @param aWsGraphicResolver Any DrawWsGraphic commands will use this to draw themselves |
|
564 @param aGraphicsContext The graphics context to draw to. |
|
565 */ |
|
566 template<typename ContextType> void CCommandBuffer::DrawSectionL(const CDrawSection& aDrawSection, const MWsGraphicResolver& aWsGraphicResolver, ContextType& aGraphicsContext) |
|
567 { |
|
568 iDrawSectionRect = aDrawSection.DrawRect(); |
|
569 Reset(aGraphicsContext); |
|
570 |
|
571 iBufRead = aDrawSection.Buffer(); |
|
572 iBufReadStream.Open(*iBufRead, 0); |
|
573 |
|
574 TDrawCode drawCode; |
|
575 while(ETrue) |
|
576 { |
|
577 TRAPD(err, ReadL<TDrawCode>(drawCode)); |
|
578 if(err == KErrEof) |
|
579 return; |
|
580 else if(err) |
|
581 User::Leave(err); |
|
582 |
|
583 switch(drawCode) |
|
584 { |
|
585 case ECommandClear: |
|
586 Clear(aGraphicsContext); |
|
587 break; |
|
588 case ECommandClearRect: |
|
589 ClearRectL(aGraphicsContext); |
|
590 break; |
|
591 case ECommandCopyRect: |
|
592 CopyRectL(aGraphicsContext); |
|
593 break; |
|
594 case ECommandBitBlt1: |
|
595 BitBlt1L(aGraphicsContext); |
|
596 break; |
|
597 case ECommandBitBlt2: |
|
598 BitBlt2L(aGraphicsContext); |
|
599 break; |
|
600 case ECommandBitBltMasked: |
|
601 BitBltMaskedL(aGraphicsContext); |
|
602 break; |
|
603 case ECommandSetFaded: |
|
604 User::Leave(KErrNotSupported); //this op code is deprecated, should never be generated |
|
605 break; |
|
606 case ECommandSetFadingParameters: |
|
607 User::Leave(KErrNotSupported); //this op code is deprecated, should never be generated |
|
608 break; |
|
609 case ECommandAlphaBlendBitmaps: |
|
610 AlphaBlendBitmapsL(aGraphicsContext); |
|
611 break; |
|
612 case ECommandSetOrigin: |
|
613 SetOriginL(aGraphicsContext); |
|
614 break; |
|
615 case ECommandSetDrawMode: |
|
616 SetDrawModeL(aGraphicsContext); |
|
617 break; |
|
618 case ECommandSetClippingRect: |
|
619 SetClippingRectL(aGraphicsContext); |
|
620 break; |
|
621 case ECommandCancelClippingRect: |
|
622 CancelClippingRect(aGraphicsContext); |
|
623 break; |
|
624 case ECommandReset: |
|
625 Reset(aGraphicsContext); |
|
626 break; |
|
627 case ECommandUseFont: |
|
628 UseFontL(aGraphicsContext); |
|
629 break; |
|
630 case ECommandDiscardFont: |
|
631 DiscardFont(aGraphicsContext); |
|
632 break; |
|
633 case ECommandSetUnderlineStyle: |
|
634 SetUnderlineStyleL(aGraphicsContext); |
|
635 break; |
|
636 case ECommandSetStrikethroughStyle: |
|
637 SetStrikethroughStyleL(aGraphicsContext); |
|
638 break; |
|
639 case ECommandSetWordJustification: |
|
640 SetWordJustificationL(aGraphicsContext); |
|
641 break; |
|
642 case ECommandSetCharJustification: |
|
643 SetCharJustificationL(aGraphicsContext); |
|
644 break; |
|
645 case ECommandSetPenColor: |
|
646 SetPenColorL(aGraphicsContext); |
|
647 break; |
|
648 case ECommandSetPenStyle: |
|
649 SetPenStyleL(aGraphicsContext); |
|
650 break; |
|
651 case ECommandSetPenSize: |
|
652 SetPenSizeL(aGraphicsContext); |
|
653 break; |
|
654 case ECommandSetBrushColor: |
|
655 SetBrushColorL(aGraphicsContext); |
|
656 break; |
|
657 case ECommandSetBrushStyle: |
|
658 SetBrushStyleL(aGraphicsContext); |
|
659 break; |
|
660 case ECommandSetBrushOrigin: |
|
661 SetBrushOriginL(aGraphicsContext); |
|
662 break; |
|
663 case ECommandUseBrushPattern: |
|
664 UseBrushPatternL(aGraphicsContext); |
|
665 break; |
|
666 case ECommandDiscardBrushPattern: |
|
667 DiscardBrushPattern(aGraphicsContext); |
|
668 break; |
|
669 case ECommandMoveTo: |
|
670 MoveToL(aGraphicsContext); |
|
671 break; |
|
672 case ECommandMoveBy: |
|
673 MoveByL(aGraphicsContext); |
|
674 break; |
|
675 case ECommandPlot: |
|
676 PlotL(aGraphicsContext); |
|
677 break; |
|
678 case ECommandDrawArc: |
|
679 DrawArcL(aGraphicsContext); |
|
680 break; |
|
681 case ECommandDrawLine: |
|
682 DrawLineL(aGraphicsContext); |
|
683 break; |
|
684 case ECommandDrawLineTo: |
|
685 DrawLineToL(aGraphicsContext); |
|
686 break; |
|
687 case ECommandDrawLineBy: |
|
688 DrawLineByL(aGraphicsContext); |
|
689 break; |
|
690 case ECommandDrawPolyLine: |
|
691 DrawPolyLineL(aGraphicsContext); |
|
692 break; |
|
693 case ECommandDrawPie: |
|
694 DrawPieL(aGraphicsContext); |
|
695 break; |
|
696 case ECommandDrawEllipse: |
|
697 DrawEllipseL(aGraphicsContext); |
|
698 break; |
|
699 case ECommandDrawRect: |
|
700 DrawRectL(aGraphicsContext); |
|
701 break; |
|
702 case ECommandDrawPolygon: |
|
703 DrawPolygonL(aGraphicsContext); |
|
704 break; |
|
705 case ECommandDrawRoundRect: |
|
706 DrawRoundRectL(aGraphicsContext); |
|
707 break; |
|
708 case ECommandDrawBitmap1: |
|
709 DrawBitmap1L(aGraphicsContext); |
|
710 break; |
|
711 case ECommandDrawBitmap2: |
|
712 DrawBitmap2L(aGraphicsContext); |
|
713 break; |
|
714 case ECommandDrawBitmap3: |
|
715 DrawBitmap3L(aGraphicsContext); |
|
716 break; |
|
717 case ECommandDrawBitmapMasked: |
|
718 DrawBitmapMaskedL(aGraphicsContext); |
|
719 break; |
|
720 case ECommandDrawText1: |
|
721 DrawText1L(aGraphicsContext); |
|
722 break; |
|
723 case ECommandDrawText2: |
|
724 DrawText2L(aGraphicsContext); |
|
725 break; |
|
726 case ECommandDrawText3: |
|
727 DrawText3L(aGraphicsContext); |
|
728 break; |
|
729 case ECommandDrawText4: |
|
730 DrawText4L(aGraphicsContext); |
|
731 break; |
|
732 case ECommandDrawText5: |
|
733 DrawText5L(aGraphicsContext); |
|
734 break; |
|
735 case ECommandMapColors: |
|
736 User::Leave(KErrNotSupported); //this op code is deprecated, should never be generated |
|
737 break; |
|
738 case ECommandSetClippingRegion: |
|
739 SetClippingRegionL(aGraphicsContext); |
|
740 break; |
|
741 case ECommandCancelClippingRegion: |
|
742 CancelClippingRegion(aGraphicsContext); |
|
743 break; |
|
744 case ECommandDrawTextVertical1: |
|
745 DrawTextVertical1L(aGraphicsContext); |
|
746 break; |
|
747 case ECommandDrawTextVertical2: |
|
748 DrawTextVertical2L(aGraphicsContext); |
|
749 break; |
|
750 case ECommandDrawTextVertical3: |
|
751 DrawTextVertical3L(aGraphicsContext); |
|
752 break; |
|
753 case ECommandDrawTextVertical4: |
|
754 DrawTextVertical4L(aGraphicsContext); |
|
755 break; |
|
756 case ECommandDrawWsGraphic1: |
|
757 DrawWsGraphic1L(aWsGraphicResolver); |
|
758 break; |
|
759 case ECommandDrawWsGraphic2: |
|
760 DrawWsGraphic2L(aWsGraphicResolver); |
|
761 break; |
|
762 case ECommandSetShadowColor: |
|
763 SetShadowColorL(aGraphicsContext); |
|
764 break; |
|
765 case ECommandDrawResourceToPos: |
|
766 DrawResourceToPosL(aGraphicsContext); |
|
767 break; |
|
768 case ECommandDrawResourceToRect: |
|
769 DrawResourceToRectL(aGraphicsContext); |
|
770 break; |
|
771 case ECommandDrawResourceFromRectToRect: |
|
772 DrawResourceFromRectToRectL(aGraphicsContext); |
|
773 break; |
|
774 case ECommandDrawResourceWithData: |
|
775 DrawResourceWithDataL(aGraphicsContext); |
|
776 break; |
|
777 default: |
|
778 User::LeaveIfError(KErrNotFound); |
|
779 break; |
|
780 } |
|
781 } |
|
782 } |
|
783 |
|
784 template<typename ContextType> void CCommandBuffer::Clear(ContextType& aGraphicsContext) const |
|
785 { |
|
786 aGraphicsContext.Clear(); |
|
787 } |
|
788 |
|
789 template<typename ContextType> void CCommandBuffer::ClearRectL(ContextType& aGraphicsContext) |
|
790 { |
|
791 TRect rect; |
|
792 ReadL<TRect>(rect); |
|
793 |
|
794 aGraphicsContext.Clear(rect); |
|
795 } |
|
796 |
|
797 template<typename ContextType> void CCommandBuffer::CopyRectL(ContextType& aGraphicsContext) |
|
798 { |
|
799 TPoint point; |
|
800 TRect rect; |
|
801 |
|
802 ReadL<TPoint>(point); |
|
803 ReadL<TRect>(rect); |
|
804 |
|
805 aGraphicsContext.CopyRect(point, rect); |
|
806 } |
|
807 |
|
808 template<typename ContextType> void CCommandBuffer::BitBlt1L(ContextType& aGraphicsContext) |
|
809 { |
|
810 TPoint point; |
|
811 TInt handle; |
|
812 |
|
813 ReadL<TPoint>(point); |
|
814 ReadL<TInt>(handle); |
|
815 |
|
816 if(!iBitmapCache->UseL(handle)) |
|
817 DoBitBlt1L(aGraphicsContext, point, handle); |
|
818 } |
|
819 |
|
820 void CCommandBuffer::DoBitBlt1L(CWindowGc& aWindowGc, TPoint aPoint, TInt aHandle) |
|
821 { |
|
822 aWindowGc.BitBlt(aPoint, iBitmapCache->Resolve(aHandle)); |
|
823 } |
|
824 |
|
825 void CCommandBuffer::DoBitBlt1L(MWsGraphicsContext& aGraphicsContext, TPoint aPoint, TInt aHandle) |
|
826 { |
|
827 aGraphicsContext.BitBlt(aPoint, *iBitmapCache->Resolve(aHandle)); |
|
828 } |
|
829 |
|
830 template<typename ContextType> void CCommandBuffer::BitBlt2L(ContextType& aGraphicsContext) |
|
831 { |
|
832 TPoint point; |
|
833 TRect sourceRect; |
|
834 TInt handle; |
|
835 |
|
836 ReadL<TPoint>(point); |
|
837 ReadL<TInt>(handle); |
|
838 ReadL<TRect>(sourceRect); |
|
839 |
|
840 if(!iBitmapCache->UseL(handle)) |
|
841 DoBitBlt2L(aGraphicsContext, point, handle, sourceRect); |
|
842 } |
|
843 |
|
844 void CCommandBuffer::DoBitBlt2L(CWindowGc& aWindowGc, TPoint aPoint, TInt aHandle, TRect aSourceRect) |
|
845 { |
|
846 aWindowGc.BitBlt(aPoint, iBitmapCache->Resolve(aHandle), aSourceRect); |
|
847 } |
|
848 |
|
849 void CCommandBuffer::DoBitBlt2L(MWsGraphicsContext& aGraphicsContext, TPoint aPoint, TInt aHandle, TRect aSourceRect) |
|
850 { |
|
851 aGraphicsContext.BitBlt(aPoint, *iBitmapCache->Resolve(aHandle), aSourceRect); |
|
852 } |
|
853 |
|
854 template<typename ContextType> void CCommandBuffer::BitBltMaskedL(ContextType& aGraphicsContext) |
|
855 { |
|
856 TPoint point; |
|
857 TInt bitmapHandle; |
|
858 TRect sourceRect; |
|
859 TInt maskHandle; |
|
860 TBool invertedMask; |
|
861 |
|
862 ReadL<TPoint>(point); |
|
863 ReadL<TInt>(bitmapHandle); |
|
864 ReadL<TRect>(sourceRect); |
|
865 ReadL<TInt>(maskHandle); |
|
866 ReadL<TBool>(invertedMask); |
|
867 |
|
868 if(!iBitmapCache->UseL(bitmapHandle) && !iBitmapCache->UseL(maskHandle)) |
|
869 DoBitBltMaskedL(aGraphicsContext, point, bitmapHandle, sourceRect, maskHandle, invertedMask); |
|
870 } |
|
871 |
|
872 void CCommandBuffer::DoBitBltMaskedL(CWindowGc& aWindowGc, TPoint aPoint, TInt aBitmapHandle, TRect aSourceRect, TInt aMaskHandle, TBool aInvertMask) |
|
873 { |
|
874 aWindowGc.BitBltMasked(aPoint, iBitmapCache->Resolve(aBitmapHandle), aSourceRect, iBitmapCache->Resolve(aMaskHandle), aInvertMask); |
|
875 } |
|
876 |
|
877 void CCommandBuffer::DoBitBltMaskedL(MWsGraphicsContext& aGraphicsContext, TPoint aPoint, TInt aBitmapHandle, TRect aSourceRect, TInt aMaskHandle, TBool aInvertMask) |
|
878 { |
|
879 aGraphicsContext.BitBltMasked(aPoint, *iBitmapCache->Resolve(aBitmapHandle), aSourceRect, *iBitmapCache->Resolve(aMaskHandle), aInvertMask); |
|
880 } |
|
881 |
|
882 template<typename ContextType> void CCommandBuffer::AlphaBlendBitmapsL(ContextType& aGraphicsContext) |
|
883 { |
|
884 TPoint destPoint; |
|
885 TInt srcHandle; |
|
886 TRect sourceRect; |
|
887 TInt alphaHandle; |
|
888 TPoint alphaPoint; |
|
889 |
|
890 ReadL<TPoint>(destPoint); |
|
891 ReadL<TInt>(srcHandle); |
|
892 ReadL<TRect>(sourceRect); |
|
893 ReadL<TInt>(alphaHandle); |
|
894 ReadL<TPoint>(alphaPoint); |
|
895 |
|
896 if(!iBitmapCache->UseL(srcHandle) && !iBitmapCache->UseL(alphaHandle)) |
|
897 DoAlphaBlendBitmapsL(aGraphicsContext, destPoint, srcHandle, sourceRect, alphaHandle, alphaPoint); |
|
898 } |
|
899 |
|
900 void CCommandBuffer::DoAlphaBlendBitmapsL(CWindowGc& aWindowGc, TPoint aDestPoint, TInt aSrcHandle, TRect aSourceRect, TInt aAlphaHandle, TPoint aAlphaPoint) |
|
901 { |
|
902 aWindowGc.AlphaBlendBitmaps(aDestPoint, iBitmapCache->Resolve(aSrcHandle), aSourceRect, iBitmapCache->Resolve(aAlphaHandle), aAlphaPoint); |
|
903 } |
|
904 |
|
905 void CCommandBuffer::DoAlphaBlendBitmapsL(MWsGraphicsContext& aGraphicsContext, TPoint aDestPoint, TInt aSrcHandle, TRect aSourceRect, TInt aAlphaHandle, TPoint aAlphaPoint) |
|
906 { |
|
907 aGraphicsContext.BitBltMasked(aDestPoint, *iBitmapCache->Resolve(aSrcHandle), aSourceRect, *iBitmapCache->Resolve(aAlphaHandle), aAlphaPoint); |
|
908 } |
|
909 |
|
910 template<typename ContextType> void CCommandBuffer::SetOriginL(ContextType& aGraphicsContext) |
|
911 { |
|
912 ReadL<TPoint>(iOrigin); |
|
913 aGraphicsContext.SetOrigin(iMasterOrigin + iOrigin); |
|
914 } |
|
915 |
|
916 template<typename ContextType> void CCommandBuffer::SetDrawModeL(ContextType& aGraphicsContext) |
|
917 { |
|
918 CGraphicsContext::TDrawMode drawMode; |
|
919 ReadL<CGraphicsContext::TDrawMode>(drawMode); |
|
920 |
|
921 DoSetDrawModeL(aGraphicsContext, drawMode); |
|
922 } |
|
923 |
|
924 void CCommandBuffer::DoSetDrawModeL(CWindowGc& aWindowGc, CGraphicsContext::TDrawMode aDrawMode) |
|
925 { |
|
926 aWindowGc.SetDrawMode(aDrawMode); |
|
927 } |
|
928 |
|
929 void CCommandBuffer::DoSetDrawModeL(MWsGraphicsContext& aGraphicsContext, CGraphicsContext::TDrawMode aDrawMode) |
|
930 { |
|
931 aGraphicsContext.SetDrawMode(BitGdiToMWsGraphicsContextMappings::LossyConvert(aDrawMode)); |
|
932 } |
|
933 |
|
934 template<typename ContextType> void CCommandBuffer::SetClippingRectL(ContextType& aGraphicsContext) |
|
935 { |
|
936 ReadL<TRect>(iClippingRect); |
|
937 iClippingRect.Intersection(iMasterClippingRect); |
|
938 iClippingRect.Intersection(iDrawSectionRect); |
|
939 |
|
940 //Replacement for SetClippingRect functionality which MWsGraphicsContext does not support |
|
941 iIntersectedRegion.Clear(); |
|
942 if(iActiveMasterClippingRegion->Count() > 0) |
|
943 iIntersectedRegion.Copy(*iActiveMasterClippingRegion); |
|
944 iIntersectedRegion.ClipRect(iClippingRect); |
|
945 aGraphicsContext.SetClippingRegion(iIntersectedRegion); |
|
946 } |
|
947 |
|
948 template<typename ContextType> void CCommandBuffer::CancelClippingRect(ContextType& aGraphicsContext) |
|
949 { |
|
950 iClippingRect = iMasterClippingRect; |
|
951 iClippingRect.Intersection(iDrawSectionRect); |
|
952 |
|
953 //Replacement for SetClippingRect functionality which MWsGraphicsContext does not support |
|
954 iIntersectedRegion.Clear(); |
|
955 if(iActiveMasterClippingRegion && iActiveMasterClippingRegion->Count() > 0) |
|
956 iIntersectedRegion.Copy(*iActiveMasterClippingRegion); |
|
957 iIntersectedRegion.ClipRect(iClippingRect); |
|
958 aGraphicsContext.SetClippingRegion(iIntersectedRegion); |
|
959 } |
|
960 |
|
961 void CCommandBuffer::Reset(CWindowGc& aWindowGc) |
|
962 { |
|
963 aWindowGc.Reset(); |
|
964 |
|
965 aWindowGc.SetOrigin(iMasterOrigin); |
|
966 if(iActiveMasterClippingRegion) |
|
967 aWindowGc.SetClippingRegion(*iActiveMasterClippingRegion); |
|
968 CancelClippingRect(aWindowGc); |
|
969 iOrigin = TPoint(0,0); |
|
970 iClippingRegion.Clear(); |
|
971 iParsedClippingRegionIsSet = EFalse; |
|
972 } |
|
973 |
|
974 void CCommandBuffer::Reset(MWsGraphicsContext& aGraphicsContext) |
|
975 { |
|
976 aGraphicsContext.Reset(); |
|
977 |
|
978 TRgb brushColor = KRgbWhite; |
|
979 brushColor.SetAlpha(0); //make transparent |
|
980 aGraphicsContext.SetBrushColor(brushColor); |
|
981 |
|
982 aGraphicsContext.SetOrigin(iMasterOrigin); |
|
983 if(iActiveMasterClippingRegion) |
|
984 aGraphicsContext.SetClippingRegion(*iActiveMasterClippingRegion); |
|
985 CancelClippingRect(aGraphicsContext); |
|
986 iOrigin = TPoint(0,0); |
|
987 iClippingRegion.Clear(); |
|
988 iParsedClippingRegionIsSet = EFalse; |
|
989 } |
|
990 |
|
991 template<typename ContextType> void CCommandBuffer::UseFontL(ContextType& aGraphicsContext) |
|
992 { |
|
993 TInt fontHandle; |
|
994 ReadL<TInt>(fontHandle); |
|
995 if(iFontCache->UseL(fontHandle)) return; |
|
996 |
|
997 DoUseFontL(aGraphicsContext, fontHandle); |
|
998 } |
|
999 |
|
1000 void CCommandBuffer::DoUseFontL(CWindowGc& aWindowGc, TInt aFontHandle) |
|
1001 { |
|
1002 aWindowGc.UseFont(iFontCache->Resolve(aFontHandle)); |
|
1003 } |
|
1004 |
|
1005 void CCommandBuffer::DoUseFontL(MWsGraphicsContext& aGraphicsContext, TInt aFontHandle) |
|
1006 { |
|
1007 aGraphicsContext.SetFont(iFontCache->Resolve(aFontHandle)); |
|
1008 } |
|
1009 |
|
1010 void CCommandBuffer::DiscardFont(CWindowGc& aWindowGc) const |
|
1011 { |
|
1012 aWindowGc.DiscardFont(); |
|
1013 } |
|
1014 |
|
1015 void CCommandBuffer::DiscardFont(MWsGraphicsContext& aGraphicsContext) const |
|
1016 { |
|
1017 aGraphicsContext.ResetFont(); |
|
1018 } |
|
1019 |
|
1020 template<typename ContextType> void CCommandBuffer::SetUnderlineStyleL(ContextType& aGraphicsContext) |
|
1021 { |
|
1022 TFontUnderline underlineStyle; |
|
1023 ReadL<TFontUnderline>(underlineStyle); |
|
1024 |
|
1025 DoSetUnderlineStyleL(aGraphicsContext, underlineStyle); |
|
1026 } |
|
1027 |
|
1028 void CCommandBuffer::DoSetUnderlineStyleL(CWindowGc& aWindowGc, TFontUnderline aUnderlineStyle) |
|
1029 { |
|
1030 aWindowGc.SetUnderlineStyle(aUnderlineStyle); |
|
1031 } |
|
1032 |
|
1033 void CCommandBuffer::DoSetUnderlineStyleL(MWsGraphicsContext& aGraphicsContext, TFontUnderline aUnderlineStyle) |
|
1034 { |
|
1035 aGraphicsContext.SetUnderlineStyle(BitGdiToMWsGraphicsContextMappings::Convert(aUnderlineStyle)); |
|
1036 } |
|
1037 |
|
1038 template<typename ContextType> void CCommandBuffer::SetStrikethroughStyleL(ContextType& aGraphicsContext) |
|
1039 { |
|
1040 TFontStrikethrough strikethroughStyle; |
|
1041 ReadL<TFontStrikethrough>(strikethroughStyle); |
|
1042 |
|
1043 DoSetStrikethroughStyleL(aGraphicsContext, strikethroughStyle); |
|
1044 } |
|
1045 |
|
1046 void CCommandBuffer::DoSetStrikethroughStyleL(CWindowGc& aWindowGc, TFontStrikethrough aStrikethroughStyle) |
|
1047 { |
|
1048 aWindowGc.SetStrikethroughStyle(aStrikethroughStyle); |
|
1049 } |
|
1050 |
|
1051 void CCommandBuffer::DoSetStrikethroughStyleL(MWsGraphicsContext& aGraphicsContext, TFontStrikethrough aStrikethroughStyle) |
|
1052 { |
|
1053 aGraphicsContext.SetStrikethroughStyle(BitGdiToMWsGraphicsContextMappings::Convert(aStrikethroughStyle)); |
|
1054 } |
|
1055 |
|
1056 template<typename ContextType> void CCommandBuffer::SetWordJustificationL(ContextType& aGraphicsContext) |
|
1057 { |
|
1058 TInt excessWidth; |
|
1059 TInt numGaps; |
|
1060 |
|
1061 ReadL<TInt>(excessWidth); |
|
1062 ReadL<TInt>(numGaps); |
|
1063 aGraphicsContext.SetWordJustification(excessWidth, numGaps); |
|
1064 } |
|
1065 |
|
1066 template<typename ContextType> void CCommandBuffer::SetCharJustificationL(ContextType& aGraphicsContext) |
|
1067 { |
|
1068 TInt excessWidth; |
|
1069 TInt numChars; |
|
1070 |
|
1071 ReadL<TInt>(excessWidth); |
|
1072 ReadL<TInt>(numChars); |
|
1073 aGraphicsContext.SetCharJustification(excessWidth, numChars); |
|
1074 } |
|
1075 |
|
1076 template<typename ContextType> void CCommandBuffer::SetPenColorL(ContextType& aGraphicsContext) |
|
1077 { |
|
1078 TRgb color; |
|
1079 ReadL<TRgb>(color); |
|
1080 |
|
1081 aGraphicsContext.SetPenColor(color); |
|
1082 } |
|
1083 |
|
1084 template<typename ContextType> void CCommandBuffer::SetPenStyleL(ContextType& aGraphicsContext) |
|
1085 { |
|
1086 CGraphicsContext::TPenStyle penStyle; |
|
1087 ReadL<CGraphicsContext::TPenStyle>(penStyle); |
|
1088 |
|
1089 DoSetPenStyleL(aGraphicsContext, penStyle); |
|
1090 } |
|
1091 |
|
1092 void CCommandBuffer::DoSetPenStyleL(CWindowGc& aWindowGc, CGraphicsContext::TPenStyle aPenStyle) |
|
1093 { |
|
1094 aWindowGc.SetPenStyle(aPenStyle); |
|
1095 } |
|
1096 |
|
1097 void CCommandBuffer::DoSetPenStyleL(MWsGraphicsContext& aGraphicsContext, CGraphicsContext::TPenStyle aPenStyle) |
|
1098 { |
|
1099 aGraphicsContext.SetPenStyle(BitGdiToMWsGraphicsContextMappings::Convert(aPenStyle)); |
|
1100 } |
|
1101 |
|
1102 template<typename ContextType> void CCommandBuffer::SetPenSizeL(ContextType& aGraphicsContext) |
|
1103 { |
|
1104 TSize size; |
|
1105 ReadL<TSize>(size); |
|
1106 |
|
1107 DoSetPenSizeL(aGraphicsContext, size); |
|
1108 } |
|
1109 |
|
1110 void CCommandBuffer::DoSetPenSizeL(CWindowGc& aWindowGc, TSize aSize) |
|
1111 { |
|
1112 aWindowGc.SetPenSize(aSize); |
|
1113 } |
|
1114 |
|
1115 void CCommandBuffer::DoSetPenSizeL(MWsGraphicsContext& aGraphicsContext, TSize aSize) |
|
1116 { |
|
1117 aGraphicsContext.SetPenSize(aSize); |
|
1118 } |
|
1119 |
|
1120 template<typename ContextType> void CCommandBuffer::SetBrushColorL(ContextType& aGraphicsContext) |
|
1121 { |
|
1122 TRgb color; |
|
1123 ReadL<TRgb>(color); |
|
1124 |
|
1125 aGraphicsContext.SetBrushColor(color); |
|
1126 } |
|
1127 |
|
1128 template<typename ContextType> void CCommandBuffer::SetBrushStyleL(ContextType& aGraphicsContext) |
|
1129 { |
|
1130 CGraphicsContext::TBrushStyle brushStyle; |
|
1131 ReadL<CGraphicsContext::TBrushStyle>(brushStyle); |
|
1132 |
|
1133 DoSetBrushStyleL(aGraphicsContext, brushStyle); |
|
1134 } |
|
1135 |
|
1136 void CCommandBuffer::DoSetBrushStyleL(CWindowGc& aWindowGc, CGraphicsContext::TBrushStyle aBrushStyle) |
|
1137 { |
|
1138 aWindowGc.SetBrushStyle(aBrushStyle); |
|
1139 } |
|
1140 |
|
1141 void CCommandBuffer::DoSetBrushStyleL(MWsGraphicsContext& aGraphicsContext, CGraphicsContext::TBrushStyle aBrushStyle) |
|
1142 { |
|
1143 aGraphicsContext.SetBrushStyle(BitGdiToMWsGraphicsContextMappings::Convert(aBrushStyle)); |
|
1144 } |
|
1145 |
|
1146 template<typename ContextType> void CCommandBuffer::SetBrushOriginL(ContextType& aGraphicsContext) |
|
1147 { |
|
1148 TPoint point; |
|
1149 ReadL<TPoint>(point); |
|
1150 |
|
1151 aGraphicsContext.SetBrushOrigin(point); |
|
1152 } |
|
1153 |
|
1154 template<typename ContextType> void CCommandBuffer::UseBrushPatternL(ContextType& aGraphicsContext) |
|
1155 { |
|
1156 TInt deviceHandle; |
|
1157 ReadL<TInt>(deviceHandle); |
|
1158 |
|
1159 if(iBitmapCache->UseL(deviceHandle)) return; |
|
1160 DoUseBrushPatternL(aGraphicsContext, deviceHandle); |
|
1161 } |
|
1162 |
|
1163 void CCommandBuffer::DoUseBrushPatternL(CWindowGc& aWindowGc, TInt aDeviceHandle) |
|
1164 { |
|
1165 aWindowGc.UseBrushPattern(iBitmapCache->Resolve(aDeviceHandle)); |
|
1166 } |
|
1167 |
|
1168 void CCommandBuffer::DoUseBrushPatternL(MWsGraphicsContext& aGraphicsContext, TInt aDeviceHandle) |
|
1169 { |
|
1170 aGraphicsContext.SetBrushPattern(*iBitmapCache->Resolve(aDeviceHandle)); |
|
1171 } |
|
1172 |
|
1173 void CCommandBuffer::DiscardBrushPattern(CWindowGc& aWindowGc) const |
|
1174 { |
|
1175 aWindowGc.DiscardBrushPattern(); |
|
1176 } |
|
1177 |
|
1178 void CCommandBuffer::DiscardBrushPattern(MWsGraphicsContext& aGraphicsContext) const |
|
1179 { |
|
1180 aGraphicsContext.ResetBrushPattern(); |
|
1181 } |
|
1182 |
|
1183 template<typename ContextType> void CCommandBuffer::MoveToL(ContextType& aGraphicsContext) |
|
1184 { |
|
1185 TPoint point; |
|
1186 ReadL<TPoint>(point); |
|
1187 |
|
1188 aGraphicsContext.MoveTo(point); |
|
1189 } |
|
1190 |
|
1191 template<typename ContextType> void CCommandBuffer::MoveByL(ContextType& aGraphicsContext) |
|
1192 { |
|
1193 TPoint point; |
|
1194 ReadL<TPoint>(point); |
|
1195 |
|
1196 aGraphicsContext.MoveBy(point); |
|
1197 } |
|
1198 |
|
1199 template<typename ContextType> void CCommandBuffer::PlotL(ContextType& aGraphicsContext) |
|
1200 { |
|
1201 TPoint point; |
|
1202 ReadL<TPoint>(point); |
|
1203 |
|
1204 aGraphicsContext.Plot(point); |
|
1205 } |
|
1206 |
|
1207 template<typename ContextType> void CCommandBuffer::DrawArcL(ContextType& aGraphicsContext) |
|
1208 { |
|
1209 TRect rect; |
|
1210 TPoint start; |
|
1211 TPoint end; |
|
1212 ReadL<TRect>(rect); |
|
1213 ReadL<TPoint>(start); |
|
1214 ReadL<TPoint>(end); |
|
1215 |
|
1216 aGraphicsContext.DrawArc(rect, start, end); |
|
1217 } |
|
1218 |
|
1219 template<typename ContextType> void CCommandBuffer::DrawLineL(ContextType& aGraphicsContext) |
|
1220 { |
|
1221 TPoint point1; |
|
1222 TPoint point2; |
|
1223 ReadL<TPoint>(point1); |
|
1224 ReadL<TPoint>(point2); |
|
1225 |
|
1226 aGraphicsContext.DrawLine(point1, point2); |
|
1227 } |
|
1228 |
|
1229 template<typename ContextType> void CCommandBuffer::DrawLineToL(ContextType& aGraphicsContext) |
|
1230 { |
|
1231 TPoint point; |
|
1232 ReadL<TPoint>(point); |
|
1233 |
|
1234 aGraphicsContext.DrawLineTo(point); |
|
1235 } |
|
1236 |
|
1237 template<typename ContextType> void CCommandBuffer::DrawLineByL(ContextType& aGraphicsContext) |
|
1238 { |
|
1239 TPoint point; |
|
1240 ReadL<TPoint>(point); |
|
1241 |
|
1242 aGraphicsContext.DrawLineBy(point); |
|
1243 } |
|
1244 |
|
1245 void CCommandBuffer::DrawPolyLineL(CWindowGc& aWindowGc) |
|
1246 { |
|
1247 TInt nrOfPoints; |
|
1248 ReadL<TInt>(nrOfPoints); |
|
1249 |
|
1250 CArrayFix<TPoint>* pointList = new (ELeave) CArrayFixFlat<TPoint>(5); |
|
1251 CleanupStack::PushL(pointList); |
|
1252 for(TInt i = 0; i < nrOfPoints; i++) |
|
1253 { |
|
1254 TPoint point; |
|
1255 ReadL<TPoint>(point); |
|
1256 pointList->AppendL(point); |
|
1257 } |
|
1258 |
|
1259 aWindowGc.DrawPolyLine(pointList); |
|
1260 CleanupStack::PopAndDestroy(pointList); |
|
1261 } |
|
1262 |
|
1263 void CCommandBuffer::DrawPolyLineL(MWsGraphicsContext& aGraphicsContext) |
|
1264 { |
|
1265 TInt nrOfPoints; |
|
1266 ReadL<TInt>(nrOfPoints); |
|
1267 |
|
1268 TPoint *points=(TPoint *)(nrOfPoints+1); |
|
1269 TArrayWrapper<TPoint> pointList(points, nrOfPoints); |
|
1270 |
|
1271 aGraphicsContext.DrawPolyLine(pointList); |
|
1272 } |
|
1273 |
|
1274 template<typename ContextType> void CCommandBuffer::DrawPieL(ContextType& aGraphicsContext) |
|
1275 { |
|
1276 TRect rect; |
|
1277 TPoint start; |
|
1278 TPoint end; |
|
1279 ReadL<TRect>(rect); |
|
1280 ReadL<TPoint>(start); |
|
1281 ReadL<TPoint>(end); |
|
1282 |
|
1283 aGraphicsContext.DrawPie(rect, start, end); |
|
1284 } |
|
1285 |
|
1286 template<typename ContextType> void CCommandBuffer::DrawEllipseL(ContextType& aGraphicsContext) |
|
1287 { |
|
1288 TRect rect; |
|
1289 ReadL<TRect>(rect); |
|
1290 |
|
1291 aGraphicsContext.DrawEllipse(rect); |
|
1292 } |
|
1293 |
|
1294 template<typename ContextType> void CCommandBuffer::DrawRectL(ContextType& aGraphicsContext) |
|
1295 { |
|
1296 TRect rect; |
|
1297 ReadL<TRect>(rect); |
|
1298 |
|
1299 aGraphicsContext.DrawRect(rect); |
|
1300 } |
|
1301 |
|
1302 template<typename ContextType> void CCommandBuffer::DrawRoundRectL(ContextType& aGraphicsContext) |
|
1303 { |
|
1304 TRect rect; |
|
1305 TSize ellipse; |
|
1306 ReadL<TRect>(rect); |
|
1307 ReadL<TSize>(ellipse); |
|
1308 |
|
1309 aGraphicsContext.DrawRoundRect(rect, ellipse); |
|
1310 } |
|
1311 |
|
1312 void CCommandBuffer::DrawPolygonL(CWindowGc& aWindowGc) |
|
1313 { |
|
1314 TInt nrOfPoints; |
|
1315 ReadL<TInt>(nrOfPoints); |
|
1316 |
|
1317 CArrayFix<TPoint>* pointList = new (ELeave) CArrayFixFlat<TPoint>(5); |
|
1318 CleanupStack::PushL(pointList); |
|
1319 for(TInt i = 0; i < nrOfPoints; i++) |
|
1320 { |
|
1321 TPoint point; |
|
1322 ReadL<TPoint>(point); |
|
1323 pointList->AppendL(point); |
|
1324 } |
|
1325 |
|
1326 CGraphicsContext::TFillRule fillRule; |
|
1327 ReadL<CGraphicsContext::TFillRule>(fillRule); |
|
1328 aWindowGc.DrawPolygon(pointList, fillRule); |
|
1329 CleanupStack::PopAndDestroy(pointList); |
|
1330 } |
|
1331 |
|
1332 void CCommandBuffer::DrawPolygonL(MWsGraphicsContext& aGraphicsContext) |
|
1333 { |
|
1334 TInt nrOfPoints; |
|
1335 ReadL<TInt>(nrOfPoints); |
|
1336 |
|
1337 TPoint *points=(TPoint *)(nrOfPoints+1); |
|
1338 TArrayWrapper<TPoint> pointList(points, nrOfPoints); |
|
1339 |
|
1340 CGraphicsContext::TFillRule fillRule; |
|
1341 ReadL<CGraphicsContext::TFillRule>(fillRule); |
|
1342 aGraphicsContext.DrawPolygon(pointList, BitGdiToMWsGraphicsContextMappings::Convert(fillRule)); |
|
1343 } |
|
1344 |
|
1345 void CCommandBuffer::DrawBitmap1L(CWindowGc& aWindowGc) |
|
1346 { |
|
1347 TPoint topLeft; |
|
1348 TInt bitmapHandle; |
|
1349 |
|
1350 ReadL<TPoint>(topLeft); |
|
1351 ReadL<TInt>(bitmapHandle); |
|
1352 |
|
1353 if(!iBitmapCache->UseL(bitmapHandle)) |
|
1354 aWindowGc.DrawBitmap(topLeft, iBitmapCache->Resolve(bitmapHandle)); |
|
1355 } |
|
1356 |
|
1357 void CCommandBuffer::DrawBitmap1L(MWsGraphicsContext& /*aGraphicsContext*/) |
|
1358 { |
|
1359 User::Leave(KErrNotSupported); //this op code is deprecated, should never be generated |
|
1360 } |
|
1361 |
|
1362 template<typename ContextType> void CCommandBuffer::DrawBitmap2L(ContextType& aGraphicsContext) |
|
1363 { |
|
1364 TRect destRect; |
|
1365 TInt bitmapHandle; |
|
1366 |
|
1367 ReadL<TRect>(destRect); |
|
1368 ReadL<TInt>(bitmapHandle); |
|
1369 |
|
1370 if(!iBitmapCache->UseL(bitmapHandle)) |
|
1371 DoDrawBitmap2L(aGraphicsContext, destRect, bitmapHandle); |
|
1372 } |
|
1373 |
|
1374 void CCommandBuffer::DoDrawBitmap2L(CWindowGc& aWindowGc, TRect aDestRect, TInt aBitmapHandle) |
|
1375 { |
|
1376 aWindowGc.DrawBitmap(aDestRect, iBitmapCache->Resolve(aBitmapHandle)); |
|
1377 } |
|
1378 |
|
1379 void CCommandBuffer::DoDrawBitmap2L(MWsGraphicsContext& aGraphicsContext, TRect aDestRect, TInt aBitmapHandle) |
|
1380 { |
|
1381 aGraphicsContext.DrawBitmap(aDestRect, *iBitmapCache->Resolve(aBitmapHandle)); |
|
1382 } |
|
1383 |
|
1384 template<typename ContextType> void CCommandBuffer::DrawBitmap3L(ContextType& aGraphicsContext) |
|
1385 { |
|
1386 TRect destRect; |
|
1387 TInt bitmapHandle; |
|
1388 TRect sourceRect; |
|
1389 |
|
1390 ReadL<TRect>(destRect); |
|
1391 ReadL<TInt>(bitmapHandle); |
|
1392 ReadL<TRect>(sourceRect); |
|
1393 |
|
1394 if(!iBitmapCache->UseL(bitmapHandle)) |
|
1395 DoDrawBitmap3L(aGraphicsContext, destRect, bitmapHandle, sourceRect); |
|
1396 } |
|
1397 |
|
1398 void CCommandBuffer::DoDrawBitmap3L(CWindowGc& aWindowGc, TRect aDestRect, TInt aBitmapHandle, TRect aSourceRect) |
|
1399 { |
|
1400 aWindowGc.DrawBitmap(aDestRect, iBitmapCache->Resolve(aBitmapHandle), aSourceRect); |
|
1401 } |
|
1402 |
|
1403 void CCommandBuffer::DoDrawBitmap3L(MWsGraphicsContext& aGraphicsContext, TRect aDestRect, TInt aBitmapHandle, TRect aSourceRect) |
|
1404 { |
|
1405 aGraphicsContext.DrawBitmap(aDestRect, *iBitmapCache->Resolve(aBitmapHandle), aSourceRect); |
|
1406 } |
|
1407 |
|
1408 template<typename ContextType> void CCommandBuffer::DrawBitmapMaskedL(ContextType& aGraphicsContext) |
|
1409 { |
|
1410 TRect destRect; |
|
1411 TInt bitmapHandle; |
|
1412 TRect sourceRect; |
|
1413 TInt maskHandle; |
|
1414 TBool invertedMask; |
|
1415 |
|
1416 ReadL<TRect>(destRect); |
|
1417 ReadL<TInt>(bitmapHandle); |
|
1418 ReadL<TRect>(sourceRect); |
|
1419 ReadL<TInt>(maskHandle); |
|
1420 ReadL<TBool>(invertedMask); |
|
1421 |
|
1422 if(!iBitmapCache->UseL(bitmapHandle) && !iBitmapCache->UseL(maskHandle)) |
|
1423 DoDrawBitmapMaskedL(aGraphicsContext, destRect, bitmapHandle, sourceRect, maskHandle, invertedMask); |
|
1424 } |
|
1425 |
|
1426 void CCommandBuffer::DoDrawBitmapMaskedL(CWindowGc& aWindowGc, TRect aDestRect, TInt aBitmapHandle, TRect aSourceRect, TInt aMaskHandle, TBool aInvertedMask) |
|
1427 { |
|
1428 aWindowGc.DrawBitmapMasked(aDestRect, iBitmapCache->Resolve(aBitmapHandle), aSourceRect, iBitmapCache->Resolve(aMaskHandle), aInvertedMask); |
|
1429 } |
|
1430 |
|
1431 void CCommandBuffer::DoDrawBitmapMaskedL(MWsGraphicsContext& aGraphicsContext, TRect aDestRect, TInt aBitmapHandle, TRect aSourceRect, TInt aMaskHandle, TBool aInvertedMask) |
|
1432 { |
|
1433 aGraphicsContext.DrawBitmapMasked(aDestRect, *iBitmapCache->Resolve(aBitmapHandle), aSourceRect, *iBitmapCache->Resolve(aMaskHandle), aInvertedMask); |
|
1434 } |
|
1435 |
|
1436 template<typename ContextType> void CCommandBuffer::DrawText1L(ContextType& aGraphicsContext) |
|
1437 { |
|
1438 TPtrC16 text; |
|
1439 TPoint point; |
|
1440 |
|
1441 ReadTextLC(text); |
|
1442 ReadL<TPoint>(point); |
|
1443 |
|
1444 DoDrawText1L(aGraphicsContext, text, point); |
|
1445 CleanupStack::PopAndDestroy(); // ReadTextLC |
|
1446 } |
|
1447 |
|
1448 void CCommandBuffer::DoDrawText1L(CWindowGc& aWindowGc, TPtrC16 aText, TPoint aPoint) |
|
1449 { |
|
1450 aWindowGc.DrawText(aText, aPoint); |
|
1451 } |
|
1452 |
|
1453 void CCommandBuffer::DoDrawText1L(MWsGraphicsContext& aGraphicsContext, TPtrC16 aText, TPoint aPoint) |
|
1454 { |
|
1455 aGraphicsContext.DrawText(aText, /*TTextParameters*/ NULL, aPoint); |
|
1456 } |
|
1457 |
|
1458 template<typename ContextType> void CCommandBuffer::DrawText2L(ContextType& aGraphicsContext) |
|
1459 { |
|
1460 TPtrC16 text; |
|
1461 TRect box; |
|
1462 TInt baselineOffset; |
|
1463 CGraphicsContext::TTextAlign horiz; |
|
1464 TInt leftMargin; |
|
1465 |
|
1466 ReadTextLC(text); |
|
1467 ReadL<TRect>(box); |
|
1468 ReadL<TInt>(baselineOffset); |
|
1469 ReadL<CGraphicsContext::TTextAlign>(horiz); |
|
1470 ReadL<TInt>(leftMargin); |
|
1471 |
|
1472 DoDrawText2L(aGraphicsContext, text, box, baselineOffset, horiz, leftMargin); |
|
1473 CleanupStack::PopAndDestroy(); // ReadTextLC |
|
1474 } |
|
1475 |
|
1476 void CCommandBuffer::DoDrawText2L(CWindowGc& aWindowGc, TPtrC16 aText, TRect aBox, TInt aBaselineOffset, CGraphicsContext::TTextAlign aHoriz, TInt aLeftMargin) |
|
1477 { |
|
1478 aWindowGc.DrawText(aText, aBox, aBaselineOffset, aHoriz, aLeftMargin); |
|
1479 } |
|
1480 |
|
1481 void CCommandBuffer::DoDrawText2L(MWsGraphicsContext& aGraphicsContext, TPtrC16 aText, TRect aBox, TInt aBaselineOffset, CGraphicsContext::TTextAlign aHoriz, TInt aLeftMargin) |
|
1482 { |
|
1483 aGraphicsContext.DrawText(aText, /*TTextParameters*/ NULL, aBox, aBaselineOffset, BitGdiToMWsGraphicsContextMappings::Convert(aHoriz), aLeftMargin); |
|
1484 } |
|
1485 |
|
1486 template<typename ContextType> void CCommandBuffer::DrawText3L(ContextType& aGraphicsContext) |
|
1487 { |
|
1488 TPtrC16 text; |
|
1489 TPoint point; |
|
1490 CGraphicsContext::TDrawTextParam param; |
|
1491 |
|
1492 ReadTextLC(text); |
|
1493 ReadL<TPoint>(point); |
|
1494 //This is now ignored in the implmentation in CGraphicsContext and hence will ignore it here. |
|
1495 ReadL<CGraphicsContext::TDrawTextParam>(param); |
|
1496 |
|
1497 DoDrawText3L(aGraphicsContext, text, point); |
|
1498 CleanupStack::PopAndDestroy(); //ReadTextLC |
|
1499 } |
|
1500 |
|
1501 void CCommandBuffer::DoDrawText3L(CWindowGc& aWindowGc, TPtrC16 aText, TPoint aPoint) |
|
1502 { |
|
1503 aWindowGc.DrawText(aText, aPoint); |
|
1504 } |
|
1505 |
|
1506 void CCommandBuffer::DoDrawText3L(MWsGraphicsContext& aGraphicsContext, TPtrC16 aText, TPoint aPoint) |
|
1507 { |
|
1508 aGraphicsContext.DrawText(aText, /*TTextParameters*/ NULL, aPoint); |
|
1509 } |
|
1510 |
|
1511 template<typename ContextType> void CCommandBuffer::DrawText4L(ContextType& aGraphicsContext) |
|
1512 { |
|
1513 TPtrC16 text; |
|
1514 CGraphicsContext::TTextParameters param; |
|
1515 TPoint point; |
|
1516 |
|
1517 ReadTextLC(text); |
|
1518 ReadL<CGraphicsContext::TTextParameters>(param); |
|
1519 ReadL<TPoint>(point); |
|
1520 |
|
1521 DoDrawText4L(aGraphicsContext, text, param, point); |
|
1522 CleanupStack::PopAndDestroy(); // ReadTextLC |
|
1523 } |
|
1524 |
|
1525 void CCommandBuffer::DoDrawText4L(CWindowGc& aWindowGc, TPtrC16 aText, CGraphicsContext::TTextParameters aParam, TPoint aPoint) |
|
1526 { |
|
1527 aWindowGc.DrawText(aText, &aParam, aPoint); |
|
1528 } |
|
1529 |
|
1530 void CCommandBuffer::DoDrawText4L(MWsGraphicsContext& aGraphicsContext, TPtrC16 aText, CGraphicsContext::TTextParameters aParam, TPoint aPoint) |
|
1531 { |
|
1532 aGraphicsContext.DrawText(aText, BitGdiToMWsGraphicsContextMappings::Convert(&aParam), aPoint); |
|
1533 } |
|
1534 |
|
1535 template<typename ContextType> void CCommandBuffer::DrawText5L(ContextType& aGraphicsContext) |
|
1536 { |
|
1537 TPtrC16 text; |
|
1538 CGraphicsContext::TTextParameters param; |
|
1539 TRect box; |
|
1540 TInt baselineOffset; |
|
1541 CGraphicsContext::TTextAlign horiz; |
|
1542 TInt leftMargin; |
|
1543 |
|
1544 ReadTextLC(text); |
|
1545 ReadL<CGraphicsContext::TTextParameters>(param); |
|
1546 ReadL<TRect>(box); |
|
1547 ReadL<TInt>(baselineOffset); |
|
1548 ReadL<CGraphicsContext::TTextAlign>(horiz); |
|
1549 ReadL<TInt>(leftMargin); |
|
1550 |
|
1551 DoDrawText5L(aGraphicsContext, text, param, box, baselineOffset, horiz, leftMargin); |
|
1552 CleanupStack::PopAndDestroy(); // ReadTextLC |
|
1553 } |
|
1554 |
|
1555 void CCommandBuffer::DoDrawText5L(CWindowGc& aWindowGc, TPtrC16 aText, CGraphicsContext::TTextParameters aParam, TRect aBox, TInt aBaselineOffset, CGraphicsContext::TTextAlign aHoriz, TInt aLeftMargin) |
|
1556 { |
|
1557 aWindowGc.DrawText(aText, &aParam, aBox, aBaselineOffset, aHoriz, aLeftMargin); |
|
1558 } |
|
1559 |
|
1560 void CCommandBuffer::DoDrawText5L(MWsGraphicsContext& aGraphicsContext, TPtrC16 aText, CGraphicsContext::TTextParameters aParam, TRect aBox, TInt aBaselineOffset, CGraphicsContext::TTextAlign aHoriz, TInt aLeftMargin) |
|
1561 { |
|
1562 aGraphicsContext.DrawText(aText, BitGdiToMWsGraphicsContextMappings::Convert(&aParam), aBox, aBaselineOffset, BitGdiToMWsGraphicsContextMappings::Convert(aHoriz), aLeftMargin); |
|
1563 } |
|
1564 |
|
1565 template<typename ContextType> void CCommandBuffer::SetClippingRegionL(ContextType& aGraphicsContext) |
|
1566 { |
|
1567 TInt nrOfRects; |
|
1568 ReadL<TInt>(nrOfRects); |
|
1569 |
|
1570 TRect rect; |
|
1571 iClippingRegion.Clear(); |
|
1572 for(TInt i = 0; i < nrOfRects; i++) |
|
1573 { |
|
1574 ReadL<TRect>(rect); |
|
1575 // rect.Move(iMasterOrigin); |
|
1576 iClippingRegion.AddRect(rect); |
|
1577 } |
|
1578 |
|
1579 iParsedClippingRegionIsSet = ETrue; |
|
1580 if(iActiveMasterClippingRegion) |
|
1581 iClippingRegion.Intersect(*iActiveMasterClippingRegion); |
|
1582 |
|
1583 if(!iClippingRect.IsEmpty()) |
|
1584 { |
|
1585 iClippingRegion.ClipRect(iClippingRect); |
|
1586 } |
|
1587 |
|
1588 aGraphicsContext.SetClippingRegion(iClippingRegion); |
|
1589 } |
|
1590 |
|
1591 template<typename ContextType> void CCommandBuffer::CancelClippingRegion(ContextType& aGraphicsContext) |
|
1592 { |
|
1593 iClippingRegion.Clear(); |
|
1594 iParsedClippingRegionIsSet = EFalse; |
|
1595 if(iActiveMasterClippingRegion) |
|
1596 aGraphicsContext.SetClippingRegion(*iActiveMasterClippingRegion); |
|
1597 else |
|
1598 DoCancelClippingRegion(aGraphicsContext); |
|
1599 } |
|
1600 |
|
1601 void CCommandBuffer::DoCancelClippingRegion(CWindowGc& aWindowGc) |
|
1602 { |
|
1603 aWindowGc.CancelClippingRegion(); |
|
1604 } |
|
1605 |
|
1606 void CCommandBuffer::DoCancelClippingRegion(MWsGraphicsContext& aGraphicsContext) |
|
1607 { |
|
1608 aGraphicsContext.ResetClippingRegion(); |
|
1609 } |
|
1610 |
|
1611 template<typename ContextType> void CCommandBuffer::DrawTextVertical1L(ContextType& aGraphicsContext) |
|
1612 { |
|
1613 TPtrC16 text; |
|
1614 TPoint point; |
|
1615 TBool up; |
|
1616 |
|
1617 ReadTextLC(text); |
|
1618 ReadL<TPoint>(point); |
|
1619 ReadL<TBool>(up); |
|
1620 |
|
1621 DoDrawTextVertical1L(aGraphicsContext, text, point, up); |
|
1622 CleanupStack::PopAndDestroy(); // ReadTextLC |
|
1623 } |
|
1624 |
|
1625 void CCommandBuffer::DoDrawTextVertical1L(CWindowGc& aWindowGc, TPtrC16 aText, TPoint aPoint, TBool aUp) |
|
1626 { |
|
1627 aWindowGc.DrawTextVertical(aText, aPoint, aUp); |
|
1628 } |
|
1629 |
|
1630 void CCommandBuffer::DoDrawTextVertical1L(MWsGraphicsContext& aGraphicsContext, TPtrC16 aText, TPoint aPoint, TBool aUp) |
|
1631 { |
|
1632 aGraphicsContext.DrawTextVertical(aText, /*TTextParameters*/ NULL, aPoint, aUp); |
|
1633 } |
|
1634 |
|
1635 template<typename ContextType> void CCommandBuffer::DrawTextVertical2L(ContextType& aGraphicsContext) |
|
1636 { |
|
1637 TPtrC16 text; |
|
1638 TRect box; |
|
1639 TInt baselineOffset; |
|
1640 TBool up; |
|
1641 CGraphicsContext::TTextAlign vertical; |
|
1642 TInt margin; |
|
1643 |
|
1644 ReadTextLC(text); |
|
1645 ReadL<TRect>(box); |
|
1646 ReadL<TInt>(baselineOffset); |
|
1647 ReadL<TBool>(up); |
|
1648 ReadL<CGraphicsContext::TTextAlign>(vertical); |
|
1649 ReadL<TInt>(margin); |
|
1650 |
|
1651 DoDrawTextVertical2L(aGraphicsContext, text, box, baselineOffset, up, vertical, margin); |
|
1652 CleanupStack::PopAndDestroy(); //ReadTextLC |
|
1653 } |
|
1654 |
|
1655 void CCommandBuffer::DoDrawTextVertical2L(CWindowGc& aWindowGc, TPtrC16 aText, TRect aBox, TInt aBaselineOffset, TBool aUp, CGraphicsContext::TTextAlign aVertical, TInt aMargin) |
|
1656 { |
|
1657 aWindowGc.DrawTextVertical(aText, aBox, aBaselineOffset, aUp, aVertical, aMargin); |
|
1658 } |
|
1659 |
|
1660 void CCommandBuffer::DoDrawTextVertical2L(MWsGraphicsContext& aGraphicsContext, TPtrC16 aText, TRect aBox, TInt aBaselineOffset, TBool aUp, CGraphicsContext::TTextAlign aVertical, TInt aMargin) |
|
1661 { |
|
1662 aGraphicsContext.DrawTextVertical(aText, /*TTextParameters*/ NULL, aBox, aBaselineOffset, aUp, BitGdiToMWsGraphicsContextMappings::Convert(aVertical), aMargin); |
|
1663 } |
|
1664 |
|
1665 template<typename ContextType> void CCommandBuffer::DrawTextVertical3L(ContextType& aGraphicsContext) |
|
1666 { |
|
1667 TPtrC16 text; |
|
1668 CGraphicsContext::TTextParameters param; |
|
1669 TPoint point; |
|
1670 TBool up; |
|
1671 |
|
1672 ReadTextLC(text); |
|
1673 ReadL<CGraphicsContext::TTextParameters>(param); |
|
1674 ReadL<TPoint>(point); |
|
1675 ReadL<TBool>(up); |
|
1676 |
|
1677 DoDrawTextVertical3L(aGraphicsContext, text, param, point, up); |
|
1678 CleanupStack::PopAndDestroy(); // ReadTextLC |
|
1679 } |
|
1680 |
|
1681 void CCommandBuffer::DoDrawTextVertical3L(CWindowGc& aWindowGc, TPtrC16 aText, CGraphicsContext::TTextParameters aParam, TPoint aPoint, TBool aUp) |
|
1682 { |
|
1683 aWindowGc.DrawTextVertical(aText, &aParam, aPoint, aUp); |
|
1684 } |
|
1685 |
|
1686 void CCommandBuffer::DoDrawTextVertical3L(MWsGraphicsContext& aGraphicsContext, TPtrC16 aText, CGraphicsContext::TTextParameters aParam, TPoint aPoint, TBool aUp) |
|
1687 { |
|
1688 aGraphicsContext.DrawTextVertical(aText, BitGdiToMWsGraphicsContextMappings::Convert(&aParam), aPoint, aUp); |
|
1689 } |
|
1690 |
|
1691 template<typename ContextType> void CCommandBuffer::DrawTextVertical4L(ContextType& aGraphicsContext) |
|
1692 { |
|
1693 TPtrC16 text; |
|
1694 CGraphicsContext::TTextParameters param; |
|
1695 TRect box; |
|
1696 TInt baselineOffset; |
|
1697 TBool up; |
|
1698 CGraphicsContext::TTextAlign vertical; |
|
1699 TInt margin; |
|
1700 |
|
1701 ReadTextLC(text); |
|
1702 ReadL<CGraphicsContext::TTextParameters>(param); |
|
1703 ReadL<TRect>(box); |
|
1704 ReadL<TInt>(baselineOffset); |
|
1705 ReadL<TBool>(up); |
|
1706 ReadL<CGraphicsContext::TTextAlign>(vertical); |
|
1707 ReadL<TInt>(margin); |
|
1708 |
|
1709 DoDrawTextVertical4L(aGraphicsContext, text, param, box, baselineOffset, up, vertical, margin); |
|
1710 CleanupStack::PopAndDestroy(); //ReadTextLC |
|
1711 } |
|
1712 |
|
1713 void CCommandBuffer::DoDrawTextVertical4L(CWindowGc& aWindowGc, TPtrC16 aText, CGraphicsContext::TTextParameters aParam, TRect aBox, TInt aBaselineOffset, TBool aUp, CGraphicsContext::TTextAlign aVertical, TInt aMargin) |
|
1714 { |
|
1715 aWindowGc.DrawTextVertical(aText, &aParam, aBox, aBaselineOffset, aUp, aVertical, aMargin); |
|
1716 } |
|
1717 |
|
1718 void CCommandBuffer::DoDrawTextVertical4L(MWsGraphicsContext& aGraphicsContext, TPtrC16 aText, CGraphicsContext::TTextParameters aParam, TRect aBox, TInt aBaselineOffset, TBool aUp, CGraphicsContext::TTextAlign aVertical, TInt aMargin) |
|
1719 { |
|
1720 aGraphicsContext.DrawTextVertical(aText, BitGdiToMWsGraphicsContextMappings::Convert(&aParam), aBox, aBaselineOffset, aUp, BitGdiToMWsGraphicsContextMappings::Convert(aVertical), aMargin); |
|
1721 } |
|
1722 |
|
1723 void CCommandBuffer::DrawWsGraphic1L(const MWsGraphicResolver& aWsGraphicResolver) |
|
1724 { |
|
1725 TInt id; |
|
1726 TBool isUid; |
|
1727 TRect rect; |
|
1728 |
|
1729 ReadL<TInt>(id); |
|
1730 ReadL<TBool>(isUid); |
|
1731 ReadL<TRect>(rect); |
|
1732 |
|
1733 aWsGraphicResolver.DrawWsGraphic(id,isUid,rect,KNullDesC8()); |
|
1734 } |
|
1735 |
|
1736 void CCommandBuffer::DrawWsGraphic2L(const MWsGraphicResolver& aWsGraphicResolver) |
|
1737 { |
|
1738 TInt id; |
|
1739 TBool isUid; |
|
1740 TRect rect; |
|
1741 |
|
1742 ReadL<TInt>(id); |
|
1743 ReadL<TBool>(isUid); |
|
1744 ReadL<TRect>(rect); |
|
1745 TPtrC8 text8; |
|
1746 ReadTextLC(text8); |
|
1747 |
|
1748 aWsGraphicResolver.DrawWsGraphic(id,isUid,rect,text8); |
|
1749 CleanupStack::PopAndDestroy(); //ReadTextLC |
|
1750 } |
|
1751 |
|
1752 template<typename ContextType> void CCommandBuffer::SetShadowColorL(ContextType& aGraphicsContext) |
|
1753 { |
|
1754 TRgb shadowColor; |
|
1755 ReadL<TRgb>(shadowColor); |
|
1756 |
|
1757 DoSetShadowColorL(aGraphicsContext, shadowColor); |
|
1758 } |
|
1759 |
|
1760 void CCommandBuffer::DoSetShadowColorL(CWindowGc& aWindowGc, TRgb aShadowColor) |
|
1761 { |
|
1762 aWindowGc.SetShadowColor(aShadowColor); |
|
1763 } |
|
1764 |
|
1765 void CCommandBuffer::DoSetShadowColorL(MWsGraphicsContext& aGraphicsContext, TRgb aShadowColor) |
|
1766 { |
|
1767 aGraphicsContext.SetTextShadowColor(aShadowColor); |
|
1768 } |
|
1769 |
|
1770 /** |
|
1771 Helper function to draw resource at specified position. The function extracts all required parameter from the stream. |
|
1772 */ |
|
1773 template<typename ContextType> void CCommandBuffer::DrawResourceToPosL(ContextType& aGraphicsContext) |
|
1774 { |
|
1775 TSgDrawableId drawableId; |
|
1776 TInt screenNumber; |
|
1777 TPoint pos; |
|
1778 CWindowGc::TGraphicsRotation rotation; |
|
1779 ReadL<TSgDrawableId>(drawableId); |
|
1780 ReadL<TInt>(screenNumber); |
|
1781 ReadL<TPoint>(pos); |
|
1782 ReadL<CWindowGc::TGraphicsRotation>(rotation); |
|
1783 if (iDrawableCache->UseL(drawableId, screenNumber) == KErrNone) |
|
1784 { |
|
1785 DoDrawResourceToPos(aGraphicsContext, iDrawableCache->Resolve(drawableId, screenNumber), pos, rotation); |
|
1786 } |
|
1787 } |
|
1788 |
|
1789 void CCommandBuffer::DoDrawResourceToPos(CWindowGc& aGraphicsContext, const TAny* aDrawableSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation) |
|
1790 { |
|
1791 MWsDrawResource* drawResource = static_cast<MWsDrawResource*>(aGraphicsContext.Interface(KMWsDrawResourceInterfaceUid)); |
|
1792 if(drawResource) |
|
1793 { |
|
1794 drawResource->DrawResource(aPos, *static_cast<const RWsDrawableSource*>(aDrawableSource), aRotation); |
|
1795 } |
|
1796 } |
|
1797 |
|
1798 void CCommandBuffer::DoDrawResourceToPos(MWsGraphicsContext& aGraphicsContext, const TAny* aDrawableSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation) |
|
1799 { |
|
1800 MWsDrawableSourceProvider* drawResource = aGraphicsContext.ObjectInterface<MWsDrawableSourceProvider>(); |
|
1801 if (drawResource) |
|
1802 { |
|
1803 drawResource->DrawResource(aDrawableSource, aPos, aRotation); |
|
1804 } |
|
1805 } |
|
1806 |
|
1807 /** |
|
1808 Helper function to draw resource into specified rectangle. The function extracts all required parameter from the stream. |
|
1809 */ |
|
1810 template<typename ContextType> void CCommandBuffer::DrawResourceToRectL(ContextType& aGraphicsContext) |
|
1811 { |
|
1812 TSgDrawableId drawableId; |
|
1813 TInt screenNumber; |
|
1814 TRect rect; |
|
1815 CWindowGc::TGraphicsRotation rotation; |
|
1816 ReadL<TSgDrawableId>(drawableId); |
|
1817 ReadL<TInt>(screenNumber); |
|
1818 ReadL<TRect>(rect); |
|
1819 ReadL<CWindowGc::TGraphicsRotation>(rotation); |
|
1820 |
|
1821 if (iDrawableCache->UseL(drawableId, screenNumber) == KErrNone) |
|
1822 { |
|
1823 DoDrawResourceToRect(aGraphicsContext, iDrawableCache->Resolve(drawableId, screenNumber), rect, rotation); |
|
1824 } |
|
1825 } |
|
1826 |
|
1827 void CCommandBuffer::DoDrawResourceToRect(CWindowGc& aGraphicsContext, const TAny* aDrawableSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation) |
|
1828 { |
|
1829 MWsDrawResource* drawResource = static_cast<MWsDrawResource*>(aGraphicsContext.Interface(KMWsDrawResourceInterfaceUid)); |
|
1830 if(drawResource) |
|
1831 { |
|
1832 drawResource->DrawResource(aRect, *static_cast<const RWsDrawableSource*>(aDrawableSource), aRotation); |
|
1833 } |
|
1834 } |
|
1835 |
|
1836 void CCommandBuffer::DoDrawResourceToRect(MWsGraphicsContext& aGraphicsContext, const TAny* aDrawableSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation) |
|
1837 { |
|
1838 MWsDrawableSourceProvider* drawResource = aGraphicsContext.ObjectInterface<MWsDrawableSourceProvider>(); |
|
1839 if (drawResource) |
|
1840 { |
|
1841 drawResource->DrawResource(aDrawableSource, aRect, aRotation); |
|
1842 } |
|
1843 } |
|
1844 |
|
1845 /** |
|
1846 Helper function to draw resource into specified rectangle from specified rectangle of the drawable. The function extracts all required parameter from the stream. |
|
1847 */ |
|
1848 template<typename ContextType> void CCommandBuffer::DrawResourceFromRectToRectL(ContextType& aGraphicsContext) |
|
1849 { |
|
1850 TSgDrawableId drawableId; |
|
1851 TInt screenNumber; |
|
1852 TRect rectDest; |
|
1853 TRect rectSrc; |
|
1854 CWindowGc::TGraphicsRotation rotation; |
|
1855 ReadL<TSgDrawableId>(drawableId); |
|
1856 ReadL<TInt>(screenNumber); |
|
1857 ReadL<TRect>(rectDest); |
|
1858 ReadL<TRect>(rectSrc); |
|
1859 ReadL<CWindowGc::TGraphicsRotation>(rotation); |
|
1860 |
|
1861 if (iDrawableCache->UseL(drawableId, screenNumber) == KErrNone) |
|
1862 { |
|
1863 DoDrawResourceFromRectToRect(aGraphicsContext, iDrawableCache->Resolve(drawableId, screenNumber), rectDest, rectSrc, rotation); |
|
1864 } |
|
1865 } |
|
1866 |
|
1867 void CCommandBuffer::DoDrawResourceFromRectToRect(CWindowGc& aGraphicsContext, const TAny* aDrawableSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation) |
|
1868 { |
|
1869 MWsDrawResource* drawResource = static_cast<MWsDrawResource*>(aGraphicsContext.Interface(KMWsDrawResourceInterfaceUid)); |
|
1870 if(drawResource) |
|
1871 { |
|
1872 drawResource->DrawResource(aRectDest, *static_cast<const RWsDrawableSource*>(aDrawableSource), aRectSrc, aRotation); |
|
1873 } |
|
1874 } |
|
1875 |
|
1876 void CCommandBuffer::DoDrawResourceFromRectToRect(MWsGraphicsContext& aGraphicsContext, const TAny* aDrawableSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation) |
|
1877 { |
|
1878 MWsDrawableSourceProvider* drawResource = aGraphicsContext.ObjectInterface<MWsDrawableSourceProvider>(); |
|
1879 if (drawResource) |
|
1880 { |
|
1881 drawResource->DrawResource(aDrawableSource, aRectDest, aRectSrc, aRotation); |
|
1882 } |
|
1883 } |
|
1884 |
|
1885 template<typename ContextType> void CCommandBuffer::DrawResourceWithDataL(ContextType& aGraphicsContext) |
|
1886 { |
|
1887 TSgDrawableId drawableId; |
|
1888 TInt screenNumber; |
|
1889 TRect rect; |
|
1890 TPtrC8 data; |
|
1891 ReadL<TSgDrawableId>(drawableId); |
|
1892 ReadL<TInt>(screenNumber); |
|
1893 ReadL<TRect>(rect); |
|
1894 ReadTextLC(data); |
|
1895 |
|
1896 if (iDrawableCache->UseL(drawableId, screenNumber) == KErrNone) |
|
1897 { |
|
1898 DoDrawResourceWithData(aGraphicsContext, iDrawableCache->Resolve(drawableId, screenNumber), rect, data); |
|
1899 } |
|
1900 |
|
1901 CleanupStack::PopAndDestroy(); //ReadTextLC |
|
1902 } |
|
1903 |
|
1904 void CCommandBuffer::DoDrawResourceWithData(CWindowGc& aGraphicsContext, const TAny* aDrawableSource, const TRect& aRect, const TDesC8& aParam) |
|
1905 { |
|
1906 MWsDrawResource* drawResource = static_cast<MWsDrawResource*>(aGraphicsContext.Interface(KMWsDrawResourceInterfaceUid)); |
|
1907 if(drawResource) |
|
1908 { |
|
1909 drawResource->DrawResource(aRect, *static_cast<const RWsDrawableSource*>(aDrawableSource), aParam); |
|
1910 } |
|
1911 } |
|
1912 |
|
1913 void CCommandBuffer::DoDrawResourceWithData(MWsGraphicsContext& aGraphicsContext, const TAny* aDrawableSource, const TRect& aRect, const TDesC8& aParam) |
|
1914 { |
|
1915 MWsDrawableSourceProvider* drawResource = aGraphicsContext.ObjectInterface<MWsDrawableSourceProvider>(); |
|
1916 if (drawResource) |
|
1917 { |
|
1918 drawResource->DrawResource(aDrawableSource, aRect, aParam); |
|
1919 } |
|
1920 } |