Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/browser/browser_theme_provider_mac.mm

Issue 151153: Allow getting the theme tint as a value so that it can be applied independent... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_theme_provider_gtk.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browser_theme_provider.h" 5 #include "chrome/browser/browser_theme_provider.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "skia/ext/skia_utils_mac.h" 10 #include "skia/ext/skia_utils_mac.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 empty_image = [[NSImage alloc] initWithSize:image_rect.size]; 45 empty_image = [[NSImage alloc] initWithSize:image_rect.size];
46 [empty_image lockFocus]; 46 [empty_image lockFocus];
47 [[NSColor redColor] set]; 47 [[NSColor redColor] set];
48 NSRectFill(image_rect); 48 NSRectFill(image_rect);
49 [empty_image unlockFocus]; 49 [empty_image unlockFocus];
50 } 50 }
51 51
52 return empty_image; 52 return empty_image;
53 } 53 }
54 54
55 void BrowserThemeProvider::FreePlatformImages() { 55 NSColor* BrowserThemeProvider::GetNSColorTint(int id) {
56 DCHECK(CalledOnValidThread());
57
58 // Check to see if we already have the color in the cache.
59 NSColorMap::const_iterator found = nscolor_cache_.find(id);
60 if (found != nscolor_cache_.end())
61 return found->second;
62
63 TintMap::iterator tint_iter = tints_.find(GetTintKey(id));
64 if (tint_iter != tints_.end()) {
65 skia::HSL tint = tint_iter->second;
66
67 // The tint is HSL, not HSB, but we're cheating for now. TODO(avi,alcor):
68 // determine how much this matters and fix it if necessary.
69 // http://crbug.com/15760
70 NSColor* tint_color = [NSColor colorWithCalibratedHue:tint.h
71 saturation:tint.s
72 brightness:tint.l
73 alpha:1.0];
74
75 // We loaded successfully. Cache the color.
76 if (tint_color) {
77 nscolor_cache_[id] = [tint_color retain];
78 return tint_color;
79 }
80 }
81
82 return nil;
83 }
84
85 void BrowserThemeProvider::FreePlatformCaches() {
56 DCHECK(CalledOnValidThread()); 86 DCHECK(CalledOnValidThread());
57 87
58 // Free images. 88 // Free images.
59 for (NSImageMap::iterator i = nsimage_cache_.begin(); 89 for (NSImageMap::iterator i = nsimage_cache_.begin();
60 i != nsimage_cache_.end(); i++) { 90 i != nsimage_cache_.end(); i++) {
61 [i->second release]; 91 [i->second release];
62 } 92 }
63 nsimage_cache_.clear(); 93 nsimage_cache_.clear();
94
95 // Free colors.
96 for (NSColorMap::iterator i = nscolor_cache_.begin();
97 i != nscolor_cache_.end(); i++) {
98 [i->second release];
99 }
100 nscolor_cache_.clear();
64 } 101 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_theme_provider_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698