Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 | 72 |
| 73 // Check to see if we already have the color in the cache. | 73 // Check to see if we already have the color in the cache. |
| 74 NSColorMap::const_iterator found = nscolor_cache_.find(id); | 74 NSColorMap::const_iterator found = nscolor_cache_.find(id); |
| 75 if (found != nscolor_cache_.end()) | 75 if (found != nscolor_cache_.end()) |
| 76 return found->second; | 76 return found->second; |
| 77 | 77 |
| 78 ColorMap::iterator color_iter = colors_.find(GetColorKey(id)); | 78 ColorMap::iterator color_iter = colors_.find(GetColorKey(id)); |
| 79 if (color_iter != colors_.end()) { | 79 if (color_iter != colors_.end()) { |
| 80 const SkColor& sk_color = color_iter->second; | 80 const SkColor& sk_color = color_iter->second; |
| 81 | 81 |
| 82 NSColor* color = [NSColor colorWithCalibratedRed:SkColorGetR(sk_color) | 82 |
| 83 green:SkColorGetG(sk_color) | 83 NSColor* color = [NSColor |
| 84 blue:SkColorGetB(sk_color) | 84 colorWithCalibratedRed:SkColorGetR(sk_color)/255.0 |
| 85 alpha:SkColorGetA(sk_color)]; | 85 green:SkColorGetG(sk_color)/255.0 |
| 86 blue:SkColorGetB(sk_color)/255.0 | |
| 87 alpha:SkColorGetA(sk_color)/255.0]; | |
|
Avi (use Gerrit)
2009/09/08 14:47:43
Yes, I am appropriately embarrassed. :)
| |
| 86 | 88 |
| 87 // We loaded successfully. Cache the color. | 89 // We loaded successfully. Cache the color. |
| 88 if (color) { | 90 if (color) { |
| 89 nscolor_cache_[id] = [color retain]; | 91 nscolor_cache_[id] = [color retain]; |
| 90 return color; | 92 return color; |
| 91 } | 93 } |
| 92 } | 94 } |
| 93 | 95 |
| 94 return nil; | 96 return nil; |
| 95 } | 97 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 } | 135 } |
| 134 nsimage_cache_.clear(); | 136 nsimage_cache_.clear(); |
| 135 | 137 |
| 136 // Free colors. | 138 // Free colors. |
| 137 for (NSColorMap::iterator i = nscolor_cache_.begin(); | 139 for (NSColorMap::iterator i = nscolor_cache_.begin(); |
| 138 i != nscolor_cache_.end(); i++) { | 140 i != nscolor_cache_.end(); i++) { |
| 139 [i->second release]; | 141 [i->second release]; |
| 140 } | 142 } |
| 141 nscolor_cache_.clear(); | 143 nscolor_cache_.clear(); |
| 142 } | 144 } |
| OLD | NEW |