Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion flutter_frontend_server/test/to_string_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ Future<void> main(List<String> args) async {
]));
final ProcessResult runResult = Process.runSync(dart, <String>[regularDill]);
checkProcessResult(runResult);
String paintString = '"Paint.toString":"Paint(Color(0xffffffff))"';
// TODO(matanlurey): "dither: true" is now present by default, until it is
// remove entirely. See https://github.com/flutter/flutter/issues/112498.
String paintString = '"Paint.toString":"Paint(Color(0xffffffff); dither: true)"';
if (buildDir.contains('release')) {
paintString = '"Paint.toString":"Instance of \'Paint\'"';
}
Expand Down
29 changes: 13 additions & 16 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1487,22 +1487,19 @@ class Paint {
_data.setInt32(_kDitherOffset, value ? 1 : 0, _kFakeHostEndian);
}

/// Whether to dither the output when drawing images.
///
/// If false, the default value, dithering will be enabled when the input
/// color depth is higher than the output color depth. For example,
/// drawing an RGB8 image onto an RGB565 canvas.
///
/// This value also controls dithering of [shader]s, which can make
/// gradients appear smoother.
///
/// Whether or not dithering affects the output is implementation defined.
/// Some implementations may choose to ignore this completely, if they're
/// unable to control dithering.
///
/// To ensure that dithering is consistently enabled for your entire
/// application, set this to true before invoking any drawing related code.
static bool enableDithering = false;
/// Whether to dither the output when drawing some elements such as gradients.
///
/// It is not expected that this flag will be used in the future; please leave
/// feedback in <https://github.com/flutter/flutter/issues/112498> if there is
/// a use case for this flag to remain long term.
@Deprecated(
'Dithering is now enabled by default on some elements (such as gradients) '
'and further support for dithering is expected to be handled by custom '
'shaders, so this flag is being removed: '
'https://github.com/flutter/flutter/issues/112498.'
'This feature was deprecated after 3.14.0-0.1.pre.'
)
static bool enableDithering = true;

@override
String toString() {
Expand Down
Binary file modified shell/platform/embedder/fixtures/dpr_noxform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shell/platform/embedder/fixtures/dpr_xform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shell/platform/embedder/fixtures/gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shell/platform/embedder/fixtures/gradient_xform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shell/platform/embedder/fixtures/vk_dpr_noxform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shell/platform/embedder/fixtures/vk_gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions testing/dart/canvas_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ void main() {
}

test('Simple gradient', () async {
// TODO(matanl): While deprecated, we still don't want to accidentally
// change the behavior of the old API,
// https://github.com/flutter/flutter/issues/112498.
// ignore: deprecated_member_use
Paint.enableDithering = false;
final Image image = await toImage((Canvas canvas) {
final Paint paint = Paint()..shader = makeGradient();
Expand All @@ -217,6 +221,8 @@ void main() {
}, skip: !Platform.isLinux); // https://github.com/flutter/flutter/issues/53784

test('Simple dithered gradient', () async {
// TODO(matanl): Reword this test once we remove the deprecated API.
// ignore: deprecated_member_use
Paint.enableDithering = true;
final Image image = await toImage((Canvas canvas) {
final Paint paint = Paint()..shader = makeGradient();
Expand Down