From 108783e718e88852985ec0c621f0c0b8c9aad5c3 Mon Sep 17 00:00:00 2001 From: Daekwang Ryu Date: Wed, 15 Sep 2021 21:29:10 +0900 Subject: [PATCH] Add NativeImageSurface NativeImageSurface is a GL Rendering surface. But it's not an actual window, it's like a pixmap. It creates EGL resources. Change-Id: Ib69a1dba557483e87bb05c76842cf012dc4423a5 --- .../adaptor-framework/native-image-surface.cpp | 81 ++++++++ .../adaptor-framework/native-image-surface.h | 138 ++++++++++++++ dali/integration-api/file.list | 2 + dali/internal/graphics/gles/egl-implementation.cpp | 1 + .../tizen/native-image-source-queue-impl-tizen.cpp | 29 ++- .../tizen/native-image-source-queue-impl-tizen.h | 3 +- .../native-image-surface-factory-android.cpp | 35 ++++ .../android/native-image-surface-impl-android.cpp | 70 +++++++ .../android/native-image-surface-impl-android.h | 88 +++++++++ .../common/native-image-surface-factory.h | 49 +++++ .../common/native-image-surface-impl.h | 80 ++++++++ dali/internal/window-system/file.list | 10 + .../macos/native-image-surface-factory-mac.cpp | 35 ++++ .../macos/native-image-surface-impl-mac.cpp | 70 +++++++ .../macos/native-image-surface-impl-mac.h | 85 +++++++++ .../native-image-surface-factory-ecore-wl.cpp | 35 ++++ .../native-image-surface-impl-ecore-wl.cpp | 208 +++++++++++++++++++++ .../native-image-surface-impl-ecore-wl.h | 111 +++++++++++ .../ubuntu-x11/native-image-surface-factory-x.cpp | 35 ++++ .../ubuntu-x11/native-image-surface-impl-x.cpp | 70 +++++++ .../ubuntu-x11/native-image-surface-impl-x.h | 88 +++++++++ .../windows/native-image-surface-factory-win.cpp | 35 ++++ .../windows/native-image-surface-impl-win.cpp | 70 +++++++ .../windows/native-image-surface-impl-win.h | 88 +++++++++ 24 files changed, 1507 insertions(+), 9 deletions(-) create mode 100644 dali/integration-api/adaptor-framework/native-image-surface.cpp create mode 100644 dali/integration-api/adaptor-framework/native-image-surface.h create mode 100644 dali/internal/window-system/android/native-image-surface-factory-android.cpp create mode 100644 dali/internal/window-system/android/native-image-surface-impl-android.cpp create mode 100644 dali/internal/window-system/android/native-image-surface-impl-android.h create mode 100644 dali/internal/window-system/common/native-image-surface-factory.h create mode 100644 dali/internal/window-system/common/native-image-surface-impl.h create mode 100644 dali/internal/window-system/macos/native-image-surface-factory-mac.cpp create mode 100644 dali/internal/window-system/macos/native-image-surface-impl-mac.cpp create mode 100644 dali/internal/window-system/macos/native-image-surface-impl-mac.h create mode 100644 dali/internal/window-system/tizen-wayland/native-image-surface-factory-ecore-wl.cpp create mode 100644 dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp create mode 100644 dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.h create mode 100644 dali/internal/window-system/ubuntu-x11/native-image-surface-factory-x.cpp create mode 100644 dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.cpp create mode 100644 dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.h create mode 100644 dali/internal/window-system/windows/native-image-surface-factory-win.cpp create mode 100644 dali/internal/window-system/windows/native-image-surface-impl-win.cpp create mode 100644 dali/internal/window-system/windows/native-image-surface-impl-win.h diff --git a/dali/integration-api/adaptor-framework/native-image-surface.cpp b/dali/integration-api/adaptor-framework/native-image-surface.cpp new file mode 100644 index 0000000..88a4d74 --- /dev/null +++ b/dali/integration-api/adaptor-framework/native-image-surface.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2021 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 INCLUDES +#include +#include + +namespace Dali +{ +NativeImageSurfacePtr NativeImageSurface::New(Dali::NativeImageSourceQueuePtr queue) +{ + NativeImageSurfacePtr surface = new NativeImageSurface(queue); + if(surface->mImpl) + { + return surface; + } + return nullptr; +} + +Any NativeImageSurface::GetNativeRenderable() +{ + return mImpl->GetNativeRenderable(); +} + +void NativeImageSurface::InitializeGraphics() +{ + mImpl->InitializeGraphics(); +} + +void NativeImageSurface::TerminateGraphics() +{ + mImpl->TerminateGraphics(); +} + +void NativeImageSurface::PreRender() +{ + mImpl->PreRender(); +} + +void NativeImageSurface::PostRender() +{ + mImpl->PostRender(); +} + +bool NativeImageSurface::CanRender() +{ + return mImpl->CanRender(); +} + +bool NativeImageSurface::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) +{ + return mImpl->SetGraphicsConfig(depth, stencil, msaa, version); +} + +NativeImageSurface::NativeImageSurface(Dali::NativeImageSourceQueuePtr queue) +{ + mImpl = Dali::Internal::Adaptor::NativeImageSurfaceFactory::CreateNativeImageSurface(queue); +} + +NativeImageSurface::~NativeImageSurface() +{ +} + +} // namespace Dali diff --git a/dali/integration-api/adaptor-framework/native-image-surface.h b/dali/integration-api/adaptor-framework/native-image-surface.h new file mode 100644 index 0000000..71d23bb --- /dev/null +++ b/dali/integration-api/adaptor-framework/native-image-surface.h @@ -0,0 +1,138 @@ +#ifndef DALI_NATIVE_IMAGE_SURFACE_H +#define DALI_NATIVE_IMAGE_SURFACE_H + +/* + * Copyright (c) 2021 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 + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +class NativeImageSurface; +} +} // namespace Internal + +class NativeImageSurface; + +/** + * @brief Pointer to Dali::NativeImageSurface. + */ +typedef Dali::IntrusivePtr NativeImageSurfacePtr; + +/** + * Native image surface is a surface that GL can render. + * The surface is not a window, it's like a pixmap. + */ +class DALI_ADAPTOR_API NativeImageSurface : public RefObject +{ +public: + /** + * Creates a NativeImageSurface + * + * @param [in] queue the native image source queue handle + * @return A smart-pointer to a newly allocated native image surface + */ + static NativeImageSurfacePtr New(Dali::NativeImageSourceQueuePtr queue); + + /** + * @brief Gets the native renderable handle + * @return The native renderable handle + */ + Any GetNativeRenderable(); + + /** + * @brief Initializes the graphics resources + */ + void InitializeGraphics(); + + /** + * @brief Terminate the graphics resources + */ + void TerminateGraphics(); + + /** + * @brief Invoked by render thread before rendering + */ + void PreRender(); + + /** + * @brief Invoked by render thread after rendering + */ + void PostRender(); + + /** + * @brief Checks to render + */ + bool CanRender(); + + /** + * @brief Sets Graphics configuration to the surface + * + * @param[in] depth the flag of depth buffer. If true is set, 24bit depth buffer is enabled. + * @param[in] stencil the flag of stencil. it true is set, 8bit stencil buffer is enabled. + * @param[in] msaa the bit of msaa. + * @param[in] version the GLES version. + * @return True if the config exists, false otherwise. + */ + bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version); + +private: + /// @cond internal + /** + * @brief Private constructor. + * @param[in] queue the native image source queue handle + */ + DALI_INTERNAL NativeImageSurface(Dali::NativeImageSourceQueuePtr queue); + + /** + * @brief A reference counted object may only be deleted by calling Unreference(). + */ + DALI_INTERNAL ~NativeImageSurface() override; + + /** + * @brief Undefined copy constructor. + * + * This avoids accidental calls to a default copy constructor. + * @param[in] nativeImageSurface A reference to the object to copy + */ + DALI_INTERNAL NativeImageSurface(const NativeImageSurface& nativeImageSurface); + + /** + * @brief Undefined assignment operator. + * + * This avoids accidental calls to a default assignment operator. + * @param[in] rhs A reference to the object to copy + */ + DALI_INTERNAL NativeImageSurface& operator=(const NativeImageSurface& rhs); + /// @endcond + +private: + std::unique_ptr mImpl; ///< Implementation pointer +}; + +} // namespace Dali + +#endif // DALI_NATIVE_IMAGE_SURFACE_H diff --git a/dali/integration-api/file.list b/dali/integration-api/file.list index 0a5b4df..40e11c9 100644 --- a/dali/integration-api/file.list +++ b/dali/integration-api/file.list @@ -3,6 +3,7 @@ SET( adaptor_integration_api_src_files ${adaptor_integration_api_dir}/adaptor-framework/scene-holder.cpp ${adaptor_integration_api_dir}/adaptor-framework/scene-holder-impl.cpp + ${adaptor_integration_api_dir}/adaptor-framework/native-image-surface.cpp ) @@ -18,5 +19,6 @@ SET( adaptor_integration_api_header_files ${adaptor_integration_api_dir}/adaptor-framework/thread-synchronization-interface.h ${adaptor_integration_api_dir}/adaptor-framework/trigger-event-interface.h ${adaptor_integration_api_dir}/adaptor-framework/trigger-event-factory.h + ${adaptor_integration_api_dir}/adaptor-framework/native-image-surface.h ) diff --git a/dali/internal/graphics/gles/egl-implementation.cpp b/dali/internal/graphics/gles/egl-implementation.cpp index 8168b72..976fab8 100644 --- a/dali/internal/graphics/gles/egl-implementation.cpp +++ b/dali/internal/graphics/gles/egl-implementation.cpp @@ -530,6 +530,7 @@ bool EglImplementation::ChooseConfig(bool isWindowType, ColorDepth depth) configAttribs.PushBack(8); // For underlay video playback, we also need to set the alpha value of the 24/32bit window. + // TODO: When the tbm queue of GlView is 24bit, do we have to set the alpha size?? configAttribs.PushBack(EGL_ALPHA_SIZE); configAttribs.PushBack(8); diff --git a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp index fab4a53..107f4cd 100644 --- a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp +++ b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp @@ -82,7 +82,8 @@ NativeImageSourceQueueTizen::NativeImageSourceQueueTizen(uint32_t width, uint32_ mEglGraphics(NULL), mEglImageExtensions(NULL), mOwnTbmQueue(false), - mBlendingRequired(false) + mBlendingRequired(false), + mIsResized(false) { DALI_ASSERT_ALWAYS(Adaptor::IsAvailable()); @@ -185,12 +186,16 @@ void NativeImageSourceQueueTizen::SetSize(uint32_t width, uint32_t height) { Dali::Mutex::ScopedLock lock(mMutex); - tbm_surface_queue_reset(mTbmQueue, width, height, tbm_surface_queue_get_format(mTbmQueue)); + if(mWidth == width && mHeight == height) + { + return; + } - mWidth = width; - mHeight = height; + tbm_surface_queue_reset(mTbmQueue, width, height, tbm_surface_queue_get_format(mTbmQueue)); - ResetEglImageList(); + mWidth = width; + mHeight = height; + mIsResized = true; } void NativeImageSourceQueueTizen::IgnoreSourceImage() @@ -297,7 +302,7 @@ void NativeImageSourceQueueTizen::DestroyResource() { Dali::Mutex::ScopedLock lock(mMutex); - ResetEglImageList(); + ResetEglImageList(true); } uint32_t NativeImageSourceQueueTizen::TargetTexture() @@ -327,6 +332,12 @@ void NativeImageSourceQueueTizen::PrepareTexture() } } + if(mIsResized) + { + ResetEglImageList(false); + mIsResized = false; + } + if(mConsumeSurface) { bool existing = false; @@ -380,9 +391,11 @@ bool NativeImageSourceQueueTizen::SourceChanged() const return false; } -void NativeImageSourceQueueTizen::ResetEglImageList() +void NativeImageSourceQueueTizen::ResetEglImageList(bool releaseConsumeSurface) { - if(mConsumeSurface) + // When Tbm surface queue is reset(resized), the surface acquired before reset() is still valid, not the others. + // We can still use the acquired surface so that we will release it as the oldSurface in PrepareTexture() when the next surface is ready. + if(releaseConsumeSurface && mConsumeSurface) { if(tbm_surface_internal_is_valid(mConsumeSurface)) { diff --git a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h index 347f60a..3556448 100644 --- a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h +++ b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h @@ -177,7 +177,7 @@ private: void Initialize(Dali::NativeImageSourceQueue::ColorFormat colorFormat); - void ResetEglImageList(); + void ResetEglImageList(bool releaseConsumeSurface); tbm_surface_queue_h GetSurfaceFromAny(Any source) const; @@ -198,6 +198,7 @@ private: EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions bool mOwnTbmQueue; ///< Whether we created tbm queue bool mBlendingRequired; ///< Whether blending is required + bool mIsResized; ///< Whether the size has changed }; } // namespace Adaptor diff --git a/dali/internal/window-system/android/native-image-surface-factory-android.cpp b/dali/internal/window-system/android/native-image-surface-factory-android.cpp new file mode 100644 index 0000000..6b05a06 --- /dev/null +++ b/dali/internal/window-system/android/native-image-surface-factory-android.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 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 +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +std::unique_ptr NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue) +{ + return std::make_unique(queue); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/android/native-image-surface-impl-android.cpp b/dali/internal/window-system/android/native-image-surface-impl-android.cpp new file mode 100644 index 0000000..29c53e5 --- /dev/null +++ b/dali/internal/window-system/android/native-image-surface-impl-android.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 + +using namespace Dali::Internal::Adaptor; + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +NativeImageSurfaceAndroid::NativeImageSurfaceAndroid(Dali::NativeImageSourceQueuePtr queue) +{ +} + +NativeImageSurfaceAndroid::~NativeImageSurfaceAndroid() +{ +} + +Any NativeImageSurfaceAndroid::GetNativeRenderable() +{ + return Any(); +} + +void NativeImageSurfaceAndroid::InitializeGraphics() +{ +} + +void NativeImageSurfaceAndroid::TerminateGraphics() +{ +} + +void NativeImageSurfaceAndroid::PreRender() +{ +} + +void NativeImageSurfaceAndroid::PostRender() +{ +} + +bool NativeImageSurfaceAndroid::CanRender() +{ + return false; +} + +bool NativeImageSurfaceAndroid::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) +{ + return false; +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/android/native-image-surface-impl-android.h b/dali/internal/window-system/android/native-image-surface-impl-android.h new file mode 100644 index 0000000..941140b --- /dev/null +++ b/dali/internal/window-system/android/native-image-surface-impl-android.h @@ -0,0 +1,88 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_ANDROID_NATIVE_IMAGE_SURFACE_IMPL_ANDROID_H +#define DALI_INTERNAL_WINDOWSYSTEM_ANDROID_NATIVE_IMAGE_SURFACE_IMPL_ANDROID_H + +/* + * Copyright (c) 2021 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 + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +class NativeImageSurfaceAndroid : public Dali::Internal::Adaptor::NativeImageSurface +{ +public: + /** + * @param [in] queue the NativeImageSourceQueue pointer + */ + NativeImageSurfaceAndroid(Dali::NativeImageSourceQueuePtr queue); + + /** + * @brief Destructor + */ + ~NativeImageSurfaceAndroid(); + +public: + /** + * @copydoc Dali::NativeImageSurface::GetNativeRenderable() + */ + Any GetNativeRenderable() override; + + /** + * @copydoc Dali::NativeImageSurface::InitializeGraphics() + */ + void InitializeGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::TerminateGraphics() + */ + void TerminateGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::PreRender() + */ + void PreRender() override; + + /** + * @copydoc Dali::NativeImageSurface::PostRender() + */ + void PostRender() override; + + /** + * @copydoc Dali::NativeImageSurface::CanRender() + */ + bool CanRender() override; + + /** + * @copydoc Dali::NativeImageSurface::SetGraphicsConfig() + */ + bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_ANDROID_NATIVE_IMAGE_SURFACE_IMPL_ANDROID_H diff --git a/dali/internal/window-system/common/native-image-surface-factory.h b/dali/internal/window-system/common/native-image-surface-factory.h new file mode 100644 index 0000000..1e6eb50 --- /dev/null +++ b/dali/internal/window-system/common/native-image-surface-factory.h @@ -0,0 +1,49 @@ +#ifndef DALI_INTERNAL_NATIVE_IMAGE_SURFACE_FACTORY_H +#define DALI_INTERNAL_NATIVE_IMAGE_SURFACE_FACTORY_H + +/* + * Copyright (c) 2021 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 +{ +namespace Adaptor +{ +class NativeImageSurface; + +class NativeImageSurfaceFactory +{ +public: + /** + * Factory function for native image surface + * A native image surface is created. + * + * @param [in] queue the native image surface handle + * @return A pointer to a newly allocated surface + */ + static std::unique_ptr CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue); +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_NATIVE_IMAGE_SURFACE_FACTORY_H diff --git a/dali/internal/window-system/common/native-image-surface-impl.h b/dali/internal/window-system/common/native-image-surface-impl.h new file mode 100644 index 0000000..2151917 --- /dev/null +++ b/dali/internal/window-system/common/native-image-surface-impl.h @@ -0,0 +1,80 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_NATIVE_IMAGE_SURFACE_IMPL_H +#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_NATIVE_IMAGE_SURFACE_IMPL_H + +/* + * Copyright (c) 2021 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 + +namespace Dali +{ +class NativeImageSurface; + +namespace Internal +{ +namespace Adaptor +{ +class NativeImageSurface +{ +public: + /** + * @copydoc Dali::NativeImageSurface::GetNativeRenderable() + */ + virtual Any GetNativeRenderable() = 0; + + /** + * @copydoc Dali::NativeImageSurface::InitializeGraphics() + */ + virtual void InitializeGraphics() = 0; + + /** + * @copydoc Dali::NativeImageSurface::TerminateGraphics() + */ + virtual void TerminateGraphics() = 0; + + /** + * @copydoc Dali::NativeImageSurface::PreRender() + */ + virtual void PreRender() = 0; + + /** + * @copydoc Dali::NativeImageSurface::PostRender() + */ + virtual void PostRender() = 0; + + /** + * @copydoc Dali::NativeImageSurface::CanRender() + */ + virtual bool CanRender() = 0; + + /** + * @copydoc Dali::NativeImageSurface::SetGraphicsConfig() + */ + virtual bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) = 0; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_NATIVE_IMAGE_SURFACE_IMPL_H diff --git a/dali/internal/window-system/file.list b/dali/internal/window-system/file.list index 101958f..a3b290f 100644 --- a/dali/internal/window-system/file.list +++ b/dali/internal/window-system/file.list @@ -16,6 +16,8 @@ SET( adaptor_window_system_common_src_files SET( adaptor_window_system_tizen_wayland_src_files ${adaptor_window_system_dir}/tizen-wayland/display-connection-factory-ecore-wl.cpp ${adaptor_window_system_dir}/tizen-wayland/display-connection-impl-ecore-wl.cpp + ${adaptor_window_system_dir}/tizen-wayland/native-image-surface-factory-ecore-wl.cpp + ${adaptor_window_system_dir}/tizen-wayland/native-image-surface-impl-ecore-wl.cpp ${adaptor_window_system_dir}/tizen-wayland/native-render-surface-ecore-wl.cpp ) @@ -45,6 +47,8 @@ SET( adaptor_window_system_ubuntu_x11_src_files ${adaptor_window_system_dir}/ubuntu-x11/window-base-ecore-x.cpp ${adaptor_window_system_dir}/ubuntu-x11/window-factory-ecore-x.cpp ${adaptor_window_system_dir}/ubuntu-x11/window-system-ecore-x.cpp + ${adaptor_window_system_dir}/ubuntu-x11/native-image-surface-factory-x.cpp + ${adaptor_window_system_dir}/ubuntu-x11/native-image-surface-impl-x.cpp ) # module: window-system, backend: android @@ -55,6 +59,8 @@ SET( adaptor_window_system_android_src_files ${adaptor_window_system_dir}/android/window-base-android.cpp ${adaptor_window_system_dir}/android/window-factory-android.cpp ${adaptor_window_system_dir}/android/window-system-android.cpp + ${adaptor_window_system_dir}/android/native-image-surface-factory-android.cpp + ${adaptor_window_system_dir}/android/native-image-surface-impl-android.cpp ) # module: window-system, backend: windows @@ -66,6 +72,8 @@ SET( adaptor_window_system_windows_src_files ${adaptor_window_system_dir}/windows/window-base-win.cpp ${adaptor_window_system_dir}/windows/window-factory-win.cpp ${adaptor_window_system_dir}/windows/window-system-win.cpp + ${adaptor_window_system_dir}/windows/native-image-surface-factory-win.cpp + ${adaptor_window_system_dir}/windows/native-image-surface-impl-win.cpp ) # module: window-system, backend: macos @@ -77,4 +85,6 @@ SET( adaptor_window_system_macos_src_files ${adaptor_window_system_dir}/macos/window-base-mac.mm ${adaptor_window_system_dir}/macos/window-factory-mac.cpp ${adaptor_window_system_dir}/macos/render-surface-factory-mac.cpp + ${adaptor_window_system_dir}/macos/native-image-surface-factory-mac.cpp + ${adaptor_window_system_dir}/macos/native-image-surface-impl-mac.cpp ) diff --git a/dali/internal/window-system/macos/native-image-surface-factory-mac.cpp b/dali/internal/window-system/macos/native-image-surface-factory-mac.cpp new file mode 100644 index 0000000..d50dd1b --- /dev/null +++ b/dali/internal/window-system/macos/native-image-surface-factory-mac.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 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 +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +std::unique_ptr NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue) +{ + return std::make_unique(queue); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/macos/native-image-surface-impl-mac.cpp b/dali/internal/window-system/macos/native-image-surface-impl-mac.cpp new file mode 100644 index 0000000..86eaaf0 --- /dev/null +++ b/dali/internal/window-system/macos/native-image-surface-impl-mac.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 + +using namespace Dali::Internal::Adaptor; + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +NativeImageSurfaceCocoa::NativeImageSurfaceCocoa(Dali::NativeImageSourceQueuePtr queue) +{ +} + +NativeImageSurfaceCocoa::~NativeImageSurfaceCocoa() +{ +} + +Any NativeImageSurfaceCocoa::GetNativeRenderable() +{ + return Any(); +} + +void NativeImageSurfaceCocoa::InitializeGraphics() +{ +} + +void NativeImageSurfaceCocoa::TerminateGraphics() +{ +} + +void NativeImageSurfaceCocoa::PreRender() +{ +} + +void NativeImageSurfaceCocoa::PostRender() +{ +} + +bool NativeImageSurfaceCocoa::CanRender() +{ + return false; +} + +bool NativeImageSurfaceCocoa::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) +{ + return false; +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/macos/native-image-surface-impl-mac.h b/dali/internal/window-system/macos/native-image-surface-impl-mac.h new file mode 100644 index 0000000..21275ba --- /dev/null +++ b/dali/internal/window-system/macos/native-image-surface-impl-mac.h @@ -0,0 +1,85 @@ +#pragma once + +/* + * Copyright (c) 2021 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 + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +class NativeImageSurfaceCocoa : public Dali::Internal::Adaptor::NativeImageSurface +{ +public: + /** + * @param [in] queue the NativeImageSourceQueue pointer + */ + NativeImageSurfaceCocoa(Dali::NativeImageSourceQueuePtr queue); + + /** + * @brief Destructor + */ + ~NativeImageSurfaceCocoa(); + +public: + /** + * @copydoc Dali::NativeImageSurface::GetNativeRenderable() + */ + Any GetNativeRenderable() override; + + /** + * @copydoc Dali::NativeImageSurface::InitializeGraphics() + */ + void InitializeGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::TerminateGraphics() + */ + void TerminateGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::PreRender() + */ + void PreRender() override; + + /** + * @copydoc Dali::NativeImageSurface::PostRender() + */ + void PostRender() override; + + /** + * @copydoc Dali::NativeImageSurface::CanRender() + */ + bool CanRender() override; + + /** + * @copydoc Dali::NativeImageSurface::SetGraphicsConfig() + */ + bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/tizen-wayland/native-image-surface-factory-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-image-surface-factory-ecore-wl.cpp new file mode 100644 index 0000000..2999e10 --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/native-image-surface-factory-ecore-wl.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 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 +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +std::unique_ptr NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue) +{ + return std::make_unique(queue); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp new file mode 100644 index 0000000..c4b68f9 --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2021 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 + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include + +using namespace Dali::Internal::Adaptor; + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +NativeImageSurfaceEcoreWl::NativeImageSurfaceEcoreWl(Dali::NativeImageSourceQueuePtr queue) +: mDisplayConnection(nullptr), + mGraphics(nullptr), + mEGL(nullptr), + mEGLSurface(nullptr), + mEGLContext(nullptr), + mColorDepth(COLOR_DEPTH_32), + mTbmQueue(nullptr), + mDepth(false), + mStencil(false), + mGLESVersion(30), + mMSAA(0) +{ + if(queue) + { + mTbmQueue = AnyCast(queue->GetNativeImageSourceQueue()); + mTbmFormat = tbm_surface_queue_get_format(mTbmQueue); + mColorDepth = (mTbmFormat == TBM_FORMAT_ARGB8888) ? COLOR_DEPTH_32 : COLOR_DEPTH_24; + } + else + { + DALI_LOG_ERROR("NativeImageSourceQueue is null."); + } +} + +bool NativeImageSurfaceEcoreWl::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) +{ + bool featureFlag = false; + int error = SYSTEM_INFO_ERROR_NONE; + + if(version == 30) + { + error = system_info_get_platform_bool("http://tizen.org/feature/opengles.version.3_0", &featureFlag); + } + else if(version == 20) + { + error = system_info_get_platform_bool("http://tizen.org/feature/opengles.version.2_0", &featureFlag); + } + else + { + DALI_LOG_ERROR("version is not valid"); + return false; + } + + if(error != SYSTEM_INFO_ERROR_NONE) + { + DALI_LOG_ERROR("Can't check platform feature.\n"); + return false; + } + + if(featureFlag) + { + mDepth = depth; + mStencil = stencil; + if(mMSAA == 0) + { + //EGL_DONT_CARE is -1 + mMSAA = -1; + } + else + { + mMSAA = msaa; + } + mGLESVersion = version; + } + + return featureFlag; +} + +Any NativeImageSurfaceEcoreWl::GetNativeRenderable() +{ + return mTbmQueue; +} + +void NativeImageSurfaceEcoreWl::InitializeGraphics() +{ + std::unique_ptr graphicsFactoryPtr = Utils::MakeUnique(*(new EnvironmentOptions())); + auto graphicsFactory = *graphicsFactoryPtr.get(); + + mGraphics = std::unique_ptr(&graphicsFactory.Create()); + GraphicsInterface* graphics = mGraphics.get(); + auto eglGraphics = static_cast(graphics); + eglGraphics->Initialize(mDepth, mStencil, false, mMSAA); + + mDisplayConnection = std::unique_ptr(Dali::DisplayConnection::New(*mGraphics, Dali::RenderSurfaceInterface::Type::NATIVE_RENDER_SURFACE)); + mDisplayConnection->Initialize(); + + mEGL = &eglGraphics->GetEglInterface(); + + if(mEGLContext == NULL) + { + Internal::Adaptor::EglImplementation& eglImpl = static_cast(*mEGL); + eglImpl.SetGlesVersion(mGLESVersion); + + if(eglImpl.ChooseConfig(true, mColorDepth) == false) + { + DALI_LOG_ERROR("InitializeGraphics: Fail to choose config. Version:%d, ColorDepth:%d, depth:%d, stencil:%d, MSAA:%d", + mGLESVersion, + mColorDepth == COLOR_DEPTH_32 ? 32 : 24, + mDepth ? 24 : 0, + mStencil ? 8 : 0, + mMSAA); + return; + } + + // Create the OpenGL Surface & Context + eglImpl.CreateWindowContext(mEGLContext); + mEGLSurface = eglImpl.CreateSurfaceWindow(reinterpret_cast(mTbmQueue), mColorDepth); + + MakeContextCurrent(); + } +} + +void NativeImageSurfaceEcoreWl::TerminateGraphics() +{ + GraphicsInterface* graphics = mGraphics.get(); + auto eglGraphics = static_cast(graphics); + + Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + if(mEGLSurface) + { + eglImpl.DestroySurface(mEGLSurface); + } + + if(mEGLContext) + { + eglImpl.DestroyContext(mEGLContext); + } +} + +void NativeImageSurfaceEcoreWl::PreRender() +{ + MakeContextCurrent(); +} + +void NativeImageSurfaceEcoreWl::PostRender() +{ + GraphicsInterface* graphics = mGraphics.get(); + auto eglGraphics = static_cast(graphics); + if(eglGraphics) + { + Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + eglImpl.SwapBuffers(mEGLSurface); + } +} + +void NativeImageSurfaceEcoreWl::MakeContextCurrent() +{ + if(mEGL != nullptr) + { + if(mEGLSurface && mEGLContext) + { + mEGL->MakeContextCurrent(mEGLSurface, mEGLContext); + } + else + { + DALI_LOG_ERROR("EGLSurface(%p) or mEGLContext(%p) is null\n", mEGLSurface, mEGLContext); + } + } +} + +bool NativeImageSurfaceEcoreWl::CanRender() +{ + return tbm_surface_queue_can_dequeue(mTbmQueue, 0); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.h b/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.h new file mode 100644 index 0000000..f78ea90 --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.h @@ -0,0 +1,111 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_IMAGE_SURFACE_IMPL_ECORE_WL_H +#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_IMAGE_SURFACE_IMPL_ECORE_WL_H + +/* + * Copyright (c) 2021 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 + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +class NativeImageSurfaceEcoreWl : public Dali::Internal::Adaptor::NativeImageSurface +{ +public: + /** + * @param [in] queue the NativeImageSourceQueue pointer + */ + NativeImageSurfaceEcoreWl(Dali::NativeImageSourceQueuePtr queue); + + /** + * @brief Destructor + */ + ~NativeImageSurfaceEcoreWl() = default; + +public: + /** + * @copydoc Dali::NativeImageSurface::GetNativeRenderable() + */ + Any GetNativeRenderable() override; + + /** + * @copydoc Dali::NativeImageSurface::InitializeGraphics() + */ + void InitializeGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::TerminateGraphics() + */ + void TerminateGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::PreRender() + */ + void PreRender() override; + + /** + * @copydoc Dali::NativeImageSurface::PostRender() + */ + void PostRender() override; + + /** + * @copydoc Dali::NativeImageSurface::CanRender() + */ + bool CanRender() override; + + /** + * @copydoc Dali::NativeImageSurface::SetGraphicsConfig() + */ + bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override; + +private: + void MakeContextCurrent(); + +private: // Data + std::unique_ptr mDisplayConnection; ///< The native display connection + std::unique_ptr mGraphics; ///< Graphics interface + EglInterface* mEGL; + EGLSurface mEGLSurface; + EGLContext mEGLContext; + ColorDepth mColorDepth; + tbm_format mTbmFormat; + tbm_surface_queue_h mTbmQueue; + + bool mDepth : 1; + bool mStencil : 1; + int mGLESVersion; + int mMSAA; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_IMAGE_SURFACE_IMPL_ECORE_WL_H diff --git a/dali/internal/window-system/ubuntu-x11/native-image-surface-factory-x.cpp b/dali/internal/window-system/ubuntu-x11/native-image-surface-factory-x.cpp new file mode 100644 index 0000000..b053f46 --- /dev/null +++ b/dali/internal/window-system/ubuntu-x11/native-image-surface-factory-x.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 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 +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +std::unique_ptr NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue) +{ + return std::make_unique(queue); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.cpp b/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.cpp new file mode 100644 index 0000000..a953e6e --- /dev/null +++ b/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 + +using namespace Dali::Internal::Adaptor; + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +NativeImageSurfaceX::NativeImageSurfaceX(Dali::NativeImageSourceQueuePtr queue) +{ +} + +NativeImageSurfaceX::~NativeImageSurfaceX() +{ +} + +Any NativeImageSurfaceX::GetNativeRenderable() +{ + return Any(); +} + +void NativeImageSurfaceX::InitializeGraphics() +{ +} + +void NativeImageSurfaceX::TerminateGraphics() +{ +} + +void NativeImageSurfaceX::PreRender() +{ +} + +void NativeImageSurfaceX::PostRender() +{ +} + +bool NativeImageSurfaceX::CanRender() +{ + return false; +} + +bool NativeImageSurfaceX::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) +{ + return false; +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.h b/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.h new file mode 100644 index 0000000..b5d597e --- /dev/null +++ b/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.h @@ -0,0 +1,88 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_X_NATIVE_IMAGE_SURFACE_IMPL_X_H +#define DALI_INTERNAL_WINDOWSYSTEM_X_NATIVE_IMAGE_SURFACE_IMPL_X_H + +/* + * Copyright (c) 2021 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 + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +class NativeImageSurfaceX : public Dali::Internal::Adaptor::NativeImageSurface +{ +public: + /** + * @param [in] queue the NativeImageSourceQueue pointer + */ + NativeImageSurfaceX(Dali::NativeImageSourceQueuePtr queue); + + /** + * @brief Destructor + */ + ~NativeImageSurfaceX(); + +public: + /** + * @copydoc Dali::NativeImageSurface::GetNativeRenderable() + */ + Any GetNativeRenderable() override; + + /** + * @copydoc Dali::NativeImageSurface::InitializeGraphics() + */ + void InitializeGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::InitializeGraphics() + */ + void TerminateGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::PreRender() + */ + void PreRender() override; + + /** + * @copydoc Dali::NativeImageSurface::PostRender() + */ + void PostRender() override; + + /** + * @copydoc Dali::NativeImageSurface::CanRender() + */ + bool CanRender() override; + + /** + * @copydoc Dali::NativeImageSurface::SetGraphicsConfig() + */ + bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_X_NATIVE_IMAGE_SURFACE_IMPL_X_H diff --git a/dali/internal/window-system/windows/native-image-surface-factory-win.cpp b/dali/internal/window-system/windows/native-image-surface-factory-win.cpp new file mode 100644 index 0000000..a66836f --- /dev/null +++ b/dali/internal/window-system/windows/native-image-surface-factory-win.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 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 +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +std::unique_ptr NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue) +{ + return std::make_unique(queue); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/windows/native-image-surface-impl-win.cpp b/dali/internal/window-system/windows/native-image-surface-impl-win.cpp new file mode 100644 index 0000000..1caa790 --- /dev/null +++ b/dali/internal/window-system/windows/native-image-surface-impl-win.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 + +using namespace Dali::Internal::Adaptor; + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +NativeImageSurfaceWin::NativeImageSurfaceWin(Dali::NativeImageSourceQueuePtr queue) +{ +} + +NativeImageSurfaceWin::~NativeImageSurfaceWin() +{ +} + +Any NativeImageSurfaceWin::GetNativeRenderable() +{ + return Any(); +} + +void NativeImageSurfaceWin::InitializeGraphics() +{ +} + +void NativeImageSurfaceWin::TerminateGraphics() +{ +} + +void NativeImageSurfaceWin::PreRender() +{ +} + +void NativeImageSurfaceWin::PostRender() +{ +} + +bool NativeImageSurfaceWin::CanRender() +{ + return false; +} + +bool NativeImageSurfaceWin::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) +{ + return false; +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/windows/native-image-surface-impl-win.h b/dali/internal/window-system/windows/native-image-surface-impl-win.h new file mode 100644 index 0000000..d79e04b --- /dev/null +++ b/dali/internal/window-system/windows/native-image-surface-impl-win.h @@ -0,0 +1,88 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_WIN_NATIVE_IMAGE_SURFACE_IMPL_WIN_H +#define DALI_INTERNAL_WINDOWSYSTEM_WIN_NATIVE_IMAGE_SURFACE_IMPL_WIN_H + +/* + * Copyright (c) 2021 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 + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +class NativeImageSurfaceWin : public Dali::Internal::Adaptor::NativeImageSurface +{ +public: + /** + * @param [in] queue the NativeImageSourceQueue pointer + */ + NativeImageSurfaceWin(Dali::NativeImageSourceQueuePtr queue); + + /** + * @brief Destructor + */ + ~NativeImageSurfaceWin(); + +public: + /** + * @copydoc Dali::NativeImageSurface::GetNativeRenderable() + */ + Any GetNativeRenderable() override; + + /** + * @copydoc Dali::NativeImageSurface::InitializeGraphics() + */ + void InitializeGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::TerminateGraphics() + */ + void TerminateGraphics() override; + + /** + * @copydoc Dali::NativeImageSurface::PreRender() + */ + void PreRender() override; + + /** + * @copydoc Dali::NativeImageSurface::PostRender() + */ + void PostRender() override; + + /** + * @copydoc Dali::NativeImageSurface::CanRender() + */ + bool CanRender() override; + + /** + * @copydoc Dali::NativeImageSurface::SetGraphicsConfig() + */ + bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_WIN_NATIVE_IMAGE_SURFACE_IMPL_WIN_H -- 2.7.4