|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <w32std.h> |
|
23 #include "mccredrawhandler.h" |
|
24 #include "mccvideosourcesinklogs.h" |
|
25 |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CMccRedrawHandler::NewL |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CMccRedrawHandler* CMccRedrawHandler::NewL( |
|
34 RWsSession& aWsSession, |
|
35 RWindow& aWindow, |
|
36 CWindowGc& aGc ) |
|
37 { |
|
38 CMccRedrawHandler* self = |
|
39 new ( ELeave ) CMccRedrawHandler( aWsSession, aWindow, aGc ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CMccRedrawHandler::~CMccRedrawHandler |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CMccRedrawHandler::~CMccRedrawHandler() |
|
51 { |
|
52 Cancel(); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CMccRedrawHandler::BlackDrawingL |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 void CMccRedrawHandler::BlackDrawingL( TBool aIsEnabled ) |
|
60 { |
|
61 __V_SOURCESINK_CONTROLL_INT1( "CMccRedrawHandler::BlackDrawingL, enabled:", |
|
62 aIsEnabled ) |
|
63 |
|
64 iDrawBlack = aIsEnabled; |
|
65 |
|
66 if ( DoRedrawing() ) |
|
67 { |
|
68 StartRedrawing(); |
|
69 } |
|
70 else |
|
71 { |
|
72 Cancel(); |
|
73 } |
|
74 |
|
75 __V_SOURCESINK_CONTROLL( "CMccRedrawHandler::BlackDrawingL, exit" ) |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CMccRedrawHandler::RunL |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CMccRedrawHandler::RunL() |
|
83 { |
|
84 TInt status( iStatus.Int() ); |
|
85 __V_SOURCESINK_CONTROLL_INT1( "CMccRedrawHandler::RunL, status:", status ) |
|
86 |
|
87 if ( status == KErrNone ) |
|
88 { |
|
89 TWsRedrawEvent event; |
|
90 iWsSession.GetRedraw( event ); |
|
91 Draw( event.Rect() ); |
|
92 |
|
93 StartRedrawing(); |
|
94 } |
|
95 |
|
96 __V_SOURCESINK_CONTROLL( "CMccRedrawHandler::RunL, exit" ) |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CMccRedrawHandler::DoCancel |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CMccRedrawHandler::DoCancel() |
|
104 { |
|
105 iWsSession.RedrawReadyCancel(); |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CMccRedrawHandler::CMccRedrawHandler |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 CMccRedrawHandler::CMccRedrawHandler( |
|
113 RWsSession& aWsSession, |
|
114 RWindow& aWindow, |
|
115 CWindowGc& aGc ) : |
|
116 CActive( CActive::EPriorityStandard ), |
|
117 iWsSession( aWsSession ), |
|
118 iWindow( aWindow ), |
|
119 iGc( aGc ), |
|
120 iDrawBlack( EFalse ) |
|
121 { |
|
122 CActiveScheduler::Add( this ); |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CMccRedrawHandler::ConstructL |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CMccRedrawHandler::ConstructL() |
|
130 { |
|
131 __V_SOURCESINK_CONTROLL( "CMccRedrawHandler::ConstructL, entry" ) |
|
132 |
|
133 StartRedrawing(); |
|
134 |
|
135 __V_SOURCESINK_CONTROLL( "CMccRedrawHandler::ConstructL, exit" ) |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CMccRedrawHandler::Draw |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CMccRedrawHandler::Draw( const TRect& aRect ) |
|
143 { |
|
144 __V_SOURCESINK_CONTROLL_INT2( "CMccRedrawHandler::Draw rect x1:", |
|
145 aRect.iTl.iX, " y1 ", aRect.iTl.iY ) |
|
146 __V_SOURCESINK_CONTROLL_INT2( "CMccRedrawHandler::Draw rect x2:", |
|
147 aRect.iBr.iX, " y2 ", aRect.iBr.iY ) |
|
148 |
|
149 iGc.Activate( iWindow ); |
|
150 iWindow.Invalidate( aRect ); |
|
151 iWindow.BeginRedraw( aRect ); |
|
152 |
|
153 if ( iDrawBlack ) |
|
154 { |
|
155 iGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
156 iGc.SetBrushColor( KRgbBlack ); |
|
157 iGc.Clear( aRect ); |
|
158 iDrawBlack = EFalse; |
|
159 } |
|
160 else if ( iWindow.DisplayMode() >= EColor16MA ) |
|
161 { |
|
162 // Need to set alpha mode, otherwise video cannot be seen |
|
163 iGc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
164 iGc.SetBrushColor( TRgb( 0, 0 ) ); |
|
165 iGc.Clear( aRect ); |
|
166 } |
|
167 else |
|
168 { |
|
169 // NOP |
|
170 } |
|
171 |
|
172 iWindow.EndRedraw(); |
|
173 iGc.Deactivate(); |
|
174 iWsSession.Flush(); |
|
175 |
|
176 __V_SOURCESINK_CONTROLL( "CMccRedrawHandler::Draw, exit" ) |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CMccRedrawHandler::DoRedrawing |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 TBool CMccRedrawHandler::DoRedrawing() const |
|
184 { |
|
185 return ( iDrawBlack || iWindow.DisplayMode() >= EColor16MA ); |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CMccRedrawHandler::StartRedrawing |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CMccRedrawHandler::StartRedrawing() |
|
193 { |
|
194 if ( DoRedrawing() && !IsActive() ) |
|
195 { |
|
196 __V_SOURCESINK_CONTROLL( "CMccRedrawHandler::StartRedrawing, activate" ) |
|
197 iWsSession.RedrawReady( &iStatus ); |
|
198 SetActive(); |
|
199 } |
|
200 } |
|
201 |
|
202 // End of file |
|
203 |