Changeset 8028 in webkit


Ignore:
Timestamp:
Nov 17, 2004 12:31:34 PM (19 years ago)
Author:
rjw
Message:

Fixed <rdar://problem/3882212> REGRESSION: Images clipped instead of scaled
Fixed <rdar://problem/3884088> Crash terminating image load

Also added code to turn off color correction for images created
via CGImageSources. This code is currently disabled because CG
can't change the color space of images loaded progressively.
Further, according to Dave Hayward, CG will no longer attempt
to color correct images that don't have embedded profiles as of
Tiger 8A306.

Reviewed by Chris.

  • WebCoreSupport.subproj/WebImageData.m: (-[WebImageData _commonTermination]): (-[WebImageData dealloc]): (-[WebImageData _invalidateImageProperties]): (-[WebImageData imageAtIndex:]): (-[WebImageData incrementalLoadWithBytes:length:complete:]): (-[WebImageData propertiesAtIndex:]):
Location:
trunk/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/ChangeLog

    r8026 r8028  
     12004-11-17  Richard Williamson   <rjw@apple.com>
     2
     3        Fixed <rdar://problem/3882212> REGRESSION: Images clipped instead of scaled
     4        Fixed <rdar://problem/3884088> Crash terminating image load
     5
     6        Also added code to turn off color correction for images created
     7        via CGImageSources.  This code is currently disabled because CG 
     8        can't change the color space of images loaded progressively.
     9        Further, according to Dave Hayward, CG will no longer attempt
     10        to color correct images that don't have embedded profiles as of
     11        Tiger 8A306.
     12
     13        Reviewed by Chris.
     14
     15        * WebCoreSupport.subproj/WebImageData.m:
     16        (-[WebImageData _commonTermination]):
     17        (-[WebImageData dealloc]):
     18        (-[WebImageData _invalidateImageProperties]):
     19        (-[WebImageData imageAtIndex:]):
     20        (-[WebImageData incrementalLoadWithBytes:length:complete:]):
     21        (-[WebImageData propertiesAtIndex:]):
     22
    1232004-11-16  Chris Blumenberg  <cblu@apple.com>
    224
  • trunk/WebKit/WebCoreSupport.subproj/WebImageData.m

    r8009 r8028  
    1313#import <CoreGraphics/CGContextPrivate.h>
    1414#import <CoreGraphics/CGContextGState.h>
     15#import <CoreGraphics/CGColorSpacePrivate.h>
    1516
    1617#ifdef USE_CGIMAGEREF
     
    2223- (void)_commonTermination;
    2324- (void)_invalidateImages;
     25- (void)_invalidateImageProperties;
    2426- (int)_repetitionCount;
    2527- (float)_frameDuration;
     
    3739    [self _invalidateImages];
    3840   
     41    [self _invalidateImageProperties];
     42   
    3943    if (imageSource)
    4044        CFRelease (imageSource);
     
    4246    if (animatingRenderers)
    4347        CFRelease (animatingRenderers);
     48
     49    free (frameDurations);
    4450}
    4551
    4652- (void)dealloc
    4753{
    48     size_t i, num;
    49    
    50     num = [self numberOfImages];
    51     for (i = 0; i < imagePropertiesSize; i++) {
    52         CFRelease (imageProperties[i]);
    53     }
    54     free (imageProperties);
    55    
    56     free (frameDurations);
    57 
    5854    [self _commonTermination];
    59    
    6055    [super dealloc];
    6156}
     
    10499}
    105100
     101- (void)_invalidateImageProperties
     102{
     103    size_t i;
     104    for (i = 0; i < imagePropertiesSize; i++) {
     105        if (imageProperties[i])
     106            CFRelease (imageProperties[i]);
     107    }
     108    free (imageProperties);
     109    imageProperties = 0;
     110    imagePropertiesSize = 0;
     111}
     112
     113- (CGImageRef)_noColorCorrectionImage:(CGImageRef)image withProperties:(CFDictionaryRef)props;
     114{
     115#if NO_COLOR_CORRECTION
     116    CGColorSpaceRef uncorrectedColorSpace = 0;
     117    CGImageRef noColorCorrectionImage = 0;
     118
     119    if (!CFDictionaryGetValue (props, kCGImagePropertyProfileName)) {
     120        CFStringRef colorModel = CFDictionaryGetValue (props, kCGImagePropertyColorModel);
     121       
     122        if (colorModel) {
     123            if (CFStringCompare (colorModel, (CFStringRef)@"RGB", 0) == kCFCompareEqualTo)
     124                uncorrectedColorSpace = CGColorSpaceCreateDisplayRGB();
     125            else if (CFStringCompare (colorModel, (CFStringRef)@"Gray", 0) == kCFCompareEqualTo)
     126                uncorrectedColorSpace = CGColorSpaceCreateDisplayGray();
     127        }
     128       
     129        if (uncorrectedColorSpace) {
     130            noColorCorrectionImage = CGImageCreateCopyWithColorSpace (image, uncorrectedColorSpace);
     131            CFRelease (uncorrectedColorSpace);
     132        }
     133    }
     134    return noColorCorrectionImage;
     135#else
     136    return 0;
     137#endif
     138}
     139           
    106140- (CGImageRef)imageAtIndex:(size_t)index
    107141{
     
    147181                ERROR ("unable to create image at index %d, containerStatus %d, image status %d", (int)index, containerStatus, imageStatus);
    148182        }
     183       
     184#if NO_COLOR_CORRECTION
     185        if (imageStatus >= kCGImageStatusIncomplete) {
     186            CGImageRef noColorCorrectionImage = [self _noColorCorrectionImage:images[index]
     187                                                withProperties:[self propertiesAtIndex:index]];
     188            if (noColorCorrectionImage) {
     189                CFRelease (images[index]);
     190                images[index] = noColorCorrectionImage;
     191            }
     192        }
     193#endif
     194       
    149195        return images[index];
    150196    }
     
    162208    CGImageSourceUpdateData (imageSource, data, isComplete);
    163209    CFRelease (data);
    164    
     210
    165211    // Always returns YES because we can't rely on status.  See 3827851
    166212    //CGImageSourceStatus status = CGImageSourceGetStatus(imageSource);
     
    171217
    172218- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
    173 {
     219{   
    174220    CGImageRef image = [self imageAtIndex:index];
    175221   
     
    179225    CGContextSaveGState (aContext);
    180226
    181     float w = CGImageGetWidth(image);
     227    //float w = CGImageGetWidth(image);
    182228    float h = CGImageGetHeight(image);
    183229
    184230    // Is the amount of available bands less than what we need to draw?  If so,
    185231    // clip.
     232    BOOL clipping = NO;
    186233    if (h < fr.size.height) {
    187234        fr.size.height = h;
    188235        ir.size.height = h;
     236        clipping = YES;
    189237    }
    190238   
     
    200248    // If we're drawing a sub portion of the image then create
    201249    // a image for the sub portion and draw that.
    202     if (fr.size.width != w || fr.size.height != h) {
     250    // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
     251    if (fr.origin.x != 0 || fr.origin.y != 0 ||
     252        fr.size.width != ir.size.width || fr.size.height != fr.size.height ||
     253        clipping) {
    203254        image = CGImageCreateWithImageInRect (image, fr);
    204255        if (image) {
     
    333384    if (imagePropertiesSize && num > imagePropertiesSize) {
    334385        // Clear cache.
    335         size_t i;
    336         for (i = 0; i < imagePropertiesSize; i++) {
    337             CFRelease (imageProperties[i]);
    338         }
    339         free (imageProperties);
    340         imageProperties = 0;
    341         imagePropertiesSize = 0;
     386        [self _invalidateImageProperties];
    342387    }
    343388   
Note: See TracChangeset for help on using the changeset viewer.