Simple test application for ui-core.so
authorSeonhyungLee <sh2644.lee@samsung.com>
Fri, 23 Aug 2013 06:41:54 +0000 (09:41 +0300)
committerSeonhyungLee <sh2644.lee@samsung.com>
Fri, 23 Aug 2013 06:42:23 +0000 (09:42 +0300)
Change-Id: Idb14c8b19fd7301ef44429584709381f4d0bf6f0

src/ui-core/CMakeLists.txt
src/ui-core/example/CMakeLists.txt [new file with mode: 0644]
src/ui-core/example/TestApplication.cpp [new file with mode: 0644]
src/ui-core/inc/UcInterface.h
src/ui-core/src/CMakeLists.txt
src/ui-core/src/UcInterface.cpp
src/ui/animations/FUiAnim_DisplayManager.cpp
src/ui/animations/FUiAnim_Looper.cpp
src/ui/animations/FUiAnim_NativeLayer.cpp
src/ui/animations/platform/FUiAnim_X11Window.cpp
src/ui/inc/FUiAnim_Looper.h

index 72d5c5c..0f5066a 100755 (executable)
@@ -26,3 +26,4 @@ LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH}/mesa)
 ENDIF(_WIN32)
 
 ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(example)
diff --git a/src/ui-core/example/CMakeLists.txt b/src/ui-core/example/CMakeLists.txt
new file mode 100644 (file)
index 0000000..51bb5ba
--- /dev/null
@@ -0,0 +1,14 @@
+SET(this_target test-application)
+
+INCLUDE_DIRECTORIES(
+    ../inc
+)
+
+SET(${this_target}_SOURCE_FILES
+    TestApplication.cpp
+)
+
+SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+ADD_EXECUTABLE(${this_target} ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} "-lui-core")
diff --git a/src/ui-core/example/TestApplication.cpp b/src/ui-core/example/TestApplication.cpp
new file mode 100644 (file)
index 0000000..29c62a8
--- /dev/null
@@ -0,0 +1,17 @@
+#include <UcInterface.h>
+
+int main(void)
+{
+       InitLibrary(0, 480, 800);
+       CreateVisualElement(0, 0, 100, 100);
+
+       for (int i = 0; ;i++)
+       {
+               if (i == 1000)
+               {
+                       IterateMainLoop();
+               }
+       }
+
+       return 0;
+}
index 4c901d1..0542175 100644 (file)
@@ -7,6 +7,8 @@ JNIEXPORT void JNICALL ResizeWindow(int width, int height);
 JNIEXPORT void JNICALL UpdateScreen(float delayedTime);
 #else
 void InitLibrary(int windowHandle, int width, int height);
+void CreateVisualElement(int x, int y, int width, int height);
 void ResizeWindow(int width, int height);
 void UpdateScreen(float delayedTime);
+void IterateMainLoop(void);
 #endif
index 08701d3..0f148a5 100755 (executable)
@@ -11,8 +11,6 @@ INCLUDE_DIRECTORIES(
     ${UIFW_DIRECTORY}/src/ui/inc
     ${UIFW_DIRECTORY}/src/ui/animations
     ${RSA_DEV_DIRECTORY}/external/boost
-    /usr/include/glib-2.0/
-    /usr/lib/i386-linux-gnu/glib-2.0/include
 )
 ELSEIF(_WIN32)
 INCLUDE_DIRECTORIES(
index 31a0509..cb5bf93 100644 (file)
@@ -1,17 +1,58 @@
 #include "UcInterface.h"
 #include "FUiAnim_DisplayManager.h"
+#include "FUiAnim_AnimationManager.h"
+#include "FUiAnim_RootVisualElement.h"
+#include "FUiAnimVisualElement.h"
+#include "FUiAnimVisualElementSurface.h"
 #include "FUiAnim_NativeLayer.h"
+#include "FGrpFloatRectangle.h"
+#include "FGrpBufferInfo.h"
+#include "FUiAnimDisplayContext.h"
+#include "FUiAnim_DisplayContextImpl.h"
+#include "FUiAnim_Looper.h"
+#include "FUiAnim_NativeWindow.h"
 
+using namespace Tizen::Graphics;
 using namespace Tizen::Ui::Animations;
 
 _NativeLayer* pNativeLayer = null;
+DisplayContext* pDisplayContext = null;
 
 void InitLibrary(int windowHandle, int width, int height)
 {
-    _DisplayManager::CreateInstance();
+#ifdef LINUX
+       _DisplayManager::CreateInstance();
+       _AnimationManager::CreateInstance();
 
     pNativeLayer = _NativeLayer::CreateInstanceN();
-    pNativeLayer->SetShowState(true);
+       pNativeLayer->SetShowState(true);
+#elif _WIN32
+#endif
+       pDisplayContext = _DisplayContextImpl::CreatePublicInstance(*pNativeLayer);
+}
+
+void CreateVisualElement(int x, int y, int width, int height)
+{
+       _RootVisualElement* pRoot = pNativeLayer->GetRootVisualElement();
+
+       VisualElement* pElement = new VisualElement();
+       pElement->Construct();
+       pElement->SetShowState(true);
+       pElement->SetBounds(FloatRectangle(x, y, width, height));
+       pRoot->AttachChild(pElement);
+
+       //VisualElementSurface* pSurface = pElement->GetSurfaceN();
+       VisualElementSurface* pSurface = new VisualElementSurface();
+       pSurface->Construct(*pDisplayContext, FloatDimension(100, 100));
+
+       BufferInfo bufferInfo;
+       pSurface->GetBufferInfo(bufferInfo);
+
+       memset(bufferInfo.pPixels, 0xFF, width * height * 4);
+
+       pElement->SetSurface(pSurface);
+
+       pElement->Flush();
 }
 
 void ResizeWindow(int width, int height)
@@ -23,3 +64,17 @@ void UpdateScreen(float delayedTime)
 {
     pNativeLayer->Flush();
 }
+
+
+void IterateMainLoop()
+{
+       _Looper* pLooper = _Looper::GetInstance();
+
+       _RawEvent rawEvent;
+
+       if(pLooper->GetRawEvent(rawEvent, -1) != 0)
+       {
+               pLooper->DispatchRawEvent(rawEvent);
+               printf("OnMainLoop:event(%d) \n",rawEvent.type);
+       }
+}
index cd5e544..9c1913e 100644 (file)
@@ -38,7 +38,7 @@
 #include "FUiAnim_GlRenderManager.h"
 #include "FUiAnim_VisualElementSurfaceManager.h"
 
-#ifndef BUILD_UI_CORE
+#ifndef _WIN32
 #include "FUiAnim_Looper.h"
 #endif
 
@@ -103,7 +103,7 @@ _DisplayManager::CreateInstance(void)
                return E_OUT_OF_MEMORY;
        }
 
