Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Expose SkCanvas::SaveLayerRec API #2773

Open
1 task done
ahmed605 opened this issue Feb 29, 2024 · 4 comments · May be fixed by #2962
Open
1 task done

[FEATURE] Expose SkCanvas::SaveLayerRec API #2773

ahmed605 opened this issue Feb 29, 2024 · 4 comments · May be fixed by #2962

Comments

@ahmed605
Copy link

ahmed605 commented Feb 29, 2024

Is your feature request related to a problem?

SkCanvas::SaveLayerRec is missing from SkiaSharp's API surface, this API is very useful for implementing backdrop effects/filters, we need this API in order to implement CompositionBackdropBrush properly in Uno Platform.

Describe the solution you would like

It would be great if SkCanvas::SaveLayerRec got exposed in SkiaSharp

Describe alternatives you have considered

We currently use a combination of SKCanvas.SaveLayer(SKPaint), SKCanvas.DrawSurface(SKSurface, SKRect), and SKCanvas.Restore() as a workaround, but it isn't ideal and has few issues (e.g. need to downscale the canvas manually, no custom clipping, slower since it's not optimized for backdrop effects unlike SkCanvas::SaveLayerRec, image filter of SKPaint isn't fully applied to the saved region (due to scaling miscalculations?), etc...)

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Gillibald
Copy link
Contributor

This is also needed to make ClearType work with layering. Otherwise parameters like pixel geometry or sub pixel text are not preserved for the created layer.

@Youssef1313
Copy link
Contributor

@mattleibow What are the chances we can have this in SkiaSharp 3?

@Gillibald
Copy link
Contributor

It does not require too much work. The native layer needs to expose the missing API and a new struct needs to be mapped.

@mattleibow
Copy link
Contributor

@Gillibald @Youssef1313 @ahmed605 I have updated the PRs, let me know if the class-based API will work. Do you see any issues with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants