Skip to content

[Impeller] Color issue with BlendMode.screen when using Gradient.linear shader in Paint #145442

@zhxst

Description

@zhxst

Steps to reproduce

I can still replay the issue B at #141160 .
Flutter version 3.19.3 and master channel 3.21.0-11.0.pre.42 .
Code list below.

Expected results

Green circle.

Actual results

black circle.

Code sample

Code sample
import 'package:flutter/material.dart';
import 'dart:ui' as ui;

void main() {
  runApp(const MyWidget());
}

class MyWidget extends StatelessWidget {
  const MyWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Align(
          alignment: Alignment.center,
          child: CustomPaint(
            size: Size.infinite,
            painter: BubbleLayerPainter(),
          ),
        ),
      ),
    );
  }
}

class BubbleLayerPainter extends CustomPainter {
  const BubbleLayerPainter();
  @override
  void paint(Canvas canvas, Size size) {
    final colorBlur = Paint()
      ..style = PaintingStyle.fill
      ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 10)
      ..color = Colors.black;

    final center = size.center(Offset.zero);
    canvas.drawCircle(center, 128, colorBlur);
    final surface = Paint()
      ..blendMode = BlendMode.screen
      ..shader = ui.Gradient.linear(
         Offset.zero, Offset(0, size.height), [Colors.green, Colors.green]);
    canvas.drawPaint(surface);
  }

  @override
  bool shouldRepaint(BubbleLayerPainter oldDelegate) {
    return true;
  }
}

Screenshots or Video

Screenshots / Video demonstration
Impeller On Impeller Off

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.3, on macOS 13.6 22G120 darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.19.3 on channel stable at /Users/abc/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ba39319843 (12 days ago), 2024-03-07 15:22:21 -0600
    • Engine revision 2e4ba9c6fb
    • Dart version 3.3.1
    • DevTools version 2.31.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/zhx/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode_15.2.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.15.2

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.87.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.85.20240301

[✓] Connected device (1 available)
    • iPhone (mobile) • ___ • ios • iOS 16.5.1 20F75

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work liste: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.found in release: 3.19Found to occur in 3.19found in release: 3.21Found to occur in 3.21has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions