From 236d27935981afac7bf57cf469d7046690e8a637 Mon Sep 17 00:00:00 2001 From: "huiyu.eun" Date: Thu, 27 Aug 2020 11:52:48 +0900 Subject: [PATCH] Binding to create Texture using TbmSurface This reverts commit 63025ee8b6f9c7fa21ff2b450fdb9a769775e4ea. Change-Id: Ib6b8330d4c960cd1acd47e6588d354c27599825e Signed-off-by: huiyu.eun --- dali-csharp-binder/file.list | 3 +- dali-csharp-binder/src/tizen-dependency-wrap.cpp | 70 ++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 dali-csharp-binder/src/tizen-dependency-wrap.cpp diff --git a/dali-csharp-binder/file.list b/dali-csharp-binder/file.list index 685627b..09a4b2e 100755 --- a/dali-csharp-binder/file.list +++ b/dali-csharp-binder/file.list @@ -40,7 +40,8 @@ dali_csharp_binder_tizen_src_files = \ ${dali_csharp_binder_dir}/src/font-client.cpp \ ${dali_csharp_binder_dir}/src/transition-effects.cpp \ ${dali_csharp_binder_dir}/src/atspi.cpp \ - ${dali_csharp_binder_dir}/src/component-application-wrap.cpp + ${dali_csharp_binder_dir}/src/component-application-wrap.cpp \ + ${dali_csharp_binder_dir}/src/tizen-dependency-wrap.cpp # module: csharp-binder, backend: tizen-wearable dali_csharp_binder_tizen_wearable_src_files = \ diff --git a/dali-csharp-binder/src/tizen-dependency-wrap.cpp b/dali-csharp-binder/src/tizen-dependency-wrap.cpp new file mode 100644 index 0000000..5baaf60 --- /dev/null +++ b/dali-csharp-binder/src/tizen-dependency-wrap.cpp @@ -0,0 +1,70 @@ +/** Copyright (c) 2020 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +#ifndef CSHARP_TIZEN_DEPENDENCY_WRAP +#define CSHARP_TIZEN_DEPENDENCY_WRAP +#endif + +#include "common.h" +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Texture_TbmSurface(tbm_surface_h tbm_surface) { + Dali::NativeImageSourcePtr mNativeImageSrc; + Dali::Texture mNativeTexture; + void * jresult ; + + if (!tbm_surface) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "tbm surface is null", 0); + return 0; + } + + try { + Dali::Any source(tbm_surface); + mNativeImageSrc = Dali::NativeImageSource::New(source); + mNativeTexture = Dali::Texture::New( *mNativeImageSrc ); + } 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; + }; + } + + jresult = new Dali::Texture((const Dali::Texture &)mNativeTexture); + return (void*)jresult; +} + +#ifdef __cplusplus +} +#endif + -- 2.7.4