mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
[ASDisplayNode] Use kCGBlendModeCopy in a Couple More Places (#2250)
* Use blend mode copy in a couple more places * Add some tests
This commit is contained in:
@@ -677,7 +677,7 @@ extern asimagenode_modification_block_t ASImageNodeRoundBorderModificationBlock(
|
||||
[roundOutline addClip];
|
||||
|
||||
// Draw the original image
|
||||
[originalImage drawAtPoint:CGPointZero];
|
||||
[originalImage drawAtPoint:CGPointZero blendMode:kCGBlendModeCopy alpha:1];
|
||||
|
||||
// Draw a border on top.
|
||||
if (borderWidth > 0.0) {
|
||||
@@ -700,7 +700,7 @@ extern asimagenode_modification_block_t ASImageNodeTintColorModificationBlock(UI
|
||||
// Set color and render template
|
||||
[color setFill];
|
||||
UIImage *templateImage = [originalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
[templateImage drawAtPoint:CGPointZero];
|
||||
[templateImage drawAtPoint:CGPointZero blendMode:kCGBlendModeCopy alpha:1];
|
||||
|
||||
UIImage *modifiedImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#import "ASAssert.h"
|
||||
#import "ASDisplayNodeInternal.h"
|
||||
#import "ASDisplayNode+FrameworkPrivate.h"
|
||||
#import "ASInternalHelpers.h"
|
||||
|
||||
@interface ASDisplayNode () <_ASDisplayLayerDelegate>
|
||||
@end
|
||||
@@ -113,7 +114,9 @@
|
||||
if (displayBlock) {
|
||||
UIImage *image = (UIImage *)displayBlock();
|
||||
if (image) {
|
||||
[image drawInRect:bounds];
|
||||
BOOL opaque = ASImageAlphaInfoIsOpaque(CGImageGetAlphaInfo(image.CGImage));
|
||||
CGBlendMode blendMode = opaque ? kCGBlendModeCopy : kCGBlendModeNormal;
|
||||
[image drawInRect:bounds blendMode:blendMode alpha:1];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user