Add some filter functions
authorHeeyong Song <heeyong.song@samsung.com>
Wed, 12 Mar 2014 06:32:22 +0000 (15:32 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 12 Mar 2014 06:32:22 +0000 (15:32 +0900)
Change-Id: I157e541d93b73c2c0fabfe31c03f77979730386b

inc/FUiAnimVisualElementFilter.h
src/ui/animations/FUiAnimVisualElementFilter.cpp
src/ui/animations/FUiAnim_GlNode.cpp
src/ui/animations/FUiAnim_GlNode.h
src/ui/animations/FUiAnim_GlRenderManager.cpp
src/ui/animations/FUiAnim_VisualElementFilterImpl.cpp
src/ui/animations/FUiAnim_VisualElementFilterImpl.h
src/ui/animations/FUiAnim_VisualElementImpl.cpp

index 46fb6e0..b5fe410 100644 (file)
@@ -48,6 +48,12 @@ public:
        void SetType(FilterType filterType);
        FilterType GetType(void) const;
 
+       void SetEnabled(bool enabled);
+       bool IsEnabled(void) const;
+
+       result SetKernelSize(float kernelSize);
+       float GetKernelSize(void);
+
 private:
        VisualElementFilter& operator =(const VisualElementFilter&);
 
index a46ce32..3d3cc9b 100644 (file)
@@ -83,4 +83,36 @@ VisualElementFilter::GetType(void) const
        return __pVisualElementFilterImpl->GetType();
 }
 
+void
+VisualElementFilter::SetEnabled(bool enabled)
+{
+       SysAssertf(__pVisualElementFilterImpl != null, "Not yet constructed.");
+
+       __pVisualElementFilterImpl->SetEnabled(enabled);
+}
+
+bool
+VisualElementFilter::IsEnabled(void) const
+{
+       SysAssertf(__pVisualElementFilterImpl != null, "Not yet constructed.");
+
+       return __pVisualElementFilterImpl->IsEnabled();
+}
+
+result
+VisualElementFilter::SetKernelSize(float kernelSize)
+{
+       SysAssertf(__pVisualElementFilterImpl != null, "Not yet constructed.");
+
+       return __pVisualElementFilterImpl->SetKernelSize(kernelSize);
+}
+
+float
+VisualElementFilter::GetKernelSize(void)
+{
+       SysAssertf(__pVisualElementFilterImpl != null, "Not yet constructed.");
+
+       return __pVisualElementFilterImpl->GetKernelSize();
+}
+
 }}} //Tizen::Ui::Animations
index fd76442..014ea39 100644 (file)
@@ -90,10 +90,11 @@ _GlNode::_GlNode(void)
        , __pLight(null)
        , __pMaterial(null)
        , __pFilter(null)
-       , __isFilterEnabled(false)
+       , __useFilter(false)
        , __alphaUpdated(true)
        , __textureRepeated(false)
        , __pShaderProgram(null)
+       , __findItemInQueue(true)
 {
        memset(extraSurfaceOpacity, 1.0, sizeof(float)*EXTRA_SURFACE_MAX);
        memset(__pExtraSurfaceList, null, sizeof(VisualElementSurface* )*EXTRA_SURFACE_MAX);
@@ -636,7 +637,7 @@ _GlNode::SyncStatus(VisualElementSurface* pSurface, _VisualElementImpl& element)
                        __pFilter = new (std::nothrow) VisualElementFilter(*pFilter);
                }
 
-               __isFilterEnabled = true;
+               __useFilter = true;
        }
        else
        {
@@ -764,6 +765,15 @@ _GlNode::SyncStatus(VisualElementSurface* pSurface, _VisualElementImpl& element)
                }
        }
 
+       if (__pMesh || __useTransform || __useStencil || __pFilter)
+       {
+               __findItemInQueue = false;
+       }
+       else
+       {
+               __findItemInQueue = true;
+       }
+
        __syncNeeded = false;
 
        return E_SUCCESS;
