summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/mac
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-10-22 13:02:20 +0100
committerBen Murdoch <benm@google.com>2010-10-26 15:21:41 +0100
commita94275402997c11dd2e778633dacf4b7e630a35d (patch)
treee66f56c67e3b01f22c9c23cd932271ee9ac558ed /WebCore/platform/graphics/mac
parent09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff)
downloadexternal_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip
external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz
external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'WebCore/platform/graphics/mac')
-rw-r--r--WebCore/platform/graphics/mac/ColorMac.mm24
-rw-r--r--WebCore/platform/graphics/mac/GraphicsContext3DMac.mm4
-rw-r--r--WebCore/platform/graphics/mac/GraphicsContextMac.mm24
-rw-r--r--WebCore/platform/graphics/mac/GraphicsLayerCA.mm12
4 files changed, 20 insertions, 44 deletions
diff --git a/WebCore/platform/graphics/mac/ColorMac.mm b/WebCore/platform/graphics/mac/ColorMac.mm
index c8ea9b1..07d6353 100644
--- a/WebCore/platform/graphics/mac/ColorMac.mm
+++ b/WebCore/platform/graphics/mac/ColorMac.mm
@@ -88,14 +88,15 @@ NSColor *nsColor(const Color& color)
static unsigned cachedRGBAValues[cacheSize];
static RetainPtr<NSColor>* cachedColors = new RetainPtr<NSColor>[cacheSize];
- for (int i = 0; i != cacheSize; ++i)
+ for (int i = 0; i != cacheSize; ++i) {
if (cachedRGBAValues[i] == c)
return cachedColors[i].get();
+ }
NSColor *result = [NSColor colorWithDeviceRed:static_cast<CGFloat>(color.red()) / 255
green:static_cast<CGFloat>(color.green()) / 255
blue:static_cast<CGFloat>(color.blue()) / 255
- alpha:static_cast<CGFloat>(color.alpha()) /255];
+ alpha:static_cast<CGFloat>(color.alpha()) / 255];
static int cursor;
cachedRGBAValues[cursor] = c;
@@ -107,24 +108,5 @@ NSColor *nsColor(const Color& color)
}
}
-static CGColorRef CGColorFromNSColor(NSColor *color)
-{
- // This needs to always use device colorspace so it can de-calibrate the color for
- // CGColor to possibly recalibrate it.
- CGFloat components[4];
- NSColor *deviceColor = [color colorUsingColorSpaceName:NSDeviceRGBColorSpace];
- [deviceColor getRed:&components[0] green:&components[1] blue:&components[2] alpha:&components[3]];
- static CGColorSpaceRef deviceRGBColorSpace = CGColorSpaceCreateDeviceRGB();
- CGColorRef cgColor = CGColorCreate(deviceRGBColorSpace, components);
- return cgColor;
-}
-
-CGColorRef createCGColor(const Color& c)
-{
- // We could directly create a CGColor here, but that would
- // skip any RGB caching the nsColor method does. A direct
- // creation could be investigated for a possible performance win.
- return CGColorFromNSColor(nsColor(c));
-}
} // namespace WebCore
diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
index a4919d8..e079b44 100644
--- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
+++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
@@ -77,12 +77,12 @@ static void setPixelFormat(Vector<CGLPixelFormatAttribute>& attribs, int colorBi
attribs.append(static_cast<CGLPixelFormatAttribute>(0));
}
-PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
+PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
{
// This implementation doesn't currently support rendering directly to the HostWindow.
if (renderStyle == RenderDirectlyToHostWindow)
return 0;
- OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs, hostWindow, false));
+ RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false));
return context->m_contextObj ? context.release() : 0;
}
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);
diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
index d4cd851..c4128ef 100644
--- a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
+++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
@@ -38,7 +38,6 @@
#import <QuartzCore/QuartzCore.h>
#import "RotateTransformOperation.h"
#import "ScaleTransformOperation.h"
-#import "StringBuilder.h"
#import "SystemTime.h"
#import "TranslateTransformOperation.h"
#import "WebLayer.h"
@@ -48,6 +47,7 @@
#import <wtf/CurrentTime.h>
#import <wtf/UnusedParam.h>
#import <wtf/RetainPtr.h>
+#import <wtf/text/StringConcatenate.h>
using namespace std;
@@ -248,7 +248,7 @@ static String propertyIdToString(AnimatedPropertyID property)
static String animationIdentifier(const String& animationName, AnimatedPropertyID property, int index)
{
- return animationName + String::format("_%d_%d", property, index);
+ return makeString(animationName, '_', String::number(property), '_', String::number(index));
}
static CAMediaTimingFunction* getCAMediaTimingFunction(const TimingFunction* timingFunction)
@@ -265,9 +265,7 @@ static CAMediaTimingFunction* getCAMediaTimingFunction(const TimingFunction* tim
static void setLayerBorderColor(PlatformLayer* layer, const Color& color)
{
- CGColorRef borderColor = createCGColor(color);
- [layer setBorderColor:borderColor];
- CGColorRelease(borderColor);
+ [layer setBorderColor:cachedCGColor(color, ColorSpaceDeviceRGB)];
}
static void clearBorderColor(PlatformLayer* layer)
@@ -277,9 +275,7 @@ static void clearBorderColor(PlatformLayer* layer)
static void setLayerBackgroundColor(PlatformLayer* layer, const Color& color)
{
- CGColorRef bgColor = createCGColor(color);
- [layer setBackgroundColor:bgColor];
- CGColorRelease(bgColor);
+ [layer setBackgroundColor:cachedCGColor(color, ColorSpaceDeviceRGB)];
}
static void clearLayerBackgroundColor(PlatformLayer* layer)