Skip to content

Fix clipRule in Android #1409#1564

Merged
magicismight merged 2 commits into
developfrom
fix-clip-rule-android
Apr 9, 2021
Merged

Fix clipRule in Android #1409#1564
magicismight merged 2 commits into
developfrom
fix-clip-rule-android

Conversation

@magicismight
Copy link
Copy Markdown
Contributor

Fix #1409

Summary

The clipRule prop should be used on graphics elements.
Not on ClipPath itself.

Test Plan

Run example in #1409

What's required for testing (prerequisites)?

None

What are the steps to reproduce (after prerequisites)?

#1409

Compatibility

OS Implemented
Android

Checklist

  • I have tested this on a device and a simulator
  • I added documentation in README.md
  • I updated the typed files (typescript)
  • I added a test for the API in the __tests__ folder

@magicismight magicismight requested a review from msand April 9, 2021 07:25
@magicismight
Copy link
Copy Markdown
Contributor Author

https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/clip-rule

clipRule should be use inside ClipPath or with clipPath prop.

@magicismight
Copy link
Copy Markdown
Contributor Author

magicismight commented Apr 9, 2021

I have removed _clipMask in RNSVG, It does not work in recent versions.
Nothing been draw on this _clipMask, it will cause bug when clipRule is nonzero

CGRect bounds = CGContextGetClipBoundingBox(context);
CGSize size = bounds.size;

UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
CGContextRef newContext = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(newContext, 0.0, size.height);
CGContextScaleCTM(newContext, 1.0, -1.0);

[_clipNode renderLayerTo:newContext rect:bounds];
_clipMask = CGBitmapContextCreateImage(newContext);
UIGraphicsEndImageContext();

Nothing drawed on this _clipMask

@magicismight magicismight merged commit fa9a25d into develop Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClipPath is not working properly on Android without clipRule prop

1 participant