|
1 /* |
|
2 * ============================================================================== |
|
3 * Name : %name: previewprovidercrp.h % |
|
4 * Part of : Hg fast swap preview provider plugin |
|
5 * Description : Preview provider ECOM plugin |
|
6 * Version : %version: sa1spcx1#3 % |
|
7 * |
|
8 * Copyright (c) 2008 Nokia Corporation. |
|
9 * This material, including documentation and any related |
|
10 * computer programs, is protected by copyright controlled by |
|
11 * Nokia Corporation. All rights are reserved. Copying, |
|
12 * including reproducing, storing, adapting or translating, any |
|
13 * or all of this material requires the prior written consent of |
|
14 * Nokia Corporation. This material also contains confidential |
|
15 * information which may not be disclosed to others without the |
|
16 * prior written consent of Nokia Corporation. |
|
17 * ============================================================================== |
|
18 */ |
|
19 |
|
20 #ifndef PREVIEWPROVIDERCRP_H |
|
21 #define PREVIEWPROVIDERCRP_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <w32std.h> |
|
25 #include <graphics/wsgraphicdrawerinterface.h> |
|
26 #include <graphics/wsgraphicdrawer.h> |
|
27 |
|
28 // Number of screenshots used at the same time, |
|
29 // each window group change will cause a screenshot |
|
30 // to one of these, the index for the current one is |
|
31 // switched after each screenshot capture. (this is needed |
|
32 // to prevent overwriting screenshots before the client could |
|
33 // make a copy of them) |
|
34 const TInt KMaxShots = 4; |
|
35 |
|
36 /** |
|
37 * Preview provider window server ECOM plugin class. |
|
38 */ |
|
39 NONSHARABLE_CLASS( CPreviewProviderCRP ) : public CWsGraphicDrawer, |
|
40 public MWsEventHandler |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Creates a new instance of the plguin. |
|
46 * |
|
47 * @return Created instance. |
|
48 */ |
|
49 static CWsGraphicDrawer* CreateL(); |
|
50 |
|
51 /** |
|
52 * Destructor |
|
53 */ |
|
54 ~CPreviewProviderCRP(); |
|
55 |
|
56 private: |
|
57 |
|
58 /** |
|
59 * From CWsGraphicDrawer. |
|
60 * |
|
61 * @param aGc |
|
62 * @param aRect |
|
63 * @param aData |
|
64 */ |
|
65 void DoDraw( MWsGc& aGc, const TRect& aRect, const TDesC8& aData ) const; |
|
66 |
|
67 /** |
|
68 * Handles message from PreviewProviderClient. |
|
69 * |
|
70 * @param aData Message data. |
|
71 */ |
|
72 void HandleMessage( const TDesC8& aData ); |
|
73 |
|
74 /** |
|
75 * 2nd phase constructor. |
|
76 * |
|
77 * @param aEnv |
|
78 * @param aId |
|
79 * @param aOwner |
|
80 * @param aData |
|
81 */ |
|
82 void ConstructL( MWsGraphicDrawerEnvironment& aEnv, |
|
83 const TGraphicDrawerId& aId, |
|
84 MWsClient& aOwner, |
|
85 const TDesC8& aData ); |
|
86 |
|
87 /** |
|
88 * From MWsEventHandler. |
|
89 * |
|
90 * Observer for TWservCrEvent::EWindowGroupChanged to take the screenshot |
|
91 * when application changes. |
|
92 * |
|
93 * @param aEvent |
|
94 */ |
|
95 void DoHandleEvent( const TWservCrEvent& aEvent ); |
|
96 |
|
97 private: |
|
98 |
|
99 /** |
|
100 * 2nd phase constructor. |
|
101 */ |
|
102 void ConstructL(); |
|
103 |
|
104 /** |
|
105 * Handles application registration. |
|
106 * |
|
107 * @param aWgId Window group id. |
|
108 */ |
|
109 void Register( TInt aWgId ); |
|
110 |
|
111 /** |
|
112 * Handler application unregistration. |
|
113 * |
|
114 * @param aWgId Window group id. |
|
115 */ |
|
116 void Unregister( TInt aWgId ); |
|
117 |
|
118 /* |
|
119 * Allocate resources and take screenshot |
|
120 */ |
|
121 void ScreenshotL(); |
|
122 |
|
123 /** |
|
124 * Takes the screenshot. |
|
125 */ |
|
126 void ScreenshotL( CFbsBitmap& aBitmap ); |
|
127 |
|
128 /** |
|
129 * Remove bitmap reference fom list |
|
130 */ |
|
131 void RemoveScreenshot( TInt aBitmapHandle ); |
|
132 |
|
133 /** |
|
134 * Remove all bitmaps overflow |
|
135 */ |
|
136 void CheckOverflow(); |
|
137 |
|
138 /** |
|
139 * Handles message from PreviewProviderClient. |
|
140 * |
|
141 * @param aData Message data. |
|
142 */ |
|
143 void DoHandleMessageL( const TDesC8& aData ); |
|
144 |
|
145 /** |
|
146 * Notifies the PreviewProviderClient when screenshot is ready for copying. |
|
147 */ |
|
148 void ScaleCompleteL(const CFbsBitmap& aBitmap); |
|
149 |
|
150 /** |
|
151 * Notifies the PreviewProviderClient when an application has been exited. |
|
152 */ |
|
153 void UnregisterComplete( TInt aWgId ); |
|
154 |
|
155 /** |
|
156 * Uses window server front buffer to create a screenshot. |
|
157 * @param aFront preallocated destination bitmap |
|
158 * @param aFront Front buffer. |
|
159 * @param aSrcSize Size of the source front buffer in pixels. |
|
160 * @param aSrcStride Source stride. |
|
161 */ |
|
162 void FrontBufferScreenShot( |
|
163 CFbsBitmap& aBitmap, |
|
164 MWsFrontBuffer& aFront, const TSize& aSrcSize, TInt aSrcStride ); |
|
165 |
|
166 private: |
|
167 TInt iScreen; |
|
168 TInt iPrevId; |
|
169 TInt iPrevReg; // to work around the problem with wgid not set when app brought |
|
170 // to foreground first time |
|
171 RPointerArray<CFbsBitmap> iScreenshots; |
|
172 TSize iScreenshotSize; |
|
173 TDisplayMode iScreenshotMode; |
|
174 RArray<TInt> iWgIds; |
|
175 }; |
|
176 |
|
177 #endif // PREVIEWPROVIDERCRP_H |
|
178 |
|
179 // End of file |