index 140be3c..9abc70d 100644 (file)
@@ -115,7 +115,7 @@ private:
        Material* __pMaterial;
 
        VisualElementFilter* __pFilter;
-       bool __isFilterEnabled;
+       bool __useFilter;
 
        bool __alphaUpdated;
        bool __extraSurfaceUpdated[EXTRA_SURFACE_MAX];
@@ -123,6 +123,8 @@ private:
 
        ShaderProgram* __pShaderProgram;
 
+       bool __findItemInQueue;
+
        friend class _INativeNode;
        friend class _VeDebug;
        friend class _VisualElementImpl;
index 52233f0..f21f575 100644 (file)
@@ -425,11 +425,16 @@ _GlRenderManager::_RenderObject::SetObject(_GlNode* pNode, bool useStencil, unsi
        }
 #endif
 
-       if (pNode->__pFilter && pNode->__isFilterEnabled)
+       if (pNode->__pFilter && pNode->__useFilter)
        {
-               shaderType |= SHADER_TYPE_BLUR;
+               _VisualElementFilterImpl* pFilterImpl = _VisualElementFilterImpl::GetInstance(*pNode->__pFilter);
 
-               __pFilter = pNode->__pFilter;
+               if (pFilterImpl->IsEnabled())
+               {
+                       shaderType |= SHADER_TYPE_BLUR;
+
+                       __pFilter = pNode->__pFilter;
+               }
        }
 
        if (likely(!pNode->__pMesh))
@@ -1022,7 +1027,7 @@ _GlRenderManager::FindRenderObject(_GlNode* pNode)
                return -1;
        }
 
-       if (unlikely(__pRenderQueue[__queueCount - 1].__isMesh || pNode->__pMesh || pNode->__useTransform || pNode->__useStencil || pNode->__pFilter))
+       if (unlikely(__pRenderQueue[__queueCount - 1].__isMesh || !pNode->__findItemInQueue))
        {
                return -1;
        }
