Commit 64866156 authored by eseidel's avatar eseidel

2006-10-01 Eric Seidel <eric@webkit.org>

        Reviewed by mjs.

        Eliminate a few more hotspots in SVG drawing code.
        
        No test cases were harmed in the making of this patch.  (And SVG has no perf tests.)

        * kcanvas/device/quartz/KRenderingPaintServerQuartz.mm:
        (WebCore::KRenderingPaintServerSolidQuartz::setup): use a single shared colorspace, avoid a few mallocs
        * platform/mac/ColorMac.mm:
        (+[WebCoreControlTintObserver WebCore]): store a single shared colorspace instance


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16705 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 747fe72e
2006-10-01 Eric Seidel <eric@webkit.org>
Reviewed by mjs.
Eliminate a few more hotspots in SVG drawing code.
No test cases were harmed in the making of this patch. (And SVG has no perf tests.)
* kcanvas/device/quartz/KRenderingPaintServerQuartz.mm:
(WebCore::KRenderingPaintServerSolidQuartz::setup): use a single shared colorspace, avoid a few mallocs
* platform/mac/ColorMac.mm:
(+[WebCoreControlTintObserver WebCore]): store a single shared colorspace instance
2006-10-01 Geoffrey Garen <ggaren@apple.com>
Reviewed by Maciej.
......@@ -85,13 +85,16 @@ bool KRenderingPaintServerSolidQuartz::setup(KRenderingDeviceContext* renderingC
RenderStyle* renderStyle = renderObject->style();
CGContextSetAlpha(context, renderStyle->opacity());
static CGColorSpaceRef deviceRGBColorSpace = CGColorSpaceCreateDeviceRGB(); // This should be shared from GraphicsContext, or some other central location
if ((type & APPLY_TO_FILL) && KSVGPainterFactory::isFilled(renderStyle)) {
CGColorRef colorCG = cgColor(color());
CGColorRef withAlpha = CGColorCreateCopyWithAlpha(colorCG, KSVGPainterFactory::fillPainter(renderStyle, renderObject).opacity());
CGContextSetFillColorWithColor(context, withAlpha);
CGColorRelease(colorCG);
CGColorRelease(withAlpha);
CGFloat colorComponents[4];
color().getRGBA(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]);
ASSERT(!color().hasAlpha());
colorComponents[3] = renderStyle->svgStyle()->fillOpacity(); // SVG/CSS colors are not specified w/o alpha
CGContextSetFillColorSpace(context, deviceRGBColorSpace);
CGContextSetFillColor(context, colorComponents);
if (isPaintingText()) {
const_cast<RenderObject*>(renderObject)->style()->setColor(color());
CGContextSetTextDrawingMode(context, kCGTextFill);
......@@ -99,11 +102,12 @@ bool KRenderingPaintServerSolidQuartz::setup(KRenderingDeviceContext* renderingC
}
if ((type & APPLY_TO_STROKE) && KSVGPainterFactory::isStroked(renderStyle)) {
CGColorRef colorCG = cgColor(color());
CGColorRef withAlpha = CGColorCreateCopyWithAlpha(colorCG, KSVGPainterFactory::strokePainter(renderStyle, renderObject).opacity());
CGContextSetStrokeColorWithColor(context, withAlpha);
CGColorRelease(colorCG);
CGColorRelease(withAlpha);
CGFloat colorComponents[4];
color().getRGBA(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]);
ASSERT(!color().hasAlpha());
colorComponents[3] = renderStyle->svgStyle()->strokeOpacity(); // SVG/CSS colors are not specified w/o alpha
CGContextSetStrokeColorSpace(context, deviceRGBColorSpace);
CGContextSetStrokeColor(context, colorComponents);
applyStrokeStyleToContext(context, renderStyle, renderObject);
if (isPaintingText()) {
const_cast<RenderObject*>(renderObject)->style()->setColor(color());
......
......@@ -99,9 +99,8 @@ static CGColorRef CGColorFromNSColor(NSColor* color)
CGFloat blue = [deviceColor blueComponent];
CGFloat alpha = [deviceColor alphaComponent];
const CGFloat components[4] = { red, green, blue, alpha };
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef cgColor = CGColorCreate(colorSpace, components);
CGColorSpaceRelease(colorSpace);
static CGColorSpaceRef deviceRGBColorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef cgColor = CGColorCreate(deviceRGBColorSpace, components);
return cgColor;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment