summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/mac/GraphicsContextMac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/mac/GraphicsContextMac.mm')
-rw-r--r--WebCore/platform/graphics/mac/GraphicsContextMac.mm24
1 files changed, 11 insertions, 13 deletions
diff --git a/WebCore/platform/graphics/mac/GraphicsContextMac.mm b/WebCore/platform/graphics/mac/GraphicsContextMac.mm
index f3301d8..aa754f2 100644
--- a/WebCore/platform/graphics/mac/GraphicsContextMac.mm
+++ b/WebCore/platform/graphics/mac/GraphicsContextMac.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
#import <AppKit/AppKit.h>
#import <wtf/StdLibExtras.h>
+#import "LocalCurrentGraphicsContext.h"
#import "WebCoreSystemInterface.h"
@class NSColor;
@@ -43,14 +44,14 @@ namespace WebCore {
// calls in this file are all exception-safe, so we don't block
// exceptions for those.
-static void drawFocusRingToContext(CGContextRef context, RetainPtr<CGPathRef> focusRingPath, RetainPtr<CGColorRef> colorRef, int radius)
+static void drawFocusRingToContext(CGContextRef context, CGPathRef focusRingPath, CGColorRef color, int radius)
{
#ifdef BUILDING_ON_TIGER
CGContextBeginTransparencyLayer(context, 0);
#endif
CGContextBeginPath(context);
- CGContextAddPath(context, focusRingPath.get());
- wkDrawFocusRing(context, colorRef.get(), radius);
+ CGContextAddPath(context, focusRingPath);
+ wkDrawFocusRing(context, color, radius);
#ifdef BUILDING_ON_TIGER
CGContextEndTransparencyLayer(context);
#endif
@@ -63,16 +64,14 @@ void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int of
int radius = (width - 1) / 2;
offset += radius;
- RetainPtr<CGColorRef> colorRef;
- if (color.isValid())
- colorRef.adoptCF(createCGColor(color));
-
+ CGColorRef colorRef = color.isValid() ? cachedCGColor(color, ColorSpaceDeviceRGB) : 0;
+
RetainPtr<CGMutablePathRef> focusRingPath(AdoptCF, CGPathCreateMutable());
unsigned pathCount = paths.size();
for (unsigned i = 0; i < pathCount; i++)
CGPathAddPath(focusRingPath.get(), 0, paths[i].platformPath());
- drawFocusRingToContext(platformContext(), focusRingPath, colorRef, radius);
+ drawFocusRingToContext(platformContext(), focusRingPath.get(), colorRef, radius);
}
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
@@ -82,16 +81,14 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int
int radius = (width - 1) / 2;
offset += radius;
- RetainPtr<CGColorRef> colorRef;
- if (color.isValid())
- colorRef.adoptCF(createCGColor(color));
+ CGColorRef colorRef = color.isValid() ? cachedCGColor(color, ColorSpaceDeviceRGB) : 0;
RetainPtr<CGMutablePathRef> focusRingPath(AdoptCF, CGPathCreateMutable());
unsigned rectCount = rects.size();
for (unsigned i = 0; i < rectCount; i++)
CGPathAddRect(focusRingPath.get(), 0, CGRectInset(rects[i], -offset, -offset));
- drawFocusRingToContext(platformContext(), focusRingPath, colorRef, radius);
+ drawFocusRingToContext(platformContext(), focusRingPath.get(), colorRef, radius);
}
#ifdef BUILDING_ON_TIGER // Post-Tiger's setCompositeOperation() is defined in GraphicsContextCG.cpp.
@@ -182,6 +179,7 @@ void GraphicsContext::drawLineForTextChecking(const IntPoint& point, int width,
// for transforms.
// Draw underline.
+ LocalCurrentGraphicsContext localContext(this);
NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
CGContextRef context = (CGContextRef)[currentContext graphicsPort];
CGContextSaveGState(context);