Fork for IVI: mesa fixing
[profile/ivi/uifw.git] / src / ui / animations / FUiAnim_EflNode.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FUiAnim_EflNode.cpp
20  * @brief       This file contains implementation of _EflNode class
21  *
22  * This file contains implementation _EflNode class.
23  */
24
25 #include <unique_ptr.h>
26 #include <math.h>
27 #include <FBaseString.h>
28 #include <FBaseSysLog.h>
29 #include <FBaseByteBuffer.h>
30 #include <FGrpFloatRectangle.h>
31 #include <FGrp_BufferInfoImpl.h>
32 #include <FGrpFloatMatrix4.h>
33 #include <FUiAnimVisualElement.h>
34
35 #include "FUi_CoordinateSystemUtils.h"
36 #include "FUi_EcoreEvas.h"
37 #include "FUi_EcoreEvasMgr.h"
38 #include "FUiAnim_Debug.h"
39 #include "FUiAnim_EflLayer.h"
40 #include "FUiAnim_EflNode.h"
41 #include "FUiAnim_MatrixUtil.h"
42 #include "FUiAnim_VisualElementImpl.h"
43 #include "FUiAnim_VisualElementSurfaceImpl.h"
44 #include "FUiAnim_RootVisualElement.h"
45
46 #include "FUiAnim_EflVisualElementSurfaceImpl.h"
47
48 // for capture
49 #include <Evas.h>
50 #include <Evas_Engine_Buffer.h>
51
52 using namespace std;
53 using namespace Tizen;
54 using namespace Tizen::Base;
55 using namespace Tizen::Graphics;
56
57 namespace
58 {
59
60 void EvasSmartObjectShowChildren(Evas_Object* pSmartObject);
61 void EvasSmartObjectHideChildren(Evas_Object* pSmartObject);
62 void EvasSmartObjectHideAllChildren(Evas_Object* pSmartObject);
63
64 Evas_Smart_Class smartClassForVisualElement =
65 {
66         "visual_element",                       // name
67         4,                                                      // version
68         null,                                                   // add
69         null,                                                   // del
70         null,                                                   // move
71         null,                                                   // resize
72         EvasSmartObjectShowChildren,    // show
73         EvasSmartObjectHideChildren,    // hide
74         null,                                                   // color_set
75         null,                                                   // clip_set
76         null,                                                   // clip_unset
77         null,                                                   // calculate
78         null,                                                   // member_add
79         null,                                                   // member_del
80         null,                                                   // parent
81         null,                                                   // call-backs
82         null,                                                   // interfaces
83         null,                                                   // data
84 };
85
86 Evas_Smart_Class smartClassForImageHolder =
87 {
88         "image_holder",                                 // name
89         4,                                                      // version
90         null,                                                   // add
91         null,                                                   // del
92         null,                                                   // move
93         null,                                                   // resize
94         EvasSmartObjectShowChildren,    // show
95         EvasSmartObjectHideChildren,    // hide
96         null,                                                   // color_set
97         null,                                                   // clip_set
98         null,                                                   // clip_unset
99         null,                                                   // calculate
100         null,                                                   // member_add
101         null,                                                   // member_del
102         null,                                                   // parent
103         null,                                                   // call-backs
104         null,                                                   // interfaces
105         null,                                                   // data
106 };
107
108 void
109 EvasSmartObjectShowChildren(Evas_Object* pSmartObject)
110 {
111         Eina_List* pChildrenList = evas_object_smart_members_get(pSmartObject);
112         if (likely(pChildrenList))
113         {
114                 void* pEvasObject = null;
115                 EINA_LIST_FREE(pChildrenList, pEvasObject)
116                 {
117                         if (likely(pEvasObject) && unlikely(evas_object_type_get((Evas_Object*)pEvasObject) != smartClassForVisualElement.name))
118                         {
119                                 evas_object_show((Evas_Object*)pEvasObject);
120
121                         }
122                 }
123         }
124 }
125
126 void
127 EvasSmartObjectHideChildren(Evas_Object* pSmartObject)
128 {
129         // hide objects only for this node
130         Eina_List* pChildrenList = evas_object_smart_members_get(pSmartObject);
131         if (likely(pChildrenList))
132         {
133                 void* pEvasObject = null;
134                 EINA_LIST_FREE(pChildrenList, pEvasObject)
135                 {
136                         if (likely(pEvasObject) && unlikely(evas_object_type_get((Evas_Object*)pEvasObject) != smartClassForVisualElement.name))
137                         {
138                                 evas_object_hide((Evas_Object*)pEvasObject);
139                         }
140                 }
141         }
142 }
143
144 void
145 EvasSmartObjectHideAllChildren(Evas_Object* pSmartObject)
146 {
147         // hide all descendants
148         Eina_List* pChildrenList = evas_object_smart_members_get(pSmartObject);
149         if (likely(pChildrenList))
150         {
151                 void* pEvasObject = null;
152                 EINA_LIST_FREE(pChildrenList, pEvasObject)
153                 {
154                         if (likely(pEvasObject))
155                         {
156                                 evas_object_hide((Evas_Object*)pEvasObject);
157                         }
158                 }
159         }
160 }
161
162 inline void
163 NormalizeUniformRectangle(Rectangle& rectangle, int width, int height)
164 {
165         if (unlikely(width <= 0) || unlikely(height <= 0))
166         {
167                 return;
168         }
169
170         if (unlikely(rectangle.x < 0))
171         {
172                 rectangle.x = width - ((-rectangle.x) % width);
173         }
174
175         if (unlikely(rectangle.y < 0))
176         {
177                 rectangle.y = height - ((-rectangle.y) % height);
178         }
179 }
180
181 inline Evas_Render_Op
182 GetRenderOperation(Tizen::Ui::Animations::VisualElement::RenderOperation renderOperation)
183 {
184         switch (renderOperation)
185         {
186         default:
187         case Tizen::Ui::Animations::VisualElement::RENDER_OPERATION_BLEND:
188                 return EVAS_RENDER_BLEND;
189
190         case Tizen::Ui::Animations::VisualElement::RENDER_OPERATION_COPY:
191                 return EVAS_RENDER_COPY;
192         }
193 }
194
195 //Evas* __pEvas = null;
196 };
197
198
199 namespace Tizen { namespace Ui { namespace Animations
200 {
201
202 Evas_Smart* _EflNode::__pStaticSmartClass = null;
203 Evas_Smart* _EflNode::__pStaticSmartClassForImageHolder = null;
204
205 _EflNode::_EflNode(void)
206         : __pSurface(null)
207         , __pSharedSurface(null)
208         , __pEvas(null)
209         , __pSmartObject(null)
210         , __pClipObject(null)
211         , __pRectangleObject(null)
212         , __pImageHolder(null)
213         , __pNativeSmartObject(null)
214         , __pMap(null)
215         , __mapUsed(false)
216         , __renderOperation(VisualElement::RENDER_OPERATION_BLEND)
217         , __needEvasObjectSync(false)
218         , __realBounds(0.0f, 0.0f, 0.0f, 0.0f)
219         , __backgroundColor(0.0f, 0.0f, 0.0f, 0.0f)     // fully transparent rectangle object by default
220         , __pLayer(null)
221 {
222 }
223
224 _EflNode::~_EflNode(void)
225 {
226         Destruct();
227 }
228
229 result
230 _EflNode::Construct(void)
231 {
232 #if 0
233         if (__pSmartObject || __pMap)
234         {
235                 return E_INVALID_STATE;
236         }
237
238         if (!__pEvas)
239         {
240                 // todo: need refactoring !
241                 Tizen::Ui::_EcoreEvasMgr* pMgr = Tizen::Ui::GetEcoreEvasMgr();
242
243                 if (pMgr && pMgr->GetEcoreEvas())
244                 {
245                         __pEvas = pMgr->GetEcoreEvas()->GetEvas();
246                 }
247
248                 if (!__pEvas)
249                 {
250                         return E_SYSTEM;
251                 }
252         }
253
254
255         if (!__pStaticSmartClass)
256         {
257                 __pStaticSmartClass = evas_smart_class_new(&smartClassForVisualElement); // TODO: no need to delete ???
258         }
259
260         __pSmartObject = evas_object_smart_add(__pEvas, __pStaticSmartClass);
261         if (!__pSmartObject)
262         {
263                 goto failure;
264         }
265
266         //evas_object_pass_events_set(__pSmartObject, EINA_TRUE);
267         evas_object_propagate_events_set(__pSmartObject, EINA_TRUE);
268         //evas_object_propagate_events_set(__pSmartObject, EINA_FALSE);
269
270         evas_object_show(__pSmartObject);
271
272 //      __pClipObject = evas_object_rectangle_add(__pEvas);
273 //      if (!__pClipObject)
274 //              goto failure;
275 //
276 //
277 //      evas_object_smart_member_add(__pClipObject,__pSmartObject);
278 //      evas_object_lower(__pClipObject);
279 //
280 //      evas_object_pass_events_set(__pClipObject, EINA_TRUE);
281
282         // Create map for 3D
283         __pMap = evas_map_new(4);
284         if (!__pMap)
285         {
286                 goto failure;
287         }
288
289         evas_map_alpha_set(__pMap, EINA_TRUE);
290         evas_map_smooth_set(__pMap, EINA_TRUE);
291
292         return E_SUCCESS;
293
294 failure:
295         if (__pSmartObject)
296         {
297                 evas_object_del(__pSmartObject);
298         }
299
300         __pSmartObject = null;
301
302 //      if (__pClipObject)
303 //              evas_object_del(__pClipObject);
304 //
305 //      __pClipObject = null;
306
307         if (__pMap)
308         {
309                 evas_map_free(__pMap);
310         }
311
312         __pMap = null;
313
314         return E_SYSTEM;
315 #else
316         return E_SUCCESS;
317 #endif
318 }
319
320 result
321 _EflNode::RebuildIfNeeded(const _INativeNode& parent)
322 {
323         _EflNode* pParent = dynamic_cast<_EflNode*>(const_cast<_INativeNode*>(&parent));
324         if (!pParent)
325         {
326                 return E_INVALID_ARG;
327         }
328         if (pParent->__pLayer)
329         {
330                 return ReConstruct(*pParent->__pLayer);
331         }
332         return E_INVALID_STATE;
333 //      __pLayer = pParent->pLayer;
334         //return ReConstruct(pParent->__pEvas);
335 }
336
337 result
338 _EflNode::ReConstruct(const _NativeLayer& layer)
339 {
340         _EflLayer* pLayer = dynamic_cast<_EflLayer*>(const_cast<_NativeLayer*>(&layer));
341         if (!pLayer)
342         {
343                 return E_INVALID_ARG;
344         }
345         __pLayer = pLayer;
346         return ReConstruct(pLayer->GetEvas());
347 }
348
349 result
350 _EflNode::ReConstruct(const Evas* pEvas)
351 {
352         if (pEvas == null)
353         {
354                 return E_INVALID_ARG;
355         }
356
357         Destruct();
358
359         __pEvas = const_cast<Evas*>(pEvas);
360
361
362         if (!__pStaticSmartClass)
363         {
364                 __pStaticSmartClass = evas_smart_class_new(&smartClassForVisualElement); // TODO: no need to delete ???
365         }
366
367         __pSmartObject = evas_object_smart_add(__pEvas, __pStaticSmartClass);
368         if (!__pSmartObject)
369         {
370                 goto failure;
371         }
372
373         if (!__pStaticSmartClassForImageHolder)
374         {
375                 __pStaticSmartClassForImageHolder = evas_smart_class_new(&smartClassForImageHolder); // TODO: no need to delete ???
376         }
377
378         //evas_object_pass_events_set(__pSmartObject, EINA_TRUE);
379         evas_object_propagate_events_set(__pSmartObject, EINA_TRUE);
380         //evas_object_propagate_events_set(__pSmartObject, EINA_FALSE);
381
382         if (__pNativeSmartObject)
383         {
384                 evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject);
385                 AdjustEvasObjectOrder();
386         }
387
388         evas_object_show(__pSmartObject);
389
390 //      __pClipObject = evas_object_rectangle_add(pEvas);
391 //      if (!__pClipObject)
392 //              goto failure;
393 //
394 //
395 //      evas_object_smart_member_add(__pClipObject,__pSmartObject);
396 //      evas_object_lower(__pClipObject);
397 //
398 //      evas_object_pass_events_set(__pClipObject, EINA_TRUE);
399
400         // Create map for 3D
401         if (__pMap)
402         {
403                 evas_map_free(__pMap);
404         }
405         __pMap = evas_map_new(4);
406         if (!__pMap)
407         {
408                 goto failure;
409         }
410
411         evas_map_alpha_set(__pMap, EINA_TRUE);
412         evas_map_smooth_set(__pMap, EINA_TRUE);
413
414         return E_SUCCESS;
415
416 failure:
417         __pEvas = null;
418
419         if (__pSmartObject)
420         {
421                 evas_object_del(__pSmartObject);
422         }
423
424         __pSmartObject = null;
425
426 //      if (__pClipObject)
427 //              evas_object_del(__pClipObject);
428 //
429 //      __pClipObject = null;
430
431         if (__pMap)
432         {
433                 evas_map_free(__pMap);
434         }
435
436         __pMap = null;
437
438         return E_SYSTEM;
439 }
440
441 result
442 _EflNode::Destruct(void)
443 {
444         __pEvas = null;
445         if (__pSmartObject)
446         {
447                 evas_object_del(__pSmartObject);
448                 __pSmartObject = null;
449         }
450
451         if (__pClipObject)
452         {
453                 evas_object_del(__pClipObject);
454                 __pClipObject = null;
455         }
456
457         if (__pRectangleObject)
458         {
459                 evas_object_del(__pRectangleObject);
460                 __pRectangleObject = null;
461         }
462
463         if (__pMap)
464         {
465                 evas_map_free(__pMap);
466                 __pMap = null;
467         }
468
469         if (__pSurface)
470         {
471                 delete __pSurface;
472                 __pSurface = null;
473         }
474
475         if (__pSharedSurface)
476         {
477                 delete __pSharedSurface;
478                 __pSharedSurface = null;
479         }
480
481         if (__pImageHolder)
482         {
483                 evas_object_del(__pImageHolder);
484         }
485
486         if (unlikely(__pNativeSmartObject))
487         {
488                 evas_object_smart_member_del(__pNativeSmartObject);
489                 //__pNativeSmartObject = null;
490         }
491
492         return E_SUCCESS;
493 }
494
495 Evas*
496 _EflNode::GetEvas(void) const
497 {
498         return __pEvas;
499 }
500
501 Handle
502 _EflNode::GetGroupContainer(void) const
503 {
504         return reinterpret_cast< Handle >(__pSmartObject);
505 }
506
507 void
508 _EflNode::AdjustEvasObjectOrder(void)
509 {
510
511         if (__pNativeSmartObject)
512                 evas_object_lower(__pNativeSmartObject);
513 //              evas_object_raise(__pNativeSmartObject);
514
515 }
516
517 void
518 _EflNode::SetNativeObject(VisualElement& element, Evas_Object* pNativeObject)
519 {
520         if (unlikely(__pNativeSmartObject != pNativeObject))
521         {
522                 if (unlikely(__pNativeSmartObject))
523                 {
524                         evas_object_smart_member_del(__pNativeSmartObject);
525                 }
526
527                 __pNativeSmartObject = pNativeObject;
528
529                 if (__pNativeSmartObject)
530                 {
531                         evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject);
532                 }
533         }
534
535         AdjustEvasObjectOrder();
536
537
538         const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
539                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
540                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
541                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
542
543         _VisualElementImpl* pElementImpl = _VisualElementImpl::GetInstance(element);
544         if (likely(pElementImpl))
545         {
546                 pElementImpl->InvalidateHierarchyProps(nativeProps, false, false);
547         }
548 }
549
550 void
551 _EflNode::AddNativeSmartObject(VisualElement& element, Evas_Object* pSmartObject)
552 {
553         SetNativeObject(element, pSmartObject);
554 }
555
556 void
557 _EflNode::RemoveNativeObject(void)
558 {
559         __pNativeSmartObject = null;
560 }
561
562 Evas_Object*
563 _EflNode::GetNativeObject(void) const
564 {
565         return __pNativeSmartObject;
566 }
567
568 result
569 _EflNode::InsertChild(_INativeNode& child, const _INativeNode* pReference, bool above)
570 {
571         _EflNode& nativeChild = dynamic_cast< _EflNode& >(child);
572         const _EflNode* pNativeReference = dynamic_cast< const _EflNode* >(pReference);
573
574         RemoveChild(nativeChild);
575
576         if (!__pSmartObject)
577         {
578                 return E_INVALID_STATE;
579         }
580
581         evas_object_smart_member_add(nativeChild.__pSmartObject, __pSmartObject);
582
583         // The order of evas objects should be as follows:
584         //              [native smart object]   [image/image-holder/rectangle/clipper]  [child smart object]*
585
586         if (likely(pNativeReference))
587         {
588                 if (likely(above))
589                 {
590                         evas_object_stack_above(nativeChild.__pSmartObject, pNativeReference->__pSmartObject);
591                 }
592                 else
593                 {
594                         evas_object_stack_below(nativeChild.__pSmartObject, pNativeReference->__pSmartObject);
595                 }
596         }
597         else
598         {
599                 if (likely(above))
600                 {
601                         evas_object_raise(nativeChild.__pSmartObject);
602                 }
603                 else
604                 {
605                         Evas_Object* pRefObject = null;
606
607
608                         if (likely(__pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSurface)))
609                         {
610                                 pRefObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
611                         }
612                         else if (likely(__pRectangleObject))
613                         {
614                                 pRefObject = __pRectangleObject;
615                         }
616                         else if (likely(__pImageHolder))
617                         {
618                                 pRefObject = __pImageHolder;
619                         }
620
621                         if (likely(pRefObject))
622                         {
623                                 evas_object_stack_above(nativeChild.__pSmartObject, pRefObject);
624                         }
625                         else
626                         {
627                                 evas_object_lower(nativeChild.__pSmartObject);
628                         }
629                 }
630         }
631
632         AdjustEvasObjectOrder();
633
634         return E_SUCCESS;
635 }
636
637 result
638 _EflNode::RemoveChild(_INativeNode& child)
639 {
640         _EflNode& nativeChild = dynamic_cast< _EflNode& >(child);
641
642         //      WARNING:
643         //      Perform recursive hiding evas objects !
644         //      After removing a child, it is not managed by visual element.
645         //      Hence, because all descendants of it will not be hided automatically, it is needed to
646         //      hide all descendants of it (or need adding damage region)
647         smartClassForVisualElement.hide = EvasSmartObjectHideAllChildren;
648         evas_object_hide(nativeChild.__pSmartObject);
649         smartClassForVisualElement.hide = EvasSmartObjectHideChildren;
650
651         evas_object_smart_member_del(nativeChild.__pSmartObject);
652
653 #if 0
654         if (nativeChild.__pClipObject)
655                 evas_object_hide((Evas_Object*)nativeChild.__pClipObject);
656
657         if (nativeChild.__pRectangleObject)
658                 evas_object_hide((Evas_Object*)nativeChild.__pRectangleObject);
659
660         if (nativeChild.__pSurface && nativeChild.__pSurface->GetNativeHandle())
661                 evas_object_hide((Evas_Object*)nativeChild.__pSurface->GetNativeHandle());
662 #endif
663
664         return E_SUCCESS;
665 }
666
667 result
668 _EflNode::SetFlushNeeded(void)
669 {
670 #if 0
671         evas_damage_rectangle_add(
672                 __pEvas,
673                 static_cast< int >(floorf(dirtyRectangle.x)),
674                 static_cast< int >(floorf(dirtyRectangle.y)),
675                 static_cast< int >(ceilf(dirtyRectangle.width)),
676                 static_cast< int >(ceilf(dirtyRectangle.height))
677                 );
678 #endif
679
680         if (!__pSurface || !_VisualElementSurfaceImpl::GetInstance(*__pSurface))
681         {
682                 return E_INVALID_STATE;
683         }
684 #if 0
685         evas_object_image_pixels_dirty_set(reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle()), true);
686 #else
687
688         Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
689
690         if (pImageObject)
691         {
692                 int imageWidth = 0;
693                 int imageHeight = 0;
694
695                 evas_object_image_data_set(pImageObject, evas_object_image_data_get(pImageObject, 1));
696
697                 evas_object_image_size_get(pImageObject, &imageWidth, &imageHeight);
698                 evas_object_image_data_update_add(pImageObject, 0, 0, imageWidth, imageHeight);
699         }
700
701 #endif
702
703         if(__pLayer)
704         {
705                 __pLayer->SetFlushNeeded();
706         }
707
708 #if 0
709         //contentChanged = false;
710         bool contentChanged = false;
711
712         if (contentChanged)
713         {
714                 evas_object_image_pixels_dirty_set((Evas_Object*) _VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle(), true);
715         }
716         else
717         {
718                 evas_object_image_data_update_add(
719                         (Evas_Object*) _VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle(),
720                         dirtyRectangle.x,
721                         dirtyRectangle.y,
722                         dirtyRectangle.width,
723                         dirtyRectangle.height
724                 );
725
726 #if 1
727                 evas_object_image_data_update_add(
728                         (Evas_Object*) _VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle(),
729                         dirtyRectangle.x,
730                         dirtyRectangle.y,
731                         dirtyRectangle.width,
732                         dirtyRectangle.height
733                 );
734 #endif
735         }
736
737 #endif
738
739         return E_SUCCESS;
740 }
741
742 result
743 _EflNode::Flush(void)
744 {
745 #ifndef VE_VSYNC_UPDATE
746         if(__pLayer)
747         {
748                 __pLayer->Flush();
749         }
750 //      ecore_evas_manual_render(ecore_evas_ecore_evas_get(__pEvas));
751 #endif
752
753         return E_SUCCESS;
754 }
755
756 _Colorf
757 _EflNode::GetBackgroundColor(void) const
758 {
759 //      if (!__pRectangleObject)
760 //              return _Colorf();   // CHECKME: Default background color ?
761
762         return __backgroundColor;
763 }
764
765 result
766 _EflNode::SetBackgroundColor(const _Colorf& backgroundColor)
767 {
768 //      if (!__pRectangleObject)
769 //              return E_INVALID_STATE;
770
771         __backgroundColor = backgroundColor;
772
773         return E_SUCCESS;
774 }
775
776 bool
777 _EflNode::AdjustImageHolder(bool useHolder)
778 {
779         if (unlikely(!__pSurface))
780         {
781                 return false;
782         }
783
784         Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
785         if (unlikely(!pImageObject))
786         {
787                 return false;
788         }
789
790         if (unlikely(useHolder))
791         {
792                 if (likely(!__pImageHolder))
793                 {
794                         __pImageHolder = evas_object_smart_add(__pEvas, __pStaticSmartClassForImageHolder);
795                         if (unlikely(!__pSmartObject))
796                         {
797                                 SysLog(NID_UI_ANIM, "Smart object cannot be created.");
798                                 return false;
799                         }
800
801                         evas_object_propagate_events_set(__pImageHolder, EINA_TRUE);
802                         evas_object_smart_member_add(pImageObject, __pImageHolder);
803
804                         evas_object_smart_member_add(__pImageHolder, __pSmartObject);
805                         evas_object_lower(__pImageHolder);
806                         AdjustEvasObjectOrder();
807
808                         if (evas_object_visible_get(__pSmartObject))
809                         {
810                                 evas_object_show(__pImageHolder);
811                         }
812                         else
813                         {
814                                 evas_object_hide(__pImageHolder);
815                         }
816
817                         return true;
818                 }
819         }
820         else
821         {
822                 if (likely(__pImageHolder))
823                 {
824                         evas_object_smart_member_add(pImageObject, __pSmartObject);
825                         evas_object_lower(pImageObject);
826                         AdjustEvasObjectOrder();
827
828                         evas_object_del(__pImageHolder);
829                         __pImageHolder = null;
830
831                         return true;
832                 }
833         }
834
835         return false;
836 }
837
838 result
839 _EflNode::Reconfigure(VisualElementSurface* pSurface, _VisualElementImpl& element, bool surfaceOnly)
840 {
841         Evas_Object* pImageObjectOrg = null;
842         Evas_Object* pImageObjectNew = null;
843         int imageWidth = 0;
844         int imageHeight = 0;
845
846         const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
847                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
848                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
849                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
850         int& invalidatedNativeProps = element.__pSharedData->invalidatedNativeProps;
851
852         invalidatedNativeProps &= nativeProps;
853
854         if (likely(pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*pSurface)))
855         {
856                 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle());
857         }
858
859         if (likely(__pSharedSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)))
860         {
861                 pImageObjectOrg = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
862         }
863
864
865         if (likely(pImageObjectNew))
866         {
867                 bool createNewObject = true;
868
869                 evas_object_image_size_get(pImageObjectNew, &imageWidth, &imageHeight);
870
871                 if (likely(__pSurface))
872                 {
873                         // if the surfaces are same, change the size
874                         if (likely(pImageObjectNew == pImageObjectOrg))
875                         {
876                                 createNewObject = false;
877                         }
878                         // if the surface is changed, delete old surface
879                         else
880                         {
881                                 delete __pSharedSurface;
882                                 __pSharedSurface = null;
883                         }
884                 }
885
886                 // create new surface
887                 if (unlikely(createNewObject))
888                 {
889
890                         unique_ptr<VisualElementSurface> pNewSharedSurface(new (std::nothrow) VisualElementSurface(*pSurface));
891                         SysTryReturnResult(NID_UI_ANIM, pNewSharedSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
892
893                         _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
894                         if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer == null)
895                         {
896                                 unique_ptr<VisualElementSurface> pNewSurface(new (std::nothrow) VisualElementSurface(*pSurface));
897                                 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
898
899                                 if (__pSurface)
900                                 {
901                                         delete __pSurface;
902                                         __pSurface = null;
903                                 }
904                                 __pSurface = pNewSurface.release();
905                         }
906                         else
907                         {
908                                 unique_ptr<VisualElementSurface> pNewSurface(_VisualElementSurfaceImpl::CreateSurfaceN((Handle)__pLayer, Dimension(1, 1)));
909                                 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
910
911                                 if (__pSurface)
912                                 {
913                                         delete __pSurface;
914                                         __pSurface = null;
915                                 }
916                                 __pSurface = pNewSurface.release();
917
918                                 if (!element.GetModel()->__imageFilePath.IsEmpty() && _VisualElementSurfaceImpl::GetInstance(*__pSurface))
919                                 {
920                                         _VisualElementSurfaceImpl::GetInstance(*__pSurface)->SetImage(element.GetModel()->__imageFilePath);
921                                 }
922                         }
923
924                         if (__pSharedSurface)
925                         {
926                                 delete __pSharedSurface;
927                                 __pSharedSurface = null;
928                         }
929                         __pSharedSurface = pNewSharedSurface.release();
930
931                         Evas_Object* pImageObject = null;
932                         if (_VisualElementSurfaceImpl::GetInstance(*__pSurface))
933                         {
934                                 pImageObject = (Evas_Object*)_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle();
935
936                                 if (likely(pImageObject))
937                                 {
938                                         evas_object_anti_alias_set(pImageObject, EINA_TRUE);
939
940                                         evas_object_smart_member_add(pImageObject, __pSmartObject);
941                                         evas_object_lower(pImageObject);
942                                         AdjustEvasObjectOrder();
943
944                                         if (evas_object_visible_get(__pSmartObject))
945                                         {
946                                                 evas_object_show(pImageObject);
947                                         }
948                                         else
949                                         {
950                                                 evas_object_hide(pImageObject);
951                                         }
952
953
954                                         _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
955                                         if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer != null)
956                                         {
957                                                 evas_object_image_source_set(pImageObject, pImageObjectNew);
958                                         }
959
960                                         //evas_object_pass_events_set(pImageObject, EINA_TRUE);
961
962                                         __needEvasObjectSync = true;
963                                         invalidatedNativeProps |= nativeProps;
964                                 }
965                         }
966                 }
967                 // TODO : Have surface, but not newly created
968
969         }
970         else
971         {
972                 // delete old surface
973                 delete __pSurface;
974                 __pSurface = null;
975
976                 // delete shared surface
977                 delete __pSharedSurface;
978                 __pSharedSurface = null;
979         }
980
981
982         if (likely(__pSurface && _VisualElementSurfaceImpl::GetInstance(*__pSurface)))
983         {
984                 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
985
986                 if (unlikely(__pRectangleObject))
987                 {
988                         evas_object_del(__pRectangleObject);
989                         __pRectangleObject = null;
990                 }
991         }
992         else
993         {
994                 pImageObjectNew = null;
995
996                 // WARNING:
997                 //      Newly created rectangle object must be reconfigured by VE!!! (size/pos/visibility/etc)
998                 //
999                 if (likely(!__pRectangleObject) && likely(element.__pSharedData->needSurface))
1000                 {
1001                         __pRectangleObject = evas_object_rectangle_add(__pEvas);
1002                         if (likely(__pRectangleObject))
1003                         {
1004                                 //evas_object_pass_events_set(__pRectangleObject, EINA_TRUE);
1005                                 evas_object_smart_member_add(__pRectangleObject, __pSmartObject);
1006                                 evas_object_lower(__pRectangleObject);
1007                                 AdjustEvasObjectOrder();
1008
1009                                 if (evas_object_visible_get(__pSmartObject))
1010                                 {
1011                                         evas_object_show(__pRectangleObject);
1012                                 }
1013                                 else
1014                                 {
1015                                         evas_object_hide(__pRectangleObject);
1016                                 }
1017
1018                                 __needEvasObjectSync = true;
1019                                 invalidatedNativeProps |= nativeProps;
1020                         }
1021                 }
1022         }
1023
1024         element.__pSharedData->surfaceChanged = false;
1025
1026         if (surfaceOnly)
1027         {
1028                 return E_SUCCESS;
1029         }
1030
1031
1032         const bool isVeVisible = element.IsVisibleI();
1033         const bool isEvasVisible = evas_object_visible_get(__pSmartObject);
1034
1035
1036         // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1037         if (unlikely(!isVeVisible))
1038         {
1039                 if (isEvasVisible)
1040                 {
1041                         evas_object_hide(__pSmartObject);
1042                 }
1043
1044                 invalidatedNativeProps = 0;
1045
1046                 goto finished;
1047         }
1048         else
1049         {
1050                 if (!isEvasVisible)
1051                 {
1052                         // WARNING:
1053                         //      When visibility of VE is changed into 'visible' and evas object is invisible,
1054                         //      it is needed to set all evas object properties because not all properties were applied due to short-circuit optimization
1055                         //      (When VE is invisible, bounds and colors are not set for optimization)
1056                         invalidatedNativeProps = nativeProps;
1057                 }
1058         }
1059
1060         // Change hierarchy properties such as bounds, clipping and map
1061         if (likely(invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS)) || unlikely(__needEvasObjectSync))
1062         {
1063                 bool needResize = false;
1064                 bool needMove = false;
1065                 bool clipChanged = false;
1066                 bool needMap = false;
1067
1068                 Evas_Coord newX = 0;
1069                 Evas_Coord newY = 0;
1070                 Evas_Coord newW = 0;
1071                 Evas_Coord newH = 0;
1072
1073                 __realBounds.width = element.__alignedSize.width;
1074                 __realBounds.height = element.__alignedSize.height;
1075
1076                 //_VisualElementImpl::AdjustSizeForSurface(__realBounds.width, __realBounds.height);
1077                 _VisualElementCoordinateSystem::ConvertDimensionToPhysical(__realBounds.width, __realBounds.height);
1078
1079                 // WARNING:
1080                 //      Do not use to MakeIntegralDimension. All information about coordinates(position/size) are calculated with same(point) way.
1081                 _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.width, __realBounds.height, newW, newH);
1082
1083
1084                 float clipX = 0.0f;
1085                 float clipY = 0.0f;
1086                 float clipW = 0.0f;
1087                 float clipH = 0.0f;
1088                 Evas_Object* pParentClipper = null;
1089
1090                 if (unlikely(element.__needTransform) || likely(element.__needClipForUntransformed))
1091                 {
1092                         const _VisualElementImpl* pClipSource = element.GetClipSource();
1093
1094                         if (likely(pClipSource))
1095                         {
1096                                 _EflNode* pParentClipNode = static_cast< _EflNode* >(pClipSource->GetNativeNode());
1097                                 if (likely(pParentClipNode))
1098                                 {
1099                                         clipX = pParentClipNode->__realBounds.x;
1100                                         clipY = pParentClipNode->__realBounds.y;
1101                                         clipW = pParentClipNode->__realBounds.width;
1102                                         clipH = pParentClipNode->__realBounds.height;
1103
1104                                         pParentClipper = pParentClipNode->__pClipObject;
1105                                 }
1106                         }
1107                 }
1108
1109
1110                 // Coordinates(including __needTransform flag) are validated by getting clip-source above
1111
1112                 if (likely(!element.__needTransform))
1113                 {
1114                         __realBounds.x = element.__boundingBoxToClipSource.x;
1115                         __realBounds.y = element.__boundingBoxToClipSource.y;
1116                         _VisualElementCoordinateSystem::ConvertPointToPhysical(__realBounds.x, __realBounds.y);
1117
1118                         __realBounds.x += clipX;
1119                         __realBounds.y += clipY;
1120                         _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.x, __realBounds.y, newX, newY);
1121
1122 #if 0
1123                         int evasOutputW, evasOutputH;
1124                         evas_output_size_get(__pEvas, &evasOutputW, &evasOutputH);
1125
1126 //                      if (newX >= 480 || newY >= 800 || newX + newW < 0 || newY + newH < 0)
1127 //                      if ((newX >= SCREEN_WIDTH || newY >= SCREEN_HEIGHT || newX + newW < 0 || newY + newH < 0) ||
1128                         if ((newX >= evasOutputW || newY >= evasOutputH || newX + newW < 0 || newY + newH < 0) ||
1129                                 (likely(pParentClipper) && (newX >= clipX + clipW || newY >= clipY + clipH || newX + newW < clipX || newY + newH < clipY)))
1130                         {
1131                                 if (isEvasVisible)
1132                                         evas_object_hide(__pSmartObject);
1133
1134                                 element.__pSharedData->invalidatedNativeProps = 0;
1135
1136                                 goto finished;
1137                         }
1138 #endif
1139
1140 #if 0
1141                         if (likely(pParentClipper))
1142                         {
1143                                 if (likely(newX >= clipX) && likely(newY >= clipY) && likely(newX + newW <= clipX + clipW) && likely(newY + newH <= clipY + clipH))
1144                                         pParentClipper = null;
1145                         }
1146 #endif
1147                 }
1148                 else
1149                 {
1150                         float x[4];
1151                         float y[4];
1152                         float z[4];
1153                         int intX[4];
1154                         int intY[4];
1155                         const Tizen::Graphics::FloatMatrix4& xform = element.GetMatrixToClipSource();
1156
1157                         x[0] = 0.0f;
1158                         y[0] = 0.0f;
1159                         z[0] = 0.0f;
1160                         x[1] = element.__alignedSize.width;
1161                         y[1] = 0.0f;
1162                         z[1] = 0.0f;
1163                         x[2] = element.__alignedSize.width;
1164                         y[2] = element.__alignedSize.height;
1165                         z[2] = 0.0f;
1166                         x[3] = 0.0f;
1167                         y[3] = element.__alignedSize.height;
1168                         z[3] = 0.0f;
1169
1170                         for (int i = 0; i < 4; i++)
1171                         {
1172                                 _MatrixUtilTransform(xform, &x[i], &y[i], &z[i]);
1173                                 _VisualElementCoordinateSystem::ConvertPointToPhysical(x[i], y[i]);
1174
1175                                 x[i] += clipX;
1176                                 y[i] += clipY;
1177                         }
1178
1179                         // WARNING:
1180                         //      Use surface size for UV-mapping *ONLY FOR* direct-map-on-image-object, not map-on-smart-object !!!
1181                         if (unlikely(!__pSharedSurface) || unlikely(element.__useContentBounds) || likely(__pClipObject))
1182                         {
1183                                 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1184                                 evas_map_point_image_uv_set(__pMap, 1, (double)newW, 0.0);
1185                                 evas_map_point_image_uv_set(__pMap, 2, (double)newW, (double)newH);
1186                                 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)newH);
1187                         }
1188                         else
1189                         {
1190                                 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1191
1192                                 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1193                                 evas_map_point_image_uv_set(__pMap, 1, (double)surfaceSize.width, 0.0);
1194                                 evas_map_point_image_uv_set(__pMap, 2, (double)surfaceSize.width, (double)surfaceSize.height);
1195                                 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)surfaceSize.height);
1196                         }
1197
1198                         for (int i = 0; i < 4; i++)
1199                         {
1200                                 // WARNING: Do not need integral Z ??
1201                                 _VisualElementCoordinateSystem::MakeIntegralPoint(x[i], y[i], intX[i], intY[i]);
1202                                 evas_map_point_coord_set(__pMap, i, intX[i], intY[i], static_cast< int >(z[i]));
1203                         }
1204
1205
1206                         __realBounds.x = x[0];
1207                         __realBounds.y = y[0];
1208                         newX = intX[0];
1209                         newY = intY[0];
1210
1211                         needMap = true;
1212                 }
1213
1214                 // Adjust flag for bounds changing
1215                 if (unlikely(__needEvasObjectSync))
1216                 {
1217                         needMove = true;
1218                         needResize = true;
1219                 }
1220                 else
1221                 {
1222                         Evas_Coord objX;
1223                         Evas_Coord objY;
1224                         Evas_Coord objW;
1225                         Evas_Coord objH;
1226
1227                         evas_object_geometry_get(__pSmartObject, &objX, &objY, &objW, &objH);
1228
1229                         if (likely(!needMove))
1230                         {
1231                                 needMove = (newX != objX || newY != objY);
1232                         }
1233
1234                         if (likely(!needResize))
1235                         {
1236                                 needResize = (newW != objW || newH != objH);
1237                         }
1238                 }
1239
1240
1241                 if (unlikely(element.__isClipChildren))
1242                 {
1243                         if (unlikely(!__pClipObject) && likely(element.__pSharedData->needSurface))
1244                         {
1245                                 __pClipObject = evas_object_rectangle_add(__pEvas);
1246                                 if (likely(__pClipObject))
1247                                 {
1248                                         evas_object_smart_member_add(__pClipObject, __pSmartObject);
1249                                         evas_object_lower(__pClipObject);
1250                                         AdjustEvasObjectOrder();
1251
1252                                         evas_object_pass_events_set(__pClipObject, EINA_TRUE);
1253                                         evas_object_static_clip_set(__pClipObject, 0);  // CHECKME: What does this mean by ?
1254
1255                                         if (evas_object_visible_get(__pSmartObject))
1256                                         {
1257                                                 evas_object_show(__pClipObject);
1258                                         }
1259                                         else
1260                                         {
1261                                                 evas_object_hide(__pClipObject);
1262                                         }
1263
1264                                         needMove = true;
1265                                         needResize = true;
1266                                         clipChanged = true;
1267                                 }
1268                         }
1269                 }
1270                 else
1271                 {
1272                         if (unlikely(__pClipObject))
1273                         {
1274                                 evas_object_del(__pClipObject);
1275                                 __pClipObject = null;
1276                                 clipChanged = true;
1277                         }
1278                 }
1279
1280
1281                 // WARNING:
1282                 //      Update image-holder information before using it !
1283                 //      Image-Holder is needed only when using content-bounds and maps on image-object, not smart-object.
1284                 if (unlikely(AdjustImageHolder(element.__useContentBounds && !__pClipObject && needMap)))
1285                 {
1286                         needMove = true;
1287                         needResize = true;
1288                         clipChanged = true;
1289                         __needEvasObjectSync = true;
1290                 }
1291
1292
1293                 // WARNING:
1294                 //      In general, changing size/position before mapping/clipping *may* improve performance, because calculating map and clip
1295                 //      needs bounds information.
1296
1297                 // Set-up Position
1298                 if (likely(needMove))
1299                 {
1300                         evas_object_move(__pSmartObject, newX, newY);
1301
1302                         if (likely(__pClipObject))
1303                         {
1304                                 evas_object_move(__pClipObject, newX, newY);
1305                         }
1306
1307                         if (likely(__pImageHolder))
1308                         {
1309                                 evas_object_move(__pImageHolder, newX, newY);
1310                         }
1311
1312                         if (likely(pImageObjectNew))
1313                         {
1314                                 evas_object_move(pImageObjectNew, newX, newY);
1315                         }
1316
1317                         if (unlikely(__pRectangleObject))
1318                         {
1319                                 evas_object_move(__pRectangleObject, newX, newY);
1320                         }
1321
1322                         if (unlikely(__pNativeSmartObject))
1323                         {
1324                                 evas_object_move(__pNativeSmartObject, newX, newY);
1325                         }
1326                 }
1327
1328                 // Set-up Size
1329                 if (unlikely(needResize))
1330                 {
1331                         evas_object_resize(__pSmartObject, newW, newH);
1332
1333                         if (likely(__pClipObject))
1334                         {
1335                                 evas_object_resize(__pClipObject, newW, newH);
1336                         }
1337
1338                         if (likely(__pImageHolder))
1339                         {
1340                                 evas_object_resize(__pImageHolder, newW, newH);
1341                         }
1342
1343                         if (likely(pImageObjectNew))
1344                         {
1345                                 evas_object_resize(pImageObjectNew, newW, newH);
1346                         }
1347
1348                         if (unlikely(__pRectangleObject))
1349                         {
1350                                 evas_object_resize(__pRectangleObject, newW, newH);
1351                         }
1352
1353                         if (unlikely(__pNativeSmartObject))
1354                         {
1355                                 evas_object_resize(__pNativeSmartObject, newW, newH);
1356                         }
1357
1358                 }
1359
1360
1361                 // Set-up Clipping
1362                 if (unlikely(__needEvasObjectSync) || unlikely(clipChanged) || unlikely(evas_object_clip_get(__pSmartObject) != pParentClipper))
1363                 {
1364                         evas_object_clip_set(__pSmartObject, pParentClipper);
1365
1366                         // CHECKME:
1367                         //      Is it needed to set clipper for image-holder smart object ?
1368
1369                         if (likely(__pClipObject))
1370                         {
1371                                 evas_object_clip_set(__pClipObject, pParentClipper);
1372
1373                                 if (unlikely(__pImageHolder))
1374                                 {
1375                                         evas_object_clip_set(__pImageHolder, __pClipObject);
1376                                 }
1377
1378                                 if (likely(pImageObjectNew))
1379                                 {
1380                                         evas_object_clip_set(pImageObjectNew, __pClipObject);
1381                                 }
1382
1383                                 if (unlikely(__pRectangleObject))
1384                                 {
1385                                         evas_object_clip_set(__pRectangleObject, __pClipObject);
1386                                 }
1387
1388                                 if (unlikely(__pNativeSmartObject))
1389                                 {
1390                                         evas_object_clip_set(__pNativeSmartObject, __pClipObject);
1391                                 }
1392                         }
1393                         else
1394                         {
1395                                 if (unlikely(__pImageHolder))
1396                                 {
1397                                         evas_object_clip_set(__pImageHolder, pParentClipper);
1398                                 }
1399
1400                                 if (likely(pImageObjectNew))
1401                                 {
1402                                         evas_object_clip_set(pImageObjectNew, pParentClipper);
1403                                 }
1404
1405                                 if (unlikely(__pRectangleObject))
1406                                 {
1407                                         evas_object_clip_set(__pRectangleObject, pParentClipper);
1408                                 }
1409
1410                                 if (unlikely(__pNativeSmartObject))
1411                                 {
1412                                         evas_object_clip_set(__pNativeSmartObject, pParentClipper);
1413                                 }
1414
1415                         }
1416                 }
1417
1418
1419                 // Set-up Maps
1420                 if (unlikely(__needEvasObjectSync) || unlikely(__mapUsed != needMap) || unlikely(needMap) || unlikely(clipChanged))
1421                 {
1422                         const bool needClipSmartMap = (__pClipObject && needMap);
1423                         const bool needClipObjectMap = (!__pClipObject && needMap);
1424
1425                         evas_object_map_enable_set(__pSmartObject, needClipSmartMap);
1426                         evas_object_map_set(__pSmartObject, (needClipSmartMap ? __pMap : null));
1427
1428                         if (unlikely(__pImageHolder))
1429                         {
1430                                 evas_object_map_enable_set(__pImageHolder, needClipObjectMap);
1431                                 evas_object_map_set(__pImageHolder, (needClipObjectMap ? __pMap : null));
1432
1433                                 if (likely(pImageObjectNew))
1434                                 {
1435                                         evas_object_map_enable_set(pImageObjectNew, EINA_FALSE);
1436                                         evas_object_map_set(pImageObjectNew, null);
1437                                 }
1438                         }
1439                         else if (likely(pImageObjectNew))
1440                         {
1441                                 evas_object_map_enable_set(pImageObjectNew, needClipObjectMap);
1442                                 evas_object_map_set(pImageObjectNew, (needClipObjectMap ? __pMap : null));
1443                         }
1444
1445                         if (unlikely(__pRectangleObject))
1446                         {
1447                                 evas_object_map_enable_set(__pRectangleObject, needClipObjectMap);
1448                                 evas_object_map_set(__pRectangleObject, (needClipObjectMap ? __pMap : null));
1449                         }
1450
1451                         if (unlikely(__pNativeSmartObject))
1452                         {
1453                                 evas_object_map_enable_set(__pNativeSmartObject, needClipObjectMap);
1454                                 evas_object_map_set(__pNativeSmartObject, (needClipObjectMap ? __pMap : null));
1455                         }
1456                         __mapUsed = needMap;
1457                 }
1458
1459
1460                 // Set-up Content Bounds
1461                 // WARNING:
1462                 //      EFL Bug! - evas_object_fill_set should be invoked only *AFTER* adjusting maps !!!!!
1463                 //                 If contents bounds are modifed before adjusting maps, it will not be applied !!!
1464                 if (likely(pImageObjectNew) && likely(__pSharedSurface))
1465                 {
1466                         bool needDefaultFillSet = true;
1467
1468                         if (unlikely(element.__useContentBounds))
1469                         {
1470                                 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1471                                 const FloatRectangle& contentBounds = element.__contentBounds;
1472                                 Rectangle contentBoundsAdjusted;
1473
1474                                 // Formula:
1475                                 //
1476                                 //  content bounds(px) = content bounds(uniform) * surface size(px)
1477                                 //
1478                                 //                                                                               surface size(px)                                  1
1479                                 //      mapped content size(px) = bounds size(px) * ------------------ = bounds size(px) * -----------------------
1480                                 //                                                                               content size(px)                       content size(uniform)
1481                                 //
1482                                 //      mapped content size(px) : surface size(px) = mapped content pos(px) : content pos(px)
1483                                 //
1484                                 //                                                                              mapped content size(px)    content pos(uniform) * bounds size(px)
1485                                 //      mapped content pos(px) = content pos(px) * ------------------------- = -----------------------------------------
1486                                 //                                                                                 surface size(px)            content size(uniform)
1487
1488                                 _VisualElementCoordinateSystem::MakeIntegralPoint(
1489                                         -contentBounds.x * static_cast< float >(newW) / contentBounds.width,
1490                                         -contentBounds.y * static_cast< float >(newH) / contentBounds.height,
1491                                         contentBoundsAdjusted.x,
1492                                         contentBoundsAdjusted.y
1493                                 );
1494                                 _VisualElementCoordinateSystem::MakeIntegralPoint(
1495                                         static_cast< float >(newW) / contentBounds.width,               // WARNING: No use of __realBounds. new[WH] is the real displaying value which is integral.
1496                                         static_cast< float >(newH) / contentBounds.height,
1497                                         contentBoundsAdjusted.width,
1498                                         contentBoundsAdjusted.height
1499                                 );
1500
1501                                 //NormalizeUniformRectangle(contentBoundsAdjusted, surfaceSize.width, surfaceSize.height);
1502
1503                                 if (likely(contentBoundsAdjusted.width > 0) && likely(contentBoundsAdjusted.height > 0))
1504                                 {
1505                                         evas_object_image_fill_set(
1506                                                 pImageObjectNew,
1507                                                 contentBoundsAdjusted.x,
1508                                                 contentBoundsAdjusted.y,
1509                                                 contentBoundsAdjusted.width,
1510                                                 contentBoundsAdjusted.height
1511                                         );
1512
1513                                         needDefaultFillSet = false;
1514                                 }
1515                         }
1516
1517                         if (likely(needDefaultFillSet))
1518                         {
1519                                 evas_object_image_fill_set(pImageObjectNew, 0, 0, newW, newH);
1520                         }
1521                 }
1522
1523
1524                 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS);
1525         }
1526
1527
1528         if ((invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY)) || unlikely(__needEvasObjectSync))
1529         {
1530                 float alpha = element.GetOpacityFromRoot();
1531                 bool renderOperationChanged = false;
1532
1533                 if (unlikely(__renderOperation != element.__renderOperation))
1534                 {
1535                         renderOperationChanged = true;
1536                         __renderOperation = element.__renderOperation;
1537                 }
1538
1539
1540                 // pImageObjectNew does exist.
1541                 if (likely(pImageObjectNew))
1542                 {
1543                         if (unlikely(renderOperationChanged))
1544                         {
1545                                 evas_object_render_op_set(pImageObjectNew, GetRenderOperation(element.__renderOperation));
1546                         }
1547 //
1548 //                      if (unlikely(__renderOperation == VisualElement::RENDER_OPERATION_COPY))
1549 //                      {
1550 //                              evas_object_color_set(pImageObjectNew, 255, 255, 255, 255);
1551 //                      }
1552 //                      else
1553 //                      {
1554                                 int premultipliedColor =  static_cast< int >(255.0f * alpha); // white color
1555                                 evas_object_color_set(pImageObjectNew, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1556 //                      }
1557                 }
1558
1559
1560                 // rectangle setting
1561                 if (unlikely(__pRectangleObject))
1562                 {
1563                         if (unlikely(renderOperationChanged))
1564                         {
1565                                 evas_object_render_op_set(__pRectangleObject, GetRenderOperation(element.__renderOperation));
1566                         }
1567
1568                         float alphaRect = alpha * __backgroundColor.Alpha() * 255.0f;
1569
1570                         evas_object_color_set(
1571                                 __pRectangleObject,
1572                                 static_cast< int >(__backgroundColor.Red() * alphaRect),
1573                                 static_cast< int >(__backgroundColor.Green() * alphaRect),
1574                                 static_cast< int >(__backgroundColor.Blue() * alphaRect),
1575                                 static_cast< int >(alphaRect)
1576                         );
1577                 }
1578
1579                 // WARNING: CHECKME: TODO:
1580                 //      How can we native smart object
1581
1582                 // Native Smart Object does exist.
1583                 if (unlikely(__pNativeSmartObject))
1584                 {
1585
1586                         if (unlikely(renderOperationChanged))
1587                         {
1588                                 evas_object_render_op_set(__pNativeSmartObject, GetRenderOperation(element.__renderOperation));
1589                         }
1590
1591                         if (unlikely(element.__renderOperation == VisualElement::RENDER_OPERATION_COPY))
1592                         {
1593                                 evas_object_color_set(__pNativeSmartObject, 0, 0, 0, 0);        // for smart
1594 //                              evas_object_color_set(__pNativeSmartObject, 255, 255, 255, 255);// for image
1595                         }
1596                         else
1597                         {
1598                                 int premultipliedColor = static_cast< int >(255.0f * alpha); // white color
1599                                 evas_object_color_set(__pNativeSmartObject, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1600                         }
1601
1602                 }
1603
1604                 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY);
1605         }
1606
1607
1608         // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1609         if (likely(isVeVisible))
1610         {
1611                 if (unlikely(!isEvasVisible))
1612                 {
1613                         evas_object_show(__pSmartObject);       // Children of smart-object such as rectangle and clip-object may be invisible here.
1614                 }
1615         }
1616         else
1617         {
1618                 if (unlikely(isEvasVisible))
1619                 {
1620                         evas_object_hide(__pSmartObject);
1621                 }
1622         }
1623
1624
1625         // WARNING:
1626         //      Only after setting all invalidated properties, need-sync flag can be cleared
1627         __needEvasObjectSync = false;
1628
1629 finished:
1630
1631         return E_SUCCESS;
1632 }
1633
1634 VisualElementSurface*
1635 _EflNode::GetSurface(void) const
1636 {
1637         return __pSurface;
1638 }
1639
1640
1641 }}}             // Tizen::Ui::Animations
1642