From b9f8f8a92ad3d15c3482caea8f504202e3e99cbf Mon Sep 17 00:00:00 2001 From: Cody Bennett Date: Tue, 2 Jan 2024 04:26:41 -0600 Subject: [PATCH] fix(native): use MSAA for antialias on iOS (#3139) --- packages/fiber/src/native/Canvas.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/fiber/src/native/Canvas.tsx b/packages/fiber/src/native/Canvas.tsx index 81a6d35c7f..db14e5034b 100644 --- a/packages/fiber/src/native/Canvas.tsx +++ b/packages/fiber/src/native/Canvas.tsx @@ -66,6 +66,8 @@ const CanvasImpl = /*#__PURE__*/ React.forwardRef( const viewRef = React.useRef(null!) const root = React.useRef>(null!) + const [antialias, setAntialias] = React.useState(true) + const onLayout = React.useCallback((e: LayoutChangeEvent) => { const { width, height, x, y } = e.nativeEvent.layout setSize({ width, height, top: y, left: x }) @@ -81,7 +83,10 @@ const CanvasImpl = /*#__PURE__*/ React.forwardRef( addEventListener: (() => {}) as any, removeEventListener: (() => {}) as any, clientHeight: context.drawingBufferHeight, - getContext: (() => context) as any, + getContext: ((_: any, { antialias = false }) => { + setAntialias(antialias) + return context + }) as any, } as HTMLCanvasElement root.current = createRoot(canvasShim) @@ -141,7 +146,9 @@ const CanvasImpl = /*#__PURE__*/ React.forwardRef( return ( - {width > 0 && } + {width > 0 && ( + + )} ) },