update presentation querry logic
authorDae young ,Ryu <karzia@samsung.com>
Tue, 13 Aug 2013 15:15:06 +0000 (18:15 +0300)
committerDae young ,Ryu <karzia@samsung.com>
Tue, 13 Aug 2013 15:15:06 +0000 (18:15 +0300)
Change-Id: Ifbcb6e2ea1c45b53edaf82d1f01580e13984f47c
Signed-off-by: Dae young ,Ryu <karzia@samsung.com>
14 files changed:
inc/FUiAnimMesh.h
src/ui/animations/FUiAnimMesh.cpp
src/ui/animations/FUiAnimVisualElement.cpp
src/ui/animations/FUiAnim_DisplayManager.cpp
src/ui/animations/FUiAnim_DisplayManager.h
src/ui/animations/FUiAnim_GlLayer.cpp
src/ui/animations/FUiAnim_Looper.cpp
src/ui/animations/FUiAnim_MeshImpl.cpp
src/ui/animations/FUiAnim_MeshImportSample.cpp
src/ui/animations/FUiAnim_NativeLayer.cpp
src/ui/animations/FUiAnim_VisualElementImpl.cpp
src/ui/inc/FUiAnim_MeshImpl.h
src/ui/inc/FUiAnim_NativeLayer.h
src/ui/inc/FUiAnim_VisualElementImpl.h

index bf4cfae..79909bc 100644 (file)
@@ -211,16 +211,16 @@ public:
        void Clear();
 
        Tizen::Graphics::FloatPoint3 GetBoundingBoxPosition() const;
-       float GetBoundingBoxVolume() const;
+    float GetBoundingBoxLength() const;
        float GetBoundingBoxWidth() const;
        float GetBoundingBoxHeight() const;
 
        // 임시 함수
-       result AllocVertices(int count);
-       result AllocIndices(int count);
-       result AllocTextureCoordinates();
-       result AllocNormals();
-       result AllocColors();
+    result ReserveVertices(int count);
+    result ReserveIndices(int count);
+    result ReserveTextureCoordinates();
+    result ReserveNormals();
+    result ReserveColors();
 
        bool IsIndexEnabled() const;
        bool IsTextureCoordinateEnabled() const;
index b028eea..2e9fc73 100644 (file)
@@ -148,7 +148,7 @@ Mesh::GetBoundingBoxPosition() const
 }
 
 float
