+2004-11-17 Richard Williamson <rjw@apple.com>
+
+ 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:]):
+
2004-11-16 Chris Blumenberg <cblu@apple.com>
Fixed: <rdar://problem/3882034> REGRESSION: Context menu incorrect for PDF content
#import <CoreGraphics/CGContextPrivate.h>
#import <CoreGraphics/CGContextGState.h>
+#import <CoreGraphics/CGColorSpacePrivate.h>
#ifdef USE_CGIMAGEREF
@interface WebImageData (WebInternal)
- (void)_commonTermination;
- (void)_invalidateImages;
+- (void)_invalidateImageProperties;
- (int)_repetitionCount;
- (float)_frameDuration;
- (void)_stopAnimation;
[self _invalidateImages];
+ [self _invalidateImageProperties];
+
if (imageSource)
CFRelease (imageSource);
if (animatingRenderers)
CFRelease (animatingRenderers);
+
+ free (frameDurations);
}
- (void)dealloc
{
- size_t i, num;
-
- num = [self numberOfImages];
- for (i = 0; i < imagePropertiesSize; i++) {
- CFRelease (imageProperties[i]);
- }
- free (imageProperties);
-
- free (frameDurations);
-
[self _commonTermination];
-
[super dealloc];
}
}
}
+- (void)_invalidateImageProperties
+{
+ size_t i;
+ for (i = 0; i < imagePropertiesSize; i++) {
+ if (imageProperties[i])
+ CFRelease (imageProperties[i]);
+ }
+ free (imageProperties);
+ imageProperties = 0;
+ imagePropertiesSize = 0;
+}
+
+- (CGImageRef)_noColorCorrectionImage:(CGImageRef)image withProperties:(CFDictionaryRef)props;
+{
+#if NO_COLOR_CORRECTION
+ CGColorSpaceRef uncorrectedColorSpace = 0;
+ CGImageRef noColorCorrectionImage = 0;
+
+ if (!CFDictionaryGetValue (props, kCGImagePropertyProfileName)) {
+ CFStringRef colorModel = CFDictionaryGetValue (props, kCGImagePropertyColorModel);
+
+ if (colorModel) {
+ if (CFStringCompare (colorModel, (CFStringRef)@"RGB", 0) == kCFCompareEqualTo)
+ uncorrectedColorSpace = CGColorSpaceCreateDisplayRGB();
+ else if (CFStringCompare (colorModel, (CFStringRef)@"Gray", 0) == kCFCompareEqualTo)
+ uncorrectedColorSpace = CGColorSpaceCreateDisplayGray();
+ }
+
+ if (uncorrectedColorSpace) {
+ noColorCorrectionImage = CGImageCreateCopyWithColorSpace (image, uncorrectedColorSpace);
+ CFRelease (uncorrectedColorSpace);
+ }
+ }
+ return noColorCorrectionImage;
+#else
+ return 0;
+#endif
+}
+
- (CGImageRef)imageAtIndex:(size_t)index
{
size_t num = [self numberOfImages];
if (images[index] == 0)
ERROR ("unable to create image at index %d, containerStatus %d, image status %d", (int)index, containerStatus, imageStatus);
}
+
+#if NO_COLOR_CORRECTION
+ if (imageStatus >= kCGImageStatusIncomplete) {
+ CGImageRef noColorCorrectionImage = [self _noColorCorrectionImage:images[index]
+ withProperties:[self propertiesAtIndex:index]];
+ if (noColorCorrectionImage) {
+ CFRelease (images[index]);
+ images[index] = noColorCorrectionImage;
+ }
+ }
+#endif
+
return images[index];
}
return 0;
CFDataRef data = CFDataCreate (NULL, bytes, length);
CGImageSourceUpdateData (imageSource, data, isComplete);
CFRelease (data);
-
+
// Always returns YES because we can't rely on status. See 3827851
//CGImageSourceStatus status = CGImageSourceGetStatus(imageSource);
//
}
- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
-{
+{
CGImageRef image = [self imageAtIndex:index];
if (!image)
CGContextSaveGState (aContext);
- float w = CGImageGetWidth(image);
+ //float w = CGImageGetWidth(image);
float h = CGImageGetHeight(image);
// Is the amount of available bands less than what we need to draw? If so,
// clip.
+ BOOL clipping = NO;
if (h < fr.size.height) {
fr.size.height = h;
ir.size.height = h;
+ clipping = YES;
}
// Flip the coords.
// If we're drawing a sub portion of the image then create
// a image for the sub portion and draw that.
- if (fr.size.width != w || fr.size.height != h) {
+ // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
+ if (fr.origin.x != 0 || fr.origin.y != 0 ||
+ fr.size.width != ir.size.width || fr.size.height != fr.size.height ||
+ clipping) {
image = CGImageCreateWithImageInRect (image, fr);
if (image) {
CGContextDrawImage (aContext, ir, image);
// Number of images changed!
if (imagePropertiesSize && num > imagePropertiesSize) {
// Clear cache.
- size_t i;
- for (i = 0; i < imagePropertiesSize; i++) {
- CFRelease (imageProperties[i]);
- }
- free (imageProperties);
- imageProperties = 0;
- imagePropertiesSize = 0;
+ [self _invalidateImageProperties];
}
if (imageProperties == 0 && num) {