|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Definition of CHuiCanvasAlfPainter. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "uiacceltk/HuiCanvasVisual.h" |
|
20 #include "HuiRenderPlugin.h" |
|
21 #include "uiacceltk/HuiGc.h" |
|
22 #include "uiacceltk/HuiPanic.h" |
|
23 #include "uiacceltk/HuiUtil.h" |
|
24 #include "uiacceltk/HuiStatic.h" |
|
25 #include "uiacceltk/HuiEnv.h" |
|
26 #include "uiacceltk/HuiControl.h" |
|
27 #include "uiacceltk/HuiVisual.h" |
|
28 #include "uiacceltk/HuiTextMesh.h" |
|
29 #include "uiacceltk/HuiCanvasCmdBufferReader.h" |
|
30 #include "huicanvasgc.h" |
|
31 #include "HuiRenderSurface.h" |
|
32 #include "huicanvastexturecache.h" |
|
33 #include "huicanvasbackground.h" |
|
34 #include <graphics/wsgraphicscontext.h> |
|
35 #include <e32cmn.h> |
|
36 #include <AknLayoutFont.h> |
|
37 #include "huicanvaspainter.h" |
|
38 |
|
39 |
|
40 |
|
41 CHuiCanvasPainter::~CHuiCanvasPainter() |
|
42 { |
|
43 iCommandBuffers.Close(); |
|
44 delete iPartialCommandBuffer; |
|
45 }; |
|
46 |
|
47 void CHuiCanvasPainter::SetCommandSetL( const TDesC8& aCommands ) |
|
48 { |
|
49 ClearCommandSet(); |
|
50 AddCommandSetL(aCommands); |
|
51 } |
|
52 |
|
53 void CHuiCanvasPainter::ClearCommandSet() |
|
54 { |
|
55 TInt count = iCommandBuffers.Count(); |
|
56 for (TInt i=0; i< count;i++) |
|
57 { |
|
58 delete iCommandBuffers[i]; |
|
59 } |
|
60 iCommandBuffers.Reset(); |
|
61 } |
|
62 |
|
63 void CHuiCanvasPainter::AddCommandSetL( const TDesC8& aMoreCommands ) |
|
64 { |
|
65 HBufC8* commands = aMoreCommands.AllocL(); |
|
66 CleanupStack::PushL(commands); |
|
67 |
|
68 CHuiCanvasCommandBuffer* newBuffer = new(ELeave) CHuiCanvasCommandBuffer; |
|
69 CleanupStack::PushL(newBuffer); |
|
70 newBuffer->iCommands = commands; |
|
71 if (iCanvasVisual && iCanvasVisual->Display()) |
|
72 { |
|
73 newBuffer->iOrientation = iCanvasVisual->Display()->Orientation(); |
|
74 } |
|
75 iCommandBuffers.AppendL( newBuffer); |
|
76 CleanupStack::Pop(2, commands); |
|
77 |
|
78 RequestContinueRefresh(); |
|
79 } |
|
80 |
|
81 void CHuiCanvasPainter::AddPartialCommandSetL( const TDesC8& aMoreCommands, TBool aLastPart ) |
|
82 { |
|
83 if (!iPartialCommandBuffer) |
|
84 { |
|
85 iPartialCommandBuffer = aMoreCommands.AllocL(); |
|
86 } |
|
87 else |
|
88 { |
|
89 iPartialCommandBuffer = |
|
90 iPartialCommandBuffer->ReAllocL( iPartialCommandBuffer->Length() + aMoreCommands.Length() ); |
|
91 |
|
92 TPtr8 ptr = iPartialCommandBuffer->Des(); |
|
93 ptr.Append(aMoreCommands); |
|
94 } |
|
95 |
|
96 if (aLastPart && iPartialCommandBuffer) |
|
97 { |
|
98 AddCommandSetL(*iPartialCommandBuffer); |
|
99 delete iPartialCommandBuffer; |
|
100 iPartialCommandBuffer = NULL; |
|
101 } |
|
102 } |
|
103 |
|
104 // Tags the last buffer for tracking |
|
105 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
106 void CHuiCanvasPainter::SetTrackCommandSet( TFileName& aFileName, TBool aTrack ) |
|
107 { |
|
108 TInt count = iCommandBuffers.Count(); |
|
109 if ( count == 0 ) |
|
110 { |
|
111 return; |
|
112 } |
|
113 iCommandBuffers[count-1]->iTrackedBuffer = aTrack; |
|
114 |
|
115 if ( aFileName.Length() > 0 ) |
|
116 { |
|
117 iCommandBuffers[count-1]->iProcessName = aFileName.Alloc(); |
|
118 } |
|
119 } |
|
120 #endif |
|
121 |
|
122 TBool CHuiCanvasPainter::HasCommandBuffers() |
|
123 { |
|
124 if (iCommandBuffers.Count() == 0 || |
|
125 !iCommandBuffers[0]->iCommands ) |
|
126 { |
|
127 return EFalse; |
|
128 } |
|
129 return ETrue; |
|
130 } |
|
131 |
|
132 void CHuiCanvasPainter::SetVisual(CHuiCanvasVisual* aVisual) |
|
133 { |
|
134 iCanvasVisual = aVisual; |
|
135 } |
|
136 |
|
137 CHuiCanvasVisual* CHuiCanvasPainter::Visual() |
|
138 { |
|
139 return iCanvasVisual; |
|
140 } |
|
141 |
|
142 TBool CHuiCanvasPainter::BuffersChanged() const |
|
143 { |
|
144 TInt bufferCount = iCommandBuffers.Count(); |
|
145 for (TInt cb = 0; cb < bufferCount; cb++) |
|
146 { |
|
147 if (iCommandBuffers[cb]->iChanged) |
|
148 { |
|
149 return ETrue; |
|
150 } |
|
151 } |
|
152 return EFalse; |
|
153 } |
|
154 |
|
155 void CHuiCanvasPainter::ClearAllBuffersChanged() |
|
156 { |
|
157 SetAllBuffersChanged(EFalse); |
|
158 } |
|
159 |
|
160 void CHuiCanvasPainter::SetAllBuffersChanged(TBool aChanged) |
|
161 { |
|
162 TInt bufferCount = iCommandBuffers.Count(); |
|
163 for (TInt cb = 0; cb < bufferCount; cb++) |
|
164 { |
|
165 iCommandBuffers[cb]->iChanged = aChanged; |
|
166 } |
|
167 |
|
168 if ( aChanged ) |
|
169 { |
|
170 RequestContinueRefresh(); |
|
171 } |
|
172 } |
|
173 |
|
174 void CHuiCanvasPainter::RequestContinueRefresh() |
|
175 { |
|
176 if ( iCanvasVisual && iCanvasVisual->Display() ) |
|
177 { |
|
178 iCanvasVisual->Owner().Env().ContinueRefresh(ETrue); |
|
179 } |
|
180 } |
|
181 |
|
182 void CHuiCanvasPainter::SetAllBufferStatusFlags(THuiCanvasBufferStatusFlags aStatusFlags) |
|
183 { |
|
184 TInt bufferCount = iCommandBuffers.Count(); |
|
185 for (TInt cb = 0; cb < bufferCount; cb++) |
|
186 { |
|
187 iCommandBuffers[cb]->SetStatusFlags(aStatusFlags); |
|
188 } |
|
189 } |
|
190 |
|
191 void CHuiCanvasPainter::ClearAllBufferStatusFlags(THuiCanvasBufferStatusFlags aStatusFlags) |
|
192 { |
|
193 TInt bufferCount = iCommandBuffers.Count(); |
|
194 for (TInt cb = 0; cb < bufferCount; cb++) |
|
195 { |
|
196 iCommandBuffers[cb]->ClearStatusFlags(aStatusFlags); |
|
197 } |
|
198 } |
|
199 |
|
200 |
|
201 TBool CHuiCanvasPainter::HasCommandBuffers(THuiCanvasBufferStatusFlags aStatusFlags) |
|
202 { |
|
203 TInt bufferCount = iCommandBuffers.Count(); |
|
204 for (TInt cb = 0; cb < bufferCount; cb++) |
|
205 { |
|
206 if (iCommandBuffers[cb]->iStatusFlags & aStatusFlags) |
|
207 { |
|
208 return ETrue; |
|
209 } |
|
210 } |
|
211 return EFalse; |
|
212 } |
|
213 |
|
214 TBool CHuiCanvasPainter::HasCommandBuffersWithoutFlags(THuiCanvasBufferStatusFlags aStatusFlags) |
|
215 { |
|
216 TInt bufferCount = iCommandBuffers.Count(); |
|
217 for (TInt cb = 0; cb < bufferCount; cb++) |
|
218 { |
|
219 if (!(iCommandBuffers[cb]->iStatusFlags & aStatusFlags)) |
|
220 { |
|
221 return ETrue; |
|
222 } |
|
223 } |
|
224 return EFalse; |
|
225 } |
|
226 |
|
227 TBool CHuiCanvasPainter::HasOldCommandBuffers(TInt aLifeTimeInMs) |
|
228 { |
|
229 TTime now; |
|
230 now.UniversalTime(); |
|
231 TInt bufferCount = iCommandBuffers.Count(); |
|
232 for (TInt cb = 0; cb < bufferCount; cb++) |
|
233 { |
|
234 TInt lifetimeInMs = now.MicroSecondsFrom( iCommandBuffers[cb]->iCreationTime ).Int64()/1000; |
|
235 if (lifetimeInMs > 0 && lifetimeInMs > aLifeTimeInMs) |
|
236 { |
|
237 return ETrue; |
|
238 } |
|
239 } |
|
240 |
|
241 return EFalse; |
|
242 } |