os/graphics/graphicscomposition/openwfcompositionengine/adaptation/src/Platform/Graphics/symbian/owfnotifications.cpp
First public contribution.
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and/or associated documentation files (the
5 // "Materials"), to deal in the Materials without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Materials, and to
8 // permit persons to whom the Materials are furnished to do so, subject to
9 // the following conditions:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Materials.
14 // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
23 // Display Channel adaptation for owfscreen
27 #include "wfcstructs.h"
28 #include "wfcdevice.h"
30 #include "wfcdevice.h"
31 #include "wfcelement.h"
32 #include "wfccontext.h"
33 #include "wfcimageprovider.h"
36 #include "owfmemory.h"
38 #include "owfscreen.h"
40 #include "owfobject.h"
44 #include "owfnotifications.h"
45 #include <graphics/symbianstream.h>
47 #include "owfdisplaycontext.h"
54 owfSymContextSourceStreamUpdated(SymbianStreamType stream,
60 owfSymDeviceSetUpdateFlags(WFC_CONTEXT* context, OWFNativeStreamType stream, WFCint updateFlags);
63 owfSymDeviceProcessAllCallBacks(WFC_CONTEXT* context, WFCint events);
66 owfSymDeviceSetVisibilityState(WFC_CONTEXT* context, OWFNativeStreamType stream, WFCint visibility);
68 static OWFint owfGetScreenNumber(WFC_CONTEXT* context)
71 return context->type == WFC_CONTEXT_TYPE_ON_SCREEN ? context->screenNumber : -context->handle;
75 owfSymContextSourceStreamUpdated(SymbianStreamType stream,
82 (void) stream; /* suppress compiler warning */
86 case ESOWF_ObserverReturnDefaultEvent:
89 SYMOWF_DEFAULT_EVENT_PARAM* parameter = (SYMOWF_DEFAULT_EVENT_PARAM*) param;
90 if ((parameter->length) == sizeof(SYMOWF_DEFAULT_EVENT_PARAM))
92 parameter->event = ESOWF_EventUpdated;
97 case ESOWF_EventUpdated:
99 WFC_CONTEXT* context = NULL;
100 context = CONTEXT(data);
102 OWF_ASSERT(context->device);
104 OWFDisplayContext *pDispCtx = _OWF_DISPLAYCONTEXT(context->displayContext);
108 SYMOWF_CONTENT_UPDATED_PARAM* parameter = (SYMOWF_CONTENT_UPDATED_PARAM*) param;
109 OWFNativeStreamType owfStream = (OWFNativeStreamType) stream;
111 if ((parameter->length) == sizeof(SYMOWF_CONTENT_UPDATED_PARAM))
113 switch (parameter->id)
115 case SYM_CONTENT_UPDATE_BEGIN:
117 OWF_Mutex_Lock(&context->updateFlagMutex);
118 NFPRINT(("+++ BEGIN CONTENT UPDATE"));
120 parameter->immediateAvailable = 0;
121 parameter->immediateVisibility = SYM_CONTENT_VISIBLE_NOT_SET;
122 if (pDispCtx->iCompositionOngoing &&
124 pDispCtx->iPreviousCommit == SYM_CONTENT_PREVIOUS_COMMIT_FALSE)
127 parameter->immediateAvailable = 1;
128 parameter->serialNumber = pDispCtx->iSerialNumber;
129 for (i = 0; i < context->device->providers.length; i++)
131 WFC_IMAGE_PROVIDER* provider;
133 provider = IMAGE_PROVIDER(OWF_Array_GetItemAt(&context->device->providers, i));
135 if (provider->type == WFC_IMAGE_SOURCE &&
136 provider->streamHandle == owfStream &&
137 context == provider->owner)
139 parameter->immediateVisibility = provider->contentVisible;
144 //the mutex is acquired!
148 case SYM_CONTENT_UPDATE_END:
149 ++context->sourceUpdateCount;
150 pDispCtx->iEventServerUpdate |= parameter->par;
151 owfSymDeviceSetUpdateFlags(context, owfStream, parameter->par);
152 OWF_Mutex_Unlock(&context->updateFlagMutex);
153 NFPRINT(("+++ END CONTENT UPDATE"));
156 case SYM_CONTENT_UPDATE:
157 NFPRINT(("+++ CONTENT UPDATE"));
158 OWF_Mutex_Lock(&context->updateFlagMutex);
159 ++context->sourceUpdateCount;
160 pDispCtx->iEventServerUpdate |= parameter->par;
161 owfSymDeviceSetUpdateFlags(context, owfStream, parameter->par);
162 OWF_Mutex_Unlock(&context->updateFlagMutex);
170 NFPRINT(("+++ WFC_Context_SourceStreamUpdated parameter length error(%d)",
177 // Old, legacy, behaviour, not sure if really needed
178 NFPRINT(("+++ LEGACY CONTENT UPDATE"));
179 OWF_Mutex_Lock(&context->updateFlagMutex);
180 ++context->sourceUpdateCount;
181 OWF_Mutex_Unlock(&context->updateFlagMutex);
191 owfSymDeviceSetUpdateFlags(WFC_CONTEXT* context, OWFNativeStreamType stream, WFCint updateFlags)
193 WFC_DEVICE* device = NULL;
196 OWF_ASSERT(context && (context->device));
198 device = context->device;
200 for (i = 0; i < device->providers.length; i++)
202 WFC_IMAGE_PROVIDER* provider = IMAGE_PROVIDER(OWF_Array_GetItemAt(&device->providers, i));
204 if (provider->type == WFC_IMAGE_SOURCE && provider->streamHandle == stream && context == provider->owner)
206 NFPRINT(("+++ owfSymDeviceSetUpdateFlags set context updated stream(0x%x) provider(0x%x) flags(0x%x)", stream, provider, updateFlags));
207 provider->contentUpdated |= updateFlags;
213 owfSymDeviceSetVisibilityState(WFC_CONTEXT* context, OWFNativeStreamType stream, WFCint visibility)
215 WFC_DEVICE* device = NULL;
218 OWF_ASSERT(context && (context->device));
220 device = context->device;
222 for (i = 0; i < device->providers.length; i++)
224 WFC_IMAGE_PROVIDER* provider = IMAGE_PROVIDER(OWF_Array_GetItemAt(&device->providers, i));
226 if (provider->type == WFC_IMAGE_SOURCE && provider->streamHandle == stream && context == provider->owner)
228 provider->contentVisible = visibility;
234 owfSymDeviceProcessAllCallBacks(WFC_CONTEXT* context, WFCint events)
236 WFC_DEVICE* device = NULL;
239 NFPRINT(("+++ START owfSymDeviceProcessAllCallBacks events=0x%x", events));
241 if (!context || !(context->device))
245 device = context->device;
247 OWFDisplayContext *pDispCtx = _OWF_DISPLAYCONTEXT(context->displayContext);
249 for (i = 0; i < device->providers.length; i++)
251 WFC_IMAGE_PROVIDER* source = IMAGE_PROVIDER(OWF_Array_GetItemAt(&device->providers, i));
253 if (source->contentVisible == SYM_CONTENT_VISIBLE_NOT_SET)
255 source->contentVisible = SYM_CONTENT_NOT_VISIBLE;
258 NFPRINT(("+++ owfSymDeviceProcessAllCallBacks provider=0x%x v=%d t=%d o=%d u=0x%x c=0x%x ",
260 source->contentVisible == SYM_CONTENT_VISIBLE,
261 source->type == WFC_IMAGE_SOURCE,
262 context == source->owner,
263 source->contentUpdated,
266 if (source->contentVisible == SYM_CONTENT_VISIBLE &&
267 source->type == WFC_IMAGE_SOURCE &&
268 context == source->owner &&
269 source->contentUpdated & events &&
272 NFPRINT(("+++ START owfSymDeviceProcessAllCallBacks process all notifications handle=0x%x",
273 source->streamHandle));
275 SymbianStreamProcessNotifications((SymbianStreamType)source->streamHandle,
276 events & source->contentUpdated,
277 owfGetScreenNumber(context),
278 pDispCtx->iSerialNumber,
281 source->visited |= events;
283 source->contentUpdated &= ~events;
284 source->contentUpdated |= newMask;
285 source->composed = 0;
289 for (i = 0; i < device->providers.length; i++)
291 WFC_IMAGE_PROVIDER* source = IMAGE_PROVIDER(OWF_Array_GetItemAt(&device->providers, i));
293 if (!source->visited &&
294 source->type == WFC_IMAGE_SOURCE &&
295 context == source->owner &&
296 (source->contentUpdated & events))
298 NFPRINT(("+++ START owfSymDeviceProcessAllCallBacks check visible handle=0x%x",
299 source->streamHandle));
300 SymbianStreamCheckVisible((SymbianStreamType)source->streamHandle,
301 events & source->contentUpdated,
302 owfGetScreenNumber(context),
303 pDispCtx->iSerialNumber);
305 source->contentUpdated &= ~events;
314 OWF_API_CALL OWFboolean
315 owfSymDeviceInitialise(WFC_IMAGE_PROVIDER* source)
317 WFC_CONTEXT* context = NULL;
318 WFC_DEVICE* device = NULL;
320 OWFNativeStreamType stream;
322 if (!source || !(source->owner) || ! (((WFC_CONTEXT*)source->owner)->device))
327 context = (WFC_CONTEXT*)source->owner;
328 device = context->device;
330 if (source->type == WFC_IMAGE_MASK)
335 stream = source->streamHandle;
337 source->contentVisible = SYM_CONTENT_VISIBLE_NOT_SET;
339 source->composed = 0;
341 // forward check to copy the visibility state
342 for (i = 0; i < device->providers.length; i++)
344 WFC_IMAGE_PROVIDER* provider = IMAGE_PROVIDER(OWF_Array_GetItemAt(&device->providers, i));
346 if (provider->type == WFC_IMAGE_SOURCE && provider->streamHandle == stream && context == provider->owner)
348 source->contentVisible = provider->contentVisible;
353 SymbianStreamAddExtendedObserver((SymbianStreamType)source->streamHandle,
354 owfSymContextSourceStreamUpdated,
356 owfGetScreenNumber(context),
363 owfSymDeviceDestroy(WFC_DEVICE* device, WFC_IMAGE_PROVIDER* source, WFCint position)
366 OWFboolean foundAnotherSource = OWF_FALSE;
371 if (source->type == WFC_IMAGE_SOURCE)
373 OWFNativeStreamType stream = source->streamHandle;
374 WFC_CONTEXT* context = (WFC_CONTEXT*)source->owner;
376 for (i = 0; i < device->providers.length; i++)
380 WFC_IMAGE_PROVIDER* newObject = (WFC_IMAGE_PROVIDER*)(OWF_Array_GetItemAt(&device->providers, i));
381 if ((stream == newObject->streamHandle) &&
382 (context == newObject->owner) &&
383 (newObject->type == WFC_IMAGE_SOURCE))
385 foundAnotherSource = OWF_TRUE;
391 if (!foundAnotherSource)
393 WFCint screenNumber = owfGetScreenNumber(context);
394 SymbianStreamRemoveObserver((SymbianStreamType)stream,
401 OWF_API_CALL OWFboolean
402 owfSymElementNotifications(WFC_CONTEXT* context, WFC_ELEMENT* element)
404 WFC_IMAGE_PROVIDER* source = NULL;
405 OWFNativeStreamType stream = OWF_INVALID_HANDLE;
407 OWF_ASSERT(context && element && (context->device) && (element->source));
409 source = IMAGE_PROVIDER(element->source);
411 if (source->type != WFC_IMAGE_SOURCE)
416 OWF_Mutex_Lock(&context->updateFlagMutex);
417 source->composed = source->contentUpdated | ESOWF_EventComposed;
418 NFPRINT(("+++ END owfSymElementNotifications composed s=0x%x u=0x%x", source, source->composed));
420 if (source->contentVisible != SYM_CONTENT_VISIBLE_NOT_SET)
422 OWF_Mutex_Unlock(&context->updateFlagMutex);
426 stream = source->streamHandle;
428 if (!element->skipCompose)
430 owfSymDeviceSetVisibilityState(context, stream, SYM_CONTENT_VISIBLE);
433 OWF_Mutex_Unlock(&context->updateFlagMutex);
439 owfSymDeviceResetVisibilityState(WFC_CONTEXT* context)
441 WFC_DEVICE* device = NULL;
444 OWF_ASSERT(context && (context->device));
446 device = context->device;
448 OWFDisplayContext *pDispCtx = _OWF_DISPLAYCONTEXT(context->displayContext);
450 OWF_Mutex_Lock(&context->updateFlagMutex);
451 pDispCtx->iPreviousCommit = SYM_CONTENT_PREVIOUS_COMMIT_TRUE;
452 context->sourceUpdateCount++;
453 for (i = 0; i < device->providers.length; i++)
455 WFC_IMAGE_PROVIDER* provider = IMAGE_PROVIDER(OWF_Array_GetItemAt(&device->providers, i));
457 if (context == provider->owner)
459 provider->contentVisible = SYM_CONTENT_VISIBLE_NOT_SET;
462 OWF_Mutex_Unlock(&context->updateFlagMutex);
466 owfSymProcessAllNotifications(WFC_CONTEXT* context)
468 WFCint newContextUpdateEvents = 0;
472 NFPRINT(("+++ END owfSymProcessAllNotifications (context = 0)"));
476 OWFDisplayContext *pDispCtx = _OWF_DISPLAYCONTEXT(context->displayContext);
478 NFPRINT(("+++ START owfSymProcessAllNotifications events=0x%x", pDispCtx->iEventServerUpdate));
479 OWF_Mutex_Lock(&context->updateFlagMutex);
480 pDispCtx->iCompositionOngoing = WFC_FALSE;
482 if (pDispCtx->iEventServerUpdate || pDispCtx->iPreviousCommit == SYM_CONTENT_PREVIOUS_COMMIT_TRUE)
484 newContextUpdateEvents |= owfSymDeviceProcessAllCallBacks(context, pDispCtx->iEventServerUpdate);
486 pDispCtx->iEventServerUpdate = newContextUpdateEvents;
488 if (newContextUpdateEvents)
490 context->sourceUpdateCount++;
494 pDispCtx->iPreviousCommit = SYM_CONTENT_PREVIOUS_COMMIT_FALSE;
495 OWF_Mutex_Unlock(&context->updateFlagMutex);
497 NFPRINT(("+++ END owfSymProcessAllNotifications newEvents=0x%x", newContextUpdateEvents));
498 return newContextUpdateEvents;