From 604a485cf188844b71f7e3426cada311ace2f147 Mon Sep 17 00:00:00 2001 From: zarzet <42882290+zarzet@users.noreply.github.com> Date: Mon, 5 Oct 2026 19:20:04 +0700 Subject: [PATCH] perf(player): reuse artwork decodes across Mornye transitions --- lib/screens/now_playing_screen.dart | 1 + lib/widgets/mornye_player_artwork.dart | 5 +---- lib/widgets/mornye_player_layout.dart | 8 +++----- lib/widgets/player_artwork.dart | 6 ++++++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/screens/now_playing_screen.dart b/lib/screens/now_playing_screen.dart index b78fbc32..28ae3a17 100644 --- a/lib/screens/now_playing_screen.dart +++ b/lib/screens/now_playing_screen.dart @@ -263,6 +263,7 @@ class _NowPlayingScreenState extends ConsumerState { ? PlayerArtwork( artUri: mediaItem.artUri?.toString(), colorScheme: colorScheme, + cacheWidth: PlayerArtwork.transitionCacheWidth(context), ) : artwork(), ), diff --git a/lib/widgets/mornye_player_artwork.dart b/lib/widgets/mornye_player_artwork.dart index dfaa0acb..59031626 100644 --- a/lib/widgets/mornye_player_artwork.dart +++ b/lib/widgets/mornye_player_artwork.dart @@ -41,10 +41,7 @@ class _MornyePlayerArtworkState extends ConsumerState { child: PlayerArtwork( artUri: widget.mediaItem.artUri?.toString(), colorScheme: Theme.of(context).colorScheme, - cacheWidth: - (MediaQuery.sizeOf(context).width * - MediaQuery.devicePixelRatioOf(context)) - .round(), + cacheWidth: PlayerArtwork.transitionCacheWidth(context), ), ), ); diff --git a/lib/widgets/mornye_player_layout.dart b/lib/widgets/mornye_player_layout.dart index a90bcc75..bfb94ad9 100644 --- a/lib/widgets/mornye_player_layout.dart +++ b/lib/widgets/mornye_player_layout.dart @@ -333,11 +333,9 @@ class MornyePlayerLayout extends ConsumerWidget { ?.toString(), colorScheme: colorScheme, cacheWidth: - (360 * - MediaQuery.devicePixelRatioOf( - context, - )) - .round(), + PlayerArtwork.transitionCacheWidth( + context, + ), ), ), ), diff --git a/lib/widgets/player_artwork.dart b/lib/widgets/player_artwork.dart index a41d4411..16a52f5f 100644 --- a/lib/widgets/player_artwork.dart +++ b/lib/widgets/player_artwork.dart @@ -20,6 +20,12 @@ class PlayerArtwork extends StatelessWidget { this.iconSize = 40, }); + /// Share one full-size decode while artwork moves between player panels. + static int transitionCacheWidth(BuildContext context) => + (MediaQuery.sizeOf(context).width * + MediaQuery.devicePixelRatioOf(context)) + .round(); + @override Widget build(BuildContext context) { final placeholder = Container(