Skip to content

[Impeller] saveLayer ignores opacity of paint with blend mode lighten. #126532

Description

@spkersten

Is there an existing issue for this?

Steps to reproduce

When using canvas.saveLayer with a paint that has BlendMode.lighten and a color with opacity, the opacity is ignored.

Expected results

Looks the same as without impeller. See screenshot.

Actual results

Opacity is ignored. See screenshot.

Code sample

Code sample
import 'package:flutter/widgets.dart';

void main() {
  runApp(CustomPaint(painter: _FooPainter()));
}


class _FooPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final rect = Offset.zero & size;
    canvas.drawRect(rect, Paint()..color = const Color(0xffff0000));

    const opacity = 0.5;
    canvas.saveLayer(
      rect,
      Paint()
        ..blendMode = BlendMode.lighten
        ..color = Color.fromARGB((opacity * 255).round(), 255, 255, 255),
    );

    canvas.drawCircle(rect.center, 80, Paint()..color = const Color(0xff00ff00));

    canvas.restore();
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}

Screenshots or Video

Screenshots

Expected (without Impeller):
no-impeller

Actual (Impeller):
iOS-impeller

Logs

No response

Flutter Doctor output

Doctor output
Flutter (Channel unknown, 3.10.0, on macOS 13.3.1 22E772610a darwin-arm64, locale en-NL)

Metadata

Metadata

Labels

P2Important issues not at the top of the work listc: renderingUI glitches reported at the engine/skia or impeller rendering levele: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.found in release: 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

Type

No type
No fields configured for issues without a type.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions