2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
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 _EflLayer* pLayer = dynamic_cast<_EflLayer*>(const_cast<_NativeLayer*>(&layer));
343 return E_INVALID_ARG;
346 return ReConstruct(pLayer->GetEvas());
350 _EflNode::ReConstruct(const Evas* pEvas)
354 return E_INVALID_ARG;
359 __pEvas = const_cast<Evas*>(pEvas);
362 if (!__pStaticSmartClass)
364 __pStaticSmartClass = evas_smart_class_new(&smartClassForVisualElement); // TODO: no need to delete ???
367 __pSmartObject = evas_object_smart_add(__pEvas, __pStaticSmartClass);
373 if (!__pStaticSmartClassForImageHolder)
375 __pStaticSmartClassForImageHolder = evas_smart_class_new(&smartClassForImageHolder); // TODO: no need to delete ???
378 //evas_object_pass_events_set(__pSmartObject, EINA_TRUE);
379 evas_object_propagate_events_set(__pSmartObject, EINA_TRUE);
380 //evas_object_propagate_events_set(__pSmartObject, EINA_FALSE);
382 if (__pNativeSmartObject)
384 evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject);
385 AdjustEvasObjectOrder();
388 evas_object_show(__pSmartObject);
390 // __pClipObject = evas_object_rectangle_add(pEvas);
391 // if (!__pClipObject)
395 // evas_object_smart_member_add(__pClipObject,__pSmartObject);
396 // evas_object_lower(__pClipObject);
398 // evas_object_pass_events_set(__pClipObject, EINA_TRUE);
403 evas_map_free(__pMap);
405 __pMap = evas_map_new(4);
411 evas_map_alpha_set(__pMap, EINA_TRUE);
412 evas_map_smooth_set(__pMap, EINA_TRUE);
421 evas_object_del(__pSmartObject);
424 __pSmartObject = null;
426 // if (__pClipObject)
427 // evas_object_del(__pClipObject);
429 // __pClipObject = null;
433 evas_map_free(__pMap);
442 _EflNode::Destruct(void)
447 evas_object_del(__pSmartObject);
448 __pSmartObject = null;
453 evas_object_del(__pClipObject);
454 __pClipObject = null;
457 if (__pRectangleObject)
459 evas_object_del(__pRectangleObject);
460 __pRectangleObject = null;
465 evas_map_free(__pMap);
475 if (__pSharedSurface)
477 delete __pSharedSurface;
478 __pSharedSurface = null;
483 evas_object_del(__pImageHolder);
486 if (unlikely(__pNativeSmartObject))
488 evas_object_smart_member_del(__pNativeSmartObject);
489 //__pNativeSmartObject = null;
496 _EflNode::GetEvas(void) const
502 _EflNode::GetGroupContainer(void) const
504 return reinterpret_cast< Handle >(__pSmartObject);
508 _EflNode::AdjustEvasObjectOrder(void)
511 if (__pNativeSmartObject)
512 evas_object_lower(__pNativeSmartObject);
513 // evas_object_raise(__pNativeSmartObject);
518 _EflNode::SetNativeObject(VisualElement& element, Evas_Object* pNativeObject)
520 if (unlikely(__pNativeSmartObject != pNativeObject))
522 if (unlikely(__pNativeSmartObject))
524 evas_object_smart_member_del(__pNativeSmartObject);
527 __pNativeSmartObject = pNativeObject;
529 if (__pNativeSmartObject)
531 evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject);
535 AdjustEvasObjectOrder();
538 const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
539 | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
540 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
541 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
543 _VisualElementImpl* pElementImpl = _VisualElementImpl::GetInstance(element);
544 if (likely(pElementImpl))
546 pElementImpl->InvalidateHierarchyProps(nativeProps, false, false);
551 _EflNode::AddNativeSmartObject(VisualElement& element, Evas_Object* pSmartObject)
553 SetNativeObject(element, pSmartObject);
557 _EflNode::RemoveNativeObject(void)
559 __pNativeSmartObject = null;
563 _EflNode::GetNativeObject(void) const
565 return __pNativeSmartObject;
569 _EflNode::InsertChild(_INativeNode& child, const _INativeNode* pReference, bool above)
571 _EflNode& nativeChild = dynamic_cast< _EflNode& >(child);
572 const _EflNode* pNativeReference = dynamic_cast< const _EflNode* >(pReference);
574 RemoveChild(nativeChild);
578 return E_INVALID_STATE;
581 evas_object_smart_member_add(nativeChild.__pSmartObject, __pSmartObject);
583 // The order of evas objects should be as follows:
584 // [native smart object] [image/image-holder/rectangle/clipper] [child smart object]*
586 if (likely(pNativeReference))
590 evas_object_stack_above(nativeChild.__pSmartObject, pNativeReference->__pSmartObject);
594 evas_object_stack_below(nativeChild.__pSmartObject, pNativeReference->__pSmartObject);
601 evas_object_raise(nativeChild.__pSmartObject);
605 Evas_Object* pRefObject = null;
608 if (likely(__pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSurface)))
610 pRefObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
612 else if (likely(__pRectangleObject))
614 pRefObject = __pRectangleObject;
616 else if (likely(__pImageHolder))
618 pRefObject = __pImageHolder;
621 if (likely(pRefObject))
623 evas_object_stack_above(nativeChild.__pSmartObject, pRefObject);
627 evas_object_lower(nativeChild.__pSmartObject);
632 AdjustEvasObjectOrder();
638 _EflNode::RemoveChild(_INativeNode& child)
640 _EflNode& nativeChild = dynamic_cast< _EflNode& >(child);
643 // Perform recursive hiding evas objects !
644 // After removing a child, it is not managed by visual element.
645 // Hence, because all descendants of it will not be hided automatically, it is needed to
646 // hide all descendants of it (or need adding damage region)
647 smartClassForVisualElement.hide = EvasSmartObjectHideAllChildren;
648 evas_object_hide(nativeChild.__pSmartObject);
649 smartClassForVisualElement.hide = EvasSmartObjectHideChildren;
651 evas_object_smart_member_del(nativeChild.__pSmartObject);
654 if (nativeChild.__pClipObject)
655 evas_object_hide((Evas_Object*)nativeChild.__pClipObject);
657 if (nativeChild.__pRectangleObject)
658 evas_object_hide((Evas_Object*)nativeChild.__pRectangleObject);
660 if (nativeChild.__pSurface && nativeChild.__pSurface->GetNativeHandle())
661 evas_object_hide((Evas_Object*)nativeChild.__pSurface->GetNativeHandle());
668 _EflNode::SetFlushNeeded(void)
671 evas_damage_rectangle_add(
673 static_cast< int >(floorf(dirtyRectangle.x)),
674 static_cast< int >(floorf(dirtyRectangle.y)),
675 static_cast< int >(ceilf(dirtyRectangle.width)),
676 static_cast< int >(ceilf(dirtyRectangle.height))
680 if (!__pSurface || !_VisualElementSurfaceImpl::GetInstance(*__pSurface))
682 return E_INVALID_STATE;
685 evas_object_image_pixels_dirty_set(reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle()), true);
688 Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
695 evas_object_image_data_set(pImageObject, evas_object_image_data_get(pImageObject, 1));
697 evas_object_image_size_get(pImageObject, &imageWidth, &imageHeight);
698 evas_object_image_data_update_add(pImageObject, 0, 0, imageWidth, imageHeight);
705 __pLayer->SetFlushNeeded();
709 //contentChanged = false;
710 bool contentChanged = false;
714 evas_object_image_pixels_dirty_set((Evas_Object*) _VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle(), true);
718 evas_object_image_data_update_add(
719 (Evas_Object*) _VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle(),
722 dirtyRectangle.width,
723 dirtyRectangle.height
727 evas_object_image_data_update_add(
728 (Evas_Object*) _VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle(),
731 dirtyRectangle.width,
732 dirtyRectangle.height
743 _EflNode::Flush(void)
745 #ifndef VE_VSYNC_UPDATE
750 // ecore_evas_manual_render(ecore_evas_ecore_evas_get(__pEvas));
757 _EflNode::GetBackgroundColor(void) const
759 // if (!__pRectangleObject)
760 // return _Colorf(); // CHECKME: Default background color ?
762 return __backgroundColor;
766 _EflNode::SetBackgroundColor(const _Colorf& backgroundColor)
768 // if (!__pRectangleObject)
769 // return E_INVALID_STATE;
771 __backgroundColor = backgroundColor;
777 _EflNode::AdjustImageHolder(bool useHolder)
779 if (unlikely(!__pSurface))
784 Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
785 if (unlikely(!pImageObject))
790 if (unlikely(useHolder))
792 if (likely(!__pImageHolder))
794 __pImageHolder = evas_object_smart_add(__pEvas, __pStaticSmartClassForImageHolder);
795 if (unlikely(!__pSmartObject))
797 SysLog(NID_UI_ANIM, "Smart object cannot be created.");
801 evas_object_propagate_events_set(__pImageHolder, EINA_TRUE);
802 evas_object_smart_member_add(pImageObject, __pImageHolder);
804 evas_object_smart_member_add(__pImageHolder, __pSmartObject);
805 evas_object_lower(__pImageHolder);
806 AdjustEvasObjectOrder();
808 if (evas_object_visible_get(__pSmartObject))
810 evas_object_show(__pImageHolder);
814 evas_object_hide(__pImageHolder);
822 if (likely(__pImageHolder))
824 evas_object_smart_member_add(pImageObject, __pSmartObject);
825 evas_object_lower(pImageObject);
826 AdjustEvasObjectOrder();
828 evas_object_del(__pImageHolder);
829 __pImageHolder = null;
839 _EflNode::Reconfigure(VisualElementSurface* pSurface, _VisualElementImpl& element, bool surfaceOnly)
841 Evas_Object* pImageObjectOrg = null;
842 Evas_Object* pImageObjectNew = null;
846 const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
847 | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
848 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
849 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
850 int& invalidatedNativeProps = element.__pSharedData->invalidatedNativeProps;
852 invalidatedNativeProps &= nativeProps;
854 if (likely(pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*pSurface)))
856 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle());
859 if (likely(__pSharedSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)))
861 pImageObjectOrg = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
865 if (likely(pImageObjectNew))
867 bool createNewObject = true;
869 evas_object_image_size_get(pImageObjectNew, &imageWidth, &imageHeight);
871 if (likely(__pSurface))
873 // if the surfaces are same, change the size
874 if (likely(pImageObjectNew == pImageObjectOrg))
876 createNewObject = false;
878 // if the surface is changed, delete old surface
881 delete __pSharedSurface;
882 __pSharedSurface = null;
886 // create new surface
887 if (unlikely(createNewObject))
890 unique_ptr<VisualElementSurface> pNewSharedSurface(new (std::nothrow) VisualElementSurface(*pSurface));
891 SysTryReturnResult(NID_UI_ANIM, pNewSharedSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
893 _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
894 if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer == null)
896 unique_ptr<VisualElementSurface> pNewSurface(new (std::nothrow) VisualElementSurface(*pSurface));
897 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
904 __pSurface = pNewSurface.release();
908 unique_ptr<VisualElementSurface> pNewSurface(_VisualElementSurfaceImpl::CreateSurfaceN((Handle)__pLayer, Dimension(1, 1)));
909 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
916 __pSurface = pNewSurface.release();
918 if (!element.GetModel()->__imageFilePath.IsEmpty() && _VisualElementSurfaceImpl::GetInstance(*__pSurface))
920 _VisualElementSurfaceImpl::GetInstance(*__pSurface)->SetImage(element.GetModel()->__imageFilePath);
924 if (__pSharedSurface)
926 delete __pSharedSurface;
927 __pSharedSurface = null;
929 __pSharedSurface = pNewSharedSurface.release();
931 Evas_Object* pImageObject = null;
932 if (_VisualElementSurfaceImpl::GetInstance(*__pSurface))
934 pImageObject = (Evas_Object*)_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle();
936 if (likely(pImageObject))
938 evas_object_anti_alias_set(pImageObject, EINA_TRUE);
940 evas_object_smart_member_add(pImageObject, __pSmartObject);
941 evas_object_lower(pImageObject);
942 AdjustEvasObjectOrder();
944 if (evas_object_visible_get(__pSmartObject))
946 evas_object_show(pImageObject);
950 evas_object_hide(pImageObject);
954 _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
955 if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer != null)
957 evas_object_image_source_set(pImageObject, pImageObjectNew);
960 //evas_object_pass_events_set(pImageObject, EINA_TRUE);
962 __needEvasObjectSync = true;
963 invalidatedNativeProps |= nativeProps;
967 // TODO : Have surface, but not newly created
972 // delete old surface
976 // delete shared surface
977 delete __pSharedSurface;
978 __pSharedSurface = null;
982 if (likely(__pSurface && _VisualElementSurfaceImpl::GetInstance(*__pSurface)))
984 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
986 if (unlikely(__pRectangleObject))
988 evas_object_del(__pRectangleObject);
989 __pRectangleObject = null;
994 pImageObjectNew = null;
997 // Newly created rectangle object must be reconfigured by VE!!! (size/pos/visibility/etc)
999 if (likely(!__pRectangleObject) && likely(element.__pSharedData->needSurface))
1001 __pRectangleObject = evas_object_rectangle_add(__pEvas);
1002 if (likely(__pRectangleObject))
1004 //evas_object_pass_events_set(__pRectangleObject, EINA_TRUE);
1005 evas_object_smart_member_add(__pRectangleObject, __pSmartObject);
1006 evas_object_lower(__pRectangleObject);
1007 AdjustEvasObjectOrder();
1009 if (evas_object_visible_get(__pSmartObject))
1011 evas_object_show(__pRectangleObject);
1015 evas_object_hide(__pRectangleObject);
1018 __needEvasObjectSync = true;
1019 invalidatedNativeProps |= nativeProps;
1024 element.__pSharedData->surfaceChanged = false;
1032 const bool isVeVisible = element.IsVisibleI();
1033 const bool isEvasVisible = evas_object_visible_get(__pSmartObject);
1036 // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1037 if (unlikely(!isVeVisible))
1041 evas_object_hide(__pSmartObject);
1044 invalidatedNativeProps = 0;
1053 // When visibility of VE is changed into 'visible' and evas object is invisible,
1054 // it is needed to set all evas object properties because not all properties were applied due to short-circuit optimization
1055 // (When VE is invisible, bounds and colors are not set for optimization)
1056 invalidatedNativeProps = nativeProps;
1060 // Change hierarchy properties such as bounds, clipping and map
1061 if (likely(invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS)) || unlikely(__needEvasObjectSync))
1063 bool needResize = false;
1064 bool needMove = false;
1065 bool clipChanged = false;
1066 bool needMap = false;
1068 Evas_Coord newX = 0;
1069 Evas_Coord newY = 0;
1070 Evas_Coord newW = 0;
1071 Evas_Coord newH = 0;
1073 __realBounds.width = element.__alignedSize.width;
1074 __realBounds.height = element.__alignedSize.height;
1076 //_VisualElementImpl::AdjustSizeForSurface(__realBounds.width, __realBounds.height);
1077 _VisualElementCoordinateSystem::ConvertDimensionToPhysical(__realBounds.width, __realBounds.height);
1080 // Do not use to MakeIntegralDimension. All information about coordinates(position/size) are calculated with same(point) way.
1081 _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.width, __realBounds.height, newW, newH);
1088 Evas_Object* pParentClipper = null;
1090 if (unlikely(element.__needTransform) || likely(element.__needClipForUntransformed))
1092 const _VisualElementImpl* pClipSource = element.GetClipSource();
1094 if (likely(pClipSource))
1096 _EflNode* pParentClipNode = static_cast< _EflNode* >(pClipSource->GetNativeNode());
1097 if (likely(pParentClipNode))
1099 clipX = pParentClipNode->__realBounds.x;
1100 clipY = pParentClipNode->__realBounds.y;
1101 clipW = pParentClipNode->__realBounds.width;
1102 clipH = pParentClipNode->__realBounds.height;
1104 pParentClipper = pParentClipNode->__pClipObject;
1110 // Coordinates(including __needTransform flag) are validated by getting clip-source above
1112 if (likely(!element.__needTransform))
1114 __realBounds.x = element.__boundingBoxToClipSource.x;
1115 __realBounds.y = element.__boundingBoxToClipSource.y;
1116 _VisualElementCoordinateSystem::ConvertPointToPhysical(__realBounds.x, __realBounds.y);
1118 __realBounds.x += clipX;
1119 __realBounds.y += clipY;
1120 _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.x, __realBounds.y, newX, newY);
1123 int evasOutputW, evasOutputH;
1124 evas_output_size_get(__pEvas, &evasOutputW, &evasOutputH);
1126 // if (newX >= 480 || newY >= 800 || newX + newW < 0 || newY + newH < 0)
1127 // if ((newX >= SCREEN_WIDTH || newY >= SCREEN_HEIGHT || newX + newW < 0 || newY + newH < 0) ||
1128 if ((newX >= evasOutputW || newY >= evasOutputH || newX + newW < 0 || newY + newH < 0) ||
1129 (likely(pParentClipper) && (newX >= clipX + clipW || newY >= clipY + clipH || newX + newW < clipX || newY + newH < clipY)))
1132 evas_object_hide(__pSmartObject);
1134 element.__pSharedData->invalidatedNativeProps = 0;
1141 if (likely(pParentClipper))
1143 if (likely(newX >= clipX) && likely(newY >= clipY) && likely(newX + newW <= clipX + clipW) && likely(newY + newH <= clipY + clipH))
1144 pParentClipper = null;
1155 const Tizen::Graphics::FloatMatrix4& xform = element.GetMatrixToClipSource();
1160 x[1] = element.__alignedSize.width;
1163 x[2] = element.__alignedSize.width;
1164 y[2] = element.__alignedSize.height;
1167 y[3] = element.__alignedSize.height;
1170 for (int i = 0; i < 4; i++)
1172 _MatrixUtilTransform(xform, &x[i], &y[i], &z[i]);
1173 _VisualElementCoordinateSystem::ConvertPointToPhysical(x[i], y[i]);
1180 // Use surface size for UV-mapping *ONLY FOR* direct-map-on-image-object, not map-on-smart-object !!!
1181 if (unlikely(!__pSharedSurface) || unlikely(element.__useContentBounds) || likely(__pClipObject))
1183 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1184 evas_map_point_image_uv_set(__pMap, 1, (double)newW, 0.0);
1185 evas_map_point_image_uv_set(__pMap, 2, (double)newW, (double)newH);
1186 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)newH);
1190 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1192 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1193 evas_map_point_image_uv_set(__pMap, 1, (double)surfaceSize.width, 0.0);
1194 evas_map_point_image_uv_set(__pMap, 2, (double)surfaceSize.width, (double)surfaceSize.height);
1195 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)surfaceSize.height);
1198 for (int i = 0; i < 4; i++)
1200 // WARNING: Do not need integral Z ??
1201 _VisualElementCoordinateSystem::MakeIntegralPoint(x[i], y[i], intX[i], intY[i]);
1202 evas_map_point_coord_set(__pMap, i, intX[i], intY[i], static_cast< int >(z[i]));
1206 __realBounds.x = x[0];
1207 __realBounds.y = y[0];
1214 // Adjust flag for bounds changing
1215 if (unlikely(__needEvasObjectSync))
1227 evas_object_geometry_get(__pSmartObject, &objX, &objY, &objW, &objH);
1229 if (likely(!needMove))
1231 needMove = (newX != objX || newY != objY);
1234 if (likely(!needResize))
1236 needResize = (newW != objW || newH != objH);
1241 if (unlikely(element.__isClipChildren))
1243 if (unlikely(!__pClipObject) && likely(element.__pSharedData->needSurface))
1245 __pClipObject = evas_object_rectangle_add(__pEvas);
1246 if (likely(__pClipObject))
1248 evas_object_smart_member_add(__pClipObject, __pSmartObject);
1249 evas_object_lower(__pClipObject);
1250 AdjustEvasObjectOrder();
1252 evas_object_pass_events_set(__pClipObject, EINA_TRUE);
1253 evas_object_static_clip_set(__pClipObject, 0); // CHECKME: What does this mean by ?
1255 if (evas_object_visible_get(__pSmartObject))
1257 evas_object_show(__pClipObject);
1261 evas_object_hide(__pClipObject);
1272 if (unlikely(__pClipObject))
1274 evas_object_del(__pClipObject);
1275 __pClipObject = null;
1282 // Update image-holder information before using it !
1283 // Image-Holder is needed only when using content-bounds and maps on image-object, not smart-object.
1284 if (unlikely(AdjustImageHolder(element.__useContentBounds && !__pClipObject && needMap)))
1289 __needEvasObjectSync = true;
1294 // In general, changing size/position before mapping/clipping *may* improve performance, because calculating map and clip
1295 // needs bounds information.
1298 if (likely(needMove))
1300 evas_object_move(__pSmartObject, newX, newY);
1302 if (likely(__pClipObject))
1304 evas_object_move(__pClipObject, newX, newY);
1307 if (likely(__pImageHolder))
1309 evas_object_move(__pImageHolder, newX, newY);
1312 if (likely(pImageObjectNew))
1314 evas_object_move(pImageObjectNew, newX, newY);
1317 if (unlikely(__pRectangleObject))
1319 evas_object_move(__pRectangleObject, newX, newY);
1322 if (unlikely(__pNativeSmartObject))
1324 evas_object_move(__pNativeSmartObject, newX, newY);
1329 if (unlikely(needResize))
1331 evas_object_resize(__pSmartObject, newW, newH);
1333 if (likely(__pClipObject))
1335 evas_object_resize(__pClipObject, newW, newH);
1338 if (likely(__pImageHolder))
1340 evas_object_resize(__pImageHolder, newW, newH);
1343 if (likely(pImageObjectNew))
1345 evas_object_resize(pImageObjectNew, newW, newH);
1348 if (unlikely(__pRectangleObject))
1350 evas_object_resize(__pRectangleObject, newW, newH);
1353 if (unlikely(__pNativeSmartObject))
1355 evas_object_resize(__pNativeSmartObject, newW, newH);
1362 if (unlikely(__needEvasObjectSync) || unlikely(clipChanged) || unlikely(evas_object_clip_get(__pSmartObject) != pParentClipper))
1364 evas_object_clip_set(__pSmartObject, pParentClipper);
1367 // Is it needed to set clipper for image-holder smart object ?
1369 if (likely(__pClipObject))
1371 evas_object_clip_set(__pClipObject, pParentClipper);
1373 if (unlikely(__pImageHolder))
1375 evas_object_clip_set(__pImageHolder, __pClipObject);
1378 if (likely(pImageObjectNew))
1380 evas_object_clip_set(pImageObjectNew, __pClipObject);
1383 if (unlikely(__pRectangleObject))
1385 evas_object_clip_set(__pRectangleObject, __pClipObject);
1388 if (unlikely(__pNativeSmartObject))
1390 evas_object_clip_set(__pNativeSmartObject, __pClipObject);
1395 if (unlikely(__pImageHolder))
1397 evas_object_clip_set(__pImageHolder, pParentClipper);
1400 if (likely(pImageObjectNew))
1402 evas_object_clip_set(pImageObjectNew, pParentClipper);
1405 if (unlikely(__pRectangleObject))
1407 evas_object_clip_set(__pRectangleObject, pParentClipper);
1410 if (unlikely(__pNativeSmartObject))
1412 evas_object_clip_set(__pNativeSmartObject, pParentClipper);
1420 if (unlikely(__needEvasObjectSync) || unlikely(__mapUsed != needMap) || unlikely(needMap) || unlikely(clipChanged))
1422 const bool needClipSmartMap = (__pClipObject && needMap);
1423 const bool needClipObjectMap = (!__pClipObject && needMap);
1425 evas_object_map_enable_set(__pSmartObject, needClipSmartMap);
1426 evas_object_map_set(__pSmartObject, (needClipSmartMap ? __pMap : null));
1428 if (unlikely(__pImageHolder))
1430 evas_object_map_enable_set(__pImageHolder, needClipObjectMap);
1431 evas_object_map_set(__pImageHolder, (needClipObjectMap ? __pMap : null));
1433 if (likely(pImageObjectNew))
1435 evas_object_map_enable_set(pImageObjectNew, EINA_FALSE);
1436 evas_object_map_set(pImageObjectNew, null);
1439 else if (likely(pImageObjectNew))
1441 evas_object_map_enable_set(pImageObjectNew, needClipObjectMap);
1442 evas_object_map_set(pImageObjectNew, (needClipObjectMap ? __pMap : null));
1445 if (unlikely(__pRectangleObject))
1447 evas_object_map_enable_set(__pRectangleObject, needClipObjectMap);
1448 evas_object_map_set(__pRectangleObject, (needClipObjectMap ? __pMap : null));
1451 if (unlikely(__pNativeSmartObject))
1453 evas_object_map_enable_set(__pNativeSmartObject, needClipObjectMap);
1454 evas_object_map_set(__pNativeSmartObject, (needClipObjectMap ? __pMap : null));
1456 __mapUsed = needMap;
1460 // Set-up Content Bounds
1462 // EFL Bug! - evas_object_fill_set should be invoked only *AFTER* adjusting maps !!!!!
1463 // If contents bounds are modifed before adjusting maps, it will not be applied !!!
1464 if (likely(pImageObjectNew) && likely(__pSharedSurface))
1466 bool needDefaultFillSet = true;
1468 if (unlikely(element.__useContentBounds))
1470 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1471 const FloatRectangle& contentBounds = element.__contentBounds;
1472 Rectangle contentBoundsAdjusted;
1476 // content bounds(px) = content bounds(uniform) * surface size(px)
1478 // surface size(px) 1
1479 // mapped content size(px) = bounds size(px) * ------------------ = bounds size(px) * -----------------------
1480 // content size(px) content size(uniform)
1482 // mapped content size(px) : surface size(px) = mapped content pos(px) : content pos(px)
1484 // mapped content size(px) content pos(uniform) * bounds size(px)
1485 // mapped content pos(px) = content pos(px) * ------------------------- = -----------------------------------------
1486 // surface size(px) content size(uniform)
1488 _VisualElementCoordinateSystem::MakeIntegralPoint(
1489 -contentBounds.x * static_cast< float >(newW) / contentBounds.width,
1490 -contentBounds.y * static_cast< float >(newH) / contentBounds.height,
1491 contentBoundsAdjusted.x,
1492 contentBoundsAdjusted.y
1494 _VisualElementCoordinateSystem::MakeIntegralPoint(
1495 static_cast< float >(newW) / contentBounds.width, // WARNING: No use of __realBounds. new[WH] is the real displaying value which is integral.
1496 static_cast< float >(newH) / contentBounds.height,
1497 contentBoundsAdjusted.width,
1498 contentBoundsAdjusted.height
1501 //NormalizeUniformRectangle(contentBoundsAdjusted, surfaceSize.width, surfaceSize.height);
1503 if (likely(contentBoundsAdjusted.width > 0) && likely(contentBoundsAdjusted.height > 0))
1505 evas_object_image_fill_set(
1507 contentBoundsAdjusted.x,
1508 contentBoundsAdjusted.y,
1509 contentBoundsAdjusted.width,
1510 contentBoundsAdjusted.height
1513 needDefaultFillSet = false;
1517 if (likely(needDefaultFillSet))
1519 evas_object_image_fill_set(pImageObjectNew, 0, 0, newW, newH);
1524 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS);
1528 if ((invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY)) || unlikely(__needEvasObjectSync))
1530 float alpha = element.GetOpacityFromRoot();
1531 bool renderOperationChanged = false;
1533 if (unlikely(__renderOperation != element.__renderOperation))
1535 renderOperationChanged = true;
1536 __renderOperation = element.__renderOperation;
1540 // pImageObjectNew does exist.
1541 if (likely(pImageObjectNew))
1543 if (unlikely(renderOperationChanged))
1545 evas_object_render_op_set(pImageObjectNew, GetRenderOperation(element.__renderOperation));
1548 // if (unlikely(__renderOperation == VisualElement::RENDER_OPERATION_COPY))
1550 // evas_object_color_set(pImageObjectNew, 255, 255, 255, 255);
1554 int premultipliedColor = static_cast< int >(255.0f * alpha); // white color
1555 evas_object_color_set(pImageObjectNew, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1560 // rectangle setting
1561 if (unlikely(__pRectangleObject))
1563 if (unlikely(renderOperationChanged))
1565 evas_object_render_op_set(__pRectangleObject, GetRenderOperation(element.__renderOperation));
1568 float alphaRect = alpha * __backgroundColor.Alpha() * 255.0f;
1570 evas_object_color_set(
1572 static_cast< int >(__backgroundColor.Red() * alphaRect),
1573 static_cast< int >(__backgroundColor.Green() * alphaRect),
1574 static_cast< int >(__backgroundColor.Blue() * alphaRect),
1575 static_cast< int >(alphaRect)
1579 // WARNING: CHECKME: TODO:
1580 // How can we native smart object
1582 // Native Smart Object does exist.
1583 if (unlikely(__pNativeSmartObject))
1586 if (unlikely(renderOperationChanged))
1588 evas_object_render_op_set(__pNativeSmartObject, GetRenderOperation(element.__renderOperation));
1591 if (unlikely(element.__renderOperation == VisualElement::RENDER_OPERATION_COPY))
1593 evas_object_color_set(__pNativeSmartObject, 0, 0, 0, 0); // for smart
1594 // evas_object_color_set(__pNativeSmartObject, 255, 255, 255, 255);// for image
1598 int premultipliedColor = static_cast< int >(255.0f * alpha); // white color
1599 evas_object_color_set(__pNativeSmartObject, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1604 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY);
1608 // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1609 if (likely(isVeVisible))
1611 if (unlikely(!isEvasVisible))
1613 evas_object_show(__pSmartObject); // Children of smart-object such as rectangle and clip-object may be invisible here.
1618 if (unlikely(isEvasVisible))
1620 evas_object_hide(__pSmartObject);
1626 // Only after setting all invalidated properties, need-sync flag can be cleared
1627 __needEvasObjectSync = false;
1634 VisualElementSurface*
1635 _EflNode::GetSurface(void) const
1641 }}} // Tizen::Ui::Animations