fix wrong memory cast in _UIAnimatedImage
This commit is contained in:
parent
0b304a867d
commit
22cd94d08a
1
Podfile
1
Podfile
|
@ -14,6 +14,7 @@ def all_test_pods
|
|||
pod 'SDWebImage/MapKit', :path => './'
|
||||
pod 'Expecta'
|
||||
pod 'KVOController'
|
||||
pod 'SDWebImageWebPCoder', :git => 'https://github.com/SDWebImage/SDWebImageWebPCoder.git', :branch => 'master'
|
||||
end
|
||||
|
||||
example_project_path = 'Examples/SDWebImage Demo'
|
||||
|
|
|
@ -20,7 +20,8 @@ FOUNDATION_STATIC_INLINE NSUInteger SDMemoryCacheCostForImage(UIImage *image) {
|
|||
#if SD_MAC
|
||||
frameCount = 1;
|
||||
#elif SD_UIKIT || SD_WATCH
|
||||
frameCount = image.images.count > 0 ? image.images.count : 1;
|
||||
// Filter the same image in `_UIAnimatedImage`.
|
||||
frameCount = image.images.count > 0 ? [NSSet setWithArray:image.images].count : 1;
|
||||
#endif
|
||||
NSUInteger cost = bytesPerFrame * frameCount;
|
||||
return cost;
|
||||
|
|
|
@ -104,6 +104,7 @@
|
|||
4369C2741D9804B1007E863A /* SDWebCacheCategoriesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4369C2731D9804B1007E863A /* SDWebCacheCategoriesTests.m */; };
|
||||
43828A451DA67F9900000E62 /* TestImageLarge.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 43828A441DA67F9900000E62 /* TestImageLarge.jpg */; };
|
||||
5F7F38AD1AE2A77A00B0E330 /* TestImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 5F7F38AC1AE2A77A00B0E330 /* TestImage.jpg */; };
|
||||
6B181A1B265757ED00BD06B3 /* TestAnimatedImageMemory.webp in Resources */ = {isa = PBXBuildFile; fileRef = 6B181A1A265757ED00BD06B3 /* TestAnimatedImageMemory.webp */; };
|
||||
770D3B9C7914D53EBA0524DB /* Pods_Tests_TV.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B73996BC299E8E0174661628 /* Pods_Tests_TV.framework */; };
|
||||
AFDBD4044E95252B70FB85CE /* Pods_Tests_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD1BD830DA7388EB6C110B3B /* Pods_Tests_iOS.framework */; };
|
||||
DA248D57195472AA00390AB0 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA248D56195472AA00390AB0 /* XCTest.framework */; };
|
||||
|
@ -165,6 +166,7 @@
|
|||
5B0011ED58CC9998E68ECCE3 /* Pods-Tests TV.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests TV.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-Tests TV/Pods-Tests TV.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
5F7F38AC1AE2A77A00B0E330 /* TestImage.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = TestImage.jpg; sourceTree = "<group>"; };
|
||||
6700DBD9C45B00AB5F77472A /* Pods-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Tests/Pods-Tests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
6B181A1A265757ED00BD06B3 /* TestAnimatedImageMemory.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestAnimatedImageMemory.webp; sourceTree = "<group>"; };
|
||||
6CB13D7A081654B2E4018F53 /* Pods-Tests TV.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests TV.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Tests TV/Pods-Tests TV.release.xcconfig"; sourceTree = "<group>"; };
|
||||
A39EDFED1067C297B91792CB /* Pods_Tests_Mac.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tests_Mac.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
AD1BD830DA7388EB6C110B3B /* Pods_Tests_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tests_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -265,6 +267,7 @@
|
|||
3297A09E23374D1600814590 /* TestImageAnimated.heic */,
|
||||
32515F9824AF1919005E8F79 /* TestImageAnimated.webp */,
|
||||
32515F9724AF1919005E8F79 /* TestImageStatic.webp */,
|
||||
6B181A1A265757ED00BD06B3 /* TestAnimatedImageMemory.webp */,
|
||||
);
|
||||
path = Images;
|
||||
sourceTree = "<group>";
|
||||
|
@ -511,6 +514,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
327A418C211D660600495442 /* TestImage.heic in Resources */,
|
||||
6B181A1B265757ED00BD06B3 /* TestAnimatedImageMemory.webp in Resources */,
|
||||
5F7F38AD1AE2A77A00B0E330 /* TestImage.jpg in Resources */,
|
||||
32905E64211D786E00460FCF /* TestImage.heif in Resources */,
|
||||
43828A451DA67F9900000E62 /* TestImageLarge.jpg in Resources */,
|
||||
|
@ -558,12 +562,16 @@
|
|||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Tests TV/Pods-Tests TV-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImage-Core-MapKit-tvOS/SDWebImage.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-tvOS/SDWebImageWebPCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/libwebp-tvOS/libwebp.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Expecta-tvOS/Expecta.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/KVOController-tvOS/KVOController.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KVOController.framework",
|
||||
);
|
||||
|
@ -598,12 +606,16 @@
|
|||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Tests Mac/Pods-Tests Mac-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImage-Core-MapKit-macOS/SDWebImage.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-macOS/SDWebImageWebPCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/libwebp-macOS/libwebp.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Expecta-macOS/Expecta.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/KVOController-macOS/KVOController.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KVOController.framework",
|
||||
);
|
||||
|
@ -620,12 +632,16 @@
|
|||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Tests iOS/Pods-Tests iOS-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImage-Core-MapKit-iOS/SDWebImage.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-iOS/SDWebImageWebPCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/libwebp-iOS/libwebp.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Expecta-iOS/Expecta.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/KVOController-iOS/KVOController.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KVOController.framework",
|
||||
);
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 574 KiB |
|
@ -10,6 +10,7 @@
|
|||
#import "SDTestCase.h"
|
||||
#import "SDInternalMacros.h"
|
||||
#import <KVOController/KVOController.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
|
||||
static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop count
|
||||
|
||||
|
@ -713,7 +714,7 @@ static BOOL _isCalled;
|
|||
[self waitForExpectationsWithTimeout:15 handler:nil];
|
||||
}
|
||||
|
||||
- (void)test35AnimatedImagePlaybackModeReversedBounce{
|
||||
- (void)test35AnimatedImagePlaybackModeReversedBounce {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"test SDAnimatedImageView playback reverse bounce mode"];
|
||||
|
||||
SDAnimatedImageView *imageView = [SDAnimatedImageView new];
|
||||
|
@ -765,6 +766,15 @@ static BOOL _isCalled;
|
|||
[self waitForExpectationsWithTimeout:15 handler:nil];
|
||||
}
|
||||
|
||||
- (void)test36AnimatedImageMemoryCost {
|
||||
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
|
||||
UIImage *image = [UIImage sd_imageWithData:[NSData dataWithContentsOfFile:[self testMemotyCostImagePath]]];
|
||||
NSUInteger cost = [image sd_memoryCost];
|
||||
expect(image.images.count).equal(5333);
|
||||
expect(image.scale).equal(1);
|
||||
expect(cost).equal(16 * image.size.width * image.size.height * 4);
|
||||
}
|
||||
|
||||
#pragma mark - Helper
|
||||
- (UIWindow *)window {
|
||||
if (!_window) {
|
||||
|
@ -795,6 +805,12 @@ static BOOL _isCalled;
|
|||
return testPath;
|
||||
}
|
||||
|
||||
- (NSString *)testMemotyCostImagePath {
|
||||
NSBundle *testBundle = [NSBundle bundleForClass:[self class]];
|
||||
NSString *testPath = [testBundle pathForResource:@"TestAnimatedImageMemory" ofType:@"webp"];
|
||||
return testPath;
|
||||
}
|
||||
|
||||
- (NSData *)testAPNGPData {
|
||||
return [NSData dataWithContentsOfFile:[self testAPNGPPath]];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue