Commit 51ec52e
Fix image disappearing on Nougat with antialiased border radius clipping (#55527)
Summary:
Pull Request resolved: #55527
On API 25 (Nougat), the `DST_OUT` + `EVEN_ODD` inverse path technique in `clipWithAntiAliasing()` doesn't render correctly — it erases all image content instead of just the area outside the rounded rect.
The bug manifests specifically with ReactImageView (Fresco-backed) but not plain ImageView. ReactImageView's Fresco hierarchy configures `RoundingParams.RoundingMethod.BITMAP_ONLY`, which causes the drawable chain to draw through a `BitmapShader`-based paint. This shader-based drawing interacts badly with the `EVEN_ODD` fill + `DST_OUT` compositing inside a hardware-accelerated `saveLayer` on API 24's Skia renderer.
The fix replaces the `EVEN_ODD` + `DST_OUT` technique with a nested `saveLayer` using `DST_IN` compositing, following the same pattern used by Facebook's Keyframes library (`AbstractLayer.applyClip`). The mask shape is drawn into a separate layer; when restored with `DST_IN`, content is preserved only where the mask is opaque. A `drawColor(CLEAR)` call after `saveLayer` ensures the layer starts fully transparent — without this, on API 24, the layer may retain parent content, causing `DST_IN` to see non-zero alpha everywhere and clip nothing.
Changelog: [Android][Fixed] - Fix image content disappearing on API 24 (Nougat) when antialiased border radius clipping is applied
Reviewed By: NickGerleman
Differential Revision: D92980234
fbshipit-source-id: ea6d05d8f06346371eab1c406538e91bbd78d0ae1 parent b92d378 commit 51ec52e
1 file changed
Lines changed: 14 additions & 9 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager
Lines changed: 14 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
601 | 605 | | |
602 | | - | |
| 606 | + | |
| 607 | + | |
603 | 608 | | |
604 | 609 | | |
605 | 610 | | |
| |||
0 commit comments