Skip to content

Despite #44730, Skia is still dithering non-gradients #132860

@matanlurey

Description

@matanlurey

Reference: flutter/engine#44730.

The problem, I believe, is even though we are guarding against this in dl_sk_conversions.cc:

auto color_source = paint.getColorSourcePtr();
if (color_source) {
  // 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 (color_source->isGradient()) {
    // Originates from `dart:ui#Paint.enableDithering`.
    auto user_specified_dither = paint.isDither();
    sk_paint.setDither(user_specified_dither);
  }

... that's unfortunately not the only entry point into SkPaint. Consider dl_sk_paint_dispatcher.cc:

void DlSkPaintDispatchHelper::setDither(bool dither) {
  paint_.setDither(dither);
}

I'll need to look at this a bit more, because it's not clear we'll have enough information in this dispatcher to make a good decision about not dithering (i.e. it's not possible to check if it's a gradient or not). I suppose we could check in setColorSource, but I don't know if there is a guarantee in ordering calls between setDither and setColorSource.


Side-note for @flar: I don't quote understand the "flow". Why do we have conversions from DlPaint -> SkPaint but still have a dispatcher that directly routes DlPaint to SkPaint? Was that intended to be cleaned up, or do I just misunderstand that there are multiple (valid) ways to interact with the underlying SkPaint?

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions