Unverified Commit 46125d07 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Mention saveLayer in the CustomPainter docs. (#130520)

Fixes https://github.com/flutter/flutter/issues/11002
parent c01d2b7f
......@@ -119,6 +119,23 @@ typedef SemanticsBuilderCallback = List<CustomPainterSemantics> Function(Size si
/// ```
/// {@end-tool}
///
/// ## Composition and the sharing of canvases
///
/// Widgets (or rather, render objects) are composited together using a minimum
/// number of [Canvas]es, for performance reasons. As a result, a
/// [CustomPainter]'s [Canvas] may be the same as that used by other widgets
/// (including other [CustomPaint] widgets).
///
/// This is mostly unnoticeable, except when using unusual [BlendMode]s. For
/// example, trying to use [BlendMode.dstOut] to "punch a hole" through a
/// previously-drawn image may erase more than was intended, because previous
/// widgets will have been painted onto the same canvas.
///
/// To avoid this issue, consider using [Canvas.saveLayer] and
/// [Canvas.restore] when using such blend modes. Creating new layers is
/// relatively expensive, however, and should be done sparingly to avoid
/// introducing jank.
///
/// See also:
///
/// * [Canvas], the class that a custom painter uses to paint.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment