From eb5a3553dcae07481b15b93dd7223e29611a36b4 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Mon, 9 Aug 2021 14:22:15 -0400 Subject: [PATCH] Do not turn on dithering by default Bug: 195281495 Test: Ief7025c21f365ae90fa63120f1cc82e0695901af This is a partial revert of 47c51fe80e3dd9d6b518c11c2e1714c271835af5/ I5d5d03e430af380e23016c6deba5eca46067a22b. The intent was to bring today's rendering implementation in line with the old HWUI implementation, which always dithered gradients by default. However, when dithering is enabled, the Skia implementation dithers more than just gradients (e.g. Bitmaps). Combined with poor performance of the dithering algorithm on certain GPUs, this led to a performance regression on key apps. Change-Id: Id54121091e2cc47131dc9b5ae67bd638fbc005fc --- graphics/java/android/graphics/Paint.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index 51bf6d539ce85..42e470b7f660a 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -254,12 +254,6 @@ public class Paint { static final int HIDDEN_DEFAULT_PAINT_FLAGS = DEV_KERN_TEXT_FLAG | EMBEDDED_BITMAP_TEXT_FLAG | FILTER_BITMAP_FLAG; - /** - * These flags are always set on a reset paint or a new paint instantiated using - * {@link #Paint()}. - */ - private static final int DEFAULT_PAINT_FLAGS = ANTI_ALIAS_FLAG | DITHER_FLAG; - /** * Font hinter option that disables font hinting. * @@ -577,12 +571,12 @@ public class Paint { * On devices running {@link Build.VERSION_CODES#Q} and above, * {@code FILTER_BITMAP_FLAG} is set by this constructor, and it can be * cleared with {@link #setFlags} or {@link #setFilterBitmap}. - * On devices running {@link Build.VERSION_CODES#S} and above, {@code ANTI_ALIAS_FLAG} and - * {@code DITHER_FLAG} are set by this constructor, and they can be cleared with - * {@link #setFlags} or {@link #setAntiAlias} and {@link #setDither}, respectively.

+ * On devices running {@link Build.VERSION_CODES#S} and above, {@code ANTI_ALIAS_FLAG} + * is set by this constructor, and it can be cleared with {@link #setFlags} or + * {@link #setAntiAlias}.

*/ public Paint() { - this(DEFAULT_PAINT_FLAGS); + this(ANTI_ALIAS_FLAG); } /** @@ -627,7 +621,7 @@ public class Paint { /** Restores the paint to its default settings. */ public void reset() { nReset(mNativePaint); - setFlags(HIDDEN_DEFAULT_PAINT_FLAGS | DEFAULT_PAINT_FLAGS); + setFlags(HIDDEN_DEFAULT_PAINT_FLAGS | ANTI_ALIAS_FLAG); // TODO: Turning off hinting has undesirable side effects, we need to // revisit hinting once we add support for subpixel positioning