From: Adeel Kazmi Date: Wed, 6 Jan 2021 17:40:05 +0000 (+0000) Subject: Merge "[macos] Prevent race condition while creating the EGL Window" into devel/master X-Git-Tag: dali_2.0.8~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=f17256e55acff8e28b48eaee5fb8fcbcc7c7304c;hp=e1a6e0dc4287d41230dfa6e7e22877df6bfcf51a Merge "[macos] Prevent race condition while creating the EGL Window" into devel/master --- diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 818b4f0..1b9e11f 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -178,18 +178,18 @@ void CombinedUpdateRenderController::Start() mEventThreadSemaphore.Acquire(); } - Dali::RenderSurfaceInterface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface(); - if( currentSurface ) - { - currentSurface->StartRender(); - } - mRunning = TRUE; LOG_EVENT( "Startup Complete, starting Update/Render Thread" ); RunUpdateRenderThread( CONTINUOUS, AnimationProgression::NONE, UpdateMode::NORMAL ); + Dali::RenderSurfaceInterface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface(); + if( currentSurface ) + { + currentSurface->StartRender(); + } + DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Start\n" ); } diff --git a/dali/internal/window-system/file.list b/dali/internal/window-system/file.list index 8a8bccd..4f7b234 100644 --- a/dali/internal/window-system/file.list +++ b/dali/internal/window-system/file.list @@ -71,6 +71,7 @@ SET( adaptor_window_system_windows_src_files SET( adaptor_window_system_macos_src_files ${adaptor_window_system_dir}/macos/display-connection-factory-mac.cpp ${adaptor_window_system_dir}/macos/display-connection-impl-mac.cpp + ${adaptor_window_system_dir}/macos/window-render-surface-cocoa.cpp ${adaptor_window_system_dir}/macos/window-system-mac.mm ${adaptor_window_system_dir}/macos/window-base-mac.mm ${adaptor_window_system_dir}/macos/window-factory-mac.cpp diff --git a/dali/internal/window-system/macos/render-surface-factory-mac.cpp b/dali/internal/window-system/macos/render-surface-factory-mac.cpp index caa386e..1c76cf4 100644 --- a/dali/internal/window-system/macos/render-surface-factory-mac.cpp +++ b/dali/internal/window-system/macos/render-surface-factory-mac.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include "window-render-surface-cocoa.h" namespace Dali::Internal::Adaptor { @@ -37,7 +37,7 @@ RenderSurfaceFactoryCocoa::CreateWindowRenderSurface( bool isTransparent ) { - return Utils::MakeUnique< WindowRenderSurface >( positionSize, surface, isTransparent ); + return Utils::MakeUnique< WindowRenderSurfaceCocoa >( positionSize, surface, isTransparent ); } std::unique_ptr< PixmapRenderSurface > diff --git a/dali/internal/window-system/macos/window-render-surface-cocoa.cpp b/dali/internal/window-system/macos/window-render-surface-cocoa.cpp new file mode 100644 index 0000000..90d0d0d --- /dev/null +++ b/dali/internal/window-system/macos/window-render-surface-cocoa.cpp @@ -0,0 +1,45 @@ +/* + * 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. + * + */ + +#include "window-render-surface-cocoa.h" + +namespace Dali::Internal::Adaptor +{ +WindowRenderSurfaceCocoa::WindowRenderSurfaceCocoa(Dali::PositionSize positionSize, Any surface, bool isTransparent) + : WindowRenderSurface(positionSize, surface, isTransparent) + , mReady(false) +{ +} + +void WindowRenderSurfaceCocoa::StartRender() +{ + std::unique_lock lock(mCondMutex); + WindowRenderSurface::StartRender(); + while (!mReady) + { + mRenderWait.wait(lock); + } +} + +void WindowRenderSurfaceCocoa::CreateSurface() +{ + std::lock_guard lock(mCondMutex); + WindowRenderSurface::CreateSurface(); + mReady = true; + mRenderWait.notify_all(); +} +} // Dali::Internal::Adaptor diff --git a/dali/internal/window-system/macos/window-render-surface-cocoa.h b/dali/internal/window-system/macos/window-render-surface-cocoa.h new file mode 100644 index 0000000..7e573a4 --- /dev/null +++ b/dali/internal/window-system/macos/window-render-surface-cocoa.h @@ -0,0 +1,57 @@ +#pragma once + +/* + * 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 + +namespace Dali::Internal::Adaptor +{ +/** + * We must create the EGL Window before we enter the run loop. + * This specialization ensures this condition is respected. + */ +class WindowRenderSurfaceCocoa : public WindowRenderSurface +{ +public: + + /** + * @copydoc Dali::WindowRenderSurface() + */ + WindowRenderSurfaceCocoa(Dali::PositionSize positionSize, Any surface, bool isTransparent = true); + + /** + * @copydoc Dali::RenderSurfaceInterface::StartRender() + */ + void StartRender() override; + + /** + * @copydoc Dali::RenderSurfaceInterface::CreateSurface() + */ + void CreateSurface() override; + +private: + std::mutex mCondMutex; + std::condition_variable mRenderWait; + bool mReady; +}; +} // Dali::Internal::Adaptor