summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_theme_provider_mac.mm
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 18:49:07 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 18:49:07 +0000
commit9366cf747481b8fb04f5e76beae807d31d4c6aff (patch)
tree91d2de15704752993dca73abd204087349f439dc /chrome/browser/browser_theme_provider_mac.mm
parent549935ac8361186f358f80b3b15ec31b1329a85a (diff)
downloadchromium_src-9366cf747481b8fb04f5e76beae807d31d4c6aff.zip
chromium_src-9366cf747481b8fb04f5e76beae807d31d4c6aff.tar.gz
chromium_src-9366cf747481b8fb04f5e76beae807d31d4c6aff.tar.bz2
Allow getting the theme tint as a value so that it can be applied independent of the theme provider. Since the Mac needs it to tint its vector resources it's added to the Mac.
BUG=none TEST=none Review URL: http://codereview.chromium.org/151153 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_theme_provider_mac.mm')
-rw-r--r--chrome/browser/browser_theme_provider_mac.mm39
1 files changed, 38 insertions, 1 deletions
diff --git a/chrome/browser/browser_theme_provider_mac.mm b/chrome/browser/browser_theme_provider_mac.mm
index 4c52fe1..300cf70 100644
--- a/chrome/browser/browser_theme_provider_mac.mm
+++ b/chrome/browser/browser_theme_provider_mac.mm
@@ -52,7 +52,37 @@ NSImage* BrowserThemeProvider::GetNSImageNamed(int id) {
return empty_image;
}
-void BrowserThemeProvider::FreePlatformImages() {
+NSColor* BrowserThemeProvider::GetNSColorTint(int id) {
+ DCHECK(CalledOnValidThread());
+
+ // Check to see if we already have the color in the cache.
+ NSColorMap::const_iterator found = nscolor_cache_.find(id);
+ if (found != nscolor_cache_.end())
+ return found->second;
+
+ TintMap::iterator tint_iter = tints_.find(GetTintKey(id));
+ if (tint_iter != tints_.end()) {
+ skia::HSL tint = tint_iter->second;
+
+ // The tint is HSL, not HSB, but we're cheating for now. TODO(avi,alcor):
+ // determine how much this matters and fix it if necessary.
+ // http://crbug.com/15760
+ NSColor* tint_color = [NSColor colorWithCalibratedHue:tint.h
+ saturation:tint.s
+ brightness:tint.l
+ alpha:1.0];
+
+ // We loaded successfully. Cache the color.
+ if (tint_color) {
+ nscolor_cache_[id] = [tint_color retain];
+ return tint_color;
+ }
+ }
+
+ return nil;
+}
+
+void BrowserThemeProvider::FreePlatformCaches() {
DCHECK(CalledOnValidThread());
// Free images.
@@ -61,4 +91,11 @@ void BrowserThemeProvider::FreePlatformImages() {
[i->second release];
}
nsimage_cache_.clear();
+
+ // Free colors.
+ for (NSColorMap::iterator i = nscolor_cache_.begin();
+ i != nscolor_cache_.end(); i++) {
+ [i->second release];
+ }
+ nscolor_cache_.clear();
}