What is the best alternate of SkiaView onDraw, as i want to draw thousands of paths restored from te database. #2362
Replies: 7 comments 10 replies
-
The picture API might be suitable: https://shopify.github.io/react-native-skia/docs/animations/textures#usepictureastexture |
Beta Was this translation helpful? Give feedback.
-
@wcandillon I've explored the usepictureastexture and under-the-hood APIs, and while they seem promising, they don't fully replicate the functionality I had with the SkiaView onDraw callback. Can you suggest an alternative component that provides similar onDraw callback functionality? |
Beta Was this translation helpful? Give feedback.
-
I've utilized the onDraw callback to implement the following features:
Please check the demo video. I'm seeking guidance on achieving the same functionality using the Canvas component. Performance is critical, as there are multiple instances of Skia Canvas within a Word App-like view, allowing users to add new pages and navigate between them to make changes. |
Beta Was this translation helpful? Give feedback.
-
@wcandillon I'd like to present my findings regarding your suggestions. I've attached a video showcasing the rendering quality of paths in three distinct demos. The first demo employs standard paths within the canvas using Skia. The second demo utilizes textures via https://shopify.github.io/react-native-skia/docs/animations/textures/#under-the-hood. The third demo is native to Android. Here's my assessment of the rendering quality:
For the texture demo, I've implemented the following code. Could you please provide suggestions on how we can enhance the rendering quality using MakeOffscreen?
My objective is to achieve optimal rendering and writing performance on any Android tablet. Any assistance would be greatly appreciated. Rendering_and_Writing_Demo_App_comp.mp4 |
Beta Was this translation helpful? Give feedback.
-
The code looks good. Did you identify where the bottleneck is?
…On Wed, May 8, 2024 at 8:40 AM amitsri007 ***@***.***> wrote:
@wcandillon <https://github.com/wcandillon> Could you please provide an
update on the findings mentioned earlier? Any assistance would be
appreciated as I migrate my existing app to the latest Skia version.
—
Reply to this email directly, view it on GitHub
<#2362 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKXVWNLG7HEOE3OI3TEGLZBHCFVAVCNFSM6AAAAABGDSDROSVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TGNJQGQ4TO>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
yes this is because on screen 100pt is 100px * pixel density. And in the
texture there is no notion of pixel density so you probably need to scale
your drawing to the oixel density. This should help
…On Wed 8 May 2024 at 09:22, amitsri007 ***@***.***> wrote:
@wcandillon <https://github.com/wcandillon> In the texture demo video,
you'll notice that the rendered paths lose their smoothness and become
pixelated. However, in the path demo video, the paths remain smooth
throughout.
Texture Demo:
https://github.com/Shopify/react-native-skia/assets/67737510/7e601eee-cf2f-4301-b7e1-8f08afa474d5
Path Demo:
https://github.com/Shopify/react-native-skia/assets/67737510/e75b135c-edca-4b01-a5fc-b426320d1f94
—
Reply to this email directly, view it on GitHub
<#2362 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKXVWHLCTUC3PURTTR7NTZBHHDXAVCNFSM6AAAAABGDSDROSVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TGNJQHA4DO>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
canvas.scale(PixelRatio.get(), PixelRatio.get())
…On Wed, May 8, 2024 at 9:36 AM amitsri007 ***@***.***> wrote:
@wcandillon <https://github.com/wcandillon> Thank you for getting back to
me so quickly. Do you have any sample code that could offer assistance?
Alternatively, could you suggest any additions to the following code? Any
help would be greatly appreciated.
const createTexture = useCallback((image: SharedValue<SkImage | null>) => {
"worklet";
if (drawingPaint.current) {
const surface = Skia.Surface.MakeOffscreen(width, height)!;
const canvas = surface.getCanvas();
// canvas.drawColor(Skia.Color("lightGray"));
// canvas.drawPoints(PointMode.Lines, points, drawingPaint.current!)
paths.map((p) => {
canvas.drawPath(p, drawingPaint.current!);
});
surface.flush();
image.value = surface.makeImageSnapshot();
surface.dispose();
}
}, [paths]);
—
Reply to this email directly, view it on GitHub
<#2362 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKXVWWZRIB7KERMAKGJGTZBHIWDAVCNFSM6AAAAABGDSDROSVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TGNJRGA2DE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
I've utilized SkiaView's onDraw function to render thousands of paths retrieved from the database in my current app. However, with the removal of SkiaView in the latest SDK, I'm seeking guidance on which component to adopt for upgrading my app to the newest Skia React Native package. Since my app is a writing application that captures user touches in the background and stores them in the database, while also displaying real-time feedback to users, performance is crucial. Can you recommend the most suitable component for achieving optimal path rendering performance? Additionally, if feasible, could you provide a sample code? I've found that drawing paths in Canvas using a path array isn't delivering the performance I require.
Beta Was this translation helpful? Give feedback.
All reactions