WebCore:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Oct 2004 01:26:54 +0000 (01:26 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Oct 2004 01:26:54 +0000 (01:26 +0000)
        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

13 files changed:
WebCore/ChangeLog-2005-08-23
WebCore/khtml/ecma/kjs_html.cpp
WebCore/khtml/rendering/render_canvasimage.cpp
WebCore/kwq/KWQColor.mm
WebCore/kwq/KWQPainter.h
WebCore/kwq/KWQPainter.mm
WebCore/kwq/WebCoreGraphicsBridge.h
WebCore/kwq/WebCoreGraphicsBridge.m
WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebGraphicsBridge.m
WebKit/WebCoreSupport.subproj/WebImageData.m
WebKit/WebCoreSupport.subproj/WebImageRenderer.h
WebKit/WebCoreSupport.subproj/WebImageRenderer.m

index bfa50b0..97a8f56 100644 (file)
@@ -1,3 +1,35 @@
+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
index 673ed51..6945c72 100644 (file)
@@ -59,6 +59,7 @@
 
 #include "qcolor.h"
 #include "qpixmap.h"
+#include "qpainter.h"
 
 #include <ApplicationServices/ApplicationServices.h>
 
@@ -3912,12 +3913,12 @@ Value KJS::Context2DFunction::tryCall(ExecState *exec, Object &thisObj, const Li
                             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;
@@ -3930,12 +3931,12 @@ Value KJS::Context2DFunction::tryCall(ExecState *exec, Object &thisObj, const Li
                             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;
@@ -3944,7 +3945,7 @@ Value KJS::Context2DFunction::tryCall(ExecState *exec, Object &thisObj, const Li
                         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: {
@@ -3954,7 +3955,7 @@ Value KJS::Context2DFunction::tryCall(ExecState *exec, Object &thisObj, const Li
                         components[3] = (float)args[6].toNumber(exec); // k
                         components[4] = (float)args[7].toNumber(exec); // a
 
-                        colorSpace = CGColorSpaceCreateDeviceCMYK();
+                        colorSpace = QPainter::cmykColorSpace();
                     }
                     break;
                     default: {
@@ -4097,7 +4098,7 @@ Value KJS::Context2DFunction::tryCall(ExecState *exec, Object &thisObj, const Li
                     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);
@@ -4393,7 +4394,7 @@ CGColorRef Context2D::colorRefFromValue(ExecState *exec, const Value &value)
         components[1] = qc.green()/255.;
         components[2] = qc.blue()/255.;
         components[3] = qc.alpha();
-        colorSpace = CGColorSpaceCreateDeviceRGB();
+        colorSpace = QPainter::rgbColorSpace();
     }
     else
         return 0;
@@ -4827,7 +4828,7 @@ CGShadingRef Gradient::getShading()
         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);
index 45192b6..8fb3410 100644 (file)
@@ -90,7 +90,7 @@ void RenderCanvasImage::createDrawingContext()
         _drawingContext = 0;
     }
     free (_drawingContextData);
-    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+    CGColorSpaceRef colorSpace = QPainter::rgbColorSpace();
 
     int cWidth = contentWidth();
     int cHeight = contentHeight();
index af3f96f..f3a6071 100644 (file)
@@ -245,10 +245,17 @@ NSColor *QColor::getNSColor() const
                 }
             }
 
+#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;
index ba9675e..094204a 100644 (file)
@@ -138,6 +138,10 @@ public:
     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 &);
index ae844f2..f01014a 100644 (file)
@@ -73,14 +73,16 @@ struct QPainterPrivate {
 
 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;
@@ -734,7 +736,9 @@ static int getBlendedColorComponent(int c, int a)
 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]));
     
@@ -904,3 +908,20 @@ void QPainter::clearFocusRing()
         data->focusRingPath = nil;
     }
 }
