From 8184cd8a6ab72a4c6a57971f330ab739c21020a9 Mon Sep 17 00:00:00 2001 From: Nayan Date: Fri, 21 Nov 2025 14:59:54 -0500 Subject: [PATCH] ui: optimize `gui_app` & spinner (#1474) remove gui_app_sp & use upstream gui_app Co-authored-by: Jason Wen --- system/ui/spinner.py | 4 +--- system/ui/sunnypilot/lib/application.py | 24 ------------------------ 2 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 system/ui/sunnypilot/lib/application.py diff --git a/system/ui/spinner.py b/system/ui/spinner.py index dc4923081..33f4543c3 100755 --- a/system/ui/spinner.py +++ b/system/ui/spinner.py @@ -8,8 +8,6 @@ from openpilot.system.ui.lib.text_measure import measure_text_cached from openpilot.system.ui.text import wrap_text from openpilot.system.ui.widgets import Widget -from openpilot.system.ui.sunnypilot.lib.application import gui_app_sp - # Constants if gui_app.big_ui(): PROGRESS_BAR_WIDTH = 1000 @@ -37,7 +35,7 @@ def clamp(value, min_value, max_value): class Spinner(Widget): def __init__(self): super().__init__() - self._comma_texture = gui_app_sp.sp_texture("images/spinner_sunnypilot.png", TEXTURE_SIZE, TEXTURE_SIZE) + self._comma_texture = gui_app.texture("../../sunnypilot/selfdrive/assets/images/spinner_sunnypilot.png", TEXTURE_SIZE, TEXTURE_SIZE) self._spinner_texture = gui_app.texture("images/spinner_track.png", TEXTURE_SIZE, TEXTURE_SIZE, alpha_premultiply=True) self._rotation = 0.0 self._progress: int | None = None diff --git a/system/ui/sunnypilot/lib/application.py b/system/ui/sunnypilot/lib/application.py deleted file mode 100644 index 7440d224c..000000000 --- a/system/ui/sunnypilot/lib/application.py +++ /dev/null @@ -1,24 +0,0 @@ -from openpilot.system.ui.lib.application import GuiApplication -from importlib.resources import as_file, files - -ASSETS_DIR_SP = files("openpilot.sunnypilot.selfdrive").joinpath("assets") - - -class GuiApplicationSP(GuiApplication): - - def __init__(self, width: int, height: int): - super().__init__(width, height) - - def sp_texture(self, asset_path: str, width: int, height: int, alpha_premultiply=False, keep_aspect_ratio=True): - cache_key = f"{asset_path}_{width}_{height}_{alpha_premultiply}{keep_aspect_ratio}" - if cache_key in self._textures: - return self._textures[cache_key] - - with as_file(ASSETS_DIR_SP.joinpath(asset_path)) as fspath: - image_obj = self._load_image_from_path(fspath.as_posix(), width, height, alpha_premultiply, keep_aspect_ratio) - texture_obj = self._load_texture_from_image(image_obj) - self._textures[cache_key] = texture_obj - return texture_obj - - -gui_app_sp = GuiApplicationSP(2160, 1080)