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

Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% #1487

Merged
merged 3 commits into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions Source/ASImageNode+AnimatedImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ - (void)setAnimatedImagePaused:(BOOL)animatedImagePaused
{
ASLockScopeSelf();

_animatedImagePaused = animatedImagePaused;
_imageNodeFlags.animatedImagePaused = animatedImagePaused;

[self _locked_setShouldAnimate:!animatedImagePaused];
}

- (BOOL)animatedImagePaused
{
ASLockScopeSelf();
return _animatedImagePaused;
return _imageNodeFlags.animatedImagePaused;
}

- (void)setCoverImageCompleted:(UIImage *)coverImage
Expand Down Expand Up @@ -235,7 +235,7 @@ - (void)_locked_startAnimating
return;
}

if (_animatedImagePaused) {
if (_imageNodeFlags.animatedImagePaused) {
return;
}

Expand Down
20 changes: 9 additions & 11 deletions Source/ASImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ @implementation ASImageNode
ASTextNode *_debugLabelNode;

// Cropping.
BOOL _cropEnabled; // Defaults to YES.
BOOL _forceUpscaling; //Defaults to NO.
CGSize _forcedSize; //Defaults to CGSizeZero, indicating no forced size.
CGRect _cropRect; // Defaults to CGRectMake(0.5, 0.5, 0, 0)
CGRect _cropDisplayBounds; // Defaults to CGRectNull
Expand All @@ -175,8 +173,8 @@ - (instancetype)init
// initial value. With setting a explicit backgroundColor we can prevent that change.
self.backgroundColor = [UIColor clearColor];

_cropEnabled = YES;
_forceUpscaling = NO;
_imageNodeFlags.cropEnabled = YES;
_imageNodeFlags.forceUpscaling = NO;
_cropRect = CGRectMake(0.5, 0.5, 0, 0);
_cropDisplayBounds = CGRectNull;
_placeholderColor = ASDisplayNodeDefaultPlaceholderColor();
Expand Down Expand Up @@ -301,8 +299,8 @@ - (NSObject *)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer
drawParameters->_contentsScale = _contentsScaleForDisplay;
drawParameters->_backgroundColor = self.backgroundColor;
drawParameters->_contentMode = self.contentMode;
drawParameters->_cropEnabled = _cropEnabled;
drawParameters->_forceUpscaling = _forceUpscaling;
drawParameters->_cropEnabled = self.cropEnabled;
drawParameters->_forceUpscaling = self.forceUpscaling;
bolsinga marked this conversation as resolved.
Show resolved Hide resolved
drawParameters->_forcedSize = _forcedSize;
drawParameters->_cropRect = _cropRect;
drawParameters->_cropDisplayBounds = _cropDisplayBounds;
Expand Down Expand Up @@ -594,7 +592,7 @@ - (void)clearContents
- (BOOL)isCropEnabled
{
AS::MutexLocker l(__instanceLock__);
return _cropEnabled;
return _imageNodeFlags.cropEnabled;
}

- (void)setCropEnabled:(BOOL)cropEnabled
Expand All @@ -605,12 +603,12 @@ - (void)setCropEnabled:(BOOL)cropEnabled
- (void)setCropEnabled:(BOOL)cropEnabled recropImmediately:(BOOL)recropImmediately inBounds:(CGRect)cropBounds
{
__instanceLock__.lock();
if (_cropEnabled == cropEnabled) {
if (_imageNodeFlags.cropEnabled == cropEnabled) {
__instanceLock__.unlock();
return;
}

_cropEnabled = cropEnabled;
_imageNodeFlags.cropEnabled = cropEnabled;
_cropDisplayBounds = cropBounds;

UIImage *image = _image;
Expand Down Expand Up @@ -660,13 +658,13 @@ - (void)setCropRect:(CGRect)cropRect
- (BOOL)forceUpscaling
{
AS::MutexLocker l(__instanceLock__);
return _forceUpscaling;
return _imageNodeFlags.forceUpscaling;
}

- (void)setForceUpscaling:(BOOL)forceUpscaling
{
AS::MutexLocker l(__instanceLock__);
_forceUpscaling = forceUpscaling;
_imageNodeFlags.forceUpscaling = forceUpscaling;
}

- (CGSize)forcedSize
Expand Down
Loading