Skip to content

[Engine] There are 2+ ways that DisplayList* results in SkPaint (which is confusing) #132994

@matanlurey

Description

@matanlurey

While attempting to pair down how setDither(...) works (e.g. flutter/engine#44912), I was constantly getting confused on how many places in the engine are SkPaint instances created by code within display_list/**. For example, consider DlSkCanvasDispatcher and DlSkCanvasAdapter:

DlSkCanvasDispatcher

//------------------------------------------------------------------------------
/// Can be fed to the dispatch() method of a DisplayList to feed the resulting
/// rendering operations to an SkCanvas instance.
///
/// Receives all methods on Dispatcher and sends them to an SkCanvas
///
class DlSkCanvasDispatcher : public virtual DlOpReceiver,
                             public DlSkPaintDispatchHelper { /* ... */ }

DlSkCanvasAdapter

// An adapter to receive DlCanvas calls and dispatch them into
// an SkCanvas.
class DlSkCanvasAdapter final : public virtual DlCanvas

... which in turn uses ToSk to convert from DlPaint to SkPaint:

void DlSkCanvasAdapter::DrawPaint(const DlPaint& paint) {
  delegate_->drawPaint(ToSk(paint));
}

I can maintain code in both branches, but I'm actually just curious (and wasn't able to easily determine) why there are multiple ways for display_list/** to write to SkPaint, and whether this is intentional (if so, it might be nice to add a bit more commenting to both of the above classes explain the intended use-cases) or some sort of intermediate state that's non-obvious (which also could deserve a few comments).

Of the two, DlSkCanvasAdapter appears to be used in many more places, fwiw.

/cc @flar, would you be able to help me understand a bit? I'm happy to volunteer PRs to improve the documentation.

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