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 const char* pName = null;
696 evas_object_image_file_get(pImageObject, &pName, null);
699 evas_object_image_size_get(pImageObject, &imageWidth, &imageHeight);
700 evas_object_image_data_update_add(pImageObject, 0, 0, imageWidth, imageHeight);
707 __pLayer->SetFlushNeeded();
714 _EflNode::Flush(void)
716 #ifndef VE_VSYNC_UPDATE
721 // ecore_evas_manual_render(ecore_evas_ecore_evas_get(__pEvas));
728 _EflNode::GetBackgroundColor(void) const
730 return __backgroundColor;
734 _EflNode::SetBackgroundColor(const _Colorf& backgroundColor)
736 __backgroundColor = backgroundColor;
742 _EflNode::AdjustImageHolder(bool useHolder)
744 if (unlikely(!__pSurface))
749 Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
750 if (unlikely(!pImageObject))
755 if (unlikely(useHolder))
757 if (likely(!__pImageHolder))
759 __pImageHolder = evas_object_smart_add(__pEvas, __pStaticSmartClassForImageHolder);
760 if (unlikely(!__pSmartObject))
762 SysLog(NID_UI_ANIM, "Smart object cannot be created.");
766 evas_object_propagate_events_set(__pImageHolder, EINA_TRUE);
767 evas_object_smart_member_add(pImageObject, __pImageHolder);
769 evas_object_smart_member_add(__pImageHolder, __pSmartObject);
770 evas_object_lower(__pImageHolder);
771 AdjustEvasObjectOrder();
773 if (evas_object_visible_get(__pSmartObject))
775 evas_object_show(__pImageHolder);
779 evas_object_hide(__pImageHolder);
787 if (likely(__pImageHolder))
789 evas_object_smart_member_add(pImageObject, __pSmartObject);
790 evas_object_lower(pImageObject);
791 AdjustEvasObjectOrder();
793 evas_object_del(__pImageHolder);
794 __pImageHolder = null;
804 _EflNode::Reconfigure(VisualElementSurface* pSurface, _VisualElementImpl& element, bool surfaceOnly)
806 Evas_Object* pImageObjectOrg = null;
807 Evas_Object* pImageObjectNew = null;
809 const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
810 | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
811 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
812 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
813 int& invalidatedNativeProps = element.__pSharedData->invalidatedNativeProps;
815 invalidatedNativeProps &= nativeProps;
818 _EflVisualElementSurfaceImpl* pSurfaceImpl = null;
820 if (likely(pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*pSurface)))
822 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle());
823 pSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
826 if (likely(__pSharedSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)))
828 pImageObjectOrg = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle());
832 if (likely(pImageObjectNew))
834 bool createNewObject = true;
836 if (likely(__pSurface))
838 // if the surfaces are same, change the size
839 if (likely(pImageObjectNew == pImageObjectOrg))
841 createNewObject = false;
843 // if the surface is changed, delete old surface
846 delete __pSharedSurface;
847 __pSharedSurface = null;
851 // create new surface
852 if (unlikely(createNewObject))
854 unique_ptr<VisualElementSurface> pNewSharedSurface(new (std::nothrow) VisualElementSurface(*pSurface));
855 SysTryReturnResult(NID_UI_ANIM, pNewSharedSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
857 _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface));
858 if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer == null)
860 unique_ptr<VisualElementSurface> pNewSurface(new (std::nothrow) VisualElementSurface(*pSurface));
861 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
868 __pSurface = pNewSurface.release();
872 unique_ptr<VisualElementSurface> pNewSurface(_VisualElementSurfaceImpl::CreateSurfaceN((Handle)__pLayer, FloatDimension(1.0f, 1.0f)));
873 SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
880 __pSurface = pNewSurface.release();
882 if (!element.GetModel()->__imageFilePath.IsEmpty() && _VisualElementSurfaceImpl::GetInstance(*__pSurface))
884 _VisualElementSurfaceImpl::GetInstance(*__pSurface)->SetImage(element.GetModel()->__imageFilePath);
888 if (__pSharedSurface)
890 delete __pSharedSurface;
891 __pSharedSurface = null;
893 __pSharedSurface = pNewSharedSurface.release();
895 Evas_Object* pImageObject = null;
896 if (_VisualElementSurfaceImpl::GetInstance(*__pSurface))
898 pImageObject = (Evas_Object*)_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle();
900 if (likely(pImageObject))
902 evas_object_anti_alias_set(pImageObject, EINA_TRUE);
904 evas_object_smart_member_add(pImageObject, __pSmartObject);
905 evas_object_lower(pImageObject);
906 AdjustEvasObjectOrder();
908 if (evas_object_visible_get(__pSmartObject))
910 evas_object_show(pImageObject);
914 evas_object_hide(pImageObject);
917 if (pSurfaceImpl && pSurfaceImpl->__pBuffer != null)
919 evas_object_image_source_set(pImageObject, pImageObjectNew);
920 #if 0 // needed if evas_object_show() has not been called in ctor of _EflVisualElementSurfaceImpl
921 evas_object_show(pImageObjectNew);
922 evas_object_image_source_visible_set(pImageObject, EINA_FALSE);
926 //evas_object_pass_events_set(pImageObject, EINA_TRUE);
928 __needEvasObjectSync = true;
929 invalidatedNativeProps |= nativeProps;
933 // TODO : Have surface, but not newly created
938 // delete old surface
942 // delete shared surface
943 delete __pSharedSurface;
944 __pSharedSurface = null;
948 if (likely(__pSurface && _VisualElementSurfaceImpl::GetInstance(*__pSurface)))
950 pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle());
952 if (unlikely(__pRectangleObject))
954 evas_object_del(__pRectangleObject);
955 __pRectangleObject = null;
960 pImageObjectNew = null;
963 // Newly created rectangle object must be reconfigured by VE!!! (size/pos/visibility/etc)
965 if (likely(!__pRectangleObject) && likely(element.__pSharedData->needSurface))
967 __pRectangleObject = evas_object_rectangle_add(__pEvas);
968 if (likely(__pRectangleObject))
970 //evas_object_pass_events_set(__pRectangleObject, EINA_TRUE);
971 evas_object_smart_member_add(__pRectangleObject, __pSmartObject);
972 evas_object_lower(__pRectangleObject);
973 AdjustEvasObjectOrder();
975 if (evas_object_visible_get(__pSmartObject))
977 evas_object_show(__pRectangleObject);
981 evas_object_hide(__pRectangleObject);
984 __needEvasObjectSync = true;
985 invalidatedNativeProps |= nativeProps;
990 element.__pSharedData->surfaceChanged = false;
998 const bool isVeVisible = element.IsVisibleI();
999 const bool isEvasVisible = evas_object_visible_get(__pSmartObject);
1002 // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1003 if (unlikely(!isVeVisible))
1007 evas_object_hide(__pSmartObject);
1010 invalidatedNativeProps = 0;
1019 // When visibility of VE is changed into 'visible' and evas object is invisible,
1020 // it is needed to set all evas object properties because not all properties were applied due to short-circuit optimization
1021 // (When VE is invisible, bounds and colors are not set for optimization)
1022 invalidatedNativeProps = nativeProps;
1026 // Change hierarchy properties such as bounds, clipping and map
1027 if (likely(invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS)) || unlikely(__needEvasObjectSync))
1029 bool needResize = false;
1030 bool needMove = false;
1031 bool clipChanged = false;
1032 bool needMap = false;
1034 Evas_Coord newX = 0;
1035 Evas_Coord newY = 0;
1036 Evas_Coord newW = 0;
1037 Evas_Coord newH = 0;
1039 __realBounds.width = element.__alignedSize.width;
1040 __realBounds.height = element.__alignedSize.height;
1042 //_VisualElementImpl::AdjustSizeForSurface(__realBounds.width, __realBounds.height);
1043 _VisualElementCoordinateSystem::ConvertDimensionToPhysical(__realBounds.width, __realBounds.height);
1046 // Do not use to MakeIntegralDimension. All information about coordinates(position/size) are calculated with same(point) way.
1047 _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.width, __realBounds.height, newW, newH);
1053 Evas_Object* pParentClipper = null;
1055 if (unlikely(element.__needTransform) || likely(element.__needClipForUntransformed))
1057 const _VisualElementImpl* pClipSource = element.GetClipSource();
1059 if (likely(pClipSource))
1061 _EflNode* pParentClipNode = static_cast< _EflNode* >(pClipSource->GetNativeNode());
1062 if (likely(pParentClipNode))
1064 clipX = pParentClipNode->__realBounds.x;
1065 clipY = pParentClipNode->__realBounds.y;
1066 clipW = pParentClipNode->__realBounds.width;
1067 clipH = pParentClipNode->__realBounds.height;
1069 pParentClipper = pParentClipNode->__pClipObject;
1075 // Coordinates(including __needTransform flag) are validated by getting clip-source above
1077 if (likely(!element.__needTransform))
1079 __realBounds.x = element.__boundingBoxToClipSource.x;
1080 __realBounds.y = element.__boundingBoxToClipSource.y;
1081 _VisualElementCoordinateSystem::ConvertPointToPhysical(__realBounds.x, __realBounds.y);
1083 __realBounds.x += clipX;
1084 __realBounds.y += clipY;
1085 _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.x, __realBounds.y, newX, newY);
1094 const Tizen::Graphics::FloatMatrix4& xform = element.GetMatrixToClipSource();
1099 x[1] = element.__alignedSize.width;
1102 x[2] = element.__alignedSize.width;
1103 y[2] = element.__alignedSize.height;
1106 y[3] = element.__alignedSize.height;
1109 for (int i = 0; i < 4; i++)
1111 _MatrixUtilTransform(xform, &x[i], &y[i], &z[i]);
1112 _VisualElementCoordinateSystem::ConvertPointToPhysical(x[i], y[i]);
1119 // Use surface size for UV-mapping *ONLY FOR* direct-map-on-image-object, not map-on-smart-object !!!
1120 if (unlikely(!__pSharedSurface) || unlikely(element.__useContentBounds) || likely(__pClipObject))
1122 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1123 evas_map_point_image_uv_set(__pMap, 1, (double)newW, 0.0);
1124 evas_map_point_image_uv_set(__pMap, 2, (double)newW, (double)newH);
1125 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)newH);
1129 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1131 evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0);
1132 evas_map_point_image_uv_set(__pMap, 1, (double)surfaceSize.width, 0.0);
1133 evas_map_point_image_uv_set(__pMap, 2, (double)surfaceSize.width, (double)surfaceSize.height);
1134 evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)surfaceSize.height);
1137 for (int i = 0; i < 4; i++)
1139 // WARNING: Do not need integral Z ??
1140 _VisualElementCoordinateSystem::MakeIntegralPoint(x[i], y[i], intX[i], intY[i]);
1141 evas_map_point_coord_set(__pMap, i, intX[i], intY[i], static_cast< int >(z[i]));
1145 __realBounds.x = x[0];
1146 __realBounds.y = y[0];
1153 // Adjust flag for bounds changing
1154 if (unlikely(__needEvasObjectSync))
1166 evas_object_geometry_get(__pSmartObject, &objX, &objY, &objW, &objH);
1168 if (likely(!needMove))
1170 needMove = (newX != objX || newY != objY);
1173 if (likely(!needResize))
1175 needResize = (newW != objW || newH != objH);
1180 if (unlikely(element.__isClipChildren))
1182 if (unlikely(!__pClipObject) && likely(element.__pSharedData->needSurface))
1184 __pClipObject = evas_object_rectangle_add(__pEvas);
1185 if (likely(__pClipObject))
1187 evas_object_smart_member_add(__pClipObject, __pSmartObject);
1188 evas_object_lower(__pClipObject);
1189 AdjustEvasObjectOrder();
1191 evas_object_pass_events_set(__pClipObject, EINA_TRUE);
1192 evas_object_static_clip_set(__pClipObject, 0); // CHECKME: What does this mean by ?
1194 if (evas_object_visible_get(__pSmartObject))
1196 evas_object_show(__pClipObject);
1200 evas_object_hide(__pClipObject);
1211 if (unlikely(__pClipObject))
1213 evas_object_del(__pClipObject);
1214 __pClipObject = null;
1221 // Update image-holder information before using it !
1222 // Image-Holder is needed only when using content-bounds and maps on image-object, not smart-object.
1223 if (unlikely(AdjustImageHolder(element.__useContentBounds && !__pClipObject && needMap)))
1228 __needEvasObjectSync = true;
1233 // In general, changing size/position before mapping/clipping *may* improve performance, because calculating map and clip
1234 // needs bounds information.
1237 if (likely(needMove))
1239 evas_object_move(__pSmartObject, newX, newY);
1241 if (likely(__pClipObject))
1243 evas_object_move(__pClipObject, newX, newY);
1246 if (likely(__pImageHolder))
1248 evas_object_move(__pImageHolder, newX, newY);
1251 if (likely(pImageObjectNew))
1253 evas_object_move(pImageObjectNew, newX, newY);
1256 if (unlikely(__pRectangleObject))
1258 evas_object_move(__pRectangleObject, newX, newY);
1261 if (unlikely(__pNativeSmartObject))
1263 evas_object_move(__pNativeSmartObject, newX, newY);
1268 if (unlikely(needResize))
1270 evas_object_resize(__pSmartObject, newW, newH);
1272 if (likely(__pClipObject))
1274 evas_object_resize(__pClipObject, newW, newH);
1277 if (likely(__pImageHolder))
1279 evas_object_resize(__pImageHolder, newW, newH);
1282 if (likely(pImageObjectNew))
1284 evas_object_resize(pImageObjectNew, newW, newH);
1287 if (unlikely(__pRectangleObject))
1289 evas_object_resize(__pRectangleObject, newW, newH);
1292 if (unlikely(__pNativeSmartObject))
1294 evas_object_resize(__pNativeSmartObject, newW, newH);
1301 if (unlikely(__needEvasObjectSync) || unlikely(clipChanged) || unlikely(evas_object_clip_get(__pSmartObject) != pParentClipper))
1303 evas_object_clip_set(__pSmartObject, pParentClipper);
1306 // Is it needed to set clipper for image-holder smart object ?
1308 if (likely(__pClipObject))
1310 evas_object_clip_set(__pClipObject, pParentClipper);
1312 if (unlikely(__pImageHolder))
1314 evas_object_clip_set(__pImageHolder, __pClipObject);
1317 if (likely(pImageObjectNew))
1319 evas_object_clip_set(pImageObjectNew, __pClipObject);
1322 if (unlikely(__pRectangleObject))
1324 evas_object_clip_set(__pRectangleObject, __pClipObject);
1327 if (unlikely(__pNativeSmartObject))
1329 evas_object_clip_set(__pNativeSmartObject, __pClipObject);
1334 if (unlikely(__pImageHolder))
1336 evas_object_clip_set(__pImageHolder, pParentClipper);
1339 if (likely(pImageObjectNew))
1341 evas_object_clip_set(pImageObjectNew, pParentClipper);
1344 if (unlikely(__pRectangleObject))
1346 evas_object_clip_set(__pRectangleObject, pParentClipper);
1349 if (unlikely(__pNativeSmartObject))
1351 evas_object_clip_set(__pNativeSmartObject, pParentClipper);
1359 if (unlikely(__needEvasObjectSync) || unlikely(__mapUsed != needMap) || unlikely(needMap) || unlikely(clipChanged))
1361 const bool needClipSmartMap = (__pClipObject && needMap);
1362 const bool needClipObjectMap = (!__pClipObject && needMap);
1364 evas_object_map_enable_set(__pSmartObject, needClipSmartMap);
1365 evas_object_map_set(__pSmartObject, (needClipSmartMap ? __pMap : null));
1367 if (unlikely(__pImageHolder))
1369 evas_object_map_enable_set(__pImageHolder, needClipObjectMap);
1370 evas_object_map_set(__pImageHolder, (needClipObjectMap ? __pMap : null));
1372 if (likely(pImageObjectNew))
1374 evas_object_map_enable_set(pImageObjectNew, EINA_FALSE);
1375 evas_object_map_set(pImageObjectNew, null);
1378 else if (likely(pImageObjectNew))
1380 evas_object_map_enable_set(pImageObjectNew, needClipObjectMap);
1381 evas_object_map_set(pImageObjectNew, (needClipObjectMap ? __pMap : null));
1384 if (unlikely(__pRectangleObject))
1386 evas_object_map_enable_set(__pRectangleObject, needClipObjectMap);
1387 evas_object_map_set(__pRectangleObject, (needClipObjectMap ? __pMap : null));
1390 if (unlikely(__pNativeSmartObject))
1392 evas_object_map_enable_set(__pNativeSmartObject, needClipObjectMap);
1393 evas_object_map_set(__pNativeSmartObject, (needClipObjectMap ? __pMap : null));
1395 __mapUsed = needMap;
1399 // Set-up Content Bounds
1401 // EFL Bug! - evas_object_fill_set should be invoked only *AFTER* adjusting maps !!!!!
1402 // If contents bounds are modifed before adjusting maps, it will not be applied !!!
1403 if (likely(pImageObjectNew) && likely(__pSharedSurface))
1405 bool needDefaultFillSet = true;
1407 if (unlikely(element.__useContentBounds))
1409 const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize());
1410 const FloatRectangle& contentBounds = element.__contentBounds;
1411 Rectangle contentBoundsAdjusted;
1415 // content bounds(px) = content bounds(uniform) * surface size(px)
1417 // surface size(px) 1
1418 // mapped content size(px) = bounds size(px) * ------------------ = bounds size(px) * -----------------------
1419 // content size(px) content size(uniform)
1421 // mapped content size(px) : surface size(px) = mapped content pos(px) : content pos(px)
1423 // mapped content size(px) content pos(uniform) * bounds size(px)
1424 // mapped content pos(px) = content pos(px) * ------------------------- = -----------------------------------------
1425 // surface size(px) content size(uniform)
1427 _VisualElementCoordinateSystem::MakeIntegralPoint(
1428 -contentBounds.x * static_cast< float >(newW) / contentBounds.width,
1429 -contentBounds.y * static_cast< float >(newH) / contentBounds.height,
1430 contentBoundsAdjusted.x,
1431 contentBoundsAdjusted.y
1433 _VisualElementCoordinateSystem::MakeIntegralPoint(
1434 static_cast< float >(newW) / contentBounds.width, // WARNING: No use of __realBounds. new[WH] is the real displaying value which is integral.
1435 static_cast< float >(newH) / contentBounds.height,
1436 contentBoundsAdjusted.width,
1437 contentBoundsAdjusted.height
1440 // Added to resolve the problem that the left edge part is shown repeatedly to the right edge.
1441 contentBoundsAdjusted.width += ceil(static_cast< float >(newW) / contentBounds.width - contentBoundsAdjusted.width);
1442 contentBoundsAdjusted.height += ceil(static_cast< float >(newH) / contentBounds.height - contentBoundsAdjusted.height);
1444 if (likely(contentBoundsAdjusted.width > 0) && likely(contentBoundsAdjusted.height > 0))
1447 if (pSurfaceImpl && pSurfaceImpl->__isImageObject)
1449 evas_object_image_fill_set(
1451 contentBoundsAdjusted.x,
1452 contentBoundsAdjusted.y,
1453 contentBoundsAdjusted.width,
1454 contentBoundsAdjusted.height
1458 needDefaultFillSet = false;
1462 if (likely(needDefaultFillSet))
1464 if (pSurfaceImpl && pSurfaceImpl->__isImageObject)
1466 evas_object_image_fill_set(pImageObjectNew, 0, 0, newW, newH);
1472 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS);
1476 if ((invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY)) || unlikely(__needEvasObjectSync))
1478 float alpha = element.GetOpacityFromRoot();
1479 bool renderOperationChanged = false;
1481 if (unlikely(__renderOperation != element.__renderOperation))
1483 renderOperationChanged = true;
1484 __renderOperation = element.__renderOperation;
1488 // pImageObjectNew does exist.
1489 if (likely(pImageObjectNew))
1491 if (unlikely(renderOperationChanged))
1493 evas_object_render_op_set(pImageObjectNew, GetRenderOperation(element.__renderOperation));
1496 int premultipliedColor = static_cast< int >(255.0f * alpha); // white color
1497 evas_object_color_set(pImageObjectNew, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1501 // rectangle setting
1502 if (unlikely(__pRectangleObject))
1504 if (unlikely(renderOperationChanged))
1506 evas_object_render_op_set(__pRectangleObject, GetRenderOperation(element.__renderOperation));
1509 float alphaRect = alpha * __backgroundColor.Alpha() * 255.0f;
1511 evas_object_color_set(
1513 static_cast< int >(__backgroundColor.Red() * alphaRect),
1514 static_cast< int >(__backgroundColor.Green() * alphaRect),
1515 static_cast< int >(__backgroundColor.Blue() * alphaRect),
1516 static_cast< int >(alphaRect)
1520 // WARNING: CHECKME: TODO:
1521 // How can we native smart object
1523 // Native Smart Object does exist.
1524 if (unlikely(__pNativeSmartObject))
1527 if (unlikely(renderOperationChanged))
1529 evas_object_render_op_set(__pNativeSmartObject, GetRenderOperation(element.__renderOperation));
1532 if (unlikely(element.__renderOperation == VisualElement::RENDER_OPERATION_COPY))
1534 evas_object_color_set(__pNativeSmartObject, 0, 0, 0, 0); // for smart
1535 // evas_object_color_set(__pNativeSmartObject, 255, 255, 255, 255);// for image
1539 int premultipliedColor = static_cast< int >(255.0f * alpha); // white color
1540 evas_object_color_set(__pNativeSmartObject, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor);
1545 invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY);
1549 // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object
1550 if (likely(isVeVisible))
1552 if (unlikely(!isEvasVisible))
1554 evas_object_show(__pSmartObject); // Children of smart-object such as rectangle and clip-object may be invisible here.
1559 if (unlikely(isEvasVisible))
1561 evas_object_hide(__pSmartObject);
1567 // Only after setting all invalidated properties, need-sync flag can be cleared
1568 __needEvasObjectSync = false;
1575 VisualElementSurface*
1576 _EflNode::GetSurface(void) const
1582 }}} // Tizen::Ui::Animations