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

Side by Side Diff: chrome/browser/themes/theme_service_mac.mm

Issue 6849030: Add support for multi resolution icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed touchui Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/themes/theme_service.h" 5 #include "chrome/browser/themes/theme_service.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 "chrome/browser/themes/browser_theme_pack.h" 10 #include "chrome/browser/themes/browser_theme_pack.h"
11 #include "skia/ext/skia_utils_mac.h" 11 #include "skia/ext/skia_utils_mac.h"
12 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" 12 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h"
13 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/gfx/color_utils.h" 14 #include "ui/gfx/color_utils.h"
15 #include "ui/gfx/image.h"
14 16
15 NSString* const kBrowserThemeDidChangeNotification = 17 NSString* const kBrowserThemeDidChangeNotification =
16 @"BrowserThemeDidChangeNotification"; 18 @"BrowserThemeDidChangeNotification";
17 19
18 namespace { 20 namespace {
19 21
20 void HSLToHSB(const color_utils::HSL& hsl, CGFloat* h, CGFloat* s, CGFloat* b) { 22 void HSLToHSB(const color_utils::HSL& hsl, CGFloat* h, CGFloat* s, CGFloat* b) {
21 SkColor color = color_utils::HSLToSkColor(hsl, 255); // alpha doesn't matter 23 SkColor color = color_utils::HSLToSkColor(hsl, 255); // alpha doesn't matter
22 SkScalar hsv[3]; 24 SkScalar hsv[3];
23 SkColorToHSV(color, hsv); 25 SkColorToHSV(color, hsv);
(...skipping 13 matching lines...) Expand all
37 39
38 // Check to see if we already have the image in the cache. 40 // Check to see if we already have the image in the cache.
39 NSImageMap::const_iterator nsimage_iter = nsimage_cache_.find(id); 41 NSImageMap::const_iterator nsimage_iter = nsimage_cache_.find(id);
40 if (nsimage_iter != nsimage_cache_.end()) 42 if (nsimage_iter != nsimage_cache_.end())
41 return nsimage_iter->second; 43 return nsimage_iter->second;
42 44
43 // Why don't we load the file directly into the image instead of the whole 45 // Why don't we load the file directly into the image instead of the whole
44 // SkBitmap > native conversion? 46 // SkBitmap > native conversion?
45 // - For consistency with other platforms. 47 // - For consistency with other platforms.
46 // - To get the generated tinted images. 48 // - To get the generated tinted images.
47 SkBitmap* bitmap = GetBitmapNamed(id); 49 NSImage* nsimage = nil;
48 NSImage* nsimage = gfx::SkBitmapToNSImage(*bitmap); 50 if (theme_pack_.get()) {
51 SkBitmap* bitmap = theme_pack_->GetBitmapNamed(id);
52 if (bitmap)
53 nsimage = gfx::SkBitmapToNSImage(*bitmap);
54 }
55
56 if (!nsimage) {
57 nsimage = static_cast<NSImage*>(rb_.GetNativeImageNamed(id));
Robert Sesek 2011/04/15 20:27:20 You can probably get away without the static cast
sail 2011/04/16 01:25:00 Done.
sail 2011/04/16 01:25:00 Done.
58 }
49 59
50 // We loaded successfully. Cache the image. 60 // We loaded successfully. Cache the image.
51 if (nsimage) { 61 if (nsimage) {
52 nsimage_cache_[id] = [nsimage retain]; 62 nsimage_cache_[id] = [nsimage retain];
53 return nsimage; 63 return nsimage;
54 } 64 }
55 65
56 // We failed to retrieve the bitmap, show a debugging red square. 66 // We failed to retrieve the bitmap, show a debugging red square.
57 LOG(WARNING) << "Unable to load NSImage with id " << id; 67 LOG(WARNING) << "Unable to load NSImage with id " << id;
58 NOTREACHED(); // Want to assert in debug mode. 68 NOTREACHED(); // Want to assert in debug mode.
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 314 }
305 nscolor_cache_.clear(); 315 nscolor_cache_.clear();
306 316
307 // Free gradients. 317 // Free gradients.
308 for (NSGradientMap::iterator i = nsgradient_cache_.begin(); 318 for (NSGradientMap::iterator i = nsgradient_cache_.begin();
309 i != nsgradient_cache_.end(); i++) { 319 i != nsgradient_cache_.end(); i++) {
310 [i->second release]; 320 [i->second release];
311 } 321 }
312 nsgradient_cache_.clear(); 322 nsgradient_cache_.clear();
313 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698