Fix for power consumption
[platform/framework/native/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                         evas_object_image_size_get(pImageObject, &imageWidth, &imageHeight);
696                         evas_object_image_data_update_add(pImageObject, 0, 0, imageWidth, imageHeight);
697                 }
698         }
699
700         if(__pLayer)
701         {
702                 __pLayer->SetFlushNeeded();
703         }
704
705         return E_SUCCESS;
706 }
707
708 result
709 _EflNode::Flush(void)
710 {
711 #ifndef VE_VSYNC_UPDATE
712         if(__pLayer)
713         {
714                 __pLayer->Flush();
715         }
716 //      ecore_evas_manual_render(ecore_evas_ecore_evas_get(__pEvas));
717 #endif
718
719         return E_SUCCESS;
720 }
721
722 _Colorf
723 _EflNode::GetBackgroundColor(void) const
724 {
725         return __backgroundColor;
726 }
727
728 result
729 _EflNode::SetBackgroundColor(const _Colorf& backgroundColor)
730 {
731         __backgroundColor = backgroundColor;
732
733         return E_SUCCESS;
734 }
735
736 bool
737 _EflNode::AdjustImageHolder(bool useHolder)
738 {
739         if (unlikely(!__pSurface))
740         {
741                 return false;
742         }
743
744         Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
745         if (unlikely(!pImageObject))
746         {
747                 return false;
748         }
749
750         if (unlikely(useHolder))
751         {
752                 if (likely(!__pImageHolder))
753                 {
754                         __pImageHolder = evas_object_smart_add(__pEvas, __pStaticSmartClassForImageHolder);
755                         if (unlikely(!__pSmartObject))
756                         {
757                                 SysLog(NID_UI_ANIM, "Smart object cannot be created.");
758                                 return false;
759                         }
760
761                         evas_object_propagate_events_set(__pImageHolder, EINA_TRUE);
762                         evas_object_smart_member_add(pImageObject, __pImageHolder);
763
764                         evas_object_smart_member_add(__pImageHolder, __pSmartObject);
765                         evas_object_lower(__pImageHolder);
766                         AdjustEvasObjectOrder();
767
768                         if (evas_object_visible_get(__pSmartObject))
769                         {
770                                 evas_object_show(__pImageHolder);
771                         }
772                         else
773                         {
774                                 evas_object_hide(__pImageHolder);
775                         }
776
777                         return true;
778                 }
779         }
780         else
781         {
782                 if (likely(__pImageHolder))
783                 {
784                         evas_object_smart_member_add(pImageObject, __pSmartObject);
785                         evas_object_lower(pImageObject);
786                         AdjustEvasObjectOrder();
787
788                         evas_object_del(__pImageHolder);
789                         __pImageHolder = null;
790
791                         return true;
792                 }
793         }
794
795         return false;
796 }
797
798 result
799 _EflNode::Reconfigure(VisualElementSurface* pSurface, _VisualElementImpl& element, bool surfaceOnly)
800 {
801         Evas_Object* pImageObjectOrg = null;
802         Evas_Object* pImageObjectNew = null;
803
804         const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
805                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
806                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
807                                                         | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
808         int& invalidatedNativeProps = element.__pSharedData->invalidatedNativeProps;
809
810         invalidatedNativeProps &= nativeProps;
811
812
813         _EflVisualElementSurfaceImpl* pSurfaceImpl = null;
814
815         if (likely(pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*pSurface)))
816         {
817                 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle());
818                 pSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
819         }
820
821         if (likely(__pSharedSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)))
822         {
823                 pImageObjectOrg = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
824         }
825
826
827         if (likely(pImageObjectNew))
828         {
829                 bool createNewObject = true;
830
831                 if (likely(__pSurface))
832                 {
833                         // if the surfaces are same, change the size
834                         if (likely(pImageObjectNew == pImageObjectOrg))
835                         {
836                                 createNewObject = false;
837                         }
838                         // if the surface is changed, delete old surface
839                         else
840                         {
841                                 delete __pSharedSurface;
842                                 __pSharedSurface = null;
843                         }
844                 }
845
846                 // create new surface
847                 if (unlikely(createNewObject))
848                 {
849                         unique_ptr<VisualElementSurface> pNewSharedSurface(new (std::nothrow) VisualElementSurface(*pSurface));
850                         SysTryReturnResult(NID_UI_ANIM, pNewSharedSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
851
852                         _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
853                         if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer == null)
854                         {
855                                 unique_ptr<VisualElementSurface> pNewSurface(new (std::nothrow) VisualElementSurface(*pSurface));
856                                 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
857
858                                 if (__pSurface)
859                                 {
860                                         delete __pSurface;
861                                         __pSurface = null;
862                                 }
863                                 __pSurface = pNewSurface.release();
864                         }
865                         else
866                         {
867                                 unique_ptr<VisualElementSurface> pNewSurface(_VisualElementSurfaceImpl::CreateSurfaceN((Handle)__pLayer, FloatDimension(1.0f, 1.0f)));
868                                 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
869
870                                 if (__pSurface)
871                                 {
872                                         delete __pSurface;
873                                         __pSurface = null;
874                                 }
875                                 __pSurface = pNewSurface.release();
876
877                                 if (!element.GetModel()->__imageFilePath.IsEmpty() && _VisualElementSurfaceImpl::GetInstance(*__pSurface))
878                                 {
879                                         _VisualElementSurfaceImpl::GetInstance(*__pSurface)->SetImage(element.GetModel()->__imageFilePath);
880                                 }
881                         }
882
883                         if (__pSharedSurface)
884                         {
885                                 delete __pSharedSurface;
886                                 __pSharedSurface = null;
887                         }
888                         __pSharedSurface = pNewSharedSurface.release();
889
890                         Evas_Object* pImageObject = null;
891                         if (_VisualElementSurfaceImpl::GetInstance(*__pSurface))
892                         {
893                                 pImageObject = (Evas_Object*)_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle();
894
895                                 if (likely(pImageObject))
896                                 {
897                                         evas_object_anti_alias_set(pImageObject, EINA_TRUE);
898
899                                         evas_object_smart_member_add(pImageObject, __pSmartObject);
900                                         evas_object_lower(pImageObject);
901                                         AdjustEvasObjectOrder();
902
903                                         if (evas_object_visible_get(__pSmartObject))
904                                         {
905                                                 evas_object_show(pImageObject);
906                                         }
907                                         else
908                                         {
909                                                 evas_object_hide(pImageObject);
910                                         }
911
912                                         if (pSurfaceImpl && pSurfaceImpl->__pBuffer != null)
913                                         {
914                                                 evas_object_image_source_set(pImageObject, pImageObjectNew);
915 #if 0   // needed if evas_object_show() has not been called  in ctor of _EflVisualElementSurfaceImpl
916                                                 evas_object_show(pImageObjectNew);
917                                                 evas_object_image_source_visible_set(pImageObject, EINA_FALSE);
918 #endif
919                                         }
920
921                                         //evas_object_pass_events_set(pImageObject, EINA_TRUE);
922
923                                         __needEvasObjectSync = true;
924                                         invalidatedNativeProps |= nativeProps;
925                                 }
926                         }
927                 }
928                 // TODO : Have surface, but not newly created
929
930         }
931         else
932         {
933                 // delete old surface
934                 delete __pSurface;
935                 __pSurface = null;
936
937                 // delete shared surface
938                 delete __pSharedSurface;
939                 __pSharedSurface = null;
940         }
941
942
943         if (likely(__pSurface && _VisualElementSurfaceImpl::GetInstance(*__pSurface)))
944         {
945                 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
946
947                 if (unlikely(__pRectangleObject))
948                 {
949                         evas_object_del(__pRectangleObject);
950                         __pRectangleObject = null;
951                 }
952         }
953         else
954         {
955                 pImageObjectNew = null;
956
957                 // WARNING:
958                 //      Newly created rectangle object must be reconfigured by VE!!! (size/pos/visibility/etc)
959                 //
960                 if (likely(!__pRectangleObject) && likely(element.__pSharedData->needSurface))
961                 {
962                         __pRectangleObject = evas_object_rectangle_add(__pEvas);
963                         if (likely(__pRectangleObject))
964                         {
965                                 //evas_object_pass_events_set(__pRectangleObject, EINA_TRUE);
966                                 evas_object_smart_member_add(__pRectangleObject, __pSmartObject);
967                                 evas_object_lower(__pRectangleObject);
968                                 AdjustEvasObjectOrder();
969
970                                 if (evas_object_visible_get(__pSmartObject))
971                                 {
972                                         evas_object_show(__pRectangleObject);
973                                 }
974                                 else
975                                 {
976                                         evas_object_hide(__pRectangleObject);
977                                 }
978
979                                 __needEvasObjectSync = true;
980                                 invalidatedNativeProps |= nativeProps;
981                         }
982                 }
983         }
984
985         element.__pSharedData->surfaceChanged = false;
986
987         if (surfaceOnly)
988         {
989                 return E_SUCCESS;
990         }
991
992
993         const bool isVeVisible = element.IsVisibleI();
994         const bool isEvasVisible = evas_object_visible_get(__pSmartObject);
995
996
997         // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
998         if (unlikely(!isVeVisible))
999         {
1000                 if (isEvasVisible)
1001                 {
1002                         evas_object_hide(__pSmartObject);
1003                 }
1004
1005                 invalidatedNativeProps = 0;
1006
1007                 goto finished;
1008         }
1009         else
1010         {
1011                 if (!isEvasVisible)
1012                 {
1013                         // WARNING:
1014                         //      When visibility of VE is changed into 'visible' and evas object is invisible,
1015                         //      it is needed to set all evas object properties because not all properties were applied due to short-circuit optimization
1016                         //      (When VE is invisible, bounds and colors are not set for optimization)
1017                         invalidatedNativeProps = nativeProps;
1018                 }
1019         }
1020
1021         // Change hierarchy properties such as bounds, clipping and map
1022         if (likely(invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS)) || unlikely(__needEvasObjectSync))
1023         {
1024                 bool needResize = false;
1025                 bool needMove = false;
1026                 bool clipChanged = false;
1027                 bool needMap = false;
1028
1029                 Evas_Coord newX = 0;
1030                 Evas_Coord newY = 0;
1031                 Evas_Coord newW = 0;
1032                 Evas_Coord newH = 0;
1033
1034                 __realBounds.width = element.__alignedSize.width;
1035                 __realBounds.height = element.__alignedSize.height;
1036
1037                 //_VisualElementImpl::AdjustSizeForSurface(__realBounds.width, __realBounds.height);
1038                 _VisualElementCoordinateSystem::ConvertDimensionToPhysical(__realBounds.width, __realBounds.height);
1039
1040                 // WARNING:
1041                 //      Do not use to MakeIntegralDimension. All information about coordinates(position/size) are calculated with same(point) way.
1042                 _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.width, __realBounds.height, newW, newH);
1043
1044                 float clipX = 0.0f;
1045                 float clipY = 0.0f;
1046                 float clipW = 0.0f;
1047                 float clipH = 0.0f;
1048                 Evas_Object* pParentClipper = null;
1049
1050                 if (unlikely(element.__needTransform) || likely(element.__needClipForUntransformed))
1051                 {
1052                         const _VisualElementImpl* pClipSource = element.GetClipSource();
1053
1054                         if (likely(pClipSource))
1055                         {
1056                                 _EflNode* pParentClipNode = static_cast< _EflNode* >(pClipSource->GetNativeNode());
1057                                 if (likely(pParentClipNode))
1058                                 {
1059                                         clipX = pParentClipNode->__realBounds.x;
1060                                         clipY = pParentClipNode->__realBounds.y;
1061                                         clipW = pParentClipNode->__realBounds.width;
1062                                         clipH = pParentClipNode->__realBounds.height;
1063
1064                                         pParentClipper = pParentClipNode->__pClipObject;
1065                                 }
1066                         }
1067                 }
1068
1069
1070                 // Coordinates(including __needTransform flag) are validated by getting clip-source above
1071
1072                 if (likely(!element.__needTransform))
1073                 {
1074                         __realBounds.x = element.__boundingBoxToClipSource.x;
1075                         __realBounds.y = element.__boundingBoxToClipSource.y;
1076                         _VisualElementCoordinateSystem::ConvertPointToPhysical(__realBounds.x, __realBounds.y);
1077
1078                         __realBounds.x += clipX;
1079                         __realBounds.y += clipY;
1080                         _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.x, __realBounds.y, newX, newY);
1081                 }
1082                 else
1083                 {
1084                         float x[4];
1085                         float y[4];
1086                         float z[4];
1087                         int intX[4];
1088                         int intY[4];
1089                         const Tizen::Graphics::FloatMatrix4& xform = element.GetMatrixToClipSource();
1090
1091                         x[0] = 0.0f;
1092                         y[0] = 0.0f;
1093                         z[0] = 0.0f;
1094                         x[1] = element.__alignedSize.width;
1095                         y[1] = 0.0f;
1096                         z[1] = 0.0f;
1097                         x[2] = element.__alignedSize.width;
1098                         y[2] = element.__alignedSize.height;
1099                         z[2] = 0.0f;
1100                         x[3] = 0.0f;
1101                         y[3] = element.__alignedSize.height;
1102                         z[3] = 0.0f;
1103
1104                         for (int i = 0; i < 4; i++)
1105                         {
1106                                 _MatrixUtilTransform(xform, &x[i], &y[i], &z[i]);
1107                                 _VisualElementCoordinateSystem::ConvertPointToPhysical(x[i], y[i]);
1108
1109                                 x[i] += clipX;
1110                                 y[i] += clipY;
1111                         }
1112
1113                         // WARNING:
1114                         //      Use surface size for UV-mapping *ONLY FOR* direct-map-on-image-object, not map-on-smart-object !!!
1115                         if (unlikely(!__pSharedSurface) || unlikely(element.__useContentBounds) || likely(__pClipObject))
1116                         {
1117                                 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1118                                 evas_map_point_image_uv_set(__pMap, 1, (double)newW, 0.0);
1119                                 evas_map_point_image_uv_set(__pMap, 2, (double)newW, (double)newH);
1120                                 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)newH);
1121                         }
1122                         else
1123                         {
1124                                 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1125
1126                                 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1127                                 evas_map_point_image_uv_set(__pMap, 1, (double)surfaceSize.width, 0.0);
1128                                 evas_map_point_image_uv_set(__pMap, 2, (double)surfaceSize.width, (double)surfaceSize.height);
1129                                 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)surfaceSize.height);
1130                         }
1131
1132                         for (int i = 0; i < 4; i++)
1133                         {
1134                                 // WARNING: Do not need integral Z ??
1135                                 _VisualElementCoordinateSystem::MakeIntegralPoint(x[i], y[i], intX[i], intY[i]);
1136                                 evas_map_point_coord_set(__pMap, i, intX[i], intY[i], static_cast< int >(z[i]));
1137                         }
1138
1139
1140                         __realBounds.x = x[0];
1141                         __realBounds.y = y[0];
1142                         newX = intX[0];
1143                         newY = intY[0];
1144
1145                         needMap = true;
1146                 }
1147
1148                 // Adjust flag for bounds changing
1149                 if (unlikely(__needEvasObjectSync))
1150                 {
1151                         needMove = true;
1152                         needResize = true;
1153                 }
1154                 else
1155                 {
1156                         Evas_Coord objX;
1157                         Evas_Coord objY;
1158                         Evas_Coord objW;
1159                         Evas_Coord objH;
1160
1161                         evas_object_geometry_get(__pSmartObject, &objX, &objY, &objW, &objH);
1162
1163                         if (likely(!needMove))
1164                         {
1165                                 needMove = (newX != objX || newY != objY);
1166                         }
1167
1168                         if (likely(!needResize))
1169                         {
1170                                 needResize = (newW != objW || newH != objH);
1171                         }
1172                 }
1173
1174
1175                 if (unlikely(element.__isClipChildren))
1176                 {
1177                         if (unlikely(!__pClipObject) && likely(element.__pSharedData->needSurface))
1178                         {
1179                                 __pClipObject = evas_object_rectangle_add(__pEvas);
1180                                 if (likely(__pClipObject))
1181                                 {
1182                                         evas_object_smart_member_add(__pClipObject, __pSmartObject);
1183                                         evas_object_lower(__pClipObject);
1184                                         AdjustEvasObjectOrder();
1185
1186                                         evas_object_pass_events_set(__pClipObject, EINA_TRUE);
1187                                         evas_object_static_clip_set(__pClipObject, 0);  // CHECKME: What does this mean by ?
1188
1189                                         if (evas_object_visible_get(__pSmartObject))
1190                                         {
1191                                                 evas_object_show(__pClipObject);
1192                                         }
1193                                         else
1194                                         {
1195                                                 evas_object_hide(__pClipObject);
1196                                         }
1197
1198                                         needMove = true;
1199                                         needResize = true;
1200                                         clipChanged = true;
1201                                 }
1202                         }
1203                 }
1204                 else
1205                 {
1206                         if (unlikely(__pClipObject))
1207                         {
1208                                 evas_object_del(__pClipObject);
1209                                 __pClipObject = null;
1210                                 clipChanged = true;
1211                         }
1212                 }
1213
1214
1215                 // WARNING:
1216                 //      Update image-holder information before using it !
1217                 //      Image-Holder is needed only when using content-bounds and maps on image-object, not smart-object.
1218                 if (unlikely(AdjustImageHolder(element.__useContentBounds && !__pClipObject && needMap)))
1219                 {
1220                         needMove = true;
1221                         needResize = true;
1222                         clipChanged = true;
1223                         __needEvasObjectSync = true;
1224                 }
1225
1226
1227                 // WARNING:
1228                 //      In general, changing size/position before mapping/clipping *may* improve performance, because calculating map and clip
1229                 //      needs bounds information.
1230
1231                 // Set-up Position
1232                 if (likely(needMove))
1233                 {
1234                         evas_object_move(__pSmartObject, newX, newY);
1235
1236                         if (likely(__pClipObject))
1237                         {
1238                                 evas_object_move(__pClipObject, newX, newY);
1239                         }
1240
1241                         if (likely(__pImageHolder))
1242                         {
1243                                 evas_object_move(__pImageHolder, newX, newY);
1244                         }
1245
1246                         if (likely(pImageObjectNew))
1247                         {
1248                                 evas_object_move(pImageObjectNew, newX, newY);
1249                         }
1250
1251                         if (unlikely(__pRectangleObject))
1252                         {
1253                                 evas_object_move(__pRectangleObject, newX, newY);
1254                         }
1255
1256                         if (unlikely(__pNativeSmartObject))
1257                         {
1258                                 evas_object_move(__pNativeSmartObject, newX, newY);
1259                         }
1260                 }
1261
1262                 // Set-up Size
1263                 if (unlikely(needResize))
1264                 {
1265                         evas_object_resize(__pSmartObject, newW, newH);
1266
1267                         if (likely(__pClipObject))
1268                         {
1269                                 evas_object_resize(__pClipObject, newW, newH);
1270                         }
1271
1272                         if (likely(__pImageHolder))
1273                         {
1274                                 evas_object_resize(__pImageHolder, newW, newH);
1275                         }
1276
1277                         if (likely(pImageObjectNew))
1278                         {
1279                                 evas_object_resize(pImageObjectNew, newW, newH);
1280                         }
1281
1282                         if (unlikely(__pRectangleObject))
1283                         {
1284                                 evas_object_resize(__pRectangleObject, newW, newH);
1285                         }
1286
1287                         if (unlikely(__pNativeSmartObject))
1288                         {
1289                                 evas_object_resize(__pNativeSmartObject, newW, newH);
1290                         }
1291
1292                 }
1293
1294
1295                 // Set-up Clipping
1296                 if (unlikely(__needEvasObjectSync) || unlikely(clipChanged) || unlikely(evas_object_clip_get(__pSmartObject) != pParentClipper))
1297                 {
1298                         evas_object_clip_set(__pSmartObject, pParentClipper);
1299
1300                         // CHECKME:
1301                         //      Is it needed to set clipper for image-holder smart object ?
1302
1303                         if (likely(__pClipObject))
1304                         {
1305                                 evas_object_clip_set(__pClipObject, pParentClipper);
1306
1307                                 if (unlikely(__pImageHolder))
1308                                 {
1309                                         evas_object_clip_set(__pImageHolder, __pClipObject);
1310                                 }
1311
1312                                 if (likely(pImageObjectNew))
1313                                 {
1314                                         evas_object_clip_set(pImageObjectNew, __pClipObject);
1315                                 }
1316
1317                                 if (unlikely(__pRectangleObject))
1318                                 {
1319                                         evas_object_clip_set(__pRectangleObject, __pClipObject);
1320                                 }
1321
1322                                 if (unlikely(__pNativeSmartObject))
1323                                 {
1324                                         evas_object_clip_set(__pNativeSmartObject, __pClipObject);
1325                                 }
1326                         }
1327                         else
1328                         {
1329                                 if (unlikely(__pImageHolder))
1330                                 {
1331                                         evas_object_clip_set(__pImageHolder, pParentClipper);
1332                                 }
1333
1334                                 if (likely(pImageObjectNew))
1335                                 {
1336                                         evas_object_clip_set(pImageObjectNew, pParentClipper);
1337                                 }
1338
1339                                 if (unlikely(__pRectangleObject))
1340                                 {
1341                                         evas_object_clip_set(__pRectangleObject, pParentClipper);
1342                                 }
1343
1344                                 if (unlikely(__pNativeSmartObject))
1345                                 {
1346                                         evas_object_clip_set(__pNativeSmartObject, pParentClipper);
1347                                 }
1348
1349                         }
1350                 }
1351
1352
1353                 // Set-up Maps
1354                 if (unlikely(__needEvasObjectSync) || unlikely(__mapUsed != needMap) || unlikely(needMap) || unlikely(clipChanged))
1355                 {
1356                         const bool needClipSmartMap = (__pClipObject && needMap);
1357                         const bool needClipObjectMap = (!__pClipObject && needMap);
1358
1359                         evas_object_map_enable_set(__pSmartObject, needClipSmartMap);
1360                         evas_object_map_set(__pSmartObject, (needClipSmartMap ? __pMap : null));
1361
1362                         if (unlikely(__pImageHolder))
1363                         {
1364                                 evas_object_map_enable_set(__pImageHolder, needClipObjectMap);
1365                                 evas_object_map_set(__pImageHolder, (needClipObjectMap ? __pMap : null));
1366
1367                                 if (likely(pImageObjectNew))
1368                                 {
1369                                         evas_object_map_enable_set(pImageObjectNew, EINA_FALSE);
1370                                         evas_object_map_set(pImageObjectNew, null);
1371                                 }
1372                         }
1373                         else if (likely(pImageObjectNew))
1374                         {
1375                                 evas_object_map_enable_set(pImageObjectNew, needClipObjectMap);
1376                                 evas_object_map_set(pImageObjectNew, (needClipObjectMap ? __pMap : null));
1377                         }
1378
1379                         if (unlikely(__pRectangleObject))
1380                         {
1381                                 evas_object_map_enable_set(__pRectangleObject, needClipObjectMap);
1382                                 evas_object_map_set(__pRectangleObject, (needClipObjectMap ? __pMap : null));
1383                         }
1384
1385                         if (unlikely(__pNativeSmartObject))
1386                         {
1387                                 evas_object_map_enable_set(__pNativeSmartObject, needClipObjectMap);
1388                                 evas_object_map_set(__pNativeSmartObject, (needClipObjectMap ? __pMap : null));
1389                         }
1390                         __mapUsed = needMap;
1391                 }
1392
1393
1394                 // Set-up Content Bounds
1395                 // WARNING:
1396                 //      EFL Bug! - evas_object_fill_set should be invoked only *AFTER* adjusting maps !!!!!
1397                 //                 If contents bounds are modifed before adjusting maps, it will not be applied !!!
1398                 if (likely(pImageObjectNew) && likely(__pSharedSurface))
1399                 {
1400                         bool needDefaultFillSet = true;
1401
1402                         if (unlikely(element.__useContentBounds))
1403                         {
1404                                 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1405                                 const FloatRectangle& contentBounds = element.__contentBounds;
1406                                 Rectangle contentBoundsAdjusted;
1407
1408                                 // Formula:
1409                                 //
1410                                 //  content bounds(px) = content bounds(uniform) * surface size(px)
1411                                 //
1412                                 //                                                                               surface size(px)                                  1
1413                                 //      mapped content size(px) = bounds size(px) * ------------------ = bounds size(px) * -----------------------
1414                                 //                                                                               content size(px)                       content size(uniform)
1415                                 //
1416                                 //      mapped content size(px) : surface size(px) = mapped content pos(px) : content pos(px)
1417                                 //
1418                                 //                                                                              mapped content size(px)    content pos(uniform) * bounds size(px)
1419                                 //      mapped content pos(px) = content pos(px) * ------------------------- = -----------------------------------------
1420                                 //                                                                                 surface size(px)            content size(uniform)
1421
1422                                 _VisualElementCoordinateSystem::MakeIntegralPoint(
1423                                         -contentBounds.x * static_cast< float >(newW) / contentBounds.width,
1424                                         -contentBounds.y * static_cast< float >(newH) / contentBounds.height,
1425                                         contentBoundsAdjusted.x,
1426                                         contentBoundsAdjusted.y
1427                                 );
1428                                 _VisualElementCoordinateSystem::MakeIntegralPoint(
1429                                         static_cast< float >(newW) / contentBounds.width,               // WARNING: No use of __realBounds. new[WH] is the real displaying value which is integral.
1430                                         static_cast< float >(newH) / contentBounds.height,
1431                                         contentBoundsAdjusted.width,
1432                                         contentBoundsAdjusted.height
1433                                 );
1434
1435                                 // Added to resolve the problem that the left edge part is shown repeatedly to the right edge.
1436                                 contentBoundsAdjusted.width += ceil(static_cast< float >(newW) / contentBounds.width - contentBoundsAdjusted.width);
1437                                 contentBoundsAdjusted.height += ceil(static_cast< float >(newH) / contentBounds.height - contentBoundsAdjusted.height);
1438
1439                                 if (likely(contentBoundsAdjusted.width > 0) && likely(contentBoundsAdjusted.height > 0))
1440                                 {
1441
1442                                         if (pSurfaceImpl && pSurfaceImpl->__isImageObject)
1443                                         {
1444                                                 evas_object_image_fill_set(
1445                                                         pImageObjectNew,
1446                                                         contentBoundsAdjusted.x,
1447                                                         contentBoundsAdjusted.y,
1448                                                         contentBoundsAdjusted.width,
1449                                                         contentBoundsAdjusted.height
1450                                                 );
1451                                         }
1452
1453                                         needDefaultFillSet = false;
1454                                 }
1455                         }
1456
1457                         if (likely(needDefaultFillSet))
1458                         {
1459                                 if (pSurfaceImpl && pSurfaceImpl->__isImageObject)
1460                                 {
1461                                         evas_object_image_fill_set(pImageObjectNew, 0, 0, newW, newH);
1462                                 }
1463                         }
1464                 }
1465
1466
1467                 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS);
1468         }
1469
1470
1471         if ((invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY)) || unlikely(__needEvasObjectSync))
1472         {
1473                 float alpha = element.GetOpacityFromRoot();
1474                 bool renderOperationChanged = false;
1475
1476                 if (unlikely(__renderOperation != element.__renderOperation))
1477                 {
1478                         renderOperationChanged = true;
1479                         __renderOperation = element.__renderOperation;
1480                 }
1481
1482
1483                 // pImageObjectNew does exist.
1484                 if (likely(pImageObjectNew))
1485                 {
1486                         if (unlikely(renderOperationChanged))
1487                         {
1488                                 evas_object_render_op_set(pImageObjectNew, GetRenderOperation(element.__renderOperation));
1489                         }
1490
1491                         int premultipliedColor =  static_cast< int >(255.0f * alpha); // white color
1492                         evas_object_color_set(pImageObjectNew, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1493                 }
1494
1495
1496                 // rectangle setting
1497                 if (unlikely(__pRectangleObject))
1498                 {
1499                         if (unlikely(renderOperationChanged))
1500                         {
1501                                 evas_object_render_op_set(__pRectangleObject, GetRenderOperation(element.__renderOperation));
1502                         }
1503
1504                         float alphaRect = alpha * __backgroundColor.Alpha() * 255.0f;
1505
1506                         evas_object_color_set(
1507                                 __pRectangleObject,
1508                                 static_cast< int >(__backgroundColor.Red() * alphaRect),
1509                                 static_cast< int >(__backgroundColor.Green() * alphaRect),
1510                                 static_cast< int >(__backgroundColor.Blue() * alphaRect),
1511                                 static_cast< int >(alphaRect)
1512                         );
1513                 }
1514
1515                 // WARNING: CHECKME: TODO:
1516                 //      How can we native smart object
1517
1518                 // Native Smart Object does exist.
1519                 if (unlikely(__pNativeSmartObject))
1520                 {
1521
1522                         if (unlikely(renderOperationChanged))
1523                         {
1524                                 evas_object_render_op_set(__pNativeSmartObject, GetRenderOperation(element.__renderOperation));
1525                         }
1526
1527                         if (unlikely(element.__renderOperation == VisualElement::RENDER_OPERATION_COPY))
1528                         {
1529                                 evas_object_color_set(__pNativeSmartObject, 0, 0, 0, 0);        // for smart
1530 //                              evas_object_color_set(__pNativeSmartObject, 255, 255, 255, 255);// for image
1531                         }
1532                         else
1533                         {
1534                                 int premultipliedColor = static_cast< int >(255.0f * alpha); // white color
1535                                 evas_object_color_set(__pNativeSmartObject, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1536                         }
1537
1538                 }
1539
1540                 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY);
1541         }
1542
1543
1544         // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1545         if (likely(isVeVisible))
1546         {
1547                 if (unlikely(!isEvasVisible))
1548                 {
1549                         evas_object_show(__pSmartObject);       // Children of smart-object such as rectangle and clip-object may be invisible here.
1550                 }
1551         }
1552         else
1553         {
1554                 if (unlikely(isEvasVisible))
1555                 {
1556                         evas_object_hide(__pSmartObject);
1557                 }
1558         }
1559
1560
1561         // WARNING:
1562         //      Only after setting all invalidated properties, need-sync flag can be cleared
1563         __needEvasObjectSync = false;
1564
1565 finished:
1566
1567         return E_SUCCESS;
1568 }
1569
1570 VisualElementSurface*
1571 _EflNode::GetSurface(void) const
1572 {
1573         return __pSurface;
1574 }
1575
1576
1577 }}}             // Tizen::Ui::Animations
1578