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

[ASDisplayNode] Always return the thread-safe cornerRadius property, even in slow CALayer rounding mode #749

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## master
* Add your own contributions to the next release on the line below this with your name.
- **Important** ASDisplayNode's cornerRadius is a new thread-safe bridged property that should be preferred over CALayer's. Use the latter at your own risk! [Huy Nguyen](https://github.com/nguyenhuy) [#749](https://github.com/TextureGroup/Texture/pull/749).
- [ASCellNode] Adds mapping for UITableViewCell focusStyle [Alex Hill](https://github.com/alexhillc) [#727](https://github.com/TextureGroup/Texture/pull/727)
- [ASNetworkImageNode] Fix capturing self in the block while loading image in ASNetworkImageNode. [Denis Mororozov](https://github.com/morozkin) [#777](https://github.com/TextureGroup/Texture/pull/777)
- [ASTraitCollection] Add new properties of UITraitCollection to ASTraitCollection. [Yevgen Pogribnyi](https://github.com/ypogribnyi)
Expand Down
6 changes: 6 additions & 0 deletions Source/ASDisplayNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,12 @@ extern NSInteger const ASDefaultDrawingPriority;
* @default ASCornerRoundingTypeDefaultSlowCALayer
*/
@property (nonatomic, assign) ASCornerRoundingType cornerRoundingType; // default=Slow CALayer .cornerRadius (offscreen rendering)

/** @abstract The radius to use when rounding corners of the ASDisplayNode.
*
* @discussion This property is thread-safe and should always be preferred over CALayer's cornerRadius property,
* even if corner rounding type is ASCornerRoundingTypeDefaultSlowCALayer.
*/
@property (nonatomic, assign) CGFloat cornerRadius; // default=0.0

@property (nonatomic, assign) BOOL clipsToBounds; // default==NO
Expand Down
12 changes: 3 additions & 9 deletions Source/Private/ASDisplayNode+UIViewBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,12 @@ - (void)setAlpha:(CGFloat)newAlpha
- (CGFloat)cornerRadius
{
ASDN::MutexLocker l(__instanceLock__);
if (_cornerRoundingType == ASCornerRoundingTypeDefaultSlowCALayer) {
return self.layerCornerRadius;
} else {
return _cornerRadius;
}
return _cornerRadius;
}

- (void)setCornerRadius:(CGFloat)newCornerRadius
{
ASDN::MutexLocker l(__instanceLock__);
Copy link
Member Author

Choose a reason for hiding this comment

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

-updateCornerRoundingWithType:cornerRadius: acquires the lock itself (here).

[self updateCornerRoundingWithType:_cornerRoundingType cornerRadius:newCornerRadius];
[self updateCornerRoundingWithType:self.cornerRoundingType cornerRadius:newCornerRadius];
}

- (ASCornerRoundingType)cornerRoundingType
Expand All @@ -207,8 +202,7 @@ - (ASCornerRoundingType)cornerRoundingType

- (void)setCornerRoundingType:(ASCornerRoundingType)newRoundingType
{
ASDN::MutexLocker l(__instanceLock__);
[self updateCornerRoundingWithType:newRoundingType cornerRadius:_cornerRadius];
[self updateCornerRoundingWithType:newRoundingType cornerRadius:self.cornerRadius];
}

- (NSString *)contentsGravity
Expand Down