Reviewed by Ken.
<rdar://problem/
3824626> Change to do colormatching for DeviceRGB colorspace causes ~11% Safari slowdown
- I fixed this by turning off all colormatching for WebKit
content. We might turn it back on later. For now, it's possible to
turn it on temporarily by defining COLORMATCH_EVERYTHING.
* WebCorePrefix.h:
* khtml/ecma/kjs_html.cpp:
(KJS::Context2DFunction::tryCall):
(Context2D::colorRefFromValue):
(Gradient::getShading):
* khtml/rendering/render_canvasimage.cpp:
(RenderCanvasImage::createDrawingContext):
* kwq/KWQColor.mm:
(QColor::getNSColor):
* kwq/KWQPainter.h:
* kwq/KWQPainter.mm:
(CGColorFromNSColor):
(QPainter::selectedTextBackgroundColor):
(QPainter::rgbColorSpace):
(QPainter::grayColorSpace):
(QPainter::cmykColorSpace):
* kwq/WebCoreGraphicsBridge.h:
* kwq/WebCoreGraphicsBridge.m:
(-[WebCoreGraphicsBridge createRGBColorSpace]):
(-[WebCoreGraphicsBridge createGrayColorSpace]):
(-[WebCoreGraphicsBridge createCMYKColorSpace]):
WebKit:
Reviewed by Ken.
<rdar://problem/
3824626> Change to do colormatching for DeviceRGB colorspace causes ~11% Safari slowdown
- I fixed this by turning off all colormatching for WebKit
content. We might turn it back on later. For now, it's possible to
turn it on temporarily by defining COLORMATCH_EVERYTHING.
* WebCoreSupport.subproj/WebGraphicsBridge.m:
(-[WebGraphicsBridge setFocusRingStyle:radius:color:]):
(-[WebGraphicsBridge additionalPatternPhase]):
(-[WebGraphicsBridge createRGBColorSpace]):
(-[WebGraphicsBridge createGrayColorSpace]):
(-[WebGraphicsBridge createCMYKColorSpace]):
* WebCoreSupport.subproj/WebImageData.m:
* WebCoreSupport.subproj/WebImageRenderer.h:
* WebCoreSupport.subproj/WebImageRenderer.m:
(-[WebImageRenderer _adjustSizeToPixelDimensions]):
(-[WebImageRenderer incrementalLoadWithBytes:length:complete:]):
(-[WebImageRenderer _adjustColorSpace]):
(-[WebImageRenderer drawClippedToValidInRect:fromRect:]):
(-[WebImageRenderer tileInRect:fromPoint:context:]):
(_createImageRef):
(WebCGColorSpaceCreateRGB):
(WebCGColorSpaceCreateGray):
(WebCGColorSpaceCreateCMYK):
* WebKitPrefix.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7833
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-10-13 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Ken.
+
+ <rdar://problem/3824626> Change to do colormatching for DeviceRGB colorspace causes ~11% Safari slowdown
+
+ - I fixed this by turning off all colormatching for WebKit
+ content. We might turn it back on later. For now, it's possible to
+ turn it on temporarily by defining COLORMATCH_EVERYTHING.
+
+ * WebCorePrefix.h:
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::Context2DFunction::tryCall):
+ (Context2D::colorRefFromValue):
+ (Gradient::getShading):
+ * khtml/rendering/render_canvasimage.cpp:
+ (RenderCanvasImage::createDrawingContext):
+ * kwq/KWQColor.mm:
+ (QColor::getNSColor):
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (CGColorFromNSColor):
+ (QPainter::selectedTextBackgroundColor):
+ (QPainter::rgbColorSpace):
+ (QPainter::grayColorSpace):
+ (QPainter::cmykColorSpace):
+ * kwq/WebCoreGraphicsBridge.h:
+ * kwq/WebCoreGraphicsBridge.m:
+ (-[WebCoreGraphicsBridge createRGBColorSpace]):
+ (-[WebCoreGraphicsBridge createGrayColorSpace]):
+ (-[WebCoreGraphicsBridge createCMYKColorSpace]):
+
2004-10-13 Ken Kocienda <kocienda@apple.com>
Reviewed by Hyatt
#include "qcolor.h"
#include "qpixmap.h"
+#include "qpainter.h"
#include <ApplicationServices/ApplicationServices.h>
components[1] = qc.green()/255.;
components[2] = qc.blue()/255.;
components[3] = 1.0f;
- colorSpace = CGColorSpaceCreateDeviceRGB();
+ colorSpace = QPainter::rgbColorSpace();
}
else {
components[0] = (float)args[3].toNumber(exec);
components[1] = 1.0f;
- colorSpace = CGColorSpaceCreateDeviceGray();
+ colorSpace = QPainter::grayColorSpace();
}
}
break;
components[1] = qc.green()/255.;
components[2] = qc.blue()/255.;
components[3] = a;
- colorSpace = CGColorSpaceCreateDeviceRGB();
+ colorSpace = QPainter::rgbColorSpace();
}
else {
components[0] = (float)args[3].toNumber(exec);
components[1] = a;
- colorSpace = CGColorSpaceCreateDeviceGray();
+ colorSpace = QPainter::grayColorSpace();
}
}
break;
components[1] = (float)args[4].toNumber(exec); // g
components[2] = (float)args[5].toNumber(exec); // b
components[3] = (float)args[6].toNumber(exec); // a
- colorSpace = CGColorSpaceCreateDeviceRGB();
+ colorSpace = QPainter::rgbColorSpace();
}
break;
case 5: {
components[3] = (float)args[6].toNumber(exec); // k
components[4] = (float)args[7].toNumber(exec); // a
- colorSpace = CGColorSpaceCreateDeviceCMYK();
+ colorSpace = QPainter::cmykColorSpace();
}
break;
default: {
size_t csw = (size_t)sw;
size_t csh = (size_t)sh;
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGColorSpaceRef colorSpace = QPainter::rgbColorSpace();
size_t numComponents = CGColorSpaceGetNumberOfComponents(colorSpace);
size_t bytesPerRow = BYTES_PER_ROW(csw,BITS_PER_COMPONENT,(numComponents+1)); // + 1 for alpha
void *_drawingContextData = malloc(csh * bytesPerRow);
components[1] = qc.green()/255.;
components[2] = qc.blue()/255.;
components[3] = qc.alpha();
- colorSpace = CGColorSpaceCreateDeviceRGB();
+ colorSpace = QPainter::rgbColorSpace();
}
else
return 0;
CGShadingRelease (_shadingRef);
CGFunctionRef _colorFunction = CGFunctionCreate((void *)this, 1, intervalRangeDomin, 4, colorComponentRangeDomains, &gradientCallbacks);
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGColorSpaceRef colorSpace = QPainter::rgbColorSpace();
if (_gradientType == Gradient::Radial) {
_shadingRef = CGShadingCreateRadial(colorSpace, CGPointMake(_x0,_y0), _r0, CGPointMake(_x1,_y1), _r1, _colorFunction, true, true);
_drawingContext = 0;
}
free (_drawingContextData);
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGColorSpaceRef colorSpace = QPainter::rgbColorSpace();
int cWidth = contentWidth();
int cHeight = contentHeight();
}
}
+#if COLORMATCH_EVERYTHING
NSColor *result = [NSColor colorWithCalibratedRed:red() / 255.0
green:green() / 255.0
blue:blue() / 255.0
- alpha: qAlpha(color)/255.0];
+ alpha:qAlpha(color)/255.0];
+#else
+ NSColor *result = [NSColor colorWithDeviceRed:red() / 255.0
+ green:green() / 255.0
+ blue:blue() / 255.0
+ alpha:qAlpha(color)/255.0];
+#endif
static int cursor;
cachedRGBAValues[cursor] = c;
static void setCompositeOperation (CGContextRef context, QString operation);
static void setCompositeOperation (CGContextRef context, int operation);
+ static CGColorSpaceRef rgbColorSpace();
+ static CGColorSpaceRef grayColorSpace();
+ static CGColorSpaceRef cmykColorSpace();
+
private:
// no copying or assignment
QPainter(const QPainter &);
static CGColorRef CGColorFromNSColor(NSColor *color)
{
- NSColor* deviceColor = [color colorUsingColorSpaceName: @"NSDeviceRGBColorSpace"];
+ // this needs to always use device colorspace so it can de-calibrate the color for
+ // CGColor to possibly recalibrate it
+ NSColor* deviceColor = [color colorUsingColorSpaceName:NSDeviceRGBColorSpace];
float red = [deviceColor redComponent];
float green = [deviceColor greenComponent];
float blue = [deviceColor blueComponent];
float alpha = [deviceColor alphaComponent];
const float components[] = { red, green, blue, alpha };
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGColorSpaceRef colorSpace = QPainter::rgbColorSpace();
CGColorRef cgColor = CGColorCreate(colorSpace, components);
CGColorSpaceRelease(colorSpace);
return cgColor;
QColor QPainter::selectedTextBackgroundColor() const
{
NSColor *color = _usesInactiveTextBackgroundColor ? [NSColor secondarySelectedControlColor] : [NSColor selectedTextBackgroundColor];
- color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
+ // this needs to always use device colorspace so it can de-calibrate the color for
+ // QColor to possibly recalibrate it
+ color = [color colorUsingColorSpaceName:NSDeviceRGBColorSpace];
QColor col = QColor((int)(255 * [color redComponent]), (int)(255 * [color greenComponent]), (int)(255 * [color blueComponent]));
data->focusRingPath = nil;
}
}
+
+CGColorSpaceRef QPainter::rgbColorSpace()
+{
+ return [[WebCoreGraphicsBridge sharedBridge] createRGBColorSpace];
+}
+
+CGColorSpaceRef QPainter::grayColorSpace()
+{
+ return [[WebCoreGraphicsBridge sharedBridge] createGrayColorSpace];
+}
+
+CGColorSpaceRef QPainter::cmykColorSpace()
+{
+ return [[WebCoreGraphicsBridge sharedBridge] createCMYKColorSpace];
+}
+
+
- (void)setFocusRingStyle:(NSFocusRingPlacement)placement radius:(int)radius color:(NSColor *)color;
- (void)setDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc;
- (void)setAdditionalPatternPhase:(NSPoint)phase;
+
+- (CGColorSpaceRef)createRGBColorSpace;
+- (CGColorSpaceRef)createGrayColorSpace;
+- (CGColorSpaceRef)createCMYKColorSpace;
+
@end
{
}
+- (CGColorSpaceRef)createRGBColorSpace
+{
+ return 0;
+}
+
+- (CGColorSpaceRef)createGrayColorSpace
+{
+ return 0;
+}
+
+- (CGColorSpaceRef)createCMYKColorSpace
+{
+ return 0;
+}
+
@end
+2004-10-13 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Ken.
+
+ <rdar://problem/3824626> Change to do colormatching for DeviceRGB colorspace causes ~11% Safari slowdown
+
+ - I fixed this by turning off all colormatching for WebKit
+ content. We might turn it back on later. For now, it's possible to
+ turn it on temporarily by defining COLORMATCH_EVERYTHING.
+
+ * WebCoreSupport.subproj/WebGraphicsBridge.m:
+ (-[WebGraphicsBridge setFocusRingStyle:radius:color:]):
+ (-[WebGraphicsBridge additionalPatternPhase]):
+ (-[WebGraphicsBridge createRGBColorSpace]):
+ (-[WebGraphicsBridge createGrayColorSpace]):
+ (-[WebGraphicsBridge createCMYKColorSpace]):
+ * WebCoreSupport.subproj/WebImageData.m:
+ * WebCoreSupport.subproj/WebImageRenderer.h:
+ * WebCoreSupport.subproj/WebImageRenderer.m:
+ (-[WebImageRenderer _adjustSizeToPixelDimensions]):
+ (-[WebImageRenderer incrementalLoadWithBytes:length:complete:]):
+ (-[WebImageRenderer _adjustColorSpace]):
+ (-[WebImageRenderer drawClippedToValidInRect:fromRect:]):
+ (-[WebImageRenderer tileInRect:fromPoint:context:]):
+ (_createImageRef):
+ (WebCGColorSpaceCreateRGB):
+ (WebCGColorSpaceCreateGray):
+ (WebCGColorSpaceCreateCMYK):
+ * WebKitPrefix.h:
+
2004-10-13 Richard Williamson <rjw@apple.com>
Don't fill background with transparency unless debug flag
#import <CoreGraphics/CGContextGState.h>
#import <CoreGraphics/CGStyle.h>
+#import "WebImageRenderer.h"
+
@interface NSView (AppKitSecretsWebGraphicsBridgeKnowsAbout)
- (NSView *)_clipViewAncestor;
@end
if (ringColor) {
float c[4];
[ringColor getRed:&c[0] green:&c[1] blue:&c[2] alpha:&c[3]];
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGColorSpaceRef colorSpace = WebCGColorSpaceCreateRGB();
CGColorRef colorRef = CGColorCreate(colorSpace, c);
CGColorSpaceRelease(colorSpace);
focusRingStyleRef = CGStyleCreateFocusRingWithColor(&focusRingStyle, colorRef);
return _phase;
}
+
+- (CGColorSpaceRef)createRGBColorSpace
+{
+ WebCGColorSpaceCreateRGB();
+}
+
+- (CGColorSpaceRef)createGrayColorSpace
+{
+ WebCGColorSpaceCreateGray();
+}
+
+- (CGColorSpaceRef)createCMYKColorSpace
+{
+ WebCGColorSpaceCreateCMYK();
+}
+
@end
size_t csw = (size_t)fr.size.width;
size_t csh = (size_t)fr.size.height;
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGColorSpaceRef colorSpace = WebCGColorSpaceCreateRGB();
size_t numComponents = CGColorSpaceGetNumberOfComponents(colorSpace);
size_t bytesPerRow = ((csw * 8 * (numComponents+1) + 7)/8); // + 1 for alpha
void *_drawingContextData = malloc(csh * bytesPerRow);
#import <Cocoa/Cocoa.h>
-// Needed for CGCompositeOperation
-#import <CoreGraphics/CGContextPrivate.h>
-
@protocol WebCoreImageRenderer;
//#ifndef OMIT_TIGER_FEATURES
@end
#endif
+
+CGColorSpaceRef WebCGColorSpaceCreateRGB(void);
+CGColorSpaceRef WebCGColorSpaceCreateGray(void);
+CGColorSpaceRef WebCGColorSpaceCreateCMYK(void);
+
+
#import <CoreGraphics/CGContextPrivate.h>
#import <CoreGraphics/CGContextGState.h>
+#import <CoreGraphics/CGColorSpacePrivate.h>
#ifdef USE_CGIMAGEREF
NSBitmapImageRep *imageRep = [[self representations] objectAtIndex:0];
NSSize size = NSMakeSize([imageRep pixelsWide], [imageRep pixelsHigh]);
[imageRep setSize:size];
+
[self setScalesWhenResized:YES];
[self setSize:size];
}
NS_DURING
// Get rep again to avoid bogus compiler warning.
NSBitmapImageRep *aRep = [[self representations] objectAtIndex:0];
+
loadStatus = [aRep incrementalLoadFromData:data complete:isComplete];
NS_HANDLER
loadStatus = NSImageRepLoadStatusInvalidData; // Arbitrary choice; any error will do.
#endif
}
+- (void)_adjustColorSpace
+{
+#if COLORMATCH_EVERYTHING
+ NSArray *reps = [self representations];
+ NSBitmapImageRep *imageRep = [reps count] > 0 ? [[self representations] objectAtIndex:0] : nil;
+ if (imageRep && [imageRep isKindOfClass: [NSBitmapImageRep class]] &&
+ [imageRep valueForProperty:NSImageColorSyncProfileData] == nil &&
+ [[imageRep colorSpaceName] isEqualToString:NSDeviceRGBColorSpace]) {
+ [imageRep setColorSpaceName:NSCalibratedRGBColorSpace];
+ }
+#else
+ NSArray *reps = [self representations];
+ NSBitmapImageRep *imageRep = [reps count] > 0 ? [[self representations] objectAtIndex:0] : nil;
+ if (imageRep && [imageRep isKindOfClass: [NSBitmapImageRep class]] &&
+ [imageRep valueForProperty:NSImageColorSyncProfileData] == nil &&
+ [[imageRep colorSpaceName] isEqualToString:NSCalibratedRGBColorSpace]) {
+ [imageRep setColorSpaceName:NSDeviceRGBColorSpace];
+ }
+#endif
+}
+
- (void)drawClippedToValidInRect:(NSRect)ir fromRect:(NSRect)fr
{
+ [self _adjustColorSpace];
+
if (loadStatus >= 0) {
// The last line might be a partial line, so the number of complete lines is the number
// we get from NSImage minus one.
ASSERT([self isFlipped]);
ASSERT([[NSView focusView] isFlipped]);
+ [self _adjustColorSpace];
+
NSSize size = [self size];
// Check and see if a single draw of the image can cover the entire area we are supposed to tile.
CGImageRef image;
CGDataProviderRef dataProvider;
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ CGColorSpaceRef colorSpace = WebCGColorSpaceCreateRGB();
dataProvider = CGDataProviderCreateWithData(NULL, bitmapData, pixelsHigh * bytesPerRow, NULL);
image = CGImageCreate(pixelsWide, pixelsHigh, bitsPerSample, bitsPerPixel, bytesPerRow, colorSpace,
return image;
}
#endif
+
+CGColorSpaceRef WebCGColorSpaceCreateRGB(void)
+{
+#ifdef COLORMATCH_EVERYTHING
+#if BUILDING_ON_PANTHER
+ return CGColorSpaceCreateWithName(kCGColorSpaceUserRGB);
+#else // !BUILDING_ON_PANTHER
+ return CGColorSpaceCreateDeviceRGB();
+#endif // BUILDING_ON_PANTHER
+#else // !COLORMATCH_EVERYTHING
+#if BUILDING_ONPANTHER
+ return CGColorSpaceCreateDeviceRGB();
+#else // !BUILDING_ON_PANTHER
+ return CGColorSpaceCreateDisplayRGB();
+#endif // BUILDING_ON_PANTHER
+#endif
+}
+
+CGColorSpaceRef WebCGColorSpaceCreateGray(void)
+{
+#ifdef COLORMATCH_EVERYTHING
+#if BUILDING_ON_PANTHER
+ return CGColorSpaceCreateWithName(kCGColorSpaceUserGray);
+#else // !BUILDING_ON_PANTHER
+ return CGColorSpaceCreateDeviceGray();
+#endif // BUILDING_ON_PANTHER
+#else // !COLORMATCH_EVERYTHING
+#if BUILDING_ONPANTHER
+ return CGColorSpaceCreateDeviceGray();
+#else // !BUILDING_ON_PANTHER
+ return CGColorSpaceCreateDisplayGray();
+#endif // BUILDING_ON_PANTHER
+#endif
+}
+
+CGColorSpaceRef WebCGColorSpaceCreateCMYK(void)
+{
+#ifdef COLORMATCH_EVERYTHING
+#if BUILDING_ON_PANTHER
+ return CGColorSpaceCreateWithName(kCGColorSpaceUserCMYK);
+#else // !BUILDING_ON_PANTHER
+ return CGColorSpaceCreateDeviceCMYK();
+#endif // BUILDING_ON_PANTHER
+#else // !COLORMATCH_EVERYTHING
+#if BUILDING_ONPANTHER
+ return CGColorSpaceCreateDeviceCMYK();
+#else // !BUILDING_ON_PANTHER
+ // FIXME: no device CMYK
+ return CGColorSpaceCreateDeviceCMYK();
+#endif // BUILDING_ON_PANTHER
+#endif
+}