diff --git a/display_list/dl_paint.h b/display_list/dl_paint.h index 430d557a9de79..e88c6cc532cc8 100644 --- a/display_list/dl_paint.h +++ b/display_list/dl_paint.h @@ -77,7 +77,7 @@ class DlPaint { // TODO(matanl): Remove this flag when the Skia backend is removed, // https://github.com/flutter/flutter/issues/112498. bool isDitherHintForSkBackend() const { - return colorSource_ ? colorSource_->isDitherHintForSkBackend() : false; + return colorSource_ ? colorSource_->isGradient() : false; } bool isInvertColors() const { return isInvertColors_; } diff --git a/display_list/effects/dl_color_source.h b/display_list/effects/dl_color_source.h index 07eb89d95aaf6..11a141da9c905 100644 --- a/display_list/effects/dl_color_source.h +++ b/display_list/effects/dl_color_source.h @@ -120,17 +120,14 @@ class DlColorSource : public DlAttribute { virtual bool isUIThreadSafe() const = 0; //---------------------------------------------------------------------------- - /// @brief If the underlying platform data should have dithering - /// applied to it (if requested), this method returns true. - /// In practice, this is only true for gradients and is only - /// used by the Skia backend. + /// @brief If the underlying platform data represents a gradient. /// /// TODO(matanl): Remove this flag when the Skia backend is /// removed, https://github.com/flutter/flutter/issues/112498. /// /// @return True if the class represents the output of a gradient. /// - virtual bool isDitherHintForSkBackend() const { return false; } + virtual bool isGradient() const { return false; } // Return a DlColorColorSource pointer to this object iff it is an Color // type of ColorSource, otherwise return nullptr. @@ -300,7 +297,7 @@ class DlGradientColorSourceBase : public DlMatrixColorSourceBase { return true; } - bool isDitherHintForSkBackend() const override { return true; } + bool isGradient() const override { return true; } DlTileMode tile_mode() const { return mode_; } int stop_count() const { return stop_count_; } diff --git a/display_list/skia/dl_sk_canvas.cc b/display_list/skia/dl_sk_canvas.cc index b0caa7f71866f..c2e84d3759335 100644 --- a/display_list/skia/dl_sk_canvas.cc +++ b/display_list/skia/dl_sk_canvas.cc @@ -27,18 +27,6 @@ SkPaint ToSk(const DlPaint& paint, bool force_stroke) { SkPaint sk_paint; sk_paint.setAntiAlias(paint.isAntiAlias()); - - // On the Impeller backend, we will only support dithering of *gradients*, - // and it will be enabled by default (without the option to disable it). Until - // Skia support is completely removed, we only want to respect the dither flag - // for gradients (otherwise it will also apply to, for example, images, which - // is not supported in Impeller). - // - // See https://github.com/flutter/flutter/issues/112498. - if (paint.isDitherHintForSkBackend()) { - sk_paint.setDither(paint.isDither()); - } - sk_paint.setColor(paint.getColor()); sk_paint.setBlendMode(ToSk(paint.getBlendMode())); sk_paint.setStyle(force_stroke ? SkPaint::kStroke_Style @@ -59,6 +47,19 @@ SkPaint ToSk(const DlPaint& paint, bool force_stroke) { color_filter = invert_filter; } sk_paint.setColorFilter(color_filter); + + // On the Impeller backend, we will only support dithering of *gradients*, + // and it will be enabled by default (without the option to disable it). Until + // Skia support is completely removed, we only want to respect the dither flag + // for gradients (otherwise it will also apply to, for example, images, which + // is not supported in Impeller). + // + // See https://github.com/flutter/flutter/issues/112498. + auto color_source = paint.getColorSourcePtr(); + if (color_source && color_source->isGradient()) { + sk_paint.setDither(paint.isDither()); + } + sk_paint.setMaskFilter(ToSk(paint.getMaskFilterPtr())); sk_paint.setPathEffect(ToSk(paint.getPathEffectPtr()));