From 15bc685fc9a7262e4f8b4bb89ffef821db9758d0 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Mon, 27 Jul 2020 15:28:07 +0900 Subject: [PATCH] [Tizen] Add OffscreenApplication Change-Id: I1962955ce6e2eec26aa8b869fd00994621125fe9 --- build/tizen/module-list.cmake | 3 + build/tizen/profiles/android-profile.cmake | 1 + build/tizen/profiles/common-profile.cmake | 2 + build/tizen/profiles/ivi-profile.cmake | 2 + build/tizen/profiles/mobile-profile.cmake | 2 + build/tizen/profiles/tv-profile.cmake | 2 + build/tizen/profiles/ubuntu-profile.cmake | 1 + build/tizen/profiles/wearable-profile.cmake | 2 + build/tizen/profiles/windows-profile.cmake | 1 + .../adaptor-framework/offscreen-application.cpp | 97 +++++++++++ .../adaptor-framework/offscreen-application.h | 140 ++++++++++++++++ .../adaptor-framework/offscreen-window.cpp | 125 ++++++++++++++ .../devel-api/adaptor-framework/offscreen-window.h | 184 +++++++++++++++++++++ dali/devel-api/file.list | 4 + .../common/offscreen-application-impl.cpp | 105 ++++++++++++ .../offscreen/common/offscreen-application-impl.h | 180 ++++++++++++++++++++ .../offscreen/common/offscreen-window-factory.h | 54 ++++++ .../offscreen/common/offscreen-window-impl.h | 155 +++++++++++++++++ dali/internal/offscreen/file.list | 12 ++ .../tizen/offscreen-window-factory-tizen.cpp | 40 +++++ .../tizen/offscreen-window-factory-tizen.h | 47 ++++++ .../tizen/offscreen-window-impl-tizen.cpp | 180 ++++++++++++++++++++ .../offscreen/tizen/offscreen-window-impl-tizen.h | 135 +++++++++++++++ 23 files changed, 1474 insertions(+) create mode 100644 dali/devel-api/adaptor-framework/offscreen-application.cpp create mode 100644 dali/devel-api/adaptor-framework/offscreen-application.h create mode 100644 dali/devel-api/adaptor-framework/offscreen-window.cpp create mode 100644 dali/devel-api/adaptor-framework/offscreen-window.h create mode 100644 dali/internal/offscreen/common/offscreen-application-impl.cpp create mode 100644 dali/internal/offscreen/common/offscreen-application-impl.h create mode 100644 dali/internal/offscreen/common/offscreen-window-factory.h create mode 100644 dali/internal/offscreen/common/offscreen-window-impl.h create mode 100644 dali/internal/offscreen/file.list create mode 100644 dali/internal/offscreen/tizen/offscreen-window-factory-tizen.cpp create mode 100644 dali/internal/offscreen/tizen/offscreen-window-factory-tizen.h create mode 100644 dali/internal/offscreen/tizen/offscreen-window-impl-tizen.cpp create mode 100644 dali/internal/offscreen/tizen/offscreen-window-impl-tizen.h diff --git a/build/tizen/module-list.cmake b/build/tizen/module-list.cmake index 161d1de..f779f50 100644 --- a/build/tizen/module-list.cmake +++ b/build/tizen/module-list.cmake @@ -28,6 +28,9 @@ include( ${ADAPTOR_ROOT}/dali/internal/legacy/file.list ) SET( adaptor_network_dir ${ADAPTOR_ROOT}/dali/internal/network ) include( ${ADAPTOR_ROOT}/dali/internal/network/file.list ) +SET( adaptor_offscreen_dir ${ADAPTOR_ROOT}/dali/internal/offscreen ) +include( ${ADAPTOR_ROOT}/dali/internal/offscreen/file.list ) + SET( adaptor_sensor_dir ${ADAPTOR_ROOT}/dali/internal/sensor ) include( ${ADAPTOR_ROOT}/dali/internal/sensor/file.list ) diff --git a/build/tizen/profiles/android-profile.cmake b/build/tizen/profiles/android-profile.cmake index 5862cec..2d41d2c 100644 --- a/build/tizen/profiles/android-profile.cmake +++ b/build/tizen/profiles/android-profile.cmake @@ -24,6 +24,7 @@ SET( SOURCES ${adaptor_integration_api_android_src_files} ${adaptor_legacy_common_src_files} ${adaptor_network_common_src_files} + ${adaptor_offscreen_common_src_files} ${adaptor_public_api_src_files} ${adaptor_sensor_common_src_files} ${adaptor_sensor_android_src_files} diff --git a/build/tizen/profiles/common-profile.cmake b/build/tizen/profiles/common-profile.cmake index 2d24972..6a8c2ba 100644 --- a/build/tizen/profiles/common-profile.cmake +++ b/build/tizen/profiles/common-profile.cmake @@ -23,6 +23,8 @@ SET( SOURCES ${adaptor_integration_api_src_files} ${adaptor_legacy_common_src_files} ${adaptor_network_common_src_files} + ${adaptor_offscreen_common_src_files} + ${adaptor_offscreen_tizen_src_files} ${adaptor_public_api_src_files} ${adaptor_sensor_common_src_files} ${adaptor_sensor_tizen_src_files} diff --git a/build/tizen/profiles/ivi-profile.cmake b/build/tizen/profiles/ivi-profile.cmake index aebd8b6..7ec48e6 100644 --- a/build/tizen/profiles/ivi-profile.cmake +++ b/build/tizen/profiles/ivi-profile.cmake @@ -24,6 +24,8 @@ SET( SOURCES ${adaptor_integration_api_src_files} ${adaptor_legacy_common_src_files} ${adaptor_network_common_src_files} + ${adaptor_offscreen_common_src_files} + ${adaptor_offscreen_tizen_src_files} ${adaptor_public_api_src_files} ${adaptor_sensor_common_src_files} ${adaptor_sensor_tizen_src_files} diff --git a/build/tizen/profiles/mobile-profile.cmake b/build/tizen/profiles/mobile-profile.cmake index a53da27..6907af4 100644 --- a/build/tizen/profiles/mobile-profile.cmake +++ b/build/tizen/profiles/mobile-profile.cmake @@ -23,6 +23,8 @@ SET( SOURCES ${adaptor_integration_api_src_files} ${adaptor_legacy_common_src_files} ${adaptor_network_common_src_files} + ${adaptor_offscreen_common_src_files} + ${adaptor_offscreen_tizen_src_files} ${adaptor_public_api_src_files} ${adaptor_sensor_common_src_files} ${adaptor_sensor_tizen_src_files} diff --git a/build/tizen/profiles/tv-profile.cmake b/build/tizen/profiles/tv-profile.cmake index 2469de7..38a21eb 100644 --- a/build/tizen/profiles/tv-profile.cmake +++ b/build/tizen/profiles/tv-profile.cmake @@ -23,6 +23,8 @@ SET( SOURCES ${adaptor_integration_api_src_files} ${adaptor_legacy_common_src_files} ${adaptor_network_common_src_files} + ${adaptor_offscreen_common_src_files} + ${adaptor_offscreen_tizen_src_files} ${adaptor_public_api_src_files} ${adaptor_sensor_common_src_files} ${adaptor_sensor_tizen_src_files} diff --git a/build/tizen/profiles/ubuntu-profile.cmake b/build/tizen/profiles/ubuntu-profile.cmake index 82643fa..cdd43c4 100644 --- a/build/tizen/profiles/ubuntu-profile.cmake +++ b/build/tizen/profiles/ubuntu-profile.cmake @@ -22,6 +22,7 @@ SET( SOURCES ${adaptor_integration_api_src_files} ${adaptor_legacy_common_src_files} ${adaptor_network_common_src_files} + ${adaptor_offscreen_common_src_files} ${adaptor_public_api_src_files} ${adaptor_sensor_common_src_files} ${adaptor_sensor_ubuntu_src_files} diff --git a/build/tizen/profiles/wearable-profile.cmake b/build/tizen/profiles/wearable-profile.cmake index 2a908d0..491f4a8 100644 --- a/build/tizen/profiles/wearable-profile.cmake +++ b/build/tizen/profiles/wearable-profile.cmake @@ -24,6 +24,8 @@ SET( SOURCES ${adaptor_integration_api_src_files} ${adaptor_legacy_common_src_files} ${adaptor_network_common_src_files} + ${adaptor_offscreen_common_src_files} + ${adaptor_offscreen_tizen_src_files} ${adaptor_public_api_src_files} ${adaptor_sensor_common_src_files} ${adaptor_sensor_tizen_src_files} diff --git a/build/tizen/profiles/windows-profile.cmake b/build/tizen/profiles/windows-profile.cmake index c39c3bd..92a7fb9 100644 --- a/build/tizen/profiles/windows-profile.cmake +++ b/build/tizen/profiles/windows-profile.cmake @@ -17,6 +17,7 @@ SET( SOURCES ${adaptor_integration_api_src_files} ${adaptor_legacy_common_src_files} ${adaptor_network_common_src_files} + ${adaptor_offscreen_common_src_files} ${adaptor_public_api_src_files} ${adaptor_sensor_common_src_files} ${adaptor_styling_common_src_files} diff --git a/dali/devel-api/adaptor-framework/offscreen-application.cpp b/dali/devel-api/adaptor-framework/offscreen-application.cpp new file mode 100644 index 0000000..5c1ea07 --- /dev/null +++ b/dali/devel-api/adaptor-framework/offscreen-application.cpp @@ -0,0 +1,97 @@ +/* + * 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. + * + */ + +// INTERNAL INCLUDES +#include + +// CLASS HEADER +#include + +namespace Dali +{ +OffscreenApplication OffscreenApplication::New( uint16_t width, uint16_t height, bool isTranslucent ) +{ + Dali::Any surface; + IntrusivePtr< Internal::OffscreenApplication > impl = Internal::OffscreenApplication::New( width, height, surface, isTranslucent ); + + OffscreenApplication offscreenApplication = OffscreenApplication( impl.Get() ); + + return offscreenApplication; +} + +OffscreenApplication OffscreenApplication::New( Dali::Any surface, bool isTranslucent ) +{ + IntrusivePtr< Internal::OffscreenApplication > impl = Internal::OffscreenApplication::New( 0, 0, surface, isTranslucent ); + + OffscreenApplication offscreenApplication = OffscreenApplication( impl.Get() ); + + return offscreenApplication; +} + +OffscreenApplication::OffscreenApplication() +{ +} + +OffscreenApplication::OffscreenApplication( const OffscreenApplication& offscreenApplication ) +: BaseHandle( offscreenApplication ) +{ +} + +OffscreenApplication& OffscreenApplication::operator=( const OffscreenApplication& offscreenApplication ) +{ + if( *this != offscreenApplication ) + { + BaseHandle::operator=( offscreenApplication ); + } + return *this; +} + +OffscreenApplication::~OffscreenApplication() +{ +} + +void OffscreenApplication::Run() +{ + Internal::GetImplementation( *this ).Run(); +} + +void OffscreenApplication::Stop() +{ + Internal::GetImplementation( *this ).Stop(); +} + +Dali::OffscreenWindow OffscreenApplication::GetWindow() +{ + return Internal::GetImplementation( *this ).GetWindow(); +} + +OffscreenApplication::OffscreenApplicationSignalType& OffscreenApplication::InitSignal() +{ + return Internal::GetImplementation( *this ).InitSignal(); +} + +OffscreenApplication::OffscreenApplicationSignalType& OffscreenApplication::TerminateSignal() +{ + return Internal::GetImplementation( *this ).TerminateSignal(); +} + +OffscreenApplication::OffscreenApplication( Internal::OffscreenApplication* offscreenApplication ) +: BaseHandle( offscreenApplication ) +{ +} + +} // namespace Dali diff --git a/dali/devel-api/adaptor-framework/offscreen-application.h b/dali/devel-api/adaptor-framework/offscreen-application.h new file mode 100644 index 0000000..19588c8 --- /dev/null +++ b/dali/devel-api/adaptor-framework/offscreen-application.h @@ -0,0 +1,140 @@ +#ifndef DALI_OFFSCREEN_APPLICATION_H +#define DALI_OFFSCREEN_APPLICATION_H + +/* + * 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. + * + */ + +/** + * @addtogroup dali_adaptor_framework + * @{ + */ + +// EXTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +class OffscreenWindow; + +namespace Internal +{ +class OffscreenApplication; +} + +/** + * @brief Appliations can draw UI on offscreen surface with the OffscreenApplication. + * When you use a OffscreenApplication, you don't have to make a Window. + */ +class DALI_IMPORT_API OffscreenApplication : public Dali::BaseHandle +{ +public: + + typedef Signal OffscreenApplicationSignalType; + +public: + + /** + * @brief This is the constructor of OffscreenApplication + * + * @param[in] width The initial width of the default OffscreenWindow + * @param[in] height The initial height of the default OffscreenWindow + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + static OffscreenApplication New( uint16_t width, uint16_t height, bool isTranslucent ); + + /** + * @brief This is the constructor of OffscreenApplication + * + * @param[in] surface The native surface handle to create the OffscreenWindow + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + static OffscreenApplication New( Dali::Any surface, bool isTranslucent ); + + /** + * @brief Constructs an empty handle + */ + OffscreenApplication(); + + /** + * @brief Copy constructor + */ + OffscreenApplication( const OffscreenApplication& offscreenApplication ); + + /** + * @brief Assignment operator + */ + OffscreenApplication& operator=( const OffscreenApplication& offscreenApplication ); + + /** + * @brief Destructor + */ + ~OffscreenApplication(); + +public: + + /** + * @brief Runs the OffscreenApplication (rendering, event handling, etc) + */ + void Run(); + + /** + * @brief Stops the OffscreenApplication + */ + void Stop(); + + + /** + * @brief Get the default Window handle + * @return The default Window + */ + OffscreenWindow GetWindow(); + +public: // Signals + + /** + * @brief Signal to notify the client when the application is ready to be initialized + * + * @note OffscreenApplication::Run() should be called to be initialized + * + * @return The signal + */ + OffscreenApplicationSignalType& InitSignal(); + + /** + * @brief Signal to notify the user when the application is about to be terminated + * + * @return The signal + */ + OffscreenApplicationSignalType& TerminateSignal(); + +public: // Not intended for application developers + /** + * @brief Internal constructor + */ + explicit DALI_INTERNAL OffscreenApplication( Internal::OffscreenApplication* offscreenApplication ); + +}; + +/** + * @} + */ + +} // namespace Dali + +#endif // DALI_OFFSCREEN_APPLICATION_H diff --git a/dali/devel-api/adaptor-framework/offscreen-window.cpp b/dali/devel-api/adaptor-framework/offscreen-window.cpp new file mode 100644 index 0000000..b7438d4 --- /dev/null +++ b/dali/devel-api/adaptor-framework/offscreen-window.cpp @@ -0,0 +1,125 @@ +/* + * 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. + * + */ + +// EXTENRAL INCLUDES +#include + +// INTERNAL INCLUDES +#include +#include +#include + +// CLASS HEADER +#include + +namespace Dali +{ +OffscreenWindow OffscreenWindow::New( OffscreenApplication offscreenApplication, uint16_t width, uint16_t height, bool isTranslucent ) +{ + auto windowFactory = Dali::Internal::GetOffscreenWindowFactory(); + Dali::Any surface; + IntrusivePtr < Internal::OffscreenWindow > impl = windowFactory->CreateOffscreenWindow( width, height, surface, isTranslucent ).release(); + OffscreenWindow window = OffscreenWindow( impl.Get() ); + impl->Initialize( &Internal::GetImplementation( offscreenApplication ), false ); + + return window; +} + +OffscreenWindow OffscreenWindow::New( OffscreenApplication offscreenApplication, Dali::Any surface, bool isTranslucent ) +{ + auto windowFactory = Dali::Internal::GetOffscreenWindowFactory(); + IntrusivePtr < Internal::OffscreenWindow > impl = windowFactory->CreateOffscreenWindow( 0, 0, surface, isTranslucent ).release(); + OffscreenWindow window = OffscreenWindow( impl.Get() ); + impl->Initialize( &Internal::GetImplementation( offscreenApplication ), false ); + + return window; +} + +OffscreenWindow::OffscreenWindow() +{ +} + +OffscreenWindow::OffscreenWindow( const OffscreenWindow& window ) +: BaseHandle( window ) +{ +} + +OffscreenWindow& OffscreenWindow::operator=( const OffscreenWindow& window ) +{ + if( *this != window ) + { + BaseHandle::operator=( window ); + } + return *this; +} + +OffscreenWindow::~OffscreenWindow() +{ +} + +void OffscreenWindow::Add( Actor actor ) +{ + Internal::GetImplementation( *this ).Add( actor ); +} + +void OffscreenWindow::Remove( Actor actor ) +{ + Internal::GetImplementation( *this ).Remove( actor ); +} + +void OffscreenWindow::SetBackgroundColor( const Vector4& color ) +{ + Internal::GetImplementation( *this ).SetBackgroundColor( color ); +} + +Vector4 OffscreenWindow::GetBackgroundColor() const +{ + return Internal::GetImplementation( *this ).GetBackgroundColor(); +} + +Layer OffscreenWindow::GetRootLayer() const +{ + return Internal::GetImplementation( *this ).GetRootLayer(); +} + +uint32_t OffscreenWindow::GetLayerCount() const +{ + return Internal::GetImplementation( *this ).GetLayerCount(); +} + +Dali::Layer OffscreenWindow::GetLayer( uint32_t depth ) const +{ + return Internal::GetImplementation( *this ).GetLayer( depth ); +} + +OffscreenWindow::WindowSize OffscreenWindow::GetSize() const +{ + return Internal::GetImplementation( *this ).GetSize(); +} + +OffscreenWindow::PostRenderSignalType& OffscreenWindow::PostRenderSignal() +{ + return Internal::GetImplementation( *this ).PostRenderSignal(); +} + + +OffscreenWindow::OffscreenWindow( Internal::OffscreenWindow* window ) +: BaseHandle( window ) +{ +} + +} // namespace Dali diff --git a/dali/devel-api/adaptor-framework/offscreen-window.h b/dali/devel-api/adaptor-framework/offscreen-window.h new file mode 100644 index 0000000..042279e --- /dev/null +++ b/dali/devel-api/adaptor-framework/offscreen-window.h @@ -0,0 +1,184 @@ +#ifndef DALI_OFFSCREEN_WINDOW_H +#define DALI_OFFSCREEN_WINDOW_H + +/* + * 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. + * + */ + +/** + * @addtogroup dali_adaptor_framework + * @{ + */ + +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +class Layer; + +namespace Internal +{ +class OffscreenWindow; +} + +class DALI_IMPORT_API OffscreenWindow : public Dali::BaseHandle +{ +public: + + typedef Uint16Pair WindowSize; + typedef Signal PostRenderSignalType; + +public: + + /** + * @brief Creates an initialized handle to a new OffscreenWindow + * @note You should hold the returned handle. If you missed the handle, the OffscreenWindow will be released + * + * @param[in] offscreenApplication The OffscreenApplication handle + * @param[in] width The initial width of the OffscreenWindow + * @param[in] height The initial height of the OffscreenWindow + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + static OffscreenWindow New( OffscreenApplication offscreenApplication, uint16_t width, uint16_t height, bool isTranslucent ); + + /** + * @brief Creates an initialized handle to a new OffscreenWindow + * @note You should hold the returned handle. If you missed the handle, the OffscreenWindow will be released + * + * @param[in] offscreenApplication The OffscreenApplication handle + * @param[in] surface The native surface handle of your platform + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + static OffscreenWindow New( OffscreenApplication offscreenApplication, Dali::Any surface, bool isTranslucent ); + + /** + * @brief Constructs an empty handle + */ + OffscreenWindow(); + + /** + * @brief Copy constructor + */ + OffscreenWindow( const OffscreenWindow& window ); + + /** + * @brief Assignment operator + */ + OffscreenWindow& operator=( const OffscreenWindow& window ); + + /** + * @brief Destructor + */ + ~OffscreenWindow(); + +public: + /** + * @brief Adds a child Actor to the OffscreenWindow. + * + * The child will be referenced. + * + * @param[in] actor The child + * @pre The actor has been initialized. + * @pre The actor does not have a parent. + */ + void Add( Actor actor ); + + /** + * @brief Removes a child Actor from the OffscreenWindow. + * + * The child will be unreferenced. + * + * @param[in] actor The child + * @pre The actor has been added to the OffscreenWindow. + */ + void Remove( Actor actor ); + + /** + * @brief Sets the background color of the OffscreenWindow. + * + * @param[in] color The new background color + */ + void SetBackgroundColor( const Vector4& color ); + + /** + * @brief Gets the background color of the OffscreenWindow. + * + * @return The background color + */ + Vector4 GetBackgroundColor() const; + + /** + * @brief Returns the root Layer of the OffscreenWindow. + * + * @return The root layer + */ + Layer GetRootLayer() const; + + /** + * @brief Queries the number of on-scene layers. + * + * Note that a default layer is always provided (count >= 1). + * + * @return The number of layers + */ + uint32_t GetLayerCount() const; + + /** + * @brief Retrieves the layer at a specified depth in the OffscreenWindow. + * + * @param[in] depth The depth + * @return The layer found at the given depth + * @pre Depth is less than layer count; see GetLayerCount(). + */ + Layer GetLayer( uint32_t depth ) const; + + /** + * @brief Returns the size of the OffscreenWindow in pixels as a Vector. + * + * The x component will be the width of the OffscreenWindow in pixels. + * The y component will be the height of the OffscreenWindow in pixels. + * + * @return The size of the OffscreenWindow as a Vector + */ + WindowSize GetSize() const; + +public: // Signals + PostRenderSignalType& PostRenderSignal(); + +public: // Not intended for application developers + + /** + * @brief Internal constructor + */ + explicit DALI_INTERNAL OffscreenWindow( Internal::OffscreenWindow* window ); + +}; + +/** + * @} + */ + +} // namespace Dali + +#endif // DALI_OFFSCREEN_WINDOW_H diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 7c404a0..717cba9 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -37,6 +37,8 @@ SET( devel_api_src_files ${adaptor_devel_api_dir}/adaptor-framework/thread-settings.cpp ${adaptor_devel_api_dir}/adaptor-framework/web-engine.cpp ${adaptor_devel_api_dir}/adaptor-framework/window-devel.cpp + ${adaptor_devel_api_dir}/adaptor-framework/offscreen-application.cpp + ${adaptor_devel_api_dir}/adaptor-framework/offscreen-window.cpp ) @@ -92,6 +94,8 @@ SET( devel_api_adaptor_framework_header_files ${adaptor_devel_api_dir}/adaptor-framework/window-devel.h ${adaptor_devel_api_dir}/adaptor-framework/component-application.h ${adaptor_devel_api_dir}/adaptor-framework/video-sync-mode.h + ${adaptor_devel_api_dir}/adaptor-framework/offscreen-application.h + ${adaptor_devel_api_dir}/adaptor-framework/offscreen-window.h ) diff --git a/dali/internal/offscreen/common/offscreen-application-impl.cpp b/dali/internal/offscreen/common/offscreen-application-impl.cpp new file mode 100644 index 0000000..eedf1b8 --- /dev/null +++ b/dali/internal/offscreen/common/offscreen-application-impl.cpp @@ -0,0 +1,105 @@ +/* + * 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include +#include + +// CLASS HEADER +#include + +namespace Dali +{ + +namespace Internal +{ + +IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent) +{ + IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent ); + return offscreenApplication; +} + +OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent ) +: mState( READY ) +{ + // Generate a default window + auto windowFactory = Dali::Internal::GetOffscreenWindowFactory(); + IntrusivePtr windowPtr = windowFactory->CreateOffscreenWindow( width, height, surface, isTranslucent ).release(); + mDefaultWindow = Dali::OffscreenWindow( windowPtr.Get() ); + + // Generate DALi adaptor + NativeRenderSurface* naitveSurface = static_cast( windowPtr->GetSurface() ); + + mAdaptor = &Dali::Adaptor::New( Dali::Integration::SceneHolder( windowPtr.Get() ), *naitveSurface, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ); + + // Initialize default window + windowPtr->Initialize( this, true ); +} + +OffscreenApplication::~OffscreenApplication() +{ + delete mAdaptor; + mAdaptor = nullptr; +} + +Dali::Adaptor* OffscreenApplication::GetAdaptor() +{ + return mAdaptor; +} + +void OffscreenApplication::Run() +{ + if( READY == mState ) + { + // Start the adaptor + mAdaptor->Start(); + + mState = RUNNING; + + mPreInitSignal.Emit(); + + mInitSignal.Emit(); + + mAdaptor->NotifySceneCreated(); + } +} + +void OffscreenApplication::Stop() +{ + if( mState != STOPPED ) + { + // Stop the adaptor + mAdaptor->Stop(); + mState = STOPPED; + + mTerminateSignal.Emit(); + } +} + +Dali::OffscreenWindow OffscreenApplication::GetWindow() +{ + return mDefaultWindow; +} + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/offscreen/common/offscreen-application-impl.h b/dali/internal/offscreen/common/offscreen-application-impl.h new file mode 100644 index 0000000..0ad3cbb --- /dev/null +++ b/dali/internal/offscreen/common/offscreen-application-impl.h @@ -0,0 +1,180 @@ +#ifndef DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H +#define DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H + +/* + * 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. + * + */ + +// EXTERNAL INCLUDES +#include + +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include + + +namespace Dali +{ +class Adaptor; + +namespace Internal +{ + +/** + * Implementation of the OffscreenApplication class. + */ +class OffscreenApplication : public BaseObject, + public ConnectionTracker +{ +public: + + typedef Dali::OffscreenApplication::OffscreenApplicationSignalType OffscreenApplicationSignalType; + + /** + * @brief Create a new OffscreenApplication + * @param[in] width The width of the default OffscreenWindow + * @param[in] height The height of the default OffscreenWindow + * @param[in] surface The native surface handle to create the default OffscreenWindow + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + static IntrusivePtr New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent); + +public: + + /** + * @copydoc Dali::OffscreenApplication::Start() + */ + void Run(); + + /** + * @copydoc Dali::OffscreenApplication::Stop() + */ + void Stop(); + + /** + * @copydoc Dali::OffscreenApplication::GetDefaultWindow() + */ + Dali::OffscreenWindow GetWindow(); + + /** + * @copydoc Dali::OffscreenApplication::InitSignal() + */ + OffscreenApplicationSignalType& InitSignal() + { + return mInitSignal; + } + + /** + * @copydoc Dali::OffscreenApplication::TerminateSignal() + */ + OffscreenApplicationSignalType& TerminateSignal() + { + return mTerminateSignal; + } + +public: + /** + * All methods here are for the internal use + */ + enum State + { + READY, + RUNNING, + STOPPED, + }; + + /** + * @brief This is for internal use to get notified before InitSignal() emits + */ + OffscreenApplicationSignalType& PreInitSignal() + { + return mPreInitSignal; + } + + /** + * @brief Get OffscreenApplication's current state + * + * @return The state + */ + const State GetState() const + { + return mState; + } + + /* + * @bried Get currently working Adaptor. It can be null. + */ + Dali::Adaptor* GetAdaptor(); + +private: + /** + * Private constructor + * @param[in] width The width of the OffscreenWindow + * @param[in] height The height of the OffscreenApplication + * @param[in] surface The native surface handle to create the default OffscreenWindow + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent ); + + + /** + * Destructor + */ + virtual ~OffscreenApplication(); + + // Undefined + OffscreenApplication( const OffscreenApplication& ); + OffscreenApplication& operator=( OffscreenApplication& ); + +private: + Dali::Adaptor* mAdaptor; + Dali::OffscreenWindow mDefaultWindow; + + OffscreenApplicationSignalType mPreInitSignal; + OffscreenApplicationSignalType mInitSignal; + OffscreenApplicationSignalType mTerminateSignal; + + State mState; +}; + +inline OffscreenApplication& GetImplementation( Dali::OffscreenApplication& offscreenApplication ) +{ + DALI_ASSERT_ALWAYS( offscreenApplication && "OffscreenApplication handle is empty" ); + + BaseObject& handle = offscreenApplication.GetBaseObject(); + + return static_cast( handle ); +} + +inline const OffscreenApplication& GetImplementation( const Dali::OffscreenApplication& offscreenApplication ) +{ + DALI_ASSERT_ALWAYS( offscreenApplication && "OffscreenApplication handle is empty" ); + + const BaseObject& handle = offscreenApplication.GetBaseObject(); + + return static_cast( handle ); +} + +} // namespace Internal + +} // namespace Dali + +#endif // DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H diff --git a/dali/internal/offscreen/common/offscreen-window-factory.h b/dali/internal/offscreen/common/offscreen-window-factory.h new file mode 100644 index 0000000..9739c6e --- /dev/null +++ b/dali/internal/offscreen/common/offscreen-window-factory.h @@ -0,0 +1,54 @@ +#ifndef DALI_OFFSCREEN_WINDOW_FACTORY_H +#define DALI_OFFSCREEN_WINDOW_FACTORY_H + +/* + * 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. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Internal +{ + +class OffscreenWindow; + +class OffscreenWindowFactory +{ +public: + + OffscreenWindowFactory() = default; + virtual ~OffscreenWindowFactory() = default; + + /** + * @brief Create a new OffscreenWindow + * + * @param[in] width The initial width of the OffscreenWindow + * @param[in] height The initial height of the OffscreenWindow + * @param[in] surface The native surface handle of your platform + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + virtual std::unique_ptr< OffscreenWindow > CreateOffscreenWindow( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent ) = 0; +}; + +extern std::unique_ptr< OffscreenWindowFactory > GetOffscreenWindowFactory(); + +} // Internal +} // Dali + +#endif // DALI_OFFSCREEN_WINDOW_FACTORY_H \ No newline at end of file diff --git a/dali/internal/offscreen/common/offscreen-window-impl.h b/dali/internal/offscreen/common/offscreen-window-impl.h new file mode 100644 index 0000000..ba084a8 --- /dev/null +++ b/dali/internal/offscreen/common/offscreen-window-impl.h @@ -0,0 +1,155 @@ +#ifndef DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_H +#define DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_H + +/* + * 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. + * + */ + +// EXTERNAL INCLUDES +#include + +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +class Adaptor; +class Layer; +class NativeRenderSurface; +class TriggerEventInterface; + +namespace Internal +{ + +/** + * Implementation of the OffscreenWindow class. + */ +class OffscreenWindow : public Dali::Internal::Adaptor::SceneHolder, + public ConnectionTracker +{ +public: + typedef Dali::OffscreenWindow::WindowSize WindowSize; + + typedef Dali::OffscreenWindow::PostRenderSignalType PostRenderSignalType; + + + /** + * @brief Create a new OffscreenWindow + * + * @param[in] width The initial width of the OffscreenWindow + * @param[in] height The initial height of the OffscreenWindow + * @param[in] surface The native surface handle of your platform + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + static OffscreenWindow* New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent ); + + OffscreenWindow() = default; + +public: + + /** + * Destructor + */ + ~OffscreenWindow() = default; + + /** + * @copydoc Dali::OffscreenWindow::GetLayerCount + */ + virtual uint32_t GetLayerCount() const = 0; + + /** + * @copydoc Dali::OffscreenWindow::GetLayer + */ + virtual Dali::Layer GetLayer( uint32_t depth ) const= 0; + + /** + * @copydoc Dali::OffscreenWindow::GetSize + */ + virtual WindowSize GetSize() const= 0; + + /** + * @brief Gets the native handle. + * @note When users call this function, it wraps the actual type used by the underlying system. + * @return The native handle or an empty handle + */ + virtual Dali::Any GetNativeHandle() const override = 0; + + virtual PostRenderSignalType& PostRenderSignal() = 0; + + /* + * @brief Initialize the OffscreenWindow + * @param[in] offscreenApplication The OffscreenApplication instance to be used to intialize the new OffscreenWindow + * @param[in] isDefaultWindow Whether the OffscreenWindow is a default one or not + */ + virtual void Initialize( OffscreenApplication* offscreenApplication, bool isDefaultWindow ) = 0; + +private: + /** + * This function is called after drawing by dali. + */ + virtual void OnPostRender() = 0; + + /** + * @brief Get the native render surface + * @return The render surface + */ + virtual NativeRenderSurface* GetNativeRenderSurface() const = 0; + +private: + + // Undefined + OffscreenWindow( const OffscreenWindow& ); + OffscreenWindow& operator=( OffscreenWindow& ); + + /** + * This is for initialization of this OffscreenWindow in case it is created before adaptor is running. + */ + void OnPreInitOffscreenApplication(); + + /* + * @brief Initialize the OffscreenWindow (for internal use) + */ + void Initialize(); +}; + +inline OffscreenWindow& GetImplementation( Dali::OffscreenWindow& offscreenWindow ) +{ + DALI_ASSERT_ALWAYS( offscreenWindow && "Dali::OffscreenWindow handle is empty" ); + + BaseObject& handle = offscreenWindow.GetBaseObject(); + + return static_cast( handle ); +} + +inline const OffscreenWindow& GetImplementation( const Dali::OffscreenWindow& offscreenWindow ) +{ + DALI_ASSERT_ALWAYS( offscreenWindow && "Dali::OffscreenWindow handle is empty" ); + + const BaseObject& handle = offscreenWindow.GetBaseObject(); + + return static_cast( handle ); +} + +} // namespace Internal + +} // namespace Dali + +#endif // DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_H diff --git a/dali/internal/offscreen/file.list b/dali/internal/offscreen/file.list new file mode 100644 index 0000000..dba04c6 --- /dev/null +++ b/dali/internal/offscreen/file.list @@ -0,0 +1,12 @@ + +# module: offscreen, backend: common +SET( adaptor_offscreen_common_src_files + ${adaptor_offscreen_dir}/common/offscreen-application-impl.cpp +) + + +# module: offscreen, backend: tizen +SET( adaptor_offscreen_tizen_src_files + ${adaptor_offscreen_dir}/tizen/offscreen-window-impl-tizen.cpp + ${adaptor_offscreen_dir}/tizen/offscreen-window-factory-tizen.cpp +) diff --git a/dali/internal/offscreen/tizen/offscreen-window-factory-tizen.cpp b/dali/internal/offscreen/tizen/offscreen-window-factory-tizen.cpp new file mode 100644 index 0000000..dfcb7e6 --- /dev/null +++ b/dali/internal/offscreen/tizen/offscreen-window-factory-tizen.cpp @@ -0,0 +1,40 @@ +/* + * 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. + * + */ + +// CLASS HEADER +#include + +// INTERNAL HEADERS +#include + +namespace Dali +{ +namespace Internal +{ + +std::unique_ptr< OffscreenWindow > OffscreenWindowFactoryTizen::CreateOffscreenWindow( uint16_t width, uint16_t height, Any surface, bool isTranslucent ) +{ + return std::unique_ptr< OffscreenWindow >( OffscreenWindowTizen::New( width, height, surface, isTranslucent ) ); +} + +std::unique_ptr< OffscreenWindowFactory > GetOffscreenWindowFactory() +{ + return std::unique_ptr< OffscreenWindowFactoryTizen >( new OffscreenWindowFactoryTizen() ); +} + +} // Internal +} // Dali diff --git a/dali/internal/offscreen/tizen/offscreen-window-factory-tizen.h b/dali/internal/offscreen/tizen/offscreen-window-factory-tizen.h new file mode 100644 index 0000000..b4c0a0d --- /dev/null +++ b/dali/internal/offscreen/tizen/offscreen-window-factory-tizen.h @@ -0,0 +1,47 @@ +#ifndef DALI_INTERNAL_OFFSCREEN_WINDOW_FACTORY_TIZEN_H +#define DALI_INTERNAL_OFFSCREEN_WINDOW_FACTORY_TIZEN_H + +/* + * 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. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Internal +{ + +class OffscreenWindowFactoryTizen : public OffscreenWindowFactory +{ +public: + + /** + * @brief Create a new OffscreenWindow + * + * @param[in] width The initial width of the OffscreenWindow + * @param[in] height The initial height of the OffscreenWindow + * @param[in] surface The tbm surface queue handle + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + std::unique_ptr< OffscreenWindow > CreateOffscreenWindow( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent ) override; +}; + +} // Internal +} // Dali + +#endif // DALI_INTERNAL_OFFSCREEN_WINDOW_FACTORY_TIZEN_H diff --git a/dali/internal/offscreen/tizen/offscreen-window-impl-tizen.cpp b/dali/internal/offscreen/tizen/offscreen-window-impl-tizen.cpp new file mode 100644 index 0000000..7abd676 --- /dev/null +++ b/dali/internal/offscreen/tizen/offscreen-window-impl-tizen.cpp @@ -0,0 +1,180 @@ +/* + * 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include + +// CLASS HEADER +#include + +namespace Dali +{ + +namespace Internal +{ + +OffscreenWindowTizen* OffscreenWindowTizen::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent ) +{ + OffscreenWindowTizen* window = new OffscreenWindowTizen( width, height, surface, isTranslucent ); + return window; +} + +OffscreenWindowTizen::OffscreenWindowTizen( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent ) +: mAdaptor( nullptr ), + mRenderNotification(), + mIsTranslucent( isTranslucent ) +{ + // Create surface + if ( surface.Empty() ) + { + mSurface = std::unique_ptr< RenderSurfaceInterface >( CreateNativeSurface( SurfaceSize( width, height ), surface, isTranslucent ) ); + } + else + { + width = static_cast( tbm_surface_queue_get_width( AnyCast< tbm_surface_queue_h > ( surface ) ) ); + height = static_cast( tbm_surface_queue_get_height( AnyCast< tbm_surface_queue_h > ( surface ) ) ); + mSurface = std::unique_ptr< RenderSurfaceInterface >( CreateNativeSurface( SurfaceSize( width, height ), surface, isTranslucent ) ); + } +} + +void OffscreenWindowTizen::Initialize( OffscreenApplication* offscreenApplication, bool isDefaultWindow ) +{ + mAdaptor = offscreenApplication->GetAdaptor(); + + DALI_ASSERT_ALWAYS( mAdaptor && "OffscreenWindowTizen can not be created when the Adaptor is null" ); + + if( isDefaultWindow ) + { + Initialize(); + return; + } + + if( offscreenApplication->GetState() != OffscreenApplication::RUNNING ) + { + offscreenApplication->PreInitSignal().Connect( this, &OffscreenWindowTizen::OnPreInitOffscreenApplication ); + + return; + } + + Dali::Integration::SceneHolder sceneHolderHandler = Dali::Integration::SceneHolder( this ); + mAdaptor->AddWindow( sceneHolderHandler, "", "", mIsTranslucent ); + + Initialize(); +} + +void OffscreenWindowTizen::Initialize() +{ + // Connect callback to be notified when the surface is rendered + TriggerEventFactory triggerEventFactory; + + mRenderNotification = std::unique_ptr< TriggerEventInterface >( triggerEventFactory.CreateTriggerEvent( MakeCallback( this, &OffscreenWindowTizen::OnPostRender ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ) ); + + NativeRenderSurface* surface = GetNativeRenderSurface(); + + if( !surface ) + { + return; + } + + surface->SetRenderNotification( mRenderNotification.get() ); +} + +void OffscreenWindowTizen::OnPreInitOffscreenApplication() +{ + Dali::Integration::SceneHolder sceneHolderHandler = Dali::Integration::SceneHolder( this ); + mAdaptor->AddWindow( sceneHolderHandler, "", "", mIsTranslucent ); + + Initialize(); +} + +OffscreenWindowTizen::~OffscreenWindowTizen() +{ + NativeRenderSurface* surface = GetNativeRenderSurface(); + + if( surface ) + { + // To prevent notification triggering in NativeRenderSurface::PostRender while deleting SceneHolder + surface->SetRenderNotification( nullptr ); + } +} + +uint32_t OffscreenWindowTizen::GetLayerCount() const +{ + return mScene.GetLayerCount(); +} + +Dali::Layer OffscreenWindowTizen::GetLayer( uint32_t depth ) const +{ + return mScene.GetLayer( depth ); +} + +OffscreenWindowTizen::WindowSize OffscreenWindowTizen::GetSize() const +{ + Size size = mScene.GetSize(); + + return OffscreenWindowTizen::WindowSize( static_cast( size.width ), static_cast( size.height ) ); +} + +Dali::Any OffscreenWindowTizen::GetNativeHandle() const +{ + // TODO: What do I have to return? +} + +NativeRenderSurface* OffscreenWindowTizen::GetNativeRenderSurface() const +{ + return dynamic_cast< NativeRenderSurface* >( mSurface.get() ); +} + +void OffscreenWindowTizen::OnPostRender() +{ + NativeRenderSurface* surface = GetNativeRenderSurface(); + + if( !surface ) + { + return; + } + + tbm_surface_h tbmSurface = AnyCast( surface->GetDrawable() ); + + if ( tbmSurface ) + { + mPostRenderSignal.Emit( Dali::OffscreenWindow( this ), AnyCast( tbmSurface ) ); + } + + surface->ReleaseLock(); +} + +OffscreenWindow::PostRenderSignalType& OffscreenWindowTizen::PostRenderSignal() +{ + return mPostRenderSignal; +} + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/offscreen/tizen/offscreen-window-impl-tizen.h b/dali/internal/offscreen/tizen/offscreen-window-impl-tizen.h new file mode 100644 index 0000000..ac245d0 --- /dev/null +++ b/dali/internal/offscreen/tizen/offscreen-window-impl-tizen.h @@ -0,0 +1,135 @@ +#ifndef DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_TIZEN_H +#define DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_TIZEN_H + +/* + * 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. + * + */ + +// EXTERNAL INCLUDES +// #include + +// #include +// #include +// #include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +class Adaptor; +class Layer; +class NativeRenderSurface; +class TriggerEventInterface; + +namespace Internal +{ + +class OffscreenWindowTizen : public Dali::Internal::OffscreenWindow +{ +public: + + static OffscreenWindowTizen* New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent ); + +public: + + /** + * @copydoc Dali::OffscreenWindow::GetLayerCount + */ + uint32_t GetLayerCount() const; + + /** + * @copydoc Dali::OffscreenWindow::GetLayer + */ + Dali::Layer GetLayer( uint32_t depth ) const; + + /** + * @copydoc Dali::OffscreenWindow::GetSize + */ + WindowSize GetSize() const; + + /** + * @brief Gets the native handle. + * @note When users call this function, it wraps the actual type used by the underlying system. + * @return The native handle or an empty handle + */ + Dali::Any GetNativeHandle() const override; + + /* + * @brief Initialize the OffscreenWindow + * @param[in] offscreenApplication The OffscreenApplication instance to be used to intialize the new window + * @param[in] isDefaultWindow Whether the OffscreenWindow is a default one or not + */ + void Initialize( OffscreenApplication* offscreenApplication, bool isDefaultWindow ); + + OffscreenWindow::PostRenderSignalType& PostRenderSignal(); + +private: + /** + * This function is called after drawing by dali. + */ + void OnPostRender(); + + /** + * @brief Get the native render surface + * @return The render surface + */ + NativeRenderSurface* GetNativeRenderSurface() const; + +private: + + /** + * Private constructor + * + * @param[in] width The initial width of the OffscreenWindow + * @param[in] height The initial height of the OffscreenWindow + * @param[in] surface The tbm surface queue handle + * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not + */ + OffscreenWindowTizen( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent ); + + /** + * Destructor + */ + virtual ~OffscreenWindowTizen(); + + // Undefined + OffscreenWindowTizen( const OffscreenWindowTizen& ); + OffscreenWindowTizen& operator=( OffscreenWindowTizen& ); + + /** + * This is for initialization of this OffscreenWindow in case it is created before adaptor is running. + */ + void OnPreInitOffscreenApplication(); + + /* + * @brief Initialize the OffscreenWindow (for internal use) + */ + void Initialize(); + +private: + + Dali::Adaptor* mAdaptor; + std::unique_ptr< TriggerEventInterface > mRenderNotification; + PostRenderSignalType mPostRenderSignal; + bool mIsTranslucent; +}; + +} // namespace Internal + +} // namespace Dali + +#endif // DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_TIZEN_H -- 2.7.4