From ecdd8c27c788550e913edd4e749ca2db0941e168 Mon Sep 17 00:00:00 2001 From: HeeJu Kang Date: Sun, 30 Dec 2012 17:28:38 +0900 Subject: [PATCH] Fixed pixmap Change-Id: Ica5d3173134d3f8b002c07fde694dada6cefe1e7 Signed-off-by: HeeJu Kang --- packaging/osp-shell.spec | 2 +- src/CMakeLists.txt | 2 +- src/FShell_LiveboxPopupView.cpp | 98 +++++++++++++++++++++++++++++++++++++++ src/FShell_LiveboxPopupView.h | 13 ++++++ src/FShell_LiveboxView.cpp | 75 +++++++++++++++++++++++++++++- src/FShell_LiveboxView.h | 15 ++++++ src/FShell_LiveboxViewManager.cpp | 90 +++++++++++++++++++++++++++++++++-- src/FShell_LiveboxViewManager.h | 2 + 8 files changed, 288 insertions(+), 9 deletions(-) diff --git a/packaging/osp-shell.spec b/packaging/osp-shell.spec index 56217e8..f0218c1 100644 --- a/packaging/osp-shell.spec +++ b/packaging/osp-shell.spec @@ -16,6 +16,7 @@ BuildRequires: pkgconfig(osp-appfw) BuildRequires: pkgconfig(osp-uifw) BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(notification) BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(pkgmgr) @@ -23,7 +24,6 @@ BuildRequires: pkgconfig(minicontrol-provider) BuildRequires: pkgconfig(x11) BuildRequires: pkgconfig(xext) BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(ail) BuildRequires: pkgconfig(provider) BuildRequires: pkgconfig(livebox-viewer) BuildRequires: pkgconfig(livebox-service) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a4e86b3..4658b6a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,6 +121,7 @@ TARGET_LINK_LIBRARIES(${this_target} "-lecore" ) TARGET_LINK_LIBRARIES(${this_target} "-levas" ) TARGET_LINK_LIBRARIES(${this_target} "-leina" ) TARGET_LINK_LIBRARIES(${this_target} "-lecore_evas" ) +TARGET_LINK_LIBRARIES(${this_target} "-lelementary" ) TARGET_LINK_LIBRARIES(${this_target} "-lminicontrol-provider" ) #TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-runtime-info") TARGET_LINK_LIBRARIES(${this_target} "-lX11" ) @@ -130,7 +131,6 @@ TARGET_LINK_LIBRARIES(${this_target} "-llivebox-viewer" ) TARGET_LINK_LIBRARIES(${this_target} "-llivebox-service" ) TARGET_LINK_LIBRARIES(${this_target} "-lprovider" ) TARGET_LINK_LIBRARIES(${this_target} "-lshortcut" ) -TARGET_LINK_LIBRARIES(${this_target} "-lail" ) SET_TARGET_PROPERTIES(${this_target} PROPERTIES diff --git a/src/FShell_LiveboxPopupView.cpp b/src/FShell_LiveboxPopupView.cpp index b0bcfe7..0fdeb4d 100644 --- a/src/FShell_LiveboxPopupView.cpp +++ b/src/FShell_LiveboxPopupView.cpp @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -40,7 +41,10 @@ #include "FShell_LiveboxView.h" #include "FShell_ILiveboxPopupViewEventListener.h" #include "FUi_ControlManager.h" +#include "FUiAnim_EflNode.h" #include "FUiAnim_VisualElement.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" using namespace std; using namespace Tizen::Base; @@ -62,6 +66,7 @@ _LiveboxPopupView::_LiveboxPopupView(_LiveboxView& liveBoxView) , __pLiveboxView(&liveBoxView) , __pLiveboxPopupViewEvent(_LiveboxPopupViewEvent::CreateInstanceN(*this)) , __firstUpdated(false) + , __pixmap(-1) { } @@ -266,6 +271,24 @@ _LiveboxPopupView::OnAttached(void) { if (__firstUpdated) { + if (__pPixmapObject) + { + _VisualElement* pVisualElement = GetVisualElement(); + SysTryReturn(NID_UI_CTRL, pVisualElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _EflNode* pEflNode = dynamic_cast<_EflNode*>(pVisualElement->GetNativeNode()); + SysTryReturn(NID_UI_CTRL, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Evas_Object* pSmartObject = (Evas_Object*)pEflNode->GetGroupContainer(); + SysTryReturn(NID_UI_CTRL, pSmartObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Evas* pEvas = evas_object_evas_get(pSmartObject); + SysTryReturn(NID_UI_CTRL, pEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEflNode->AddNativeSmartObject(*pVisualElement, __pPixmapObject.get()); + + } + PlayAnimation(true); } @@ -390,6 +413,81 @@ _LiveboxPopupView::OnLiveboxUpdated(const Tizen::Graphics::Bitmap& bitmap, const } void +_LiveboxPopupView::OnLiveboxUpdated(int pixmap) +{ + int x = 0; + int y = 0; + int width = 0; + int height = 0; + + ecore_x_pixmap_geometry_get(pixmap, &x, &y, &width, &height); + + if (__pixmap != pixmap ) + { + SetBackgroundColor(Color(0, 0, 0, 0)); + + _VisualElement* pVisualElement = GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _EflNode* pEflNode = dynamic_cast<_EflNode*>(pVisualElement->GetNativeNode()); + SysTryReturnVoidResult(NID_UI_CTRL, pEflNode, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Evas_Object* pSmartObject = (Evas_Object*)pEflNode->GetGroupContainer(); + SysTryReturnVoidResult(NID_UI_CTRL, pSmartObject, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Evas* pEvas = evas_object_evas_get(pSmartObject); + SysTryReturnVoidResult(NID_UI_CTRL, pEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + __pPixmapObject.reset(evas_object_image_filled_add(pEvas)); + SysTryReturnVoidResult(NID_UI_CTRL, __pPixmapObject.get(), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pEflNode->AddNativeSmartObject(*pVisualElement, __pPixmapObject.get()); + + evas_object_image_size_set(__pPixmapObject.get(), width, height); + evas_object_image_colorspace_set(__pPixmapObject.get(), EVAS_COLORSPACE_ARGB8888); + evas_object_image_alpha_set(__pPixmapObject.get(), EINA_TRUE); + + Rectangle absoluteBounds = GetAbsoluteBounds(); + + evas_object_move(__pPixmapObject.get(), absoluteBounds.x, absoluteBounds.y); + evas_object_show(__pPixmapObject.get()); + + Evas_Native_Surface surface; + + surface.version = EVAS_NATIVE_SURFACE_VERSION; + surface.type = EVAS_NATIVE_SURFACE_X11; + surface.data.x11.visual = ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get()); + surface.data.x11.pixmap = pixmap; + + evas_object_image_native_surface_set(__pPixmapObject.get(), &surface); + + SysLog(NID_UI_CTRL, "[0x%x]", surface.data.x11.pixmap); + } + + SysLog(NID_UI_CTRL, "[%d %d %d %d]", x, y, width, height); + + evas_object_image_size_set(__pPixmapObject.get(), width, height); + evas_object_image_pixels_dirty_set(__pPixmapObject.get(), EINA_TRUE); + evas_object_image_fill_set(__pPixmapObject.get(), 0, 0, width, height); + evas_object_image_data_update_add(__pPixmapObject.get(), 0, 0, width, height); + evas_object_resize(__pPixmapObject.get(), width, height); + + Dimension size(width, height); + if (size != GetSize()) + { + SetPopupBounds(size); + } + + if (!__firstUpdated) + { + PlayAnimation(true); + __firstUpdated = true; + } + + __pixmap = pixmap; +} + +void _LiveboxPopupView::OnLiveboxPopupCreated(struct livebox *pLivebox, int ret, void* pData) { SysTryReturnVoidResult(NID_UI_CTRL, pLivebox, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); diff --git a/src/FShell_LiveboxPopupView.h b/src/FShell_LiveboxPopupView.h index ebff7d4..11a9cfa 100644 --- a/src/FShell_LiveboxPopupView.h +++ b/src/FShell_LiveboxPopupView.h @@ -24,6 +24,7 @@ #define _FSHELL_INTERNAL_LIVEBOX_POPUP_VIEW_H_ #include +#include #include #include "FUi_Window.h" @@ -97,6 +98,7 @@ private: virtual void OnDraw(void); void OnLiveboxUpdated(const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Dimension& size); + void OnLiveboxUpdated(int pixmap); static void OnLiveboxPopupCreated(struct livebox *pLivebox, int ret, void* pData); static void OnLiveboxPopupDestroyed(struct livebox *pLivebox, int ret, void* pData); @@ -108,6 +110,17 @@ private: _LiveboxView* __pLiveboxView; std::unique_ptr<_LiveboxPopupViewEvent> __pLiveboxPopupViewEvent; bool __firstUpdated; + + struct _EvasObjectDeleter + { + void operator()(Evas_Object* pEvasObject) + { + evas_object_del(pEvasObject); + } + }; + + std::unique_ptr __pPixmapObject; + int __pixmap; }; // _LiveboxPopupView }} // Tizen::Shell diff --git a/src/FShell_LiveboxView.cpp b/src/FShell_LiveboxView.cpp index 1b9e9fc..d4b901d 100644 --- a/src/FShell_LiveboxView.cpp +++ b/src/FShell_LiveboxView.cpp @@ -20,7 +20,7 @@ */ #include -#include +#include #include #include #include @@ -37,7 +37,9 @@ #include "FShell_LiveboxViewPresenter.h" #include "FShell_LiveboxPopupView.h" #include "FShell_LiveboxViewManager.h" -#include "FUiAnim_VisualElement.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" using namespace std; using namespace Tizen::App; @@ -59,6 +61,7 @@ _LiveboxView::_LiveboxView(void) , __pLiveboxViewManager(null) , __resizeFromRemote(false) , __updated(false) + , __pixmap(-1) { __pLiveboxViewManager = _LiveboxViewManager::GetInstance(); SysTryReturnVoidResult(NID_UI_CTRL, __pLiveboxViewManager, E_SYSTEM, "[E_SYSTEM] A system error occurred."); @@ -403,4 +406,72 @@ _LiveboxView::OnLiveboxUpdated(const Bitmap& bitmap, const Dimension& size) Invalidate(false); } +void +_LiveboxView::OnLiveboxUpdated(int pixmap) +{ + int x = 0; + int y = 0; + int width = 0; + int height = 0; + + ecore_x_pixmap_geometry_get(pixmap, &x, &y, &width, &height); + + if (__pixmap != pixmap ) + { + SetBackgroundColor(Color(0, 0, 0, 0)); + + _VisualElement* pVisualElement = GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _EflNode* pEflNode = dynamic_cast<_EflNode*>(pVisualElement->GetNativeNode()); + SysTryReturnVoidResult(NID_UI_CTRL, pEflNode, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Evas_Object* pSmartObject = (Evas_Object*)pEflNode->GetGroupContainer(); + SysTryReturnVoidResult(NID_UI_CTRL, pSmartObject, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Evas* pEvas = evas_object_evas_get(pSmartObject); + SysTryReturnVoidResult(NID_UI_CTRL, pEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + __pPixmapObject.reset(evas_object_image_filled_add(pEvas)); + SysTryReturnVoidResult(NID_UI_CTRL, __pPixmapObject.get(), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pEflNode->AddNativeSmartObject(*pVisualElement, __pPixmapObject.get()); + + evas_object_image_size_set(__pPixmapObject.get(), width, height); + evas_object_image_colorspace_set(__pPixmapObject.get(), EVAS_COLORSPACE_ARGB8888); + evas_object_image_alpha_set(__pPixmapObject.get(), EINA_TRUE); + + Rectangle absoluteBounds = GetAbsoluteBounds(); + + evas_object_move(__pPixmapObject.get(), absoluteBounds.x, absoluteBounds.y); + evas_object_show(__pPixmapObject.get()); + + Evas_Native_Surface surface; + + surface.version = EVAS_NATIVE_SURFACE_VERSION; + surface.type = EVAS_NATIVE_SURFACE_X11; + surface.data.x11.visual = ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get()); + surface.data.x11.pixmap = pixmap; + + evas_object_image_native_surface_set(__pPixmapObject.get(), &surface); + + SysLog(NID_UI_CTRL, "[0x%x]", surface.data.x11.pixmap); + } + + SysLog(NID_UI_CTRL, "[%d %d %d %d]", x, y, width, height); + + evas_object_image_size_set(__pPixmapObject.get(), width, height); + evas_object_image_pixels_dirty_set(__pPixmapObject.get(), EINA_TRUE); + evas_object_image_fill_set(__pPixmapObject.get(), 0, 0, width, height); + evas_object_image_data_update_add(__pPixmapObject.get(), 0, 0, width, height); + evas_object_resize(__pPixmapObject.get(), width, height); + + __resizeFromRemote = true; + SetSize(Dimension(width, height)); + __resizeFromRemote = false; + __updated = true; + + __pixmap = pixmap; +} + }} // Tizen::Shell diff --git a/src/FShell_LiveboxView.h b/src/FShell_LiveboxView.h index d030206..0eb36e4 100644 --- a/src/FShell_LiveboxView.h +++ b/src/FShell_LiveboxView.h @@ -24,8 +24,10 @@ #define _FSHELL_INTERNAL_LIVEBOX_VIEW_H_ #include +#include #include "FUi_Control.h" #include "FUi_ITouchFlickGestureEventListener.h" +#include "FUiAnim_VisualElement.h" #include "FShell_ILiveboxPopupViewEventListener.h" namespace Tizen { namespace Base @@ -98,6 +100,7 @@ private: virtual void OnDraw(void); void OnLiveboxUpdated(const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Dimension& size); + void OnLiveboxUpdated(int pixmap); private: std::unique_ptr<_LiveboxViewPresenter> __pLiveboxViewPresenter; @@ -111,6 +114,18 @@ private: std::unique_ptr __pTouchFlickGestureDetector; bool __resizeFromRemote; bool __updated; + + struct _EvasObjectDeleter + { + void operator()(Evas_Object* pEvasObject) + { + evas_object_del(pEvasObject); + } + }; + + std::unique_ptr __pPixmapObject; + + int __pixmap; }; // _LiveboxView }} // Tizen::Shell diff --git a/src/FShell_LiveboxViewManager.cpp b/src/FShell_LiveboxViewManager.cpp index 3185bda..1e6c437 100644 --- a/src/FShell_LiveboxViewManager.cpp +++ b/src/FShell_LiveboxViewManager.cpp @@ -21,6 +21,11 @@ #include #include +#include +extern "C" +{ +#include +} #include #include #include @@ -142,6 +147,8 @@ _LiveboxViewManager::GetLiveboxSize(livebox* pLivebox) const int type = livebox_size(pLivebox); livebox_service_get_size(type, &width, &height); + SysLog(NID_UI_CTRL, "size [%d %d]", width, height); + return Dimension(width, height); } @@ -155,6 +162,8 @@ _LiveboxViewManager::GetLiveboxPopupSize(livebox* pLivebox) const livebox_get_pdsize(pLivebox, &width, &height); + SysLog(NID_UI_CTRL, "size [%d %d]", width, height); + return Dimension(width, height); } @@ -170,6 +179,7 @@ _LiveboxViewManager::SetLiveboxSize(const _LiveboxView& liveboxView, const Dimen } _LiveboxViewManager::_LiveboxViewManager(void) + : __glMode(false) { // _LogicalResolution sourceResolution = RESOLUTION_LOGICAL_720; // _PhysicalResolution destResolution = _CoordinateSystem::GetInstance()->GetPhysicalResolution(); @@ -190,6 +200,7 @@ _LiveboxViewManager::_LiveboxViewManager(void) SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); __pViewMap = move(pViewMap); + __glMode = IsGlMode(); // r = _CreateCoordinateTransformer(__pCoordinateTransformer, sourceResolution, BASE_SCREEN_SIZE_NORMAL, destResolution, BASE_SCREEN_SIZE_NORMAL); // SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); @@ -283,6 +294,37 @@ _LiveboxViewManager::GetBitmapN(void* pBuffer, const Dimension& size) const return pBitmap.release(); } +bool +_LiveboxViewManager::IsGlMode(void) const +{ + int mode = 0; + bool glMode = false; + String preferred(elm_config_preferred_engine_get()); + if(preferred == L"opengl_x11") + { + glMode = true; + mode = 1; + } + else if(preferred == L"software_x11") + { + glMode = false; + mode = 2; + } + else + { + String engineConfig(elm_config_engine_get()); + if(engineConfig == L"opengl_x11") + { + glMode = true; + mode = 3; + } + } + + SysLog(NID_UI_CTRL, "[%d %d]", mode, glMode); + + return glMode; +} + void _LiveboxViewManager::OnLiveboxCreated(livebox* pLivebox) { @@ -311,12 +353,13 @@ _LiveboxViewManager::OnLiveboxUpdated(livebox* pLivebox) break; case LB_TYPE_BUFFER: - case LB_TYPE_PIXMAP: { void* pBuffer = livebox_acquire_fb(pLivebox); SysTryReturnVoidResult(NID_UI_CTRL, pBuffer, E_SYSTEM, "[E_SYSTEM] A system error occured."); Dimension sourceSize = GetLiveboxSize(pLivebox); + SysLog(NID_UI_CTRL, "size [%d %d]", sourceSize.width, sourceSize.height); + unique_ptr pBitmap(GetBitmapN(pBuffer, sourceSize)); SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); @@ -326,7 +369,26 @@ _LiveboxViewManager::OnLiveboxUpdated(livebox* pLivebox) } break; - case LB_TYPE_TEXT: + case LB_TYPE_PIXMAP: + if (__glMode) + { + pLiveboxView->OnLiveboxUpdated(livebox_lb_pixmap(pLivebox)); + } + else + { + void* pBuffer = livebox_acquire_fb(pLivebox); + SysTryReturnVoidResult(NID_UI_CTRL, pBuffer, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + Dimension sourceSize = GetLiveboxSize(pLivebox); + SysLog(NID_UI_CTRL, "size [%d %d]", sourceSize.width, sourceSize.height); + + unique_ptr pBitmap(GetBitmapN(pBuffer, sourceSize)); + SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pLiveboxView->OnLiveboxUpdated(*pBitmap.get(), sourceSize); + livebox_release_fb(pBuffer); + pBitmap.release(); + } break; default: @@ -359,22 +421,40 @@ _LiveboxViewManager::OnLiveboxPopupUpdated(livebox* pLivebox) switch (type) { - case PD_TYPE_TEXT: + case PD_TYPE_BUFFER: + { + void* pBuffer = livebox_acquire_pdfb(pLivebox); + SysTryReturnVoidResult(NID_UI_CTRL, pBuffer, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + Dimension sourceSize = GetLiveboxPopupSize(pLivebox); + + unique_ptr pBitmap(GetBitmapN(pBuffer, sourceSize)); + SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pLiveboxPopupView->OnLiveboxUpdated(*pBitmap.get(), sourceSize); + livebox_release_pdfb(pBuffer); + pBitmap.release(); + } break; - case PD_TYPE_BUFFER: case PD_TYPE_PIXMAP: + if (__glMode) + { + pLiveboxPopupView->OnLiveboxUpdated(livebox_pd_pixmap(pLivebox)); + } + else { void* pBuffer = livebox_acquire_pdfb(pLivebox); SysTryReturnVoidResult(NID_UI_CTRL, pBuffer, E_SYSTEM, "[E_SYSTEM] A system error occured."); Dimension sourceSize = GetLiveboxPopupSize(pLivebox); + unique_ptr pBitmap(GetBitmapN(pBuffer, sourceSize)); SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); pLiveboxPopupView->OnLiveboxUpdated(*pBitmap.get(), sourceSize); livebox_release_pdfb(pBuffer); - pBitmap.release(); + pBitmap.release(); } break; diff --git a/src/FShell_LiveboxViewManager.h b/src/FShell_LiveboxViewManager.h index 2373b26..e842a51 100644 --- a/src/FShell_LiveboxViewManager.h +++ b/src/FShell_LiveboxViewManager.h @@ -76,6 +76,7 @@ private: Tizen::Media::MediaPixelFormat GetPixelFormat(Tizen::Graphics::BitmapPixelFormat format) const; Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& fileName) const; Tizen::Graphics::Bitmap* GetBitmapN(void* pBuffer, const Tizen::Graphics::Dimension& size) const; + bool IsGlMode(void) const; void OnLiveboxCreated(livebox* pLivebox); void OnLiveboxUpdated(livebox* pLivebox); @@ -115,6 +116,7 @@ private: std::unique_ptr __pCoordinateTransformer; std::unique_ptr __eventHandler; std::unique_ptr __faultEventHandler; + bool __glMode; }; }} // Tizen::Shell -- 2.7.4