diff --git a/lib/widgets/material_player_backdrop.dart b/lib/widgets/material_player_backdrop.dart index 8b0ca8375..d8cf8e407 100644 --- a/lib/widgets/material_player_backdrop.dart +++ b/lib/widgets/material_player_backdrop.dart @@ -279,11 +279,16 @@ class PlayerCoverBlur extends StatefulWidget { required this.artUri, required this.colorScheme, this.reveal, + this.sigma = 48, }); final String? artUri; final ColorScheme colorScheme; + /// The blur radius in logical pixels. The default keeps the cover's + /// larger shapes; a few times that leaves only its colours. + final double sigma; + /// Without it the blur sits between two layers of the surface colour and /// is blurred live while the cover decodes. With it, only the blur is /// drawn, transparent down to `top` and opaque from `bottom` (logical @@ -297,7 +302,6 @@ class PlayerCoverBlur extends StatefulWidget { class _PlayerCoverBlurState extends State with SingleTickerProviderStateMixin { - static const _sigma = 48.0; static const _artWidth = PlayerArtwork.miniCacheWidth; late final _listener = ImageStreamListener( @@ -392,18 +396,26 @@ class _PlayerCoverBlurState extends State Size size, double dpr, ({double top, double bottom})? reveal, + double logicalSigma, ) { final scale = dpr / 4; final width = math.max(1, (size.width * scale).ceil()); final height = math.max(1, (size.height * scale).ceil()); final rect = Rect.fromLTWH(0, 0, width.toDouble(), height.toDouble()); - final sigma = _sigma * scale; + final sigma = logicalSigma * scale; final recorder = ui.PictureRecorder(); final canvas = Canvas(recorder); if (reveal != null) canvas.saveLayer(rect, Paint()); canvas.saveLayer( rect, - Paint()..imageFilter = ui.ImageFilter.blur(sigmaX: sigma, sigmaY: sigma), + Paint() + ..imageFilter = ui.ImageFilter.blur( + sigmaX: sigma, + sigmaY: sigma, + // Alone over a sharp cover the blur has to stay opaque up to its + // edges; between the surface layers it fades into them instead. + tileMode: reveal == null ? null : TileMode.clamp, + ), ); paintImage( canvas: canvas, @@ -453,7 +465,10 @@ class _PlayerCoverBlurState extends State if (reveal != null) return const SizedBox.shrink(); // Blur live while the cover decodes and for the placeholder. blurred = ImageFiltered( - imageFilter: ui.ImageFilter.blur(sigmaX: _sigma, sigmaY: _sigma), + imageFilter: ui.ImageFilter.blur( + sigmaX: widget.sigma, + sigmaY: widget.sigma, + ), child: PlayerArtwork( artUri: widget.artUri, colorScheme: widget.colorScheme, @@ -464,10 +479,11 @@ class _PlayerCoverBlurState extends State final dpr = MediaQuery.devicePixelRatioOf(context); blurred = LayoutBuilder( builder: (context, constraints) { - final inputs = (art, constraints.biggest, dpr, reveal); + final sigma = widget.sigma; + final inputs = (art, constraints.biggest, dpr, reveal, sigma); if (inputs != _blurInputs) { _blur?.dispose(); - _blur = _render(art, constraints.biggest, dpr, reveal); + _blur = _render(art, constraints.biggest, dpr, reveal, sigma); _blurInputs = inputs; } final outgoing = _outgoing; diff --git a/lib/widgets/mornye_player_background.dart b/lib/widgets/mornye_player_background.dart index 37d837f61..a9c483fdf 100644 --- a/lib/widgets/mornye_player_background.dart +++ b/lib/widgets/mornye_player_background.dart @@ -273,6 +273,10 @@ class _CoverBlur extends StatelessWidget { // Opaque by the middle of the artwork's own fade, before the // flat gradient under it shows as a dull band between the two. reveal: (top: top, bottom: (top + bottom) / 2), + // Far past the cover's shapes: they would read as a second, + // see-through cover under the sharp one. Only its colours stay, + // as one tone that shifts slowly down the screen. + sigma: 120, ), DecoratedBox( decoration: BoxDecoration(