2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUiAnim_EflNode.cpp
20 * @brief This file contains implementation of _EflNode class
22 * This file contains implementation _EflNode class.
25 #include <unique_ptr.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>
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"
46 #include "FUiAnim_EflVisualElementSurfaceImpl.h"
50 #include <Evas_Engine_Buffer.h>
53 using namespace Tizen;
54 using namespace Tizen::Base;
55 using namespace Tizen::Graphics;
60 void EvasSmartObjectShowChildren(Evas_Object* pSmartObject);
61 void EvasSmartObjectHideChildren(Evas_Object* pSmartObject);
62 void EvasSmartObjectHideAllChildren(Evas_Object* pSmartObject);
64 Evas_Smart_Class smartClassForVisualElement =
66 "visual_element", // name
72 EvasSmartObjectShowChildren, // show
73 EvasSmartObjectHideChildren, // hide
86 Evas_Smart_Class smartClassForImageHolder =
88 "image_holder", // name
94 EvasSmartObjectShowChildren, // show
95 EvasSmartObjectHideChildren, // hide
109 EvasSmartObjectShowChildren(Evas_Object* pSmartObject)
111 Eina_List* pChildrenList = evas_object_smart_members_get(pSmartObject);
112 if (likely(pChildrenList))
114 void* pEvasObject = null;
115 EINA_LIST_FREE(pChildrenList, pEvasObject)
117 if (likely(pEvasObject) && unlikely(evas_object_type_get((Evas_Object*)pEvasObject) != smartClassForVisualElement.name))
119 evas_object_show((Evas_Object*)pEvasObject);
127 EvasSmartObjectHideChildren(Evas_Object* pSmartObject)
129 // hide objects only for this node
130 Eina_List* pChildrenList = evas_object_smart_members_get(pSmartObject);
131 if (likely(pChildrenList))
133 void* pEvasObject = null;
134 EINA_LIST_FREE(pChildrenList, pEvasObject)
136 if (likely(pEvasObject) && unlikely(evas_object_type_get((Evas_Object*)pEvasObject) != smartClassForVisualElement.name))
138 evas_object_hide((Evas_Object*)pEvasObject);
145 EvasSmartObjectHideAllChildren(Evas_Object* pSmartObject)
147 // hide all descendants
148 Eina_List* pChildrenList = evas_object_smart_members_get(pSmartObject);
149 if (likely(pChildrenList))
151 void* pEvasObject = null;
152 EINA_LIST_FREE(pChildrenList, pEvasObject)
154 if (likely(pEvasObject))
156 evas_object_hide((Evas_Object*)pEvasObject);
163 NormalizeUniformRectangle(Rectangle& rectangle, int width, int height)
165 if (unlikely(width <= 0) || unlikely(height <= 0))
170 if (unlikely(rectangle.x < 0))
172 rectangle.x = width - ((-rectangle.x) % width);
175 if (unlikely(rectangle.y < 0))
177 rectangle.y = height - ((-rectangle.y) % height);
181 inline Evas_Render_Op
182 GetRenderOperation(Tizen::Ui::Animations::VisualElement::RenderOperation renderOperation)
184 switch (renderOperation)
187 case Tizen::Ui::Animations::VisualElement::RENDER_OPERATION_BLEND:
188 return EVAS_RENDER_BLEND;
190 case Tizen::Ui::Animations::VisualElement::RENDER_OPERATION_COPY:
191 return EVAS_RENDER_COPY;
195 //Evas* __pEvas = null;
199 namespace Tizen { namespace Ui { namespace Animations
202 Evas_Smart* _EflNode::__pStaticSmartClass = null;
203 Evas_Smart* _EflNode::__pStaticSmartClassForImageHolder = null;
205 _EflNode::_EflNode(void)
207 , __pSharedSurface(null)
209 , __pSmartObject(null)
210 , __pClipObject(null)
211 , __pRectangleObject(null)
212 , __pImageHolder(null)
213 , __pNativeSmartObject(null)
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
224 _EflNode::~_EflNode(void)
230 _EflNode::Construct(void)
233 if (__pSmartObject || __pMap)
235 return E_INVALID_STATE;
240 // todo: need refactoring !
241 Tizen::Ui::_EcoreEvasMgr* pMgr = Tizen::Ui::GetEcoreEvasMgr();
243 if (pMgr && pMgr->GetEcoreEvas())
245 __pEvas = pMgr->GetEcoreEvas()->GetEvas();
255 if (!__pStaticSmartClass)
257 __pStaticSmartClass = evas_smart_class_new(&smartClassForVisualElement); // TODO: no need to delete ???
260 __pSmartObject = evas_object_smart_add(__pEvas, __pStaticSmartClass);
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);
270 evas_object_show(__pSmartObject);
272 // __pClipObject = evas_object_rectangle_add(__pEvas);
273 // if (!__pClipObject)
277 // evas_object_smart_member_add(__pClipObject,__pSmartObject);
278 // evas_object_lower(__pClipObject);
280 // evas_object_pass_events_set(__pClipObject, EINA_TRUE);
283 __pMap = evas_map_new(4);
289 evas_map_alpha_set(__pMap, EINA_TRUE);
290 evas_map_smooth_set(__pMap, EINA_TRUE);
297 evas_object_del(__pSmartObject);
300 __pSmartObject = null;
302 // if (__pClipObject)
303 // evas_object_del(__pClipObject);
305 // __pClipObject = null;
309 evas_map_free(__pMap);
321 _EflNode::RebuildIfNeeded(const _INativeNode& parent)
323 _EflNode* pParent = dynamic_cast<_EflNode*>(const_cast<_INativeNode*>(&parent));
326 return E_INVALID_ARG;
328 if (pParent->__pLayer)
330 return ReConstruct(*pParent->__pLayer);
332 return E_INVALID_STATE;
333 // __pLayer = pParent->pLayer;
334 //return ReConstruct(pParent->__pEvas);
338 _EflNode::ReConstruct(const _NativeLayer& layer)
340 if (__pLayer == &layer)
345 _EflLayer* pLayer = dynamic_cast<_EflLayer*>(const_cast<_NativeLayer*>(&layer));
348 return E_INVALID_ARG;
351 return ReConstruct(pLayer->GetEvas());
355 _EflNode::ReConstruct(const Evas* pEvas)
359 return E_INVALID_ARG;
364 __pEvas = const_cast<Evas*>(pEvas);
367 if (!__pStaticSmartClass)
369 __pStaticSmartClass = evas_smart_class_new(&smartClassForVisualElement); // TODO: no need to delete ???
372 __pSmartObject = evas_object_smart_add(__pEvas, __pStaticSmartClass);
378 if (!__pStaticSmartClassForImageHolder)
380 __pStaticSmartClassForImageHolder = evas_smart_class_new(&smartClassForImageHolder); // TODO: no need to delete ???
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);
387 if (__pNativeSmartObject)
389 evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject);
390 AdjustEvasObjectOrder();
393 evas_object_show(__pSmartObject);
395 // __pClipObject = evas_object_rectangle_add(pEvas);
396 // if (!__pClipObject)
400 // evas_object_smart_member_add(__pClipObject,__pSmartObject);
401 // evas_object_lower(__pClipObject);
403 // evas_object_pass_events_set(__pClipObject, EINA_TRUE);
408 evas_map_free(__pMap);
410 __pMap = evas_map_new(4);
416 evas_map_alpha_set(__pMap, EINA_TRUE);
417 evas_map_smooth_set(__pMap, EINA_TRUE);
426 evas_object_del(__pSmartObject);
429 __pSmartObject = null;
431 // if (__pClipObject)
432 // evas_object_del(__pClipObject);
434 // __pClipObject = null;
438 evas_map_free(__pMap);
447 _EflNode::Destruct(void)
452 evas_object_del(__pSmartObject);
453 __pSmartObject = null;
458 evas_object_del(__pClipObject);
459 __pClipObject = null;
462 if (__pRectangleObject)
464 evas_object_del(__pRectangleObject);
465 __pRectangleObject = null;
470 evas_map_free(__pMap);
480 if (__pSharedSurface)
482 delete __pSharedSurface;
483 __pSharedSurface = null;
488 evas_object_del(__pImageHolder);
491 if (unlikely(__pNativeSmartObject))
493 evas_object_smart_member_del(__pNativeSmartObject);
494 //__pNativeSmartObject = null;
501 _EflNode::GetEvas(void) const
507 _EflNode::GetGroupContainer(void) const
509 return reinterpret_cast< Handle >(__pSmartObject);
513 _EflNode::AdjustEvasObjectOrder(void)
516 if (__pNativeSmartObject)
517 evas_object_lower(__pNativeSmartObject);
518 // evas_object_raise(__pNativeSmartObject);
523 _EflNode::SetNativeObject(VisualElement& element, Evas_Object* pNativeObject)
525 if (unlikely(__pNativeSmartObject != pNativeObject))
527 if (unlikely(__pNativeSmartObject))
529 evas_object_smart_member_del(__pNativeSmartObject);
532 __pNativeSmartObject = pNativeObject;
534 if (__pNativeSmartObject)
536 evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject);
540 AdjustEvasObjectOrder();
543 const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
544 | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
545 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
546 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
548 _VisualElementImpl* pElementImpl = _VisualElementImpl::GetInstance(element);
549 if (likely(pElementImpl))
551 pElementImpl->InvalidateHierarchyProps(nativeProps, false, false);
556 _EflNode::AddNativeSmartObject(VisualElement& element, Evas_Object* pSmartObject)
558 SetNativeObject(element, pSmartObject);
562 _EflNode::RemoveNativeObject(void)
564 __pNativeSmartObject = null;
568 _EflNode::GetNativeObject(void) const
570 return __pNativeSmartObject;
574 _EflNode::InsertChild(_INativeNode& child, const _INativeNode* pReference, bool above)
576 _EflNode& nativeChild = dynamic_cast< _EflNode& >(child);
577 const _EflNode* pNativeReference = dynamic_cast< const _EflNode* >(pReference);
579 RemoveChild(nativeChild);
583 return E_INVALID_STATE;
586 evas_object_smart_member_add(nativeChild.__pSmartObject, __pSmartObject);
588 // The order of evas objects should be as follows:
589 // [native smart object] [image/image-holder/rectangle/clipper] [child smart object]*
591 if (likely(pNativeReference))
595 evas_object_stack_above(nativeChild.__pSmartObject, pNativeReference->__pSmartObject);
599 evas_object_stack_below(nativeChild.__pSmartObject, pNativeReference->__pSmartObject);
606 evas_object_raise(nativeChild.__pSmartObject);
610 Evas_Object* pRefObject = null;
613 if (likely(__pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSurface)))
615 pRefObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
617 else if (likely(__pRectangleObject))
619 pRefObject = __pRectangleObject;
621 else if (likely(__pImageHolder))
623 pRefObject = __pImageHolder;
626 if (likely(pRefObject))
628 evas_object_stack_above(nativeChild.__pSmartObject, pRefObject);
632 evas_object_lower(nativeChild.__pSmartObject);
637 AdjustEvasObjectOrder();
643 _EflNode::RemoveChild(_INativeNode& child)
645 _EflNode& nativeChild = dynamic_cast< _EflNode& >(child);
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;
656 evas_object_smart_member_del(nativeChild.__pSmartObject);
659 if (nativeChild.__pClipObject)
660 evas_object_hide((Evas_Object*)nativeChild.__pClipObject);
662 if (nativeChild.__pRectangleObject)
663 evas_object_hide((Evas_Object*)nativeChild.__pRectangleObject);
665 if (nativeChild.__pSurface && nativeChild.__pSurface->GetNativeHandle())
666 evas_object_hide((Evas_Object*)nativeChild.__pSurface->GetNativeHandle());
673 _EflNode::SetFlushNeeded(void)
675 _EflVisualElementSurfaceImpl* pSurfaceImpl = null;
678 return E_INVALID_STATE;
680 pSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*__pSurface));
683 return E_INVALID_STATE;
686 Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
693 if (pSurfaceImpl->__isImageObject)
695 evas_object_image_size_get(pImageObject, &imageWidth, &imageHeight);
696 evas_object_image_data_update_add(pImageObject, 0, 0, imageWidth, imageHeight);
702 __pLayer->SetFlushNeeded();
709 _EflNode::Flush(void)
711 #ifndef VE_VSYNC_UPDATE
716 // ecore_evas_manual_render(ecore_evas_ecore_evas_get(__pEvas));
723 _EflNode::GetBackgroundColor(void) const
725 return __backgroundColor;
729 _EflNode::SetBackgroundColor(const _Colorf& backgroundColor)
731 __backgroundColor = backgroundColor;
737 _EflNode::AdjustImageHolder(bool useHolder)
739 if (unlikely(!__pSurface))
744 Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
745 if (unlikely(!pImageObject))
750 if (unlikely(useHolder))
752 if (likely(!__pImageHolder))
754 __pImageHolder = evas_object_smart_add(__pEvas, __pStaticSmartClassForImageHolder);
755 if (unlikely(!__pSmartObject))
757 SysLog(NID_UI_ANIM, "Smart object cannot be created.");
761 evas_object_propagate_events_set(__pImageHolder, EINA_TRUE);
762 evas_object_smart_member_add(pImageObject, __pImageHolder);
764 evas_object_smart_member_add(__pImageHolder, __pSmartObject);
765 evas_object_lower(__pImageHolder);
766 AdjustEvasObjectOrder();
768 if (evas_object_visible_get(__pSmartObject))
770 evas_object_show(__pImageHolder);
774 evas_object_hide(__pImageHolder);
782 if (likely(__pImageHolder))
784 evas_object_smart_member_add(pImageObject, __pSmartObject);
785 evas_object_lower(pImageObject);
786 AdjustEvasObjectOrder();
788 evas_object_del(__pImageHolder);
789 __pImageHolder = null;
799 _EflNode::Reconfigure(VisualElementSurface* pSurface, _VisualElementImpl& element, bool surfaceOnly)
801 Evas_Object* pImageObjectOrg = null;
802 Evas_Object* pImageObjectNew = null;
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;
810 invalidatedNativeProps &= nativeProps;
813 _EflVisualElementSurfaceImpl* pSurfaceImpl = null;
815 if (likely(pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*pSurface)))
817 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle());
818 pSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
821 if (likely(__pSharedSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)))
823 pImageObjectOrg = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
827 if (likely(pImageObjectNew))
829 bool createNewObject = true;
831 if (likely(__pSurface))
833 // if the surfaces are same, change the size
834 if (likely(pImageObjectNew == pImageObjectOrg))
836 createNewObject = false;
838 // if the surface is changed, delete old surface
841 delete __pSharedSurface;
842 __pSharedSurface = null;
846 // create new surface
847 if (unlikely(createNewObject))
849 unique_ptr<VisualElementSurface> pNewSharedSurface(new (std::nothrow) VisualElementSurface(*pSurface));
850 SysTryReturnResult(NID_UI_ANIM, pNewSharedSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
852 _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
853 if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer == null)
855 unique_ptr<VisualElementSurface> pNewSurface(new (std::nothrow) VisualElementSurface(*pSurface));
856 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
863 __pSurface = pNewSurface.release();
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.");
875 __pSurface = pNewSurface.release();
877 if (!element.GetModel()->__imageFilePath.IsEmpty() && _VisualElementSurfaceImpl::GetInstance(*__pSurface))
879 _VisualElementSurfaceImpl::GetInstance(*__pSurface)->SetImage(element.GetModel()->__imageFilePath);
883 if (__pSharedSurface)
885 delete __pSharedSurface;
886 __pSharedSurface = null;
888 __pSharedSurface = pNewSharedSurface.release();
890 Evas_Object* pImageObject = null;
891 if (_VisualElementSurfaceImpl::GetInstance(*__pSurface))
893 pImageObject = (Evas_Object*)_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle();
895 if (likely(pImageObject))
897 evas_object_anti_alias_set(pImageObject, EINA_TRUE);
899 evas_object_smart_member_add(pImageObject, __pSmartObject);
900 evas_object_lower(pImageObject);
901 AdjustEvasObjectOrder();
903 if (evas_object_visible_get(__pSmartObject))
905 evas_object_show(pImageObject);
909 evas_object_hide(pImageObject);
912 if (pSurfaceImpl && pSurfaceImpl->__pBuffer != null)
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);
921 //evas_object_pass_events_set(pImageObject, EINA_TRUE);
923 __needEvasObjectSync = true;
924 invalidatedNativeProps |= nativeProps;
928 // TODO : Have surface, but not newly created
933 // delete old surface
937 // delete shared surface
938 delete __pSharedSurface;
939 __pSharedSurface = null;
943 if (likely(__pSurface && _VisualElementSurfaceImpl::GetInstance(*__pSurface)))
945 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
947 if (unlikely(__pRectangleObject))
949 evas_object_del(__pRectangleObject);
950 __pRectangleObject = null;
955 pImageObjectNew = null;
958 // Newly created rectangle object must be reconfigured by VE!!! (size/pos/visibility/etc)
960 if (likely(!__pRectangleObject) && likely(element.__pSharedData->needSurface))
962 __pRectangleObject = evas_object_rectangle_add(__pEvas);
963 if (likely(__pRectangleObject))
965 //evas_object_pass_events_set(__pRectangleObject, EINA_TRUE);
966 evas_object_smart_member_add(__pRectangleObject, __pSmartObject);
967 evas_object_lower(__pRectangleObject);
968 AdjustEvasObjectOrder();
970 if (evas_object_visible_get(__pSmartObject))
972 evas_object_show(__pRectangleObject);
976 evas_object_hide(__pRectangleObject);
979 __needEvasObjectSync = true;
980 invalidatedNativeProps |= nativeProps;
985 element.__pSharedData->surfaceChanged = false;
993 const bool isVeVisible = element.IsVisibleI();
994 const bool isEvasVisible = evas_object_visible_get(__pSmartObject);
997 // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
998 if (unlikely(!isVeVisible))
1002 evas_object_hide(__pSmartObject);
1005 invalidatedNativeProps = 0;
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;
1021 // Change hierarchy properties such as bounds, clipping and map
1022 if (likely(invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS)) || unlikely(__needEvasObjectSync))
1024 bool needResize = false;
1025 bool needMove = false;
1026 bool clipChanged = false;
1027 bool needMap = false;
1029 Evas_Coord newX = 0;
1030 Evas_Coord newY = 0;
1031 Evas_Coord newW = 0;
1032 Evas_Coord newH = 0;
1034 __realBounds.width = element.__alignedSize.width;
1035 __realBounds.height = element.__alignedSize.height;
1037 //_VisualElementImpl::AdjustSizeForSurface(__realBounds.width, __realBounds.height);
1038 _VisualElementCoordinateSystem::ConvertDimensionToPhysical(__realBounds.width, __realBounds.height);
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);
1048 Evas_Object* pParentClipper = null;
1050 if (unlikely(element.__needTransform) || likely(element.__needClipForUntransformed))
1052 const _VisualElementImpl* pClipSource = element.GetClipSource();
1054 if (likely(pClipSource))
1056 _EflNode* pParentClipNode = static_cast< _EflNode* >(pClipSource->GetNativeNode());
1057 if (likely(pParentClipNode))
1059 clipX = pParentClipNode->__realBounds.x;
1060 clipY = pParentClipNode->__realBounds.y;
1061 clipW = pParentClipNode->__realBounds.width;
1062 clipH = pParentClipNode->__realBounds.height;
1064 pParentClipper = pParentClipNode->__pClipObject;
1070 // Coordinates(including __needTransform flag) are validated by getting clip-source above
1072 if (likely(!element.__needTransform))
1074 __realBounds.x = element.__boundingBoxToClipSource.x;
1075 __realBounds.y = element.__boundingBoxToClipSource.y;
1076 _VisualElementCoordinateSystem::ConvertPointToPhysical(__realBounds.x, __realBounds.y);
1078 __realBounds.x += clipX;
1079 __realBounds.y += clipY;
1080 _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.x, __realBounds.y, newX, newY);
1089 const Tizen::Graphics::FloatMatrix4& xform = element.GetMatrixToClipSource();
1094 x[1] = element.__alignedSize.width;
1097 x[2] = element.__alignedSize.width;
1098 y[2] = element.__alignedSize.height;
1101 y[3] = element.__alignedSize.height;
1104 for (int i = 0; i < 4; i++)
1106 _MatrixUtilTransform(xform, &x[i], &y[i], &z[i]);
1107 _VisualElementCoordinateSystem::ConvertPointToPhysical(x[i], y[i]);
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))
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);
1124 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
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);
1132 for (int i = 0; i < 4; i++)
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]));
1140 __realBounds.x = x[0];
1141 __realBounds.y = y[0];
1148 // Adjust flag for bounds changing
1149 if (unlikely(__needEvasObjectSync))
1161 evas_object_geometry_get(__pSmartObject, &objX, &objY, &objW, &objH);
1163 if (likely(!needMove))
1165 needMove = (newX != objX || newY != objY);
1168 if (likely(!needResize))
1170 needResize = (newW != objW || newH != objH);
1175 if (unlikely(element.__isClipChildren))
1177 if (unlikely(!__pClipObject) && likely(element.__pSharedData->needSurface))
1179 __pClipObject = evas_object_rectangle_add(__pEvas);
1180 if (likely(__pClipObject))
1182 evas_object_smart_member_add(__pClipObject, __pSmartObject);
1183 evas_object_lower(__pClipObject);
1184 AdjustEvasObjectOrder();
1186 evas_object_pass_events_set(__pClipObject, EINA_TRUE);
1187 evas_object_static_clip_set(__pClipObject, 0); // CHECKME: What does this mean by ?
1189 if (evas_object_visible_get(__pSmartObject))
1191 evas_object_show(__pClipObject);
1195 evas_object_hide(__pClipObject);
1206 if (unlikely(__pClipObject))
1208 evas_object_del(__pClipObject);
1209 __pClipObject = null;
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)))
1223 __needEvasObjectSync = true;
1228 // In general, changing size/position before mapping/clipping *may* improve performance, because calculating map and clip
1229 // needs bounds information.
1232 if (likely(needMove))
1234 evas_object_move(__pSmartObject, newX, newY);
1236 if (likely(__pClipObject))
1238 evas_object_move(__pClipObject, newX, newY);
1241 if (likely(__pImageHolder))
1243 evas_object_move(__pImageHolder, newX, newY);
1246 if (likely(pImageObjectNew))
1248 evas_object_move(pImageObjectNew, newX, newY);
1251 if (unlikely(__pRectangleObject))
1253 evas_object_move(__pRectangleObject, newX, newY);
1256 if (unlikely(__pNativeSmartObject))
1258 evas_object_move(__pNativeSmartObject, newX, newY);
1263 if (unlikely(needResize))
1265 evas_object_resize(__pSmartObject, newW, newH);
1267 if (likely(__pClipObject))
1269 evas_object_resize(__pClipObject, newW, newH);
1272 if (likely(__pImageHolder))
1274 evas_object_resize(__pImageHolder, newW, newH);
1277 if (likely(pImageObjectNew))
1279 evas_object_resize(pImageObjectNew, newW, newH);
1282 if (unlikely(__pRectangleObject))
1284 evas_object_resize(__pRectangleObject, newW, newH);
1287 if (unlikely(__pNativeSmartObject))
1289 evas_object_resize(__pNativeSmartObject, newW, newH);
1296 if (unlikely(__needEvasObjectSync) || unlikely(clipChanged) || unlikely(evas_object_clip_get(__pSmartObject) != pParentClipper))
1298 evas_object_clip_set(__pSmartObject, pParentClipper);
1301 // Is it needed to set clipper for image-holder smart object ?
1303 if (likely(__pClipObject))
1305 evas_object_clip_set(__pClipObject, pParentClipper);
1307 if (unlikely(__pImageHolder))
1309 evas_object_clip_set(__pImageHolder, __pClipObject);
1312 if (likely(pImageObjectNew))
1314 evas_object_clip_set(pImageObjectNew, __pClipObject);
1317 if (unlikely(__pRectangleObject))
1319 evas_object_clip_set(__pRectangleObject, __pClipObject);
1322 if (unlikely(__pNativeSmartObject))
1324 evas_object_clip_set(__pNativeSmartObject, __pClipObject);
1329 if (unlikely(__pImageHolder))
1331 evas_object_clip_set(__pImageHolder, pParentClipper);
1334 if (likely(pImageObjectNew))
1336 evas_object_clip_set(pImageObjectNew, pParentClipper);
1339 if (unlikely(__pRectangleObject))
1341 evas_object_clip_set(__pRectangleObject, pParentClipper);
1344 if (unlikely(__pNativeSmartObject))
1346 evas_object_clip_set(__pNativeSmartObject, pParentClipper);
1354 if (unlikely(__needEvasObjectSync) || unlikely(__mapUsed != needMap) || unlikely(needMap) || unlikely(clipChanged))
1356 const bool needClipSmartMap = (__pClipObject && needMap);
1357 const bool needClipObjectMap = (!__pClipObject && needMap);
1359 evas_object_map_enable_set(__pSmartObject, needClipSmartMap);
1360 evas_object_map_set(__pSmartObject, (needClipSmartMap ? __pMap : null));
1362 if (unlikely(__pImageHolder))
1364 evas_object_map_enable_set(__pImageHolder, needClipObjectMap);
1365 evas_object_map_set(__pImageHolder, (needClipObjectMap ? __pMap : null));
1367 if (likely(pImageObjectNew))
1369 evas_object_map_enable_set(pImageObjectNew, EINA_FALSE);
1370 evas_object_map_set(pImageObjectNew, null);
1373 else if (likely(pImageObjectNew))
1375 evas_object_map_enable_set(pImageObjectNew, needClipObjectMap);
1376 evas_object_map_set(pImageObjectNew, (needClipObjectMap ? __pMap : null));
1379 if (unlikely(__pRectangleObject))
1381 evas_object_map_enable_set(__pRectangleObject, needClipObjectMap);
1382 evas_object_map_set(__pRectangleObject, (needClipObjectMap ? __pMap : null));
1385 if (unlikely(__pNativeSmartObject))
1387 evas_object_map_enable_set(__pNativeSmartObject, needClipObjectMap);
1388 evas_object_map_set(__pNativeSmartObject, (needClipObjectMap ? __pMap : null));
1390 __mapUsed = needMap;
1394 // Set-up Content Bounds
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))
1400 bool needDefaultFillSet = true;
1402 if (unlikely(element.__useContentBounds))
1404 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1405 const FloatRectangle& contentBounds = element.__contentBounds;
1406 Rectangle contentBoundsAdjusted;
1410 // content bounds(px) = content bounds(uniform) * surface size(px)
1412 // surface size(px) 1
1413 // mapped content size(px) = bounds size(px) * ------------------ = bounds size(px) * -----------------------
1414 // content size(px) content size(uniform)
1416 // mapped content size(px) : surface size(px) = mapped content pos(px) : content pos(px)
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)
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
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
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);
1439 if (likely(contentBoundsAdjusted.width > 0) && likely(contentBoundsAdjusted.height > 0))
1442 if (pSurfaceImpl && pSurfaceImpl->__isImageObject)
1444 evas_object_image_fill_set(
1446 contentBoundsAdjusted.x,
1447 contentBoundsAdjusted.y,
1448 contentBoundsAdjusted.width,
1449 contentBoundsAdjusted.height
1453 needDefaultFillSet = false;
1457 if (likely(needDefaultFillSet))
1459 if (pSurfaceImpl && pSurfaceImpl->__isImageObject)
1461 evas_object_image_fill_set(pImageObjectNew, 0, 0, newW, newH);
1467 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS);
1471 if ((invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY)) || unlikely(__needEvasObjectSync))
1473 float alpha = element.GetOpacityFromRoot();
1474 bool renderOperationChanged = false;
1476 if (unlikely(__renderOperation != element.__renderOperation))
1478 renderOperationChanged = true;
1479 __renderOperation = element.__renderOperation;
1483 // pImageObjectNew does exist.
1484 if (likely(pImageObjectNew))
1486 if (unlikely(renderOperationChanged))
1488 evas_object_render_op_set(pImageObjectNew, GetRenderOperation(element.__renderOperation));
1491 int premultipliedColor = static_cast< int >(255.0f * alpha); // white color
1492 evas_object_color_set(pImageObjectNew, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1496 // rectangle setting
1497 if (unlikely(__pRectangleObject))
1499 if (unlikely(renderOperationChanged))
1501 evas_object_render_op_set(__pRectangleObject, GetRenderOperation(element.__renderOperation));
1504 float alphaRect = alpha * __backgroundColor.Alpha() * 255.0f;
1506 evas_object_color_set(
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)
1515 // WARNING: CHECKME: TODO:
1516 // How can we native smart object
1518 // Native Smart Object does exist.
1519 if (unlikely(__pNativeSmartObject))
1522 if (unlikely(renderOperationChanged))
1524 evas_object_render_op_set(__pNativeSmartObject, GetRenderOperation(element.__renderOperation));
1527 if (unlikely(element.__renderOperation == VisualElement::RENDER_OPERATION_COPY))
1529 evas_object_color_set(__pNativeSmartObject, 0, 0, 0, 0); // for smart
1530 // evas_object_color_set(__pNativeSmartObject, 255, 255, 255, 255);// for image
1534 int premultipliedColor = static_cast< int >(255.0f * alpha); // white color
1535 evas_object_color_set(__pNativeSmartObject, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1540 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY);
1544 // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1545 if (likely(isVeVisible))
1547 if (unlikely(!isEvasVisible))
1549 evas_object_show(__pSmartObject); // Children of smart-object such as rectangle and clip-object may be invisible here.
1554 if (unlikely(isEvasVisible))
1556 evas_object_hide(__pSmartObject);
1562 // Only after setting all invalidated properties, need-sync flag can be cleared
1563 __needEvasObjectSync = false;
1570 VisualElementSurface*
1571 _EflNode::GetSurface(void) const
1577 }}} // Tizen::Ui::Animations