-#ifndef BUILD_UI_CORE
+#ifndef _WIN32
        _Looper::CreateInstance();
 #endif
        _NativeWindow::WindowSystemInit();
@@ -111,10 +111,9 @@ _DisplayManager::CreateInstance(void)
 
        _GlRenderManager::CreateInstance();
 //     _GlRenderManager::GetInstance()->SyncRenderManager();
-#ifndef BUILD_UI_CORE
+#ifndef _WIN32
        _Looper::GetInstance()->AddWakeupEvent();
 #endif
-
        return E_SUCCESS;
 }
 
@@ -125,7 +124,7 @@ _DisplayManager::ReleaseInstance(void)
 
        delete __pInstance;
        __pInstance = null;
-#ifndef BUILD_UI_CORE
+#ifndef _WIN32
        _Looper::ReleaseInstance();
 #endif
        return E_SUCCESS;
@@ -179,7 +178,7 @@ _DisplayManager::GetLayerById(unsigned long id) const
 void
 _DisplayManager::AddWakeUpEvent(void)
 {
-#ifndef BUILD_UI_CORE
+#ifndef _WIN32
 //     _AnimationManager::GetInstance()->SetAnimatorEnabled(true);
        if(_Looper::GetInstance())
        {
index b0d6e44..1f4dd34 100644 (file)
@@ -130,9 +130,11 @@ _Looper::_Looper(void)
        , __epollFD(-1)
        , __epollFDCount(0)
        , __eventLock()
+#ifndef BUILD_UI_CORE
        , __pGlibCondition(null)
        , __pGlibFDs(null)
        , __glibFDBufferCount(G_POLL_INITIAL_FD_SIZE)
+#endif
 {
        SysAssertf(!__pLooper, "main loop was created already");
        __pLooper = this;
@@ -152,8 +154,9 @@ _Looper::_Looper(void)
 #else
        __epollFD = epoll_create(10);
        SysAssertf(__epollFD >= 0, "epoll creation failed");
-
+#ifndef BUILD_UI_CORE
        __pGlibFDs =  new (std::nothrow) GPollFD[G_POLL_INITIAL_FD_SIZE];
+#endif
 
 #endif
 
@@ -181,7 +184,7 @@ _Looper::~_Looper(void)
 
                __eventProducers.RemoveAt(0);
        }
-
+#ifndef BUILD_UI_CORE
        if (__pGlibCondition)
        {
                g_cond_free(__pGlibCondition);
@@ -192,7 +195,7 @@ _Looper::~_Looper(void)
        {
                delete [] __pGlibFDs;
        }
-
+#endif
 #if defined (USE_ECORE_LOOP)
        while (__ecoreFdHandlers.GetCount() > 0)
        {
@@ -525,10 +528,12 @@ _Looper::MonitorEvents(void)
 bool
 _Looper::WaitForEvents(int timeout)
 {
+       int glibFDCount = 0;
+#ifndef BUILD_UI_CORE
        GStaticMutex glibLock = G_STATIC_MUTEX_INIT;
        GMutex *pGlibMutex = g_static_mutex_get_mutex(&glibLock);
        GMainContext *pGlibCtx = g_main_context_default();
-       int ret, glibPriority = 0, glibTimeout = 0, glibFDCount = 0;
+       int glibPriority = 0, glibTimeout = 0   ;
        bool needRelease = true;
 
        if (g_main_context_acquire(pGlibCtx))
@@ -570,6 +575,7 @@ _Looper::WaitForEvents(int timeout)
 
                needRelease = false;
        }
+#endif
 
        struct epoll_event epollEvent[glibFDCount + __epollFDCount];
        memset(&epollEvent, 0, sizeof (epollEvent));
@@ -579,7 +585,7 @@ _Looper::WaitForEvents(int timeout)
                timeout = -1;
        }
 
-       ret = epoll_wait(__epollFD, epollEvent, glibFDCount + __epollFDCount,timeout);
+       int ret = epoll_wait(__epollFD, epollEvent, glibFDCount + __epollFDCount,timeout);
 
        if (ret < 0)
        {
@@ -588,7 +594,7 @@ _Looper::WaitForEvents(int timeout)
 
                return false;
        }
-
+#ifndef BUILD_UI_CORE
        int epollFDCount = ret;
 
        if (likely(glibFDCount > 0))
@@ -625,10 +631,11 @@ _Looper::WaitForEvents(int timeout)
                g_main_context_release(pGlibCtx);
                g_static_mutex_free(&glibLock);
        }
-
+#endif
        return true;
 }
 
+#ifndef BUILD_UI_CORE
 int
 _Looper::GetGlibFDCount(GMainContext* pGlibCtx, int& glibPriority, int& glibTimeout)
 {
@@ -765,6 +772,7 @@ _Looper::RemoveGlibFDFromWaitEvent(int glibFDCount)
 
        return true;
 }
+#endif
 
 }}}            // Tizen::Ui::Animations
 
