|
1 // btrace_screenupdate.cpp |
|
2 // |
|
3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include "btrace_parser.h" |
|
14 |
|
15 |
|
16 EXPORT_C CBtraceScreenUpdate* CBtraceScreenUpdate::NewL(CBtraceReader& aReader) |
|
17 { |
|
18 CBtraceScreenUpdate* self = new(ELeave) CBtraceScreenUpdate(aReader); |
|
19 CleanupStack::PushL(self); |
|
20 self->ConstructL(); |
|
21 CleanupStack::Pop(self); |
|
22 return self; |
|
23 } |
|
24 |
|
25 EXPORT_C CBtraceScreenUpdate::~CBtraceScreenUpdate() |
|
26 { |
|
27 iNotifs.Close(); |
|
28 iReader.RemoveObserver(KAmTraceCategory, *this); |
|
29 } |
|
30 |
|
31 EXPORT_C void CBtraceScreenUpdate::NotifyScreenUpdateL(MBtraceScreenUpdateObserver& aObserver) |
|
32 { |
|
33 NotifyScreenUpdateL(aObserver, ENotificationOneShot); |
|
34 } |
|
35 |
|
36 EXPORT_C void CBtraceScreenUpdate::NotifyScreenUpdateL(MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence) |
|
37 { |
|
38 iNotifs.AppendL(TScreenUpdateNotif(aObserver, aPersistence)); |
|
39 } |
|
40 |
|
41 EXPORT_C void CBtraceScreenUpdate::NotifyScreenUpdateL(TInt aScreenNumber, const TRect& aRect, MBtraceScreenUpdateObserver& aObserver) |
|
42 { |
|
43 NotifyScreenUpdateL(aScreenNumber, aRect, aObserver, ENotificationOneShot); |
|
44 } |
|
45 |
|
46 EXPORT_C void CBtraceScreenUpdate::NotifyScreenUpdateL(TInt aScreenNumber, const TRect& aRect, MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence) |
|
47 { |
|
48 iNotifs.AppendL(TScreenUpdateNotif(aScreenNumber, aRect, aObserver, aPersistence)); |
|
49 } |
|
50 |
|
51 EXPORT_C void CBtraceScreenUpdate::CancelNotifyScreenUpdate(MBtraceScreenUpdateObserver& aObserver) |
|
52 { |
|
53 for (TInt i = iNotifs.Count()-1; i>=0; --i) |
|
54 { |
|
55 if (iNotifs[i].iObserver == &aObserver) |
|
56 { |
|
57 iNotifs.Remove(i); |
|
58 } |
|
59 } |
|
60 } |
|
61 |
|
62 CBtraceScreenUpdate::CBtraceScreenUpdate(CBtraceReader& aReader) |
|
63 : iReader(aReader) |
|
64 { |
|
65 } |
|
66 |
|
67 void CBtraceScreenUpdate::ConstructL() |
|
68 { |
|
69 iReader.AddObserverL(KAmTraceCategory, *this); |
|
70 } |
|
71 |
|
72 void CBtraceScreenUpdate::HandleScreenUpdateL(const TBtraceTickCount& aTickCount, TInt aScreenNumber, const TRect& aRect) |
|
73 { |
|
74 for (TInt i = (iNotifs.Count() - 1); i >= 0; --i) |
|
75 { |
|
76 TScreenUpdateNotif& notif = iNotifs[i]; |
|
77 if (notif.iNotifyAll || ((notif.iScreenNumber == aScreenNumber) && (notif.iRect.Intersects(aRect)))) |
|
78 { |
|
79 MBtraceScreenUpdateObserver* observer = notif.iObserver; |
|
80 if (notif.iPersistence == ENotificationOneShot) |
|
81 { |
|
82 iNotifs.Remove(i); |
|
83 } |
|
84 observer->HandleScreenUpdateL(aTickCount, aScreenNumber, aRect); |
|
85 } |
|
86 } |
|
87 } |
|
88 |
|
89 void CBtraceScreenUpdate::HandleBtraceFrameL(const TBtraceFrame& aFrame) |
|
90 { |
|
91 if (aFrame.iCategory == KAmTraceCategory && aFrame.iSubCategory == EAmTraceSubCategoryScreenDriver) |
|
92 { |
|
93 const TUint8* data = aFrame.iData.Ptr(); |
|
94 TAmTraceEventScreenDriver event = *((const TAmTraceEventScreenDriver*)data); |
|
95 data += sizeof (TAmTraceEventScreenDriver); |
|
96 if (event == EAmTraceEventScreenDriverRectangleUpdated) |
|
97 { |
|
98 TInt screenNumber = *((const TInt32*)data); |
|
99 data += sizeof (TInt); |
|
100 const TRect* rect = (const TRect*)data; |
|
101 HandleScreenUpdateL(aFrame.iTickCount, screenNumber, *rect); |
|
102 } |
|
103 } |
|
104 } |
|
105 |
|
106 CBtraceScreenUpdate::TScreenUpdateNotif::TScreenUpdateNotif(MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence) |
|
107 : iNotifyAll(ETrue), iObserver(&aObserver), iPersistence(aPersistence) |
|
108 { |
|
109 } |
|
110 |
|
111 CBtraceScreenUpdate::TScreenUpdateNotif::TScreenUpdateNotif(TInt aScreenNumber, const TRect& aRect, MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence) |
|
112 : iNotifyAll(EFalse), iScreenNumber(aScreenNumber), iRect(aRect), iObserver(&aObserver), iPersistence(aPersistence) |
|
113 { |
|
114 } |
|
115 |