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

Always use the correct representation when drawing image #2044

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 1 addition & 16 deletions Source/ASImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ - (instancetype)init

_imageNodeFlags.cropEnabled = YES;
_imageNodeFlags.forceUpscaling = NO;
_imageNodeFlags.regenerateFromImageAsset = NO;
_cropRect = CGRectMake(0.5, 0.5, 0, 0);
_cropDisplayBounds = CGRectNull;
_placeholderColor = ASDisplayNodeDefaultPlaceholderColor();
Expand Down Expand Up @@ -295,8 +294,7 @@ - (NSObject *)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer
ASLockScopeSelf();
UIImage *drawImage = _image;
if (AS_AVAILABLE_IOS_TVOS(13, 10)) {
if (_imageNodeFlags.regenerateFromImageAsset && drawImage != nil) {
_imageNodeFlags.regenerateFromImageAsset = NO;
if (drawImage != nil && drawImage.imageAsset != nil) {
UITraitCollection *tc = [UITraitCollection traitCollectionWithUserInterfaceStyle:_primitiveTraitCollection.userInterfaceStyle];
UIImage *generatedImage = [drawImage.imageAsset imageWithTraitCollection:tc];
if ( generatedImage != nil ) {
Expand Down Expand Up @@ -777,19 +775,6 @@ - (NSDictionary *)debugLabelAttributes
};
}

- (void)asyncTraitCollectionDidChangeWithPreviousTraitCollection:(ASPrimitiveTraitCollection)previousTraitCollection {
[super asyncTraitCollectionDidChangeWithPreviousTraitCollection:previousTraitCollection];

if (AS_AVAILABLE_IOS_TVOS(13, 10)) {
AS::MutexLocker l(__instanceLock__);
// update image if userInterfaceStyle was changed (dark mode)
if (_image != nil
&& _primitiveTraitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle) {
_imageNodeFlags.regenerateFromImageAsset = YES;
}
}
}


@end

Expand Down
1 change: 0 additions & 1 deletion Source/Private/ASImageNode+AnimatedImagePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
unsigned int animatedImagePaused:1;
unsigned int cropEnabled:1; // Defaults to YES.
unsigned int forceUpscaling:1; //Defaults to NO.
unsigned int regenerateFromImageAsset:1; //Defaults to NO.
} _imageNodeFlags;
}

Expand Down