From 2baefde535e140977835b57637172571f6925e1a Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Fri, 27 Sep 2024 15:41:29 +0900 Subject: [PATCH] Bind NativeImage constructor with tbm_surface_h and tbm_queue_h Change-Id: I9c4ef546493d5838d40c24fe1a8af1a3fbed084f Signed-off-by: Eunki, Hong --- .../common/tizen-dependency-wrap.cpp | 68 ++++++++---- .../dali-adaptor/capture-wrap.cpp | 32 +----- .../dali-adaptor/dali-adaptor-wrap.cpp | 100 ++---------------- .../dali-adaptor/native-image-queue-wrap.cpp | 4 +- 4 files changed, 64 insertions(+), 140 deletions(-) diff --git a/dali-csharp-binder/common/tizen-dependency-wrap.cpp b/dali-csharp-binder/common/tizen-dependency-wrap.cpp index 7d0ac428..750dd627 100644 --- a/dali-csharp-binder/common/tizen-dependency-wrap.cpp +++ b/dali-csharp-binder/common/tizen-dependency-wrap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -18,7 +18,11 @@ // EXTERNAL INCLUDES #include #include +#include + +// Tizen dependency header #include +#include // INTERNAL INCLUDES #include "common.h" @@ -41,37 +45,59 @@ SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Texture_TbmSurface(tbm_surface_h tb Dali::Any source(tbm_surface); mNativeImageSrc = Dali::NativeImageSource::New(source); mNativeTexture = Dali::Texture::New( *mNativeImageSrc ); - } CALL_CATCH_EXCEPTION(0); + } CALL_CATCH_EXCEPTION(0); jresult = new Dali::Texture((const Dali::Texture &)mNativeTexture); return (void*)jresult; } +struct NativeImageSourcePtrHandle +{ + Dali::NativeImageSourcePtr Ptr; +}; + +SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_NativeImageSource_New_Handle_With_TbmSurface(tbm_surface_h csTbmSurface) +{ + void* jresult; + NativeImageSourcePtrHandle* handle = new NativeImageSourcePtrHandle(); + Dali::Any tbmSurface = (Dali::Any)csTbmSurface; + { + try { + handle->Ptr = NativeImageSource::New(tbmSurface); + } CALL_CATCH_EXCEPTION_WITH_FUNCTION(0, [](NativeImageSourcePtrHandle* ptr){delete ptr;}, handle); + } + jresult = (void *)handle; + return jresult; +} -SWIGEXPORT void SWIGSTDCALL CSharp_Dali_NativeImageSource_SetSource(void* jarg1, tbm_surface_h jarg2) +SWIGEXPORT void SWIGSTDCALL CSharp_Dali_NativeImageSource_SetSource(void* jarg1, tbm_surface_h csTbmSurface) { Dali::NativeImageSource* pImage = (Dali::NativeImageSource*)jarg1; - Dali::Any source = (Dali::Any)jarg2; + Dali::Any tbmSurface = (Dali::Any)csTbmSurface; try { - pImage->SetSource(source); - } - catch (std::out_of_range & e) { - SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); - return; - } - catch (std::exception & e) { - SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); - return; - } - catch (Dali::DaliException e) { - SWIG_CSharpException(SWIG_UnknownError, e.condition); - return; - } - catch (...) { - SWIG_CSharpException(SWIG_UnknownError, "unknown error"); - return; + pImage->SetSource(tbmSurface); + } CALL_CATCH_EXCEPTION(); +} + +struct NativeImageSourceQueuePtrHandle +{ + Dali::NativeImageSourceQueuePtr Ptr; +}; + +SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_NativeImageQueuePtr_New_Handle_With_TbmQueue(tbm_queue_h csTbmQueue) +{ + void* jresult; + NativeImageSourceQueuePtrHandle* queue = new NativeImageSourceQueuePtrHandle(); + Dali::Any tbmQueue = (Dali::Any)csTbmQueue; + { + try { + queue->Ptr = Dali::NativeImageSourceQueue::New(tbmQueue); + } + CALL_CATCH_EXCEPTION_WITH_FUNCTION(0, [](NativeImageSourceQueuePtrHandle* ptr){delete ptr;}, queue); } + jresult = (void *)queue; + return jresult; } #ifdef __cplusplus diff --git a/dali-csharp-binder/dali-adaptor/capture-wrap.cpp b/dali-csharp-binder/dali-adaptor/capture-wrap.cpp index 6861d34b..7f59dacb 100755 --- a/dali-csharp-binder/dali-adaptor/capture-wrap.cpp +++ b/dali-csharp-binder/dali-adaptor/capture-wrap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -381,43 +381,19 @@ struct NativeImageSourcePtrHandle SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Capture_GetNativeImageSource(void* jarg1) { Dali::Capture* arg1 = (Dali::Capture*)jarg1; - NativeImageSourcePtrHandle* handle = new NativeImageSourcePtrHandle(); if(!arg1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "some argument is null", 0); - delete handle; return 0; } + + NativeImageSourcePtrHandle* handle = new NativeImageSourcePtrHandle(); { try { handle->Ptr = arg1->GetNativeImageSource(); - } - catch(std::out_of_range& e) - { - SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); - delete handle; - return 0; - } - catch(std::exception& e) - { - SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); - delete handle; - return 0; - } - catch(Dali::DaliException e) - { - SWIG_CSharpException(SWIG_UnknownError, e.condition); - delete handle; - return 0; - } - catch(...) - { - SWIG_CSharpException(SWIG_UnknownError, "unknown error"); - delete handle; - return 0; - } + } CALL_CATCH_EXCEPTION_WITH_FUNCTION(0, [](NativeImageSourcePtrHandle* ptr){delete ptr;}, handle); } return (void*)handle; } diff --git a/dali-csharp-binder/dali-adaptor/dali-adaptor-wrap.cpp b/dali-csharp-binder/dali-adaptor/dali-adaptor-wrap.cpp index 6514f874..69e01f5b 100644 --- a/dali-csharp-binder/dali-adaptor/dali-adaptor-wrap.cpp +++ b/dali-csharp-binder/dali-adaptor/dali-adaptor-wrap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -1291,7 +1291,6 @@ struct NativeImageSourcePtrHandle NativeImageSourcePtr Ptr; }; - SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_NativeImageSource_New_Handle(unsigned int jarg1, unsigned int jarg2, int jarg3) { void* jresult; @@ -1299,27 +1298,7 @@ SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_NativeImageSource_New_Handle(unsigned i { try { handle->Ptr = ( NativeImageSource::New(jarg1, jarg2, (NativeImageSource::ColorDepth)jarg3) ); - } - catch (std::out_of_range & e) { - { - SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return 0; - }; - } - catch (std::exception & e) { - { - SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return 0; - }; - } - catch (Dali::DaliException e) { - { - SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0; - }; - } - catch (...) { - { - SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0; - }; - } + } CALL_CATCH_EXCEPTION_WITH_FUNCTION(0, [](NativeImageSourcePtrHandle* ptr){delete ptr;}, handle); } jresult = (void *)handle; return jresult; @@ -1329,7 +1308,11 @@ SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_NativeImageSource_New(void* jarg1) { void* jresult; NativeImageSourcePtrHandle* handle = (NativeImageSourcePtrHandle*)jarg1; - jresult = (void*)( handle->Ptr.Get() ); + { + try { + jresult = (void*)( handle->Ptr.Get() ); + } CALL_CATCH_EXCEPTION(0); + } return jresult; } @@ -1338,27 +1321,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_Dali_NativeImageSource_Delete(void* jarg1) { { try { delete arg1; - } - catch (std::out_of_range & e) { - { - SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return; - }; - } - catch (std::exception & e) { - { - SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return; - }; - } - catch (Dali::DaliException e) { - { - SWIG_CSharpException(SWIG_UnknownError, e.condition); return; - }; - } - catch (...) { - { - SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return; - }; - } + } CALL_CATCH_EXCEPTION(); } } @@ -1372,27 +1335,7 @@ SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_NativeImageSource_AcquireBuffer(void* j { try { jresult = (void *)Dali::DevelNativeImageSource::AcquireBuffer( *arg1, *arg2, *arg3, *arg4 ); - } - catch (std::out_of_range & e) { - { - SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return 0; - }; - } - catch (std::exception & e) { - { - SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return 0; - }; - } - catch (Dali::DaliException e) { - { - SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0; - }; - } - catch (...) { - { - SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0; - }; - } + } CALL_CATCH_EXCEPTION(0); } return jresult; } @@ -1405,27 +1348,7 @@ SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_NativeImageSource_ReleaseBuffer(void* ja { try { jresult = Dali::DevelNativeImageSource::ReleaseBuffer(*arg1, Rect{}); - } - catch (std::out_of_range & e) { - { - SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return 0; - }; - } - catch (std::exception & e) { - { - SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return 0; - }; - } - catch (Dali::DaliException e) { - { - SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0; - }; - } - catch (...) { - { - SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0; - }; - } + } CALL_CATCH_EXCEPTION(0); } return jresult; } @@ -1444,8 +1367,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_Dali_NativeImageSource_EnableBackBuffer(void* try { Dali::DevelNativeImageSource::EnableBackBuffer(*nativeImage, enable); - } - CALL_CATCH_EXCEPTION(); + } CALL_CATCH_EXCEPTION(); } } diff --git a/dali-csharp-binder/dali-adaptor/native-image-queue-wrap.cpp b/dali-csharp-binder/dali-adaptor/native-image-queue-wrap.cpp index d0dc4b6c..c76c3f41 100644 --- a/dali-csharp-binder/dali-adaptor/native-image-queue-wrap.cpp +++ b/dali-csharp-binder/dali-adaptor/native-image-queue-wrap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -40,7 +40,7 @@ SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_NativeImageQueuePtr_2(unsigned int try { queue->Ptr = Dali::NativeImageSourceQueue::New(queueCount, width, height, (Dali::NativeImageSourceQueue::ColorFormat)colorFormat); } - CALL_CATCH_EXCEPTION(0); + CALL_CATCH_EXCEPTION_WITH_FUNCTION(0, [](NativeImageSourceQueuePtrHandle* ptr){delete ptr;}, queue); } jresult = (void *)queue; return jresult; -- 2.34.1