Skip to content

Commit

Permalink
[#trivial] fixes rendered image quality on networked image nodes whic…
Browse files Browse the repository at this point in the history
…h have their image directly set. (TextureGroup#826)
  • Loading branch information
garrettmoon authored Mar 9, 2018
1 parent d70ab3e commit f99dd68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Source/ASNetworkImageNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,19 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign, readwrite) BOOL shouldRenderProgressImages;

/**
* The image quality of the current image. This is a number between 0 and 1 and can be used to track
* The image quality of the current image.
*
* If the URL is set, this is a number between 0 and 1 and can be used to track
* progressive progress. Calculated by dividing number of bytes / expected number of total bytes.
* This is zero until the first progressive render or the final display.
*
* If the URL is unset, this is 1 if defaultImage or image is set to non-nil.
*
*/
@property (nonatomic, assign, readonly) CGFloat currentImageQuality;

/**
* The image quality (value between 0 and 1) of the last image that completed displaying.
* The currentImageQuality (value between 0 and 1) of the last image that completed displaying.
*/
@property (nonatomic, assign, readonly) CGFloat renderedImageQuality;

Expand Down
6 changes: 5 additions & 1 deletion Source/ASNetworkImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ - (void)_locked_setImage:(UIImage *)image
[self _locked_cancelDownloadAndClearImageWithResumePossibility:NO];
}

// If our image is being set externally, the image quality is 100%
if (imageWasSetExternally) {
[self _setCurrentImageQuality:1.0];
}

[self _locked__setImage:image];
}

Expand Down Expand Up @@ -227,7 +232,6 @@ - (void)_locked_setDefaultImage:(UIImage *)defaultImage
if (!_imageLoaded) {
[self _setCurrentImageQuality:((_URL == nil) ? 0.0 : 1.0)];
[self _locked__setImage:defaultImage];

}
}

Expand Down

0 comments on commit f99dd68

Please sign in to comment.