From 03e63ede2538b43bf76bf16441d496542dbea4bf Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Mon, 6 Jan 2020 19:06:49 +0800 Subject: [PATCH] Change the default limit bytes 60MB on iOS/tvOS, 90MB on macOS, 30MB on watchOS --- SDWebImage/Core/SDImageCoderHelper.h | 2 +- SDWebImage/Core/SDImageCoderHelper.m | 6 ++++++ SDWebImage/Core/SDWebImageDefine.h | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/SDWebImage/Core/SDImageCoderHelper.h b/SDWebImage/Core/SDImageCoderHelper.h index 353a8729..38085b7e 100644 --- a/SDWebImage/Core/SDImageCoderHelper.h +++ b/SDWebImage/Core/SDImageCoderHelper.h @@ -91,7 +91,7 @@ /** Control the default limit bytes to scale down larget images. - This value must be larger than or equal to 1MB. Defaults to 60MB. + This value must be larger than or equal to 1MB. Defaults to 60MB on iOS/tvOS, 90MB on macOS, 30MB on watchOS. */ @property (class, readwrite) NSUInteger defaultScaleDownLimitBytes; diff --git a/SDWebImage/Core/SDImageCoderHelper.m b/SDWebImage/Core/SDImageCoderHelper.m index ac671366..b88f7068 100644 --- a/SDWebImage/Core/SDImageCoderHelper.m +++ b/SDWebImage/Core/SDImageCoderHelper.m @@ -26,7 +26,13 @@ static const CGFloat kPixelsPerMB = kBytesPerMB / kBytesPerPixel; * Suggested value for iPad2 and iPhone 4: 120. * Suggested value for iPhone 3G and iPod 2 and earlier devices: 30. */ +#if SD_MAC +static CGFloat kDestImageLimitBytes = 90.f * kBytesPerMB; +#elif SD_UIKIT static CGFloat kDestImageLimitBytes = 60.f * kBytesPerMB; +#elif SD_WATCH +static CGFloat kDestImageLimitBytes = 30.f * kBytesPerMB; +#endif static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to overlap the seems where tiles meet. diff --git a/SDWebImage/Core/SDWebImageDefine.h b/SDWebImage/Core/SDWebImageDefine.h index 8c364844..1e871ac0 100644 --- a/SDWebImage/Core/SDWebImageDefine.h +++ b/SDWebImage/Core/SDWebImageDefine.h @@ -124,8 +124,8 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { /** * By default, images are decoded respecting their original size. * This flag will scale down the images to a size compatible with the constrained memory of devices. - * To control the limit memory bytes, check `SDImageCoderHelper.defaultScaleDownLimitBytes` (Defaults to 60MB) - * This will actually translate to use context option `.imageThumbnailPixelSize` from v5.5.0 (Defaults to (3966, 3966)). Previously does not. + * To control the limit memory bytes, check `SDImageCoderHelper.defaultScaleDownLimitBytes` (Defaults to 60MB on iOS) + * This will actually translate to use context option `.imageThumbnailPixelSize` from v5.5.0 (Defaults to (3966, 3966) on iOS). Previously does not. * This flags effect the progressive and animated images as well from v5.5.0. Previously does not. * @note If you need detail controls, it's better to use context option `imageThumbnailPixelSize` and `imagePreserveAspectRatio` instead. */