Explorar el Código

Add some more comments about coder method

DreamPiggy hace 8 años
padre
commit
decb5dcdeb
Se han modificado 2 ficheros con 10 adiciones y 5 borrados
  1. 4 0
      SDWebImage/SDWebImageCoder.h
  2. 6 5
      SDWebImage/SDWebImageImageIOCoder.m

+ 4 - 0
SDWebImage/SDWebImageCoder.h

@@ -33,10 +33,12 @@ CG_EXTERN BOOL SDCGImageRefContainsAlpha(_Nullable CGImageRef imageRef);
 
 /**
  This is the image coder protocol to provide custom image decoding/encoding.
+ These methods are all required to implement.
  @note Pay attention that these methods are not called from main queue.
  */
 @protocol SDWebImageCoder <NSObject>
 
+@required
 #pragma mark - Decoding
 /**
  Returns YES if this coder can decode some data. Otherwise, the data should be passed to another coder.
@@ -90,10 +92,12 @@ CG_EXTERN BOOL SDCGImageRefContainsAlpha(_Nullable CGImageRef imageRef);
 
 /**
  This is the image coder protocol to provide custom progressive image decoding.
+ These methods are all required to implement.
  @note Pay attention that these methods are not called from main queue.
  */
 @protocol SDWebImageProgressiveCoder <SDWebImageCoder>
 
+@required
 /**
  Returns YES if this coder can incremental decode some data. Otherwise, it should be passed to another coder.
  

+ 6 - 5
SDWebImage/SDWebImageImageIOCoder.m

@@ -66,8 +66,8 @@ static const CGFloat kDestSeemOverlap = 2.0f;   // the numbers of pixels to over
 #pragma mark - Decode
 - (BOOL)canDecodeFromData:(nullable NSData *)data {
     switch ([NSData sd_imageFormatForImageData:data]) {
-        // Do not support WebP decoding
         case SDImageFormatWebP:
+            // Do not support WebP decoding
             return NO;
         default:
             return YES;
@@ -76,8 +76,8 @@ static const CGFloat kDestSeemOverlap = 2.0f;   // the numbers of pixels to over
 
 - (BOOL)canIncrementallyDecodeFromData:(NSData *)data {
     switch ([NSData sd_imageFormatForImageData:data]) {
-        // Support static GIF progressive decoding
         case SDImageFormatWebP:
+            // Do not support WebP progressive decoding
             return NO;
         default:
             return YES;
@@ -394,10 +394,11 @@ static const CGFloat kDestSeemOverlap = 2.0f;   // the numbers of pixels to over
 #pragma mark - Encode
 - (BOOL)canEncodeToFormat:(SDImageFormat)format {
     switch (format) {
-        // Do not support WebP encoding
         case SDImageFormatWebP:
+            // Do not support WebP encoding
             return NO;
         case SDImageFormatHEIC:
+            // Check HEIC encoding compatibility
             return [[self class] canEncodeToHEICFormat];
         default:
             return YES;
@@ -482,10 +483,10 @@ static const CGFloat kDestSeemOverlap = 2.0f;   // the numbers of pixels to over
         // Create an image destination.
         CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL);
         if (!imageDestination) {
-            // Can encode to HEIC
+            // Can't encode to HEIC
             canEncode = NO;
         } else {
-            // Can't encode to HEIF
+            // Can encode to HEIC
             CFRelease(imageDestination);
             canEncode = YES;
         }