mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Add allowsGroupOpacity property to ASDisplayNode (#2320)
This commit is contained in:
committed by
GitHub
parent
f9ee1dd4b6
commit
4692e25204
@@ -653,6 +653,7 @@ extern NSInteger const ASDefaultDrawingPriority;
|
||||
@property (nonatomic, assign) BOOL clipsToBounds; // default==NO
|
||||
@property (nonatomic, getter=isOpaque) BOOL opaque; // default==YES
|
||||
|
||||
@property (nonatomic, assign) BOOL allowsGroupOpacity;
|
||||
@property (nonatomic, assign) BOOL allowsEdgeAntialiasing;
|
||||
@property (nonatomic, assign) unsigned int edgeAntialiasingMask; // default==all values from CAEdgeAntialiasingMask
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, assign, getter = isOpaque) BOOL opaque;
|
||||
@property (nonatomic, strong) __attribute__((NSObject)) CGColorRef borderColor;
|
||||
@property (nonatomic, strong) __attribute__((NSObject)) CGColorRef backgroundColor;
|
||||
@property (nonatomic, assign) BOOL allowsGroupOpacity;
|
||||
@property (nonatomic, assign) BOOL allowsEdgeAntialiasing;
|
||||
@property (nonatomic, assign) unsigned int edgeAntialiasingMask;
|
||||
|
||||
|
||||
@@ -695,6 +695,18 @@ if (shouldApply) { _layer.layerProperty = (layerValueExpr); } else { ASDisplayNo
|
||||
_setToLayer(borderColor, colorValue);
|
||||
}
|
||||
|
||||
- (BOOL)allowsGroupOpacity
|
||||
{
|
||||
_bridge_prologue_read;
|
||||
return _getFromLayer(allowsGroupOpacity);
|
||||
}
|
||||
|
||||
- (void)setAllowsGroupOpacity:(BOOL)allowsGroupOpacity
|
||||
{
|
||||
_bridge_prologue_write;
|
||||
_setToLayer(allowsGroupOpacity, allowsGroupOpacity);
|
||||
}
|
||||
|
||||
- (BOOL)allowsEdgeAntialiasing
|
||||
{
|
||||
_bridge_prologue_read;
|
||||
|
||||
@@ -56,6 +56,7 @@ typedef struct {
|
||||
int setBorderWidth:1;
|
||||
int setBorderColor:1;
|
||||
int setAsyncTransactionContainer:1;
|
||||
int setAllowsGroupOpacity:1;
|
||||
int setAllowsEdgeAntialiasing:1;
|
||||
int setEdgeAntialiasingMask:1;
|
||||
int setIsAccessibilityElement:1;
|
||||
@@ -153,6 +154,7 @@ ASDISPLAYNODE_INLINE void ASPendingStateApplyMetricsToLayer(_ASPendingState *sta
|
||||
@synthesize contents=contents;
|
||||
@synthesize hidden=isHidden;
|
||||
@synthesize needsDisplayOnBoundsChange=needsDisplayOnBoundsChange;
|
||||
@synthesize allowsGroupOpacity=allowsGroupOpacity;
|
||||
@synthesize allowsEdgeAntialiasing=allowsEdgeAntialiasing;
|
||||
@synthesize edgeAntialiasingMask=edgeAntialiasingMask;
|
||||
@synthesize autoresizesSubviews=autoresizesSubviews;
|
||||
@@ -180,6 +182,19 @@ ASDISPLAYNODE_INLINE void ASPendingStateApplyMetricsToLayer(_ASPendingState *sta
|
||||
|
||||
static CGColorRef blackColorRef = NULL;
|
||||
static UIColor *defaultTintColor = nil;
|
||||
static BOOL defaultAllowsGroupOpacity = YES;
|
||||
static BOOL defaultAllowsEdgeAntialiasing = NO;
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
// Create temporary view to read default values that are based on linked SDK and Info.plist values
|
||||
// Ensure this values cached on the main thread before needed
|
||||
ASDisplayNodeCAssertMainThread();
|
||||
UIView *view = [[UIView alloc] init];
|
||||
defaultAllowsGroupOpacity = view.layer.allowsGroupOpacity;
|
||||
defaultAllowsEdgeAntialiasing = view.layer.allowsEdgeAntialiasing;
|
||||
}
|
||||
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
@@ -207,6 +222,8 @@ static UIColor *defaultTintColor = nil;
|
||||
contents = nil;
|
||||
isHidden = NO;
|
||||
needsDisplayOnBoundsChange = NO;
|
||||
allowsGroupOpacity = defaultAllowsGroupOpacity;
|
||||
allowsEdgeAntialiasing = defaultAllowsEdgeAntialiasing;
|
||||
autoresizesSubviews = YES;
|
||||
alpha = 1.0f;
|
||||
cornerRadius = 0.0f;
|
||||
@@ -273,6 +290,12 @@ static UIColor *defaultTintColor = nil;
|
||||
_flags.setNeedsDisplayOnBoundsChange = YES;
|
||||
}
|
||||
|
||||
- (void)setAllowsGroupOpacity:(BOOL)flag
|
||||
{
|
||||
allowsGroupOpacity = flag;
|
||||
_flags.setAllowsGroupOpacity = YES;
|
||||
}
|
||||
|
||||
- (void)setAllowsEdgeAntialiasing:(BOOL)flag
|
||||
{
|
||||
allowsEdgeAntialiasing = flag;
|
||||
@@ -729,6 +752,9 @@ static UIColor *defaultTintColor = nil;
|
||||
if (flags.setNeedsDisplayOnBoundsChange)
|
||||
layer.needsDisplayOnBoundsChange = needsDisplayOnBoundsChange;
|
||||
|
||||
if (flags.setAllowsGroupOpacity)
|
||||
layer.allowsGroupOpacity = allowsGroupOpacity;
|
||||
|
||||
if (flags.setAllowsEdgeAntialiasing)
|
||||
layer.allowsEdgeAntialiasing = allowsEdgeAntialiasing;
|
||||
|
||||
@@ -854,6 +880,9 @@ static UIColor *defaultTintColor = nil;
|
||||
if (flags.setNeedsDisplayOnBoundsChange)
|
||||
layer.needsDisplayOnBoundsChange = needsDisplayOnBoundsChange;
|
||||
|
||||
if (flags.setAllowsGroupOpacity)
|
||||
layer.allowsGroupOpacity = allowsGroupOpacity;
|
||||
|
||||
if (flags.setAllowsEdgeAntialiasing)
|
||||
layer.allowsEdgeAntialiasing = allowsEdgeAntialiasing;
|
||||
|
||||
@@ -957,6 +986,7 @@ static UIColor *defaultTintColor = nil;
|
||||
pendingState.borderWidth = layer.borderWidth;
|
||||
pendingState.borderColor = layer.borderColor;
|
||||
pendingState.needsDisplayOnBoundsChange = layer.needsDisplayOnBoundsChange;
|
||||
pendingState.allowsGroupOpacity = layer.allowsGroupOpacity;
|
||||
pendingState.allowsEdgeAntialiasing = layer.allowsEdgeAntialiasing;
|
||||
pendingState.edgeAntialiasingMask = layer.edgeAntialiasingMask;
|
||||
return pendingState;
|
||||
@@ -1000,6 +1030,7 @@ static UIColor *defaultTintColor = nil;
|
||||
pendingState.autoresizingMask = view.autoresizingMask;
|
||||
pendingState.autoresizesSubviews = view.autoresizesSubviews;
|
||||
pendingState.needsDisplayOnBoundsChange = layer.needsDisplayOnBoundsChange;
|
||||
pendingState.allowsGroupOpacity = layer.allowsGroupOpacity;
|
||||
pendingState.allowsEdgeAntialiasing = layer.allowsEdgeAntialiasing;
|
||||
pendingState.edgeAntialiasingMask = layer.edgeAntialiasingMask;
|
||||
pendingState.isAccessibilityElement = view.isAccessibilityElement;
|
||||
@@ -1069,6 +1100,7 @@ static UIColor *defaultTintColor = nil;
|
||||
|| flags.setAutoresizingMask
|
||||
|| flags.setAutoresizesSubviews
|
||||
|| flags.setNeedsDisplayOnBoundsChange
|
||||
|| flags.setAllowsGroupOpacity
|
||||
|| flags.setAllowsEdgeAntialiasing
|
||||
|| flags.setEdgeAntialiasingMask
|
||||
|| flags.needsDisplay
|
||||
|
||||
@@ -304,6 +304,7 @@ for (ASDisplayNode *n in @[ nodes ]) {\
|
||||
XCTAssertEqual(NO, node.clipsToBounds, @"default clipsToBounds broken %@", hasLoadedView);
|
||||
XCTAssertEqual(YES, node.opaque, @"default opaque broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.needsDisplayOnBoundsChange, @"default needsDisplayOnBoundsChange broken %@", hasLoadedView);
|
||||
XCTAssertEqual(YES, node.allowsGroupOpacity, @"default allowsGroupOpacity broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.allowsEdgeAntialiasing, @"default allowsEdgeAntialiasing broken %@", hasLoadedView);
|
||||
XCTAssertEqual((unsigned int)(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge), node.edgeAntialiasingMask, @"default edgeAntialisingMask broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.hidden, @"default hidden broken %@", hasLoadedView);
|
||||
@@ -401,6 +402,7 @@ for (ASDisplayNode *n in @[ nodes ]) {\
|
||||
XCTAssertEqual(YES, node.clipsToBounds, @"clipsToBounds broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.opaque, @"opaque broken %@", hasLoadedView);
|
||||
XCTAssertEqual(YES, node.needsDisplayOnBoundsChange, @"needsDisplayOnBoundsChange broken %@", hasLoadedView);
|
||||
XCTAssertEqual(NO, node.allowsGroupOpacity, @"allowsGroupOpacity broken %@", hasLoadedView);
|
||||
XCTAssertEqual(YES, node.allowsEdgeAntialiasing, @"allowsEdgeAntialiasing broken %@", hasLoadedView);
|
||||
XCTAssertTrue((unsigned int)(kCALayerLeftEdge | kCALayerTopEdge) == node.edgeAntialiasingMask, @"edgeAntialiasingMask broken: %@", hasLoadedView);
|
||||
XCTAssertEqual(YES, node.hidden, @"hidden broken %@", hasLoadedView);
|
||||
@@ -459,6 +461,7 @@ for (ASDisplayNode *n in @[ nodes ]) {\
|
||||
node.clipsToBounds = YES;
|
||||
node.opaque = NO;
|
||||
node.needsDisplayOnBoundsChange = YES;
|
||||
node.allowsGroupOpacity = NO;
|
||||
node.allowsEdgeAntialiasing = YES;
|
||||
node.edgeAntialiasingMask = (kCALayerLeftEdge | kCALayerTopEdge);
|
||||
node.hidden = YES;
|
||||
|
||||
Reference in New Issue
Block a user