-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#34835Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.1Found to occur in 3.1Found to occur in 3.1found in release: 3.3Found to occur in 3.3Found to occur in 3.3has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
The result returned by the "ui.canvas.getDestinationClipBounds()" method is incorrect when with matrix.
Steps to Reproduce
run with the following code on master channel
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/widgets.dart';
void main() {
runApp(CustomPaint(painter: MyPainter()));
}
class MyPainter extends CustomPainter {
const MyPainter();
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint();
{
// case 1
paint.strokeWidth = 10;
paint.color = const Color(0xFFFFFFFF);
Offset p1 = const Offset(0, 0);
Offset p2 = const Offset(100, 100);
Rect rect = Rect.fromLTWH(0, 0, 100, 100);
canvas.save();
canvas.clipRect(rect);
canvas.translate(0, 100);
canvas.clipRect(rect);
print("case1 clip bounds is ${canvas.getDestinationClipBounds()}");
canvas.drawLine(p1, p2, paint);
canvas.restore();
}
{
// case 2
paint.strokeWidth = 10;
paint.color = const Color(0xFFFF0000);
Offset p1 = const Offset(0, 100);
Offset p2 = const Offset(100, 0);
Rect rect1 = Rect.fromLTWH(0, 0, 100, 100);
Rect rect2 = Rect.fromLTWH(100, 100, 200, 200);
canvas.save();
canvas.clipRect(rect1);
canvas.translate(-100, -100);
canvas.clipRect(rect2);
print("case2 clip bounds is ${canvas.getDestinationClipBounds()}");
canvas.translate(100, 100);
canvas.drawLine(p1, p2, paint);
canvas.restore();
}
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}
expected result
expected see the following lines in log.
case1 clip bounds is Rect.fromLTRB(0.0, 0.0, 0.0, 0.0)
case2 clip bounds is Rect.fromLTRB(0.0, 0.0, 100.0, 100.0)
actual result
actual log
case1 clip bounds is Rect.fromLTRB(0.0, 0.0, 100.0, 100.0)
case2 clip bounds is Rect.fromLTRB(0.0, 0.0, 0.0, 0.0)
Cause
matrix().mapRect(rect) was not used when calculating the intersection of clip bounds of multiple clipRect calls, which caused this issue.
c.f.
https://github.com/flutter/engine/blob/6ecab1ed96cbf7605317afff36e983049848c484/display_list/display_list_builder.cc#L605
cc @flar
flutter doctor -v
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1806, on macOS 12.2.1 21D62 darwin-arm (Rosetta), locale zh-Hans-CN)
• Flutter version 3.1.0-0.0.pre.1806 on channel master at /Users/bytedance/Develop/upstream/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision dd20919ad6 (23 minutes ago), 2022-07-21 20:50:08 -0700
• Engine revision a56d98ea78
• Dart version 2.19.0 (build 2.19.0-22.0.dev)
• DevTools version 2.15.0
• Pub download mirror https://dart-pub.byted.org
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/bytedance/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 13F100
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.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 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.68.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.44.0
[✓] Connected device (3 available)
• M2011K2C (mobile) • e717b6a0 • android-arm64 • Android 12 (API 31)
• macOS (desktop) • macos • darwin-arm64 • macOS 12.2.1 21D62 darwin-arm (Rosetta)
• Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.134
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.1Found to occur in 3.1Found to occur in 3.1found in release: 3.3Found to occur in 3.3Found to occur in 3.3has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version