+
+CGColorSpaceRef QPainter::rgbColorSpace()
+{
+    return [[WebCoreGraphicsBridge sharedBridge] createRGBColorSpace];
+}
+
+CGColorSpaceRef QPainter::grayColorSpace()
+{
+    return [[WebCoreGraphicsBridge sharedBridge] createGrayColorSpace];
+}
+
+CGColorSpaceRef QPainter::cmykColorSpace()
+{
+    return [[WebCoreGraphicsBridge sharedBridge] createCMYKColorSpace];
+}
+
+
index f7f9a5f..d096901 100644 (file)
@@ -31,4 +31,9 @@
 - (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
index 475de80..15696f7 100644 (file)
@@ -58,4 +58,19 @@ static WebCoreGraphicsBridge *sharedBridge;
 {
 }
 
+- (CGColorSpaceRef)createRGBColorSpace
+{
+    return 0;
+}
+
+- (CGColorSpaceRef)createGrayColorSpace
+{
+    return 0;
+}
+
+- (CGColorSpaceRef)createCMYKColorSpace
+{
+    return 0;
+}
+
 @end
index 957d9a0..569c56d 100644 (file)
@@ -1,3 +1,33 @@
+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
index 8706efd..9224c27 100644 (file)
@@ -39,6 +39,8 @@
 #import <CoreGraphics/CGContextGState.h>
 #import <CoreGraphics/CGStyle.h>
 
+#import "WebImageRenderer.h"
+
 @interface NSView (AppKitSecretsWebGraphicsBridgeKnowsAbout)
 - (NSView *)_clipViewAncestor;
 @end
@@ -88,7 +90,7 @@
     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);
@@ -205,4 +207,20 @@ static void FlipImageSpec(CoreDragImageSpec* imageSpec) {
     return _phase;
 }
 
+
+- (CGColorSpaceRef)createRGBColorSpace
+{
+    WebCGColorSpaceCreateRGB();
+}
+
+- (CGColorSpaceRef)createGrayColorSpace
+{
+    WebCGColorSpaceCreateGray();
+}
+
+- (CGColorSpaceRef)createCMYKColorSpace
+{
+    WebCGColorSpaceCreateCMYK();
+}
+
 @end
index b5ad21b..74c1cc6 100644 (file)
@@ -207,7 +207,7 @@ static CFDictionaryRef imageSourceOptions;
         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);
index 54bd293..ecaa6b1 100644 (file)
@@ -4,9 +4,6 @@
 
 #import <Cocoa/Cocoa.h>
 
-// Needed for CGCompositeOperation
-#import <CoreGraphics/CGContextPrivate.h>
-
 @protocol WebCoreImageRenderer;
 
 //#ifndef OMIT_TIGER_FEATURES
@@ -92,3 +89,9 @@
 @end
 
 #endif
+
+CGColorSpaceRef WebCGColorSpaceCreateRGB(void);
+CGColorSpaceRef WebCGColorSpaceCreateGray(void);
+CGColorSpaceRef WebCGColorSpaceCreateCMYK(void);
+
+
index 9732f6f..01bbaea 100644 (file)
@@ -13,6 +13,7 @@
 
 #import <CoreGraphics/CGContextPrivate.h>
 #import <CoreGraphics/CGContextGState.h>
+#import <CoreGraphics/CGColorSpacePrivate.h>
 
 
 #ifdef USE_CGIMAGEREF
@@ -530,6 +531,7 @@ static NSMutableSet *activeImageRenderers;
     NSBitmapImageRep *imageRep = [[self representations] objectAtIndex:0];
     NSSize size = NSMakeSize([imageRep pixelsWide], [imageRep pixelsHigh]);
     [imageRep setSize:size];
+        
     [self setScalesWhenResized:YES];
     [self setSize:size];
 }
@@ -545,6 +547,7 @@ static NSMutableSet *activeImageRenderers;
         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.
@@ -745,9 +748,32 @@ static NSMutableSet *activeImageRenderers;
 #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.
@@ -963,6 +989,8 @@ static NSMutableSet *activeImageRenderers;
     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.
@@ -1221,7 +1249,7 @@ static CGImageRef _createImageRef(NSBitmapImageRep *rep) {
     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,
@@ -1234,3 +1262,55 @@ static CGImageRef _createImageRef(NSBitmapImageRep *rep) {
     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    
+}