Prevent to update_add on object to use file_set
[framework/osp/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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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         if (__pLayer == &layer)
341         {
342                 return E_SUCCESS;
343         }
344
345         _EflLayer* pLayer = dynamic_cast<_EflLayer*>(const_cast<_NativeLayer*>(&layer));
346         if (!pLayer)
347         {
348                 return E_INVALID_ARG;
349         }
350         __pLayer = pLayer;
351         return ReConstruct(pLayer->GetEvas());
352 }
353
354 result
355 _EflNode::ReConstruct(const Evas* pEvas)
356 {
357         if (pEvas == null)
358         {
359                 return E_INVALID_ARG;
360         }
361
362         Destruct();
363
364         __pEvas = const_cast<Evas*>(pEvas);
365
366
367         if (!__pStaticSmartClass)
368         {
369                 __pStaticSmartClass = evas_smart_class_new(&smartClassForVisualElement); // TODO: no need to delete ???
370         }
371
372         __pSmartObject = evas_object_smart_add(__pEvas, __pStaticSmartClass);
373         if (!__pSmartObject)
374         {
375                 goto failure;
376         }
377
378         if (!__pStaticSmartClassForImageHolder)
379         {
380                 __pStaticSmartClassForImageHolder = evas_smart_class_new(&smartClassForImageHolder); // TODO: no need to delete ???
381         }
382
383         //evas_object_pass_events_set(__pSmartObject, EINA_TRUE);
384         evas_object_propagate_events_set(__pSmartObject, EINA_TRUE);
385         //evas_object_propagate_events_set(__pSmartObject, EINA_FALSE);
386
387         if (__pNativeSmartObject)
388         {
389                 evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject);
390                 AdjustEvasObjectOrder();
391         }
392
393         evas_object_show(__pSmartObject);
394
395 //      __pClipObject = evas_object_rectangle_add(pEvas);
396 //      if (!__pClipObject)
397 //              goto failure;
398 //
399 //
400 //      evas_object_smart_member_add(__pClipObject,__pSmartObject);
401 //      evas_object_lower(__pClipObject);
402 //
403 //      evas_object_pass_events_set(__pClipObject, EINA_TRUE);
404
405         // Create map for 3D
406         if (__pMap)
407         {
408                 evas_map_free(__pMap);
409         }
410         __pMap = evas_map_new(4);
411         if (!__pMap)
412         {
413                 goto failure;
414         }
415
416         evas_map_alpha_set(__pMap, EINA_TRUE);
417         evas_map_smooth_set(__pMap, EINA_TRUE);
418
419         return E_SUCCESS;
420
421 failure:
422         __pEvas = null;
423
424         if (__pSmartObject)
425         {
426                 evas_object_del(__pSmartObject);
427         }
428
429         __pSmartObject = null;
430
431 //      if (__pClipObject)
432 //              evas_object_del(__pClipObject);
433 //
434 //      __pClipObject = null;
435
436         if (__pMap)
437         {
438                 evas_map_free(__pMap);
439         }
440
441         __pMap = null;
442
443         return E_SYSTEM;
444 }
445
446 result
447 _EflNode::Destruct(void)
448 {
449         __pEvas = null;
450         if (__pSmartObject)
451         {
452                 evas_object_del(__pSmartObject);
453                 __pSmartObject = null;
454         }
455
456         if (__pClipObject)
457         {
458                 evas_object_del(__pClipObject);
459                 __pClipObject = null;
460         }
461
462         if (__pRectangleObject)
463         {
464                 evas_object_del(__pRectangleObject);
465                 __pRectangleObject = null;
466         }
467
468         if (__pMap)
469         {
470                 evas_map_free(__pMap);
471                 __pMap = null;
472         }
473
474         if (__pSurface)
475         {
476                 delete __pSurface;
477                 __pSurface = null;
478         }
479
480         if (__pSharedSurface)
481         {
482                 delete __pSharedSurface;
483                 __pSharedSurface = null;
484         }
485
486         if (__pImageHolder)
487         {
488                 evas_object_del(__pImageHolder);
489         }
490
491         if (unlikely(__pNativeSmartObject))
492         {
493                 evas_object_smart_member_del(__pNativeSmartObject);
494                 //__pNativeSmartObject = null;
495         }
496
497         return E_SUCCESS;
498 }
499
500 Evas*
501 _EflNode::GetEvas(void) const
502 {
503         return __pEvas;
504 }
505
506 Handle
507 _EflNode::GetGroupContainer(void) const
508 {
509         return reinterpret_cast< Handle >(__pSmartObject);
510 }
511
512 void
513 _EflNode::AdjustEvasObjectOrder(void)
514 {
515
516         if (__pNativeSmartObject)
517                 evas_object_lower(__pNativeSmartObject);
518 //              evas_object_raise(__pNativeSmartObject);
519
520 }
521
522 void
523 _EflNode::SetNativeObject(VisualElement& element, Evas_Object* pNativeObject)
524 {
525         if (unlikely(__pNativeSmartObject != pNativeObject))
526         {
527                 if (unlikely(__pNativeSmartObject))
528                 {
529                         evas_object_smart_member_del(__pNativeSmartObject);
530                 }
531
532                 __pNativeSmartObject = pNativeObject;
533
534                 if (__pNativeSmartObject)
535                 {
536                         evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject);
537                 }
538         }
539
540         AdjustEvasObjectOrder();
541
542
543         const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
544                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
545                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
546                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
547
548         _VisualElementImpl* pElementImpl = _VisualElementImpl::GetInstance(element);
549         if (likely(pElementImpl))
550         {
551                 pElementImpl->InvalidateHierarchyProps(nativeProps, false, false);
552         }
553 }
554
555 void
556 _EflNode::AddNativeSmartObject(VisualElement& element, Evas_Object* pSmartObject)
557 {
558         SetNativeObject(element, pSmartObject);
559 }
560
561 void
562 _EflNode::RemoveNativeObject(void)
563 {
564         __pNativeSmartObject = null;
565 }
566
567 Evas_Object*
568 _EflNode::GetNativeObject(void) const
569 {
570         return __pNativeSmartObject;
571 }
572
573 result
574 _EflNode::InsertChild(_INativeNode& child, const _INativeNode* pReference, bool above)
575 {
576         _EflNode& nativeChild = dynamic_cast< _EflNode& >(child);
577         const _EflNode* pNativeReference = dynamic_cast< const _EflNode* >(pReference);
578
579         RemoveChild(nativeChild);
580
581         if (!__pSmartObject)
582         {
583                 return E_INVALID_STATE;
584         }
585
586         evas_object_smart_member_add(nativeChild.__pSmartObject, __pSmartObject);
587
588         // The order of evas objects should be as follows:
589         //              [native smart object]   [image/image-holder/rectangle/clipper]  [child smart object]*
590
591         if (likely(pNativeReference))
592         {
593                 if (likely(above))
594                 {
595                         evas_object_stack_above(nativeChild.__pSmartObject, pNativeReference->__pSmartObject);
596                 }
597                 else
598                 {
599                         evas_object_stack_below(nativeChild.__pSmartObject, pNativeReference->__pSmartObject);
600                 }
601         }
602         else
603         {
604                 if (likely(above))
605                 {
606                         evas_object_raise(nativeChild.__pSmartObject);
607                 }
608                 else
609                 {
610                         Evas_Object* pRefObject = null;
611
612
613                         if (likely(__pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSurface)))
614                         {
615                                 pRefObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
616                         }
617                         else if (likely(__pRectangleObject))
618                         {
619                                 pRefObject = __pRectangleObject;
620                         }
621                         else if (likely(__pImageHolder))
622                         {
623                                 pRefObject = __pImageHolder;
624                         }
625
626                         if (likely(pRefObject))
627                         {
628                                 evas_object_stack_above(nativeChild.__pSmartObject, pRefObject);
629                         }
630                         else
631                         {
632                                 evas_object_lower(nativeChild.__pSmartObject);
633                         }
634                 }
635         }
636
637         AdjustEvasObjectOrder();
638
639         return E_SUCCESS;
640 }
641
642 result
643 _EflNode::RemoveChild(_INativeNode& child)
644 {
645         _EflNode& nativeChild = dynamic_cast< _EflNode& >(child);
646
647         //      WARNING:
648         //      Perform recursive hiding evas objects !
649         //      After removing a child, it is not managed by visual element.
650         //      Hence, because all descendants of it will not be hided automatically, it is needed to
651         //      hide all descendants of it (or need adding damage region)
652         smartClassForVisualElement.hide = EvasSmartObjectHideAllChildren;
653         evas_object_hide(nativeChild.__pSmartObject);
654         smartClassForVisualElement.hide = EvasSmartObjectHideChildren;
655
656         evas_object_smart_member_del(nativeChild.__pSmartObject);
657
658 #if 0
659         if (nativeChild.__pClipObject)
660                 evas_object_hide((Evas_Object*)nativeChild.__pClipObject);
661
662         if (nativeChild.__pRectangleObject)
663                 evas_object_hide((Evas_Object*)nativeChild.__pRectangleObject);
664
665         if (nativeChild.__pSurface && nativeChild.__pSurface->GetNativeHandle())
666                 evas_object_hide((Evas_Object*)nativeChild.__pSurface->GetNativeHandle());
667 #endif
668
669         return E_SUCCESS;
670 }
671
672 result
673 _EflNode::SetFlushNeeded(void)
674 {
675         _EflVisualElementSurfaceImpl* pSurfaceImpl = null;
676         if (!__pSurface)
677         {
678                 return E_INVALID_STATE;
679         }
680         pSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*__pSurface));
681         if (!pSurfaceImpl)
682         {
683                 return E_INVALID_STATE;
684         }
685
686         Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
687
688         if (pImageObject)
689         {
690                 int imageWidth = 0;
691                 int imageHeight = 0;
692
693                 if (pSurfaceImpl->__isImageObject)
694                 {
695                         const char* pName = null;
696                         evas_object_image_file_get(pImageObject, &pName, null);
697                         if (!pName)
698                         {
699                                 evas_object_image_size_get(pImageObject, &imageWidth, &imageHeight);
700                                 evas_object_image_data_update_add(pImageObject, 0, 0, imageWidth, imageHeight);
701                         }
702                 }
703         }
704
705         if(__pLayer)
706         {
707                 __pLayer->SetFlushNeeded();
708         }
709
710         return E_SUCCESS;
711 }
712
713 result
714 _EflNode::Flush(void)
715 {
716 #ifndef VE_VSYNC_UPDATE
717         if(__pLayer)
718         {
719                 __pLayer->Flush();
720         }
721 //      ecore_evas_manual_render(ecore_evas_ecore_evas_get(__pEvas));
722 #endif
723
724         return E_SUCCESS;
725 }
726
727 _Colorf
728 _EflNode::GetBackgroundColor(void) const
729 {
730         return __backgroundColor;
731 }
732
733 result
734 _EflNode::SetBackgroundColor(const _Colorf& backgroundColor)
735 {
736         __backgroundColor = backgroundColor;
737
738         return E_SUCCESS;
739 }
740
741 bool
742 _EflNode::AdjustImageHolder(bool useHolder)
743 {
744         if (unlikely(!__pSurface))
745         {
746                 return false;
747         }
748
749         Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
750         if (unlikely(!pImageObject))
751         {
752                 return false;
753         }
754
755         if (unlikely(useHolder))
756         {
757                 if (likely(!__pImageHolder))
758                 {
759                         __pImageHolder = evas_object_smart_add(__pEvas, __pStaticSmartClassForImageHolder);
760                         if (unlikely(!__pSmartObject))
761                         {
762                                 SysLog(NID_UI_ANIM, "Smart object cannot be created.");
763                                 return false;
764                         }
765
766                         evas_object_propagate_events_set(__pImageHolder, EINA_TRUE);
767                         evas_object_smart_member_add(pImageObject, __pImageHolder);
768
769                         evas_object_smart_member_add(__pImageHolder, __pSmartObject);
770                         evas_object_lower(__pImageHolder);
771                         AdjustEvasObjectOrder();
772
773                         if (evas_object_visible_get(__pSmartObject))
774                         {
775                                 evas_object_show(__pImageHolder);
776                         }
777                         else
778                         {
779                                 evas_object_hide(__pImageHolder);
780                         }
781
782                         return true;
783                 }
784         }
785         else
786         {
787                 if (likely(__pImageHolder))
788                 {
789                         evas_object_smart_member_add(pImageObject, __pSmartObject);
790                         evas_object_lower(pImageObject);
791                         AdjustEvasObjectOrder();
792
793                         evas_object_del(__pImageHolder);
794                         __pImageHolder = null;
795
796                         return true;
797                 }
798         }
799
800         return false;
801 }
802
803 result
804 _EflNode::Reconfigure(VisualElementSurface* pSurface, _VisualElementImpl& element, bool surfaceOnly)
805 {
806         Evas_Object* pImageObjectOrg = null;
807         Evas_Object* pImageObjectNew = null;
808
809         const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
810                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
811                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
812                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
813         int& invalidatedNativeProps = element.__pSharedData->invalidatedNativeProps;
814
815         invalidatedNativeProps &= nativeProps;
816
817
818         _EflVisualElementSurfaceImpl* pSurfaceImpl = null;
819
820         if (likely(pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*pSurface)))
821         {
822                 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle());
823                 pSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
824         }
825
826         if (likely(__pSharedSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)))
827         {
828                 pImageObjectOrg = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
829         }
830
831
832         if (likely(pImageObjectNew))
833         {
834                 bool createNewObject = true;
835
836                 if (likely(__pSurface))
837                 {
838                         // if the surfaces are same, change the size
839                         if (likely(pImageObjectNew == pImageObjectOrg))
840                         {
841                                 createNewObject = false;
842                         }
843                         // if the surface is changed, delete old surface
844                         else
845                         {
846                                 delete __pSharedSurface;
847                                 __pSharedSurface = null;
848                         }
849                 }
850
851                 // create new surface
852                 if (unlikely(createNewObject))
853                 {
854                         unique_ptr<VisualElementSurface> pNewSharedSurface(new (std::nothrow) VisualElementSurface(*pSurface));
855                         SysTryReturnResult(NID_UI_ANIM, pNewSharedSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
856
857                         _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
858                         if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer == null)
859                         {
860                                 unique_ptr<VisualElementSurface> pNewSurface(new (std::nothrow) VisualElementSurface(*pSurface));
861                                 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
862
863                                 if (__pSurface)
864                                 {
865                                         delete __pSurface;
866                                         __pSurface = null;
867                                 }
868                                 __pSurface = pNewSurface.release();
869                         }
870                         else
871                         {
872                                 unique_ptr<VisualElementSurface> pNewSurface(_VisualElementSurfaceImpl::CreateSurfaceN((Handle)__pLayer, FloatDimension(1.0f, 1.0f)));
873                                 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
874
875                                 if (__pSurface)
876                                 {
877                                         delete __pSurface;
878                                         __pSurface = null;
879                                 }
880                                 __pSurface = pNewSurface.release();
881
882                                 if (!element.GetModel()->__imageFilePath.IsEmpty() && _VisualElementSurfaceImpl::GetInstance(*__pSurface))
883                                 {
884                                         _VisualElementSurfaceImpl::GetInstance(*__pSurface)->SetImage(element.GetModel()->__imageFilePath);
885                                 }
886                         }
887
888                         if (__pSharedSurface)
889                         {
890                                 delete __pSharedSurface;
891                                 __pSharedSurface = null;
892                         }
893                         __pSharedSurface = pNewSharedSurface.release();
894
895                         Evas_Object* pImageObject = null;
896                         if (_VisualElementSurfaceImpl::GetInstance(*__pSurface))
897                         {
898                                 pImageObject = (Evas_Object*)_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle();
899
900                                 if (likely(pImageObject))
901                                 {
902                                         evas_object_anti_alias_set(pImageObject, EINA_TRUE);
903
904                                         evas_object_smart_member_add(pImageObject, __pSmartObject);
905                                         evas_object_lower(pImageObject);
906                                         AdjustEvasObjectOrder();
907
908                                         if (evas_object_visible_get(__pSmartObject))
909                                         {
910                                                 evas_object_show(pImageObject);
911                                         }
912                                         else
913                                         {
914                                                 evas_object_hide(pImageObject);
915                                         }
916
917                                         if (pSurfaceImpl && pSurfaceImpl->__pBuffer != null)
918                                         {
919                                                 evas_object_image_source_set(pImageObject, pImageObjectNew);
920 #if 0   // needed if evas_object_show() has not been called  in ctor of _EflVisualElementSurfaceImpl
921                                                 evas_object_show(pImageObjectNew);
922                                                 evas_object_image_source_visible_set(pImageObject, EINA_FALSE);
923 #endif
924                                         }
925
926                                         //evas_object_pass_events_set(pImageObject, EINA_TRUE);
927
928                                         __needEvasObjectSync = true;
929                                         invalidatedNativeProps |= nativeProps;
930                                 }
931                         }
932                 }
933                 // TODO : Have surface, but not newly created
934
935         }
936         else
937         {
938                 // delete old surface
939                 delete __pSurface;
940                 __pSurface = null;
941
942                 // delete shared surface
943                 delete __pSharedSurface;
944                 __pSharedSurface = null;
945         }
946
947
948         if (likely(__pSurface && _VisualElementSurfaceImpl::GetInstance(*__pSurface)))
949         {
950                 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
951
952                 if (unlikely(__pRectangleObject))
953                 {
954                         evas_object_del(__pRectangleObject);
955                         __pRectangleObject = null;
956                 }
957         }
958         else
959         {
960                 pImageObjectNew = null;
961
962                 // WARNING:
963                 //      Newly created rectangle object must be reconfigured by VE!!! (size/pos/visibility/etc)
964                 //
965                 if (likely(!__pRectangleObject) && likely(element.__pSharedData->needSurface))
966                 {
967                         __pRectangleObject = evas_object_rectangle_add(__pEvas);
968                         if (likely(__pRectangleObject))
969                         {
970                                 //evas_object_pass_events_set(__pRectangleObject, EINA_TRUE);
971                                 evas_object_smart_member_add(__pRectangleObject, __pSmartObject);
972                                 evas_object_lower(__pRectangleObject);
973                                 AdjustEvasObjectOrder();
974
975                                 if (evas_object_visible_get(__pSmartObject))
976                                 {
977                                         evas_object_show(__pRectangleObject);
978                                 }
979                                 else
980                                 {
981                                         evas_object_hide(__pRectangleObject);
982                                 }
983
984                                 __needEvasObjectSync = true;
985                                 invalidatedNativeProps |= nativeProps;
986                         }
987                 }
988         }
989
990         element.__pSharedData->surfaceChanged = false;
991
992         if (surfaceOnly)
993         {
994                 return E_SUCCESS;
995         }
996
997
998         const bool isVeVisible = element.IsVisibleI();
999         const bool isEvasVisible = evas_object_visible_get(__pSmartObject);
1000
1001
1002         // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1003         if (unlikely(!isVeVisible))
1004         {
1005                 if (isEvasVisible)
1006                 {
1007                         evas_object_hide(__pSmartObject);
1008                 }
1009
1010                 invalidatedNativeProps = 0;
1011
1012                 goto finished;
1013         }
1014         else
1015         {
1016                 if (!isEvasVisible)
1017                 {
1018                         // WARNING:
1019                         //      When visibility of VE is changed into 'visible' and evas object is invisible,
1020                         //      it is needed to set all evas object properties because not all properties were applied due to short-circuit optimization
1021                         //      (When VE is invisible, bounds and colors are not set for optimization)
1022                         invalidatedNativeProps = nativeProps;
1023                 }
1024         }
1025
1026         // Change hierarchy properties such as bounds, clipping and map
1027         if (likely(invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS)) || unlikely(__needEvasObjectSync))
1028         {
1029                 bool needResize = false;
1030                 bool needMove = false;
1031                 bool clipChanged = false;
1032                 bool needMap = false;
1033
1034                 Evas_Coord newX = 0;
1035                 Evas_Coord newY = 0;
1036                 Evas_Coord newW = 0;
1037                 Evas_Coord newH = 0;
1038
1039                 __realBounds.width = element.__alignedSize.width;
1040                 __realBounds.height = element.__alignedSize.height;
1041
1042                 //_VisualElementImpl::AdjustSizeForSurface(__realBounds.width, __realBounds.height);
1043                 _VisualElementCoordinateSystem::ConvertDimensionToPhysical(__realBounds.width, __realBounds.height);
1044
1045                 // WARNING:
1046                 //      Do not use to MakeIntegralDimension. All information about coordinates(position/size) are calculated with same(point) way.
1047                 _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.width, __realBounds.height, newW, newH);
1048
1049                 float clipX = 0.0f;
1050                 float clipY = 0.0f;
1051                 float clipW = 0.0f;
1052                 float clipH = 0.0f;
1053                 Evas_Object* pParentClipper = null;
1054
1055                 if (unlikely(element.__needTransform) || likely(element.__needClipForUntransformed))
1056                 {
1057                         const _VisualElementImpl* pClipSource = element.GetClipSource();
1058
1059                         if (likely(pClipSource))
1060                         {
1061                                 _EflNode* pParentClipNode = static_cast< _EflNode* >(pClipSource->GetNativeNode());
1062                                 if (likely(pParentClipNode))
1063                                 {
1064                                         clipX = pParentClipNode->__realBounds.x;
1065                                         clipY = pParentClipNode->__realBounds.y;
1066                                         clipW = pParentClipNode->__realBounds.width;
1067                                         clipH = pParentClipNode->__realBounds.height;
1068
1069                                         pParentClipper = pParentClipNode->__pClipObject;
1070                                 }
1071                         }
1072                 }
1073
1074
1075                 // Coordinates(including __needTransform flag) are validated by getting clip-source above
1076
1077                 if (likely(!element.__needTransform))
1078                 {
1079                         __realBounds.x = element.__boundingBoxToClipSource.x;
1080                         __realBounds.y = element.__boundingBoxToClipSource.y;
1081                         _VisualElementCoordinateSystem::ConvertPointToPhysical(__realBounds.x, __realBounds.y);
1082
1083                         __realBounds.x += clipX;
1084                         __realBounds.y += clipY;
1085                         _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.x, __realBounds.y, newX, newY);
1086                 }
1087                 else
1088                 {
1089                         float x[4];
1090                         float y[4];
1091                         float z[4];
1092                         int intX[4];
1093                         int intY[4];
1094                         const Tizen::Graphics::FloatMatrix4& xform = element.GetMatrixToClipSource();
1095
1096                         x[0] = 0.0f;
1097                         y[0] = 0.0f;
1098                         z[0] = 0.0f;
1099                         x[1] = element.__alignedSize.width;
1100                         y[1] = 0.0f;
1101                         z[1] = 0.0f;
1102                         x[2] = element.__alignedSize.width;
1103                         y[2] = element.__alignedSize.height;
1104                         z[2] = 0.0f;
1105                         x[3] = 0.0f;
1106                         y[3] = element.__alignedSize.height;
1107                         z[3] = 0.0f;
1108
1109                         for (int i = 0; i < 4; i++)
1110                         {
1111                                 _MatrixUtilTransform(xform, &x[i], &y[i], &z[i]);
1112                                 _VisualElementCoordinateSystem::ConvertPointToPhysical(x[i], y[i]);
1113
1114                                 x[i] += clipX;
1115                                 y[i] += clipY;
1116                         }
1117
1118                         // WARNING:
1119                         //      Use surface size for UV-mapping *ONLY FOR* direct-map-on-image-object, not map-on-smart-object !!!
1120                         if (unlikely(!__pSharedSurface) || unlikely(element.__useContentBounds) || likely(__pClipObject))
1121                         {
1122                                 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1123                                 evas_map_point_image_uv_set(__pMap, 1, (double)newW, 0.0);
1124                                 evas_map_point_image_uv_set(__pMap, 2, (double)newW, (double)newH);
1125                                 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)newH);
1126                         }
1127                         else
1128                         {
1129                                 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1130
1131                                 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1132                                 evas_map_point_image_uv_set(__pMap, 1, (double)surfaceSize.width, 0.0);
1133                                 evas_map_point_image_uv_set(__pMap, 2, (double)surfaceSize.width, (double)surfaceSize.height);
1134                                 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)surfaceSize.height);
1135                         }
1136
1137                         for (int i = 0; i < 4; i++)
1138                         {
1139                                 // WARNING: Do not need integral Z ??
1140                                 _VisualElementCoordinateSystem::MakeIntegralPoint(x[i], y[i], intX[i], intY[i]);
1141                                 evas_map_point_coord_set(__pMap, i, intX[i], intY[i], static_cast< int >(z[i]));
1142                         }
1143
1144
1145                         __realBounds.x = x[0];
1146                         __realBounds.y = y[0];
1147                         newX = intX[0];
1148                         newY = intY[0];
1149
1150                         needMap = true;
1151                 }
1152
1153                 // Adjust flag for bounds changing
1154                 if (unlikely(__needEvasObjectSync))
1155                 {
1156                         needMove = true;
1157                         needResize = true;
1158                 }
1159                 else
1160                 {
1161                         Evas_Coord objX;
1162                         Evas_Coord objY;
1163                         Evas_Coord objW;
1164                         Evas_Coord objH;
1165
1166                         evas_object_geometry_get(__pSmartObject, &objX, &objY, &objW, &objH);
1167
1168                         if (likely(!needMove))
1169                         {
1170                                 needMove = (newX != objX || newY != objY);
1171                         }
1172
1173                         if (likely(!needResize))
1174                         {
1175                                 needResize = (newW != objW || newH != objH);
1176                         }
1177                 }
1178
1179
1180                 if (unlikely(element.__isClipChildren))
1181                 {
1182                         if (unlikely(!__pClipObject) && likely(element.__pSharedData->needSurface))
1183                         {
1184                                 __pClipObject = evas_object_rectangle_add(__pEvas);
1185                                 if (likely(__pClipObject))
1186                                 {
1187                                         evas_object_smart_member_add(__pClipObject, __pSmartObject);
1188                                         evas_object_lower(__pClipObject);
1189                                         AdjustEvasObjectOrder();
1190
1191                                         evas_object_pass_events_set(__pClipObject, EINA_TRUE);
1192                                         evas_object_static_clip_set(__pClipObject, 0);  // CHECKME: What does this mean by ?
1193
1194                                         if (evas_object_visible_get(__pSmartObject))
1195                                         {
1196                                                 evas_object_show(__pClipObject);
1197                                         }
1198                                         else
1199                                         {
1200                                                 evas_object_hide(__pClipObject);
1201                                         }
1202
1203                                         needMove = true;
1204                                         needResize = true;
1205                                         clipChanged = true;
1206                                 }
1207                         }
1208                 }
1209                 else
1210                 {
1211                         if (unlikely(__pClipObject))
1212                         {
1213                                 evas_object_del(__pClipObject);
1214                                 __pClipObject = null;
1215                                 clipChanged = true;
1216                         }
1217                 }
1218
1219
1220                 // WARNING:
1221                 //      Update image-holder information before using it !
1222                 //      Image-Holder is needed only when using content-bounds and maps on image-object, not smart-object.
1223                 if (unlikely(AdjustImageHolder(element.__useContentBounds && !__pClipObject && needMap)))
1224                 {
1225                         needMove = true;
1226                         needResize = true;
1227                         clipChanged = true;
1228                         __needEvasObjectSync = true;
1229                 }
1230
1231
1232                 // WARNING:
1233                 //      In general, changing size/position before mapping/clipping *may* improve performance, because calculating map and clip
1234                 //      needs bounds information.
1235
1236                 // Set-up Position
1237                 if (likely(needMove))
1238                 {
1239                         evas_object_move(__pSmartObject, newX, newY);
1240
1241                         if (likely(__pClipObject))
1242                         {
1243                                 evas_object_move(__pClipObject, newX, newY);
1244                         }
1245
1246                         if (likely(__pImageHolder))
1247                         {
1248                                 evas_object_move(__pImageHolder, newX, newY);
1249                         }
1250
1251                         if (likely(pImageObjectNew))
1252                         {
1253                                 evas_object_move(pImageObjectNew, newX, newY);
1254                         }
1255
1256                         if (unlikely(__pRectangleObject))
1257                         {
1258                                 evas_object_move(__pRectangleObject, newX, newY);
1259                         }
1260
1261                         if (unlikely(__pNativeSmartObject))
1262                         {
1263                                 evas_object_move(__pNativeSmartObject, newX, newY);
1264                         }
1265                 }
1266
1267                 // Set-up Size
1268                 if (unlikely(needResize))
1269                 {
1270                         evas_object_resize(__pSmartObject, newW, newH);
1271
1272                         if (likely(__pClipObject))
1273                         {
1274                                 evas_object_resize(__pClipObject, newW, newH);
1275                         }
1276
1277                         if (likely(__pImageHolder))
1278                         {
1279                                 evas_object_resize(__pImageHolder, newW, newH);
1280                         }
1281
1282                         if (likely(pImageObjectNew))
1283                         {
1284                                 evas_object_resize(pImageObjectNew, newW, newH);
1285                         }
1286
1287                         if (unlikely(__pRectangleObject))
1288                         {
1289                                 evas_object_resize(__pRectangleObject, newW, newH);
1290                         }
1291
1292                         if (unlikely(__pNativeSmartObject))
1293                         {
1294                                 evas_object_resize(__pNativeSmartObject, newW, newH);
1295                         }
1296
1297                 }
1298
1299
1300                 // Set-up Clipping
1301                 if (unlikely(__needEvasObjectSync) || unlikely(clipChanged) || unlikely(evas_object_clip_get(__pSmartObject) != pParentClipper))
1302                 {
1303                         evas_object_clip_set(__pSmartObject, pParentClipper);
1304
1305                         // CHECKME:
1306                         //      Is it needed to set clipper for image-holder smart object ?
1307
1308                         if (likely(__pClipObject))
1309                         {
1310                                 evas_object_clip_set(__pClipObject, pParentClipper);
1311
1312                                 if (unlikely(__pImageHolder))
1313                                 {
1314                                         evas_object_clip_set(__pImageHolder, __pClipObject);
1315                                 }
1316
1317                                 if (likely(pImageObjectNew))
1318                                 {
1319                                         evas_object_clip_set(pImageObjectNew, __pClipObject);
1320                                 }
1321
1322                                 if (unlikely(__pRectangleObject))
1323                                 {
1324                                         evas_object_clip_set(__pRectangleObject, __pClipObject);
1325                                 }
1326
1327                                 if (unlikely(__pNativeSmartObject))
1328                                 {
1329                                         evas_object_clip_set(__pNativeSmartObject, __pClipObject);
1330                                 }
1331                         }
1332                         else
1333                         {
1334                                 if (unlikely(__pImageHolder))
1335                                 {
1336                                         evas_object_clip_set(__pImageHolder, pParentClipper);
1337                                 }
1338
1339                                 if (likely(pImageObjectNew))
1340                                 {
1341                                         evas_object_clip_set(pImageObjectNew, pParentClipper);
1342                                 }
1343
1344                                 if (unlikely(__pRectangleObject))
1345                                 {
1346                                         evas_object_clip_set(__pRectangleObject, pParentClipper);
1347                                 }
1348
1349                                 if (unlikely(__pNativeSmartObject))
1350                                 {
1351                                         evas_object_clip_set(__pNativeSmartObject, pParentClipper);
1352                                 }
1353
1354                         }
1355                 }
1356
1357
1358                 // Set-up Maps
1359                 if (unlikely(__needEvasObjectSync) || unlikely(__mapUsed != needMap) || unlikely(needMap) || unlikely(clipChanged))
1360                 {
1361                         const bool needClipSmartMap = (__pClipObject && needMap);
1362                         const bool needClipObjectMap = (!__pClipObject && needMap);
1363
1364                         evas_object_map_enable_set(__pSmartObject, needClipSmartMap);
1365                         evas_object_map_set(__pSmartObject, (needClipSmartMap ? __pMap : null));
1366
1367                         if (unlikely(__pImageHolder))
1368                         {
1369                                 evas_object_map_enable_set(__pImageHolder, needClipObjectMap);
1370                                 evas_object_map_set(__pImageHolder, (needClipObjectMap ? __pMap : null));
1371
1372                                 if (likely(pImageObjectNew))
1373                                 {
1374                                         evas_object_map_enable_set(pImageObjectNew, EINA_FALSE);
1375                                         evas_object_map_set(pImageObjectNew, null);
1376                                 }
1377                         }
1378                         else if (likely(pImageObjectNew))
1379                         {
1380                                 evas_object_map_enable_set(pImageObjectNew, needClipObjectMap);
1381                                 evas_object_map_set(pImageObjectNew, (needClipObjectMap ? __pMap : null));
1382                         }
1383
1384                         if (unlikely(__pRectangleObject))
1385                         {
1386                                 evas_object_map_enable_set(__pRectangleObject, needClipObjectMap);
1387                                 evas_object_map_set(__pRectangleObject, (needClipObjectMap ? __pMap : null));
1388                         }
1389
1390                         if (unlikely(__pNativeSmartObject))
1391                         {
1392                                 evas_object_map_enable_set(__pNativeSmartObject, needClipObjectMap);
1393                                 evas_object_map_set(__pNativeSmartObject, (needClipObjectMap ? __pMap : null));
1394                         }
1395                         __mapUsed = needMap;
1396                 }
1397
1398
1399                 // Set-up Content Bounds
1400                 // WARNING:
1401                 //      EFL Bug! - evas_object_fill_set should be invoked only *AFTER* adjusting maps !!!!!
1402                 //                 If contents bounds are modifed before adjusting maps, it will not be applied !!!
1403                 if (likely(pImageObjectNew) && likely(__pSharedSurface))
1404                 {
1405                         bool needDefaultFillSet = true;
1406
1407                         if (unlikely(element.__useContentBounds))
1408                         {
1409                                 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1410                                 const FloatRectangle& contentBounds = element.__contentBounds;
1411                                 Rectangle contentBoundsAdjusted;
1412
1413                                 // Formula:
1414                                 //
1415                                 //  content bounds(px) = content bounds(uniform) * surface size(px)
1416                                 //
1417                                 //                                                                               surface size(px)                                  1
1418                                 //      mapped content size(px) = bounds size(px) * ------------------ = bounds size(px) * -----------------------
1419                                 //                                                                               content size(px)                       content size(uniform)
1420                                 //
1421                                 //      mapped content size(px) : surface size(px) = mapped content pos(px) : content pos(px)
1422                                 //
1423                                 //                                                                              mapped content size(px)    content pos(uniform) * bounds size(px)
1424                                 //      mapped content pos(px) = content pos(px) * ------------------------- = -----------------------------------------
1425                                 //                                                                                 surface size(px)            content size(uniform)
1426
1427                                 _VisualElementCoordinateSystem::MakeIntegralPoint(
1428                                         -contentBounds.x * static_cast< float >(newW) / contentBounds.width,
1429                                         -contentBounds.y * static_cast< float >(newH) / contentBounds.height,
1430                                         contentBoundsAdjusted.x,
1431                                         contentBoundsAdjusted.y
1432                                 );
1433                                 _VisualElementCoordinateSystem::MakeIntegralPoint(
1434                                         static_cast< float >(newW) / contentBounds.width,               // WARNING: No use of __realBounds. new[WH] is the real displaying value which is integral.
1435                                         static_cast< float >(newH) / contentBounds.height,
1436                                         contentBoundsAdjusted.width,
1437                                         contentBoundsAdjusted.height
1438                                 );
1439
1440                                 // Added to resolve the problem that the left edge part is shown repeatedly to the right edge.
1441                                 contentBoundsAdjusted.width += ceil(static_cast< float >(newW) / contentBounds.width - contentBoundsAdjusted.width);
1442                                 contentBoundsAdjusted.height += ceil(static_cast< float >(newH) / contentBounds.height - contentBoundsAdjusted.height);
1443
1444                                 if (likely(contentBoundsAdjusted.width > 0) && likely(contentBoundsAdjusted.height > 0))
1445                                 {
1446
1447                                         if (pSurfaceImpl && pSurfaceImpl->__isImageObject)
1448                                         {
1449                                                 evas_object_image_fill_set(
1450                                                         pImageObjectNew,
1451                                                         contentBoundsAdjusted.x,
1452                                                         contentBoundsAdjusted.y,
1453                                                         contentBoundsAdjusted.width,
1454                                                         contentBoundsAdjusted.height
1455                                                 );
1456                                         }
1457
1458                                         needDefaultFillSet = false;
1459                                 }
1460                         }
1461
1462                         if (likely(needDefaultFillSet))
1463                         {
1464                                 if (pSurfaceImpl && pSurfaceImpl->__isImageObject)
1465                                 {
1466                                         evas_object_image_fill_set(pImageObjectNew, 0, 0, newW, newH);
1467                                 }
1468                         }
1469                 }
1470
1471
1472                 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS);
1473         }
1474
1475
1476         if ((invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY)) || unlikely(__needEvasObjectSync))
1477         {
1478                 float alpha = element.GetOpacityFromRoot();
1479                 bool renderOperationChanged = false;
1480
1481                 if (unlikely(__renderOperation != element.__renderOperation))
1482                 {
1483                         renderOperationChanged = true;
1484                         __renderOperation = element.__renderOperation;
1485                 }
1486
1487
1488                 // pImageObjectNew does exist.
1489                 if (likely(pImageObjectNew))
1490                 {
1491                         if (unlikely(renderOperationChanged))
1492                         {
1493                                 evas_object_render_op_set(pImageObjectNew, GetRenderOperation(element.__renderOperation));
1494                         }
1495
1496                         int premultipliedColor =  static_cast< int >(255.0f * alpha); // white color
1497                         evas_object_color_set(pImageObjectNew, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1498                 }
1499
1500
1501                 // rectangle setting
1502                 if (unlikely(__pRectangleObject))
1503                 {
1504                         if (unlikely(renderOperationChanged))
1505                         {
1506                                 evas_object_render_op_set(__pRectangleObject, GetRenderOperation(element.__renderOperation));
1507                         }
1508
1509                         float alphaRect = alpha * __backgroundColor.Alpha() * 255.0f;
1510
1511                         evas_object_color_set(
1512                                 __pRectangleObject,
1513                                 static_cast< int >(__backgroundColor.Red() * alphaRect),
1514                                 static_cast< int >(__backgroundColor.Green() * alphaRect),
1515                                 static_cast< int >(__backgroundColor.Blue() * alphaRect),
1516                                 static_cast< int >(alphaRect)
1517                         );
1518                 }
1519
1520                 // WARNING: CHECKME: TODO:
1521                 //      How can we native smart object
1522
1523                 // Native Smart Object does exist.
1524                 if (unlikely(__pNativeSmartObject))
1525                 {
1526
1527                         if (unlikely(renderOperationChanged))
1528                         {
1529                                 evas_object_render_op_set(__pNativeSmartObject, GetRenderOperation(element.__renderOperation));
1530                         }
1531
1532                         if (unlikely(element.__renderOperation == VisualElement::RENDER_OPERATION_COPY))
1533                         {
1534                                 evas_object_color_set(__pNativeSmartObject, 0, 0, 0, 0);        // for smart
1535 //                              evas_object_color_set(__pNativeSmartObject, 255, 255, 255, 255);// for image
1536                         }
1537                         else
1538                         {
1539                                 int premultipliedColor = static_cast< int >(255.0f * alpha); // white color
1540                                 evas_object_color_set(__pNativeSmartObject, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1541                         }
1542
1543                 }
1544
1545                 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY);
1546         }
1547
1548
1549         // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1550         if (likely(isVeVisible))
1551         {
1552                 if (unlikely(!isEvasVisible))
1553                 {
1554                         evas_object_show(__pSmartObject);       // Children of smart-object such as rectangle and clip-object may be invisible here.
1555                 }
1556         }
1557         else
1558         {
1559                 if (unlikely(isEvasVisible))
1560                 {
1561                         evas_object_hide(__pSmartObject);
1562                 }
1563         }
1564
1565
1566         // WARNING:
1567         //      Only after setting all invalidated properties, need-sync flag can be cleared
1568         __needEvasObjectSync = false;
1569
1570 finished:
1571
1572         return E_SUCCESS;
1573 }
1574
1575 VisualElementSurface*
1576 _EflNode::GetSurface(void) const
1577 {
1578         return __pSurface;
1579 }
1580
1581
1582 }}}             // Tizen::Ui::Animations
1583