-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NUI] Minimize system settings API calls in Text
Each text component's call to the system API takes a lot of time. Especially for FontType, initialization of FontConfig occurs natively and consumes most of the time. This patch updates through static classes only when a specific value is needed. TODO: manager should handle all events. Signed-off-by: Bowon Ryu <[email protected]>
- Loading branch information
Showing
6 changed files
with
114 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/Tizen.NUI/src/internal/Common/SystemFontTypeChangedManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2025 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. | ||
* | ||
*/ | ||
|
||
extern alias TizenSystemSettings; | ||
using TizenSystemSettings.Tizen.System; | ||
|
||
using System; | ||
|
||
namespace Tizen.NUI | ||
{ | ||
/// <summary> | ||
/// A static class which adds user handler to the SystemSettings.FontTypeChanged event. | ||
/// This class also adds user handler to the last of the SystemSettings.FontTypeChanged event. | ||
/// </summary> | ||
internal static class SystemFontTypeChangedManager | ||
{ | ||
static SystemFontTypeChangedManager() | ||
{ | ||
SystemSettings.FontTypeChanged += SystemFontTypeChanged; | ||
} | ||
|
||
/// <summary> | ||
/// The handler invoked last after all handlers added to the SystemSettings.FontTypeChanged event are invoked. | ||
/// </summary> | ||
public static event EventHandler<FontTypeChangedEventArgs> Finished; | ||
|
||
/// <summary> | ||
/// Adds the given handler to the SystemSettings.FontTypeChanged event. | ||
/// </summary> | ||
/// <param name="handler">A handler to be added to the event</param> | ||
public static void Add(EventHandler<FontTypeChangedEventArgs> handler) | ||
{ | ||
proxy.Add(handler); | ||
} | ||
|
||
/// <summary> | ||
/// Removes the given handler from the SystemSettings.FontTypeChanged event. | ||
/// </summary> | ||
/// <param name="handler">A handler to be added to the event</param> | ||
public static void Remove(EventHandler<FontTypeChangedEventArgs> handler) | ||
{ | ||
proxy.Remove(handler); | ||
} | ||
|
||
private static void SystemFontTypeChanged(object sender, FontTypeChangedEventArgs args) | ||
{ | ||
fontType = args.Value; | ||
proxy.Invoke(sender, args); | ||
Finished?.Invoke(sender, args); | ||
} | ||
|
||
public static string FontType | ||
{ | ||
get | ||
{ | ||
if (string.IsNullOrEmpty(fontType)) | ||
{ | ||
fontType = SystemSettings.FontType; | ||
} | ||
return fontType; | ||
} | ||
} | ||
|
||
private static string fontType = string.Empty; | ||
private static WeakEvent<EventHandler<FontTypeChangedEventArgs>> proxy = new WeakEvent<EventHandler<FontTypeChangedEventArgs>>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters