66
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// Include Files
|
|
20 |
#include <e32def.h>
|
|
21 |
#include <fbs.h>
|
|
22 |
#include <jdebug.h>
|
|
23 |
|
|
24 |
#include "cmmaplayerevent.h"
|
|
25 |
#include "mmmaguiplayer.h"
|
|
26 |
#include "mmmadisplaywindow.h"
|
|
27 |
#include "cmmadcdisplay.h"
|
|
28 |
#include "mmmacontainer.h"
|
|
29 |
#include "cmmaeventsource.h"
|
|
30 |
#include "cmmadcrepaintevent.h"
|
|
31 |
#include "cmmadcfullscreenevent.h"
|
|
32 |
#include "cmmadcinvalidateevent.h"
|
|
33 |
|
|
34 |
// CONSTRUCTION
|
|
35 |
// Static constructor, leaves pointer to cleanup-stack
|
|
36 |
CMMADCDisplay* CMMADCDisplay::NewLC(MMMAGuiPlayer* aPlayer,
|
|
37 |
CMMAEventSource* aEventSource,
|
|
38 |
jobject aGUIObject)
|
|
39 |
{
|
|
40 |
CMMADCDisplay* self =
|
|
41 |
new(ELeave) CMMADCDisplay(aPlayer, aEventSource, aGUIObject);
|
|
42 |
CleanupStack::PushL(self);
|
|
43 |
self->iRepaint = new(ELeave) CMMADCRepaintEvent(aGUIObject);
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
// Destructor (virtual by CBase)
|
|
48 |
CMMADCDisplay::~CMMADCDisplay()
|
|
49 |
{
|
|
50 |
if (iContainer)
|
|
51 |
{
|
|
52 |
iContainer->MdcRemoveContent();
|
|
53 |
}
|
|
54 |
delete iBitmap;
|
|
55 |
delete iRepaint;
|
|
56 |
}
|
|
57 |
|
|
58 |
// interface MMMADisplay
|
|
59 |
void CMMADCDisplay::DrawFrameL(const CFbsBitmap* aBitmap)
|
|
60 |
{
|
|
61 |
// This method is called only if bitmap is used.
|
|
62 |
TInt err = InitBitmapMode();
|
|
63 |
|
|
64 |
if (iVisible && iWindow &&
|
|
65 |
iContainer && iContainer->MdcContainerVisibility() &&
|
|
66 |
err == KErrNone)
|
|
67 |
{
|
|
68 |
iWindow->DrawFrameL(aBitmap);
|
|
69 |
|
|
70 |
// container will draw bitmap obtained with MdcFrameBuffer method
|
|
71 |
if (!iRepaint->IsActive())
|
|
72 |
{
|
|
73 |
iRepaint->SetActive();
|
|
74 |
iEventSource->PostEvent(iRepaint, CJavaEventBase::EEventPriority);
|
|
75 |
}
|
|
76 |
}
|
|
77 |
}
|
|
78 |
|
|
79 |
// interface MMMADisplay
|
|
80 |
void CMMADCDisplay::SetDisplaySizeL(const TSize& aSize)
|
|
81 |
{
|
|
82 |
DEBUG_INT2("CMMADCDisplay::SetDisplaySizeL w %d h %d",
|
|
83 |
aSize.iWidth, aSize.iHeight);
|
|
84 |
// user rect contains size set from java.
|
|
85 |
iUserRect.SetSize(aSize);
|
|
86 |
|
|
87 |
if (iContainer)
|
|
88 |
{
|
|
89 |
CMMADCInvalidateEvent* event =
|
|
90 |
new(ELeave)CMMADCInvalidateEvent(iGUIObject, aSize);
|
|
91 |
iEventSource->PostEvent(event, CJavaEventBase::EEventPriority);
|
|
92 |
}
|
|
93 |
}
|
|
94 |
|
|
95 |
// interface MMMADisplay
|
|
96 |
void CMMADCDisplay::SetDisplayLocationL(const TPoint& /*aPosition*/)
|
|
97 |
{
|
|
98 |
DEBUG("CMMADCDisplay::SetDisplayLocationL");
|
|
99 |
// This method only works when the USE_DIRECT_VIDEO mode is set.
|
|
100 |
// In USE_GUI_PRIMITIVE mode, this call will be ignored.
|
|
101 |
}
|
|
102 |
|
|
103 |
// interface MMMADisplay
|
|
104 |
TPoint CMMADCDisplay::DisplayLocation()
|
|
105 |
{
|
|
106 |
DEBUG("CMMADCDisplay::DisplayLocation");
|
|
107 |
// This method returns always (0,0),
|
|
108 |
// because SetDisplayLocationL call is ignored.
|
|
109 |
return TPoint(0, 0);
|
|
110 |
}
|
|
111 |
|
|
112 |
// interface MMMADisplay
|
|
113 |
void CMMADCDisplay::SetFullScreenL(TBool aFullScreen)
|
|
114 |
{
|
|
115 |
DEBUG_INT("CMMADCDisplay::SetFullScreenL %d", aFullScreen);
|
|
116 |
// This method tries to set eSWT Widget size to its parent size.
|
|
117 |
// If real full screen mode is needed parent Composite must be in
|
|
118 |
// fullscreen mode (for example with MobileShell's setFullScreenMode method).
|
|
119 |
if (iContainer)
|
|
120 |
{
|
|
121 |
CMMADCFullScreenEvent* event =
|
|
122 |
new(ELeave)CMMADCFullScreenEvent(iGUIObject, aFullScreen);
|
|
123 |
iEventSource->PostEvent(event, CJavaEventBase::EEventPriority);
|
|
124 |
}
|
|
125 |
}
|
|
126 |
|
|
127 |
// interface MMMADisplay
|
|
128 |
void CMMADCDisplay::SourceSizeChanged(const TSize& aSourceSize)
|
|
129 |
{
|
|
130 |
DEBUG_INT2("CMMADCDisplay::SourceSizeChanged %d %d",
|
|
131 |
aSourceSize.iWidth,
|
|
132 |
aSourceSize.iHeight);
|
|
133 |
|
|
134 |
#ifdef RD_JAVA_NGA_ENABLED
|
|
135 |
if (iWindow)
|
|
136 |
{
|
|
137 |
TPoint topLeft(0, 0);
|
|
138 |
iWindow->SetVideoCropRegion(TRect(topLeft,aSourceSize));
|
|
139 |
}
|
|
140 |
#endif
|
|
141 |
|
|
142 |
if (iWindow)
|
|
143 |
{
|
|
144 |
TRect tmp(TPoint(0, 0), aSourceSize);
|
|
145 |
iWindow->SetDrawRect(tmp);
|
|
146 |
iWindow->SetWindowRect(tmp,MMMADisplay::EMmaThread);
|
|
147 |
|
|
148 |
// set visibility without using event server because this is called
|
|
149 |
// from MMA thread
|
|
150 |
if (iContainer)
|
|
151 |
{
|
|
152 |
if (iContainer->MdcContainerVisibility())
|
|
153 |
{
|
|
154 |
iWindow->SetVisible(ETrue, EFalse);
|
|
155 |
}
|
|
156 |
}
|
|
157 |
}
|
|
158 |
}
|
|
159 |
|
|
160 |
// interface MMMADisplay
|
|
161 |
TBool CMMADCDisplay::IsVisible()
|
|
162 |
{
|
|
163 |
TBool visible = EFalse;
|
|
164 |
if (iContainer)
|
|
165 |
{
|
|
166 |
visible = iContainer->MdcContainerVisibility();
|
|
167 |
}
|
|
168 |
// else invisible
|
|
169 |
|
|
170 |
// return true if both are visible
|
|
171 |
return iVisible && visible;
|
|
172 |
}
|
|
173 |
|
|
174 |
|
|
175 |
// interface MMMADisplay
|
|
176 |
TBool CMMADCDisplay::HasContainer()
|
|
177 |
{
|
|
178 |
return iContainer != NULL;
|
|
179 |
}
|
|
180 |
|
|
181 |
|
|
182 |
// interface MMMADirectContent
|
|
183 |
void CMMADCDisplay::MdcContainerVisibilityChanged(TBool aVisible)
|
|
184 |
{
|
|
185 |
DEBUG_INT("CMMADCDisplay::MdcContainerVisibilityChanged aVisible %d",
|
|
186 |
aVisible);
|
|
187 |
if (iWindow)
|
|
188 |
{
|
|
189 |
iWindow->SetVisible(aVisible && iVisible);
|
|
190 |
}
|
|
191 |
DEBUG("CMMADCDisplay::MdcContainerVisibilityChanged OK");
|
|
192 |
}
|
|
193 |
|
|
194 |
// interface MMMADirectContent
|
|
195 |
void CMMADCDisplay::MdcContentRectChanged(const TRect& aContentRect,
|
|
196 |
const TRect& aParentRect)
|
|
197 |
{
|
|
198 |
DEBUG("MMA::CMMADCDisplay::MdcContentRectChanged");
|
|
199 |
if (iWindow)
|
|
200 |
{
|
|
201 |
TSize size = aContentRect.Size();
|
|
202 |
iWindow->SetDrawRectThread(TRect(size));
|
|
203 |
TInt err = iEventSource->ExecuteTrap(CMMADCDisplay::SetDrawRectL,
|
|
204 |
this,
|
|
205 |
&size);
|
|
206 |
if (err == KErrNone)
|
|
207 |
{
|
|
208 |
// bitmap window ignores window rect and position
|
|
209 |
iWindow->SetWindowRect(aParentRect,MMMADisplay::EUiThread);
|
|
210 |
iWindow->SetPosition(aContentRect.iTl - aParentRect.iTl);
|
|
211 |
}
|
|
212 |
}
|
|
213 |
}
|
|
214 |
|
|
215 |
void CMMADCDisplay::MdcContainerWindowRectChanged(const TRect&
|
|
216 |
#ifdef RD_JAVA_NGA_ENABLED
|
|
217 |
aRect
|
|
218 |
#endif
|
|
219 |
)
|
|
220 |
{
|
|
221 |
DEBUG("CMMADCDisplay::MdcContainerWindowRectChanged");
|
|
222 |
|
|
223 |
#ifdef RD_JAVA_NGA_ENABLED
|
|
224 |
if (iWindow)
|
|
225 |
{
|
|
226 |
iWindow->SetRWindowRect(aRect, MMMADisplay::EUiThread);
|
|
227 |
}
|
|
228 |
#endif
|
|
229 |
}
|
|
230 |
|
|
231 |
// interface MMMADirectContent
|
|
232 |
void CMMADCDisplay::MdcContainerDestroyed()
|
|
233 |
{
|
|
234 |
DEBUG("MMA::CMMADCDisplay::MdcContainerDestroyed");
|
|
235 |
if (iContainer)
|
|
236 |
{
|
|
237 |
iContainer->MdcRemoveContent();
|
|
238 |
}
|
|
239 |
|
|
240 |
iContainer = NULL;
|
|
241 |
if (iWindow)
|
|
242 |
{
|
|
243 |
iWindow->SetVisible(EFalse);
|
|
244 |
iWindow->ContainerDestroyed();
|
|
245 |
}
|
|
246 |
}
|
|
247 |
|
|
248 |
// interface MMMADirectContent
|
|
249 |
void CMMADCDisplay::MdcSetContainer(MMMAContainer* aContainer)
|
|
250 |
{
|
|
251 |
iContainer = aContainer;
|
|
252 |
TSize sourceSize = iPlayer->SourceSize();
|
|
253 |
DEBUG_INT2("CMMADCDisplay::MdcSetContainer source size %d %d",
|
|
254 |
sourceSize.iWidth, sourceSize.iHeight);
|
|
255 |
aContainer->MdcInvalidate(sourceSize);
|
|
256 |
if (iWindow)
|
|
257 |
{
|
|
258 |
// Notify window that container has been set
|
|
259 |
iWindow->ContainerSet();
|
|
260 |
|
|
261 |
TRect controlRect;
|
|
262 |
TRect parentRect;
|
|
263 |
iContainer->MdcGetContentRect(controlRect, parentRect);
|
|
264 |
|
|
265 |
// bitmap window ignores window rect and position
|
|
266 |
iWindow->SetWindowRect(parentRect,MMMADisplay::EUiThread);
|
|
267 |
iWindow->SetPosition(controlRect.iTl - parentRect.iTl);
|
|
268 |
|
|
269 |
DEBUG_INT("CMMADCDisplay::MdcSetContainer container visible %d",
|
|
270 |
aContainer->MdcContainerVisibility());
|
|
271 |
DEBUG_INT("CMMADCDisplay::MdcSetContainer content visible %d",
|
|
272 |
iVisible);
|
|
273 |
|
|
274 |
iWindow->SetVisible(aContainer->MdcContainerVisibility() &&
|
|
275 |
iVisible);
|
|
276 |
}
|
|
277 |
|
|
278 |
if(iFixUIOrientation)
|
|
279 |
{
|
|
280 |
iContainer->MdcFixUIOrientation(ETrue);
|
|
281 |
iFixUIOrientation = EFalse;
|
|
282 |
}
|
|
283 |
}
|
|
284 |
|
|
285 |
// interface MMMADirectContent
|
|
286 |
CFbsBitmap* CMMADCDisplay::MdcFrameBuffer() const
|
|
287 |
{
|
|
288 |
return iBitmap;
|
|
289 |
}
|
|
290 |
|
|
291 |
// interface MMMADirectContent
|
|
292 |
TSize CMMADCDisplay::MdcSourceSize()
|
|
293 |
{
|
|
294 |
return iPlayer->SourceSize();
|
|
295 |
}
|
|
296 |
|
|
297 |
void CMMADCDisplay::MdcContentBoundsChanged(const TRect& /*aRect*/)
|
|
298 |
{
|
|
299 |
}
|
|
300 |
|
|
301 |
void CMMADCDisplay::UIGetDSAResources(
|
|
302 |
MUiEventConsumer& aConsumer,
|
|
303 |
MMMADisplay::TThreadType aThreadType)
|
|
304 |
{
|
|
305 |
if (iContainer)
|
|
306 |
{
|
|
307 |
iContainer->MdcGetDSAResources(aConsumer, aThreadType);
|
|
308 |
}
|
|
309 |
}
|
|
310 |
|
|
311 |
void CMMADCDisplay::UIGetCallback(
|
|
312 |
MUiEventConsumer& aConsumer,
|
|
313 |
TInt aCallbackId)
|
|
314 |
{
|
|
315 |
if (iContainer)
|
|
316 |
{
|
|
317 |
iContainer->MdcGetUICallback(aConsumer, aCallbackId);
|
|
318 |
}
|
|
319 |
}
|
|
320 |
|
|
321 |
void CMMADCDisplay::FixUIOrientation(TBool aFix)
|
|
322 |
{
|
|
323 |
if (iContainer)
|
|
324 |
{
|
|
325 |
iContainer->MdcFixUIOrientation(aFix);
|
|
326 |
}
|
|
327 |
else
|
|
328 |
{
|
|
329 |
// fix orientation when container becomes available
|
|
330 |
iFixUIOrientation = aFix;
|
|
331 |
}
|
|
332 |
}
|
|
333 |
|
|
334 |
TInt CMMADCDisplay::InitBitmapMode()
|
|
335 |
{
|
|
336 |
TInt errCode = KErrNone;
|
|
337 |
// If there is no bitmap, create one and set it to window
|
|
338 |
if (!iBitmap && iWindow)
|
|
339 |
{
|
|
340 |
iBitmap = new CFbsBitmap;
|
|
341 |
if (iBitmap)
|
|
342 |
{
|
|
343 |
errCode = iBitmap->Create(iPlayer->SourceSize(),
|
|
344 |
EColor16MA);
|
|
345 |
}
|
|
346 |
else
|
|
347 |
{
|
|
348 |
errCode = KErrNoMemory;
|
|
349 |
}
|
|
350 |
|
|
351 |
if (errCode == KErrNone)
|
|
352 |
{
|
|
353 |
TRAP(errCode,
|
|
354 |
iWindow->SetDestinationBitmapL(iBitmap));
|
|
355 |
}
|
|
356 |
}
|
|
357 |
return errCode;
|
|
358 |
}
|
|
359 |
|
|
360 |
void CMMADCDisplay::SetDrawRectL(CMMADCDisplay* aDisplay, TSize* aSize)
|
|
361 |
{
|
|
362 |
if (aDisplay->iBitmap)
|
|
363 |
{
|
|
364 |
User::LeaveIfError(aDisplay->iBitmap->Resize(*aSize));
|
|
365 |
aDisplay->iWindow->SetDestinationBitmapL(aDisplay->iBitmap);
|
|
366 |
}
|
|
367 |
}
|
|
368 |
|
|
369 |
CMMADCDisplay::CMMADCDisplay(MMMAGuiPlayer* aPlayer,
|
|
370 |
CMMAEventSource* aEventSource,
|
|
371 |
jobject aGUIObject):
|
|
372 |
iFixUIOrientation(EFalse)
|
|
373 |
{
|
|
374 |
iPlayer = aPlayer;
|
|
375 |
iEventSource = aEventSource;
|
|
376 |
iGUIObject = aGUIObject;
|
|
377 |
// GUI_PRIMITIVE is visible by default.
|
|
378 |
iVisible = ETrue;
|
|
379 |
}
|
|
380 |
|
|
381 |
// END OF FILE
|