Commit 95e54306 authored by andersca@apple.com's avatar andersca@apple.com

Stop using DEFINE_STATIC_LOCAL with RetainPtr

https://bugs.webkit.org/show_bug.cgi?id=119765

Reviewed by Jessie Berlin.

No need to waste heap memory allocating RetainPtrs, just store the raw pointers directly.

* platform/graphics/mac/ColorMac.mm:
(WebCore::nsColor):
* platform/graphics/mac/GraphicsContextMac.mm:
(WebCore::makePatternColor):
(WebCore::GraphicsContext::drawLineForDocumentMarker):
* platform/graphics/mac/SimpleFontDataMac.mm:
(WebCore::webFallbackFontFamily):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154021 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d1096b36
2013-08-13 Anders Carlsson <andersca@apple.com>
Stop using DEFINE_STATIC_LOCAL with RetainPtr
https://bugs.webkit.org/show_bug.cgi?id=119765
Reviewed by Jessie Berlin.
No need to waste heap memory allocating RetainPtrs, just store the raw pointers directly.
* platform/graphics/mac/ColorMac.mm:
(WebCore::nsColor):
* platform/graphics/mac/GraphicsContextMac.mm:
(WebCore::makePatternColor):
(WebCore::GraphicsContext::drawLineForDocumentMarker):
* platform/graphics/mac/SimpleFontDataMac.mm:
(WebCore::webFallbackFontFamily):
2013-08-13 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r153925.
......@@ -78,16 +78,16 @@ NSColor *nsColor(const Color& color)
switch (c) {
case 0: {
// Need this to avoid returning nil because cachedRGBAValues will default to 0.
DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, clearColor, ([NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:0]));
return clearColor.get();
static NSColor *clearColor = [[NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:0] retain];
return clearColor;
}
case Color::black: {
DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, blackColor, ([NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:1]));
return blackColor.get();
static NSColor *blackColor = [[NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:1] retain];
return blackColor;
}
case Color::white: {
DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, whiteColor, ([NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:1]));
return whiteColor.get();
static NSColor *whiteColor = [[NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:1] retain];
return whiteColor;
}
default: {
const int cacheSize = 32;
......
......@@ -83,7 +83,7 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int
}
static NSColor* createPatternColor(NSString* firstChoiceName, NSString* secondChoiceName, NSColor* defaultColor, bool& usingDot)
static NSColor* makePatternColor(NSString* firstChoiceName, NSString* secondChoiceName, NSColor* defaultColor, bool& usingDot)
{
// Eventually we should be able to get rid of the secondChoiceName. For the time being we need both to keep
// this working on all platforms.
......@@ -116,18 +116,18 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& point, float w
{
// Constants for spelling pattern color.
static bool usingDotForSpelling = false;
DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, spellingPatternColor, (createPatternColor(@"NSSpellingDot", @"SpellingDot", [NSColor redColor], usingDotForSpelling)));
static NSColor *spellingPatternColor = [makePatternColor(@"NSSpellingDot", @"SpellingDot", [NSColor redColor], usingDotForSpelling) retain];
usingDot = usingDotForSpelling;
patternColor = spellingPatternColor.get();
patternColor = spellingPatternColor;
break;
}
case DocumentMarkerGrammarLineStyle:
{
// Constants for grammar pattern color.
static bool usingDotForGrammar = false;
DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, grammarPatternColor, (createPatternColor(@"NSGrammarDot", @"GrammarDot", [NSColor greenColor], usingDotForGrammar)));
static NSColor *grammarPatternColor = [makePatternColor(@"NSGrammarDot", @"GrammarDot", [NSColor greenColor], usingDotForGrammar) retain];
usingDot = usingDotForGrammar;
patternColor = grammarPatternColor.get();
patternColor = grammarPatternColor;
break;
}
#if PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
......@@ -137,9 +137,9 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& point, float w
{
// Constants for spelling pattern color.
static bool usingDotForSpelling = false;
DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, spellingPatternColor, (createPatternColor(@"NSCorrectionDot", @"CorrectionDot", [NSColor blueColor], usingDotForSpelling)));
static NSColor *spellingPatternColor = [makePatternColor(@"NSCorrectionDot", @"CorrectionDot", [NSColor blueColor], usingDotForSpelling) retain];
usingDot = usingDotForSpelling;
patternColor = spellingPatternColor.get();
patternColor = spellingPatternColor;
break;
}
#endif
......
......@@ -74,8 +74,8 @@ static bool initFontData(SimpleFontData* fontData)
static NSString *webFallbackFontFamily(void)
{
DEFINE_STATIC_LOCAL(RetainPtr<NSString>, webFallbackFontFamily, ([[NSFont systemFontOfSize:16.0f] familyName]));
return webFallbackFontFamily.get();
static NSString *webFallbackFontFamily = [[[NSFont systemFontOfSize:16.0f] familyName] retain];
return webFallbackFontFamily;
}
const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont *key) const
......
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