From c654062328d4fab86ac7cca47808e40d475e3430 Mon Sep 17 00:00:00 2001 From: Dae Young Ryu Date: Mon, 25 Nov 2013 22:40:00 +0900 Subject: [PATCH] changed RootVisualElement Managing logic Change-Id: Ib7e996fc43cb74524f788cb1d81a05d3899fe0a4 Signed-off-by: Dae Young Ryu --- inc/FUiAnimSceneVisualElement.h | 8 + src/ui/CMakeLists.txt | 1 + src/ui/FUi_Window.cpp | 22 +- src/ui/animations/FUiAnimSceneVisualElement.cpp | 29 +- src/ui/animations/FUiAnim_NativeLayer.cpp | 361 ++++++++++++++------- src/ui/animations/FUiAnim_RootVisualElement.cpp | 114 ++++++- .../animations/FUiAnim_SceneVisualElementImpl.cpp | 50 +++ src/ui/animations/FUiAnim_SceneVisualElementImpl.h | 59 ++++ src/ui/animations/FUiAnim_TransactionNode.cpp | 21 +- src/ui/animations/FUiAnim_View.cpp | 4 + src/ui/animations/FUiAnim_VisualElementImpl.cpp | 49 ++- src/ui/inc/FUiAnim_NativeLayer.h | 19 +- src/ui/inc/FUiAnim_RootVisualElement.h | 16 +- src/ui/inc/FUiAnim_VisualElementImpl.h | 2 +- src/ui/inc/FUi_Window.h | 1 - 15 files changed, 575 insertions(+), 181 deletions(-) create mode 100644 src/ui/animations/FUiAnim_SceneVisualElementImpl.cpp create mode 100644 src/ui/animations/FUiAnim_SceneVisualElementImpl.h diff --git a/inc/FUiAnimSceneVisualElement.h b/inc/FUiAnimSceneVisualElement.h index adb0b41..ed0e26d 100644 --- a/inc/FUiAnimSceneVisualElement.h +++ b/inc/FUiAnimSceneVisualElement.h @@ -66,6 +66,13 @@ public: */ SceneVisualElement(void); + /** + * This is the destroy method for the instance. + * + * @since 3.0 + */ + result Destroy(void); + public: /** @@ -375,6 +382,7 @@ private: protected: class _SceneVisualElementImpl* _pSceneVisualElementImpl; + friend class _SceneVisualElementImpl; }; // VisualElement diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index b783c69..23c8ecc 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -77,6 +77,7 @@ SET (${this_target}_SOURCE_FILES animations/FUiAnim_NativeLayer.cpp animations/FUiAnim_RootVisualElement.cpp animations/FUiAnimSceneVisualElement.cpp + animations/FUiAnim_SceneVisualElementImpl.cpp animations/FUiAnim_AnimationManager.cpp animations/FUiAnim_TransactionNode.cpp animations/FUiAnim_AnimationGroupNode.cpp diff --git a/src/ui/FUi_Window.cpp b/src/ui/FUi_Window.cpp index e98b7e8..2803ef7 100644 --- a/src/ui/FUi_Window.cpp +++ b/src/ui/FUi_Window.cpp @@ -91,12 +91,6 @@ _Window::~_Window(void) Close(); SetOwner(null); - if (__pDisplayContext) - { - _DisplayContextImpl::DestroyPublicInstance(*__pDisplayContext); - __pDisplayContext = null; - } - if(__pLayer) { @@ -139,8 +133,8 @@ _Window::GetDescription(void) const String description = _Control::GetDescription(); String descriptionTemp(L""); - descriptionTemp.Format(LOG_LEN_MAX, L"_Window: xid(0x%x) owner(0x%x) delegate(0x%x) activated(%d) destroying(%d) displayContext(0x%x)", - GetNativeHandle(), __pOwner, __pWindowDelegate, __activated, __destroying, __pDisplayContext); + descriptionTemp.Format(LOG_LEN_MAX, L"_Window: xid(0x%x) owner(0x%x) delegate(0x%x) activated(%d) destroying(%d)", + GetNativeHandle(), __pOwner, __pWindowDelegate, __activated, __destroying); description.Append(descriptionTemp); @@ -858,17 +852,10 @@ _Window::SetWindowState(WindowState windowState) DisplayContext* _Window::GetDisplayContext(void) const { - if (!__pDisplayContext) - { - SysTryReturn(NID_UI, __pLayer, null, E_SYSTEM, "[E_SYSTEM] Cannot gain the DisplayContext. This window is not completed."); - __pDisplayContext = _DisplayContextImpl::CreatePublicInstance(*__pLayer); - } - - result r = GetLastResult(); - SysTryReturn(NID_UI, __pDisplayContext, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_UI, __pLayer, null, E_SYSTEM, "[E_SYSTEM] Cannot gain the DisplayContext. This window is not completed."); - return __pDisplayContext; + return __pLayer->GetDisplayContext(); } result @@ -917,7 +904,6 @@ _Window::_Window() , __pRootVisualElement(null) , __pLayer(null) , __pDimmingLayer(null) - , __pDisplayContext(null) , __systemWindow(false) , __isOpened(false) , __isInitialized(false) diff --git a/src/ui/animations/FUiAnimSceneVisualElement.cpp b/src/ui/animations/FUiAnimSceneVisualElement.cpp index 86cf15c..a36f36c 100644 --- a/src/ui/animations/FUiAnimSceneVisualElement.cpp +++ b/src/ui/animations/FUiAnimSceneVisualElement.cpp @@ -28,10 +28,14 @@ #include #include #include + #include "FUiAnim_TransformMatrix3Df.h" #include "FUiAnim_View.h" -#include "FUiAnim_RootVisualElement.h" +#include +#include "FUiAnim_DisplayContextImpl.h" +#include "FUiAnim_NativeLayer.h" +#include "FUiAnim_SceneVisualElementImpl.h" #include #define CHECK_CONSTRUCTED \ @@ -42,16 +46,9 @@ using namespace Tizen::Base; using namespace Tizen::Graphics; - - namespace Tizen { namespace Ui { namespace Animations { -class _SceneVisualElementImpl : public _RootVisualElement -{ - -}; - SceneVisualElement::SceneVisualElement(void) :_pSceneVisualElementImpl(null) { @@ -60,11 +57,19 @@ SceneVisualElement::SceneVisualElement(void) SceneVisualElement::~SceneVisualElement(void) { - delete _pSceneVisualElementImpl; + _pSceneVisualElementImpl->Destroy(); _pSceneVisualElementImpl = null; } result +SceneVisualElement::Destroy(void) +{ + delete this; + + return E_SUCCESS; +} + +result SceneVisualElement::Construct(VisualElement& parent) { CHECK_NOT_CONSTRUCTED; @@ -95,6 +100,12 @@ SceneVisualElement::Construct(DisplayContext& display) _pSceneVisualElementImpl = new (std::nothrow) _SceneVisualElementImpl; _pSceneVisualElementImpl->Construct(); + + _DisplayContextImpl* pDisplay = _DisplayContextImpl::GetInstance(display); + _NativeLayer* pLayer = pDisplay->GetNativeLayer(); + + pLayer->AttachScene(this); + return E_SUCCESS; } diff --git a/src/ui/animations/FUiAnim_NativeLayer.cpp b/src/ui/animations/FUiAnim_NativeLayer.cpp index b5744bd..41be306 100644 --- a/src/ui/animations/FUiAnim_NativeLayer.cpp +++ b/src/ui/animations/FUiAnim_NativeLayer.cpp @@ -28,11 +28,15 @@ #include "FUiAnim_Mutex.h" #include "FUiAnim_VisualElementEnvironment.h" -#include "FUiAnim_RootVisualElement.h" + +#include "FUiAnim_SceneVisualElementImpl.h" +#include #include "FUiAnim_NativeWindow.h" #include "FUiAnim_NativeLayer.h" #include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_DisplayContextImpl.h" +#include "FUiAnimDisplayContext.h" #if defined(VE_EFL) #include "FUiAnim_EflLayer.h" #elif defined(VE_X_GL) || defined(VE_WIN32_GL) @@ -55,30 +59,58 @@ _NativeLayer::_NativeLayer(void) , _isRunningOnRenderThread(false) , _showState(false) , _bounds(0.0f, 0.0f, 0.0f, 0.0f) + , _pDisplayContext(null) , __needFlush(false) - , __needUpdateRenderObjects(false) - , __didSyncPresentation(false) +// , __needUpdateRenderObjects(false) +// , __didSyncPresentation(false) { static unsigned long idCount = 0; __id = idCount++; PRINT("_NativeLayer:_NativeLayer() \n"); + _roots.Construct(); } _NativeLayer::~_NativeLayer(void) { PRINT("_NativeLayer:~_NativeLayer() \n"); - if(_pRootVisualElement) + + int count = _roots.GetCount(); + if (count > 0) { _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); - if(pDisplayManager) + if (pDisplayManager) { pDisplayManager->UnregisterLayer(*this); } - _pRootVisualElement->SetNativeLayer(null); - _pRootVisualElement->Destroy(); - _pRootVisualElement = null; + + for(int i = 0; i< count; i++) + { + SceneVisualElement* pScene = null; + + if (_roots.GetAt(i, pScene) == E_SUCCESS) + { + if (pScene) + { + _SceneVisualElementImpl* pRoot = _SceneVisualElementImpl::GetInstance(*pScene); + if (pRoot) + pRoot->SetNativeLayer(null); + } + } + } + + if (_pRootVisualElement) + { + _pRootVisualElement->Destroy(); + _pRootVisualElement = null; + } + + } + if (_pDisplayContext) + { + _DisplayContextImpl::DestroyPublicInstance(*_pDisplayContext); + _pDisplayContext = null; } - if(_isWindowOwner) + if (_isWindowOwner) { _NativeWindow::DestroyNativeWindow(_pWindow); _pWindow = null; @@ -125,27 +157,32 @@ _NativeLayer::Construct(_NativeWindow* pNativeWindow) result r = E_SUCCESS; - if(pNativeWindow) + if (pNativeWindow) { _pWindow = pNativeWindow; } SysAssertf(_pRootVisualElement == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); - _pRootVisualElement = new _RootVisualElement(); - if (_pRootVisualElement != null) + _pRootVisualElement = new SceneVisualElement(); + + if (_pRootVisualElement) { + DisplayContext* pDisplayContext = GetDisplayContext(); FloatRectangle bounds = _pWindow->GetBounds(); - r = _pRootVisualElement->Construct(); + r = _pRootVisualElement->Construct(*pDisplayContext); SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Propagating."); - _pRootVisualElement->SetImplicitAnimationEnabled(false); + _SceneVisualElementImpl* pRoot = _SceneVisualElementImpl::GetInstance(*_pRootVisualElement); + + pRoot->SetImplicitAnimationEnabled(false); - _pRootVisualElement->MakeOrthogonalProjeciton(0.0f, bounds.width, 0.0f, bounds.height, -bounds.height, bounds.height); + pRoot->MakeOrthogonalProjeciton(0.0f, bounds.width, 0.0f, bounds.height, -bounds.height, bounds.height); - _pRootVisualElement->SetName(L"Root"); - _pRootVisualElement->SetShowState(true); + pRoot->SetName(L"Root"); + pRoot->SetShowState(true); +// AttachScene(_pRootVisualElement); } _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); @@ -153,12 +190,7 @@ _NativeLayer::Construct(_NativeWindow* pNativeWindow) r = OnConstructed(); SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Constructing failed."); - _pRootVisualElement->SetNativeLayer(this); - - r = Configure(*_pRootVisualElement); - SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Configuring failed."); - - if(pDisplayManager) + if (pDisplayManager) { pDisplayManager->RegisterLayer(*this); } @@ -166,21 +198,144 @@ _NativeLayer::Construct(_NativeWindow* pNativeWindow) return E_SUCCESS; } +DisplayContext* +_NativeLayer::GetDisplayContext(void) const +{ + if (_pDisplayContext) + { + return _pDisplayContext; + } + + _NativeLayer* pThis = const_cast<_NativeLayer*>(this); + pThis->_pDisplayContext = _DisplayContextImpl::CreatePublicInstance(*this); + + return _pDisplayContext; +} + _RootVisualElement* _NativeLayer::GetRootVisualElement(void) const { + if (!_pRootVisualElement) + { + return null; + } + + return _SceneVisualElementImpl::GetInstance(*_pRootVisualElement); +} + +SceneVisualElement* +_NativeLayer::GetScene(int sceneIndex) const +{ return _pRootVisualElement; } +result +_NativeLayer::AttachScene(SceneVisualElement* pScene) +{ + if (!pScene) + { + return E_INVALID_ARG; + } + + _SceneVisualElementImpl* pRoot = _SceneVisualElementImpl::GetInstance(*pScene); + + SysTryReturnResult(NID_UI_ANIM, !pRoot->GetNativeLayer(), E_INVALID_ARG, "[E_INVALID_ARG] pScene[0x%x] is already attached to NativeLayer", pScene); + + _roots.Add(pScene); + pRoot->SetNativeLayer(this); + + + result r = Configure(*_SceneVisualElementImpl::GetInstance(*_pRootVisualElement)); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Configuring failed."); + + return E_SUCCESS; +} + +result +_NativeLayer::DetachScene(SceneVisualElement* pScene) +{ + if (!pScene) + { + return E_INVALID_ARG; + } + _roots.Remove(pScene); + //_RootVisualElement* pRoot = _RootVisualElement::GetInstance(*pScene); + //pRoot->SetNativeLayer(this); + + return E_SUCCESS; +} + +result +_NativeLayer::ChangeSceneOrder(SceneVisualElement* pScene, const SceneVisualElement* pReference, bool above) +{ + + bool isAdded = false; + + // search pScene; + if (_roots.Remove(pScene) == E_OBJ_NOT_FOUND) + { + isAdded = true; + } + + if (pReference == null) + { + if (!above) + { + _roots.InsertAt(pScene, 0); + } + else + { + _roots.Add(pScene); + } + } + else + { + int count = _roots.GetCount(); + int refIndex = -1; + + for ( int i = 0 ; i < count ; i++ ) + { + SceneVisualElement* pTemp = null; + _roots.GetAt(i, pTemp); + if ( pTemp && pReference == pTemp ) + { + if (above) + { + _roots.InsertAt(pScene, i+1); + } + else + { + _roots.InsertAt(pScene, i); + } + break; + } + } + if (refIndex == -1) + { + return E_INVALID_ARG; + } + } + if ( isAdded) + { + _SceneVisualElementImpl* pRoot = _SceneVisualElementImpl::GetInstance(*pScene); + pRoot->SetNativeLayer(this); + } + return E_SUCCESS; + +} + + + bool _NativeLayer::IsRenderNeeded(void) const { - if(!_pRootVisualElement ) + if (!_pRootVisualElement ) { return false; } - _VisualElementImpl* pRootModelImpl = _VisualElementImpl::GetInstance(*_pRootVisualElement); + _SceneVisualElementImpl* pSceneImpl = _SceneVisualElementImpl::GetInstance(*_pRootVisualElement); + _VisualElementImpl* pRootModelImpl = _VisualElementImpl::GetInstance(*pSceneImpl); if (unlikely(!pRootModelImpl)) { @@ -188,12 +343,12 @@ _NativeLayer::IsRenderNeeded(void) const } - if (unlikely(_pRootVisualElement->GetNeedsContentUpdate())) + if (unlikely(pSceneImpl->GetNeedsContentUpdate())) { return true; } - if(likely((pRootModelImpl->__childrenNeedsUpdateProps & ~_VisualElementImpl::UPDATED_PROP_CONTENT) != 0) ) + if (likely((pRootModelImpl->__childrenNeedsUpdateProps & ~_VisualElementImpl::UPDATED_PROP_CONTENT) != 0) ) { return true; } @@ -204,62 +359,41 @@ _NativeLayer::IsRenderNeeded(void) const bool _NativeLayer::Render(void) { - - if(!_pRootVisualElement) - { - return false; - } - - _VisualElementImpl* pRootModelImpl = _VisualElementImpl::GetInstance(*_pRootVisualElement); + int count = _roots.GetCount(); bool updated = false; - if (likely(pRootModelImpl)) + for(int i =0; iGetNeedsContentUpdate())) + SceneVisualElement* pScene = null; + _roots.GetAt(i,pScene); + if(pScene) { - _pRootVisualElement->SetNeedsContentUpdate(false); - _pRootVisualElement->Draw(); - __needUpdateRenderObjects = true; - - updated = true; + _SceneVisualElementImpl* pSceneImpl = _SceneVisualElementImpl::GetInstance(*pScene); + updated |= pSceneImpl->DrawModelTree(); } - - if(likely((pRootModelImpl->__childrenNeedsUpdateProps & ~_VisualElementImpl::UPDATED_PROP_CONTENT) != 0) ) - { - pRootModelImpl->UpdateHierarchyProps(); - __needUpdateRenderObjects = true; - updated = true; - } - -#if 0 // TEXTURE UPLOAD - if(_pRootVisualElement->GetNeedsSurfaceUpdate()) - { - if (!checkOnly) - { - _pRootVisualElement->SetNeedsSurfaceUpdate(false); - _GlRenderManager::GetInstance()->UpdateTexture(); - } - updated = true; - } -#endif } + +// if(updated) +// { +// __needUpdateRenderObjects = true; +// } return updated; } - result _NativeLayer::SetBounds(const FloatRectangle& bounds) { result r = E_SUCCESS; _bounds = bounds; - if(_pWindow && _isWindowOwner) + if (_pWindow && _isWindowOwner) { r = _pWindow->SetBounds(bounds); // TODO: keep projection type and value. ??? - if(_pRootVisualElement) + if (_pRootVisualElement) { - _pRootVisualElement->MakeOrthogonalProjeciton(0.0f, bounds.width, 0.0f, bounds.height, -bounds.height, bounds.height); + _SceneVisualElementImpl* pSceneImpl = _SceneVisualElementImpl::GetInstance(*_pRootVisualElement); + pSceneImpl->MakeOrthogonalProjeciton(0.0f, bounds.width, 0.0f, bounds.height, -bounds.height, bounds.height); } } @@ -276,7 +410,7 @@ result _NativeLayer::SetShowState(bool show) { _showState = true; - if(_pWindow && _isWindowOwner) + if (_pWindow && _isWindowOwner) { return _pWindow->SetShowState(show); } @@ -292,79 +426,70 @@ _NativeLayer::GetShowState(void) const bool _NativeLayer::UpdateRenderObjects(void) { - if(!_pRootVisualElement) - { - return false; - } + int count = _roots.GetCount(); + + bool updated = false; - if(!__needUpdateRenderObjects) + for(int i =0; iUpdateRenderObjectTree(); + } } - _VisualElementImpl* pRootModelImpl = _VisualElementImpl::GetInstance(*_pRootVisualElement); - - pRootModelImpl->UpdateRender(); // FLUSH with compose??? - - __needUpdateRenderObjects = false; - return true; + return updated; } bool _NativeLayer::UpdateNativeNodes(void) { - if(!_pRootVisualElement) - { - return false; - } - - _VisualElementImpl* pRootModelImpl = _VisualElementImpl::GetInstance(*_pRootVisualElement); - _VisualElementImpl* pRenderRootImpl = pRootModelImpl->__pRenderObject; - - if(!pRenderRootImpl) - { - return false; - } + int count = _roots.GetCount(); + bool updated = false; - if (likely((pRenderRootImpl->__childrenNeedsUpdateProps & ~_VisualElementImpl::UPDATED_PROP_CONTENT) != 0) - || likely(pRenderRootImpl->__pSharedData->NeedNativeReconfigure()) - ) + for(int i =0; iUpdateHierarchyProps(); - __didSyncPresentation = false; - return true; + SceneVisualElement* pScene = null; + _roots.GetAt(i,pScene); + if(pScene) + { + _SceneVisualElementImpl* pSceneImpl = _SceneVisualElementImpl::GetInstance(*pScene); + updated |= pSceneImpl->UpdateNativeNode(); + } } - return false; + + return updated; } + bool _NativeLayer::UpdatePresentation(void) { - if(!_pRootVisualElement) - { - return false; - } - - if(__didSyncPresentation) - { - return true; - } - - _AutoMutex treeLock(*_VisualElementEnvironment::GetTreeLock()); - - _VisualElementImpl* pRootModelImpl = _VisualElementImpl::GetInstance(*_pRootVisualElement); - _VisualElementImpl* pRootPresentationImpl = pRootModelImpl->__pPresentation; - _VisualElementImpl* pRenderRootImpl = pRootModelImpl->__pRenderObject; - - if ( pRootPresentationImpl && pRenderRootImpl ) - { - pRootPresentationImpl->Sync(*pRenderRootImpl); - __didSyncPresentation = true; - } - return true; + int count = _roots.GetCount(); + + bool updated = false; + + _AutoMutex treeLock(*_VisualElementEnvironment::GetTreeLock()); + + for(int i =0; iSyncPresentationTree(); + } + } + + return updated; } + unsigned long _NativeLayer::GetWindowHandle(void) const { diff --git a/src/ui/animations/FUiAnim_RootVisualElement.cpp b/src/ui/animations/FUiAnim_RootVisualElement.cpp index cd84e9e..7e34846 100644 --- a/src/ui/animations/FUiAnim_RootVisualElement.cpp +++ b/src/ui/animations/FUiAnim_RootVisualElement.cpp @@ -32,6 +32,7 @@ #include "FUiAnim_Mutex.h" #include "FUiAnim_VisualElementEnvironment.h" #include "FUiAnim_View.h" +#include #include "FUiAnim_RootVisualElement.h" #include "FUiAnim_NativeLayer.h" #include "FUiAnim_VisualElementImpl.h" @@ -45,6 +46,8 @@ namespace Tizen { namespace Ui { namespace Animations _RootVisualElement::_RootVisualElement(void) : __needsUpdateFromRoot(false) , __needsSurfaceUpdate(false) + , __haveUpdatesForRender(false) + , __isSyncedPresentation(false) , __isModel(true) , __pLayer(null) { @@ -57,6 +60,8 @@ _RootVisualElement::_RootVisualElement(void) _RootVisualElement::_RootVisualElement(const _RootVisualElement& rhs) : _VisualElement(rhs) , __needsUpdateFromRoot(false) + , __haveUpdatesForRender(false) + , __isSyncedPresentation(false) , __isModel(false) , __pLayer(rhs.__pLayer) { @@ -76,7 +81,6 @@ _RootVisualElement::~_RootVisualElement(void) __pLayer = NULL; } - VisualElement* _RootVisualElement::CloneN(void) const { @@ -246,5 +250,113 @@ _RootVisualElement::GetProjectionMatrix(void) const } +bool +_RootVisualElement::DrawModelTree(void) +{ + if(!__isModel) + { + return false; + } + + _VisualElementImpl* pRootModelImpl = _pVisualElementImpl; + + bool updated = false; + if (likely(pRootModelImpl)) + { + if (unlikely(GetNeedsContentUpdate())) + { + SetNeedsContentUpdate(false); + Draw(); + updated = true; + __haveUpdatesForRender = true; + } + + if (likely((pRootModelImpl->__childrenNeedsUpdateProps & ~_VisualElementImpl::UPDATED_PROP_CONTENT) != 0) ) + { + pRootModelImpl->UpdateHierarchyProps(); + updated = true; + __haveUpdatesForRender = true; + } + +#if 0 // TEXTURE UPLOAD + if (_pRootVisualElement->GetNeedsSurfaceUpdate()) + { + if (!checkOnly) + { + _pRootVisualElement->SetNeedsSurfaceUpdate(false); + _GlRenderManager::GetInstance()->UpdateTexture(); + } + updated = true; + __haveUpdatesForRender = true; + } +#endif + } + return updated; +} + +bool +_RootVisualElement::UpdateRenderObjectTree(void) +{ + if(!__isModel) + { + return false; + } + if (!__haveUpdatesForRender) + { + return false; + } + + _pVisualElementImpl->UpdateRender(); + + __haveUpdatesForRender = false; + + return true; +} + +bool +_RootVisualElement::UpdateNativeNode(void) +{ + if(!__isModel) + { + return false; + } + + _VisualElementImpl* pRenderRootImpl = _pVisualElementImpl->__pRenderObject; + + if (!pRenderRootImpl) + { + return false; + } + + if (likely((pRenderRootImpl->__childrenNeedsUpdateProps & ~_VisualElementImpl::UPDATED_PROP_CONTENT) != 0) + || likely(pRenderRootImpl->__pSharedData->NeedNativeReconfigure()) + ) + { + pRenderRootImpl->UpdateHierarchyProps(); + __isSyncedPresentation = false; + return true; + } + return false; +} + +bool +_RootVisualElement::SyncPresentationTree(void) +{ + if(!__isModel) + { + return false; + } + + _VisualElementImpl* pRootPresentationImpl = _pVisualElementImpl->__pPresentation; + _VisualElementImpl* pRenderRootImpl = _pVisualElementImpl->__pRenderObject; + + if ( pRootPresentationImpl && pRenderRootImpl ) + { + pRootPresentationImpl->Sync(*pRenderRootImpl); + __isSyncedPresentation = true; + } + return true; +} + }}} //namespace Tizen { namespace Ui { namespace Animations { diff --git a/src/ui/animations/FUiAnim_SceneVisualElementImpl.cpp b/src/ui/animations/FUiAnim_SceneVisualElementImpl.cpp new file mode 100644 index 0000000..8aa8e70 --- /dev/null +++ b/src/ui/animations/FUiAnim_SceneVisualElementImpl.cpp @@ -0,0 +1,50 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + + +#include +#include "FUiAnim_SceneVisualElementImpl.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + + +_SceneVisualElementImpl::_SceneVisualElementImpl(void) +{ + +} + +_SceneVisualElementImpl::~_SceneVisualElementImpl(void) +{ + +} + +_SceneVisualElementImpl* +_SceneVisualElementImpl::GetInstance(SceneVisualElement& scene) +{ + return scene._pSceneVisualElementImpl; +} + +const _SceneVisualElementImpl* +_SceneVisualElementImpl::GetInstance(const SceneVisualElement& scene) +{ + return scene._pSceneVisualElementImpl; +} + +}}} //namespace Tizen { namespace Ui { namespace Animations { + diff --git a/src/ui/animations/FUiAnim_SceneVisualElementImpl.h b/src/ui/animations/FUiAnim_SceneVisualElementImpl.h new file mode 100644 index 0000000..eadcb88 --- /dev/null +++ b/src/ui/animations/FUiAnim_SceneVisualElementImpl.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUiAnim_SceneVisualElementImpl.h + * @brief This is the header file for the _SceneVisualElementImpl class. + * + * This header file contains the declarations of the _SceneVisualElementImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_SCENE_VISUAL_ELEMENT_IMPL_H_ +#define _FUI_ANIM_INTERNAL_SCENE_VISUAL_ELEMENT_IMPL_H_ + + +#include +#include "FUiAnim_RootVisualElement.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +class SceneVisualElement; + + +class _OSP_EXPORT_ _SceneVisualElementImpl + : public _RootVisualElement +{ +public: + _SceneVisualElementImpl(void); + virtual ~_SceneVisualElementImpl(void); + + static _SceneVisualElementImpl* GetInstance(SceneVisualElement& scene); + static const _SceneVisualElementImpl* GetInstance(const SceneVisualElement& scene); +private: + + friend class _RootVisualElement; + friend class SceneVisualElement; +}; + + +}}} //namespace Tizen { namespace Ui { namespace Animations + + +#endif //_FUI_ANIM_INTERNAL_SCENE_VISUAL_ELEMENT_IMPL_H_ + + diff --git a/src/ui/animations/FUiAnim_TransactionNode.cpp b/src/ui/animations/FUiAnim_TransactionNode.cpp index 30e7780..731e9c7 100644 --- a/src/ui/animations/FUiAnim_TransactionNode.cpp +++ b/src/ui/animations/FUiAnim_TransactionNode.cpp @@ -69,28 +69,21 @@ namespace Tizen { namespace Ui { namespace Animations unsigned int _AnimationTime::GetTime(bool loopTime) { -#ifdef VE_EFL #ifdef VE_DEBUG_ANIMATION static unsigned int debug_time = 0; - debug_time += 20; + debug_time += 10; return debug_time; -#else +#else // if not VE_DEBUG_ANIMATION +#ifdef VE_EFL + if (likely(loopTime)) { return (unsigned int) (ecore_loop_time_get() * 1000.0f); // ecore_loop_time_get() returns a value in seconds. } return (unsigned int) (ecore_time_get() * 1000.0f); // ecore_loop_time_get() returns a value in seconds. -#endif -#else -#ifdef VE_DEBUG_ANIMATION - static unsigned int debug_time = 0; - - debug_time += 10; - return debug_time; -#else - +#else // GL static _Mutex timeMutex(true); struct timeval timev; @@ -99,8 +92,8 @@ _AnimationTime::GetTime(bool loopTime) gettimeofday(&timev, NULL); return timev.tv_sec * 1000 + timev.tv_usec / 1000; -#endif -#endif +#endif // end GL +#endif // end (if not VE_DEBUG_ANIMATION) } _AnimationData::_AnimationData(Tizen::Base::Object& target, _AnimationTargetType type, const Tizen::Base::String* pName, VisualElementAnimation& animation) diff --git a/src/ui/animations/FUiAnim_View.cpp b/src/ui/animations/FUiAnim_View.cpp index 76dc201..9e77645 100644 --- a/src/ui/animations/FUiAnim_View.cpp +++ b/src/ui/animations/FUiAnim_View.cpp @@ -27,6 +27,10 @@ using namespace Tizen::Graphics; namespace Tizen { namespace Ui { namespace Animations { _View::_View() + : __pCamera(null) + , __pProjection(null) + , __pViewport(null) + , __pRenderTarget(null) { static StringHashCodeProvider strHashCodeProvider; static ComparerT comparer; diff --git a/src/ui/animations/FUiAnim_VisualElementImpl.cpp b/src/ui/animations/FUiAnim_VisualElementImpl.cpp index 5344548..9e6e97f 100644 --- a/src/ui/animations/FUiAnim_VisualElementImpl.cpp +++ b/src/ui/animations/FUiAnim_VisualElementImpl.cpp @@ -2549,6 +2549,8 @@ _VisualElementImpl::SetBoundsProperty(const Variant& v) else if ( IS_PRESENTATION(this)) { GetSharedData().toUpdatePropertiesForRenderObject.Update(UPDATED_PROP_BOUNDS, this); + // TODO:need to find more optimized code + GetSharedData().toUpdatePropertiesForRenderObject.Apply(); //UPDATE_PROP_FOR_RENDER(UPDATED_PROP_BOUNDS,__bounds); } @@ -2599,6 +2601,8 @@ _VisualElementImpl::SetBoundsPositionSubProperty(const Variant& v) else if ( IS_PRESENTATION(this)) { GetSharedData().toUpdatePropertiesForRenderObject.UpdateSubProperty(PROP_ID(VeSubPropBoundsPosition), this); + // TODO:need to find more optimized code + GetSharedData().toUpdatePropertiesForRenderObject.Apply(); } return r; } @@ -2645,6 +2649,8 @@ _VisualElementImpl::SetBoundsSizeSubProperty(const Variant& v) else if ( IS_PRESENTATION(this)) { GetSharedData().toUpdatePropertiesForRenderObject.UpdateSubProperty(PROP_ID(VeSubPropBoundsSize), this); + // TODO:need to find more optimized code + GetSharedData().toUpdatePropertiesForRenderObject.Apply(); } return r; @@ -3482,6 +3488,8 @@ _VisualElementImpl::SetTransformMatrixI(const FloatMatrix4& xform, bool updateDe else if ( IS_PRESENTATION(this)) { GetSharedData().toUpdatePropertiesForRenderObject.Update(UPDATED_PROP_TRANSFORM, this); + // TODO:need to find more optimized code + GetSharedData().toUpdatePropertiesForRenderObject.Apply(); // UPDATE_PROP_FOR_RENDER(UPDATED_PROP_TRANSFORM, __transform); } @@ -3543,6 +3551,8 @@ _VisualElementImpl::SetTransformDecomposedFactorI(const String* pProperty, int p else if ( IS_PRESENTATION(this)) { GetSharedData().toUpdatePropertiesForRenderObject.UpdateSubProperty(propertyId, this); + // TODO:need to find more optimized code + GetSharedData().toUpdatePropertiesForRenderObject.Apply(); } return r; } @@ -4304,6 +4314,8 @@ _VisualElementImpl::SetChildrenTransformMatrixI(const FloatMatrix4& xform, bool { //UPDATE_PROP_FOR_RENDER(UPDATED_PROP_CHILDREN_TRANSFORM, __childrenTransform); GetSharedData().toUpdatePropertiesForRenderObject.Update(UPDATED_PROP_CHILDREN_TRANSFORM, this); + // TODO:need to find more optimized code + GetSharedData().toUpdatePropertiesForRenderObject.Apply(); } return E_SUCCESS; } @@ -4369,6 +4381,8 @@ _VisualElementImpl::SetChildrenTransformDecomposedFactorI(const String* pPropert else if ( IS_PRESENTATION(this)) { GetSharedData().toUpdatePropertiesForRenderObject.UpdateSubProperty(propertyId, this); + // TODO:need to find more optimized code + GetSharedData().toUpdatePropertiesForRenderObject.Apply(); } return E_SUCCESS; } @@ -5277,7 +5291,9 @@ _VisualElementImpl::GetCanvasN(const FloatRectangle& bounds) canvasBounds = canvasBounds.GetIntersection(clipBounds); //pRenderTarget->__pPresentation->ConvertCoordinates(canvasBounds, this->__pPresentation); pRenderTarget->ConvertCoordinates(canvasBounds, this); - canvasBounds = canvasBounds.GetIntersection(pRenderTarget->GetDrawableRect()); + FloatRectangle drawableRect; + pRenderTarget->GetDrawableRect(drawableRect); + canvasBounds = canvasBounds.GetIntersection(drawableRect); SysTryReturn(NID_UI_ANIM, canvasBounds.width > 0.0f && canvasBounds.height > 0.0f, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Bounds is out of range."); @@ -6252,15 +6268,16 @@ _VisualElementImpl::GetVisibleRect(void) const return __visibleRect; } -FloatRectangle -_VisualElementImpl::GetDrawableRect(void) const +void +_VisualElementImpl::GetDrawableRect(FloatRectangle& bounds) const { // If VE has backing-buffer, visible status is not important for drawing... bool needSurface = NEED_SURFACE(this); if (unlikely(!needSurface)) { - return FloatRectangle(); + bounds.SetBounds(0,0,0,0) ; + return; } if (unlikely(IsPropsInvalidated(UPDATED_PROP_COORDINATES_MASK))) @@ -6281,12 +6298,14 @@ _VisualElementImpl::GetDrawableRect(void) const #endif if (HAVE_SURFACE(this) && GetSharedData().fixedSurfaceSize) { - return FloatRectangle(0.0f, 0.0f, static_cast< float >(GetSharedData().pSurface->GetSize().width), static_cast< float >(GetSharedData().pSurface->GetSize().height)); + bounds.SetBounds(0.0f, 0.0f, static_cast< float >(GetSharedData().pSurface->GetSize().width), static_cast< float >(GetSharedData().pSurface->GetSize().height)); + return; } - return FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height); + bounds.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height); } + float _VisualElementImpl::GetOpacityFromRoot(void) const { @@ -7214,9 +7233,13 @@ _VisualElementImpl::Draw(void) // To reduce drawing calls such as 'OnDraw', use '__DrawRectangle' directly // int maxScreenSize = _Max(_VisualElementCoordinateSystem::logScreenWidth, _VisualElementCoordinateSystem::logScreenHeight); - pRenderTarget->DrawRectangleIfNeeded( - needFullScreenDraw ? FloatRectangle(0.0f, 0.0f, maxScreenSize, maxScreenSize) : GetDrawableRect() - ); + + FloatRectangle bounds(0.0f, 0.0f, maxScreenSize, maxScreenSize); + if(!needFullScreenDraw) + { + GetDrawableRect(bounds); + } + pRenderTarget->DrawRectangleIfNeeded(bounds); } return E_SUCCESS; @@ -7297,7 +7320,8 @@ _VisualElementImpl::DrawRectangleIfNeeded(const FloatRectangle& drawRect) { // WARNING: // Redraw only if the request has some valid region to draw. - drawableRect = GetDrawableRect(); + GetDrawableRect(drawableRect); + if (!drawRect.IsIntersected(drawableRect)) { drawableRect.SetSize(0.0f, 0.0f); // Make empty @@ -7404,7 +7428,10 @@ _VisualElementImpl::DrawRectangle(const FloatRectangle& drawRect) bool needDraw = false; bool fullValidated = false; - FloatRectangle drawableRect(GetDrawableRect()); + FloatRectangle drawableRect; + + GetDrawableRect(drawableRect); + FloatRectangle drawRectVisible(drawRect.GetIntersection(drawableRect)); FloatRectangle invalidatedRectVisible(GetSharedData().invalidatedRegion.GetIntersection(drawableRect)); diff --git a/src/ui/inc/FUiAnim_NativeLayer.h b/src/ui/inc/FUiAnim_NativeLayer.h index e457ffb..0f2a231 100644 --- a/src/ui/inc/FUiAnim_NativeLayer.h +++ b/src/ui/inc/FUiAnim_NativeLayer.h @@ -27,11 +27,15 @@ #include #include +#include #include + namespace Tizen { namespace Ui { namespace Animations { +class SceneVisualElement; +class DisplayContext; class _RootVisualElement; class _INativeNode; class _NativeWindow; @@ -69,7 +73,12 @@ public: result Construct(_NativeWindow* pNativeWindow); _RootVisualElement* GetRootVisualElement(void) const; + SceneVisualElement* GetScene(int sceneIndex) const; + result AttachScene( SceneVisualElement* pScene); + result DetachScene( SceneVisualElement* pScene); + result ChangeSceneOrder( SceneVisualElement* pScene, const SceneVisualElement* pReference, bool above); + DisplayContext* GetDisplayContext(void) const; void SetFlushNeeded(void) { @@ -97,7 +106,6 @@ public: */ bool Render(void); - /** * Update render objects with model objects. * @@ -123,7 +131,6 @@ public: */ bool UpdatePresentation(void); - unsigned long GetWindowHandle(void) const; unsigned long GetId(void) const; @@ -221,19 +228,21 @@ private: _NativeLayer& operator =(const _NativeLayer& rhs); protected: - _RootVisualElement* _pRootVisualElement; + Tizen::Base::Collection::ArrayListT _roots; + SceneVisualElement* _pRootVisualElement; _NativeWindow* _pWindow; bool _isWindowOwner; bool _isRunningOnRenderThread; bool _showState; Tizen::Graphics::FloatRectangle _bounds; + DisplayContext* _pDisplayContext; private: unsigned long __id; bool __needFlush; - bool __needUpdateRenderObjects; - bool __didSyncPresentation; +// bool __needUpdateRenderObjects; +// bool __didSyncPresentation; friend class _RootVisualElement; diff --git a/src/ui/inc/FUiAnim_RootVisualElement.h b/src/ui/inc/FUiAnim_RootVisualElement.h index 28622c9..1d6e176 100644 --- a/src/ui/inc/FUiAnim_RootVisualElement.h +++ b/src/ui/inc/FUiAnim_RootVisualElement.h @@ -37,6 +37,7 @@ namespace Tizen { namespace Ui { namespace Animations { class _NativeLayer; class _View; +class SceneVisualElement; class _OSP_EXPORT_ _RootVisualElement : public _VisualElement @@ -45,9 +46,6 @@ public: _RootVisualElement(void); - - virtual ~_RootVisualElement(void); - public: bool GetNeedsContentUpdate(void) const @@ -76,6 +74,15 @@ public: return __pLayer; } + + bool DrawModelTree(void); + bool UpdateRenderObjectTree(void); + bool SyncPresentationTree(void); + bool UpdateNativeNode(void); + + bool HaveUpdatesForRender() const {return __haveUpdatesForRender;} + bool IsSyncedPrensenation() const {return __isSyncedPresentation;} + result SetNativeLayer(_NativeLayer* pLayer); // view @@ -102,11 +109,14 @@ protected: virtual VisualElement* CloneN(void) const; + virtual ~_RootVisualElement(void); private: bool __needsUpdateFromRoot; bool __needsSurfaceUpdate; + bool __haveUpdatesForRender;// model use this + bool __isSyncedPresentation;// render object use this bool __isModel; _NativeLayer* __pLayer; _View* __pView; diff --git a/src/ui/inc/FUiAnim_VisualElementImpl.h b/src/ui/inc/FUiAnim_VisualElementImpl.h index 70e6b03..428b500 100644 --- a/src/ui/inc/FUiAnim_VisualElementImpl.h +++ b/src/ui/inc/FUiAnim_VisualElementImpl.h @@ -1351,7 +1351,7 @@ private: result CreateElementTreeForDetachImplicitAnimation(_VisualElementImpl& child); Tizen::Graphics::FloatRectangle GetVisibleRect(void) const; - Tizen::Graphics::FloatRectangle GetDrawableRect(void) const; + void GetDrawableRect(Tizen::Graphics::FloatRectangle& bounds) const; const Tizen::Graphics::FloatRectangle& GetBoundingBoxI(void) const; const Tizen::Graphics::FloatMatrix4& GetMatrixToSuper(void) const; diff --git a/src/ui/inc/FUi_Window.h b/src/ui/inc/FUi_Window.h index b03c221..1fa1b4e 100644 --- a/src/ui/inc/FUi_Window.h +++ b/src/ui/inc/FUi_Window.h @@ -165,7 +165,6 @@ private: Tizen::Ui::Animations::_NativeLayer* __pLayer; Tizen::Ui::_DimmingLayer* __pDimmingLayer; - mutable Tizen::Ui::Animations::DisplayContext* __pDisplayContext; bool __systemWindow; bool __isOpened; bool __isInitialized; -- 2.7.4