# BlendMode vs CompositingStrategy: It's Not a Fence, It's a Different Canvas

> BlendMode and CompositingStrategy look like two settings on the same graphicsLayer call, but they answer completely different questions. One is the color formula; the other decides what that formula even sees as "already there."

**Date:** 2026-10-11T00:00:00.000Z
**Tags:** Draw, Canvas, Graphics

## The intuition

`CompositingStrategy.Offscreen` feels like it builds a fence around your
blend mode, a wall that keeps its effect from leaking onto pixels outside
your component.

* That's the right *effect*, but the wrong *mechanism*, and the wrong
  mechanism breaks down the moment you ask a sharper question: what does
  the blend mode actually read as `dst` (The destination pixel: whatever color is already sitting at a given spot before your draw call blends a new src pixel into it.), not just what does it affect?
* `BlendMode` is the formula: `out = f(src, dst)`. `Multiply`, `Clear`,
  `DstOut` are just different `f`.
* `CompositingStrategy` decides what `dst` *is*: the real, already-painted
  screen, or a fresh, private, transparent buffer that only your subtree
  has drawn into.

Without isolation, your draw calls blend against whatever's already on
the real screen surface, background, siblings painted earlier, all of it.
With `Offscreen`, they blend against a buffer that starts out fully
blank, so there's nothing "outside" for the blend to read or touch,
because that buffer contains *only* what your subtree drew.

So isolation doesn't clamp an operation's reach after the fact, it hands
the operation a different substrate to run on in the first place. Painting
without `Offscreen` is painting directly onto the photo. Painting with it
is painting on a sheet of transparent film, blending only ever happens
film-on-film, and only once you're done do you lay the finished film on
top of the photo.

* [Recomposition, Layout, and DrawScope: One Idea, Three Phases](/phase-aware-compose-tips) — Why compositingStrategy and drawWithContent belong to the draw phase specifically, and how that phase model determines what a draw call can read without triggering recomposition.

* [Modifier Order Matters: It's a Wrapper Chain, Not a Property Bag](/compose-modifier-order) — The same wrapper-chain mental model this post uses for compositingStrategy and blend modes, applied to where graphicsLayer sits in a modifier chain generally.

## Reference: common blend modes and their formulas

`BlendMode` has far more values than any one post needs, but these are
the ones you'll actually reach for. `src` is the pixel you're drawing,
`dst` is whatever's already there, `srcA`/`dstA` are their alphas:

| Blend mode | Formula | What it does |
|---|---|---|
| `Clear` | `out = 0` | Erases `dst` wherever `src` is drawn, ignoring `src`'s own color entirely. |
| `Src` | `out = src` | Replaces `dst` outright, as if nothing was there before. |
| `Dst` | `out = dst` | No-op: keeps whatever was already there, discards `src`. |
| `SrcOver` (the default) | `out = src + dst·(1-srcA)` | Ordinary painting: `src` on top, `dst` showing through wherever `src` is transparent. |
| `DstOver` | `out = dst + src·(1-dstA)` | Same as `SrcOver` with the roles swapped: `dst` paints on top of `src`. |
| `SrcIn` | `out = src·dstA` | Keeps `src` only where `dst` already had something, using `dst`'s shape as a mask. |
| `DstIn` | `out = dst·srcA` | Keeps `dst` only where `src` has something, "cut `dst` to `src`'s shape." |
| `SrcOut` | `out = src·(1-dstA)` | Keeps `src` only where `dst` was empty, the inverse of `SrcIn`. |
| `DstOut` | `out = dst·(1-srcA)` | Erases `dst` wherever `src` is drawn, "subtract `src`'s shape from `dst`," the knockout-text mode. |
| `SrcAtop` | `out = src·dstA + dst·(1-srcA)` | `src` shows only inside `dst`'s existing shape; `dst` shows through elsewhere. |
| `DstAtop` | `out = dst·srcA + src·(1-dstA)` | `dst` shows only inside `src`'s shape; `src` shows through elsewhere. |
| `Xor` | `out = src·(1-dstA) + dst·(1-srcA)` | Keeps whichever of `src`/`dst` is present, not both; the overlap disappears. |
| `Plus` | `out = src + dst` (clamped) | Additive: colors stack and brighten, the mode behind glow and light-stacking effects. |
| `Multiply` | `out = src · dst` | Darkens: the result is never lighter than either input, like stacking two translucent color filters. |
| `Screen` | `out = src + dst - src·dst` | Lightens: the inverse of `Multiply`, result is never darker than either input. |
| `Darken` | `out = min(src, dst)` | Keeps whichever is darker, per channel. |
| `Lighten` | `out = max(src, dst)` | Keeps whichever is lighter, per channel. |
| `Difference` | `out = \|src - dst\|` | Absolute difference per channel, used for contrast/invert-style effects. |
| `Overlay` | `Multiply` or `Screen`, picked per-pixel by `dst`'s value | Darkens dark areas and lightens light areas of `dst` in one pass; contrast and tint combined. |

All of these are the *formula* axis. None of them say anything about
whether `dst` is the real screen or a private buffer, that's the other
axis, and it's what the rest of this post is about.

The web has a near-exact equivalent: Canvas 2D's `globalCompositeOperation`
is mostly a literal rename of this same table (`source-over`, `source-in`,
`destination-out`, `multiply`, `screen`, ...). Pick a mode below and watch
both the Compose call and the formula play out on two overlapping shapes:

*\[Interactive demo: BlendModePickerDemo — view this post in a browser for the live version.]*

## The bug `Auto` quietly fixes for you

```kotlin
Box(Modifier.graphicsLayer { alpha = 0.5f }) {
    Box(Modifier.background(Color.Red).size(80.dp))
    Box(Modifier.background(Color.Blue).size(80.dp).offset(40.dp, 40.dp))
}
```

Two overlapping, semi-transparent children, default
`compositingStrategy = Auto`. Compose detects the overlap and silently
promotes this group to `Offscreen` for you, and here's why it has to:

* **Without isolation**, each child blends individually against the real
  background, so the overlap region gets hit *twice*: once by
  red-over-background, then again by blue-over-(red-over-background). The
  seam is visibly darker than "draw both fully, then fade the result
  once."
* **With isolation**, both boxes draw fully opaque into their own empty
  buffer first, so they composite against *each other* correctly, and
  only then does the group's `0.5f` alpha get applied once, to the
  finished, flattened result.

`Auto` is doing you a favor here, detecting the overlap and reaching for
isolation on your behalf. Toggle isolation off and on below, over the
exact same two overlapping boxes, to see the seam appear and disappear:

*\[Interactive demo: IsolationToggleDemo — view this post in a browser for the live version.]*

The next case is where `Auto` can't help at all.

## Where isolation isn't optional: blend modes that erase

```kotlin
Modifier.graphicsLayer {
    compositingStrategy = CompositingStrategy.Offscreen   // required, not optional
}.drawWithContent {
    drawContent()
    drawCircle(Color.Black, radius = 60.dp.toPx(), blendMode = BlendMode.Clear)
}
```

`BlendMode.Clear` means "erase `dst` here." Which `dst` depends entirely
on whether isolation ran first:

* **Without `Offscreen`**, `dst` is the real screen, so this punches a
  hole through *everything already drawn below it in the whole frame*,
  other UI, the window background, all of it.
* **With `Offscreen`**, `dst` is this layer's own private buffer. `Clear`
  only erases pixels this subtree already drew, and the punched-out
  buffer then composites normally onto the real screen. This is the
  standard spotlight / cutout-badge technique, and it's also why
  knockout text (a text-shaped hole punched through a photo, via
  `DstOut`) needs the same setup: isolate photo and text as a group
  first, then punch the hole into the group's own buffer.

> **The fundamental**
>
> Mechanically, isolation is Skia's (and every 2D renderer's) **`saveLayer`**:
> push a new offscreen buffer, draw into it, then pop it back by
> compositing the whole buffer onto what was there with one paint
> operation, alpha, blend mode, or filter applied exactly once.
> `CompositingStrategy.Offscreen` is `graphicsLayer` asking for exactly
> that. `Auto` runs the same mechanism, just only when something, group
> alpha over overlapping children, a non-default blend mode, certain
> `RenderEffect`s, actually needs it.

