Skip to content

Commit a4957bb

Browse files
authored
Revert "Have image nodes draw into opaque contexts automatically if possible (#1432)" (#1443)
This reverts commit 28522ce.
1 parent bf466e8 commit a4957bb

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Source/ASImageNode.mm

+5-12
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,9 @@ + (UIImage *)createContentsForkey:(ASImageNodeContentsKey *)key drawParameters:(
473473
return nil;
474474
}
475475

476-
// If the image is opaque, and the draw rect contains the bounds rect, we can use an opaque context.
477-
UIImage *image = key.image;
478-
const CGRect imageDrawRect = key.imageDrawRect;
479-
const CGRect contextBounds = { CGPointZero, key.backingSize };
480-
const BOOL imageIsOpaque = ASImageAlphaInfoIsOpaque(CGImageGetAlphaInfo(image.CGImage));
481-
const BOOL imageFillsContext = CGRectContainsRect(imageDrawRect, contextBounds);
482-
const BOOL contextIsOpaque = (imageIsOpaque && imageFillsContext) || key.isOpaque;
483-
484476
// Use contentsScale of 1.0 and do the contentsScale handling in boundsSizeInPixels so ASCroppedImageBackingSizeAndDrawRectInBounds
485477
// will do its rounding on pixel instead of point boundaries
486-
ASGraphicsBeginImageContextWithOptions(contextBounds.size, contextIsOpaque, 1.0);
478+
ASGraphicsBeginImageContextWithOptions(key.backingSize, key.isOpaque, 1.0);
487479

488480
BOOL contextIsClean = YES;
489481

@@ -511,12 +503,13 @@ + (UIImage *)createContentsForkey:(ASImageNodeContentsKey *)key drawParameters:(
511503
// upon removal of the object from the set when the operation completes.
512504
// Another option is to have ASDisplayNode+AsyncDisplay coordinate these cases, and share the decoded buffer.
513505
// Details tracked in https://github.com/facebook/AsyncDisplayKit/issues/1068
514-
515-
BOOL canUseCopy = (contextIsClean || imageIsOpaque);
506+
507+
UIImage *image = key.image;
508+
BOOL canUseCopy = (contextIsClean || ASImageAlphaInfoIsOpaque(CGImageGetAlphaInfo(image.CGImage)));
516509
CGBlendMode blendMode = canUseCopy ? kCGBlendModeCopy : kCGBlendModeNormal;
517510

518511
@synchronized(image) {
519-
[image drawInRect:imageDrawRect blendMode:blendMode alpha:1];
512+
[image drawInRect:key.imageDrawRect blendMode:blendMode alpha:1];
520513
}
521514

522515
if (context && key.didDisplayNodeContentWithRenderingContext) {

0 commit comments

Comments
 (0)