23 #include <graphics/gdi/gdistructs.h> |
23 #include <graphics/gdi/gdistructs.h> |
24 #endif // SYMBIAN_ENABLE_SPLIT_HEADERS |
24 #endif // SYMBIAN_ENABLE_SPLIT_HEADERS |
25 #include <e32err.h> |
25 #include <e32err.h> |
26 |
26 |
27 #include "aknrecordinggc.h" |
27 #include "aknrecordinggc.h" |
28 #include "akntrace.h" |
|
29 |
28 |
30 #ifdef _DEBUG |
29 #ifdef _DEBUG |
31 _LIT( KOverFlow, "Array overflow" ); |
30 _LIT( KOverFlow, "Array overflow" ); |
32 _LIT( KBadArgument, "Bad argument"); |
31 _LIT( KBadArgument, "Bad argument"); |
33 #endif // _DEBUG |
32 #endif // _DEBUG |
63 // CAknRecordingGc::~CAknRecordingGc |
62 // CAknRecordingGc::~CAknRecordingGc |
64 // ----------------------------------------------------------------------------- |
63 // ----------------------------------------------------------------------------- |
65 // |
64 // |
66 CAknRecordingGc::~CAknRecordingGc() |
65 CAknRecordingGc::~CAknRecordingGc() |
67 { |
66 { |
68 _AKNTRACE_FUNC_ENTER; |
|
69 iLines.ResetAndDestroy(); |
67 iLines.ResetAndDestroy(); |
70 delete iOffScreenBmp; |
68 delete iOffScreenBmp; |
71 delete iBitGc; |
69 delete iBitGc; |
72 delete iBitmapDevice; |
70 delete iBitmapDevice; |
73 _AKNTRACE_FUNC_EXIT; |
|
74 } |
71 } |
75 |
72 |
76 |
73 |
77 // ----------------------------------------------------------------------------- |
74 // ----------------------------------------------------------------------------- |
78 // CAknRecordingGc::FlushBuffer |
75 // CAknRecordingGc::FlushBuffer |
79 // ----------------------------------------------------------------------------- |
76 // ----------------------------------------------------------------------------- |
80 // |
77 // |
81 void CAknRecordingGc::FlushBuffer( const TRect& aRect, TInt aLineToSkip ) |
78 void CAknRecordingGc::FlushBuffer( const TRect& aRect, TInt aLineToSkip ) |
82 { |
79 { |
83 _AKNTRACE_FUNC_ENTER; |
|
84 _AKNTRACE( "The rect of FlushBuffer are ( %d, %d ) ( %d, %d )", |
|
85 aRect.iTl.iX, aRect.iTl.iY, |
|
86 aRect.iBr.iX, aRect.iBr.iY ); |
|
87 _AKNTRACE( "[%s][%s]aLineToSkip: [%d]", "CAknRecordingGc", __FUNCTION__, aLineToSkip ); |
|
88 if ( iLines.Count() == 0 ) |
80 if ( iLines.Count() == 0 ) |
89 { |
81 { |
90 return; |
82 return; |
91 } |
83 } |
92 |
84 |
173 break; |
165 break; |
174 |
166 |
175 case CBufferItem::EDrawRect: |
167 case CBufferItem::EDrawRect: |
176 gc->DrawRect( item->iRect ); |
168 gc->DrawRect( item->iRect ); |
177 break; |
169 break; |
178 |
|
179 case CBufferItem::EClear: |
170 case CBufferItem::EClear: |
180 gc->Clear( item->iRect ); |
171 gc->Clear( item->iRect ); |
181 break; |
|
182 |
|
183 case CBufferItem::EDrawLine: |
|
184 // EDrawLine is used for separator line only and it |
|
185 // should be skipped for the last visible item. |
|
186 if ( i < iLines.Count() - 1 ) |
|
187 { |
|
188 gc->DrawLine( item->iRect.iTl, item->iRect.iBr ); |
|
189 } |
|
190 break; |
|
191 |
|
192 case CBufferItem::EUseBrushPattern: |
|
193 gc->UseBrushPattern( item->iBitmap ); |
|
194 break; |
|
195 |
|
196 case CBufferItem::EDiscardBrushPattern: |
|
197 gc->DiscardBrushPattern(); |
|
198 break; |
172 break; |
199 } |
173 } |
200 } |
174 } |
201 |
175 |
202 gc->CancelClippingRect(); |
176 gc->CancelClippingRect(); |
216 |
190 |
217 if ( iUseBitGc ) |
191 if ( iUseBitGc ) |
218 { |
192 { |
219 iRealGc->BitBlt( TPoint( 0, 0 ), iOffScreenBmp, TRect( 0, 0, 360, 500 ) ); |
193 iRealGc->BitBlt( TPoint( 0, 0 ), iOffScreenBmp, TRect( 0, 0, 360, 500 ) ); |
220 } |
194 } |
221 _AKNTRACE_FUNC_EXIT; |
|
222 } |
195 } |
223 |
196 |
224 |
197 |
225 // ----------------------------------------------------------------------------- |
198 // ----------------------------------------------------------------------------- |
226 // CAknRecordingGc::PurgeBuffer |
199 // CAknRecordingGc::PurgeBuffer |
237 // CAknRecordingGc::PrepareForNewLineL |
210 // CAknRecordingGc::PrepareForNewLineL |
238 // ----------------------------------------------------------------------------- |
211 // ----------------------------------------------------------------------------- |
239 // |
212 // |
240 void CAknRecordingGc::PrepareForNewLineL( const TRect& aRect ) |
213 void CAknRecordingGc::PrepareForNewLineL( const TRect& aRect ) |
241 { |
214 { |
242 _AKNTRACE_FUNC_ENTER; |
|
243 CLineData* newLine = new ( ELeave ) CLineData; |
215 CLineData* newLine = new ( ELeave ) CLineData; |
244 newLine->iRect = aRect; |
216 newLine->iRect = aRect; |
245 iLines.AppendL( newLine ); |
217 iLines.AppendL( newLine ); |
246 iCurrentLine = iLines.Count() - 1; |
218 iCurrentLine = iLines.Count() - 1; |
247 _AKNTRACE_FUNC_EXIT; |
|
248 } |
219 } |
249 |
220 |
250 |
221 |
251 // ----------------------------------------------------------------------------- |
222 // ----------------------------------------------------------------------------- |
252 // CAknRecordingGc::ReplaceLineL |
223 // CAknRecordingGc::ReplaceLineL |
253 // ----------------------------------------------------------------------------- |
224 // ----------------------------------------------------------------------------- |
254 // |
225 // |
255 void CAknRecordingGc::ReplaceLineL( TInt aLine ) |
226 void CAknRecordingGc::ReplaceLineL( TInt aLine ) |
256 { |
227 { |
257 _AKNTRACE_FUNC_ENTER; |
|
258 _AKNTRACE( "[%s][%s]aLine: [%d].", "CAknRecordingGc", __FUNCTION__, aLine ); |
|
259 if ( aLine < iLines.Count() ) |
228 if ( aLine < iLines.Count() ) |
260 { |
229 { |
261 TRect rect( iLines[aLine]->iRect ); |
230 TRect rect( iLines[aLine]->iRect ); |
262 |
231 |
263 delete iLines[aLine]; |
232 delete iLines[aLine]; |
265 iLines[aLine] = new ( ELeave ) CLineData; |
234 iLines[aLine] = new ( ELeave ) CLineData; |
266 iLines[aLine]->iRect = rect; |
235 iLines[aLine]->iRect = rect; |
267 } |
236 } |
268 |
237 |
269 iCurrentLine = aLine; |
238 iCurrentLine = aLine; |
270 _AKNTRACE_FUNC_EXIT; |
|
271 } |
239 } |
272 |
240 |
273 |
241 |
274 // ----------------------------------------------------------------------------- |
242 // ----------------------------------------------------------------------------- |
275 // CAknRecordingGc::UseBitGc |
243 // CAknRecordingGc::UseBitGc |
285 // CAknRecordingGc::InsertLineL |
253 // CAknRecordingGc::InsertLineL |
286 // ----------------------------------------------------------------------------- |
254 // ----------------------------------------------------------------------------- |
287 // |
255 // |
288 void CAknRecordingGc::InsertLineL( TInt aLine, const TRect& aRect ) |
256 void CAknRecordingGc::InsertLineL( TInt aLine, const TRect& aRect ) |
289 { |
257 { |
290 _AKNTRACE_FUNC_ENTER; |
|
291 _AKNTRACE( "[%s][%s]aLine: [%d].", "CAknRecordingGc", __FUNCTION__, aLine ); |
|
292 CLineData* newLine = new ( ELeave ) CLineData; |
258 CLineData* newLine = new ( ELeave ) CLineData; |
293 newLine->iRect = aRect; |
259 newLine->iRect = aRect; |
294 |
260 |
295 iLines.Insert( newLine, aLine ); |
261 iLines.Insert( newLine, aLine ); |
296 iCurrentLine = aLine; |
262 iCurrentLine = aLine; |
297 _AKNTRACE_FUNC_EXIT; |
|
298 } |
263 } |
299 |
264 |
300 |
265 |
301 // ----------------------------------------------------------------------------- |
266 // ----------------------------------------------------------------------------- |
302 // CAknRecordingGc::InsertLineL |
267 // CAknRecordingGc::InsertLineL |
347 // CAknRecordingGc::DeleteLine |
312 // CAknRecordingGc::DeleteLine |
348 // ----------------------------------------------------------------------------- |
313 // ----------------------------------------------------------------------------- |
349 // |
314 // |
350 void CAknRecordingGc::DeleteLine( TInt aLine ) |
315 void CAknRecordingGc::DeleteLine( TInt aLine ) |
351 { |
316 { |
352 _AKNTRACE_FUNC_ENTER; |
|
353 _AKNTRACE( "[%s][%s]aLine: [%d].", "CAknRecordingGc", __FUNCTION__, aLine ); |
|
354 if ( aLine != -1 && aLine < iLines.Count() ) |
317 if ( aLine != -1 && aLine < iLines.Count() ) |
355 { |
318 { |
356 delete iLines[aLine]; |
319 delete iLines[aLine]; |
357 iLines.Remove( aLine ); |
320 iLines.Remove( aLine ); |
358 } |
321 } |
359 _AKNTRACE_FUNC_EXIT; |
|
360 } |
322 } |
361 |
323 |
362 |
324 |
363 // ----------------------------------------------------------------------------- |
325 // ----------------------------------------------------------------------------- |
364 // CAknRecordingGc::CBufferItem::~CBufferItem() |
326 // CAknRecordingGc::CBufferItem::~CBufferItem() |
617 |
579 |
618 // --------------------------------------------------------------------------- |
580 // --------------------------------------------------------------------------- |
619 // From class CWindowGc |
581 // From class CWindowGc |
620 // --------------------------------------------------------------------------- |
582 // --------------------------------------------------------------------------- |
621 // |
583 // |
622 void CAknRecordingGc::UseBrushPattern( const CFbsBitmap* aDevice ) |
584 void CAknRecordingGc::UseBrushPattern( const CFbsBitmap* /*aDevice*/ ) |
623 { |
585 { |
624 CBufferItem* buffer = BufferItem(); |
|
625 buffer->iType = CBufferItem::EUseBrushPattern; |
|
626 |
|
627 CFbsBitmap* bitmap = NULL; |
|
628 TRAP_IGNORE( bitmap = new (ELeave) CFbsBitmap() ); |
|
629 bitmap->Duplicate(aDevice->Handle()); |
|
630 buffer->iBitmap = bitmap; |
|
631 } |
586 } |
632 |
587 |
633 |
588 |
634 // --------------------------------------------------------------------------- |
589 // --------------------------------------------------------------------------- |
635 // From class CWindowGc |
590 // From class CWindowGc |
636 // --------------------------------------------------------------------------- |
591 // --------------------------------------------------------------------------- |
637 // |
592 // |
638 void CAknRecordingGc::DiscardBrushPattern() |
593 void CAknRecordingGc::DiscardBrushPattern() |
639 { |
594 { |
640 CBufferItem* buffer = BufferItem(); |
|
641 buffer->iType = CBufferItem::EDiscardBrushPattern; |
|
642 } |
595 } |
643 |
596 |
644 |
597 |
645 // --------------------------------------------------------------------------- |
598 // --------------------------------------------------------------------------- |
646 // From class CWindowGc |
599 // From class CWindowGc |
681 |
634 |
682 // --------------------------------------------------------------------------- |
635 // --------------------------------------------------------------------------- |
683 // From class CWindowGc |
636 // From class CWindowGc |
684 // --------------------------------------------------------------------------- |
637 // --------------------------------------------------------------------------- |
685 // |
638 // |
686 void CAknRecordingGc::DrawLine( const TPoint& aPoint1, |
639 void CAknRecordingGc::DrawLine( const TPoint& /*aPoint1*/, |
687 const TPoint& aPoint2 ) |
640 const TPoint& /*aPoint2*/ ) |
688 { |
641 { |
689 _AKNTRACE_FUNC_ENTER; |
|
690 CBufferItem* buffer = BufferItem(); |
|
691 buffer->iType = CBufferItem::EDrawLine; |
|
692 buffer->iRect.iTl = aPoint1; |
|
693 buffer->iRect.iBr = aPoint2; |
|
694 _AKNTRACE_FUNC_EXIT; |
|
695 } |
642 } |
696 |
643 |
697 |
644 |
698 // --------------------------------------------------------------------------- |
645 // --------------------------------------------------------------------------- |
699 // From class CWindowGc |
646 // From class CWindowGc |
946 // |
893 // |
947 void CAknRecordingGc::BitBltMasked( const TPoint& aPoint, |
894 void CAknRecordingGc::BitBltMasked( const TPoint& aPoint, |
948 const CFbsBitmap* aBitmap, const TRect& aSourceRect, |
895 const CFbsBitmap* aBitmap, const TRect& aSourceRect, |
949 const CFbsBitmap* aMaskBitmap, TBool aInvertMask ) |
896 const CFbsBitmap* aMaskBitmap, TBool aInvertMask ) |
950 { |
897 { |
951 _AKNTRACE_FUNC_ENTER; |
|
952 if ( !iUseBitGc ) |
898 if ( !iUseBitGc ) |
953 { |
899 { |
954 CBufferItem* buffer = BufferItem(); |
900 CBufferItem* buffer = BufferItem(); |
955 buffer->iType = CBufferItem::EBitBltMasked1; |
901 buffer->iType = CBufferItem::EBitBltMasked1; |
956 buffer->iPosition = aPoint; |
902 buffer->iPosition = aPoint; |
971 } |
917 } |
972 else |
918 else |
973 { |
919 { |
974 iBitGc->BitBltMasked( aPoint, aBitmap, aSourceRect, aMaskBitmap, aInvertMask ); |
920 iBitGc->BitBltMasked( aPoint, aBitmap, aSourceRect, aMaskBitmap, aInvertMask ); |
975 } |
921 } |
976 _AKNTRACE_FUNC_EXIT; |
|
977 } |
922 } |
978 |
923 |
979 |
924 |
980 // --------------------------------------------------------------------------- |
925 // --------------------------------------------------------------------------- |
981 // From class CWindowGc |
926 // From class CWindowGc |
1144 // --------------------------------------------------------------------------- |
1089 // --------------------------------------------------------------------------- |
1145 // |
1090 // |
1146 TInt CAknRecordingGc::APIExtension( TUid aUid, TAny*& /*aOutput*/, |
1091 TInt CAknRecordingGc::APIExtension( TUid aUid, TAny*& /*aOutput*/, |
1147 TAny* aInput ) |
1092 TAny* aInput ) |
1148 { |
1093 { |
1149 _AKNTRACE_FUNC_ENTER; |
|
1150 if (aUid == KDrawTextInContextUid) |
1094 if (aUid == KDrawTextInContextUid) |
1151 { |
1095 { |
1152 __ASSERT_DEBUG( aInput, User::Panic(KBadArgument, KErrArgument )); |
1096 __ASSERT_DEBUG( aInput, User::Panic(KBadArgument, KErrArgument )); |
1153 TDrawTextInContextInternal* contextParam = |
1097 TDrawTextInContextInternal* contextParam = |
1154 static_cast<TDrawTextInContextInternal*>(aInput); |
1098 static_cast<TDrawTextInContextInternal*>(aInput); |
1155 const TTextParameters* params = &contextParam->iParam; |
1099 const TTextParameters* params = &contextParam->iParam; |
1156 __ASSERT_DEBUG( params, User::Panic(KBadArgument, KErrArgument )); |
1100 __ASSERT_DEBUG( params, User::Panic(KBadArgument, KErrArgument )); |
1157 TPtrC textToDraw = contextParam->iText.Mid( params->iStart, |
1101 TPtrC textToDraw = contextParam->iText.Mid( params->iStart, |
1158 params->iEnd - params->iStart ); |
1102 params->iEnd - params->iStart ); |
1159 DrawText(textToDraw, contextParam->iPosition); |
1103 DrawText(textToDraw, contextParam->iPosition); |
1160 _AKNTRACE_FUNC_EXIT; |
|
1161 return KErrNone; |
1104 return KErrNone; |
1162 } |
1105 } |
1163 else |
1106 else |
1164 { |
1107 { |
1165 _AKNTRACE_FUNC_EXIT; |
|
1166 return KErrNotSupported; |
1108 return KErrNotSupported; |
1167 } |
1109 } |
1168 } |
1110 } |