Просмотр исходного кода

Fix the handle of ForceDecodePolicyAlways, still need to check animated image and vector image to not break them

DreamPiggy 2 лет назад
Родитель
Сommit
cc89e14fdd
1 измененных файлов с 17 добавлено и 14 удалено
  1. 17 14
      SDWebImage/Core/SDImageCoderHelper.m

+ 17 - 14
SDWebImage/Core/SDImageCoderHelper.m

@@ -816,11 +816,9 @@ static const CGFloat kDestSeemOverlap = 2.0f;   // the numbers of pixels to over
     if (image == nil) {
         return NO;
     }
-    // Check policy (never/always)
+    // Check policy (never)
     if (policy == SDImageForceDecodePolicyNever) {
         return NO;
-    } else if (policy == SDImageForceDecodePolicyAlways) {
-        return YES;
     }
     // Avoid extra decode
     if (image.sd_isDecoded) {
@@ -834,17 +832,22 @@ static const CGFloat kDestSeemOverlap = 2.0f;   // the numbers of pixels to over
     if (image.sd_isVector) {
         return NO;
     }
-    // Check policy (automatic)
-    CGImageRef cgImage = image.CGImage;
-    if (cgImage) {
-        CFStringRef uttype = CGImageGetUTType(cgImage);
-        if (uttype) {
-            // Only ImageIO can set `com.apple.ImageIO.imageSourceTypeIdentifier`
-            return YES;
-        } else {
-            // Now, let's check if the CGImage is hardware supported (not byte-aligned will cause extra copy)
-            BOOL isSupported = [SDImageCoderHelper CGImageIsHardwareSupported:cgImage];
-            return !isSupported;
+    // Check policy (always)
+    if (policy == SDImageForceDecodePolicyAlways) {
+        return YES;
+    } else {
+        // Check policy (automatic)
+        CGImageRef cgImage = image.CGImage;
+        if (cgImage) {
+            CFStringRef uttype = CGImageGetUTType(cgImage);
+            if (uttype) {
+                // Only ImageIO can set `com.apple.ImageIO.imageSourceTypeIdentifier`
+                return YES;
+            } else {
+                // Now, let's check if the CGImage is hardware supported (not byte-aligned will cause extra copy)
+                BOOL isSupported = [SDImageCoderHelper CGImageIsHardwareSupported:cgImage];
+                return !isSupported;
+            }
         }
     }