## Elsewhere: same fundamental, different framework

* **CSS**: `isolation: isolate` opens a new stacking context, so
  `mix-blend-mode` on elements inside it stops reaching elements outside.
* **SwiftUI**: `.compositingGroup()` flattens a subtree into one layer
  before any `.blendMode()` or `.opacity()` above it gets applied.
* **Skia**, the renderer Compose sits on: `canvas->saveLayer()` /
  `restore()` is the literal primitive both of the above compile down to.
* **Flutter**: `Opacity`/`ColorFiltered` widgets get an implicit
  offscreen layer whenever their child isn't a single opaque primitive.
* **Photoshop**: a layer group with "pass through" turned off is the
  isolation switch. "Pass through" (the default) lets blend modes leak to
  layers below; turning it off isolates the group first, the exact
  Photoshop analog of `Offscreen`.
* **Canvas 2D**: no built-in isolation primitive at all, every draw call
  composites straight onto the one visible bitmap. Faking `saveLayer` by
  hand means creating a second, in-memory `<canvas>`, drawing into *that*,
  then `drawImage()`-ing the finished result onto the visible one with
  the group's alpha, exactly what the toggle demo above does under the
  hood.

## Edge case: `ModulateAlpha` betting wrong

`CompositingStrategy.ModulateAlpha` is a narrower optimization than
`Offscreen`: instead of allocating a buffer, it multiplies the group
alpha into each child's *own* alpha as it draws, skipping isolation
entirely. That's the same visual result as `Offscreen`, but only when
the children genuinely don't overlap.

Reach for it after profiling shows `Offscreen`'s extra buffer and extra
composite pass actually costs you something, not before. If a later
change adds an overlapping child, there's no detection to catch it the
way `Auto` catches the overlap case, `ModulateAlpha` just silently
double-blends the overlap region, reproducing the exact seam from the
first example, except this time nothing promotes it back to `Offscreen`
for you. It's an optimization you opt into once you've confirmed the
no-overlap assumption, not a default you fall back on.

## Mental model to actually use

**`BlendMode` decides the formula; `CompositingStrategy` decides what `dst`
even is, isolation doesn't fence that formula in, it hands it a blank
canvas to blend against instead of the real screen.**


---

Canonical page: https://recomposed.blog/blend-mode-and-compositing-strategy