index 0156fbf..9fffadb 100644 (file)
@@ -87,7 +87,7 @@ _NativeLayer::CreateInstanceN(void)
        return pLayer;
 
 #else
-       _GlLayer* pLayer = new (std::nothrow) _GlLayer;
+       _GlLayer* pLayer = new (std::nothrow) _GlLayer();
        if (pLayer)
        {
                pLayer->Construct();
index fcf746e..efa9925 100644 (file)
@@ -1,4 +1,3 @@
-
 #include <X11/Xutil.h>
 #include <X11/extensions/Xrender.h>
 #include <X11/extensions/sync.h>
@@ -930,7 +929,7 @@ _X11Window::OnBoundsChanging(const Tizen::Graphics::FloatRectangle& newBounds)
 
                XMoveResizeWindow(pDisplay, window, x, y, w, h); // CHECKME: What's the result of this API ?
 
-               XSync(pDisplay,FALSE);
+               XSync(pDisplay,False);
 //             XFlush(pDisplay);       // CHECKME: Why is this needed ???
        }
 }
@@ -1209,7 +1208,7 @@ _X11Window::ProcessEvent(_GlLayer* pLayer, XEvent& xEvent)
 
                PRINT("ProcessEvent :: MapNotify \n");
                __isMapped = true;
-//             _GlRenderManager::GetInstance()->Composite(pLayer);
+               _GlRenderManager::GetInstance()->Composite(pLayer);
                break;
        case UnmapNotify:
                PRINT("ProcessEvent :: UnmapNotify \n");
index ca96e68..340bd87 100644 (file)
@@ -25,7 +25,9 @@
 #ifndef _FUI_ANIM_INTERNAL_LOOPER_H_
 #define _FUI_ANIM_INTERNAL_LOOPER_H_
 
+#ifndef BUILD_UI_CORE
 #include <glib.h>
+#endif
 #include <FBaseColQueueT.h>
 #include <FBaseColArrayListT.h>
 #include <FBaseColHashMapT.h>
@@ -186,11 +188,12 @@ private:
        static result ReleaseInstance(void);
 
        bool WaitForEvents(int timeout);
-
+#ifndef BUILD_UI_CORE
        int GetGlibFDCount(GMainContext* pGlibCtx, int& glibPriority, int& glibTimeout);
        bool AddGlibFDToWaitEvent(int glibFDCount);
        int DispatchGlib(struct epoll_event* pEpollEvent, int& eventCount, GMainContext* pGlibCtx, int& glibPriority, int glibFDCount);
        bool RemoveGlibFDFromWaitEvent(int glibFDCount);
+#endif
 
        EventProducerInfo* GetRawEventProducer(int fd);
        
@@ -216,11 +219,12 @@ private:
        _Mutex __eventLock;
 
        friend class _DisplayManager;
-
+#ifndef BUILD_UI_CORE
        GCond* __pGlibCondition;
        
        GPollFD* __pGlibFDs;
        int __glibFDBufferCount;
+#endif
        
        static const unsigned int G_POLL_INITIAL_FD_SIZE = 128;
        static int __eventType;