-Mesh::GetBoundingBoxVolume() const
+Mesh::GetBoundingBoxLength() const
 {
     CHECK_CONSTRUCTED;
     return __pMeshImpl->GetBoundingBoxVolume();
@@ -169,35 +169,35 @@ Mesh::GetBoundingBoxHeight() const
 
 // 임시 함수
 result
-Mesh::AllocVertices(int count)
+Mesh::ReserveVertices(int count)
 {
     CHECK_CONSTRUCTED;
     return __pMeshImpl->AllocVertices(count);
 }
 
 result
-Mesh::AllocIndices(int count)
+Mesh::ReserveIndices(int count)
 {
     CHECK_CONSTRUCTED;
     return __pMeshImpl->AllocIndices(count);
 }
 
 result
-Mesh::AllocTextureCoordinates()
+Mesh::ReserveTextureCoordinates()
 {
     CHECK_CONSTRUCTED;
     return __pMeshImpl->AllocTextureCoordinates();
 }
 
 result
-Mesh::AllocNormals()
+Mesh::ReserveNormals()
 {
     CHECK_CONSTRUCTED;
     return __pMeshImpl->AllocNormals();
 }
 
 result
-Mesh::AllocColors()
+Mesh::ReserveColors()
 {
     CHECK_CONSTRUCTED;
     return __pMeshImpl->AllocColors();
index 1d7e852..635065c 100644 (file)
@@ -28,6 +28,7 @@
 #include <FUiAnimVisualElementSurface.h>
 #include <FUiAnimVisualElementAnimation.h>
 
+#include "FUiAnim_NativeLayer.h"
 #include "FUiAnim_VisualElementAnimationImpl.h"
 #include "FUiAnim_VisualElementImpl.h"
 #include "FUiAnim_Mutex.h"
@@ -834,8 +835,6 @@ VisualElement::RemoveAllAnimations(void)
        _pVisualElementImpl->RemoveAllAnimations();
 }
 
-static int acquireCount = 0;
-
 const VisualElement*
 VisualElement::AcquirePresentationInstance(void)
 {
@@ -843,23 +842,27 @@ VisualElement::AcquirePresentationInstance(void)
 
     if (_pVisualElementImpl && _pVisualElementImpl->GetPresentation() && _pVisualElementImpl->GetPresentation()->GetPublic())
     {
-        if (acquireCount <= 0)
+        _RootVisualElement* pRoot = dynamic_cast<_RootVisualElement*>(_pVisualElementImpl->GetRootPublic());
+        bool isUpdated = false;
+
+        if ( pRoot )
         {
-            _AutoMutex treeLock(*_VisualElementEnvironment::GetTreeLock());
-
-            acquireCount++;
-               _VisualElementImpl* pRootImpl = _pVisualElementImpl->GetRoot();
-               _VisualElementImpl* pTargetImpl = (pRootImpl)? pRootImpl : _pVisualElementImpl;
-
-               if (likely(pTargetImpl))
-               {
-                       _VisualElementImpl* pRenderObject = pTargetImpl->GetRenderObject();
-                       if(pRenderObject && pTargetImpl->GetPresentation())
-                       {
-                               pTargetImpl->GetPresentation()->Sync(*pRenderObject);
-                       }
+            _NativeLayer* pLayer = pRoot->GetNativeLayer();
+            if ( pLayer )
+            {
+                pLayer->UpdatePresentation();
+                isUpdated = true;
             }
+
         }
+        if(!isUpdated)
+        {
+
+            // todo: when Ve isn't attached to the maintree, just update presentation without sync.(use UpdatePropertiesForRender infomation)
+            //_pVisualElementImpl->Update() Sync(_pVisualElementImpl->Sync());
+
+        }
+
 
         return _pVisualElementImpl->GetPresentation()->GetPublic();
     }
@@ -870,7 +873,6 @@ VisualElement::AcquirePresentationInstance(void)
 void
 VisualElement::ReleasePresentationInstance(void)
 {
-       acquireCount--;
        return;
 }
 
@@ -913,6 +915,7 @@ VisualElement::SetTexture(const String& meshName, Bitmap* pTexture)
        CHECK_CONSTRUCTED;
        return _pVisualElementImpl->SetTexture(meshName, pTexture);
 }
+
 Bitmap*
 VisualElement::GetTexture(const String& meshName) const
 {
index 70f4f5d..0abaae6 100644 (file)
@@ -181,7 +181,7 @@ _DisplayManager::AddWakeUpEvent(void)
 }
 
 bool
-_DisplayManager::NeedAllUpdates()
+_DisplayManager::HasUpdates() const
 {
        int count = __layers.GetCount();
        if (count <= 0)
@@ -189,26 +189,16 @@ _DisplayManager::NeedAllUpdates()
 
        for (int i = 0; i < count; i++)
        {
-               _NativeLayer* pLayer = null;
+        const _NativeLayer* pLayer = null;
 
-               pLayer = static_cast< _NativeLayer* >(__layers.GetAt(i));
+        pLayer = static_cast<const _NativeLayer* >(__layers.GetAt(i));
 
                if (likely(pLayer))
                {
-//                     if(isMainThread)
-//                     {
-                               if(pLayer->IsRenderNeeded())
-                               {
-                                       return true;
-                               }
-
-//                     }
-//                     else
-//                     {
-//                             bool updated = pLayer->UpdateNativeNodes();
-//                             needUpdate |= updated;
-//                     }
-
+            if(pLayer->IsRenderNeeded())
+            {
+                return true;
+            }
                }
        }
        return false;
@@ -303,8 +293,42 @@ _DisplayManager::PostRender(_NativeLayer& layer, bool isMainThread)
 result
 _DisplayManager::Flush(void)
 {
-       _GlRenderManager::GetInstance()->Composite();
-       // FIXME: VisualElement::Flush should wait for complete
+    //for main thread
+    int count =__layers.GetCount();
+
+
+    _GlRenderManager* pRenderManager = _GlRenderManager::GetInstance();
+
+    if(!pRenderManager)
+    {
+        return E_INVALID_STATE;
+    }
+
+    _NativeLayer* pLayer = null;
+
+    bool needCompositRenderer = false;
+
+    for(int i = 0;i< count; i++)
+    {
+        pLayer = static_cast<_NativeLayer*>(__layers.GetAt(i));
+        if(pLayer)
+        {
+            if(!pLayer->IsRunningOnRenderThread())
+            {
+                pLayer->Flush();
+            }
+            else
+            {
+                needCompositRenderer = true;
+            }
+        }
+    }
+
+    if (needCompositRenderer) //by render thread
+    {
+        _GlRenderManager::GetInstance()->Composite();
+    }
+    // FIXME: VisualElement::Flush should wait for complete
 
        return E_SUCCESS;
 }
index 303c716..44e796e 100644 (file)
@@ -71,7 +71,7 @@ public:
        void AddWakeUpEvent(void);
        void RemoveWakeUpEvent(void);
 
-       bool NeedAllUpdates();
+    bool HasUpdates() const;
        bool RenderAll(bool modelObject);
 //     bool Render(_RootVisualElement& root, bool checkOnly, bool isMainThread);
        result PostRender(_NativeLayer& layer, bool isMainThread);
index f55df55..ace4139 100644 (file)
@@ -71,6 +71,7 @@ _GlLayer::_GlLayer(void)
        , __pContext(null)
 #endif
 {
+    _isRunningOnRenderThread = true;
 }
 
 _GlLayer::~_GlLayer(void)
index 6c65a4a..b47989f 100644 (file)
@@ -392,7 +392,7 @@ _Looper::PeekRawEvent(_RawEvent& rawEvent, bool consume)
 
        if (__eventQueue.GetCount() <= 0)
        {
-               __needUpdateDraw = _DisplayManager::GetInstance()->NeedAllUpdates(); //true
+        __needUpdateDraw = _DisplayManager::GetInstance()->HasUpdates(); //true
 #if 1 // todo works
                if (unlikely(__needUpdateDraw))
                {
index 0c670f5..3d4fa6d 100644 (file)
@@ -118,29 +118,6 @@ _MeshImpl::AllocVertices(int count)
     return E_SUCCESS;
 }
 
-result
-_MeshImpl::AllocIndices(int count)
-{
-    if(__pIndices)
-        return E_ALREADY_SET;
-
-    if(count <= 0)
-        return E_INVALID_ARG;
-
-
-    __countOfAllocatedIndex = count;
-
-    __pIndices = new (std::nothrow) unsigned short int[count];
-    if(!__pIndices)
-        return E_OUT_OF_MEMORY;
-
-    for(int i = 0 ; i < __countOfAllocatedVertex ; i++)
-    {
-        __pIndices[i] = 0;
-    }
-
-    return E_SUCCESS;
-}
 
 result
 _MeshImpl::AllocTextureCoordinates()
@@ -148,7 +125,7 @@ _MeshImpl::AllocTextureCoordinates()
     if(__pTexCoordinates)
         return E_ALREADY_SET;
 
-    if(__countOfAllocatedVertex<=0)
+    if(__countOfAllocatedVertex <= 0)
         return E_INVALID_STATE;
 
     int count = __countOfAllocatedVertex * 2;
@@ -169,7 +146,7 @@ _MeshImpl::AllocNormals()
     if(__pNormals)
         return E_ALREADY_SET;
 
-    if(__countOfAllocatedVertex<=0)
+    if(__countOfAllocatedVertex <= 0)
         return E_INVALID_STATE;
 
     int count = __countOfAllocatedVertex * 3;
@@ -190,7 +167,7 @@ _MeshImpl::AllocColors()
     if(__pColors)
         return E_ALREADY_SET;
 
-    if(__countOfAllocatedVertex<=0)
+    if(__countOfAllocatedVertex <= 0)
         return E_INVALID_STATE;
 
     int count = __countOfAllocatedVertex * 4;
@@ -206,12 +183,43 @@ _MeshImpl::AllocColors()
 }
 
 result
+_MeshImpl::AllocIndices(int count)
+{
+    if(__pIndices)
+        return E_ALREADY_SET;
+
+    if(count <= 0)
+        return E_INVALID_ARG;
+
+
+    __countOfAllocatedIndex = count;
+
+    __pIndices = new (std::nothrow) unsigned short int[count];
+    if(!__pIndices)
+        return E_OUT_OF_MEMORY;
+
+    for(int i = 0 ; i < __countOfAllocatedVertex ; i++)
+    {
+        __pIndices[i] = 0;
+    }
+
+    return E_SUCCESS;
+}
+
+
+result
 _MeshImpl::SetVertex(int arrayIndex, const FloatPoint3& vertex)
 {
     if(__pVertices)
     {
+        if ( arrayIndex > __countOfAllocatedVertex )
+        {
+            return E_OUT_OF_RANGE;
+        }
+
         int i = arrayIndex * 3;
-        if(__hasBoundingBox)
+
+        if ( __hasBoundingBox )
         {
             __pVertices[i]   = vertex.x - __boundingBox.x;   //x
             __pVertices[i+1] = vertex.y - __boundingBox.y;   //y
@@ -233,31 +241,52 @@ _MeshImpl::SetVertex(int arrayIndex, const FloatPoint3& vertex)
         return E_SUCCESS;
     }
 
-    return E_INVALID_ARG;
+    return E_INVALID_STATE;
 }
 
 
 result
 _MeshImpl::SetTextureCoord(int arrayIndex, const FloatPoint& textureCoord)
 {
+    if(!__pTexCoordinates)
+    {
+       AllocTextureCoordinates();
+    }
     if(__pTexCoordinates)
     {
+        if ( arrayIndex > __countOfAllocatedVertex )
+        {
+            return E_OUT_OF_RANGE;
+        }
+
         int i = arrayIndex * 2;
+
         __pTexCoordinates[i] = textureCoord.x;       //x
         __pTexCoordinates[i+1] = textureCoord.y;   //y
 
         return E_SUCCESS;
     }
 
-    return E_INVALID_ARG;
+    return E_INVALID_STATE;
 }
 
 result
 _MeshImpl::SetNormal(int arrayIndex, const FloatPoint3& normal)
 {
+    if(!__pNormals)
+    {
+       AllocNormals();
+    }
+
     if(__pNormals)
     {
+        if ( arrayIndex > __countOfAllocatedVertex )
+        {
+            return E_OUT_OF_RANGE;
+        }
+
         int i = arrayIndex * 3;
+
         __pNormals[i] = normal.x;       //x
         __pNormals[i+1] = normal.y;   //y
         __pNormals[i+2] = normal.z;   //z
@@ -265,14 +294,23 @@ _MeshImpl::SetNormal(int arrayIndex, const FloatPoint3& normal)
         return E_SUCCESS;
     }
 
-    return E_INVALID_ARG;
+    return E_INVALID_STATE;
 }
 
 result
 _MeshImpl::SetColor(int arrayIndex, const Color& color)
 {
+    if(!__pColors)
+    {
+       AllocColors();
+    }
     if(__pColors)
     {
+        if ( arrayIndex > __countOfAllocatedVertex )
+        {
+            return E_OUT_OF_RANGE;
+        }
+
         int i = arrayIndex*4;
         __pColors[i]   = (float)color.GetRed()/255.0f;
         __pColors[i+1] = (float)color.GetGreen()/255.0f;
@@ -281,7 +319,7 @@ _MeshImpl::SetColor(int arrayIndex, const Color& color)
         return E_SUCCESS;
     }
 
-    return E_INVALID_ARG;
+    return E_INVALID_STATE;
 }
 
 result
@@ -289,14 +327,20 @@ _MeshImpl::SetIndex(int arrayIndex, int vertexIndex)
 {
     if(__pIndices)
     {
+        if ( arrayIndex > __countOfAllocatedIndex )
+        {
+            return E_OUT_OF_RANGE;
+        }
+
         __pIndices[arrayIndex] = vertexIndex;
 
                if(__countOfIndex <= arrayIndex )
         {
                        __countOfIndex = arrayIndex + 1;
         }
+        return E_SUCCESS;
     }
-    return E_SUCCESS;
+    return E_INVALID_STATE;
 }
 
 FloatPoint3
index d3a8261..e8d0e01 100644 (file)
@@ -305,8 +305,8 @@ bool _MeshImportSample::Parsing(char* pStrAse)
                                                        pCur = STRTOK(NULL,seps,&pNext);
                                                        int countOfFace = atoi(pCur);
                                                        MESH_NUMFACES = countOfFace;
-                                                       pMesh->AllocVertices(countOfFace*3);
-//                                                     pMesh->AllocIndices(countOfFace*3);
+                            pMesh->ReserveVertices(countOfFace*3);
+//                                                     pMesh->ReserveIndices(countOfFace*3);
 
                                                        PRINT("*MESH_NUMFACES = %d\n", countOfFace);
                                                }
@@ -512,7 +512,7 @@ bool _MeshImportSample::Parsing(char* pStrAse)
 //                                                     pMesh->MESH_TFACELIST = new unsigned short int[3 * pMesh->MESH_NUMTVFACES];
 //                                                     pMesh->MESH_TFACELIST_REAL = new float[2 * 3 * pMesh->MESH_NUMTVFACES];
 
-                                                       pMesh->AllocTextureCoordinates();
+                            pMesh->ReserveTextureCoordinates();
 
                                                        FloatPoint texCoord;
 //                                                     int k = 0;
index 5dbfb8e..dfa804a 100644 (file)
@@ -25,6 +25,9 @@
 #include <new>
 #include <FBaseSysLog.h>
 
+
+#include "FUiAnim_Mutex.h"
+#include "FUiAnim_VisualElementEnvironment.h"
 #include "FUiAnim_RootVisualElement.h"
 #include "FUiAnim_NativeLayer.h"
 #include "FUiAnim_VisualElementImpl.h"
@@ -43,9 +46,11 @@ namespace Tizen { namespace Ui { namespace Animations
 
 _NativeLayer::_NativeLayer(void)
        : _pRootVisualElement(null)
+    , _isRunningOnRenderThread(false)
        , __handle(0)
        , __needFlush(false)
        , __needUpdateRenderObjects(false)
+    , __didSyncPresentation(false)
 {
        static unsigned long idCount = 0;
        __id = idCount++;
@@ -243,7 +248,9 @@ _NativeLayer::UpdateNativeNodes(void)
        _VisualElementImpl* pRenderRootImpl = pRootModelImpl->__pRenderObject;
 
        if(!pRenderRootImpl)
+    {
                return false;
+    }
 
 
        if (likely((pRenderRootImpl->__childrenNeedsUpdateProps & ~_VisualElementImpl::UPDATED_PROP_CONTENT) != 0)
@@ -251,16 +258,45 @@ _NativeLayer::UpdateNativeNodes(void)
                        )
        {
                pRenderRootImpl->UpdateHierarchyProps();
+        __didSyncPresentation = false;
                return true;
        }
        return false;
 }
 
+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;
+}
+
 unsigned long
 _NativeLayer::GetHandle(void) const
 {
        return __handle;
 }
+
 unsigned long
 _NativeLayer::GetId(void) const
 {
index 8b0f116..b4a149e 100644 (file)
@@ -839,20 +839,13 @@ _VisualElementImpl::SetVisualElementEventListener(IVisualElementEventListener* p
 result
 _VisualElementImpl::FlushI(void)
 {
-#ifdef VE_EFL
-       _DisplayManager* pDisplayManager = _DisplayManager::GetInstance();
-       if (pDisplayManager)
-       {
-               pDisplayManager->RenderAll();
-       }
-#else
-       _DisplayManager* pDisplayManager = _DisplayManager::GetInstance();
+    _DisplayManager* pDisplayManager = _DisplayManager::GetInstance();
        if (pDisplayManager)
        {
                pDisplayManager->RenderAll(true);
                return pDisplayManager->Flush();
        }
-#endif
+    return E_INVALID_STATE;
 }
 
 bool
@@ -1420,6 +1413,19 @@ _VisualElementImpl::SetSurface(const VisualElementSurface* pSurface)
 }
 
 result
+_VisualElementImpl::SetExtraSurface(const Tizen::Base::String& name, const VisualElementSurface* pSurface)
+{
+    return E_SUCCESS;
+}
+
+result
+_VisualElementImpl::SetAlphaMask(const Tizen::Base::String& extraSurfaceName)
+{
+    return E_SUCCESS;
+}
+
+
+result
 _VisualElementImpl::SetImageSource(const String& filePath)
 {
        result r = E_SUCCESS;
index 6067d98..cf99f91 100644 (file)
@@ -82,9 +82,27 @@ public:
        // 임시 함수
        result AllocVertices(int count);
        result AllocIndices(int count);
-       result AllocTextureCoordinates();
-       result AllocNormals();
-       result AllocColors();
+
+    int GetCountOfAllocatedVertices() const
+    {
+        return __countOfAllocatedVertex;
+    }
+
+    int GetCountOfVertices() const
+    {
+        return __countOfVertex;
+    }
+
+    int GetCountOfAllocatedIndices() const
+    {
+        return __countOfAllocatedIndex;
+    }
+
+    int GetCountOfIndices() const
+    {
+        return __countOfIndex;
+    }
+
 
        bool IsIndexEnabled() const
        {
@@ -106,6 +124,11 @@ protected:
        virtual ~_MeshImpl();
        result GatherBoundingPosition(const Tizen::Graphics::FloatPoint3& pt);
 private:
+    result AllocTextureCoordinates();
+    result AllocNormals();
+    result AllocColors();
+
+private:
        Mesh::GeometryType __geoType;
 
        float* __pVertices;                     //MESH_VERTEX_LIST
@@ -133,6 +156,7 @@ private:
 
        Mesh* __pPublic;
 
+    friend class Mesh;
        friend class _MeshImportSample;
        friend class _GlRenderManager;
 };
index 508c3b7..4de421f 100644 (file)
@@ -119,10 +119,25 @@ public:
         */
        bool UpdateNativeNodes(void);
 
+
+    /**
+     * Update presentation with render objects.
+     *
+     * @since 3.0
+     *
+     */
+    bool UpdatePresentation(void);
+
+
        unsigned long GetHandle(void) const;
 
        unsigned long GetId(void) const;
 
+    bool IsRunningOnRenderThread(void) const
+    {
+        return _isRunningOnRenderThread;
+    }
+
        /**
         * Sets the position and the size of this instance.
         *
@@ -212,12 +227,14 @@ private:
 
 protected:
        _RootVisualElement* _pRootVisualElement;
+    bool _isRunningOnRenderThread;
 
 private:
        unsigned long __id;
        unsigned long __handle; // window handle
        bool __needFlush;
        bool __needUpdateRenderObjects;
+    bool __didSyncPresentation;
 
        friend class _RootVisualElement;
 
index 10a5c11..a27a027 100644 (file)
@@ -329,6 +329,8 @@ public:
 
        VisualElementSurface* GetSurfaceN(void) const;
        result SetSurface(const VisualElementSurface* pSurface);
+    result SetExtraSurface(const Tizen::Base::String& name, const VisualElementSurface* pSurface);
+    result SetAlphaMask(const Tizen::Base::String& extraSurfaceName);
 
        result SetContentBounds(const Tizen::Graphics::FloatRectangle& contentBounds);
        Tizen::Graphics::FloatRectangle GetContentBounds(void) const;