Przeglądaj źródła

Calculate Image cost accounting for number of image frames

When we calculate the Image cost for cache purposes, we should take into account how many frames make up the Image to get an accurate cost.
Aron Springfield 4 lat temu
rodzic
commit
592b9c9f50
1 zmienionych plików z 5 dodań i 1 usunięć
  1. 5 1
      Sources/Image/Image.swift

+ 5 - 1
Sources/Image/Image.swift

@@ -103,7 +103,11 @@ extension KingfisherWrapper where Base: KFCrossPlatformImage {
         guard let cgImage = cgImage else {
         guard let cgImage = cgImage else {
             return pixel * 4
             return pixel * 4
         }
         }
-        return pixel * cgImage.bitsPerPixel / 8
+        let bytesPerPixel = cgImage.bitsPerPixel / 8
+        guard let imageCount = images?.count else {
+            return pixel * bytesPerPixel
+        }
+        return pixel * bytesPerPixel * imageCount
     }
     }
 }
 }