From 345d8afdd3a269ea22a10a9979969ab5e6701a6c Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Tue, 21 Mar 2023 19:33:58 +0900 Subject: [PATCH] [Tizen] Add get/set Dpi to window system Change-Id: I7ddebe179b025d6d1e45595216c9cb5f2dce851a Signed-off-by: Bowon Ryu --- dali/internal/adaptor/common/adaptor-impl.cpp | 6 +-- .../text/text-abstraction/font-client-impl.cpp | 10 ++++ .../window-system/common/window-system.cpp | 58 ++++++++++++++++++++++ dali/internal/window-system/common/window-system.h | 18 +++++++ dali/internal/window-system/file.list | 5 +- 5 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 dali/internal/window-system/common/window-system.cpp diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index ddc8ccd..81c9aff 100644 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -396,10 +397,7 @@ void Adaptor::Start() dpiHor = dpiVer = 0; defaultWindow->GetSurface()->GetDpi(dpiHor, dpiVer); - - // set the DPI value for font rendering - FontClient fontClient = FontClient::Get(); - fontClient.SetDpi(dpiHor, dpiVer); + Dali::Internal::Adaptor::WindowSystem::SetDpi(dpiHor, dpiVer); // Initialize the thread controller mThreadController->Initialize(); diff --git a/dali/internal/text/text-abstraction/font-client-impl.cpp b/dali/internal/text/text-abstraction/font-client-impl.cpp index f6e5c9c..fad420c 100644 --- a/dali/internal/text/text-abstraction/font-client-impl.cpp +++ b/dali/internal/text/text-abstraction/font-client-impl.cpp @@ -26,6 +26,7 @@ // INTERNAL INCLUDES #include #include +#include #include @@ -76,6 +77,15 @@ Dali::TextAbstraction::FontClient FontClient::Get() fontClientHandle = Dali::TextAbstraction::FontClient(new FontClient); } + uint32_t horizontalDpi, verticalDpi; + fontClientHandle.GetDpi(horizontalDpi, verticalDpi); + if(horizontalDpi == 0u || verticalDpi == 0u) + { + horizontalDpi = verticalDpi = 0u; + Dali::Internal::Adaptor::WindowSystem::GetDpi(horizontalDpi, verticalDpi); + fontClientHandle.SetDpi(horizontalDpi, verticalDpi); + } + service.Register(typeid(fontClientHandle), fontClientHandle); } } diff --git a/dali/internal/window-system/common/window-system.cpp b/dali/internal/window-system/common/window-system.cpp new file mode 100644 index 0000000..a5f27d3 --- /dev/null +++ b/dali/internal/window-system/common/window-system.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 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 HEADERS +#include + +// EXTERNAL_HEADERS +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +namespace WindowSystem +{ +namespace +{ +static uint32_t gDpiHorizontal = 0u; +static uint32_t gDpiVertical = 0u; +} // unnamed namespaces + +void SetDpi(uint32_t dpiHorizontal, uint32_t dpiVertical) +{ + gDpiHorizontal = dpiHorizontal; + gDpiVertical = dpiVertical; +} + +void GetDpi(uint32_t& dpiHorizontal, uint32_t& dpiVertical) +{ + dpiHorizontal = gDpiHorizontal; + dpiVertical = gDpiVertical; +} + +} // namespace WindowSystem + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#pragma GCC diagnostic pop diff --git a/dali/internal/window-system/common/window-system.h b/dali/internal/window-system/common/window-system.h index d669791..a551f90 100644 --- a/dali/internal/window-system/common/window-system.h +++ b/dali/internal/window-system/common/window-system.h @@ -41,6 +41,24 @@ void Initialize(); void Shutdown(); /** + * @brief Set the DPI of the target screen. + * + * @note Multiple screens are not currently supported. + * @param[in] horizontalDpi The horizontal resolution in DPI. + * @param[in] verticalDpi The vertical resolution in DPI. + */ +void SetDpi(uint32_t dpiHorizontal, uint32_t dpiVertical); + +/** + * @brief Retrieves the DPI previously set to the target screen. + * + * @note Multiple screens are not currently supported. + * @param[out] horizontalDpi The horizontal resolution in DPI. + * @param[out] verticalDpi The vertical resolution in DPI. + */ +void GetDpi(uint32_t& dpiHorizontal, uint32_t& dpiVertical); + +/** * @brief Get the screen size */ void GetScreenSize(int32_t& width, int32_t& height); diff --git a/dali/internal/window-system/file.list b/dali/internal/window-system/file.list index ac9be4f..c142f37 100644 --- a/dali/internal/window-system/file.list +++ b/dali/internal/window-system/file.list @@ -3,13 +3,14 @@ SET( adaptor_window_system_common_src_files ${adaptor_window_system_dir}/common/display-connection.cpp ${adaptor_window_system_dir}/common/event-handler.cpp + ${adaptor_window_system_dir}/common/gl-window-impl.cpp + ${adaptor_window_system_dir}/common/gl-window-render-thread.cpp ${adaptor_window_system_dir}/common/native-render-surface-factory.cpp ${adaptor_window_system_dir}/common/orientation-impl.cpp ${adaptor_window_system_dir}/common/window-base.cpp ${adaptor_window_system_dir}/common/window-impl.cpp ${adaptor_window_system_dir}/common/window-render-surface.cpp - ${adaptor_window_system_dir}/common/gl-window-impl.cpp - ${adaptor_window_system_dir}/common/gl-window-render-thread.cpp + ${adaptor_window_system_dir}/common/window-system.cpp ) # module: window-system, backend: tizen-wayland -- 2.7.4