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

Implement SkCanvas::SaveLayerRec #2962

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Implement SkCanvas::SaveLayerRec #2962

wants to merge 1 commit into from

Conversation

ahmed605
Copy link

Description of Change

Implement SkCanvas::SaveLayerRec

Bugs Fixed

API Changes

Added:

  • int SKCanvas.SaveLayer(SKRect bounds, SKPaint paint, SKImageFilter backdrop, SKSaveLayerFlags saveLayerFlags = SKSaveLayerFlags.None)
  • int SKCanvas.SaveLayer(SKRect bounds, SKPaint paint, SKSaveLayerFlags saveLayerFlags)

Behavioral Changes

None.

Required skia PR

mono/skia#130

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Merged related skia PRs
  • Changes adhere to coding standard
  • Updated documentation

@mattleibow
Copy link
Contributor

Not sure my magic with CI is working with the auto detection of the skia branch (probably because I am not doing it right for forks) so maybe just update the submodule here and we can merge in one go later once the skia PR is merged.

@@ -1066,4 +1076,13 @@ public void Restore ()
}
}
}

[Flags]
public enum SKSaveLayerFlags
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public enum SKSaveLayerFlags
public enum SKCanvasSaveLayerFlags

@@ -68,6 +68,16 @@ public int SaveLayer (SKPaint paint)
return SkiaApi.sk_canvas_save_layer (Handle, null, paint == null ? IntPtr.Zero : paint.Handle);
}

public int SaveLayer (SKRect bounds, SKPaint paint, SKImageFilter backdrop, SKSaveLayerFlags saveLayerFlags = SKSaveLayerFlags.None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth creating a rec struct now instead of adding overloads? The next skia update will have a filters list and a color space, so reducing the new things to a new property may be nicer.

public struct SKCanvasSaveLayerRec
{
    public SKRect? Bounds { get; set; }
    public SKPaint? Paint  { get; set; }
    public SKImageFilter? Backdrop { get; set; }
    public SKCanvasSaveLayerFlags { get; set; }
}

Then in the save layer we can "unpack" this struct and pass it as the single C function. This way we don't need to create yet another overload to the save layer world just to add colorspace.

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

Successfully merging this pull request may close these issues.

[FEATURE] Expose SkCanvas::SaveLayerRec API
2 participants