Skip to content

[Impeller] It is not working as expected when save layer with image filter and alpha #112175

@ColdPaleLight

Description

@ColdPaleLight

It can reproduce on master channel.

Reproduce code

Code
import 'dart:ui' as ui;

import 'package:flutter/material.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(
    MaterialApp(
      home: Container(
        color: Colors.blue,
        child: CustomPaint(
          painter: MyPaint(),
        ),
      ),
    ),
  );
}

const ColorFilter colorFilter = ColorFilter.matrix([
  1.0, 0.0, 0.0, 0.0, 0.0, //
  0.0, 1.0, 0.0, 0.0, 0.0, //
  0.0, 0.0, 1.0, 0.0, 0.0, //
  0.0, 0.0, 0.0, 2.0, 0.0, //
]);

class MyPaint extends CustomPainter {
  @override
  void paint(ui.Canvas canvas, ui.Size size) {
    Rect rect = Rect.fromLTWH(0, 0, 100, 100);

    ui.Paint paint1 = Paint();
    paint1.color = Colors.white.withOpacity(0.5);
    paint1.imageFilter = colorFilter;
    canvas.saveLayer(null, paint1);
    canvas.translate(100, 100);
    canvas.drawRect(rect, Paint()..color = const Color(0xFFFF0000));
    canvas.restore();

    ui.Paint paint2 = Paint();
    paint2.color = Colors.white.withOpacity(0.5);
    paint2.colorFilter = colorFilter;
    canvas.saveLayer(null, paint2);
    canvas.translate(100, 300);
    canvas.drawRect(rect, Paint()..color = const Color(0xFFFF0000));
    canvas.restore();
  }

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

Expected result

Image

Actual result

Image

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work liste: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.r: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions