diff --git a/Tests/Images/TestColorspaceStatic.webp b/Tests/Images/TestColorspaceStatic.webp new file mode 100644 index 0000000..0f17960 Binary files /dev/null and b/Tests/Images/TestColorspaceStatic.webp differ diff --git a/Tests/SDWebImageWebPCoderTests.m b/Tests/SDWebImageWebPCoderTests.m index c2c797f..40bdf9f 100644 --- a/Tests/SDWebImageWebPCoderTests.m +++ b/Tests/SDWebImageWebPCoderTests.m @@ -218,6 +218,18 @@ const int64_t kAsyncTestTimeout = 5; XCTAssertLessThanOrEqual(dataWithLimit.length, maxFileSize); } +- (void)testWebPDecodeDoesNotTriggerCACopyImage { + NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestColorspaceStatic" withExtension:@"webp"]; + NSData *data = [NSData dataWithContentsOfURL:staticWebPURL]; + UIImage *image = [SDImageWebPCoder.sharedCoder decodedImageWithData:data options:@{SDImageCoderDecodeThumbnailPixelSize: @(CGSizeMake(1023, 680))}]; // 1023 * 4 need aligned to 4096 + CGImageRef cgImage = [image CGImage]; + size_t bytesPerRow = CGImageGetBytesPerRow(cgImage); + XCTAssertEqual(bytesPerRow, 4096); + CGColorSpaceRef colorspace = CGImageGetColorSpace(cgImage); + NSString *colorspaceName = (__bridge_transfer NSString *)CGColorSpaceCopyName(colorspace); + XCTAssertEqual(colorspaceName, (__bridge NSString *)kCGColorSpaceSRGB, @"Color space is not sRGB"); +} + - (void)testEncodingSettings { WebPConfig config; WebPConfigPreset(&config, WEBP_PRESET_DEFAULT, 0.2); diff --git a/Tests/SDWebImageWebPCoderTests.xcodeproj/project.pbxproj b/Tests/SDWebImageWebPCoderTests.xcodeproj/project.pbxproj index 25bd836..504faab 100644 --- a/Tests/SDWebImageWebPCoderTests.xcodeproj/project.pbxproj +++ b/Tests/SDWebImageWebPCoderTests.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 0EF5B6264833B7BC20894578 /* Pods_SDWebImageWebPCoderTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46F21AD7D1692EBAC4D0FF33 /* Pods_SDWebImageWebPCoderTests.framework */; }; 3219F3B2228B0453003822A6 /* TestImageBlendAnimated.webp in Resources */ = {isa = PBXBuildFile; fileRef = 3219F3B1228B0453003822A6 /* TestImageBlendAnimated.webp */; }; 325E268E25C82BE1000B807B /* TestImageGrayscale.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 325E268D25C82BE1000B807B /* TestImageGrayscale.jpg */; }; + 326420312A5D53E300EE3E46 /* TestColorspaceStatic.webp in Resources */ = {isa = PBXBuildFile; fileRef = 326420302A5D53E300EE3E46 /* TestColorspaceStatic.webp */; }; 808C918E213FD131004B0F7C /* SDWebImageWebPCoderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 808C918D213FD131004B0F7C /* SDWebImageWebPCoderTests.m */; }; 808C919C213FD2B2004B0F7C /* TestImageStatic.webp in Resources */ = {isa = PBXBuildFile; fileRef = 808C919A213FD2B2004B0F7C /* TestImageStatic.webp */; }; 808C919D213FD2B2004B0F7C /* TestImageAnimated.webp in Resources */ = {isa = PBXBuildFile; fileRef = 808C919B213FD2B2004B0F7C /* TestImageAnimated.webp */; }; @@ -19,6 +20,7 @@ 28D8AA3D3015E075692FD3E3 /* Pods-SDWebImageWebPCoderTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageWebPCoderTests.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-SDWebImageWebPCoderTests/Pods-SDWebImageWebPCoderTests.debug.xcconfig"; sourceTree = ""; }; 3219F3B1228B0453003822A6 /* TestImageBlendAnimated.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestImageBlendAnimated.webp; sourceTree = ""; }; 325E268D25C82BE1000B807B /* TestImageGrayscale.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = TestImageGrayscale.jpg; sourceTree = ""; }; + 326420302A5D53E300EE3E46 /* TestColorspaceStatic.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestColorspaceStatic.webp; sourceTree = ""; }; 46F21AD7D1692EBAC4D0FF33 /* Pods_SDWebImageWebPCoderTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SDWebImageWebPCoderTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 808C918B213FD130004B0F7C /* SDWebImageWebPCoderTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SDWebImageWebPCoderTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 808C918D213FD131004B0F7C /* SDWebImageWebPCoderTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageWebPCoderTests.m; sourceTree = ""; }; @@ -80,6 +82,7 @@ 808C9199213FD2B2004B0F7C /* Images */ = { isa = PBXGroup; children = ( + 326420302A5D53E300EE3E46 /* TestColorspaceStatic.webp */, 325E268D25C82BE1000B807B /* TestImageGrayscale.jpg */, 808C919A213FD2B2004B0F7C /* TestImageStatic.webp */, 808C919B213FD2B2004B0F7C /* TestImageAnimated.webp */, @@ -157,6 +160,7 @@ 3219F3B2228B0453003822A6 /* TestImageBlendAnimated.webp in Resources */, 808C919D213FD2B2004B0F7C /* TestImageAnimated.webp in Resources */, 808C919C213FD2B2004B0F7C /* TestImageStatic.webp in Resources */, + 326420312A5D53E300EE3E46 /* TestColorspaceStatic.webp in Resources */, 325E268E25C82BE1000B807B /* TestImageGrayscale.jpg in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -377,6 +381,7 @@ "$(inherited)", ); INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; PRODUCT_BUNDLE_IDENTIFIER = org.SDWebImage.SDWebImageWebPCoderTests; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -387,6 +392,7 @@ baseConfigurationReference = D92E6791BF088D1A101E670E /* Pods-SDWebImageWebPCoderTests.release.xcconfig */; buildSettings = { INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; PRODUCT_BUNDLE_IDENTIFIER = org.SDWebImage.SDWebImageWebPCoderTests; PRODUCT_NAME = "$(TARGET_NAME)"; };