[Tizen] Add get/set Dpi to window system 01/290401/1
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 21 Mar 2023 10:33:58 +0000 (19:33 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Fri, 24 Mar 2023 04:09:12 +0000 (13:09 +0900)
Change-Id: I7ddebe179b025d6d1e45595216c9cb5f2dce851a
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/text/text-abstraction/font-client-impl.cpp
dali/internal/window-system/common/window-system.cpp [new file with mode: 0644]
dali/internal/window-system/common/window-system.h
dali/internal/window-system/file.list

index ddc8ccd..81c9aff 100644 (file)
@@ -67,6 +67,7 @@
 #include <dali/internal/window-system/common/event-handler.h>
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/window-system.h>
 
 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
 #include <dali/internal/system/common/logging.h>
@@ -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();
index f6e5c9c..fad420c 100644 (file)
@@ -26,6 +26,7 @@
 // INTERNAL INCLUDES
 #include <dali/devel-api/common/singleton-service.h>
 #include <dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.h>
+#include <dali/internal/window-system/common/window-system.h>
 
 #include <dali/devel-api/text-abstraction/glyph-info.h>
 
@@ -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 (file)
index 0000000..a5f27d3
--- /dev/null
@@ -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 <dali/internal/window-system/common/window-system.h>
+
+// EXTERNAL_HEADERS
+#include <cstdio>
+
+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
index d669791..a551f90 100644 (file)
@@ -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);
index ac9be4f..c142f37 100644 (file)
@@ -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