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

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

Issue 162010: Allow theming of colors for the Mac. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 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.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.h" 10 #include "skia/ext/skia_utils.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 empty_image = [[NSImage alloc] initWithSize:image_rect.size]; 60 empty_image = [[NSImage alloc] initWithSize:image_rect.size];
61 [empty_image lockFocus]; 61 [empty_image lockFocus];
62 [[NSColor redColor] set]; 62 [[NSColor redColor] set];
63 NSRectFill(image_rect); 63 NSRectFill(image_rect);
64 [empty_image unlockFocus]; 64 [empty_image unlockFocus];
65 } 65 }
66 66
67 return empty_image; 67 return empty_image;
68 } 68 }
69 69
70 NSColor* BrowserThemeProvider::GetNSColor(int id) {
71 DCHECK(CalledOnValidThread());
72
73 // Check to see if we already have the color in the cache.
74 NSColorMap::const_iterator found = nscolor_cache_.find(id);
75 if (found != nscolor_cache_.end())
76 return found->second;
77
78 ColorMap::iterator color_iter = colors_.find(GetColorKey(id));
79 if (color_iter != colors_.end()) {
80 const SkColor& sk_color = color_iter->second;
81
82 NSColor* color = [NSColor colorWithCalibratedRed:SkColorGetR(sk_color)
Nico 2009/09/05 21:20:23 Come on guys. NSColor wants its channels in [0.0..
83 green:SkColorGetG(sk_color)
84 blue:SkColorGetB(sk_color)
85 alpha:SkColorGetA(sk_color)];
86
87 // We loaded successfully. Cache the color.
88 if (color) {
89 nscolor_cache_[id] = [color retain];
90 return color;
91 }
92 }
93
94 return nil;
95 }
96
70 NSColor* BrowserThemeProvider::GetNSColorTint(int id) { 97 NSColor* BrowserThemeProvider::GetNSColorTint(int id) {
71 DCHECK(CalledOnValidThread()); 98 DCHECK(CalledOnValidThread());
72 99
73 // Check to see if we already have the color in the cache. 100 // Check to see if we already have the color in the cache.
74 NSColorMap::const_iterator found = nscolor_cache_.find(id); 101 NSColorMap::const_iterator found = nscolor_cache_.find(id);
75 if (found != nscolor_cache_.end()) 102 if (found != nscolor_cache_.end())
76 return found->second; 103 return found->second;
77 104
78 TintMap::iterator tint_iter = tints_.find(GetTintKey(id)); 105 TintMap::iterator tint_iter = tints_.find(GetTintKey(id));
79 if (tint_iter != tints_.end()) { 106 if (tint_iter != tints_.end()) {
(...skipping 26 matching lines...) Expand all
106 } 133 }
107 nsimage_cache_.clear(); 134 nsimage_cache_.clear();
108 135
109 // Free colors. 136 // Free colors.
110 for (NSColorMap::iterator i = nscolor_cache_.begin(); 137 for (NSColorMap::iterator i = nscolor_cache_.begin();
111 i != nscolor_cache_.end(); i++) { 138 i != nscolor_cache_.end(); i++) {
112 [i->second release]; 139 [i->second release];
113 } 140 }
114 nscolor_cache_.clear(); 141 nscolor_cache_.clear();
115 } 142 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_theme_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698