Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
box_shadow_cache.hpp File Reference

Process-wide cache for rasterized outset box-shadow coverage. More...

Go to the source code of this file.

Detailed Description

Process-wide cache for rasterized outset box-shadow coverage.

Drawing a CSS box shadow blurs a rounded rect every paint, which is wasteful when the same shadow is painted frame after frame — a static shadow on a repainting view, or a card that only translates or whose shadow color/opacity animates. The blurred shape is origin-agnostic: it depends on the box size, blur, spread, corner radius, shadow offset, and device scale, but not on the box's screen position or the shadow color.

This cache stores the blurred white coverage image keyed on that origin-agnostic fingerprint. The shadow path then:

  • re-blits the cached coverage translated to the box position (free move),
  • re-tints it with the shadow color via a SrcIn color filter (free color/opacity change),
  • only re-blurs when the geometry fingerprint changes.

Painting is on the UI thread (not the realtime audio thread), so a small mutex is acceptable; the cache is process-global with an LRU cap. Disabled or non-axis-aligned transforms fall back to the direct (uncached) shadow path, so output is unchanged when caching cannot apply.