@@ -1300,7 +1305,7 @@ _GlRenderManager::FlushRenderQueue(void)
                        {
                                _VisualElementFilterImpl* pFilterImpl = _VisualElementFilterImpl::GetInstance(*__pRenderQueue[i].__pFilter);
 
-                               glUniform1i(glGetUniformLocation(pProgramImpl->__program, "u_blurSize"), pFilterImpl->__radius);
+                               glUniform1i(glGetUniformLocation(pProgramImpl->__program, "u_blurSize"), pFilterImpl->__kernelSize);
                                glUniform1i(glGetUniformLocation(pProgramImpl->__program, "u_horizontalPass"), pFilterImpl->__isFirstPass ? 1 : 0);
                                glUniform1f(glGetUniformLocation(pProgramImpl->__program, "u_sigma"), pFilterImpl->__sigma);
                                glUniform2f(glGetUniformLocation(pProgramImpl->__program, "u_texcoordOffset"), 1.0f / __pRenderQueue[i].__pSurfaceInfo->width, 1.0f / __pRenderQueue[i].__pSurfaceInfo->height);
@@ -1612,7 +1617,7 @@ _GlRenderManager::CompositeNode(VisualElement* pRenderObject, Tizen::Base::Colle
                                __pGlContext->BindFramebuffer(pRenderTextureInfo);
                                __needClear = true;
 
-                               pNode->__isFilterEnabled = false;
+                               pNode->__useFilter = false;
 
                                EnqueueRenderObject(pNode, false, 0, true);
 
@@ -1620,7 +1625,7 @@ _GlRenderManager::CompositeNode(VisualElement* pRenderObject, Tizen::Base::Colle
 
                                __pGlContext->BindFramebuffer(null);            // TODO: restore previous framebuffer
 
-                               pNode->__isFilterEnabled = true;
+                               pNode->__useFilter = true;
 
                                // for next rendering
                                useTempNode = true;
@@ -1647,7 +1652,7 @@ _GlRenderManager::CompositeNode(VisualElement* pRenderObject, Tizen::Base::Colle
                                        __pTempNode->__childrenCount = pNode->__childrenCount;
                                        __pTempNode->__opacity = pNode->__opacity;
                                        __pTempNode->__pFilter = pNode->__pFilter;
-                                       __pTempNode->__isFilterEnabled = pNode->__isFilterEnabled;
+                                       __pTempNode->__useFilter = pNode->__useFilter;
                                        __pTempNode->__textureId = textureId;
                                        __pTempNode->__pSurface = pSurface;
 
@@ -1677,7 +1682,7 @@ _GlRenderManager::CompositeNode(VisualElement* pRenderObject, Tizen::Base::Colle
                                __pTempNode->__childrenCount = pNode->__childrenCount;
                                __pTempNode->__opacity = pNode->__opacity;
                                __pTempNode->__pFilter = pNode->__pFilter;
-                               __pTempNode->__isFilterEnabled = pNode->__isFilterEnabled;
+                               __pTempNode->__useFilter = pNode->__useFilter;
                                __pTempNode->__textureId = textureId;
                                __pTempNode->__pSurface = pSurface;
 
index e6d0845..ab7049e 100644 (file)
@@ -39,8 +39,9 @@ _VisualElementFilterImpl::_VisualElementFilterImpl(void)
        , __size()
        , __pInternalSurface(null)
        , __pRenderSurface(null)
-       , __radius(9.0f)        // test
-       , __sigma(4.0f)
+       , __enabled(true)
+       , __kernelSize(0.0f)
+       , __sigma(0.0f)
 {
 }
 
@@ -85,6 +86,39 @@ _VisualElementFilterImpl::GetType(void) const
        return __type;
 }
 
+void
+_VisualElementFilterImpl::SetEnabled(bool enabled)
+{
+       __enabled = enabled;
+}
+
+bool
+_VisualElementFilterImpl::IsEnabled(void) const
+{
+       return __enabled;
+}
+
+result
+_VisualElementFilterImpl::SetKernelSize(float kernelSize)
+{
+       if (kernelSize < 1.0f)
+       {
+               return E_INVALID_ARG;
+       }
+
+       __kernelSize = kernelSize;
+
+       __sigma = __kernelSize / 2;
+
+       return E_SUCCESS;
+}
+
+float
+_VisualElementFilterImpl::GetKernelSize(void)
+{
+       return __kernelSize;
+}
+
 bool
 _VisualElementFilterImpl::Prepare(const _NativeLayer& layer, const Tizen::Graphics::Dimension& size, bool needRenderSurface)
 {
index cb2d7bd..199edce 100644 (file)
@@ -46,6 +46,12 @@ public:
        void SetType(VisualElementFilter::FilterType filterType);
        VisualElementFilter::FilterType GetType(void) const;
 
+       void SetEnabled(bool enabled);
+       bool IsEnabled(void) const;
+
+       result SetKernelSize(float kernelSize);
+       float GetKernelSize(void);
+
        bool Prepare(const _NativeLayer& layer, const Tizen::Graphics::Dimension& size, bool needRenderSurface);
 
 public:
@@ -64,7 +70,9 @@ private:
        VisualElementSurface* __pInternalSurface;
        VisualElementSurface* __pRenderSurface;
 
-       float __radius;
+       bool __enabled;
+
+       float __kernelSize;
        float __sigma;
 
        friend class _GlRenderManager;
index fb51187..c764ee2 100644 (file)
@@ -8919,6 +8919,8 @@ _VisualElementImpl::SetFilter(VisualElementFilter* pFilter)
                        pFilterImpl->Prepare(*pRoot->GetNativeLayer(), Dimension(__bounds.width, __bounds.height), false);
                }
        }
+
+       return E_SUCCESS;
 }
 
 VisualElementFilter*