From e996c123d44be564b822d5a407120b96cc546a50 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Tue, 8 Aug 2023 18:05:33 -0700 Subject: [PATCH] [Impeller] Plumb Paint.enableDithering to backend (flutter/engine#44522) Closes https://github.com/flutter/flutter/issues/131450 and https://github.com/flutter/flutter/issues/118073. Example from https://github.com/flutter/flutter/issues/118073: ```diff import 'package:flutter/material.dart'; void main() { + Paint.enableDithering = true; runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Container( width: double.infinity, decoration: const BoxDecoration( gradient: LinearGradient( colors: [Color(0xffcccccc), Color(0xff333333)])), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headlineMedium, ), ], ), ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); } } ``` ## Before Screenshot 2023-08-08 at 5 15 40 PM ## After Screenshot 2023-08-08 at 5 15 01 PM --- engine/src/flutter/impeller/display_list/dl_dispatcher.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/engine/src/flutter/impeller/display_list/dl_dispatcher.cc b/engine/src/flutter/impeller/display_list/dl_dispatcher.cc index c2d65bc260..4ddaee6eb1 100644 --- a/engine/src/flutter/impeller/display_list/dl_dispatcher.cc +++ b/engine/src/flutter/impeller/display_list/dl_dispatcher.cc @@ -187,10 +187,7 @@ void DlDispatcher::setAntiAlias(bool aa) { // |flutter::DlOpReceiver| void DlDispatcher::setDither(bool dither) { - // TODO(https://github.com/flutter/flutter/issues/131450): Implement dither. - // - // This is intentionally left blank because we don't want to ship enabling - // dithering from the framework yet (it's only used in Impeller-only tests). + paint_.dither = dither; } static Paint::Style ToStyle(flutter::DlDrawStyle style) {