MCPcopy
hub / github.com/commaai/openpilot / texture

Method texture

system/ui/lib/application.py:454–475  ·  view source on GitHub ↗
(self, asset_path: str, width: int | None = None, height: int | None = None,
              alpha_premultiply=False, keep_aspect_ratio=True, flip_x: bool = False)

Source from the content-addressed store, hash-verified

452 self._should_render = should_render
453
454 def texture(self, asset_path: str, width: int | None = None, height: int | None = None,
455 alpha_premultiply=False, keep_aspect_ratio=True, flip_x: bool = False) -> rl.Texture:
456 if width is not None:
457 width = round(width)
458 if height is not None:
459 height = round(height)
460
461 cache_key = f"{asset_path}_{width}_{height}_{alpha_premultiply}_{keep_aspect_ratio}_{flip_x}"
462 if cache_key in self._textures:
463 return self._textures[cache_key]
464
465 with as_file(ASSETS_DIR.joinpath(asset_path)) as fspath:
466 image_obj = self._load_image_from_path(fspath.as_posix(), width, height, alpha_premultiply, keep_aspect_ratio, flip_x)
467 texture_obj = self._load_texture_from_image(image_obj)
468
469 # Set logical size so widget layout math stays at 1x coordinates
470 if self._scale != 1.0 and width is not None and height is not None:
471 texture_obj.width = width
472 texture_obj.height = height
473
474 self._textures[cache_key] = texture_obj
475 return texture_obj
476
477 def _load_image_from_path(self, image_path: str, width: int | None = None, height: int | None = None,
478 alpha_premultiply: bool = False, keep_aspect_ratio: bool = True, flip_x: bool = False) -> rl.Image:

Callers 15

__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 2

_load_image_from_pathMethod · 0.95

Tested by 1

test_dialogs_do_not_leakFunction · 0.64